From 36315ecc53f2d8772fc3bcfe255e0eaf0df2ee4b Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 15 Nov 2022 03:04:36 +0000 Subject: [PATCH 1/4] feat: added Sku.geo_taxonomy fix: more oauth scopes PiperOrigin-RevId: 488493014 Source-Link: https://github.com/googleapis/googleapis/commit/8995a8817642b3a209103677012521f953616011 Source-Link: https://github.com/googleapis/googleapis-gen/commit/adbfce0c0e59b1b38bb8e81ae9a3d0b408e7f7c0 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpbGxpbmcvLk93bEJvdC55YW1sIiwiaCI6ImFkYmZjZTBjMGU1OWIxYjM4YmI4ZTgxYWU5YTNkMGI0MDhlN2Y3YzAifQ== --- .../google-cloud-billing/v1/.eslintignore | 7 + .../google-cloud-billing/v1/.eslintrc.json | 3 + .../google-cloud-billing/v1/.gitignore | 14 + .../google-cloud-billing/v1/.jsdoc.js | 55 + .../google-cloud-billing/v1/.mocharc.js | 33 + .../google-cloud-billing/v1/.prettierrc.js | 22 + .../google-cloud-billing/v1/README.md | 1 + .../v1/linkinator.config.json | 16 + .../google-cloud-billing/v1/package.json | 65 + .../cloud/billing/v1/cloud_billing.proto | 373 ++++ .../cloud/billing/v1/cloud_catalog.proto | 363 ++++ .../cloud_billing.create_billing_account.js | 64 + .../v1/cloud_billing.get_billing_account.js | 62 + .../v1/cloud_billing.get_iam_policy.js | 67 + .../cloud_billing.get_project_billing_info.js | 62 + .../v1/cloud_billing.list_billing_accounts.js | 78 + ...cloud_billing.list_project_billing_info.js | 75 + .../v1/cloud_billing.set_iam_policy.js | 77 + .../v1/cloud_billing.test_iam_permissions.js | 70 + .../cloud_billing.update_billing_account.js | 71 + ...oud_billing.update_project_billing_info.js | 67 + .../v1/cloud_catalog.list_services.js | 68 + .../generated/v1/cloud_catalog.list_skus.js | 98 ++ ...ppet_metadata.google.cloud.billing.v1.json | 563 ++++++ .../google-cloud-billing/v1/src/index.ts | 27 + .../v1/src/v1/cloud_billing_client.ts | 1454 ++++++++++++++++ .../src/v1/cloud_billing_client_config.json | 76 + .../v1/src/v1/cloud_billing_proto_list.json | 4 + .../v1/src/v1/cloud_catalog_client.ts | 788 +++++++++ .../src/v1/cloud_catalog_client_config.json | 36 + .../v1/src/v1/cloud_catalog_proto_list.json | 4 + .../v1/src/v1/gapic_metadata.json | 173 ++ .../google-cloud-billing/v1/src/v1/index.ts | 20 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1/system-test/install.ts | 49 + .../v1/test/gapic_cloud_billing_v1.ts | 1549 +++++++++++++++++ .../v1/test/gapic_cloud_catalog_v1.ts | 688 ++++++++ .../google-cloud-billing/v1/tsconfig.json | 19 + .../google-cloud-billing/v1/webpack.config.js | 64 + 40 files changed, 7391 insertions(+) create mode 100644 owl-bot-staging/google-cloud-billing/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-billing/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-billing/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/README.md create mode 100644 owl-bot-staging/google-cloud-billing/v1/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/package.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto create mode 100644 owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_billing_v1.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/webpack.config.js diff --git a/owl-bot-staging/google-cloud-billing/v1/.eslintignore b/owl-bot-staging/google-cloud-billing/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-billing/v1/.eslintrc.json b/owl-bot-staging/google-cloud-billing/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-billing/v1/.gitignore b/owl-bot-staging/google-cloud-billing/v1/.gitignore new file mode 100644 index 00000000000..5d32b23782f --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/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-billing/v1/.jsdoc.js b/owl-bot-staging/google-cloud-billing/v1/.jsdoc.js new file mode 100644 index 00000000000..a1fe10efe19 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/billing', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-billing/v1/.mocharc.js b/owl-bot-staging/google-cloud-billing/v1/.mocharc.js new file mode 100644 index 00000000000..481c522b00f --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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-billing/v1/.prettierrc.js b/owl-bot-staging/google-cloud-billing/v1/.prettierrc.js new file mode 100644 index 00000000000..494e147865d --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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-billing/v1/README.md b/owl-bot-staging/google-cloud-billing/v1/README.md new file mode 100644 index 00000000000..4f22cab915e --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/README.md @@ -0,0 +1 @@ +Billing: Nodejs Client diff --git a/owl-bot-staging/google-cloud-billing/v1/linkinator.config.json b/owl-bot-staging/google-cloud-billing/v1/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/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-billing/v1/package.json b/owl-bot-staging/google-cloud-billing/v1/package.json new file mode 100644 index 00000000000..761cb3cfd5d --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/billing", + "version": "0.1.0", + "description": "Billing client for Node.js", + "repository": "googleapis/nodejs-billing", + "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 billing", + "billing", + "cloud billing", + "cloud catalog" + ], + "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.2" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.62", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.0.3", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.3", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto b/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto new file mode 100644 index 00000000000..b98f0fd7c26 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto @@ -0,0 +1,373 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.billing.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/protobuf/field_mask.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/billing/v1;billing"; +option java_multiple_files = true; +option java_outer_classname = "CloudBillingProto"; +option java_package = "com.google.cloud.billing.v1"; + +// Retrieves the Google Cloud Console billing accounts and associates them with +// projects. +service CloudBilling { + option (google.api.default_host) = "cloudbilling.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-billing," + "https://www.googleapis.com/auth/cloud-billing.readonly," + "https://www.googleapis.com/auth/cloud-platform"; + + // Gets information about a billing account. The current authenticated user + // must be a [viewer of the billing + // account](https://cloud.google.com/billing/docs/how-to/billing-access). + rpc GetBillingAccount(GetBillingAccountRequest) returns (BillingAccount) { + option (google.api.http) = { + get: "/v1/{name=billingAccounts/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists the billing accounts that the current authenticated user has + // permission to + // [view](https://cloud.google.com/billing/docs/how-to/billing-access). + rpc ListBillingAccounts(ListBillingAccountsRequest) returns (ListBillingAccountsResponse) { + option (google.api.http) = { + get: "/v1/billingAccounts" + }; + option (google.api.method_signature) = ""; + } + + // Updates a billing account's fields. + // Currently the only field that can be edited is `display_name`. + // The current authenticated user must have the `billing.accounts.update` + // IAM permission, which is typically given to the + // [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) + // of the billing account. + rpc UpdateBillingAccount(UpdateBillingAccountRequest) returns (BillingAccount) { + option (google.api.http) = { + patch: "/v1/{name=billingAccounts/*}" + body: "account" + }; + option (google.api.method_signature) = "name,account"; + } + + // This method creates [billing + // subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). + // + // Google Cloud resellers should use the + // Channel Services APIs, + // [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) + // and + // [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). + // + // When creating a subaccount, the current authenticated user must have the + // `billing.accounts.update` IAM permission on the parent account, which is + // typically given to billing account + // [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). + // This method will return an error if the parent account has not been + // provisioned as a reseller account. + rpc CreateBillingAccount(CreateBillingAccountRequest) returns (BillingAccount) { + option (google.api.http) = { + post: "/v1/billingAccounts" + body: "billing_account" + }; + option (google.api.method_signature) = "billing_account"; + } + + // Lists the projects associated with a billing account. The current + // authenticated user must have the `billing.resourceAssociations.list` IAM + // permission, which is often given to billing account + // [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). + rpc ListProjectBillingInfo(ListProjectBillingInfoRequest) returns (ListProjectBillingInfoResponse) { + option (google.api.http) = { + get: "/v1/{name=billingAccounts/*}/projects" + }; + option (google.api.method_signature) = "name"; + } + + // Gets the billing information for a project. The current authenticated user + // must have the `resourcemanager.projects.get` permission for the project, + // which can be granted by assigning the [Project + // Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) + // role. + rpc GetProjectBillingInfo(GetProjectBillingInfoRequest) returns (ProjectBillingInfo) { + option (google.api.http) = { + get: "/v1/{name=projects/*}/billingInfo" + }; + option (google.api.method_signature) = "name"; + } + + // Sets or updates the billing account associated with a project. You specify + // the new billing account by setting the `billing_account_name` in the + // `ProjectBillingInfo` resource to the resource name of a billing account. + // Associating a project with an open billing account enables billing on the + // project and allows charges for resource usage. If the project already had a + // billing account, this method changes the billing account used for resource + // usage charges. + // + // *Note:* Incurred charges that have not yet been reported in the transaction + // history of the Google Cloud Console might be billed to the new billing + // account, even if the charge occurred before the new billing account was + // assigned to the project. + // + // The current authenticated user must have ownership privileges for both the + // [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo + // ) and the [billing + // account](https://cloud.google.com/billing/docs/how-to/billing-access). + // + // You can disable billing on the project by setting the + // `billing_account_name` field to empty. This action disassociates the + // current billing account from the project. Any billable activity of your + // in-use services will stop, and your application could stop functioning as + // expected. Any unbilled charges to date will be billed to the previously + // associated account. The current authenticated user must be either an owner + // of the project or an owner of the billing account for the project. + // + // Note that associating a project with a *closed* billing account will have + // much the same effect as disabling billing on the project: any paid + // resources used by the project will be shut down. Thus, unless you wish to + // disable billing, you should always call this method with the name of an + // *open* billing account. + rpc UpdateProjectBillingInfo(UpdateProjectBillingInfoRequest) returns (ProjectBillingInfo) { + option (google.api.http) = { + put: "/v1/{name=projects/*}/billingInfo" + body: "project_billing_info" + }; + option (google.api.method_signature) = "name,project_billing_info"; + } + + // Gets the access control policy for a billing account. + // The caller must have the `billing.accounts.getIamPolicy` permission on the + // account, which is often given to billing account + // [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + get: "/v1/{resource=billingAccounts/*}:getIamPolicy" + }; + option (google.api.method_signature) = "resource"; + } + + // Sets the access control policy for a billing account. Replaces any existing + // policy. + // The caller must have the `billing.accounts.setIamPolicy` permission on the + // account, which is often given to billing account + // [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v1/{resource=billingAccounts/*}:setIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource,policy"; + } + + // Tests the access control policy for a billing account. This method takes + // the resource and a set of permissions as input and returns the subset of + // the input permissions that the caller is allowed for that resource. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v1/{resource=billingAccounts/*}:testIamPermissions" + body: "*" + }; + option (google.api.method_signature) = "resource,permissions"; + } +} + +// A billing account in the +// [Google Cloud Console](https://console.cloud.google.com/). You can assign a +// billing account to one or more projects. +message BillingAccount { + // Output only. The resource name of the billing account. The resource name has the form + // `billingAccounts/{billing_account_id}`. For example, + // `billingAccounts/012345-567890-ABCDEF` would be the resource name for + // billing account `012345-567890-ABCDEF`. + string name = 1 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "cloudbilling.googleapis.com/BillingAccount" + } + ]; + + // Output only. True if the billing account is open, and will therefore be charged for any + // usage on associated projects. False if the billing account is closed, and + // therefore projects associated with it will be unable to use paid services. + bool open = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The display name given to the billing account, such as `My Billing + // Account`. This name is displayed in the Google Cloud Console. + string display_name = 3; + + // If this account is a + // [subaccount](https://cloud.google.com/billing/docs/concepts), then this + // will be the resource name of the parent billing account that it is being + // resold through. + // Otherwise this will be empty. + string master_billing_account = 4; +} + +// Encapsulation of billing information for a Google Cloud Console project. A +// project has at most one associated billing account at a time (but a billing +// account can be assigned to multiple projects). +message ProjectBillingInfo { + // The resource name for the `ProjectBillingInfo`; has the form + // `projects/{project_id}/billingInfo`. For example, the resource name for the + // billing information for project `tokyo-rain-123` would be + // `projects/tokyo-rain-123/billingInfo`. This field is read-only. + string name = 1; + + // The ID of the project that this `ProjectBillingInfo` represents, such as + // `tokyo-rain-123`. This is a convenience field so that you don't need to + // parse the `name` field to obtain a project ID. This field is read-only. + string project_id = 2; + + // The resource name of the billing account associated with the project, if + // any. For example, `billingAccounts/012345-567890-ABCDEF`. + string billing_account_name = 3; + + // True if the project is associated with an open billing account, to which + // usage on the project is charged. False if the project is associated with a + // closed billing account, or no billing account at all, and therefore cannot + // use paid services. This field is read-only. + bool billing_enabled = 4; +} + +// Request message for `GetBillingAccount`. +message GetBillingAccountRequest { + // Required. The resource name of the billing account to retrieve. For example, + // `billingAccounts/012345-567890-ABCDEF`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudbilling.googleapis.com/BillingAccount" + } + ]; +} + +// Request message for `ListBillingAccounts`. +message ListBillingAccountsRequest { + // Requested page size. The maximum page size is 100; this is also the + // default. + int32 page_size = 1; + + // A token identifying a page of results to return. This should be a + // `next_page_token` value returned from a previous `ListBillingAccounts` + // call. If unspecified, the first page of results is returned. + string page_token = 2; + + // Options for how to filter the returned billing accounts. + // Currently this only supports filtering for + // [subaccounts](https://cloud.google.com/billing/docs/concepts) under a + // single provided reseller billing account. + // (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). + // Boolean algebra and other fields are not currently supported. + string filter = 3; +} + +// Response message for `ListBillingAccounts`. +message ListBillingAccountsResponse { + // A list of billing accounts. + repeated BillingAccount billing_accounts = 1; + + // A token to retrieve the next page of results. To retrieve the next page, + // call `ListBillingAccounts` again with the `page_token` field set to this + // value. This field is empty if there are no more results to retrieve. + string next_page_token = 2; +} + +// Request message for `CreateBillingAccount`. +message CreateBillingAccountRequest { + // Required. The billing account resource to create. + // Currently CreateBillingAccount only supports subaccount creation, so + // any created billing accounts must be under a provided parent billing + // account. + BillingAccount billing_account = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for `UpdateBillingAccount`. +message UpdateBillingAccountRequest { + // Required. The name of the billing account resource to be updated. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudbilling.googleapis.com/BillingAccount" + } + ]; + + // Required. The billing account resource to replace the resource on the server. + BillingAccount account = 2 [(google.api.field_behavior) = REQUIRED]; + + // The update mask applied to the resource. + // Only "display_name" is currently supported. + google.protobuf.FieldMask update_mask = 3; +} + +// Request message for `ListProjectBillingInfo`. +message ListProjectBillingInfoRequest { + // Required. The resource name of the billing account associated with the projects that + // you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudbilling.googleapis.com/BillingAccount" + } + ]; + + // Requested page size. The maximum page size is 100; this is also the + // default. + int32 page_size = 2; + + // A token identifying a page of results to be returned. This should be a + // `next_page_token` value returned from a previous `ListProjectBillingInfo` + // call. If unspecified, the first page of results is returned. + string page_token = 3; +} + +// Request message for `ListProjectBillingInfoResponse`. +message ListProjectBillingInfoResponse { + // A list of `ProjectBillingInfo` resources representing the projects + // associated with the billing account. + repeated ProjectBillingInfo project_billing_info = 1; + + // A token to retrieve the next page of results. To retrieve the next page, + // call `ListProjectBillingInfo` again with the `page_token` field set to this + // value. This field is empty if there are no more results to retrieve. + string next_page_token = 2; +} + +// Request message for `GetProjectBillingInfo`. +message GetProjectBillingInfoRequest { + // Required. The resource name of the project for which billing information is + // retrieved. For example, `projects/tokyo-rain-123`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for `UpdateProjectBillingInfo`. +message UpdateProjectBillingInfoRequest { + // Required. The resource name of the project associated with the billing information + // that you want to update. For example, `projects/tokyo-rain-123`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The new billing information for the project. Read-only fields are ignored; + // thus, you can leave empty all fields except `billing_account_name`. + ProjectBillingInfo project_billing_info = 2; +} diff --git a/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto b/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto new file mode 100644 index 00000000000..f3d46e62708 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto @@ -0,0 +1,363 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.billing.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/money.proto"; + +option csharp_namespace = "Google.Cloud.Billing.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/billing/v1;billing"; +option java_multiple_files = true; +option java_outer_classname = "CloudCatalogProto"; +option java_package = "com.google.cloud.billing.v1"; +option objc_class_prefix = "CLDCTLG"; + +// A catalog of Google Cloud Platform services and SKUs. +// Provides pricing information and metadata on Google Cloud Platform services +// and SKUs. +service CloudCatalog { + option (google.api.default_host) = "cloudbilling.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-billing," + "https://www.googleapis.com/auth/cloud-billing.readonly," + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all public cloud services. + rpc ListServices(ListServicesRequest) returns (ListServicesResponse) { + option (google.api.http) = { + get: "/v1/services" + }; + option (google.api.method_signature) = ""; + } + + // Lists all publicly available SKUs for a given cloud service. + rpc ListSkus(ListSkusRequest) returns (ListSkusResponse) { + option (google.api.http) = { + get: "/v1/{parent=services/*}/skus" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Encapsulates a single service in Google Cloud Platform. +message Service { + option (google.api.resource) = { + type: "cloudbilling.googleapis.com/Service" + pattern: "services/{service}" + }; + + // The resource name for the service. + // Example: "services/DA34-426B-A397" + string name = 1; + + // The identifier for the service. + // Example: "DA34-426B-A397" + string service_id = 2; + + // A human readable display name for this service. + string display_name = 3; + + // The business under which the service is offered. + // Ex. "businessEntities/GCP", "businessEntities/Maps" + string business_entity_name = 4; +} + +// Encapsulates a single SKU in Google Cloud Platform +message Sku { + option (google.api.resource) = { + type: "cloudbilling.googleapis.com/Sku" + pattern: "services/{service}/skus/{sku}" + }; + + // The resource name for the SKU. + // Example: "services/DA34-426B-A397/skus/AA95-CD31-42FE" + string name = 1; + + // The identifier for the SKU. + // Example: "AA95-CD31-42FE" + string sku_id = 2; + + // A human readable description of the SKU, has a maximum length of 256 + // characters. + string description = 3; + + // The category hierarchy of this SKU, purely for organizational purpose. + Category category = 4; + + // List of service regions this SKU is offered at. + // Example: "asia-east1" + // Service regions can be found at https://cloud.google.com/about/locations/ + repeated string service_regions = 5; + + // A timeline of pricing info for this SKU in chronological order. + repeated PricingInfo pricing_info = 6; + + // Identifies the service provider. + // This is 'Google' for first party services in Google Cloud Platform. + string service_provider_name = 7; + + // The geographic taxonomy for this sku. + GeoTaxonomy geo_taxonomy = 8; +} + +// Represents the category hierarchy of a SKU. +message Category { + // The display name of the service this SKU belongs to. + string service_display_name = 1; + + // The type of product the SKU refers to. + // Example: "Compute", "Storage", "Network", "ApplicationServices" etc. + string resource_family = 2; + + // A group classification for related SKUs. + // Example: "RAM", "GPU", "Prediction", "Ops", "GoogleEgress" etc. + string resource_group = 3; + + // Represents how the SKU is consumed. + // Example: "OnDemand", "Preemptible", "Commit1Mo", "Commit1Yr" etc. + string usage_type = 4; +} + +// Represents the pricing information for a SKU at a single point of time. +message PricingInfo { + // The timestamp from which this pricing was effective within the requested + // time range. This is guaranteed to be greater than or equal to the + // start_time field in the request and less than the end_time field in the + // request. If a time range was not specified in the request this field will + // be equivalent to a time within the last 12 hours, indicating the latest + // pricing info. + google.protobuf.Timestamp effective_time = 1; + + // An optional human readable summary of the pricing information, has a + // maximum length of 256 characters. + string summary = 2; + + // Expresses the pricing formula. See `PricingExpression` for an example. + PricingExpression pricing_expression = 3; + + // Aggregation Info. This can be left unspecified if the pricing expression + // doesn't require aggregation. + AggregationInfo aggregation_info = 4; + + // Conversion rate used for currency conversion, from USD to the currency + // specified in the request. This includes any surcharge collected for billing + // in non USD currency. If a currency is not specified in the request this + // defaults to 1.0. + // Example: USD * currency_conversion_rate = JPY + double currency_conversion_rate = 5; +} + +// Expresses a mathematical pricing formula. For Example:- +// +// `usage_unit: GBy` +// `tiered_rates:` +// `[start_usage_amount: 20, unit_price: $10]` +// `[start_usage_amount: 100, unit_price: $5]` +// +// The above expresses a pricing formula where the first 20GB is free, the +// next 80GB is priced at $10 per GB followed by $5 per GB for additional +// usage. +message PricingExpression { + // The price rate indicating starting usage and its corresponding price. + message TierRate { + // Usage is priced at this rate only after this amount. + // Example: start_usage_amount of 10 indicates that the usage will be priced + // at the unit_price after the first 10 usage_units. + double start_usage_amount = 1; + + // The price per unit of usage. + // Example: unit_price of amount $10 indicates that each unit will cost $10. + google.type.Money unit_price = 2; + } + + // The short hand for unit of usage this pricing is specified in. + // Example: usage_unit of "GiBy" means that usage is specified in "Gibi Byte". + string usage_unit = 1; + + // The recommended quantity of units for displaying pricing info. When + // displaying pricing info it is recommended to display: + // (unit_price * display_quantity) per display_quantity usage_unit. + // This field does not affect the pricing formula and is for display purposes + // only. + // Example: If the unit_price is "0.0001 USD", the usage_unit is "GB" and + // the display_quantity is "1000" then the recommended way of displaying the + // pricing info is "0.10 USD per 1000 GB" + double display_quantity = 2; + + // The list of tiered rates for this pricing. The total cost is computed by + // applying each of the tiered rates on usage. This repeated list is sorted + // by ascending order of start_usage_amount. + repeated TierRate tiered_rates = 3; + + // The unit of usage in human readable form. + // Example: "gibi byte". + string usage_unit_description = 4; + + // The base unit for the SKU which is the unit used in usage exports. + // Example: "By" + string base_unit = 5; + + // The base unit in human readable form. + // Example: "byte". + string base_unit_description = 6; + + // Conversion factor for converting from price per usage_unit to price per + // base_unit, and start_usage_amount to start_usage_amount in base_unit. + // unit_price / base_unit_conversion_factor = price per base_unit. + // start_usage_amount * base_unit_conversion_factor = start_usage_amount in + // base_unit. + double base_unit_conversion_factor = 7; +} + +// Represents the aggregation level and interval for pricing of a single SKU. +message AggregationInfo { + // The level at which usage is aggregated to compute cost. + // Example: "ACCOUNT" aggregation level indicates that usage for tiered + // pricing is aggregated across all projects in a single account. + enum AggregationLevel { + AGGREGATION_LEVEL_UNSPECIFIED = 0; + + ACCOUNT = 1; + + PROJECT = 2; + } + + // The interval at which usage is aggregated to compute cost. + // Example: "MONTHLY" aggregation interval indicates that usage for tiered + // pricing is aggregated every month. + enum AggregationInterval { + AGGREGATION_INTERVAL_UNSPECIFIED = 0; + + DAILY = 1; + + MONTHLY = 2; + } + + AggregationLevel aggregation_level = 1; + + AggregationInterval aggregation_interval = 2; + + // The number of intervals to aggregate over. + // Example: If aggregation_level is "DAILY" and aggregation_count is 14, + // aggregation will be over 14 days. + int32 aggregation_count = 3; +} + +// Encapsulates the geographic taxonomy data for a sku. +message GeoTaxonomy { + // The type of Geo Taxonomy: GLOBAL, REGIONAL, or MULTI_REGIONAL. + enum Type { + // The type is not specified. + TYPE_UNSPECIFIED = 0; + + // The sku is global in nature, e.g. a license sku. Global skus are + // available in all regions, and so have an empty region list. + GLOBAL = 1; + + // The sku is available in a specific region, e.g. "us-west2". + REGIONAL = 2; + + // The sku is associated with multiple regions, e.g. "us-west2" and + // "us-east1". + MULTI_REGIONAL = 3; + } + + // The type of Geo Taxonomy: GLOBAL, REGIONAL, or MULTI_REGIONAL. + Type type = 1; + + // The list of regions associated with a sku. Empty for Global skus, which are + // associated with all Google Cloud regions. + repeated string regions = 2; +} + +// Request message for `ListServices`. +message ListServicesRequest { + // Requested page size. Defaults to 5000. + int32 page_size = 1; + + // A token identifying a page of results to return. This should be a + // `next_page_token` value returned from a previous `ListServices` + // call. If unspecified, the first page of results is returned. + string page_token = 2; +} + +// Response message for `ListServices`. +message ListServicesResponse { + // A list of services. + repeated Service services = 1; + + // A token to retrieve the next page of results. To retrieve the next page, + // call `ListServices` again with the `page_token` field set to this + // value. This field is empty if there are no more results to retrieve. + string next_page_token = 2; +} + +// Request message for `ListSkus`. +message ListSkusRequest { + // Required. The name of the service. + // Example: "services/DA34-426B-A397" + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudbilling.googleapis.com/Service" + } + ]; + + // Optional inclusive start time of the time range for which the pricing + // versions will be returned. Timestamps in the future are not allowed. + // The time range has to be within a single calendar month in + // America/Los_Angeles timezone. Time range as a whole is optional. If not + // specified, the latest pricing will be returned (up to 12 hours old at + // most). + google.protobuf.Timestamp start_time = 2; + + // Optional exclusive end time of the time range for which the pricing + // versions will be returned. Timestamps in the future are not allowed. + // The time range has to be within a single calendar month in + // America/Los_Angeles timezone. Time range as a whole is optional. If not + // specified, the latest pricing will be returned (up to 12 hours old at + // most). + google.protobuf.Timestamp end_time = 3; + + // The ISO 4217 currency code for the pricing info in the response proto. + // Will use the conversion rate as of start_time. + // Optional. If not specified USD will be used. + string currency_code = 4; + + // Requested page size. Defaults to 5000. + int32 page_size = 5; + + // A token identifying a page of results to return. This should be a + // `next_page_token` value returned from a previous `ListSkus` + // call. If unspecified, the first page of results is returned. + string page_token = 6; +} + +// Response message for `ListSkus`. +message ListSkusResponse { + // The list of public SKUs of the given service. + repeated Sku skus = 1; + + // A token to retrieve the next page of results. To retrieve the next page, + // call `ListSkus` again with the `page_token` field set to this + // value. This field is empty if there are no more results to retrieve. + string next_page_token = 2; +} diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js new file mode 100644 index 00000000000..06e6462d716 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js @@ -0,0 +1,64 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(billingAccount) { + // [START cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The billing account resource to create. + * Currently CreateBillingAccount only supports subaccount creation, so + * any created billing accounts must be under a provided parent billing + * account. + */ + // const billingAccount = {} + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callCreateBillingAccount() { + // Construct request + const request = { + billingAccount, + }; + + // Run request + const response = await billingClient.createBillingAccount(request); + console.log(response); + } + + callCreateBillingAccount(); + // [END cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js new file mode 100644 index 00000000000..8d420a0e1a5 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the billing account to retrieve. For example, + * `billingAccounts/012345-567890-ABCDEF`. + */ + // const name = 'abc123' + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callGetBillingAccount() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await billingClient.getBillingAccount(request); + console.log(response); + } + + callGetBillingAccount(); + // [END cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js new file mode 100644 index 00000000000..df9f6c0a259 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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 cloudbilling_v1_generated_CloudBilling_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. + */ + /** + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await billingClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END cloudbilling_v1_generated_CloudBilling_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-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js new file mode 100644 index 00000000000..1b9bd0c1604 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the project for which billing information is + * retrieved. For example, `projects/tokyo-rain-123`. + */ + // const name = 'abc123' + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callGetProjectBillingInfo() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await billingClient.getProjectBillingInfo(request); + console.log(response); + } + + callGetProjectBillingInfo(); + // [END cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js new file mode 100644 index 00000000000..916633c0352 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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 cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 page size. The maximum page size is 100; this is also the + * default. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListBillingAccounts` + * call. If unspecified, the first page of results is returned. + */ + // const pageToken = 'abc123' + /** + * Options for how to filter the returned billing accounts. + * Currently this only supports filtering for + * subaccounts (https://cloud.google.com/billing/docs/concepts) under a + * single provided reseller billing account. + * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). + * Boolean algebra and other fields are not currently supported. + */ + // const filter = 'abc123' + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callListBillingAccounts() { + // Construct request + const request = { + }; + + // Run request + const iterable = await billingClient.listBillingAccountsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListBillingAccounts(); + // [END cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js new file mode 100644 index 00000000000..3ab054e3f1d --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the billing account associated with the projects that + * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. + */ + // const name = 'abc123' + /** + * Requested page size. The maximum page size is 100; this is also the + * default. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous `ListProjectBillingInfo` + * call. If unspecified, the first page of results is returned. + */ + // const pageToken = 'abc123' + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callListProjectBillingInfo() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await billingClient.listProjectBillingInfoAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProjectBillingInfo(); + // [END cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js new file mode 100644 index 00000000000..41fa9a179ef --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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, policy) { + // [START cloudbilling_v1_generated_CloudBilling_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. + */ + /** + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * 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 a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await billingClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END cloudbilling_v1_generated_CloudBilling_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-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js new file mode 100644 index 00000000000..b1ffbd536e5 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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, permissions) { + // [START cloudbilling_v1_generated_CloudBilling_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. + */ + /** + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = 'abc123' + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await billingClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END cloudbilling_v1_generated_CloudBilling_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-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js new file mode 100644 index 00000000000..c487c7c3d5c --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js @@ -0,0 +1,71 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, account) { + // [START cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the billing account resource to be updated. + */ + // const name = 'abc123' + /** + * Required. The billing account resource to replace the resource on the server. + */ + // const account = {} + /** + * The update mask applied to the resource. + * Only "display_name" is currently supported. + */ + // const updateMask = {} + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callUpdateBillingAccount() { + // Construct request + const request = { + name, + account, + }; + + // Run request + const response = await billingClient.updateBillingAccount(request); + console.log(response); + } + + callUpdateBillingAccount(); + // [END cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js new file mode 100644 index 00000000000..0168c7c8daa --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the project associated with the billing information + * that you want to update. For example, `projects/tokyo-rain-123`. + */ + // const name = 'abc123' + /** + * The new billing information for the project. Read-only fields are ignored; + * thus, you can leave empty all fields except `billing_account_name`. + */ + // const projectBillingInfo = {} + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callUpdateProjectBillingInfo() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await billingClient.updateProjectBillingInfo(request); + console.log(response); + } + + callUpdateProjectBillingInfo(); + // [END cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js new file mode 100644 index 00000000000..c21a6be3aeb --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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 cloudbilling_v1_generated_CloudCatalog_ListServices_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 page size. Defaults to 5000. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListServices` + * call. If unspecified, the first page of results is returned. + */ + // const pageToken = 'abc123' + + // Imports the Billing library + const {CloudCatalogClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudCatalogClient(); + + async function callListServices() { + // Construct request + const request = { + }; + + // Run request + const iterable = await billingClient.listServicesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListServices(); + // [END cloudbilling_v1_generated_CloudCatalog_ListServices_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js new file mode 100644 index 00000000000..71decc1085d --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js @@ -0,0 +1,98 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START cloudbilling_v1_generated_CloudCatalog_ListSkus_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the service. + * Example: "services/DA34-426B-A397" + */ + // const parent = 'abc123' + /** + * Optional inclusive start time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + */ + // const startTime = {} + /** + * Optional exclusive end time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + */ + // const endTime = {} + /** + * The ISO 4217 currency code for the pricing info in the response proto. + * Will use the conversion rate as of start_time. + * Optional. If not specified USD will be used. + */ + // const currencyCode = 'abc123' + /** + * Requested page size. Defaults to 5000. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListSkus` + * call. If unspecified, the first page of results is returned. + */ + // const pageToken = 'abc123' + + // Imports the Billing library + const {CloudCatalogClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudCatalogClient(); + + async function callListSkus() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await billingClient.listSkusAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListSkus(); + // [END cloudbilling_v1_generated_CloudCatalog_ListSkus_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json new file mode 100644 index 00000000000..e446c6b0814 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json @@ -0,0 +1,563 @@ +{ + "clientLibrary": { + "name": "nodejs-billing", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.billing.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async", + "title": "CloudBilling getBillingAccount Sample", + "origin": "API_DEFINITION", + "description": " Gets information about a billing account. The current authenticated user must be a [viewer of the billing account](https://cloud.google.com/billing/docs/how-to/billing-access).", + "canonical": true, + "file": "cloud_billing.get_billing_account.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetBillingAccount", + "fullName": "google.cloud.billing.v1.CloudBilling.GetBillingAccount", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.billing.v1.BillingAccount", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "GetBillingAccount", + "fullName": "google.cloud.billing.v1.CloudBilling.GetBillingAccount", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async", + "title": "CloudBilling listBillingAccounts Sample", + "origin": "API_DEFINITION", + "description": " Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).", + "canonical": true, + "file": "cloud_billing.list_billing_accounts.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListBillingAccounts", + "fullName": "google.cloud.billing.v1.CloudBilling.ListBillingAccounts", + "async": true, + "parameters": [ + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.billing.v1.ListBillingAccountsResponse", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "ListBillingAccounts", + "fullName": "google.cloud.billing.v1.CloudBilling.ListBillingAccounts", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async", + "title": "CloudBilling updateBillingAccount Sample", + "origin": "API_DEFINITION", + "description": " Updates a billing account's fields. Currently the only field that can be edited is `display_name`. The current authenticated user must have the `billing.accounts.update` IAM permission, which is typically given to the [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing account.", + "canonical": true, + "file": "cloud_billing.update_billing_account.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateBillingAccount", + "fullName": "google.cloud.billing.v1.CloudBilling.UpdateBillingAccount", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "account", + "type": ".google.cloud.billing.v1.BillingAccount" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.billing.v1.BillingAccount", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "UpdateBillingAccount", + "fullName": "google.cloud.billing.v1.CloudBilling.UpdateBillingAccount", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async", + "title": "CloudBilling createBillingAccount Sample", + "origin": "API_DEFINITION", + "description": " This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned as a reseller account.", + "canonical": true, + "file": "cloud_billing.create_billing_account.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateBillingAccount", + "fullName": "google.cloud.billing.v1.CloudBilling.CreateBillingAccount", + "async": true, + "parameters": [ + { + "name": "billing_account", + "type": ".google.cloud.billing.v1.BillingAccount" + } + ], + "resultType": ".google.cloud.billing.v1.BillingAccount", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "CreateBillingAccount", + "fullName": "google.cloud.billing.v1.CloudBilling.CreateBillingAccount", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async", + "title": "CloudBilling listProjectBillingInfo Sample", + "origin": "API_DEFINITION", + "description": " Lists the projects associated with a billing account. The current authenticated user must have the `billing.resourceAssociations.list` IAM permission, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).", + "canonical": true, + "file": "cloud_billing.list_project_billing_info.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProjectBillingInfo", + "fullName": "google.cloud.billing.v1.CloudBilling.ListProjectBillingInfo", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.billing.v1.ListProjectBillingInfoResponse", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "ListProjectBillingInfo", + "fullName": "google.cloud.billing.v1.CloudBilling.ListProjectBillingInfo", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async", + "title": "CloudBilling getProjectBillingInfo Sample", + "origin": "API_DEFINITION", + "description": " Gets the billing information for a project. The current authenticated user must have the `resourcemanager.projects.get` permission for the project, which can be granted by assigning the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) role.", + "canonical": true, + "file": "cloud_billing.get_project_billing_info.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProjectBillingInfo", + "fullName": "google.cloud.billing.v1.CloudBilling.GetProjectBillingInfo", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.billing.v1.ProjectBillingInfo", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "GetProjectBillingInfo", + "fullName": "google.cloud.billing.v1.CloudBilling.GetProjectBillingInfo", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async", + "title": "CloudBilling updateProjectBillingInfo Sample", + "origin": "API_DEFINITION", + "description": " Sets or updates the billing account associated with a project. You specify the new billing account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the resource name of a billing account. Associating a project with an open billing account enables billing on the project and allows charges for resource usage. If the project already had a billing account, this method changes the billing account used for resource usage charges. *Note:* Incurred charges that have not yet been reported in the transaction history of the Google Cloud Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project. The current authenticated user must have ownership privileges for both the [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](https://cloud.google.com/billing/docs/how-to/billing-access). You can disable billing on the project by setting the `billing_account_name` field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project. Note that associating a project with a *closed* billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an *open* billing account.", + "canonical": true, + "file": "cloud_billing.update_project_billing_info.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProjectBillingInfo", + "fullName": "google.cloud.billing.v1.CloudBilling.UpdateProjectBillingInfo", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "project_billing_info", + "type": ".google.cloud.billing.v1.ProjectBillingInfo" + } + ], + "resultType": ".google.cloud.billing.v1.ProjectBillingInfo", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "UpdateProjectBillingInfo", + "fullName": "google.cloud.billing.v1.CloudBilling.UpdateProjectBillingInfo", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_GetIamPolicy_async", + "title": "CloudBilling getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a billing account. The caller must have the `billing.accounts.getIamPolicy` permission on the account, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).", + "canonical": true, + "file": "cloud_billing.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.billing.v1.CloudBilling.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.billing.v1.CloudBilling.GetIamPolicy", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_SetIamPolicy_async", + "title": "CloudBilling setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy for a billing account. Replaces any existing policy. The caller must have the `billing.accounts.setIamPolicy` permission on the account, which is often given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).", + "canonical": true, + "file": "cloud_billing.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.billing.v1.CloudBilling.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.billing.v1.CloudBilling.SetIamPolicy", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_TestIamPermissions_async", + "title": "CloudBilling testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Tests the access control policy for a billing account. This method takes the resource and a set of permissions as input and returns the subset of the input permissions that the caller is allowed for that resource.", + "canonical": true, + "file": "cloud_billing.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.billing.v1.CloudBilling.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.billing.v1.CloudBilling.TestIamPermissions", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudCatalog_ListServices_async", + "title": "CloudBilling listServices Sample", + "origin": "API_DEFINITION", + "description": " Lists all public cloud services.", + "canonical": true, + "file": "cloud_catalog.list_services.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServices", + "fullName": "google.cloud.billing.v1.CloudCatalog.ListServices", + "async": true, + "parameters": [ + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.billing.v1.ListServicesResponse", + "client": { + "shortName": "CloudCatalogClient", + "fullName": "google.cloud.billing.v1.CloudCatalogClient" + }, + "method": { + "shortName": "ListServices", + "fullName": "google.cloud.billing.v1.CloudCatalog.ListServices", + "service": { + "shortName": "CloudCatalog", + "fullName": "google.cloud.billing.v1.CloudCatalog" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudCatalog_ListSkus_async", + "title": "CloudBilling listSkus Sample", + "origin": "API_DEFINITION", + "description": " Lists all publicly available SKUs for a given cloud service.", + "canonical": true, + "file": "cloud_catalog.list_skus.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 90, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListSkus", + "fullName": "google.cloud.billing.v1.CloudCatalog.ListSkus", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "start_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "end_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "currency_code", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.billing.v1.ListSkusResponse", + "client": { + "shortName": "CloudCatalogClient", + "fullName": "google.cloud.billing.v1.CloudCatalogClient" + }, + "method": { + "shortName": "ListSkus", + "fullName": "google.cloud.billing.v1.CloudCatalog.ListSkus", + "service": { + "shortName": "CloudCatalog", + "fullName": "google.cloud.billing.v1.CloudCatalog" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/index.ts b/owl-bot-staging/google-cloud-billing/v1/src/index.ts new file mode 100644 index 00000000000..6cac30c8973 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 CloudBillingClient = v1.CloudBillingClient; +type CloudBillingClient = v1.CloudBillingClient; +const CloudCatalogClient = v1.CloudCatalogClient; +type CloudCatalogClient = v1.CloudCatalogClient; +export {v1, CloudBillingClient, CloudCatalogClient}; +export default {v1, CloudBillingClient, CloudCatalogClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts new file mode 100644 index 00000000000..5f4bf33e28f --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts @@ -0,0 +1,1454 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/cloud_billing_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './cloud_billing_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Retrieves the Google Cloud Console billing accounts and associates them with + * projects. + * @class + * @memberof v1 + */ +export class CloudBillingClient { + 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}; + pathTemplates: {[name: string]: gax.PathTemplate}; + cloudBillingStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CloudBillingClient. + * + * @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 CloudBillingClient({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 CloudBillingClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // 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 useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + billingAccountPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}' + ), + servicePathTemplate: new this._gaxModule.PathTemplate( + 'services/{service}' + ), + skuPathTemplate: new this._gaxModule.PathTemplate( + 'services/{service}/skus/{sku}' + ), + }; + + // 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 = { + listBillingAccounts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'billingAccounts'), + listProjectBillingInfo: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'projectBillingInfo') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.billing.v1.CloudBilling', 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.cloudBillingStub) { + return this.cloudBillingStub; + } + + // Put together the "service stub" for + // google.cloud.billing.v1.CloudBilling. + this.cloudBillingStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.billing.v1.CloudBilling') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.billing.v1.CloudBilling, + 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 cloudBillingStubMethods = + ['getBillingAccount', 'listBillingAccounts', 'updateBillingAccount', 'createBillingAccount', 'listProjectBillingInfo', 'getProjectBillingInfo', 'updateProjectBillingInfo', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of cloudBillingStubMethods) { + const callPromise = this.cloudBillingStub.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.cloudBillingStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudbilling.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 'cloudbilling.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/cloud-billing', + 'https://www.googleapis.com/auth/cloud-billing.readonly', + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets information about a billing account. The current authenticated user + * must be a [viewer of the billing + * account](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the billing account to retrieve. For example, + * `billingAccounts/012345-567890-ABCDEF`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. + * 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/cloud_billing.get_billing_account.js + * region_tag:cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async + */ + getBillingAccount( + request?: protos.google.cloud.billing.v1.IGetBillingAccountRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IGetBillingAccountRequest|undefined, {}|undefined + ]>; + getBillingAccount( + request: protos.google.cloud.billing.v1.IGetBillingAccountRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, + {}|null|undefined>): void; + getBillingAccount( + request: protos.google.cloud.billing.v1.IGetBillingAccountRequest, + callback: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, + {}|null|undefined>): void; + getBillingAccount( + request?: protos.google.cloud.billing.v1.IGetBillingAccountRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IGetBillingAccountRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getBillingAccount(request, options, callback); + } +/** + * Updates a billing account's fields. + * Currently the only field that can be edited is `display_name`. + * The current authenticated user must have the `billing.accounts.update` + * IAM permission, which is typically given to the + * [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) + * of the billing account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the billing account resource to be updated. + * @param {google.cloud.billing.v1.BillingAccount} request.account + * Required. The billing account resource to replace the resource on the server. + * @param {google.protobuf.FieldMask} request.updateMask + * The update mask applied to the resource. + * Only "display_name" is currently supported. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. + * 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/cloud_billing.update_billing_account.js + * region_tag:cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async + */ + updateBillingAccount( + request?: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|undefined, {}|undefined + ]>; + updateBillingAccount( + request: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, + {}|null|undefined>): void; + updateBillingAccount( + request: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, + callback: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, + {}|null|undefined>): void; + updateBillingAccount( + request?: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateBillingAccount(request, options, callback); + } +/** + * This method creates [billing + * subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). + * + * Google Cloud resellers should use the + * Channel Services APIs, + * [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) + * and + * [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). + * + * When creating a subaccount, the current authenticated user must have the + * `billing.accounts.update` IAM permission on the parent account, which is + * typically given to billing account + * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). + * This method will return an error if the parent account has not been + * provisioned as a reseller account. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.billing.v1.BillingAccount} request.billingAccount + * Required. The billing account resource to create. + * Currently CreateBillingAccount only supports subaccount creation, so + * any created billing accounts must be under a provided parent billing + * account. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. + * 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/cloud_billing.create_billing_account.js + * region_tag:cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async + */ + createBillingAccount( + request?: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.ICreateBillingAccountRequest|undefined, {}|undefined + ]>; + createBillingAccount( + request: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, + {}|null|undefined>): void; + createBillingAccount( + request: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, + callback: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, + {}|null|undefined>): void; + createBillingAccount( + request?: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.ICreateBillingAccountRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof 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.createBillingAccount(request, options, callback); + } +/** + * Gets the billing information for a project. The current authenticated user + * must have the `resourcemanager.projects.get` permission for the project, + * which can be granted by assigning the [Project + * Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) + * role. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the project for which billing information is + * retrieved. For example, `projects/tokyo-rain-123`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. + * 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/cloud_billing.get_project_billing_info.js + * region_tag:cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async + */ + getProjectBillingInfo( + request?: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|undefined, {}|undefined + ]>; + getProjectBillingInfo( + request: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, + {}|null|undefined>): void; + getProjectBillingInfo( + request: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, + callback: Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, + {}|null|undefined>): void; + getProjectBillingInfo( + request?: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProjectBillingInfo(request, options, callback); + } +/** + * Sets or updates the billing account associated with a project. You specify + * the new billing account by setting the `billing_account_name` in the + * `ProjectBillingInfo` resource to the resource name of a billing account. + * Associating a project with an open billing account enables billing on the + * project and allows charges for resource usage. If the project already had a + * billing account, this method changes the billing account used for resource + * usage charges. + * + * *Note:* Incurred charges that have not yet been reported in the transaction + * history of the Google Cloud Console might be billed to the new billing + * account, even if the charge occurred before the new billing account was + * assigned to the project. + * + * The current authenticated user must have ownership privileges for both the + * [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo + * ) and the [billing + * account](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * You can disable billing on the project by setting the + * `billing_account_name` field to empty. This action disassociates the + * current billing account from the project. Any billable activity of your + * in-use services will stop, and your application could stop functioning as + * expected. Any unbilled charges to date will be billed to the previously + * associated account. The current authenticated user must be either an owner + * of the project or an owner of the billing account for the project. + * + * Note that associating a project with a *closed* billing account will have + * much the same effect as disabling billing on the project: any paid + * resources used by the project will be shut down. Thus, unless you wish to + * disable billing, you should always call this method with the name of an + * *open* billing account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the project associated with the billing information + * that you want to update. For example, `projects/tokyo-rain-123`. + * @param {google.cloud.billing.v1.ProjectBillingInfo} request.projectBillingInfo + * The new billing information for the project. Read-only fields are ignored; + * thus, you can leave empty all fields except `billing_account_name`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. + * 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/cloud_billing.update_project_billing_info.js + * region_tag:cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async + */ + updateProjectBillingInfo( + request?: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|undefined, {}|undefined + ]>; + updateProjectBillingInfo( + request: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, + {}|null|undefined>): void; + updateProjectBillingInfo( + request: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, + callback: Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, + {}|null|undefined>): void; + updateProjectBillingInfo( + request?: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProjectBillingInfo(request, options, callback); + } +/** + * Gets the access control policy for a billing account. + * The caller must have the `billing.accounts.getIamPolicy` permission on the + * account, which is often given to billing account + * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.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/cloud_billing.get_iam_policy.js + * region_tag:cloudbilling_v1_generated_CloudBilling_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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); + } +/** + * Sets the access control policy for a billing account. Replaces any existing + * policy. + * The caller must have the `billing.accounts.setIamPolicy` permission on the + * account, which is often given to billing account + * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * 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 a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.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/cloud_billing.set_iam_policy.js + * region_tag:cloudbilling_v1_generated_CloudBilling_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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); + } +/** + * Tests the access control policy for a billing account. This method takes + * the resource and a set of permissions as input and returns the subset of + * the input permissions that the caller is allowed for that resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * 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/cloud_billing.test_iam_permissions.js + * region_tag:cloudbilling_v1_generated_CloudBilling_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 the billing accounts that the current authenticated user has + * permission to + * [view](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.pageSize + * Requested page size. The maximum page size is 100; this is also the + * default. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListBillingAccounts` + * call. If unspecified, the first page of results is returned. + * @param {string} request.filter + * Options for how to filter the returned billing accounts. + * Currently this only supports filtering for + * [subaccounts](https://cloud.google.com/billing/docs/concepts) under a + * single provided reseller billing account. + * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). + * Boolean algebra and other fields are not currently supported. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. + * 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 `listBillingAccountsAsync()` + * 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. + */ + listBillingAccounts( + request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount[], + protos.google.cloud.billing.v1.IListBillingAccountsRequest|null, + protos.google.cloud.billing.v1.IListBillingAccountsResponse + ]>; + listBillingAccounts( + request: protos.google.cloud.billing.v1.IListBillingAccountsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListBillingAccountsRequest, + protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, + protos.google.cloud.billing.v1.IBillingAccount>): void; + listBillingAccounts( + request: protos.google.cloud.billing.v1.IListBillingAccountsRequest, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListBillingAccountsRequest, + protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, + protos.google.cloud.billing.v1.IBillingAccount>): void; + listBillingAccounts( + request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.billing.v1.IListBillingAccountsRequest, + protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, + protos.google.cloud.billing.v1.IBillingAccount>, + callback?: PaginationCallback< + protos.google.cloud.billing.v1.IListBillingAccountsRequest, + protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, + protos.google.cloud.billing.v1.IBillingAccount>): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount[], + protos.google.cloud.billing.v1.IListBillingAccountsRequest|null, + protos.google.cloud.billing.v1.IListBillingAccountsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof 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.listBillingAccounts(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 {number} request.pageSize + * Requested page size. The maximum page size is 100; this is also the + * default. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListBillingAccounts` + * call. If unspecified, the first page of results is returned. + * @param {string} request.filter + * Options for how to filter the returned billing accounts. + * Currently this only supports filtering for + * [subaccounts](https://cloud.google.com/billing/docs/concepts) under a + * single provided reseller billing account. + * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). + * Boolean algebra and other fields are not currently supported. + * @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 [BillingAccount]{@link google.cloud.billing.v1.BillingAccount} 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 `listBillingAccountsAsync()` + * 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. + */ + listBillingAccountsStream( + request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listBillingAccounts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listBillingAccounts.createStream( + this.innerApiCalls.listBillingAccounts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listBillingAccounts`, 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 {number} request.pageSize + * Requested page size. The maximum page size is 100; this is also the + * default. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListBillingAccounts` + * call. If unspecified, the first page of results is returned. + * @param {string} request.filter + * Options for how to filter the returned billing accounts. + * Currently this only supports filtering for + * [subaccounts](https://cloud.google.com/billing/docs/concepts) under a + * single provided reseller billing account. + * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). + * Boolean algebra and other fields are not currently supported. + * @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 + * [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. 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/cloud_billing.list_billing_accounts.js + * region_tag:cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async + */ + listBillingAccountsAsync( + request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listBillingAccounts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listBillingAccounts.asyncIterate( + this.innerApiCalls['listBillingAccounts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the projects associated with a billing account. The current + * authenticated user must have the `billing.resourceAssociations.list` IAM + * permission, which is often given to billing account + * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the billing account associated with the projects that + * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. + * @param {number} request.pageSize + * Requested page size. The maximum page size is 100; this is also the + * default. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous `ListProjectBillingInfo` + * call. If unspecified, the first page of results is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. + * 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 `listProjectBillingInfoAsync()` + * 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. + */ + listProjectBillingInfo( + request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IProjectBillingInfo[], + protos.google.cloud.billing.v1.IListProjectBillingInfoRequest|null, + protos.google.cloud.billing.v1.IListProjectBillingInfoResponse + ]>; + listProjectBillingInfo( + request: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, + protos.google.cloud.billing.v1.IProjectBillingInfo>): void; + listProjectBillingInfo( + request: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, + protos.google.cloud.billing.v1.IProjectBillingInfo>): void; + listProjectBillingInfo( + request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, + protos.google.cloud.billing.v1.IProjectBillingInfo>, + callback?: PaginationCallback< + protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, + protos.google.cloud.billing.v1.IProjectBillingInfo>): + Promise<[ + protos.google.cloud.billing.v1.IProjectBillingInfo[], + protos.google.cloud.billing.v1.IListProjectBillingInfoRequest|null, + protos.google.cloud.billing.v1.IListProjectBillingInfoResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProjectBillingInfo(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.name + * Required. The resource name of the billing account associated with the projects that + * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. + * @param {number} request.pageSize + * Requested page size. The maximum page size is 100; this is also the + * default. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous `ListProjectBillingInfo` + * call. If unspecified, the first page of results is returned. + * @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 [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo} 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 `listProjectBillingInfoAsync()` + * 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. + */ + listProjectBillingInfoStream( + request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProjectBillingInfo']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProjectBillingInfo.createStream( + this.innerApiCalls.listProjectBillingInfo as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProjectBillingInfo`, 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.name + * Required. The resource name of the billing account associated with the projects that + * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. + * @param {number} request.pageSize + * Requested page size. The maximum page size is 100; this is also the + * default. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous `ListProjectBillingInfo` + * call. If unspecified, the first page of results is returned. + * @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 + * [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. 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/cloud_billing.list_project_billing_info.js + * region_tag:cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async + */ + listProjectBillingInfoAsync( + request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProjectBillingInfo']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProjectBillingInfo.asyncIterate( + this.innerApiCalls['listProjectBillingInfo'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified billingAccount resource name string. + * + * @param {string} billing_account + * @returns {string} Resource name string. + */ + billingAccountPath(billingAccount:string) { + return this.pathTemplates.billingAccountPathTemplate.render({ + billing_account: billingAccount, + }); + } + + /** + * Parse the billing_account from BillingAccount resource. + * + * @param {string} billingAccountName + * A fully-qualified path representing BillingAccount resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountName(billingAccountName: string) { + return this.pathTemplates.billingAccountPathTemplate.match(billingAccountName).billing_account; + } + + /** + * Return a fully-qualified service resource name string. + * + * @param {string} service + * @returns {string} Resource name string. + */ + servicePath(service:string) { + return this.pathTemplates.servicePathTemplate.render({ + service: service, + }); + } + + /** + * Parse the service from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).service; + } + + /** + * Return a fully-qualified sku resource name string. + * + * @param {string} service + * @param {string} sku + * @returns {string} Resource name string. + */ + skuPath(service:string,sku:string) { + return this.pathTemplates.skuPathTemplate.render({ + service: service, + sku: sku, + }); + } + + /** + * Parse the service from Sku resource. + * + * @param {string} skuName + * A fully-qualified path representing Sku resource. + * @returns {string} A string representing the service. + */ + matchServiceFromSkuName(skuName: string) { + return this.pathTemplates.skuPathTemplate.match(skuName).service; + } + + /** + * Parse the sku from Sku resource. + * + * @param {string} skuName + * A fully-qualified path representing Sku resource. + * @returns {string} A string representing the sku. + */ + matchSkuFromSkuName(skuName: string) { + return this.pathTemplates.skuPathTemplate.match(skuName).sku; + } + + /** + * 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.cloudBillingStub && !this._terminated) { + return this.cloudBillingStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json new file mode 100644 index 00000000000..e98db6a6e4b --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json @@ -0,0 +1,76 @@ +{ + "interfaces": { + "google.cloud.billing.v1.CloudBilling": { + "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": { + "GetBillingAccount": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListBillingAccounts": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateBillingAccount": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateBillingAccount": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProjectBillingInfo": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProjectBillingInfo": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProjectBillingInfo": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json new file mode 100644 index 00000000000..e34eb066aa5 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/cloud/billing/v1/cloud_billing.proto", + "../../protos/google/cloud/billing/v1/cloud_catalog.proto" +] diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts new file mode 100644 index 00000000000..2f53a0645e8 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts @@ -0,0 +1,788 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/cloud_catalog_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './cloud_catalog_client_config.json'; +const version = require('../../../package.json').version; + +/** + * A catalog of Google Cloud Platform services and SKUs. + * Provides pricing information and metadata on Google Cloud Platform services + * and SKUs. + * @class + * @memberof v1 + */ +export class CloudCatalogClient { + 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}; + pathTemplates: {[name: string]: gax.PathTemplate}; + cloudCatalogStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CloudCatalogClient. + * + * @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 CloudCatalogClient({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 CloudCatalogClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // 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 useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + servicePathTemplate: new this._gaxModule.PathTemplate( + 'services/{service}' + ), + skuPathTemplate: new this._gaxModule.PathTemplate( + 'services/{service}/skus/{sku}' + ), + }; + + // 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 = { + listServices: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services'), + listSkus: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'skus') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.billing.v1.CloudCatalog', 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.cloudCatalogStub) { + return this.cloudCatalogStub; + } + + // Put together the "service stub" for + // google.cloud.billing.v1.CloudCatalog. + this.cloudCatalogStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.billing.v1.CloudCatalog') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.billing.v1.CloudCatalog, + 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 cloudCatalogStubMethods = + ['listServices', 'listSkus']; + for (const methodName of cloudCatalogStubMethods) { + const callPromise = this.cloudCatalogStub.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.cloudCatalogStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudbilling.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 'cloudbilling.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/cloud-billing', + 'https://www.googleapis.com/auth/cloud-billing.readonly', + '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 -- + // ------------------- + + /** + * Lists all public cloud services. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.pageSize + * Requested page size. Defaults to 5000. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListServices` + * call. If unspecified, the first page of results is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Service]{@link google.cloud.billing.v1.Service}. + * 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 `listServicesAsync()` + * 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. + */ + listServices( + request?: protos.google.cloud.billing.v1.IListServicesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IService[], + protos.google.cloud.billing.v1.IListServicesRequest|null, + protos.google.cloud.billing.v1.IListServicesResponse + ]>; + listServices( + request: protos.google.cloud.billing.v1.IListServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListServicesRequest, + protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, + protos.google.cloud.billing.v1.IService>): void; + listServices( + request: protos.google.cloud.billing.v1.IListServicesRequest, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListServicesRequest, + protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, + protos.google.cloud.billing.v1.IService>): void; + listServices( + request?: protos.google.cloud.billing.v1.IListServicesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.billing.v1.IListServicesRequest, + protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, + protos.google.cloud.billing.v1.IService>, + callback?: PaginationCallback< + protos.google.cloud.billing.v1.IListServicesRequest, + protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, + protos.google.cloud.billing.v1.IService>): + Promise<[ + protos.google.cloud.billing.v1.IService[], + protos.google.cloud.billing.v1.IListServicesRequest|null, + protos.google.cloud.billing.v1.IListServicesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof 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.listServices(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 {number} request.pageSize + * Requested page size. Defaults to 5000. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListServices` + * call. If unspecified, the first page of results is returned. + * @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 [Service]{@link google.cloud.billing.v1.Service} 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 `listServicesAsync()` + * 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. + */ + listServicesStream( + request?: protos.google.cloud.billing.v1.IListServicesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listServices']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServices.createStream( + this.innerApiCalls.listServices as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listServices`, 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 {number} request.pageSize + * Requested page size. Defaults to 5000. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListServices` + * call. If unspecified, the first page of results is returned. + * @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 + * [Service]{@link google.cloud.billing.v1.Service}. 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/cloud_catalog.list_services.js + * region_tag:cloudbilling_v1_generated_CloudCatalog_ListServices_async + */ + listServicesAsync( + request?: protos.google.cloud.billing.v1.IListServicesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listServices']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServices.asyncIterate( + this.innerApiCalls['listServices'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists all publicly available SKUs for a given cloud service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the service. + * Example: "services/DA34-426B-A397" + * @param {google.protobuf.Timestamp} request.startTime + * Optional inclusive start time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + * @param {google.protobuf.Timestamp} request.endTime + * Optional exclusive end time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + * @param {string} request.currencyCode + * The ISO 4217 currency code for the pricing info in the response proto. + * Will use the conversion rate as of start_time. + * Optional. If not specified USD will be used. + * @param {number} request.pageSize + * Requested page size. Defaults to 5000. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListSkus` + * call. If unspecified, the first page of results is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Sku]{@link google.cloud.billing.v1.Sku}. + * 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 `listSkusAsync()` + * 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. + */ + listSkus( + request?: protos.google.cloud.billing.v1.IListSkusRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.ISku[], + protos.google.cloud.billing.v1.IListSkusRequest|null, + protos.google.cloud.billing.v1.IListSkusResponse + ]>; + listSkus( + request: protos.google.cloud.billing.v1.IListSkusRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListSkusRequest, + protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, + protos.google.cloud.billing.v1.ISku>): void; + listSkus( + request: protos.google.cloud.billing.v1.IListSkusRequest, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListSkusRequest, + protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, + protos.google.cloud.billing.v1.ISku>): void; + listSkus( + request?: protos.google.cloud.billing.v1.IListSkusRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.billing.v1.IListSkusRequest, + protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, + protos.google.cloud.billing.v1.ISku>, + callback?: PaginationCallback< + protos.google.cloud.billing.v1.IListSkusRequest, + protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, + protos.google.cloud.billing.v1.ISku>): + Promise<[ + protos.google.cloud.billing.v1.ISku[], + protos.google.cloud.billing.v1.IListSkusRequest|null, + protos.google.cloud.billing.v1.IListSkusResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listSkus(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the service. + * Example: "services/DA34-426B-A397" + * @param {google.protobuf.Timestamp} request.startTime + * Optional inclusive start time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + * @param {google.protobuf.Timestamp} request.endTime + * Optional exclusive end time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + * @param {string} request.currencyCode + * The ISO 4217 currency code for the pricing info in the response proto. + * Will use the conversion rate as of start_time. + * Optional. If not specified USD will be used. + * @param {number} request.pageSize + * Requested page size. Defaults to 5000. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListSkus` + * call. If unspecified, the first page of results is returned. + * @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 [Sku]{@link google.cloud.billing.v1.Sku} 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 `listSkusAsync()` + * 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. + */ + listSkusStream( + request?: protos.google.cloud.billing.v1.IListSkusRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listSkus']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSkus.createStream( + this.innerApiCalls.listSkus as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listSkus`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the service. + * Example: "services/DA34-426B-A397" + * @param {google.protobuf.Timestamp} request.startTime + * Optional inclusive start time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + * @param {google.protobuf.Timestamp} request.endTime + * Optional exclusive end time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + * @param {string} request.currencyCode + * The ISO 4217 currency code for the pricing info in the response proto. + * Will use the conversion rate as of start_time. + * Optional. If not specified USD will be used. + * @param {number} request.pageSize + * Requested page size. Defaults to 5000. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListSkus` + * call. If unspecified, the first page of results is returned. + * @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 + * [Sku]{@link google.cloud.billing.v1.Sku}. 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/cloud_catalog.list_skus.js + * region_tag:cloudbilling_v1_generated_CloudCatalog_ListSkus_async + */ + listSkusAsync( + request?: protos.google.cloud.billing.v1.IListSkusRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listSkus']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSkus.asyncIterate( + this.innerApiCalls['listSkus'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified service resource name string. + * + * @param {string} service + * @returns {string} Resource name string. + */ + servicePath(service:string) { + return this.pathTemplates.servicePathTemplate.render({ + service: service, + }); + } + + /** + * Parse the service from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).service; + } + + /** + * Return a fully-qualified sku resource name string. + * + * @param {string} service + * @param {string} sku + * @returns {string} Resource name string. + */ + skuPath(service:string,sku:string) { + return this.pathTemplates.skuPathTemplate.render({ + service: service, + sku: sku, + }); + } + + /** + * Parse the service from Sku resource. + * + * @param {string} skuName + * A fully-qualified path representing Sku resource. + * @returns {string} A string representing the service. + */ + matchServiceFromSkuName(skuName: string) { + return this.pathTemplates.skuPathTemplate.match(skuName).service; + } + + /** + * Parse the sku from Sku resource. + * + * @param {string} skuName + * A fully-qualified path representing Sku resource. + * @returns {string} A string representing the sku. + */ + matchSkuFromSkuName(skuName: string) { + return this.pathTemplates.skuPathTemplate.match(skuName).sku; + } + + /** + * 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.cloudCatalogStub && !this._terminated) { + return this.cloudCatalogStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json new file mode 100644 index 00000000000..65eb2dffc09 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json @@ -0,0 +1,36 @@ +{ + "interfaces": { + "google.cloud.billing.v1.CloudCatalog": { + "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": { + "ListServices": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListSkus": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json new file mode 100644 index 00000000000..e34eb066aa5 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/cloud/billing/v1/cloud_billing.proto", + "../../protos/google/cloud/billing/v1/cloud_catalog.proto" +] diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..57395f94def --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json @@ -0,0 +1,173 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.billing.v1", + "libraryPackage": "@google-cloud/billing", + "services": { + "CloudBilling": { + "clients": { + "grpc": { + "libraryClient": "CloudBillingClient", + "rpcs": { + "GetBillingAccount": { + "methods": [ + "getBillingAccount" + ] + }, + "UpdateBillingAccount": { + "methods": [ + "updateBillingAccount" + ] + }, + "CreateBillingAccount": { + "methods": [ + "createBillingAccount" + ] + }, + "GetProjectBillingInfo": { + "methods": [ + "getProjectBillingInfo" + ] + }, + "UpdateProjectBillingInfo": { + "methods": [ + "updateProjectBillingInfo" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "ListBillingAccounts": { + "methods": [ + "listBillingAccounts", + "listBillingAccountsStream", + "listBillingAccountsAsync" + ] + }, + "ListProjectBillingInfo": { + "methods": [ + "listProjectBillingInfo", + "listProjectBillingInfoStream", + "listProjectBillingInfoAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CloudBillingClient", + "rpcs": { + "GetBillingAccount": { + "methods": [ + "getBillingAccount" + ] + }, + "UpdateBillingAccount": { + "methods": [ + "updateBillingAccount" + ] + }, + "CreateBillingAccount": { + "methods": [ + "createBillingAccount" + ] + }, + "GetProjectBillingInfo": { + "methods": [ + "getProjectBillingInfo" + ] + }, + "UpdateProjectBillingInfo": { + "methods": [ + "updateProjectBillingInfo" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "ListBillingAccounts": { + "methods": [ + "listBillingAccounts", + "listBillingAccountsStream", + "listBillingAccountsAsync" + ] + }, + "ListProjectBillingInfo": { + "methods": [ + "listProjectBillingInfo", + "listProjectBillingInfoStream", + "listProjectBillingInfoAsync" + ] + } + } + } + } + }, + "CloudCatalog": { + "clients": { + "grpc": { + "libraryClient": "CloudCatalogClient", + "rpcs": { + "ListServices": { + "methods": [ + "listServices", + "listServicesStream", + "listServicesAsync" + ] + }, + "ListSkus": { + "methods": [ + "listSkus", + "listSkusStream", + "listSkusAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CloudCatalogClient", + "rpcs": { + "ListServices": { + "methods": [ + "listServices", + "listServicesStream", + "listServicesAsync" + ] + }, + "ListSkus": { + "methods": [ + "listSkus", + "listSkusStream", + "listSkusAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts new file mode 100644 index 00000000000..def6d7cf917 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {CloudBillingClient} from './cloud_billing_client'; +export {CloudCatalogClient} from './cloud_catalog_client'; diff --git a/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..09c87aa5083 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 billing = require('@google-cloud/billing'); + +function main() { + const cloudBillingClient = new billing.CloudBillingClient(); + const cloudCatalogClient = new billing.CloudCatalogClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..08be974583e --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {CloudBillingClient, CloudCatalogClient} from '@google-cloud/billing'; + +// check that the client class type name can be used +function doStuffWithCloudBillingClient(client: CloudBillingClient) { + client.close(); +} +function doStuffWithCloudCatalogClient(client: CloudCatalogClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const cloudBillingClient = new CloudBillingClient(); + doStuffWithCloudBillingClient(cloudBillingClient); + // check that the client instance can be created + const cloudCatalogClient = new CloudCatalogClient(); + doStuffWithCloudCatalogClient(cloudCatalogClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-billing/v1/system-test/install.ts b/owl-bot-staging/google-cloud-billing/v1/system-test/install.ts new file mode 100644 index 00000000000..557a57558e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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-billing/v1/test/gapic_cloud_billing_v1.ts b/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_billing_v1.ts new file mode 100644 index 00000000000..5b87b5fffec --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_billing_v1.ts @@ -0,0 +1,1549 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as cloudbillingModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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.CloudBillingClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = cloudbillingModule.v1.CloudBillingClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = cloudbillingModule.v1.CloudBillingClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = cloudbillingModule.v1.CloudBillingClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new cloudbillingModule.v1.CloudBillingClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudBillingStub, undefined); + await client.initialize(); + assert(client.cloudBillingStub); + }); + + it('has close method for the initialized client', done => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.cloudBillingStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudBillingStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getBillingAccount', () => { + it('invokes getBillingAccount without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.BillingAccount() + ); + client.innerApiCalls.getBillingAccount = stubSimpleCall(expectedResponse); + const [response] = await client.getBillingAccount(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getBillingAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getBillingAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getBillingAccount without error using callback', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.BillingAccount() + ); + client.innerApiCalls.getBillingAccount = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBillingAccount( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getBillingAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getBillingAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getBillingAccount with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getBillingAccount = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getBillingAccount(request), expectedError); + const actualRequest = (client.innerApiCalls.getBillingAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getBillingAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getBillingAccount with closed client', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getBillingAccount(request), expectedError); + }); + }); + + describe('updateBillingAccount', () => { + it('invokes updateBillingAccount without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.BillingAccount() + ); + client.innerApiCalls.updateBillingAccount = stubSimpleCall(expectedResponse); + const [response] = await client.updateBillingAccount(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateBillingAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateBillingAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateBillingAccount without error using callback', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.BillingAccount() + ); + client.innerApiCalls.updateBillingAccount = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateBillingAccount( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateBillingAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateBillingAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateBillingAccount with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateBillingAccount = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateBillingAccount(request), expectedError); + const actualRequest = (client.innerApiCalls.updateBillingAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateBillingAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateBillingAccount with closed client', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateBillingAccount(request), expectedError); + }); + }); + + describe('createBillingAccount', () => { + it('invokes createBillingAccount without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.CreateBillingAccountRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.BillingAccount() + ); + client.innerApiCalls.createBillingAccount = stubSimpleCall(expectedResponse); + const [response] = await client.createBillingAccount(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createBillingAccount without error using callback', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.CreateBillingAccountRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.BillingAccount() + ); + client.innerApiCalls.createBillingAccount = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createBillingAccount( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createBillingAccount with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.CreateBillingAccountRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.createBillingAccount = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createBillingAccount(request), expectedError); + }); + + it('invokes createBillingAccount with closed client', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.CreateBillingAccountRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createBillingAccount(request), expectedError); + }); + }); + + describe('getProjectBillingInfo', () => { + it('invokes getProjectBillingInfo without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.ProjectBillingInfo() + ); + client.innerApiCalls.getProjectBillingInfo = stubSimpleCall(expectedResponse); + const [response] = await client.getProjectBillingInfo(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProjectBillingInfo without error using callback', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.ProjectBillingInfo() + ); + client.innerApiCalls.getProjectBillingInfo = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProjectBillingInfo( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IProjectBillingInfo|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProjectBillingInfo with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProjectBillingInfo = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProjectBillingInfo(request), expectedError); + const actualRequest = (client.innerApiCalls.getProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProjectBillingInfo with closed client', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProjectBillingInfo(request), expectedError); + }); + }); + + describe('updateProjectBillingInfo', () => { + it('invokes updateProjectBillingInfo without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.ProjectBillingInfo() + ); + client.innerApiCalls.updateProjectBillingInfo = stubSimpleCall(expectedResponse); + const [response] = await client.updateProjectBillingInfo(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProjectBillingInfo without error using callback', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.ProjectBillingInfo() + ); + client.innerApiCalls.updateProjectBillingInfo = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProjectBillingInfo( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IProjectBillingInfo|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProjectBillingInfo with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProjectBillingInfo = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProjectBillingInfo(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProjectBillingInfo with closed client', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProjectBillingInfo(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + 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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + 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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + 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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + 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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + 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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + 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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('listBillingAccounts', () => { + it('invokes listBillingAccounts without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListBillingAccountsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + ]; + client.innerApiCalls.listBillingAccounts = stubSimpleCall(expectedResponse); + const [response] = await client.listBillingAccounts(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listBillingAccounts without error using callback', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListBillingAccountsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + ]; + client.innerApiCalls.listBillingAccounts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBillingAccounts( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listBillingAccounts with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListBillingAccountsRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.listBillingAccounts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listBillingAccounts(request), expectedError); + }); + + it('invokes listBillingAccountsStream without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListBillingAccountsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + ]; + client.descriptors.page.listBillingAccounts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listBillingAccountsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.BillingAccount[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.BillingAccount) => { + 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.listBillingAccounts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listBillingAccounts, request)); + }); + + it('invokes listBillingAccountsStream with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListBillingAccountsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listBillingAccounts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listBillingAccountsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.BillingAccount[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.BillingAccount) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listBillingAccounts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listBillingAccounts, request)); + }); + + it('uses async iteration with listBillingAccounts without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListBillingAccountsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + ]; + client.descriptors.page.listBillingAccounts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.billing.v1.IBillingAccount[] = []; + const iterable = client.listBillingAccountsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listBillingAccounts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listBillingAccounts with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListBillingAccountsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listBillingAccounts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listBillingAccountsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.billing.v1.IBillingAccount[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listBillingAccounts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('listProjectBillingInfo', () => { + it('invokes listProjectBillingInfo without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + ]; + client.innerApiCalls.listProjectBillingInfo = stubSimpleCall(expectedResponse); + const [response] = await client.listProjectBillingInfo(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProjectBillingInfo without error using callback', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + ]; + client.innerApiCalls.listProjectBillingInfo = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProjectBillingInfo( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IProjectBillingInfo[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProjectBillingInfo with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProjectBillingInfo = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProjectBillingInfo(request), expectedError); + const actualRequest = (client.innerApiCalls.listProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProjectBillingInfoStream without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + ]; + client.descriptors.page.listProjectBillingInfo.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProjectBillingInfoStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.ProjectBillingInfo[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.ProjectBillingInfo) => { + 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.listProjectBillingInfo.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProjectBillingInfo, request)); + assert( + (client.descriptors.page.listProjectBillingInfo.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProjectBillingInfoStream with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProjectBillingInfo.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProjectBillingInfoStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.ProjectBillingInfo[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.ProjectBillingInfo) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProjectBillingInfo.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProjectBillingInfo, request)); + assert( + (client.descriptors.page.listProjectBillingInfo.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProjectBillingInfo without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + ]; + client.descriptors.page.listProjectBillingInfo.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.billing.v1.IProjectBillingInfo[] = []; + const iterable = client.listProjectBillingInfoAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProjectBillingInfo with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProjectBillingInfo.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProjectBillingInfoAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.billing.v1.IProjectBillingInfo[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('billingAccount', () => { + const fakePath = "/rendered/path/billingAccount"; + const expectedParameters = { + billing_account: "billingAccountValue", + }; + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.billingAccountPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.billingAccountPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('billingAccountPath', () => { + const result = client.billingAccountPath("billingAccountValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.billingAccountPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchBillingAccountFromBillingAccountName', () => { + const result = client.matchBillingAccountFromBillingAccountName(fakePath); + assert.strictEqual(result, "billingAccountValue"); + assert((client.pathTemplates.billingAccountPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('service', () => { + const fakePath = "/rendered/path/service"; + const expectedParameters = { + service: "serviceValue", + }; + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath("serviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('sku', () => { + const fakePath = "/rendered/path/sku"; + const expectedParameters = { + service: "serviceValue", + sku: "skuValue", + }; + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.skuPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.skuPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('skuPath', () => { + const result = client.skuPath("serviceValue", "skuValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.skuPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchServiceFromSkuName', () => { + const result = client.matchServiceFromSkuName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.skuPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSkuFromSkuName', () => { + const result = client.matchSkuFromSkuName(fakePath); + assert.strictEqual(result, "skuValue"); + assert((client.pathTemplates.skuPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts b/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts new file mode 100644 index 00000000000..2b09f24d4d7 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts @@ -0,0 +1,688 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as cloudcatalogModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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.CloudCatalogClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = cloudcatalogModule.v1.CloudCatalogClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = cloudcatalogModule.v1.CloudCatalogClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = cloudcatalogModule.v1.CloudCatalogClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudCatalogStub, undefined); + await client.initialize(); + assert(client.cloudCatalogStub); + }); + + it('has close method for the initialized client', done => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.cloudCatalogStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudCatalogStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('listServices', () => { + it('invokes listServices without error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListServicesRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + ]; + client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); + const [response] = await client.listServices(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listServices without error using callback', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListServicesRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + ]; + client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServices( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IService[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listServices with error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListServicesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.listServices = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listServices(request), expectedError); + }); + + it('invokes listServicesStream without error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListServicesRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + ]; + client.descriptors.page.listServices.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.Service[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.Service) => { + 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.listServices.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServices, request)); + }); + + it('invokes listServicesStream with error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListServicesRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listServices.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.Service[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.Service) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServices, request)); + }); + + it('uses async iteration with listServices without error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListServicesRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + ]; + client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.billing.v1.IService[] = []; + const iterable = client.listServicesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listServices with error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListServicesRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServicesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.billing.v1.IService[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('listSkus', () => { + it('invokes listSkus without error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListSkusRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + ]; + client.innerApiCalls.listSkus = stubSimpleCall(expectedResponse); + const [response] = await client.listSkus(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSkus as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSkus as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSkus without error using callback', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListSkusRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + ]; + client.innerApiCalls.listSkus = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSkus( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.ISku[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSkus as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSkus as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSkus with error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListSkusRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSkus = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listSkus(request), expectedError); + const actualRequest = (client.innerApiCalls.listSkus as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSkus as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSkusStream without error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListSkusRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + ]; + client.descriptors.page.listSkus.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listSkusStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.Sku[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.Sku) => { + 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.listSkus.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSkus, request)); + assert( + (client.descriptors.page.listSkus.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listSkusStream with error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListSkusRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSkus.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listSkusStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.Sku[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.Sku) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listSkus.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSkus, request)); + assert( + (client.descriptors.page.listSkus.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSkus without error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListSkusRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + ]; + client.descriptors.page.listSkus.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.billing.v1.ISku[] = []; + const iterable = client.listSkusAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSkus.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSkus.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSkus with error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListSkusRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSkus.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSkusAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.billing.v1.ISku[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSkus.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSkus.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('service', () => { + const fakePath = "/rendered/path/service"; + const expectedParameters = { + service: "serviceValue", + }; + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath("serviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('sku', () => { + const fakePath = "/rendered/path/sku"; + const expectedParameters = { + service: "serviceValue", + sku: "skuValue", + }; + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.skuPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.skuPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('skuPath', () => { + const result = client.skuPath("serviceValue", "skuValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.skuPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchServiceFromSkuName', () => { + const result = client.matchServiceFromSkuName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.skuPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSkuFromSkuName', () => { + const result = client.matchSkuFromSkuName(fakePath); + assert.strictEqual(result, "skuValue"); + assert((client.pathTemplates.skuPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-billing/v1/tsconfig.json b/owl-bot-staging/google-cloud-billing/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/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-billing/v1/webpack.config.js b/owl-bot-staging/google-cloud-billing/v1/webpack.config.js new file mode 100644 index 00000000000..d2282430c03 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/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: 'CloudBilling', + filename: './cloud-billing.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', +}; From 273b3187e0776153770ed3c37b52ad967ee6fa9e Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 30 Nov 2022 04:46:54 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../google-cloud-billing/v1/.eslintignore | 7 - .../google-cloud-billing/v1/.eslintrc.json | 3 - .../google-cloud-billing/v1/.gitignore | 14 - .../google-cloud-billing/v1/.jsdoc.js | 55 - .../google-cloud-billing/v1/.mocharc.js | 33 - .../google-cloud-billing/v1/.prettierrc.js | 22 - .../google-cloud-billing/v1/README.md | 1 - .../v1/linkinator.config.json | 16 - .../google-cloud-billing/v1/package.json | 65 - .../cloud/billing/v1/cloud_billing.proto | 373 ---- .../cloud/billing/v1/cloud_catalog.proto | 363 ---- .../cloud_billing.create_billing_account.js | 64 - .../v1/cloud_billing.get_billing_account.js | 62 - .../v1/cloud_billing.get_iam_policy.js | 67 - .../cloud_billing.get_project_billing_info.js | 62 - .../v1/cloud_billing.list_billing_accounts.js | 78 - ...cloud_billing.list_project_billing_info.js | 75 - .../v1/cloud_billing.set_iam_policy.js | 77 - .../v1/cloud_billing.test_iam_permissions.js | 70 - .../cloud_billing.update_billing_account.js | 71 - ...oud_billing.update_project_billing_info.js | 67 - .../v1/cloud_catalog.list_services.js | 68 - .../generated/v1/cloud_catalog.list_skus.js | 98 -- ...ppet_metadata.google.cloud.billing.v1.json | 563 ------ .../google-cloud-billing/v1/src/index.ts | 27 - .../v1/src/v1/cloud_billing_client.ts | 1454 ---------------- .../src/v1/cloud_billing_client_config.json | 76 - .../v1/src/v1/cloud_billing_proto_list.json | 4 - .../v1/src/v1/cloud_catalog_client.ts | 788 --------- .../src/v1/cloud_catalog_client_config.json | 36 - .../v1/src/v1/cloud_catalog_proto_list.json | 4 - .../v1/src/v1/gapic_metadata.json | 173 -- .../google-cloud-billing/v1/src/v1/index.ts | 20 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1/system-test/install.ts | 49 - .../v1/test/gapic_cloud_billing_v1.ts | 1549 ----------------- .../v1/test/gapic_cloud_catalog_v1.ts | 688 -------- .../google-cloud-billing/v1/tsconfig.json | 19 - .../google-cloud-billing/v1/webpack.config.js | 64 - .../cloud/billing/v1/cloud_billing.proto | 65 +- .../cloud/billing/v1/cloud_catalog.proto | 68 +- .../google-cloud-billing/protos/protos.d.ts | 144 +- .../google-cloud-billing/protos/protos.js | 414 ++++- .../google-cloud-billing/protos/protos.json | 50 +- .../cloud_billing.create_billing_account.js | 2 +- ...ppet_metadata.google.cloud.billing.v1.json | 6 +- .../src/v1/cloud_billing_client.ts | 37 +- .../src/v1/cloud_catalog_client.ts | 6 +- 49 files changed, 659 insertions(+), 7524 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-billing/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-billing/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-billing/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-billing/v1/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto delete mode 100644 owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_billing_v1.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/webpack.config.js diff --git a/owl-bot-staging/google-cloud-billing/v1/.eslintignore b/owl-bot-staging/google-cloud-billing/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-billing/v1/.eslintrc.json b/owl-bot-staging/google-cloud-billing/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-billing/v1/.gitignore b/owl-bot-staging/google-cloud-billing/v1/.gitignore deleted file mode 100644 index 5d32b23782f..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.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-billing/v1/.jsdoc.js b/owl-bot-staging/google-cloud-billing/v1/.jsdoc.js deleted file mode 100644 index a1fe10efe19..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file 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 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/billing', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-billing/v1/.mocharc.js b/owl-bot-staging/google-cloud-billing/v1/.mocharc.js deleted file mode 100644 index 481c522b00f..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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-billing/v1/.prettierrc.js b/owl-bot-staging/google-cloud-billing/v1/.prettierrc.js deleted file mode 100644 index 494e147865d..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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-billing/v1/README.md b/owl-bot-staging/google-cloud-billing/v1/README.md deleted file mode 100644 index 4f22cab915e..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Billing: Nodejs Client diff --git a/owl-bot-staging/google-cloud-billing/v1/linkinator.config.json b/owl-bot-staging/google-cloud-billing/v1/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "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-billing/v1/package.json b/owl-bot-staging/google-cloud-billing/v1/package.json deleted file mode 100644 index 761cb3cfd5d..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/billing", - "version": "0.1.0", - "description": "Billing client for Node.js", - "repository": "googleapis/nodejs-billing", - "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 billing", - "billing", - "cloud billing", - "cloud catalog" - ], - "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.2" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.62", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.0.3", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.3", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto b/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto deleted file mode 100644 index b98f0fd7c26..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto +++ /dev/null @@ -1,373 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.billing.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/protobuf/field_mask.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/billing/v1;billing"; -option java_multiple_files = true; -option java_outer_classname = "CloudBillingProto"; -option java_package = "com.google.cloud.billing.v1"; - -// Retrieves the Google Cloud Console billing accounts and associates them with -// projects. -service CloudBilling { - option (google.api.default_host) = "cloudbilling.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-billing," - "https://www.googleapis.com/auth/cloud-billing.readonly," - "https://www.googleapis.com/auth/cloud-platform"; - - // Gets information about a billing account. The current authenticated user - // must be a [viewer of the billing - // account](https://cloud.google.com/billing/docs/how-to/billing-access). - rpc GetBillingAccount(GetBillingAccountRequest) returns (BillingAccount) { - option (google.api.http) = { - get: "/v1/{name=billingAccounts/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists the billing accounts that the current authenticated user has - // permission to - // [view](https://cloud.google.com/billing/docs/how-to/billing-access). - rpc ListBillingAccounts(ListBillingAccountsRequest) returns (ListBillingAccountsResponse) { - option (google.api.http) = { - get: "/v1/billingAccounts" - }; - option (google.api.method_signature) = ""; - } - - // Updates a billing account's fields. - // Currently the only field that can be edited is `display_name`. - // The current authenticated user must have the `billing.accounts.update` - // IAM permission, which is typically given to the - // [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) - // of the billing account. - rpc UpdateBillingAccount(UpdateBillingAccountRequest) returns (BillingAccount) { - option (google.api.http) = { - patch: "/v1/{name=billingAccounts/*}" - body: "account" - }; - option (google.api.method_signature) = "name,account"; - } - - // This method creates [billing - // subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). - // - // Google Cloud resellers should use the - // Channel Services APIs, - // [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) - // and - // [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). - // - // When creating a subaccount, the current authenticated user must have the - // `billing.accounts.update` IAM permission on the parent account, which is - // typically given to billing account - // [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). - // This method will return an error if the parent account has not been - // provisioned as a reseller account. - rpc CreateBillingAccount(CreateBillingAccountRequest) returns (BillingAccount) { - option (google.api.http) = { - post: "/v1/billingAccounts" - body: "billing_account" - }; - option (google.api.method_signature) = "billing_account"; - } - - // Lists the projects associated with a billing account. The current - // authenticated user must have the `billing.resourceAssociations.list` IAM - // permission, which is often given to billing account - // [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). - rpc ListProjectBillingInfo(ListProjectBillingInfoRequest) returns (ListProjectBillingInfoResponse) { - option (google.api.http) = { - get: "/v1/{name=billingAccounts/*}/projects" - }; - option (google.api.method_signature) = "name"; - } - - // Gets the billing information for a project. The current authenticated user - // must have the `resourcemanager.projects.get` permission for the project, - // which can be granted by assigning the [Project - // Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) - // role. - rpc GetProjectBillingInfo(GetProjectBillingInfoRequest) returns (ProjectBillingInfo) { - option (google.api.http) = { - get: "/v1/{name=projects/*}/billingInfo" - }; - option (google.api.method_signature) = "name"; - } - - // Sets or updates the billing account associated with a project. You specify - // the new billing account by setting the `billing_account_name` in the - // `ProjectBillingInfo` resource to the resource name of a billing account. - // Associating a project with an open billing account enables billing on the - // project and allows charges for resource usage. If the project already had a - // billing account, this method changes the billing account used for resource - // usage charges. - // - // *Note:* Incurred charges that have not yet been reported in the transaction - // history of the Google Cloud Console might be billed to the new billing - // account, even if the charge occurred before the new billing account was - // assigned to the project. - // - // The current authenticated user must have ownership privileges for both the - // [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo - // ) and the [billing - // account](https://cloud.google.com/billing/docs/how-to/billing-access). - // - // You can disable billing on the project by setting the - // `billing_account_name` field to empty. This action disassociates the - // current billing account from the project. Any billable activity of your - // in-use services will stop, and your application could stop functioning as - // expected. Any unbilled charges to date will be billed to the previously - // associated account. The current authenticated user must be either an owner - // of the project or an owner of the billing account for the project. - // - // Note that associating a project with a *closed* billing account will have - // much the same effect as disabling billing on the project: any paid - // resources used by the project will be shut down. Thus, unless you wish to - // disable billing, you should always call this method with the name of an - // *open* billing account. - rpc UpdateProjectBillingInfo(UpdateProjectBillingInfoRequest) returns (ProjectBillingInfo) { - option (google.api.http) = { - put: "/v1/{name=projects/*}/billingInfo" - body: "project_billing_info" - }; - option (google.api.method_signature) = "name,project_billing_info"; - } - - // Gets the access control policy for a billing account. - // The caller must have the `billing.accounts.getIamPolicy` permission on the - // account, which is often given to billing account - // [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - get: "/v1/{resource=billingAccounts/*}:getIamPolicy" - }; - option (google.api.method_signature) = "resource"; - } - - // Sets the access control policy for a billing account. Replaces any existing - // policy. - // The caller must have the `billing.accounts.setIamPolicy` permission on the - // account, which is often given to billing account - // [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v1/{resource=billingAccounts/*}:setIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource,policy"; - } - - // Tests the access control policy for a billing account. This method takes - // the resource and a set of permissions as input and returns the subset of - // the input permissions that the caller is allowed for that resource. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v1/{resource=billingAccounts/*}:testIamPermissions" - body: "*" - }; - option (google.api.method_signature) = "resource,permissions"; - } -} - -// A billing account in the -// [Google Cloud Console](https://console.cloud.google.com/). You can assign a -// billing account to one or more projects. -message BillingAccount { - // Output only. The resource name of the billing account. The resource name has the form - // `billingAccounts/{billing_account_id}`. For example, - // `billingAccounts/012345-567890-ABCDEF` would be the resource name for - // billing account `012345-567890-ABCDEF`. - string name = 1 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { - type: "cloudbilling.googleapis.com/BillingAccount" - } - ]; - - // Output only. True if the billing account is open, and will therefore be charged for any - // usage on associated projects. False if the billing account is closed, and - // therefore projects associated with it will be unable to use paid services. - bool open = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The display name given to the billing account, such as `My Billing - // Account`. This name is displayed in the Google Cloud Console. - string display_name = 3; - - // If this account is a - // [subaccount](https://cloud.google.com/billing/docs/concepts), then this - // will be the resource name of the parent billing account that it is being - // resold through. - // Otherwise this will be empty. - string master_billing_account = 4; -} - -// Encapsulation of billing information for a Google Cloud Console project. A -// project has at most one associated billing account at a time (but a billing -// account can be assigned to multiple projects). -message ProjectBillingInfo { - // The resource name for the `ProjectBillingInfo`; has the form - // `projects/{project_id}/billingInfo`. For example, the resource name for the - // billing information for project `tokyo-rain-123` would be - // `projects/tokyo-rain-123/billingInfo`. This field is read-only. - string name = 1; - - // The ID of the project that this `ProjectBillingInfo` represents, such as - // `tokyo-rain-123`. This is a convenience field so that you don't need to - // parse the `name` field to obtain a project ID. This field is read-only. - string project_id = 2; - - // The resource name of the billing account associated with the project, if - // any. For example, `billingAccounts/012345-567890-ABCDEF`. - string billing_account_name = 3; - - // True if the project is associated with an open billing account, to which - // usage on the project is charged. False if the project is associated with a - // closed billing account, or no billing account at all, and therefore cannot - // use paid services. This field is read-only. - bool billing_enabled = 4; -} - -// Request message for `GetBillingAccount`. -message GetBillingAccountRequest { - // Required. The resource name of the billing account to retrieve. For example, - // `billingAccounts/012345-567890-ABCDEF`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudbilling.googleapis.com/BillingAccount" - } - ]; -} - -// Request message for `ListBillingAccounts`. -message ListBillingAccountsRequest { - // Requested page size. The maximum page size is 100; this is also the - // default. - int32 page_size = 1; - - // A token identifying a page of results to return. This should be a - // `next_page_token` value returned from a previous `ListBillingAccounts` - // call. If unspecified, the first page of results is returned. - string page_token = 2; - - // Options for how to filter the returned billing accounts. - // Currently this only supports filtering for - // [subaccounts](https://cloud.google.com/billing/docs/concepts) under a - // single provided reseller billing account. - // (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). - // Boolean algebra and other fields are not currently supported. - string filter = 3; -} - -// Response message for `ListBillingAccounts`. -message ListBillingAccountsResponse { - // A list of billing accounts. - repeated BillingAccount billing_accounts = 1; - - // A token to retrieve the next page of results. To retrieve the next page, - // call `ListBillingAccounts` again with the `page_token` field set to this - // value. This field is empty if there are no more results to retrieve. - string next_page_token = 2; -} - -// Request message for `CreateBillingAccount`. -message CreateBillingAccountRequest { - // Required. The billing account resource to create. - // Currently CreateBillingAccount only supports subaccount creation, so - // any created billing accounts must be under a provided parent billing - // account. - BillingAccount billing_account = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for `UpdateBillingAccount`. -message UpdateBillingAccountRequest { - // Required. The name of the billing account resource to be updated. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudbilling.googleapis.com/BillingAccount" - } - ]; - - // Required. The billing account resource to replace the resource on the server. - BillingAccount account = 2 [(google.api.field_behavior) = REQUIRED]; - - // The update mask applied to the resource. - // Only "display_name" is currently supported. - google.protobuf.FieldMask update_mask = 3; -} - -// Request message for `ListProjectBillingInfo`. -message ListProjectBillingInfoRequest { - // Required. The resource name of the billing account associated with the projects that - // you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudbilling.googleapis.com/BillingAccount" - } - ]; - - // Requested page size. The maximum page size is 100; this is also the - // default. - int32 page_size = 2; - - // A token identifying a page of results to be returned. This should be a - // `next_page_token` value returned from a previous `ListProjectBillingInfo` - // call. If unspecified, the first page of results is returned. - string page_token = 3; -} - -// Request message for `ListProjectBillingInfoResponse`. -message ListProjectBillingInfoResponse { - // A list of `ProjectBillingInfo` resources representing the projects - // associated with the billing account. - repeated ProjectBillingInfo project_billing_info = 1; - - // A token to retrieve the next page of results. To retrieve the next page, - // call `ListProjectBillingInfo` again with the `page_token` field set to this - // value. This field is empty if there are no more results to retrieve. - string next_page_token = 2; -} - -// Request message for `GetProjectBillingInfo`. -message GetProjectBillingInfoRequest { - // Required. The resource name of the project for which billing information is - // retrieved. For example, `projects/tokyo-rain-123`. - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for `UpdateProjectBillingInfo`. -message UpdateProjectBillingInfoRequest { - // Required. The resource name of the project associated with the billing information - // that you want to update. For example, `projects/tokyo-rain-123`. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The new billing information for the project. Read-only fields are ignored; - // thus, you can leave empty all fields except `billing_account_name`. - ProjectBillingInfo project_billing_info = 2; -} diff --git a/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto b/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto deleted file mode 100644 index f3d46e62708..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto +++ /dev/null @@ -1,363 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.billing.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/money.proto"; - -option csharp_namespace = "Google.Cloud.Billing.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/billing/v1;billing"; -option java_multiple_files = true; -option java_outer_classname = "CloudCatalogProto"; -option java_package = "com.google.cloud.billing.v1"; -option objc_class_prefix = "CLDCTLG"; - -// A catalog of Google Cloud Platform services and SKUs. -// Provides pricing information and metadata on Google Cloud Platform services -// and SKUs. -service CloudCatalog { - option (google.api.default_host) = "cloudbilling.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-billing," - "https://www.googleapis.com/auth/cloud-billing.readonly," - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists all public cloud services. - rpc ListServices(ListServicesRequest) returns (ListServicesResponse) { - option (google.api.http) = { - get: "/v1/services" - }; - option (google.api.method_signature) = ""; - } - - // Lists all publicly available SKUs for a given cloud service. - rpc ListSkus(ListSkusRequest) returns (ListSkusResponse) { - option (google.api.http) = { - get: "/v1/{parent=services/*}/skus" - }; - option (google.api.method_signature) = "parent"; - } -} - -// Encapsulates a single service in Google Cloud Platform. -message Service { - option (google.api.resource) = { - type: "cloudbilling.googleapis.com/Service" - pattern: "services/{service}" - }; - - // The resource name for the service. - // Example: "services/DA34-426B-A397" - string name = 1; - - // The identifier for the service. - // Example: "DA34-426B-A397" - string service_id = 2; - - // A human readable display name for this service. - string display_name = 3; - - // The business under which the service is offered. - // Ex. "businessEntities/GCP", "businessEntities/Maps" - string business_entity_name = 4; -} - -// Encapsulates a single SKU in Google Cloud Platform -message Sku { - option (google.api.resource) = { - type: "cloudbilling.googleapis.com/Sku" - pattern: "services/{service}/skus/{sku}" - }; - - // The resource name for the SKU. - // Example: "services/DA34-426B-A397/skus/AA95-CD31-42FE" - string name = 1; - - // The identifier for the SKU. - // Example: "AA95-CD31-42FE" - string sku_id = 2; - - // A human readable description of the SKU, has a maximum length of 256 - // characters. - string description = 3; - - // The category hierarchy of this SKU, purely for organizational purpose. - Category category = 4; - - // List of service regions this SKU is offered at. - // Example: "asia-east1" - // Service regions can be found at https://cloud.google.com/about/locations/ - repeated string service_regions = 5; - - // A timeline of pricing info for this SKU in chronological order. - repeated PricingInfo pricing_info = 6; - - // Identifies the service provider. - // This is 'Google' for first party services in Google Cloud Platform. - string service_provider_name = 7; - - // The geographic taxonomy for this sku. - GeoTaxonomy geo_taxonomy = 8; -} - -// Represents the category hierarchy of a SKU. -message Category { - // The display name of the service this SKU belongs to. - string service_display_name = 1; - - // The type of product the SKU refers to. - // Example: "Compute", "Storage", "Network", "ApplicationServices" etc. - string resource_family = 2; - - // A group classification for related SKUs. - // Example: "RAM", "GPU", "Prediction", "Ops", "GoogleEgress" etc. - string resource_group = 3; - - // Represents how the SKU is consumed. - // Example: "OnDemand", "Preemptible", "Commit1Mo", "Commit1Yr" etc. - string usage_type = 4; -} - -// Represents the pricing information for a SKU at a single point of time. -message PricingInfo { - // The timestamp from which this pricing was effective within the requested - // time range. This is guaranteed to be greater than or equal to the - // start_time field in the request and less than the end_time field in the - // request. If a time range was not specified in the request this field will - // be equivalent to a time within the last 12 hours, indicating the latest - // pricing info. - google.protobuf.Timestamp effective_time = 1; - - // An optional human readable summary of the pricing information, has a - // maximum length of 256 characters. - string summary = 2; - - // Expresses the pricing formula. See `PricingExpression` for an example. - PricingExpression pricing_expression = 3; - - // Aggregation Info. This can be left unspecified if the pricing expression - // doesn't require aggregation. - AggregationInfo aggregation_info = 4; - - // Conversion rate used for currency conversion, from USD to the currency - // specified in the request. This includes any surcharge collected for billing - // in non USD currency. If a currency is not specified in the request this - // defaults to 1.0. - // Example: USD * currency_conversion_rate = JPY - double currency_conversion_rate = 5; -} - -// Expresses a mathematical pricing formula. For Example:- -// -// `usage_unit: GBy` -// `tiered_rates:` -// `[start_usage_amount: 20, unit_price: $10]` -// `[start_usage_amount: 100, unit_price: $5]` -// -// The above expresses a pricing formula where the first 20GB is free, the -// next 80GB is priced at $10 per GB followed by $5 per GB for additional -// usage. -message PricingExpression { - // The price rate indicating starting usage and its corresponding price. - message TierRate { - // Usage is priced at this rate only after this amount. - // Example: start_usage_amount of 10 indicates that the usage will be priced - // at the unit_price after the first 10 usage_units. - double start_usage_amount = 1; - - // The price per unit of usage. - // Example: unit_price of amount $10 indicates that each unit will cost $10. - google.type.Money unit_price = 2; - } - - // The short hand for unit of usage this pricing is specified in. - // Example: usage_unit of "GiBy" means that usage is specified in "Gibi Byte". - string usage_unit = 1; - - // The recommended quantity of units for displaying pricing info. When - // displaying pricing info it is recommended to display: - // (unit_price * display_quantity) per display_quantity usage_unit. - // This field does not affect the pricing formula and is for display purposes - // only. - // Example: If the unit_price is "0.0001 USD", the usage_unit is "GB" and - // the display_quantity is "1000" then the recommended way of displaying the - // pricing info is "0.10 USD per 1000 GB" - double display_quantity = 2; - - // The list of tiered rates for this pricing. The total cost is computed by - // applying each of the tiered rates on usage. This repeated list is sorted - // by ascending order of start_usage_amount. - repeated TierRate tiered_rates = 3; - - // The unit of usage in human readable form. - // Example: "gibi byte". - string usage_unit_description = 4; - - // The base unit for the SKU which is the unit used in usage exports. - // Example: "By" - string base_unit = 5; - - // The base unit in human readable form. - // Example: "byte". - string base_unit_description = 6; - - // Conversion factor for converting from price per usage_unit to price per - // base_unit, and start_usage_amount to start_usage_amount in base_unit. - // unit_price / base_unit_conversion_factor = price per base_unit. - // start_usage_amount * base_unit_conversion_factor = start_usage_amount in - // base_unit. - double base_unit_conversion_factor = 7; -} - -// Represents the aggregation level and interval for pricing of a single SKU. -message AggregationInfo { - // The level at which usage is aggregated to compute cost. - // Example: "ACCOUNT" aggregation level indicates that usage for tiered - // pricing is aggregated across all projects in a single account. - enum AggregationLevel { - AGGREGATION_LEVEL_UNSPECIFIED = 0; - - ACCOUNT = 1; - - PROJECT = 2; - } - - // The interval at which usage is aggregated to compute cost. - // Example: "MONTHLY" aggregation interval indicates that usage for tiered - // pricing is aggregated every month. - enum AggregationInterval { - AGGREGATION_INTERVAL_UNSPECIFIED = 0; - - DAILY = 1; - - MONTHLY = 2; - } - - AggregationLevel aggregation_level = 1; - - AggregationInterval aggregation_interval = 2; - - // The number of intervals to aggregate over. - // Example: If aggregation_level is "DAILY" and aggregation_count is 14, - // aggregation will be over 14 days. - int32 aggregation_count = 3; -} - -// Encapsulates the geographic taxonomy data for a sku. -message GeoTaxonomy { - // The type of Geo Taxonomy: GLOBAL, REGIONAL, or MULTI_REGIONAL. - enum Type { - // The type is not specified. - TYPE_UNSPECIFIED = 0; - - // The sku is global in nature, e.g. a license sku. Global skus are - // available in all regions, and so have an empty region list. - GLOBAL = 1; - - // The sku is available in a specific region, e.g. "us-west2". - REGIONAL = 2; - - // The sku is associated with multiple regions, e.g. "us-west2" and - // "us-east1". - MULTI_REGIONAL = 3; - } - - // The type of Geo Taxonomy: GLOBAL, REGIONAL, or MULTI_REGIONAL. - Type type = 1; - - // The list of regions associated with a sku. Empty for Global skus, which are - // associated with all Google Cloud regions. - repeated string regions = 2; -} - -// Request message for `ListServices`. -message ListServicesRequest { - // Requested page size. Defaults to 5000. - int32 page_size = 1; - - // A token identifying a page of results to return. This should be a - // `next_page_token` value returned from a previous `ListServices` - // call. If unspecified, the first page of results is returned. - string page_token = 2; -} - -// Response message for `ListServices`. -message ListServicesResponse { - // A list of services. - repeated Service services = 1; - - // A token to retrieve the next page of results. To retrieve the next page, - // call `ListServices` again with the `page_token` field set to this - // value. This field is empty if there are no more results to retrieve. - string next_page_token = 2; -} - -// Request message for `ListSkus`. -message ListSkusRequest { - // Required. The name of the service. - // Example: "services/DA34-426B-A397" - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudbilling.googleapis.com/Service" - } - ]; - - // Optional inclusive start time of the time range for which the pricing - // versions will be returned. Timestamps in the future are not allowed. - // The time range has to be within a single calendar month in - // America/Los_Angeles timezone. Time range as a whole is optional. If not - // specified, the latest pricing will be returned (up to 12 hours old at - // most). - google.protobuf.Timestamp start_time = 2; - - // Optional exclusive end time of the time range for which the pricing - // versions will be returned. Timestamps in the future are not allowed. - // The time range has to be within a single calendar month in - // America/Los_Angeles timezone. Time range as a whole is optional. If not - // specified, the latest pricing will be returned (up to 12 hours old at - // most). - google.protobuf.Timestamp end_time = 3; - - // The ISO 4217 currency code for the pricing info in the response proto. - // Will use the conversion rate as of start_time. - // Optional. If not specified USD will be used. - string currency_code = 4; - - // Requested page size. Defaults to 5000. - int32 page_size = 5; - - // A token identifying a page of results to return. This should be a - // `next_page_token` value returned from a previous `ListSkus` - // call. If unspecified, the first page of results is returned. - string page_token = 6; -} - -// Response message for `ListSkus`. -message ListSkusResponse { - // The list of public SKUs of the given service. - repeated Sku skus = 1; - - // A token to retrieve the next page of results. To retrieve the next page, - // call `ListSkus` again with the `page_token` field set to this - // value. This field is empty if there are no more results to retrieve. - string next_page_token = 2; -} diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js deleted file mode 100644 index 06e6462d716..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(billingAccount) { - // [START cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The billing account resource to create. - * Currently CreateBillingAccount only supports subaccount creation, so - * any created billing accounts must be under a provided parent billing - * account. - */ - // const billingAccount = {} - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callCreateBillingAccount() { - // Construct request - const request = { - billingAccount, - }; - - // Run request - const response = await billingClient.createBillingAccount(request); - console.log(response); - } - - callCreateBillingAccount(); - // [END cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js deleted file mode 100644 index 8d420a0e1a5..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the billing account to retrieve. For example, - * `billingAccounts/012345-567890-ABCDEF`. - */ - // const name = 'abc123' - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callGetBillingAccount() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await billingClient.getBillingAccount(request); - console.log(response); - } - - callGetBillingAccount(); - // [END cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js deleted file mode 100644 index df9f6c0a259..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 cloudbilling_v1_generated_CloudBilling_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. - */ - /** - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await billingClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END cloudbilling_v1_generated_CloudBilling_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-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js deleted file mode 100644 index 1b9bd0c1604..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the project for which billing information is - * retrieved. For example, `projects/tokyo-rain-123`. - */ - // const name = 'abc123' - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callGetProjectBillingInfo() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await billingClient.getProjectBillingInfo(request); - console.log(response); - } - - callGetProjectBillingInfo(); - // [END cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js deleted file mode 100644 index 916633c0352..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 page size. The maximum page size is 100; this is also the - * default. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListBillingAccounts` - * call. If unspecified, the first page of results is returned. - */ - // const pageToken = 'abc123' - /** - * Options for how to filter the returned billing accounts. - * Currently this only supports filtering for - * subaccounts (https://cloud.google.com/billing/docs/concepts) under a - * single provided reseller billing account. - * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). - * Boolean algebra and other fields are not currently supported. - */ - // const filter = 'abc123' - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callListBillingAccounts() { - // Construct request - const request = { - }; - - // Run request - const iterable = await billingClient.listBillingAccountsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListBillingAccounts(); - // [END cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js deleted file mode 100644 index 3ab054e3f1d..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the billing account associated with the projects that - * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. - */ - // const name = 'abc123' - /** - * Requested page size. The maximum page size is 100; this is also the - * default. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to be returned. This should be a - * `next_page_token` value returned from a previous `ListProjectBillingInfo` - * call. If unspecified, the first page of results is returned. - */ - // const pageToken = 'abc123' - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callListProjectBillingInfo() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await billingClient.listProjectBillingInfoAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProjectBillingInfo(); - // [END cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js deleted file mode 100644 index 41fa9a179ef..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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, policy) { - // [START cloudbilling_v1_generated_CloudBilling_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. - */ - /** - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * 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 a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await billingClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END cloudbilling_v1_generated_CloudBilling_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-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js deleted file mode 100644 index b1ffbd536e5..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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, permissions) { - // [START cloudbilling_v1_generated_CloudBilling_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. - */ - /** - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = 'abc123' - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await billingClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END cloudbilling_v1_generated_CloudBilling_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-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js deleted file mode 100644 index c487c7c3d5c..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, account) { - // [START cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the billing account resource to be updated. - */ - // const name = 'abc123' - /** - * Required. The billing account resource to replace the resource on the server. - */ - // const account = {} - /** - * The update mask applied to the resource. - * Only "display_name" is currently supported. - */ - // const updateMask = {} - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callUpdateBillingAccount() { - // Construct request - const request = { - name, - account, - }; - - // Run request - const response = await billingClient.updateBillingAccount(request); - console.log(response); - } - - callUpdateBillingAccount(); - // [END cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js deleted file mode 100644 index 0168c7c8daa..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the project associated with the billing information - * that you want to update. For example, `projects/tokyo-rain-123`. - */ - // const name = 'abc123' - /** - * The new billing information for the project. Read-only fields are ignored; - * thus, you can leave empty all fields except `billing_account_name`. - */ - // const projectBillingInfo = {} - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callUpdateProjectBillingInfo() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await billingClient.updateProjectBillingInfo(request); - console.log(response); - } - - callUpdateProjectBillingInfo(); - // [END cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js deleted file mode 100644 index c21a6be3aeb..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 cloudbilling_v1_generated_CloudCatalog_ListServices_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 page size. Defaults to 5000. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListServices` - * call. If unspecified, the first page of results is returned. - */ - // const pageToken = 'abc123' - - // Imports the Billing library - const {CloudCatalogClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudCatalogClient(); - - async function callListServices() { - // Construct request - const request = { - }; - - // Run request - const iterable = await billingClient.listServicesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListServices(); - // [END cloudbilling_v1_generated_CloudCatalog_ListServices_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js deleted file mode 100644 index 71decc1085d..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START cloudbilling_v1_generated_CloudCatalog_ListSkus_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the service. - * Example: "services/DA34-426B-A397" - */ - // const parent = 'abc123' - /** - * Optional inclusive start time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - */ - // const startTime = {} - /** - * Optional exclusive end time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - */ - // const endTime = {} - /** - * The ISO 4217 currency code for the pricing info in the response proto. - * Will use the conversion rate as of start_time. - * Optional. If not specified USD will be used. - */ - // const currencyCode = 'abc123' - /** - * Requested page size. Defaults to 5000. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListSkus` - * call. If unspecified, the first page of results is returned. - */ - // const pageToken = 'abc123' - - // Imports the Billing library - const {CloudCatalogClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudCatalogClient(); - - async function callListSkus() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await billingClient.listSkusAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListSkus(); - // [END cloudbilling_v1_generated_CloudCatalog_ListSkus_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json deleted file mode 100644 index e446c6b0814..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json +++ /dev/null @@ -1,563 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-billing", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.billing.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async", - "title": "CloudBilling getBillingAccount Sample", - "origin": "API_DEFINITION", - "description": " Gets information about a billing account. The current authenticated user must be a [viewer of the billing account](https://cloud.google.com/billing/docs/how-to/billing-access).", - "canonical": true, - "file": "cloud_billing.get_billing_account.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetBillingAccount", - "fullName": "google.cloud.billing.v1.CloudBilling.GetBillingAccount", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.billing.v1.BillingAccount", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "GetBillingAccount", - "fullName": "google.cloud.billing.v1.CloudBilling.GetBillingAccount", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async", - "title": "CloudBilling listBillingAccounts Sample", - "origin": "API_DEFINITION", - "description": " Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).", - "canonical": true, - "file": "cloud_billing.list_billing_accounts.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListBillingAccounts", - "fullName": "google.cloud.billing.v1.CloudBilling.ListBillingAccounts", - "async": true, - "parameters": [ - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.billing.v1.ListBillingAccountsResponse", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "ListBillingAccounts", - "fullName": "google.cloud.billing.v1.CloudBilling.ListBillingAccounts", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async", - "title": "CloudBilling updateBillingAccount Sample", - "origin": "API_DEFINITION", - "description": " Updates a billing account's fields. Currently the only field that can be edited is `display_name`. The current authenticated user must have the `billing.accounts.update` IAM permission, which is typically given to the [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing account.", - "canonical": true, - "file": "cloud_billing.update_billing_account.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateBillingAccount", - "fullName": "google.cloud.billing.v1.CloudBilling.UpdateBillingAccount", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "account", - "type": ".google.cloud.billing.v1.BillingAccount" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.billing.v1.BillingAccount", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "UpdateBillingAccount", - "fullName": "google.cloud.billing.v1.CloudBilling.UpdateBillingAccount", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async", - "title": "CloudBilling createBillingAccount Sample", - "origin": "API_DEFINITION", - "description": " This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned as a reseller account.", - "canonical": true, - "file": "cloud_billing.create_billing_account.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateBillingAccount", - "fullName": "google.cloud.billing.v1.CloudBilling.CreateBillingAccount", - "async": true, - "parameters": [ - { - "name": "billing_account", - "type": ".google.cloud.billing.v1.BillingAccount" - } - ], - "resultType": ".google.cloud.billing.v1.BillingAccount", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "CreateBillingAccount", - "fullName": "google.cloud.billing.v1.CloudBilling.CreateBillingAccount", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async", - "title": "CloudBilling listProjectBillingInfo Sample", - "origin": "API_DEFINITION", - "description": " Lists the projects associated with a billing account. The current authenticated user must have the `billing.resourceAssociations.list` IAM permission, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).", - "canonical": true, - "file": "cloud_billing.list_project_billing_info.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProjectBillingInfo", - "fullName": "google.cloud.billing.v1.CloudBilling.ListProjectBillingInfo", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.billing.v1.ListProjectBillingInfoResponse", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "ListProjectBillingInfo", - "fullName": "google.cloud.billing.v1.CloudBilling.ListProjectBillingInfo", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async", - "title": "CloudBilling getProjectBillingInfo Sample", - "origin": "API_DEFINITION", - "description": " Gets the billing information for a project. The current authenticated user must have the `resourcemanager.projects.get` permission for the project, which can be granted by assigning the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) role.", - "canonical": true, - "file": "cloud_billing.get_project_billing_info.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProjectBillingInfo", - "fullName": "google.cloud.billing.v1.CloudBilling.GetProjectBillingInfo", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.billing.v1.ProjectBillingInfo", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "GetProjectBillingInfo", - "fullName": "google.cloud.billing.v1.CloudBilling.GetProjectBillingInfo", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async", - "title": "CloudBilling updateProjectBillingInfo Sample", - "origin": "API_DEFINITION", - "description": " Sets or updates the billing account associated with a project. You specify the new billing account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the resource name of a billing account. Associating a project with an open billing account enables billing on the project and allows charges for resource usage. If the project already had a billing account, this method changes the billing account used for resource usage charges. *Note:* Incurred charges that have not yet been reported in the transaction history of the Google Cloud Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project. The current authenticated user must have ownership privileges for both the [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](https://cloud.google.com/billing/docs/how-to/billing-access). You can disable billing on the project by setting the `billing_account_name` field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project. Note that associating a project with a *closed* billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an *open* billing account.", - "canonical": true, - "file": "cloud_billing.update_project_billing_info.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProjectBillingInfo", - "fullName": "google.cloud.billing.v1.CloudBilling.UpdateProjectBillingInfo", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "project_billing_info", - "type": ".google.cloud.billing.v1.ProjectBillingInfo" - } - ], - "resultType": ".google.cloud.billing.v1.ProjectBillingInfo", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "UpdateProjectBillingInfo", - "fullName": "google.cloud.billing.v1.CloudBilling.UpdateProjectBillingInfo", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_GetIamPolicy_async", - "title": "CloudBilling getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets the access control policy for a billing account. The caller must have the `billing.accounts.getIamPolicy` permission on the account, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).", - "canonical": true, - "file": "cloud_billing.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.billing.v1.CloudBilling.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.billing.v1.CloudBilling.GetIamPolicy", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_SetIamPolicy_async", - "title": "CloudBilling setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the access control policy for a billing account. Replaces any existing policy. The caller must have the `billing.accounts.setIamPolicy` permission on the account, which is often given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).", - "canonical": true, - "file": "cloud_billing.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.billing.v1.CloudBilling.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.billing.v1.CloudBilling.SetIamPolicy", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_TestIamPermissions_async", - "title": "CloudBilling testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Tests the access control policy for a billing account. This method takes the resource and a set of permissions as input and returns the subset of the input permissions that the caller is allowed for that resource.", - "canonical": true, - "file": "cloud_billing.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.billing.v1.CloudBilling.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.billing.v1.CloudBilling.TestIamPermissions", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudCatalog_ListServices_async", - "title": "CloudBilling listServices Sample", - "origin": "API_DEFINITION", - "description": " Lists all public cloud services.", - "canonical": true, - "file": "cloud_catalog.list_services.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListServices", - "fullName": "google.cloud.billing.v1.CloudCatalog.ListServices", - "async": true, - "parameters": [ - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.billing.v1.ListServicesResponse", - "client": { - "shortName": "CloudCatalogClient", - "fullName": "google.cloud.billing.v1.CloudCatalogClient" - }, - "method": { - "shortName": "ListServices", - "fullName": "google.cloud.billing.v1.CloudCatalog.ListServices", - "service": { - "shortName": "CloudCatalog", - "fullName": "google.cloud.billing.v1.CloudCatalog" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudCatalog_ListSkus_async", - "title": "CloudBilling listSkus Sample", - "origin": "API_DEFINITION", - "description": " Lists all publicly available SKUs for a given cloud service.", - "canonical": true, - "file": "cloud_catalog.list_skus.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 90, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListSkus", - "fullName": "google.cloud.billing.v1.CloudCatalog.ListSkus", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "start_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "end_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "currency_code", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.billing.v1.ListSkusResponse", - "client": { - "shortName": "CloudCatalogClient", - "fullName": "google.cloud.billing.v1.CloudCatalogClient" - }, - "method": { - "shortName": "ListSkus", - "fullName": "google.cloud.billing.v1.CloudCatalog.ListSkus", - "service": { - "shortName": "CloudCatalog", - "fullName": "google.cloud.billing.v1.CloudCatalog" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/index.ts b/owl-bot-staging/google-cloud-billing/v1/src/index.ts deleted file mode 100644 index 6cac30c8973..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 CloudBillingClient = v1.CloudBillingClient; -type CloudBillingClient = v1.CloudBillingClient; -const CloudCatalogClient = v1.CloudCatalogClient; -type CloudCatalogClient = v1.CloudCatalogClient; -export {v1, CloudBillingClient, CloudCatalogClient}; -export default {v1, CloudBillingClient, CloudCatalogClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts deleted file mode 100644 index 5f4bf33e28f..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts +++ /dev/null @@ -1,1454 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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/cloud_billing_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './cloud_billing_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Retrieves the Google Cloud Console billing accounts and associates them with - * projects. - * @class - * @memberof v1 - */ -export class CloudBillingClient { - 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}; - pathTemplates: {[name: string]: gax.PathTemplate}; - cloudBillingStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CloudBillingClient. - * - * @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 CloudBillingClient({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 CloudBillingClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // 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 useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - billingAccountPathTemplate: new this._gaxModule.PathTemplate( - 'billingAccounts/{billing_account}' - ), - servicePathTemplate: new this._gaxModule.PathTemplate( - 'services/{service}' - ), - skuPathTemplate: new this._gaxModule.PathTemplate( - 'services/{service}/skus/{sku}' - ), - }; - - // 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 = { - listBillingAccounts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'billingAccounts'), - listProjectBillingInfo: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'projectBillingInfo') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.billing.v1.CloudBilling', 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.cloudBillingStub) { - return this.cloudBillingStub; - } - - // Put together the "service stub" for - // google.cloud.billing.v1.CloudBilling. - this.cloudBillingStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.billing.v1.CloudBilling') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.billing.v1.CloudBilling, - 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 cloudBillingStubMethods = - ['getBillingAccount', 'listBillingAccounts', 'updateBillingAccount', 'createBillingAccount', 'listProjectBillingInfo', 'getProjectBillingInfo', 'updateProjectBillingInfo', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of cloudBillingStubMethods) { - const callPromise = this.cloudBillingStub.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.cloudBillingStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudbilling.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 'cloudbilling.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/cloud-billing', - 'https://www.googleapis.com/auth/cloud-billing.readonly', - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets information about a billing account. The current authenticated user - * must be a [viewer of the billing - * account](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the billing account to retrieve. For example, - * `billingAccounts/012345-567890-ABCDEF`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. - * 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/cloud_billing.get_billing_account.js - * region_tag:cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async - */ - getBillingAccount( - request?: protos.google.cloud.billing.v1.IGetBillingAccountRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IGetBillingAccountRequest|undefined, {}|undefined - ]>; - getBillingAccount( - request: protos.google.cloud.billing.v1.IGetBillingAccountRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, - {}|null|undefined>): void; - getBillingAccount( - request: protos.google.cloud.billing.v1.IGetBillingAccountRequest, - callback: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, - {}|null|undefined>): void; - getBillingAccount( - request?: protos.google.cloud.billing.v1.IGetBillingAccountRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IGetBillingAccountRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getBillingAccount(request, options, callback); - } -/** - * Updates a billing account's fields. - * Currently the only field that can be edited is `display_name`. - * The current authenticated user must have the `billing.accounts.update` - * IAM permission, which is typically given to the - * [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) - * of the billing account. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the billing account resource to be updated. - * @param {google.cloud.billing.v1.BillingAccount} request.account - * Required. The billing account resource to replace the resource on the server. - * @param {google.protobuf.FieldMask} request.updateMask - * The update mask applied to the resource. - * Only "display_name" is currently supported. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. - * 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/cloud_billing.update_billing_account.js - * region_tag:cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async - */ - updateBillingAccount( - request?: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|undefined, {}|undefined - ]>; - updateBillingAccount( - request: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, - {}|null|undefined>): void; - updateBillingAccount( - request: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, - callback: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, - {}|null|undefined>): void; - updateBillingAccount( - request?: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateBillingAccount(request, options, callback); - } -/** - * This method creates [billing - * subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). - * - * Google Cloud resellers should use the - * Channel Services APIs, - * [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) - * and - * [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). - * - * When creating a subaccount, the current authenticated user must have the - * `billing.accounts.update` IAM permission on the parent account, which is - * typically given to billing account - * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). - * This method will return an error if the parent account has not been - * provisioned as a reseller account. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.billing.v1.BillingAccount} request.billingAccount - * Required. The billing account resource to create. - * Currently CreateBillingAccount only supports subaccount creation, so - * any created billing accounts must be under a provided parent billing - * account. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. - * 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/cloud_billing.create_billing_account.js - * region_tag:cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async - */ - createBillingAccount( - request?: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.ICreateBillingAccountRequest|undefined, {}|undefined - ]>; - createBillingAccount( - request: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, - {}|null|undefined>): void; - createBillingAccount( - request: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, - callback: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, - {}|null|undefined>): void; - createBillingAccount( - request?: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.ICreateBillingAccountRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof 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.createBillingAccount(request, options, callback); - } -/** - * Gets the billing information for a project. The current authenticated user - * must have the `resourcemanager.projects.get` permission for the project, - * which can be granted by assigning the [Project - * Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) - * role. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the project for which billing information is - * retrieved. For example, `projects/tokyo-rain-123`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. - * 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/cloud_billing.get_project_billing_info.js - * region_tag:cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async - */ - getProjectBillingInfo( - request?: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|undefined, {}|undefined - ]>; - getProjectBillingInfo( - request: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, - {}|null|undefined>): void; - getProjectBillingInfo( - request: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, - callback: Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, - {}|null|undefined>): void; - getProjectBillingInfo( - request?: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getProjectBillingInfo(request, options, callback); - } -/** - * Sets or updates the billing account associated with a project. You specify - * the new billing account by setting the `billing_account_name` in the - * `ProjectBillingInfo` resource to the resource name of a billing account. - * Associating a project with an open billing account enables billing on the - * project and allows charges for resource usage. If the project already had a - * billing account, this method changes the billing account used for resource - * usage charges. - * - * *Note:* Incurred charges that have not yet been reported in the transaction - * history of the Google Cloud Console might be billed to the new billing - * account, even if the charge occurred before the new billing account was - * assigned to the project. - * - * The current authenticated user must have ownership privileges for both the - * [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo - * ) and the [billing - * account](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * You can disable billing on the project by setting the - * `billing_account_name` field to empty. This action disassociates the - * current billing account from the project. Any billable activity of your - * in-use services will stop, and your application could stop functioning as - * expected. Any unbilled charges to date will be billed to the previously - * associated account. The current authenticated user must be either an owner - * of the project or an owner of the billing account for the project. - * - * Note that associating a project with a *closed* billing account will have - * much the same effect as disabling billing on the project: any paid - * resources used by the project will be shut down. Thus, unless you wish to - * disable billing, you should always call this method with the name of an - * *open* billing account. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the project associated with the billing information - * that you want to update. For example, `projects/tokyo-rain-123`. - * @param {google.cloud.billing.v1.ProjectBillingInfo} request.projectBillingInfo - * The new billing information for the project. Read-only fields are ignored; - * thus, you can leave empty all fields except `billing_account_name`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. - * 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/cloud_billing.update_project_billing_info.js - * region_tag:cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async - */ - updateProjectBillingInfo( - request?: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|undefined, {}|undefined - ]>; - updateProjectBillingInfo( - request: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, - {}|null|undefined>): void; - updateProjectBillingInfo( - request: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, - callback: Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, - {}|null|undefined>): void; - updateProjectBillingInfo( - request?: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProjectBillingInfo(request, options, callback); - } -/** - * Gets the access control policy for a billing account. - * The caller must have the `billing.accounts.getIamPolicy` permission on the - * account, which is often given to billing account - * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.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/cloud_billing.get_iam_policy.js - * region_tag:cloudbilling_v1_generated_CloudBilling_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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); - } -/** - * Sets the access control policy for a billing account. Replaces any existing - * policy. - * The caller must have the `billing.accounts.setIamPolicy` permission on the - * account, which is often given to billing account - * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * 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 a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.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/cloud_billing.set_iam_policy.js - * region_tag:cloudbilling_v1_generated_CloudBilling_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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); - } -/** - * Tests the access control policy for a billing account. This method takes - * the resource and a set of permissions as input and returns the subset of - * the input permissions that the caller is allowed for that resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * 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/cloud_billing.test_iam_permissions.js - * region_tag:cloudbilling_v1_generated_CloudBilling_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 the billing accounts that the current authenticated user has - * permission to - * [view](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * @param {Object} request - * The request object that will be sent. - * @param {number} request.pageSize - * Requested page size. The maximum page size is 100; this is also the - * default. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListBillingAccounts` - * call. If unspecified, the first page of results is returned. - * @param {string} request.filter - * Options for how to filter the returned billing accounts. - * Currently this only supports filtering for - * [subaccounts](https://cloud.google.com/billing/docs/concepts) under a - * single provided reseller billing account. - * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). - * Boolean algebra and other fields are not currently supported. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. - * 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 `listBillingAccountsAsync()` - * 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. - */ - listBillingAccounts( - request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount[], - protos.google.cloud.billing.v1.IListBillingAccountsRequest|null, - protos.google.cloud.billing.v1.IListBillingAccountsResponse - ]>; - listBillingAccounts( - request: protos.google.cloud.billing.v1.IListBillingAccountsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListBillingAccountsRequest, - protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, - protos.google.cloud.billing.v1.IBillingAccount>): void; - listBillingAccounts( - request: protos.google.cloud.billing.v1.IListBillingAccountsRequest, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListBillingAccountsRequest, - protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, - protos.google.cloud.billing.v1.IBillingAccount>): void; - listBillingAccounts( - request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.billing.v1.IListBillingAccountsRequest, - protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, - protos.google.cloud.billing.v1.IBillingAccount>, - callback?: PaginationCallback< - protos.google.cloud.billing.v1.IListBillingAccountsRequest, - protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, - protos.google.cloud.billing.v1.IBillingAccount>): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount[], - protos.google.cloud.billing.v1.IListBillingAccountsRequest|null, - protos.google.cloud.billing.v1.IListBillingAccountsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof 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.listBillingAccounts(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 {number} request.pageSize - * Requested page size. The maximum page size is 100; this is also the - * default. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListBillingAccounts` - * call. If unspecified, the first page of results is returned. - * @param {string} request.filter - * Options for how to filter the returned billing accounts. - * Currently this only supports filtering for - * [subaccounts](https://cloud.google.com/billing/docs/concepts) under a - * single provided reseller billing account. - * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). - * Boolean algebra and other fields are not currently supported. - * @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 [BillingAccount]{@link google.cloud.billing.v1.BillingAccount} 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 `listBillingAccountsAsync()` - * 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. - */ - listBillingAccountsStream( - request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listBillingAccounts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listBillingAccounts.createStream( - this.innerApiCalls.listBillingAccounts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listBillingAccounts`, 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 {number} request.pageSize - * Requested page size. The maximum page size is 100; this is also the - * default. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListBillingAccounts` - * call. If unspecified, the first page of results is returned. - * @param {string} request.filter - * Options for how to filter the returned billing accounts. - * Currently this only supports filtering for - * [subaccounts](https://cloud.google.com/billing/docs/concepts) under a - * single provided reseller billing account. - * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). - * Boolean algebra and other fields are not currently supported. - * @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 - * [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. 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/cloud_billing.list_billing_accounts.js - * region_tag:cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async - */ - listBillingAccountsAsync( - request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listBillingAccounts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listBillingAccounts.asyncIterate( - this.innerApiCalls['listBillingAccounts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the projects associated with a billing account. The current - * authenticated user must have the `billing.resourceAssociations.list` IAM - * permission, which is often given to billing account - * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the billing account associated with the projects that - * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. - * @param {number} request.pageSize - * Requested page size. The maximum page size is 100; this is also the - * default. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This should be a - * `next_page_token` value returned from a previous `ListProjectBillingInfo` - * call. If unspecified, the first page of results is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. - * 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 `listProjectBillingInfoAsync()` - * 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. - */ - listProjectBillingInfo( - request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IProjectBillingInfo[], - protos.google.cloud.billing.v1.IListProjectBillingInfoRequest|null, - protos.google.cloud.billing.v1.IListProjectBillingInfoResponse - ]>; - listProjectBillingInfo( - request: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, - protos.google.cloud.billing.v1.IProjectBillingInfo>): void; - listProjectBillingInfo( - request: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, - protos.google.cloud.billing.v1.IProjectBillingInfo>): void; - listProjectBillingInfo( - request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, - protos.google.cloud.billing.v1.IProjectBillingInfo>, - callback?: PaginationCallback< - protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, - protos.google.cloud.billing.v1.IProjectBillingInfo>): - Promise<[ - protos.google.cloud.billing.v1.IProjectBillingInfo[], - protos.google.cloud.billing.v1.IListProjectBillingInfoRequest|null, - protos.google.cloud.billing.v1.IListProjectBillingInfoResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProjectBillingInfo(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.name - * Required. The resource name of the billing account associated with the projects that - * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. - * @param {number} request.pageSize - * Requested page size. The maximum page size is 100; this is also the - * default. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This should be a - * `next_page_token` value returned from a previous `ListProjectBillingInfo` - * call. If unspecified, the first page of results is returned. - * @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 [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo} 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 `listProjectBillingInfoAsync()` - * 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. - */ - listProjectBillingInfoStream( - request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProjectBillingInfo']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProjectBillingInfo.createStream( - this.innerApiCalls.listProjectBillingInfo as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProjectBillingInfo`, 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.name - * Required. The resource name of the billing account associated with the projects that - * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. - * @param {number} request.pageSize - * Requested page size. The maximum page size is 100; this is also the - * default. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This should be a - * `next_page_token` value returned from a previous `ListProjectBillingInfo` - * call. If unspecified, the first page of results is returned. - * @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 - * [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. 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/cloud_billing.list_project_billing_info.js - * region_tag:cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async - */ - listProjectBillingInfoAsync( - request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProjectBillingInfo']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProjectBillingInfo.asyncIterate( - this.innerApiCalls['listProjectBillingInfo'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified billingAccount resource name string. - * - * @param {string} billing_account - * @returns {string} Resource name string. - */ - billingAccountPath(billingAccount:string) { - return this.pathTemplates.billingAccountPathTemplate.render({ - billing_account: billingAccount, - }); - } - - /** - * Parse the billing_account from BillingAccount resource. - * - * @param {string} billingAccountName - * A fully-qualified path representing BillingAccount resource. - * @returns {string} A string representing the billing_account. - */ - matchBillingAccountFromBillingAccountName(billingAccountName: string) { - return this.pathTemplates.billingAccountPathTemplate.match(billingAccountName).billing_account; - } - - /** - * Return a fully-qualified service resource name string. - * - * @param {string} service - * @returns {string} Resource name string. - */ - servicePath(service:string) { - return this.pathTemplates.servicePathTemplate.render({ - service: service, - }); - } - - /** - * Parse the service from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).service; - } - - /** - * Return a fully-qualified sku resource name string. - * - * @param {string} service - * @param {string} sku - * @returns {string} Resource name string. - */ - skuPath(service:string,sku:string) { - return this.pathTemplates.skuPathTemplate.render({ - service: service, - sku: sku, - }); - } - - /** - * Parse the service from Sku resource. - * - * @param {string} skuName - * A fully-qualified path representing Sku resource. - * @returns {string} A string representing the service. - */ - matchServiceFromSkuName(skuName: string) { - return this.pathTemplates.skuPathTemplate.match(skuName).service; - } - - /** - * Parse the sku from Sku resource. - * - * @param {string} skuName - * A fully-qualified path representing Sku resource. - * @returns {string} A string representing the sku. - */ - matchSkuFromSkuName(skuName: string) { - return this.pathTemplates.skuPathTemplate.match(skuName).sku; - } - - /** - * 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.cloudBillingStub && !this._terminated) { - return this.cloudBillingStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json deleted file mode 100644 index e98db6a6e4b..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "interfaces": { - "google.cloud.billing.v1.CloudBilling": { - "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": { - "GetBillingAccount": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListBillingAccounts": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateBillingAccount": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateBillingAccount": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProjectBillingInfo": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProjectBillingInfo": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProjectBillingInfo": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json deleted file mode 100644 index e34eb066aa5..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "../../protos/google/cloud/billing/v1/cloud_billing.proto", - "../../protos/google/cloud/billing/v1/cloud_catalog.proto" -] diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts deleted file mode 100644 index 2f53a0645e8..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts +++ /dev/null @@ -1,788 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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/cloud_catalog_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './cloud_catalog_client_config.json'; -const version = require('../../../package.json').version; - -/** - * A catalog of Google Cloud Platform services and SKUs. - * Provides pricing information and metadata on Google Cloud Platform services - * and SKUs. - * @class - * @memberof v1 - */ -export class CloudCatalogClient { - 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}; - pathTemplates: {[name: string]: gax.PathTemplate}; - cloudCatalogStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CloudCatalogClient. - * - * @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 CloudCatalogClient({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 CloudCatalogClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // 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 useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - servicePathTemplate: new this._gaxModule.PathTemplate( - 'services/{service}' - ), - skuPathTemplate: new this._gaxModule.PathTemplate( - 'services/{service}/skus/{sku}' - ), - }; - - // 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 = { - listServices: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services'), - listSkus: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'skus') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.billing.v1.CloudCatalog', 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.cloudCatalogStub) { - return this.cloudCatalogStub; - } - - // Put together the "service stub" for - // google.cloud.billing.v1.CloudCatalog. - this.cloudCatalogStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.billing.v1.CloudCatalog') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.billing.v1.CloudCatalog, - 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 cloudCatalogStubMethods = - ['listServices', 'listSkus']; - for (const methodName of cloudCatalogStubMethods) { - const callPromise = this.cloudCatalogStub.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.cloudCatalogStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudbilling.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 'cloudbilling.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/cloud-billing', - 'https://www.googleapis.com/auth/cloud-billing.readonly', - '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 -- - // ------------------- - - /** - * Lists all public cloud services. - * - * @param {Object} request - * The request object that will be sent. - * @param {number} request.pageSize - * Requested page size. Defaults to 5000. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListServices` - * call. If unspecified, the first page of results is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Service]{@link google.cloud.billing.v1.Service}. - * 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 `listServicesAsync()` - * 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. - */ - listServices( - request?: protos.google.cloud.billing.v1.IListServicesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IService[], - protos.google.cloud.billing.v1.IListServicesRequest|null, - protos.google.cloud.billing.v1.IListServicesResponse - ]>; - listServices( - request: protos.google.cloud.billing.v1.IListServicesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListServicesRequest, - protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, - protos.google.cloud.billing.v1.IService>): void; - listServices( - request: protos.google.cloud.billing.v1.IListServicesRequest, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListServicesRequest, - protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, - protos.google.cloud.billing.v1.IService>): void; - listServices( - request?: protos.google.cloud.billing.v1.IListServicesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.billing.v1.IListServicesRequest, - protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, - protos.google.cloud.billing.v1.IService>, - callback?: PaginationCallback< - protos.google.cloud.billing.v1.IListServicesRequest, - protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, - protos.google.cloud.billing.v1.IService>): - Promise<[ - protos.google.cloud.billing.v1.IService[], - protos.google.cloud.billing.v1.IListServicesRequest|null, - protos.google.cloud.billing.v1.IListServicesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof 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.listServices(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 {number} request.pageSize - * Requested page size. Defaults to 5000. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListServices` - * call. If unspecified, the first page of results is returned. - * @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 [Service]{@link google.cloud.billing.v1.Service} 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 `listServicesAsync()` - * 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. - */ - listServicesStream( - request?: protos.google.cloud.billing.v1.IListServicesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listServices']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServices.createStream( - this.innerApiCalls.listServices as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listServices`, 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 {number} request.pageSize - * Requested page size. Defaults to 5000. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListServices` - * call. If unspecified, the first page of results is returned. - * @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 - * [Service]{@link google.cloud.billing.v1.Service}. 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/cloud_catalog.list_services.js - * region_tag:cloudbilling_v1_generated_CloudCatalog_ListServices_async - */ - listServicesAsync( - request?: protos.google.cloud.billing.v1.IListServicesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listServices']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServices.asyncIterate( - this.innerApiCalls['listServices'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists all publicly available SKUs for a given cloud service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the service. - * Example: "services/DA34-426B-A397" - * @param {google.protobuf.Timestamp} request.startTime - * Optional inclusive start time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - * @param {google.protobuf.Timestamp} request.endTime - * Optional exclusive end time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - * @param {string} request.currencyCode - * The ISO 4217 currency code for the pricing info in the response proto. - * Will use the conversion rate as of start_time. - * Optional. If not specified USD will be used. - * @param {number} request.pageSize - * Requested page size. Defaults to 5000. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListSkus` - * call. If unspecified, the first page of results is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Sku]{@link google.cloud.billing.v1.Sku}. - * 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 `listSkusAsync()` - * 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. - */ - listSkus( - request?: protos.google.cloud.billing.v1.IListSkusRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.ISku[], - protos.google.cloud.billing.v1.IListSkusRequest|null, - protos.google.cloud.billing.v1.IListSkusResponse - ]>; - listSkus( - request: protos.google.cloud.billing.v1.IListSkusRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListSkusRequest, - protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, - protos.google.cloud.billing.v1.ISku>): void; - listSkus( - request: protos.google.cloud.billing.v1.IListSkusRequest, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListSkusRequest, - protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, - protos.google.cloud.billing.v1.ISku>): void; - listSkus( - request?: protos.google.cloud.billing.v1.IListSkusRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.billing.v1.IListSkusRequest, - protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, - protos.google.cloud.billing.v1.ISku>, - callback?: PaginationCallback< - protos.google.cloud.billing.v1.IListSkusRequest, - protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, - protos.google.cloud.billing.v1.ISku>): - Promise<[ - protos.google.cloud.billing.v1.ISku[], - protos.google.cloud.billing.v1.IListSkusRequest|null, - protos.google.cloud.billing.v1.IListSkusResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listSkus(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the service. - * Example: "services/DA34-426B-A397" - * @param {google.protobuf.Timestamp} request.startTime - * Optional inclusive start time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - * @param {google.protobuf.Timestamp} request.endTime - * Optional exclusive end time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - * @param {string} request.currencyCode - * The ISO 4217 currency code for the pricing info in the response proto. - * Will use the conversion rate as of start_time. - * Optional. If not specified USD will be used. - * @param {number} request.pageSize - * Requested page size. Defaults to 5000. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListSkus` - * call. If unspecified, the first page of results is returned. - * @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 [Sku]{@link google.cloud.billing.v1.Sku} 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 `listSkusAsync()` - * 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. - */ - listSkusStream( - request?: protos.google.cloud.billing.v1.IListSkusRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listSkus']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSkus.createStream( - this.innerApiCalls.listSkus as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listSkus`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the service. - * Example: "services/DA34-426B-A397" - * @param {google.protobuf.Timestamp} request.startTime - * Optional inclusive start time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - * @param {google.protobuf.Timestamp} request.endTime - * Optional exclusive end time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - * @param {string} request.currencyCode - * The ISO 4217 currency code for the pricing info in the response proto. - * Will use the conversion rate as of start_time. - * Optional. If not specified USD will be used. - * @param {number} request.pageSize - * Requested page size. Defaults to 5000. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListSkus` - * call. If unspecified, the first page of results is returned. - * @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 - * [Sku]{@link google.cloud.billing.v1.Sku}. 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/cloud_catalog.list_skus.js - * region_tag:cloudbilling_v1_generated_CloudCatalog_ListSkus_async - */ - listSkusAsync( - request?: protos.google.cloud.billing.v1.IListSkusRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listSkus']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSkus.asyncIterate( - this.innerApiCalls['listSkus'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified service resource name string. - * - * @param {string} service - * @returns {string} Resource name string. - */ - servicePath(service:string) { - return this.pathTemplates.servicePathTemplate.render({ - service: service, - }); - } - - /** - * Parse the service from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).service; - } - - /** - * Return a fully-qualified sku resource name string. - * - * @param {string} service - * @param {string} sku - * @returns {string} Resource name string. - */ - skuPath(service:string,sku:string) { - return this.pathTemplates.skuPathTemplate.render({ - service: service, - sku: sku, - }); - } - - /** - * Parse the service from Sku resource. - * - * @param {string} skuName - * A fully-qualified path representing Sku resource. - * @returns {string} A string representing the service. - */ - matchServiceFromSkuName(skuName: string) { - return this.pathTemplates.skuPathTemplate.match(skuName).service; - } - - /** - * Parse the sku from Sku resource. - * - * @param {string} skuName - * A fully-qualified path representing Sku resource. - * @returns {string} A string representing the sku. - */ - matchSkuFromSkuName(skuName: string) { - return this.pathTemplates.skuPathTemplate.match(skuName).sku; - } - - /** - * 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.cloudCatalogStub && !this._terminated) { - return this.cloudCatalogStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json deleted file mode 100644 index 65eb2dffc09..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "interfaces": { - "google.cloud.billing.v1.CloudCatalog": { - "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": { - "ListServices": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListSkus": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json deleted file mode 100644 index e34eb066aa5..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "../../protos/google/cloud/billing/v1/cloud_billing.proto", - "../../protos/google/cloud/billing/v1/cloud_catalog.proto" -] diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 57395f94def..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,173 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.billing.v1", - "libraryPackage": "@google-cloud/billing", - "services": { - "CloudBilling": { - "clients": { - "grpc": { - "libraryClient": "CloudBillingClient", - "rpcs": { - "GetBillingAccount": { - "methods": [ - "getBillingAccount" - ] - }, - "UpdateBillingAccount": { - "methods": [ - "updateBillingAccount" - ] - }, - "CreateBillingAccount": { - "methods": [ - "createBillingAccount" - ] - }, - "GetProjectBillingInfo": { - "methods": [ - "getProjectBillingInfo" - ] - }, - "UpdateProjectBillingInfo": { - "methods": [ - "updateProjectBillingInfo" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "ListBillingAccounts": { - "methods": [ - "listBillingAccounts", - "listBillingAccountsStream", - "listBillingAccountsAsync" - ] - }, - "ListProjectBillingInfo": { - "methods": [ - "listProjectBillingInfo", - "listProjectBillingInfoStream", - "listProjectBillingInfoAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CloudBillingClient", - "rpcs": { - "GetBillingAccount": { - "methods": [ - "getBillingAccount" - ] - }, - "UpdateBillingAccount": { - "methods": [ - "updateBillingAccount" - ] - }, - "CreateBillingAccount": { - "methods": [ - "createBillingAccount" - ] - }, - "GetProjectBillingInfo": { - "methods": [ - "getProjectBillingInfo" - ] - }, - "UpdateProjectBillingInfo": { - "methods": [ - "updateProjectBillingInfo" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "ListBillingAccounts": { - "methods": [ - "listBillingAccounts", - "listBillingAccountsStream", - "listBillingAccountsAsync" - ] - }, - "ListProjectBillingInfo": { - "methods": [ - "listProjectBillingInfo", - "listProjectBillingInfoStream", - "listProjectBillingInfoAsync" - ] - } - } - } - } - }, - "CloudCatalog": { - "clients": { - "grpc": { - "libraryClient": "CloudCatalogClient", - "rpcs": { - "ListServices": { - "methods": [ - "listServices", - "listServicesStream", - "listServicesAsync" - ] - }, - "ListSkus": { - "methods": [ - "listSkus", - "listSkusStream", - "listSkusAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CloudCatalogClient", - "rpcs": { - "ListServices": { - "methods": [ - "listServices", - "listServicesStream", - "listServicesAsync" - ] - }, - "ListSkus": { - "methods": [ - "listSkus", - "listSkusStream", - "listSkusAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts deleted file mode 100644 index def6d7cf917..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 {CloudBillingClient} from './cloud_billing_client'; -export {CloudCatalogClient} from './cloud_catalog_client'; diff --git a/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 09c87aa5083..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 billing = require('@google-cloud/billing'); - -function main() { - const cloudBillingClient = new billing.CloudBillingClient(); - const cloudCatalogClient = new billing.CloudCatalogClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 08be974583e..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 {CloudBillingClient, CloudCatalogClient} from '@google-cloud/billing'; - -// check that the client class type name can be used -function doStuffWithCloudBillingClient(client: CloudBillingClient) { - client.close(); -} -function doStuffWithCloudCatalogClient(client: CloudCatalogClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const cloudBillingClient = new CloudBillingClient(); - doStuffWithCloudBillingClient(cloudBillingClient); - // check that the client instance can be created - const cloudCatalogClient = new CloudCatalogClient(); - doStuffWithCloudCatalogClient(cloudCatalogClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-billing/v1/system-test/install.ts b/owl-bot-staging/google-cloud-billing/v1/system-test/install.ts deleted file mode 100644 index 557a57558e1..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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-billing/v1/test/gapic_cloud_billing_v1.ts b/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_billing_v1.ts deleted file mode 100644 index 5b87b5fffec..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_billing_v1.ts +++ /dev/null @@ -1,1549 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as cloudbillingModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .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.CloudBillingClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = cloudbillingModule.v1.CloudBillingClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = cloudbillingModule.v1.CloudBillingClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = cloudbillingModule.v1.CloudBillingClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudbillingModule.v1.CloudBillingClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudBillingStub, undefined); - await client.initialize(); - assert(client.cloudBillingStub); - }); - - it('has close method for the initialized client', done => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.cloudBillingStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudBillingStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('getBillingAccount', () => { - it('invokes getBillingAccount without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.BillingAccount() - ); - client.innerApiCalls.getBillingAccount = stubSimpleCall(expectedResponse); - const [response] = await client.getBillingAccount(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBillingAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBillingAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBillingAccount without error using callback', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.BillingAccount() - ); - client.innerApiCalls.getBillingAccount = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBillingAccount( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBillingAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBillingAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBillingAccount with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getBillingAccount = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getBillingAccount(request), expectedError); - const actualRequest = (client.innerApiCalls.getBillingAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBillingAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBillingAccount with closed client', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getBillingAccount(request), expectedError); - }); - }); - - describe('updateBillingAccount', () => { - it('invokes updateBillingAccount without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.BillingAccount() - ); - client.innerApiCalls.updateBillingAccount = stubSimpleCall(expectedResponse); - const [response] = await client.updateBillingAccount(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateBillingAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBillingAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBillingAccount without error using callback', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.BillingAccount() - ); - client.innerApiCalls.updateBillingAccount = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateBillingAccount( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateBillingAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBillingAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBillingAccount with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateBillingAccount = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateBillingAccount(request), expectedError); - const actualRequest = (client.innerApiCalls.updateBillingAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBillingAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBillingAccount with closed client', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateBillingAccount(request), expectedError); - }); - }); - - describe('createBillingAccount', () => { - it('invokes createBillingAccount without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.CreateBillingAccountRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.BillingAccount() - ); - client.innerApiCalls.createBillingAccount = stubSimpleCall(expectedResponse); - const [response] = await client.createBillingAccount(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes createBillingAccount without error using callback', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.CreateBillingAccountRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.BillingAccount() - ); - client.innerApiCalls.createBillingAccount = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createBillingAccount( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes createBillingAccount with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.CreateBillingAccountRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.createBillingAccount = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createBillingAccount(request), expectedError); - }); - - it('invokes createBillingAccount with closed client', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.CreateBillingAccountRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createBillingAccount(request), expectedError); - }); - }); - - describe('getProjectBillingInfo', () => { - it('invokes getProjectBillingInfo without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.ProjectBillingInfo() - ); - client.innerApiCalls.getProjectBillingInfo = stubSimpleCall(expectedResponse); - const [response] = await client.getProjectBillingInfo(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProjectBillingInfo without error using callback', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.ProjectBillingInfo() - ); - client.innerApiCalls.getProjectBillingInfo = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProjectBillingInfo( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IProjectBillingInfo|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProjectBillingInfo with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProjectBillingInfo = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProjectBillingInfo(request), expectedError); - const actualRequest = (client.innerApiCalls.getProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProjectBillingInfo with closed client', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProjectBillingInfo(request), expectedError); - }); - }); - - describe('updateProjectBillingInfo', () => { - it('invokes updateProjectBillingInfo without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.ProjectBillingInfo() - ); - client.innerApiCalls.updateProjectBillingInfo = stubSimpleCall(expectedResponse); - const [response] = await client.updateProjectBillingInfo(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProjectBillingInfo without error using callback', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.ProjectBillingInfo() - ); - client.innerApiCalls.updateProjectBillingInfo = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProjectBillingInfo( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IProjectBillingInfo|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProjectBillingInfo with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProjectBillingInfo = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProjectBillingInfo(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProjectBillingInfo with closed client', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProjectBillingInfo(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - 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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - 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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - 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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - 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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - 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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - 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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('listBillingAccounts', () => { - it('invokes listBillingAccounts without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListBillingAccountsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - ]; - client.innerApiCalls.listBillingAccounts = stubSimpleCall(expectedResponse); - const [response] = await client.listBillingAccounts(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listBillingAccounts without error using callback', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListBillingAccountsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - ]; - client.innerApiCalls.listBillingAccounts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBillingAccounts( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listBillingAccounts with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListBillingAccountsRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.listBillingAccounts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBillingAccounts(request), expectedError); - }); - - it('invokes listBillingAccountsStream without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListBillingAccountsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - ]; - client.descriptors.page.listBillingAccounts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBillingAccountsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.BillingAccount[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.BillingAccount) => { - 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.listBillingAccounts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBillingAccounts, request)); - }); - - it('invokes listBillingAccountsStream with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListBillingAccountsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listBillingAccounts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBillingAccountsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.BillingAccount[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.BillingAccount) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBillingAccounts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBillingAccounts, request)); - }); - - it('uses async iteration with listBillingAccounts without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListBillingAccountsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - ]; - client.descriptors.page.listBillingAccounts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.billing.v1.IBillingAccount[] = []; - const iterable = client.listBillingAccountsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBillingAccounts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listBillingAccounts with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListBillingAccountsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listBillingAccounts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBillingAccountsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.billing.v1.IBillingAccount[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBillingAccounts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('listProjectBillingInfo', () => { - it('invokes listProjectBillingInfo without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - ]; - client.innerApiCalls.listProjectBillingInfo = stubSimpleCall(expectedResponse); - const [response] = await client.listProjectBillingInfo(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProjectBillingInfo without error using callback', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - ]; - client.innerApiCalls.listProjectBillingInfo = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProjectBillingInfo( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IProjectBillingInfo[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProjectBillingInfo with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProjectBillingInfo = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProjectBillingInfo(request), expectedError); - const actualRequest = (client.innerApiCalls.listProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProjectBillingInfoStream without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - ]; - client.descriptors.page.listProjectBillingInfo.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProjectBillingInfoStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.ProjectBillingInfo[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.ProjectBillingInfo) => { - 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.listProjectBillingInfo.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProjectBillingInfo, request)); - assert( - (client.descriptors.page.listProjectBillingInfo.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProjectBillingInfoStream with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProjectBillingInfo.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProjectBillingInfoStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.ProjectBillingInfo[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.ProjectBillingInfo) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProjectBillingInfo.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProjectBillingInfo, request)); - assert( - (client.descriptors.page.listProjectBillingInfo.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProjectBillingInfo without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - ]; - client.descriptors.page.listProjectBillingInfo.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.billing.v1.IProjectBillingInfo[] = []; - const iterable = client.listProjectBillingInfoAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProjectBillingInfo with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProjectBillingInfo.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProjectBillingInfoAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.billing.v1.IProjectBillingInfo[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('billingAccount', () => { - const fakePath = "/rendered/path/billingAccount"; - const expectedParameters = { - billing_account: "billingAccountValue", - }; - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.billingAccountPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.billingAccountPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('billingAccountPath', () => { - const result = client.billingAccountPath("billingAccountValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.billingAccountPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchBillingAccountFromBillingAccountName', () => { - const result = client.matchBillingAccountFromBillingAccountName(fakePath); - assert.strictEqual(result, "billingAccountValue"); - assert((client.pathTemplates.billingAccountPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('service', () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - service: "serviceValue", - }; - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('sku', () => { - const fakePath = "/rendered/path/sku"; - const expectedParameters = { - service: "serviceValue", - sku: "skuValue", - }; - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.skuPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.skuPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('skuPath', () => { - const result = client.skuPath("serviceValue", "skuValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.skuPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchServiceFromSkuName', () => { - const result = client.matchServiceFromSkuName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.skuPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSkuFromSkuName', () => { - const result = client.matchSkuFromSkuName(fakePath); - assert.strictEqual(result, "skuValue"); - assert((client.pathTemplates.skuPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts b/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts deleted file mode 100644 index 2b09f24d4d7..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts +++ /dev/null @@ -1,688 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as cloudcatalogModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .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.CloudCatalogClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = cloudcatalogModule.v1.CloudCatalogClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = cloudcatalogModule.v1.CloudCatalogClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = cloudcatalogModule.v1.CloudCatalogClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudCatalogStub, undefined); - await client.initialize(); - assert(client.cloudCatalogStub); - }); - - it('has close method for the initialized client', done => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.cloudCatalogStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudCatalogStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('listServices', () => { - it('invokes listServices without error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListServicesRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); - const [response] = await client.listServices(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listServices without error using callback', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListServicesRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServices( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IService[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listServices with error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListServicesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.listServices = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServices(request), expectedError); - }); - - it('invokes listServicesStream without error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListServicesRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - ]; - client.descriptors.page.listServices.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.Service[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.Service) => { - 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.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - }); - - it('invokes listServicesStream with error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListServicesRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listServices.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.Service[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.Service) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - }); - - it('uses async iteration with listServices without error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListServicesRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - ]; - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.billing.v1.IService[] = []; - const iterable = client.listServicesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listServices with error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListServicesRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServicesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.billing.v1.IService[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('listSkus', () => { - it('invokes listSkus without error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListSkusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - ]; - client.innerApiCalls.listSkus = stubSimpleCall(expectedResponse); - const [response] = await client.listSkus(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSkus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSkus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSkus without error using callback', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListSkusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - ]; - client.innerApiCalls.listSkus = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSkus( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.ISku[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSkus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSkus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSkus with error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListSkusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSkus = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSkus(request), expectedError); - const actualRequest = (client.innerApiCalls.listSkus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSkus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSkusStream without error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListSkusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - ]; - client.descriptors.page.listSkus.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSkusStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.Sku[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.Sku) => { - 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.listSkus.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSkus, request)); - assert( - (client.descriptors.page.listSkus.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listSkusStream with error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListSkusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSkus.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSkusStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.Sku[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.Sku) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSkus.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSkus, request)); - assert( - (client.descriptors.page.listSkus.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSkus without error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListSkusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - ]; - client.descriptors.page.listSkus.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.billing.v1.ISku[] = []; - const iterable = client.listSkusAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSkus.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSkus.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSkus with error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListSkusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSkus.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSkusAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.billing.v1.ISku[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSkus.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSkus.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('service', () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - service: "serviceValue", - }; - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('sku', () => { - const fakePath = "/rendered/path/sku"; - const expectedParameters = { - service: "serviceValue", - sku: "skuValue", - }; - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.skuPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.skuPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('skuPath', () => { - const result = client.skuPath("serviceValue", "skuValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.skuPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchServiceFromSkuName', () => { - const result = client.matchServiceFromSkuName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.skuPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSkuFromSkuName', () => { - const result = client.matchSkuFromSkuName(fakePath); - assert.strictEqual(result, "skuValue"); - assert((client.pathTemplates.skuPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-billing/v1/tsconfig.json b/owl-bot-staging/google-cloud-billing/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "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-billing/v1/webpack.config.js b/owl-bot-staging/google-cloud-billing/v1/webpack.config.js deleted file mode 100644 index d2282430c03..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// 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: 'CloudBilling', - filename: './cloud-billing.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/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_billing.proto b/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_billing.proto index f0b19d14d13..b98f0fd7c26 100644 --- a/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_billing.proto +++ b/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_billing.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; @@ -30,10 +29,14 @@ option java_multiple_files = true; option java_outer_classname = "CloudBillingProto"; option java_package = "com.google.cloud.billing.v1"; -// Retrieves GCP Console billing accounts and associates them with projects. +// Retrieves the Google Cloud Console billing accounts and associates them with +// projects. service CloudBilling { option (google.api.default_host) = "cloudbilling.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-billing," + "https://www.googleapis.com/auth/cloud-billing.readonly," + "https://www.googleapis.com/auth/cloud-platform"; // Gets information about a billing account. The current authenticated user // must be a [viewer of the billing @@ -69,15 +72,20 @@ service CloudBilling { option (google.api.method_signature) = "name,account"; } - // Creates a billing account. - // This method can only be used to create - // [billing subaccounts](https://cloud.google.com/billing/docs/concepts) - // by GCP resellers. + // This method creates [billing + // subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). + // + // Google Cloud resellers should use the + // Channel Services APIs, + // [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) + // and + // [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). + // // When creating a subaccount, the current authenticated user must have the - // `billing.accounts.update` IAM permission on the master account, which is + // `billing.accounts.update` IAM permission on the parent account, which is // typically given to billing account // [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). - // This method will return an error if the master account has not been + // This method will return an error if the parent account has not been // provisioned as a reseller account. rpc CreateBillingAccount(CreateBillingAccountRequest) returns (BillingAccount) { option (google.api.http) = { @@ -99,9 +107,10 @@ service CloudBilling { } // Gets the billing information for a project. The current authenticated user - // must have [permission to view the - // project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo - // ). + // must have the `resourcemanager.projects.get` permission for the project, + // which can be granted by assigning the [Project + // Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) + // role. rpc GetProjectBillingInfo(GetProjectBillingInfoRequest) returns (ProjectBillingInfo) { option (google.api.http) = { get: "/v1/{name=projects/*}/billingInfo" @@ -118,7 +127,7 @@ service CloudBilling { // usage charges. // // *Note:* Incurred charges that have not yet been reported in the transaction - // history of the GCP Console might be billed to the new billing + // history of the Google Cloud Console might be billed to the new billing // account, even if the charge occurred before the new billing account was // assigned to the project. // @@ -184,16 +193,20 @@ service CloudBilling { } } -// A billing account in [GCP Console](https://console.cloud.google.com/). -// You can assign a billing account to one or more projects. +// A billing account in the +// [Google Cloud Console](https://console.cloud.google.com/). You can assign a +// billing account to one or more projects. message BillingAccount { - // The resource name of the billing account. The resource name has the form + // Output only. The resource name of the billing account. The resource name has the form // `billingAccounts/{billing_account_id}`. For example, // `billingAccounts/012345-567890-ABCDEF` would be the resource name for // billing account `012345-567890-ABCDEF`. - string name = 1 [(google.api.resource_reference) = { - type: "cloudbilling.googleapis.com/BillingAccount" - }]; + string name = 1 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "cloudbilling.googleapis.com/BillingAccount" + } + ]; // Output only. True if the billing account is open, and will therefore be charged for any // usage on associated projects. False if the billing account is closed, and @@ -201,20 +214,20 @@ message BillingAccount { bool open = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; // The display name given to the billing account, such as `My Billing - // Account`. This name is displayed in the GCP Console. + // Account`. This name is displayed in the Google Cloud Console. string display_name = 3; // If this account is a // [subaccount](https://cloud.google.com/billing/docs/concepts), then this - // will be the resource name of the master billing account that it is being + // will be the resource name of the parent billing account that it is being // resold through. // Otherwise this will be empty. string master_billing_account = 4; } -// Encapsulation of billing information for a GCP Console project. A project -// has at most one associated billing account at a time (but a billing account -// can be assigned to multiple projects). +// Encapsulation of billing information for a Google Cloud Console project. A +// project has at most one associated billing account at a time (but a billing +// account can be assigned to multiple projects). message ProjectBillingInfo { // The resource name for the `ProjectBillingInfo`; has the form // `projects/{project_id}/billingInfo`. For example, the resource name for the @@ -285,7 +298,7 @@ message ListBillingAccountsResponse { message CreateBillingAccountRequest { // Required. The billing account resource to create. // Currently CreateBillingAccount only supports subaccount creation, so - // any created billing accounts must be under a provided master billing + // any created billing accounts must be under a provided parent billing // account. BillingAccount billing_account = 1 [(google.api.field_behavior) = REQUIRED]; } diff --git a/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_catalog.proto b/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_catalog.proto index 7bc2f14e3b1..f3d46e62708 100644 --- a/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_catalog.proto +++ b/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_catalog.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; @@ -36,7 +35,10 @@ option objc_class_prefix = "CLDCTLG"; // and SKUs. service CloudCatalog { option (google.api.default_host) = "cloudbilling.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-billing," + "https://www.googleapis.com/auth/cloud-billing.readonly," + "https://www.googleapis.com/auth/cloud-platform"; // Lists all public cloud services. rpc ListServices(ListServicesRequest) returns (ListServicesResponse) { @@ -111,6 +113,9 @@ message Sku { // Identifies the service provider. // This is 'Google' for first party services in Google Cloud Platform. string service_provider_name = 7; + + // The geographic taxonomy for this sku. + GeoTaxonomy geo_taxonomy = 8; } // Represents the category hierarchy of a SKU. @@ -187,6 +192,21 @@ message PricingExpression { // Example: usage_unit of "GiBy" means that usage is specified in "Gibi Byte". string usage_unit = 1; + // The recommended quantity of units for displaying pricing info. When + // displaying pricing info it is recommended to display: + // (unit_price * display_quantity) per display_quantity usage_unit. + // This field does not affect the pricing formula and is for display purposes + // only. + // Example: If the unit_price is "0.0001 USD", the usage_unit is "GB" and + // the display_quantity is "1000" then the recommended way of displaying the + // pricing info is "0.10 USD per 1000 GB" + double display_quantity = 2; + + // The list of tiered rates for this pricing. The total cost is computed by + // applying each of the tiered rates on usage. This repeated list is sorted + // by ascending order of start_usage_amount. + repeated TierRate tiered_rates = 3; + // The unit of usage in human readable form. // Example: "gibi byte". string usage_unit_description = 4; @@ -205,21 +225,6 @@ message PricingExpression { // start_usage_amount * base_unit_conversion_factor = start_usage_amount in // base_unit. double base_unit_conversion_factor = 7; - - // The recommended quantity of units for displaying pricing info. When - // displaying pricing info it is recommended to display: - // (unit_price * display_quantity) per display_quantity usage_unit. - // This field does not affect the pricing formula and is for display purposes - // only. - // Example: If the unit_price is "0.0001 USD", the usage_unit is "GB" and - // the display_quantity is "1000" then the recommended way of displaying the - // pricing info is "0.10 USD per 1000 GB" - double display_quantity = 2; - - // The list of tiered rates for this pricing. The total cost is computed by - // applying each of the tiered rates on usage. This repeated list is sorted - // by ascending order of start_usage_amount. - repeated TierRate tiered_rates = 3; } // Represents the aggregation level and interval for pricing of a single SKU. @@ -256,6 +261,33 @@ message AggregationInfo { int32 aggregation_count = 3; } +// Encapsulates the geographic taxonomy data for a sku. +message GeoTaxonomy { + // The type of Geo Taxonomy: GLOBAL, REGIONAL, or MULTI_REGIONAL. + enum Type { + // The type is not specified. + TYPE_UNSPECIFIED = 0; + + // The sku is global in nature, e.g. a license sku. Global skus are + // available in all regions, and so have an empty region list. + GLOBAL = 1; + + // The sku is available in a specific region, e.g. "us-west2". + REGIONAL = 2; + + // The sku is associated with multiple regions, e.g. "us-west2" and + // "us-east1". + MULTI_REGIONAL = 3; + } + + // The type of Geo Taxonomy: GLOBAL, REGIONAL, or MULTI_REGIONAL. + Type type = 1; + + // The list of regions associated with a sku. Empty for Global skus, which are + // associated with all Google Cloud regions. + repeated string regions = 2; +} + // Request message for `ListServices`. message ListServicesRequest { // Requested page size. Defaults to 5000. diff --git a/packages/google-cloud-billing/protos/protos.d.ts b/packages/google-cloud-billing/protos/protos.d.ts index 478f7a3002a..1f13256deec 100644 --- a/packages/google-cloud-billing/protos/protos.d.ts +++ b/packages/google-cloud-billing/protos/protos.d.ts @@ -1621,6 +1621,9 @@ export namespace google { /** Sku serviceProviderName */ serviceProviderName?: (string|null); + + /** Sku geoTaxonomy */ + geoTaxonomy?: (google.cloud.billing.v1.IGeoTaxonomy|null); } /** Represents a Sku. */ @@ -1653,6 +1656,9 @@ export namespace google { /** Sku serviceProviderName. */ public serviceProviderName: string; + /** Sku geoTaxonomy. */ + public geoTaxonomy?: (google.cloud.billing.v1.IGeoTaxonomy|null); + /** * Creates a new Sku instance using the specified properties. * @param [properties] Properties to set @@ -1973,6 +1979,12 @@ export namespace google { /** PricingExpression usageUnit */ usageUnit?: (string|null); + /** PricingExpression displayQuantity */ + displayQuantity?: (number|null); + + /** PricingExpression tieredRates */ + tieredRates?: (google.cloud.billing.v1.PricingExpression.ITierRate[]|null); + /** PricingExpression usageUnitDescription */ usageUnitDescription?: (string|null); @@ -1984,12 +1996,6 @@ export namespace google { /** PricingExpression baseUnitConversionFactor */ baseUnitConversionFactor?: (number|null); - - /** PricingExpression displayQuantity */ - displayQuantity?: (number|null); - - /** PricingExpression tieredRates */ - tieredRates?: (google.cloud.billing.v1.PricingExpression.ITierRate[]|null); } /** Represents a PricingExpression. */ @@ -2004,6 +2010,12 @@ export namespace google { /** PricingExpression usageUnit. */ public usageUnit: string; + /** PricingExpression displayQuantity. */ + public displayQuantity: number; + + /** PricingExpression tieredRates. */ + public tieredRates: google.cloud.billing.v1.PricingExpression.ITierRate[]; + /** PricingExpression usageUnitDescription. */ public usageUnitDescription: string; @@ -2016,12 +2028,6 @@ export namespace google { /** PricingExpression baseUnitConversionFactor. */ public baseUnitConversionFactor: number; - /** PricingExpression displayQuantity. */ - public displayQuantity: number; - - /** PricingExpression tieredRates. */ - public tieredRates: google.cloud.billing.v1.PricingExpression.ITierRate[]; - /** * Creates a new PricingExpression instance using the specified properties. * @param [properties] Properties to set @@ -2332,6 +2338,120 @@ export namespace google { } } + /** Properties of a GeoTaxonomy. */ + interface IGeoTaxonomy { + + /** GeoTaxonomy type */ + type?: (google.cloud.billing.v1.GeoTaxonomy.Type|keyof typeof google.cloud.billing.v1.GeoTaxonomy.Type|null); + + /** GeoTaxonomy regions */ + regions?: (string[]|null); + } + + /** Represents a GeoTaxonomy. */ + class GeoTaxonomy implements IGeoTaxonomy { + + /** + * Constructs a new GeoTaxonomy. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.billing.v1.IGeoTaxonomy); + + /** GeoTaxonomy type. */ + public type: (google.cloud.billing.v1.GeoTaxonomy.Type|keyof typeof google.cloud.billing.v1.GeoTaxonomy.Type); + + /** GeoTaxonomy regions. */ + public regions: string[]; + + /** + * Creates a new GeoTaxonomy instance using the specified properties. + * @param [properties] Properties to set + * @returns GeoTaxonomy instance + */ + public static create(properties?: google.cloud.billing.v1.IGeoTaxonomy): google.cloud.billing.v1.GeoTaxonomy; + + /** + * Encodes the specified GeoTaxonomy message. Does not implicitly {@link google.cloud.billing.v1.GeoTaxonomy.verify|verify} messages. + * @param message GeoTaxonomy message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.billing.v1.IGeoTaxonomy, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GeoTaxonomy message, length delimited. Does not implicitly {@link google.cloud.billing.v1.GeoTaxonomy.verify|verify} messages. + * @param message GeoTaxonomy message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.billing.v1.IGeoTaxonomy, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GeoTaxonomy message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GeoTaxonomy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.billing.v1.GeoTaxonomy; + + /** + * Decodes a GeoTaxonomy message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GeoTaxonomy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.billing.v1.GeoTaxonomy; + + /** + * Verifies a GeoTaxonomy message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GeoTaxonomy message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GeoTaxonomy + */ + public static fromObject(object: { [k: string]: any }): google.cloud.billing.v1.GeoTaxonomy; + + /** + * Creates a plain object from a GeoTaxonomy message. Also converts values to other types if specified. + * @param message GeoTaxonomy + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.billing.v1.GeoTaxonomy, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GeoTaxonomy to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GeoTaxonomy + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace GeoTaxonomy { + + /** Type enum. */ + enum Type { + TYPE_UNSPECIFIED = 0, + GLOBAL = 1, + REGIONAL = 2, + MULTI_REGIONAL = 3 + } + } + /** Properties of a ListServicesRequest. */ interface IListServicesRequest { diff --git a/packages/google-cloud-billing/protos/protos.js b/packages/google-cloud-billing/protos/protos.js index faa7d08fa8b..86cd9d40619 100644 --- a/packages/google-cloud-billing/protos/protos.js +++ b/packages/google-cloud-billing/protos/protos.js @@ -3466,6 +3466,7 @@ * @property {Array.|null} [serviceRegions] Sku serviceRegions * @property {Array.|null} [pricingInfo] Sku pricingInfo * @property {string|null} [serviceProviderName] Sku serviceProviderName + * @property {google.cloud.billing.v1.IGeoTaxonomy|null} [geoTaxonomy] Sku geoTaxonomy */ /** @@ -3541,6 +3542,14 @@ */ Sku.prototype.serviceProviderName = ""; + /** + * Sku geoTaxonomy. + * @member {google.cloud.billing.v1.IGeoTaxonomy|null|undefined} geoTaxonomy + * @memberof google.cloud.billing.v1.Sku + * @instance + */ + Sku.prototype.geoTaxonomy = null; + /** * Creates a new Sku instance using the specified properties. * @function create @@ -3581,6 +3590,8 @@ $root.google.cloud.billing.v1.PricingInfo.encode(message.pricingInfo[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); if (message.serviceProviderName != null && Object.hasOwnProperty.call(message, "serviceProviderName")) writer.uint32(/* id 7, wireType 2 =*/58).string(message.serviceProviderName); + if (message.geoTaxonomy != null && Object.hasOwnProperty.call(message, "geoTaxonomy")) + $root.google.cloud.billing.v1.GeoTaxonomy.encode(message.geoTaxonomy, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); return writer; }; @@ -3647,6 +3658,10 @@ message.serviceProviderName = reader.string(); break; } + case 8: { + message.geoTaxonomy = $root.google.cloud.billing.v1.GeoTaxonomy.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -3715,6 +3730,11 @@ if (message.serviceProviderName != null && message.hasOwnProperty("serviceProviderName")) if (!$util.isString(message.serviceProviderName)) return "serviceProviderName: string expected"; + if (message.geoTaxonomy != null && message.hasOwnProperty("geoTaxonomy")) { + var error = $root.google.cloud.billing.v1.GeoTaxonomy.verify(message.geoTaxonomy); + if (error) + return "geoTaxonomy." + error; + } return null; }; @@ -3760,6 +3780,11 @@ } if (object.serviceProviderName != null) message.serviceProviderName = String(object.serviceProviderName); + if (object.geoTaxonomy != null) { + if (typeof object.geoTaxonomy !== "object") + throw TypeError(".google.cloud.billing.v1.Sku.geoTaxonomy: object expected"); + message.geoTaxonomy = $root.google.cloud.billing.v1.GeoTaxonomy.fromObject(object.geoTaxonomy); + } return message; }; @@ -3786,6 +3811,7 @@ object.description = ""; object.category = null; object.serviceProviderName = ""; + object.geoTaxonomy = null; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -3807,6 +3833,8 @@ } if (message.serviceProviderName != null && message.hasOwnProperty("serviceProviderName")) object.serviceProviderName = message.serviceProviderName; + if (message.geoTaxonomy != null && message.hasOwnProperty("geoTaxonomy")) + object.geoTaxonomy = $root.google.cloud.billing.v1.GeoTaxonomy.toObject(message.geoTaxonomy, options); return object; }; @@ -4430,12 +4458,12 @@ * @memberof google.cloud.billing.v1 * @interface IPricingExpression * @property {string|null} [usageUnit] PricingExpression usageUnit + * @property {number|null} [displayQuantity] PricingExpression displayQuantity + * @property {Array.|null} [tieredRates] PricingExpression tieredRates * @property {string|null} [usageUnitDescription] PricingExpression usageUnitDescription * @property {string|null} [baseUnit] PricingExpression baseUnit * @property {string|null} [baseUnitDescription] PricingExpression baseUnitDescription * @property {number|null} [baseUnitConversionFactor] PricingExpression baseUnitConversionFactor - * @property {number|null} [displayQuantity] PricingExpression displayQuantity - * @property {Array.|null} [tieredRates] PricingExpression tieredRates */ /** @@ -4462,6 +4490,22 @@ */ PricingExpression.prototype.usageUnit = ""; + /** + * PricingExpression displayQuantity. + * @member {number} displayQuantity + * @memberof google.cloud.billing.v1.PricingExpression + * @instance + */ + PricingExpression.prototype.displayQuantity = 0; + + /** + * PricingExpression tieredRates. + * @member {Array.} tieredRates + * @memberof google.cloud.billing.v1.PricingExpression + * @instance + */ + PricingExpression.prototype.tieredRates = $util.emptyArray; + /** * PricingExpression usageUnitDescription. * @member {string} usageUnitDescription @@ -4494,22 +4538,6 @@ */ PricingExpression.prototype.baseUnitConversionFactor = 0; - /** - * PricingExpression displayQuantity. - * @member {number} displayQuantity - * @memberof google.cloud.billing.v1.PricingExpression - * @instance - */ - PricingExpression.prototype.displayQuantity = 0; - - /** - * PricingExpression tieredRates. - * @member {Array.} tieredRates - * @memberof google.cloud.billing.v1.PricingExpression - * @instance - */ - PricingExpression.prototype.tieredRates = $util.emptyArray; - /** * Creates a new PricingExpression instance using the specified properties. * @function create @@ -4587,6 +4615,16 @@ message.usageUnit = reader.string(); break; } + case 2: { + message.displayQuantity = reader.double(); + break; + } + case 3: { + if (!(message.tieredRates && message.tieredRates.length)) + message.tieredRates = []; + message.tieredRates.push($root.google.cloud.billing.v1.PricingExpression.TierRate.decode(reader, reader.uint32())); + break; + } case 4: { message.usageUnitDescription = reader.string(); break; @@ -4603,16 +4641,6 @@ message.baseUnitConversionFactor = reader.double(); break; } - case 2: { - message.displayQuantity = reader.double(); - break; - } - case 3: { - if (!(message.tieredRates && message.tieredRates.length)) - message.tieredRates = []; - message.tieredRates.push($root.google.cloud.billing.v1.PricingExpression.TierRate.decode(reader, reader.uint32())); - break; - } default: reader.skipType(tag & 7); break; @@ -4651,18 +4679,6 @@ if (message.usageUnit != null && message.hasOwnProperty("usageUnit")) if (!$util.isString(message.usageUnit)) return "usageUnit: string expected"; - if (message.usageUnitDescription != null && message.hasOwnProperty("usageUnitDescription")) - if (!$util.isString(message.usageUnitDescription)) - return "usageUnitDescription: string expected"; - if (message.baseUnit != null && message.hasOwnProperty("baseUnit")) - if (!$util.isString(message.baseUnit)) - return "baseUnit: string expected"; - if (message.baseUnitDescription != null && message.hasOwnProperty("baseUnitDescription")) - if (!$util.isString(message.baseUnitDescription)) - return "baseUnitDescription: string expected"; - if (message.baseUnitConversionFactor != null && message.hasOwnProperty("baseUnitConversionFactor")) - if (typeof message.baseUnitConversionFactor !== "number") - return "baseUnitConversionFactor: number expected"; if (message.displayQuantity != null && message.hasOwnProperty("displayQuantity")) if (typeof message.displayQuantity !== "number") return "displayQuantity: number expected"; @@ -4675,6 +4691,18 @@ return "tieredRates." + error; } } + if (message.usageUnitDescription != null && message.hasOwnProperty("usageUnitDescription")) + if (!$util.isString(message.usageUnitDescription)) + return "usageUnitDescription: string expected"; + if (message.baseUnit != null && message.hasOwnProperty("baseUnit")) + if (!$util.isString(message.baseUnit)) + return "baseUnit: string expected"; + if (message.baseUnitDescription != null && message.hasOwnProperty("baseUnitDescription")) + if (!$util.isString(message.baseUnitDescription)) + return "baseUnitDescription: string expected"; + if (message.baseUnitConversionFactor != null && message.hasOwnProperty("baseUnitConversionFactor")) + if (typeof message.baseUnitConversionFactor !== "number") + return "baseUnitConversionFactor: number expected"; return null; }; @@ -4692,14 +4720,6 @@ var message = new $root.google.cloud.billing.v1.PricingExpression(); if (object.usageUnit != null) message.usageUnit = String(object.usageUnit); - if (object.usageUnitDescription != null) - message.usageUnitDescription = String(object.usageUnitDescription); - if (object.baseUnit != null) - message.baseUnit = String(object.baseUnit); - if (object.baseUnitDescription != null) - message.baseUnitDescription = String(object.baseUnitDescription); - if (object.baseUnitConversionFactor != null) - message.baseUnitConversionFactor = Number(object.baseUnitConversionFactor); if (object.displayQuantity != null) message.displayQuantity = Number(object.displayQuantity); if (object.tieredRates) { @@ -4712,6 +4732,14 @@ message.tieredRates[i] = $root.google.cloud.billing.v1.PricingExpression.TierRate.fromObject(object.tieredRates[i]); } } + if (object.usageUnitDescription != null) + message.usageUnitDescription = String(object.usageUnitDescription); + if (object.baseUnit != null) + message.baseUnit = String(object.baseUnit); + if (object.baseUnitDescription != null) + message.baseUnitDescription = String(object.baseUnitDescription); + if (object.baseUnitConversionFactor != null) + message.baseUnitConversionFactor = Number(object.baseUnitConversionFactor); return message; }; @@ -5349,6 +5377,296 @@ return AggregationInfo; })(); + v1.GeoTaxonomy = (function() { + + /** + * Properties of a GeoTaxonomy. + * @memberof google.cloud.billing.v1 + * @interface IGeoTaxonomy + * @property {google.cloud.billing.v1.GeoTaxonomy.Type|null} [type] GeoTaxonomy type + * @property {Array.|null} [regions] GeoTaxonomy regions + */ + + /** + * Constructs a new GeoTaxonomy. + * @memberof google.cloud.billing.v1 + * @classdesc Represents a GeoTaxonomy. + * @implements IGeoTaxonomy + * @constructor + * @param {google.cloud.billing.v1.IGeoTaxonomy=} [properties] Properties to set + */ + function GeoTaxonomy(properties) { + this.regions = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GeoTaxonomy type. + * @member {google.cloud.billing.v1.GeoTaxonomy.Type} type + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @instance + */ + GeoTaxonomy.prototype.type = 0; + + /** + * GeoTaxonomy regions. + * @member {Array.} regions + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @instance + */ + GeoTaxonomy.prototype.regions = $util.emptyArray; + + /** + * Creates a new GeoTaxonomy instance using the specified properties. + * @function create + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {google.cloud.billing.v1.IGeoTaxonomy=} [properties] Properties to set + * @returns {google.cloud.billing.v1.GeoTaxonomy} GeoTaxonomy instance + */ + GeoTaxonomy.create = function create(properties) { + return new GeoTaxonomy(properties); + }; + + /** + * Encodes the specified GeoTaxonomy message. Does not implicitly {@link google.cloud.billing.v1.GeoTaxonomy.verify|verify} messages. + * @function encode + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {google.cloud.billing.v1.IGeoTaxonomy} message GeoTaxonomy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GeoTaxonomy.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.type); + if (message.regions != null && message.regions.length) + for (var i = 0; i < message.regions.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.regions[i]); + return writer; + }; + + /** + * Encodes the specified GeoTaxonomy message, length delimited. Does not implicitly {@link google.cloud.billing.v1.GeoTaxonomy.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {google.cloud.billing.v1.IGeoTaxonomy} message GeoTaxonomy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GeoTaxonomy.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GeoTaxonomy message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.billing.v1.GeoTaxonomy} GeoTaxonomy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GeoTaxonomy.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.billing.v1.GeoTaxonomy(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type = reader.int32(); + break; + } + case 2: { + if (!(message.regions && message.regions.length)) + message.regions = []; + message.regions.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GeoTaxonomy message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.billing.v1.GeoTaxonomy} GeoTaxonomy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GeoTaxonomy.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GeoTaxonomy message. + * @function verify + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GeoTaxonomy.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.regions != null && message.hasOwnProperty("regions")) { + if (!Array.isArray(message.regions)) + return "regions: array expected"; + for (var i = 0; i < message.regions.length; ++i) + if (!$util.isString(message.regions[i])) + return "regions: string[] expected"; + } + return null; + }; + + /** + * Creates a GeoTaxonomy message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.billing.v1.GeoTaxonomy} GeoTaxonomy + */ + GeoTaxonomy.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.billing.v1.GeoTaxonomy) + return object; + var message = new $root.google.cloud.billing.v1.GeoTaxonomy(); + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "TYPE_UNSPECIFIED": + case 0: + message.type = 0; + break; + case "GLOBAL": + case 1: + message.type = 1; + break; + case "REGIONAL": + case 2: + message.type = 2; + break; + case "MULTI_REGIONAL": + case 3: + message.type = 3; + break; + } + if (object.regions) { + if (!Array.isArray(object.regions)) + throw TypeError(".google.cloud.billing.v1.GeoTaxonomy.regions: array expected"); + message.regions = []; + for (var i = 0; i < object.regions.length; ++i) + message.regions[i] = String(object.regions[i]); + } + return message; + }; + + /** + * Creates a plain object from a GeoTaxonomy message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {google.cloud.billing.v1.GeoTaxonomy} message GeoTaxonomy + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GeoTaxonomy.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.regions = []; + if (options.defaults) + object.type = options.enums === String ? "TYPE_UNSPECIFIED" : 0; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.google.cloud.billing.v1.GeoTaxonomy.Type[message.type] === undefined ? message.type : $root.google.cloud.billing.v1.GeoTaxonomy.Type[message.type] : message.type; + if (message.regions && message.regions.length) { + object.regions = []; + for (var j = 0; j < message.regions.length; ++j) + object.regions[j] = message.regions[j]; + } + return object; + }; + + /** + * Converts this GeoTaxonomy to JSON. + * @function toJSON + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @instance + * @returns {Object.} JSON object + */ + GeoTaxonomy.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GeoTaxonomy + * @function getTypeUrl + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GeoTaxonomy.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.billing.v1.GeoTaxonomy"; + }; + + /** + * Type enum. + * @name google.cloud.billing.v1.GeoTaxonomy.Type + * @enum {number} + * @property {number} TYPE_UNSPECIFIED=0 TYPE_UNSPECIFIED value + * @property {number} GLOBAL=1 GLOBAL value + * @property {number} REGIONAL=2 REGIONAL value + * @property {number} MULTI_REGIONAL=3 MULTI_REGIONAL value + */ + GeoTaxonomy.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "GLOBAL"] = 1; + values[valuesById[2] = "REGIONAL"] = 2; + values[valuesById[3] = "MULTI_REGIONAL"] = 3; + return values; + })(); + + return GeoTaxonomy; + })(); + v1.ListServicesRequest = (function() { /** diff --git a/packages/google-cloud-billing/protos/protos.json b/packages/google-cloud-billing/protos/protos.json index c1e48b8313d..a89fc6d6f3f 100644 --- a/packages/google-cloud-billing/protos/protos.json +++ b/packages/google-cloud-billing/protos/protos.json @@ -19,7 +19,7 @@ "CloudBilling": { "options": { "(google.api.default_host)": "cloudbilling.googleapis.com", - "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-billing,https://www.googleapis.com/auth/cloud-billing.readonly,https://www.googleapis.com/auth/cloud-platform" }, "methods": { "GetBillingAccount": { @@ -220,6 +220,7 @@ "type": "string", "id": 1, "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY", "(google.api.resource_reference).type": "cloudbilling.googleapis.com/BillingAccount" } }, @@ -397,7 +398,7 @@ "CloudCatalog": { "options": { "(google.api.default_host)": "cloudbilling.googleapis.com", - "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-billing,https://www.googleapis.com/auth/cloud-billing.readonly,https://www.googleapis.com/auth/cloud-platform" }, "methods": { "ListServices": { @@ -497,6 +498,10 @@ "serviceProviderName": { "type": "string", "id": 7 + }, + "geoTaxonomy": { + "type": "GeoTaxonomy", + "id": 8 } } }, @@ -550,6 +555,15 @@ "type": "string", "id": 1 }, + "displayQuantity": { + "type": "double", + "id": 2 + }, + "tieredRates": { + "rule": "repeated", + "type": "TierRate", + "id": 3 + }, "usageUnitDescription": { "type": "string", "id": 4 @@ -565,15 +579,6 @@ "baseUnitConversionFactor": { "type": "double", "id": 7 - }, - "displayQuantity": { - "type": "double", - "id": 2 - }, - "tieredRates": { - "rule": "repeated", - "type": "TierRate", - "id": 3 } }, "nested": { @@ -623,6 +628,29 @@ } } }, + "GeoTaxonomy": { + "fields": { + "type": { + "type": "Type", + "id": 1 + }, + "regions": { + "rule": "repeated", + "type": "string", + "id": 2 + } + }, + "nested": { + "Type": { + "values": { + "TYPE_UNSPECIFIED": 0, + "GLOBAL": 1, + "REGIONAL": 2, + "MULTI_REGIONAL": 3 + } + } + } + }, "ListServicesRequest": { "fields": { "pageSize": { diff --git a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js index 5924f24b633..06e6462d716 100644 --- a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js +++ b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js @@ -31,7 +31,7 @@ function main(billingAccount) { /** * Required. The billing account resource to create. * Currently CreateBillingAccount only supports subaccount creation, so - * any created billing accounts must be under a provided master billing + * any created billing accounts must be under a provided parent billing * account. */ // const billingAccount = {} diff --git a/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json b/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json index 1aa2814bffc..f1c5ec85fc3 100644 --- a/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json +++ b/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json @@ -151,7 +151,7 @@ "regionTag": "cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async", "title": "CloudBilling createBillingAccount Sample", "origin": "API_DEFINITION", - "description": " Creates a billing account. This method can only be used to create [billing subaccounts](https://cloud.google.com/billing/docs/concepts) by GCP resellers. When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the master account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the master account has not been provisioned as a reseller account.", + "description": " This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned as a reseller account.", "canonical": true, "file": "cloud_billing.create_billing_account.js", "language": "JAVASCRIPT", @@ -239,7 +239,7 @@ "regionTag": "cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async", "title": "CloudBilling getProjectBillingInfo Sample", "origin": "API_DEFINITION", - "description": " Gets the billing information for a project. The current authenticated user must have [permission to view the project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ).", + "description": " Gets the billing information for a project. The current authenticated user must have the `resourcemanager.projects.get` permission for the project, which can be granted by assigning the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) role.", "canonical": true, "file": "cloud_billing.get_project_billing_info.js", "language": "JAVASCRIPT", @@ -279,7 +279,7 @@ "regionTag": "cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async", "title": "CloudBilling updateProjectBillingInfo Sample", "origin": "API_DEFINITION", - "description": " Sets or updates the billing account associated with a project. You specify the new billing account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the resource name of a billing account. Associating a project with an open billing account enables billing on the project and allows charges for resource usage. If the project already had a billing account, this method changes the billing account used for resource usage charges. *Note:* Incurred charges that have not yet been reported in the transaction history of the GCP Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project. The current authenticated user must have ownership privileges for both the [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](https://cloud.google.com/billing/docs/how-to/billing-access). You can disable billing on the project by setting the `billing_account_name` field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project. Note that associating a project with a *closed* billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an *open* billing account.", + "description": " Sets or updates the billing account associated with a project. You specify the new billing account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the resource name of a billing account. Associating a project with an open billing account enables billing on the project and allows charges for resource usage. If the project already had a billing account, this method changes the billing account used for resource usage charges. *Note:* Incurred charges that have not yet been reported in the transaction history of the Google Cloud Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project. The current authenticated user must have ownership privileges for both the [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](https://cloud.google.com/billing/docs/how-to/billing-access). You can disable billing on the project by setting the `billing_account_name` field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project. Note that associating a project with a *closed* billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an *open* billing account.", "canonical": true, "file": "cloud_billing.update_project_billing_info.js", "language": "JAVASCRIPT", diff --git a/packages/google-cloud-billing/src/v1/cloud_billing_client.ts b/packages/google-cloud-billing/src/v1/cloud_billing_client.ts index 54c42f18eb4..642bc23905d 100644 --- a/packages/google-cloud-billing/src/v1/cloud_billing_client.ts +++ b/packages/google-cloud-billing/src/v1/cloud_billing_client.ts @@ -38,7 +38,8 @@ import * as gapicConfig from './cloud_billing_client_config.json'; const version = require('../../../package.json').version; /** - * Retrieves GCP Console billing accounts and associates them with projects. + * Retrieves the Google Cloud Console billing accounts and associates them with + * projects. * @class * @memberof v1 */ @@ -323,7 +324,11 @@ export class CloudBillingClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return ['https://www.googleapis.com/auth/cloud-platform']; + return [ + 'https://www.googleapis.com/auth/cloud-billing', + 'https://www.googleapis.com/auth/cloud-billing.readonly', + 'https://www.googleapis.com/auth/cloud-platform', + ]; } getProjectId(): Promise; @@ -541,15 +546,20 @@ export class CloudBillingClient { return this.innerApiCalls.updateBillingAccount(request, options, callback); } /** - * Creates a billing account. - * This method can only be used to create - * [billing subaccounts](https://cloud.google.com/billing/docs/concepts) - * by GCP resellers. + * This method creates [billing + * subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). + * + * Google Cloud resellers should use the + * Channel Services APIs, + * [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) + * and + * [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). + * * When creating a subaccount, the current authenticated user must have the - * `billing.accounts.update` IAM permission on the master account, which is + * `billing.accounts.update` IAM permission on the parent account, which is * typically given to billing account * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). - * This method will return an error if the master account has not been + * This method will return an error if the parent account has not been * provisioned as a reseller account. * * @param {Object} request @@ -557,7 +567,7 @@ export class CloudBillingClient { * @param {google.cloud.billing.v1.BillingAccount} request.billingAccount * Required. The billing account resource to create. * Currently CreateBillingAccount only supports subaccount creation, so - * any created billing accounts must be under a provided master billing + * any created billing accounts must be under a provided parent billing * account. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. @@ -641,9 +651,10 @@ export class CloudBillingClient { } /** * Gets the billing information for a project. The current authenticated user - * must have [permission to view the - * project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo - * ). + * must have the `resourcemanager.projects.get` permission for the project, + * which can be granted by assigning the [Project + * Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) + * role. * * @param {Object} request * The request object that will be sent. @@ -744,7 +755,7 @@ export class CloudBillingClient { * usage charges. * * *Note:* Incurred charges that have not yet been reported in the transaction - * history of the GCP Console might be billed to the new billing + * history of the Google Cloud Console might be billed to the new billing * account, even if the charge occurred before the new billing account was * assigned to the project. * diff --git a/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts b/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts index d000f8e8bc6..0602dbbe1bf 100644 --- a/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts +++ b/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts @@ -311,7 +311,11 @@ export class CloudCatalogClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return ['https://www.googleapis.com/auth/cloud-platform']; + return [ + 'https://www.googleapis.com/auth/cloud-billing', + 'https://www.googleapis.com/auth/cloud-billing.readonly', + 'https://www.googleapis.com/auth/cloud-platform', + ]; } getProjectId(): Promise; From ede64f87b2e0997eea4b78f9fa458ad790124954 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 6 Dec 2022 03:51:29 +0000 Subject: [PATCH 3/4] chore: Enable requesting numeric enums in "transport=rest" responses for services supporting this (Java, Go, Python, PHP, TypeScript, C#, and Ruby), even if they do not yet turn on REST transport chore: disallow "transport=rest" for services where numeric enums are not confirmed to be supported (except in PHP and Java) PiperOrigin-RevId: 493113566 Source-Link: https://github.com/googleapis/googleapis/commit/758f0d1217d9c7fe398aa5efb1057ce4b6409e55 Source-Link: https://github.com/googleapis/googleapis-gen/commit/78bd8f05e1276363eb14eae70e91fe4bc20703ab Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpbGxpbmcvLk93bEJvdC55YW1sIiwiaCI6Ijc4YmQ4ZjA1ZTEyNzYzNjNlYjE0ZWFlNzBlOTFmZTRiYzIwNzAzYWIifQ== --- .../google-cloud-billing/v1/.eslintignore | 7 + .../google-cloud-billing/v1/.eslintrc.json | 3 + .../google-cloud-billing/v1/.gitignore | 14 + .../google-cloud-billing/v1/.jsdoc.js | 55 + .../google-cloud-billing/v1/.mocharc.js | 33 + .../google-cloud-billing/v1/.prettierrc.js | 22 + .../google-cloud-billing/v1/README.md | 1 + .../v1/linkinator.config.json | 16 + .../google-cloud-billing/v1/package.json | 65 + .../cloud/billing/v1/cloud_billing.proto | 373 ++++ .../cloud/billing/v1/cloud_catalog.proto | 363 ++++ .../cloud_billing.create_billing_account.js | 64 + .../v1/cloud_billing.get_billing_account.js | 62 + .../v1/cloud_billing.get_iam_policy.js | 67 + .../cloud_billing.get_project_billing_info.js | 62 + .../v1/cloud_billing.list_billing_accounts.js | 78 + ...cloud_billing.list_project_billing_info.js | 75 + .../v1/cloud_billing.set_iam_policy.js | 77 + .../v1/cloud_billing.test_iam_permissions.js | 70 + .../cloud_billing.update_billing_account.js | 71 + ...oud_billing.update_project_billing_info.js | 67 + .../v1/cloud_catalog.list_services.js | 68 + .../generated/v1/cloud_catalog.list_skus.js | 98 ++ ...ppet_metadata.google.cloud.billing.v1.json | 563 ++++++ .../google-cloud-billing/v1/src/index.ts | 27 + .../v1/src/v1/cloud_billing_client.ts | 1457 ++++++++++++++++ .../src/v1/cloud_billing_client_config.json | 76 + .../v1/src/v1/cloud_billing_proto_list.json | 4 + .../v1/src/v1/cloud_catalog_client.ts | 791 +++++++++ .../src/v1/cloud_catalog_client_config.json | 36 + .../v1/src/v1/cloud_catalog_proto_list.json | 4 + .../v1/src/v1/gapic_metadata.json | 173 ++ .../google-cloud-billing/v1/src/v1/index.ts | 20 + .../system-test/fixtures/sample/src/index.js | 28 + .../system-test/fixtures/sample/src/index.ts | 38 + .../v1/system-test/install.ts | 49 + .../v1/test/gapic_cloud_billing_v1.ts | 1549 +++++++++++++++++ .../v1/test/gapic_cloud_catalog_v1.ts | 688 ++++++++ .../google-cloud-billing/v1/tsconfig.json | 19 + .../google-cloud-billing/v1/webpack.config.js | 64 + 40 files changed, 7397 insertions(+) create mode 100644 owl-bot-staging/google-cloud-billing/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-billing/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-billing/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/README.md create mode 100644 owl-bot-staging/google-cloud-billing/v1/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/package.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto create mode 100644 owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_billing_v1.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts create mode 100644 owl-bot-staging/google-cloud-billing/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-billing/v1/webpack.config.js diff --git a/owl-bot-staging/google-cloud-billing/v1/.eslintignore b/owl-bot-staging/google-cloud-billing/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-billing/v1/.eslintrc.json b/owl-bot-staging/google-cloud-billing/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-billing/v1/.gitignore b/owl-bot-staging/google-cloud-billing/v1/.gitignore new file mode 100644 index 00000000000..5d32b23782f --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/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-billing/v1/.jsdoc.js b/owl-bot-staging/google-cloud-billing/v1/.jsdoc.js new file mode 100644 index 00000000000..a1fe10efe19 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/billing', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-billing/v1/.mocharc.js b/owl-bot-staging/google-cloud-billing/v1/.mocharc.js new file mode 100644 index 00000000000..481c522b00f --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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-billing/v1/.prettierrc.js b/owl-bot-staging/google-cloud-billing/v1/.prettierrc.js new file mode 100644 index 00000000000..494e147865d --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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-billing/v1/README.md b/owl-bot-staging/google-cloud-billing/v1/README.md new file mode 100644 index 00000000000..4f22cab915e --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/README.md @@ -0,0 +1 @@ +Billing: Nodejs Client diff --git a/owl-bot-staging/google-cloud-billing/v1/linkinator.config.json b/owl-bot-staging/google-cloud-billing/v1/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/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-billing/v1/package.json b/owl-bot-staging/google-cloud-billing/v1/package.json new file mode 100644 index 00000000000..761cb3cfd5d --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/package.json @@ -0,0 +1,65 @@ +{ + "name": "@google-cloud/billing", + "version": "0.1.0", + "description": "Billing client for Node.js", + "repository": "googleapis/nodejs-billing", + "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 billing", + "billing", + "cloud billing", + "cloud catalog" + ], + "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.2" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.62", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.0.3", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.3", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto b/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto new file mode 100644 index 00000000000..b98f0fd7c26 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto @@ -0,0 +1,373 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.billing.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/protobuf/field_mask.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/billing/v1;billing"; +option java_multiple_files = true; +option java_outer_classname = "CloudBillingProto"; +option java_package = "com.google.cloud.billing.v1"; + +// Retrieves the Google Cloud Console billing accounts and associates them with +// projects. +service CloudBilling { + option (google.api.default_host) = "cloudbilling.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-billing," + "https://www.googleapis.com/auth/cloud-billing.readonly," + "https://www.googleapis.com/auth/cloud-platform"; + + // Gets information about a billing account. The current authenticated user + // must be a [viewer of the billing + // account](https://cloud.google.com/billing/docs/how-to/billing-access). + rpc GetBillingAccount(GetBillingAccountRequest) returns (BillingAccount) { + option (google.api.http) = { + get: "/v1/{name=billingAccounts/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists the billing accounts that the current authenticated user has + // permission to + // [view](https://cloud.google.com/billing/docs/how-to/billing-access). + rpc ListBillingAccounts(ListBillingAccountsRequest) returns (ListBillingAccountsResponse) { + option (google.api.http) = { + get: "/v1/billingAccounts" + }; + option (google.api.method_signature) = ""; + } + + // Updates a billing account's fields. + // Currently the only field that can be edited is `display_name`. + // The current authenticated user must have the `billing.accounts.update` + // IAM permission, which is typically given to the + // [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) + // of the billing account. + rpc UpdateBillingAccount(UpdateBillingAccountRequest) returns (BillingAccount) { + option (google.api.http) = { + patch: "/v1/{name=billingAccounts/*}" + body: "account" + }; + option (google.api.method_signature) = "name,account"; + } + + // This method creates [billing + // subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). + // + // Google Cloud resellers should use the + // Channel Services APIs, + // [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) + // and + // [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). + // + // When creating a subaccount, the current authenticated user must have the + // `billing.accounts.update` IAM permission on the parent account, which is + // typically given to billing account + // [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). + // This method will return an error if the parent account has not been + // provisioned as a reseller account. + rpc CreateBillingAccount(CreateBillingAccountRequest) returns (BillingAccount) { + option (google.api.http) = { + post: "/v1/billingAccounts" + body: "billing_account" + }; + option (google.api.method_signature) = "billing_account"; + } + + // Lists the projects associated with a billing account. The current + // authenticated user must have the `billing.resourceAssociations.list` IAM + // permission, which is often given to billing account + // [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). + rpc ListProjectBillingInfo(ListProjectBillingInfoRequest) returns (ListProjectBillingInfoResponse) { + option (google.api.http) = { + get: "/v1/{name=billingAccounts/*}/projects" + }; + option (google.api.method_signature) = "name"; + } + + // Gets the billing information for a project. The current authenticated user + // must have the `resourcemanager.projects.get` permission for the project, + // which can be granted by assigning the [Project + // Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) + // role. + rpc GetProjectBillingInfo(GetProjectBillingInfoRequest) returns (ProjectBillingInfo) { + option (google.api.http) = { + get: "/v1/{name=projects/*}/billingInfo" + }; + option (google.api.method_signature) = "name"; + } + + // Sets or updates the billing account associated with a project. You specify + // the new billing account by setting the `billing_account_name` in the + // `ProjectBillingInfo` resource to the resource name of a billing account. + // Associating a project with an open billing account enables billing on the + // project and allows charges for resource usage. If the project already had a + // billing account, this method changes the billing account used for resource + // usage charges. + // + // *Note:* Incurred charges that have not yet been reported in the transaction + // history of the Google Cloud Console might be billed to the new billing + // account, even if the charge occurred before the new billing account was + // assigned to the project. + // + // The current authenticated user must have ownership privileges for both the + // [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo + // ) and the [billing + // account](https://cloud.google.com/billing/docs/how-to/billing-access). + // + // You can disable billing on the project by setting the + // `billing_account_name` field to empty. This action disassociates the + // current billing account from the project. Any billable activity of your + // in-use services will stop, and your application could stop functioning as + // expected. Any unbilled charges to date will be billed to the previously + // associated account. The current authenticated user must be either an owner + // of the project or an owner of the billing account for the project. + // + // Note that associating a project with a *closed* billing account will have + // much the same effect as disabling billing on the project: any paid + // resources used by the project will be shut down. Thus, unless you wish to + // disable billing, you should always call this method with the name of an + // *open* billing account. + rpc UpdateProjectBillingInfo(UpdateProjectBillingInfoRequest) returns (ProjectBillingInfo) { + option (google.api.http) = { + put: "/v1/{name=projects/*}/billingInfo" + body: "project_billing_info" + }; + option (google.api.method_signature) = "name,project_billing_info"; + } + + // Gets the access control policy for a billing account. + // The caller must have the `billing.accounts.getIamPolicy` permission on the + // account, which is often given to billing account + // [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + get: "/v1/{resource=billingAccounts/*}:getIamPolicy" + }; + option (google.api.method_signature) = "resource"; + } + + // Sets the access control policy for a billing account. Replaces any existing + // policy. + // The caller must have the `billing.accounts.setIamPolicy` permission on the + // account, which is often given to billing account + // [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v1/{resource=billingAccounts/*}:setIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource,policy"; + } + + // Tests the access control policy for a billing account. This method takes + // the resource and a set of permissions as input and returns the subset of + // the input permissions that the caller is allowed for that resource. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v1/{resource=billingAccounts/*}:testIamPermissions" + body: "*" + }; + option (google.api.method_signature) = "resource,permissions"; + } +} + +// A billing account in the +// [Google Cloud Console](https://console.cloud.google.com/). You can assign a +// billing account to one or more projects. +message BillingAccount { + // Output only. The resource name of the billing account. The resource name has the form + // `billingAccounts/{billing_account_id}`. For example, + // `billingAccounts/012345-567890-ABCDEF` would be the resource name for + // billing account `012345-567890-ABCDEF`. + string name = 1 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "cloudbilling.googleapis.com/BillingAccount" + } + ]; + + // Output only. True if the billing account is open, and will therefore be charged for any + // usage on associated projects. False if the billing account is closed, and + // therefore projects associated with it will be unable to use paid services. + bool open = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The display name given to the billing account, such as `My Billing + // Account`. This name is displayed in the Google Cloud Console. + string display_name = 3; + + // If this account is a + // [subaccount](https://cloud.google.com/billing/docs/concepts), then this + // will be the resource name of the parent billing account that it is being + // resold through. + // Otherwise this will be empty. + string master_billing_account = 4; +} + +// Encapsulation of billing information for a Google Cloud Console project. A +// project has at most one associated billing account at a time (but a billing +// account can be assigned to multiple projects). +message ProjectBillingInfo { + // The resource name for the `ProjectBillingInfo`; has the form + // `projects/{project_id}/billingInfo`. For example, the resource name for the + // billing information for project `tokyo-rain-123` would be + // `projects/tokyo-rain-123/billingInfo`. This field is read-only. + string name = 1; + + // The ID of the project that this `ProjectBillingInfo` represents, such as + // `tokyo-rain-123`. This is a convenience field so that you don't need to + // parse the `name` field to obtain a project ID. This field is read-only. + string project_id = 2; + + // The resource name of the billing account associated with the project, if + // any. For example, `billingAccounts/012345-567890-ABCDEF`. + string billing_account_name = 3; + + // True if the project is associated with an open billing account, to which + // usage on the project is charged. False if the project is associated with a + // closed billing account, or no billing account at all, and therefore cannot + // use paid services. This field is read-only. + bool billing_enabled = 4; +} + +// Request message for `GetBillingAccount`. +message GetBillingAccountRequest { + // Required. The resource name of the billing account to retrieve. For example, + // `billingAccounts/012345-567890-ABCDEF`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudbilling.googleapis.com/BillingAccount" + } + ]; +} + +// Request message for `ListBillingAccounts`. +message ListBillingAccountsRequest { + // Requested page size. The maximum page size is 100; this is also the + // default. + int32 page_size = 1; + + // A token identifying a page of results to return. This should be a + // `next_page_token` value returned from a previous `ListBillingAccounts` + // call. If unspecified, the first page of results is returned. + string page_token = 2; + + // Options for how to filter the returned billing accounts. + // Currently this only supports filtering for + // [subaccounts](https://cloud.google.com/billing/docs/concepts) under a + // single provided reseller billing account. + // (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). + // Boolean algebra and other fields are not currently supported. + string filter = 3; +} + +// Response message for `ListBillingAccounts`. +message ListBillingAccountsResponse { + // A list of billing accounts. + repeated BillingAccount billing_accounts = 1; + + // A token to retrieve the next page of results. To retrieve the next page, + // call `ListBillingAccounts` again with the `page_token` field set to this + // value. This field is empty if there are no more results to retrieve. + string next_page_token = 2; +} + +// Request message for `CreateBillingAccount`. +message CreateBillingAccountRequest { + // Required. The billing account resource to create. + // Currently CreateBillingAccount only supports subaccount creation, so + // any created billing accounts must be under a provided parent billing + // account. + BillingAccount billing_account = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for `UpdateBillingAccount`. +message UpdateBillingAccountRequest { + // Required. The name of the billing account resource to be updated. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudbilling.googleapis.com/BillingAccount" + } + ]; + + // Required. The billing account resource to replace the resource on the server. + BillingAccount account = 2 [(google.api.field_behavior) = REQUIRED]; + + // The update mask applied to the resource. + // Only "display_name" is currently supported. + google.protobuf.FieldMask update_mask = 3; +} + +// Request message for `ListProjectBillingInfo`. +message ListProjectBillingInfoRequest { + // Required. The resource name of the billing account associated with the projects that + // you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudbilling.googleapis.com/BillingAccount" + } + ]; + + // Requested page size. The maximum page size is 100; this is also the + // default. + int32 page_size = 2; + + // A token identifying a page of results to be returned. This should be a + // `next_page_token` value returned from a previous `ListProjectBillingInfo` + // call. If unspecified, the first page of results is returned. + string page_token = 3; +} + +// Request message for `ListProjectBillingInfoResponse`. +message ListProjectBillingInfoResponse { + // A list of `ProjectBillingInfo` resources representing the projects + // associated with the billing account. + repeated ProjectBillingInfo project_billing_info = 1; + + // A token to retrieve the next page of results. To retrieve the next page, + // call `ListProjectBillingInfo` again with the `page_token` field set to this + // value. This field is empty if there are no more results to retrieve. + string next_page_token = 2; +} + +// Request message for `GetProjectBillingInfo`. +message GetProjectBillingInfoRequest { + // Required. The resource name of the project for which billing information is + // retrieved. For example, `projects/tokyo-rain-123`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for `UpdateProjectBillingInfo`. +message UpdateProjectBillingInfoRequest { + // Required. The resource name of the project associated with the billing information + // that you want to update. For example, `projects/tokyo-rain-123`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The new billing information for the project. Read-only fields are ignored; + // thus, you can leave empty all fields except `billing_account_name`. + ProjectBillingInfo project_billing_info = 2; +} diff --git a/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto b/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto new file mode 100644 index 00000000000..f3d46e62708 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto @@ -0,0 +1,363 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.billing.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/money.proto"; + +option csharp_namespace = "Google.Cloud.Billing.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/billing/v1;billing"; +option java_multiple_files = true; +option java_outer_classname = "CloudCatalogProto"; +option java_package = "com.google.cloud.billing.v1"; +option objc_class_prefix = "CLDCTLG"; + +// A catalog of Google Cloud Platform services and SKUs. +// Provides pricing information and metadata on Google Cloud Platform services +// and SKUs. +service CloudCatalog { + option (google.api.default_host) = "cloudbilling.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-billing," + "https://www.googleapis.com/auth/cloud-billing.readonly," + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all public cloud services. + rpc ListServices(ListServicesRequest) returns (ListServicesResponse) { + option (google.api.http) = { + get: "/v1/services" + }; + option (google.api.method_signature) = ""; + } + + // Lists all publicly available SKUs for a given cloud service. + rpc ListSkus(ListSkusRequest) returns (ListSkusResponse) { + option (google.api.http) = { + get: "/v1/{parent=services/*}/skus" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Encapsulates a single service in Google Cloud Platform. +message Service { + option (google.api.resource) = { + type: "cloudbilling.googleapis.com/Service" + pattern: "services/{service}" + }; + + // The resource name for the service. + // Example: "services/DA34-426B-A397" + string name = 1; + + // The identifier for the service. + // Example: "DA34-426B-A397" + string service_id = 2; + + // A human readable display name for this service. + string display_name = 3; + + // The business under which the service is offered. + // Ex. "businessEntities/GCP", "businessEntities/Maps" + string business_entity_name = 4; +} + +// Encapsulates a single SKU in Google Cloud Platform +message Sku { + option (google.api.resource) = { + type: "cloudbilling.googleapis.com/Sku" + pattern: "services/{service}/skus/{sku}" + }; + + // The resource name for the SKU. + // Example: "services/DA34-426B-A397/skus/AA95-CD31-42FE" + string name = 1; + + // The identifier for the SKU. + // Example: "AA95-CD31-42FE" + string sku_id = 2; + + // A human readable description of the SKU, has a maximum length of 256 + // characters. + string description = 3; + + // The category hierarchy of this SKU, purely for organizational purpose. + Category category = 4; + + // List of service regions this SKU is offered at. + // Example: "asia-east1" + // Service regions can be found at https://cloud.google.com/about/locations/ + repeated string service_regions = 5; + + // A timeline of pricing info for this SKU in chronological order. + repeated PricingInfo pricing_info = 6; + + // Identifies the service provider. + // This is 'Google' for first party services in Google Cloud Platform. + string service_provider_name = 7; + + // The geographic taxonomy for this sku. + GeoTaxonomy geo_taxonomy = 8; +} + +// Represents the category hierarchy of a SKU. +message Category { + // The display name of the service this SKU belongs to. + string service_display_name = 1; + + // The type of product the SKU refers to. + // Example: "Compute", "Storage", "Network", "ApplicationServices" etc. + string resource_family = 2; + + // A group classification for related SKUs. + // Example: "RAM", "GPU", "Prediction", "Ops", "GoogleEgress" etc. + string resource_group = 3; + + // Represents how the SKU is consumed. + // Example: "OnDemand", "Preemptible", "Commit1Mo", "Commit1Yr" etc. + string usage_type = 4; +} + +// Represents the pricing information for a SKU at a single point of time. +message PricingInfo { + // The timestamp from which this pricing was effective within the requested + // time range. This is guaranteed to be greater than or equal to the + // start_time field in the request and less than the end_time field in the + // request. If a time range was not specified in the request this field will + // be equivalent to a time within the last 12 hours, indicating the latest + // pricing info. + google.protobuf.Timestamp effective_time = 1; + + // An optional human readable summary of the pricing information, has a + // maximum length of 256 characters. + string summary = 2; + + // Expresses the pricing formula. See `PricingExpression` for an example. + PricingExpression pricing_expression = 3; + + // Aggregation Info. This can be left unspecified if the pricing expression + // doesn't require aggregation. + AggregationInfo aggregation_info = 4; + + // Conversion rate used for currency conversion, from USD to the currency + // specified in the request. This includes any surcharge collected for billing + // in non USD currency. If a currency is not specified in the request this + // defaults to 1.0. + // Example: USD * currency_conversion_rate = JPY + double currency_conversion_rate = 5; +} + +// Expresses a mathematical pricing formula. For Example:- +// +// `usage_unit: GBy` +// `tiered_rates:` +// `[start_usage_amount: 20, unit_price: $10]` +// `[start_usage_amount: 100, unit_price: $5]` +// +// The above expresses a pricing formula where the first 20GB is free, the +// next 80GB is priced at $10 per GB followed by $5 per GB for additional +// usage. +message PricingExpression { + // The price rate indicating starting usage and its corresponding price. + message TierRate { + // Usage is priced at this rate only after this amount. + // Example: start_usage_amount of 10 indicates that the usage will be priced + // at the unit_price after the first 10 usage_units. + double start_usage_amount = 1; + + // The price per unit of usage. + // Example: unit_price of amount $10 indicates that each unit will cost $10. + google.type.Money unit_price = 2; + } + + // The short hand for unit of usage this pricing is specified in. + // Example: usage_unit of "GiBy" means that usage is specified in "Gibi Byte". + string usage_unit = 1; + + // The recommended quantity of units for displaying pricing info. When + // displaying pricing info it is recommended to display: + // (unit_price * display_quantity) per display_quantity usage_unit. + // This field does not affect the pricing formula and is for display purposes + // only. + // Example: If the unit_price is "0.0001 USD", the usage_unit is "GB" and + // the display_quantity is "1000" then the recommended way of displaying the + // pricing info is "0.10 USD per 1000 GB" + double display_quantity = 2; + + // The list of tiered rates for this pricing. The total cost is computed by + // applying each of the tiered rates on usage. This repeated list is sorted + // by ascending order of start_usage_amount. + repeated TierRate tiered_rates = 3; + + // The unit of usage in human readable form. + // Example: "gibi byte". + string usage_unit_description = 4; + + // The base unit for the SKU which is the unit used in usage exports. + // Example: "By" + string base_unit = 5; + + // The base unit in human readable form. + // Example: "byte". + string base_unit_description = 6; + + // Conversion factor for converting from price per usage_unit to price per + // base_unit, and start_usage_amount to start_usage_amount in base_unit. + // unit_price / base_unit_conversion_factor = price per base_unit. + // start_usage_amount * base_unit_conversion_factor = start_usage_amount in + // base_unit. + double base_unit_conversion_factor = 7; +} + +// Represents the aggregation level and interval for pricing of a single SKU. +message AggregationInfo { + // The level at which usage is aggregated to compute cost. + // Example: "ACCOUNT" aggregation level indicates that usage for tiered + // pricing is aggregated across all projects in a single account. + enum AggregationLevel { + AGGREGATION_LEVEL_UNSPECIFIED = 0; + + ACCOUNT = 1; + + PROJECT = 2; + } + + // The interval at which usage is aggregated to compute cost. + // Example: "MONTHLY" aggregation interval indicates that usage for tiered + // pricing is aggregated every month. + enum AggregationInterval { + AGGREGATION_INTERVAL_UNSPECIFIED = 0; + + DAILY = 1; + + MONTHLY = 2; + } + + AggregationLevel aggregation_level = 1; + + AggregationInterval aggregation_interval = 2; + + // The number of intervals to aggregate over. + // Example: If aggregation_level is "DAILY" and aggregation_count is 14, + // aggregation will be over 14 days. + int32 aggregation_count = 3; +} + +// Encapsulates the geographic taxonomy data for a sku. +message GeoTaxonomy { + // The type of Geo Taxonomy: GLOBAL, REGIONAL, or MULTI_REGIONAL. + enum Type { + // The type is not specified. + TYPE_UNSPECIFIED = 0; + + // The sku is global in nature, e.g. a license sku. Global skus are + // available in all regions, and so have an empty region list. + GLOBAL = 1; + + // The sku is available in a specific region, e.g. "us-west2". + REGIONAL = 2; + + // The sku is associated with multiple regions, e.g. "us-west2" and + // "us-east1". + MULTI_REGIONAL = 3; + } + + // The type of Geo Taxonomy: GLOBAL, REGIONAL, or MULTI_REGIONAL. + Type type = 1; + + // The list of regions associated with a sku. Empty for Global skus, which are + // associated with all Google Cloud regions. + repeated string regions = 2; +} + +// Request message for `ListServices`. +message ListServicesRequest { + // Requested page size. Defaults to 5000. + int32 page_size = 1; + + // A token identifying a page of results to return. This should be a + // `next_page_token` value returned from a previous `ListServices` + // call. If unspecified, the first page of results is returned. + string page_token = 2; +} + +// Response message for `ListServices`. +message ListServicesResponse { + // A list of services. + repeated Service services = 1; + + // A token to retrieve the next page of results. To retrieve the next page, + // call `ListServices` again with the `page_token` field set to this + // value. This field is empty if there are no more results to retrieve. + string next_page_token = 2; +} + +// Request message for `ListSkus`. +message ListSkusRequest { + // Required. The name of the service. + // Example: "services/DA34-426B-A397" + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudbilling.googleapis.com/Service" + } + ]; + + // Optional inclusive start time of the time range for which the pricing + // versions will be returned. Timestamps in the future are not allowed. + // The time range has to be within a single calendar month in + // America/Los_Angeles timezone. Time range as a whole is optional. If not + // specified, the latest pricing will be returned (up to 12 hours old at + // most). + google.protobuf.Timestamp start_time = 2; + + // Optional exclusive end time of the time range for which the pricing + // versions will be returned. Timestamps in the future are not allowed. + // The time range has to be within a single calendar month in + // America/Los_Angeles timezone. Time range as a whole is optional. If not + // specified, the latest pricing will be returned (up to 12 hours old at + // most). + google.protobuf.Timestamp end_time = 3; + + // The ISO 4217 currency code for the pricing info in the response proto. + // Will use the conversion rate as of start_time. + // Optional. If not specified USD will be used. + string currency_code = 4; + + // Requested page size. Defaults to 5000. + int32 page_size = 5; + + // A token identifying a page of results to return. This should be a + // `next_page_token` value returned from a previous `ListSkus` + // call. If unspecified, the first page of results is returned. + string page_token = 6; +} + +// Response message for `ListSkus`. +message ListSkusResponse { + // The list of public SKUs of the given service. + repeated Sku skus = 1; + + // A token to retrieve the next page of results. To retrieve the next page, + // call `ListSkus` again with the `page_token` field set to this + // value. This field is empty if there are no more results to retrieve. + string next_page_token = 2; +} diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js new file mode 100644 index 00000000000..06e6462d716 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js @@ -0,0 +1,64 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(billingAccount) { + // [START cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The billing account resource to create. + * Currently CreateBillingAccount only supports subaccount creation, so + * any created billing accounts must be under a provided parent billing + * account. + */ + // const billingAccount = {} + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callCreateBillingAccount() { + // Construct request + const request = { + billingAccount, + }; + + // Run request + const response = await billingClient.createBillingAccount(request); + console.log(response); + } + + callCreateBillingAccount(); + // [END cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js new file mode 100644 index 00000000000..8d420a0e1a5 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the billing account to retrieve. For example, + * `billingAccounts/012345-567890-ABCDEF`. + */ + // const name = 'abc123' + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callGetBillingAccount() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await billingClient.getBillingAccount(request); + console.log(response); + } + + callGetBillingAccount(); + // [END cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js new file mode 100644 index 00000000000..df9f6c0a259 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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 cloudbilling_v1_generated_CloudBilling_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. + */ + /** + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await billingClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END cloudbilling_v1_generated_CloudBilling_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-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js new file mode 100644 index 00000000000..1b9bd0c1604 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the project for which billing information is + * retrieved. For example, `projects/tokyo-rain-123`. + */ + // const name = 'abc123' + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callGetProjectBillingInfo() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await billingClient.getProjectBillingInfo(request); + console.log(response); + } + + callGetProjectBillingInfo(); + // [END cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js new file mode 100644 index 00000000000..916633c0352 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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 cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 page size. The maximum page size is 100; this is also the + * default. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListBillingAccounts` + * call. If unspecified, the first page of results is returned. + */ + // const pageToken = 'abc123' + /** + * Options for how to filter the returned billing accounts. + * Currently this only supports filtering for + * subaccounts (https://cloud.google.com/billing/docs/concepts) under a + * single provided reseller billing account. + * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). + * Boolean algebra and other fields are not currently supported. + */ + // const filter = 'abc123' + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callListBillingAccounts() { + // Construct request + const request = { + }; + + // Run request + const iterable = await billingClient.listBillingAccountsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListBillingAccounts(); + // [END cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js new file mode 100644 index 00000000000..3ab054e3f1d --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the billing account associated with the projects that + * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. + */ + // const name = 'abc123' + /** + * Requested page size. The maximum page size is 100; this is also the + * default. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous `ListProjectBillingInfo` + * call. If unspecified, the first page of results is returned. + */ + // const pageToken = 'abc123' + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callListProjectBillingInfo() { + // Construct request + const request = { + name, + }; + + // Run request + const iterable = await billingClient.listProjectBillingInfoAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProjectBillingInfo(); + // [END cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js new file mode 100644 index 00000000000..41fa9a179ef --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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, policy) { + // [START cloudbilling_v1_generated_CloudBilling_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. + */ + /** + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * 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 a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await billingClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END cloudbilling_v1_generated_CloudBilling_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-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js new file mode 100644 index 00000000000..b1ffbd536e5 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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, permissions) { + // [START cloudbilling_v1_generated_CloudBilling_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. + */ + /** + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = 'abc123' + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await billingClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END cloudbilling_v1_generated_CloudBilling_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-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js new file mode 100644 index 00000000000..c487c7c3d5c --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js @@ -0,0 +1,71 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, account) { + // [START cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the billing account resource to be updated. + */ + // const name = 'abc123' + /** + * Required. The billing account resource to replace the resource on the server. + */ + // const account = {} + /** + * The update mask applied to the resource. + * Only "display_name" is currently supported. + */ + // const updateMask = {} + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callUpdateBillingAccount() { + // Construct request + const request = { + name, + account, + }; + + // Run request + const response = await billingClient.updateBillingAccount(request); + console.log(response); + } + + callUpdateBillingAccount(); + // [END cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js new file mode 100644 index 00000000000..0168c7c8daa --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the project associated with the billing information + * that you want to update. For example, `projects/tokyo-rain-123`. + */ + // const name = 'abc123' + /** + * The new billing information for the project. Read-only fields are ignored; + * thus, you can leave empty all fields except `billing_account_name`. + */ + // const projectBillingInfo = {} + + // Imports the Billing library + const {CloudBillingClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudBillingClient(); + + async function callUpdateProjectBillingInfo() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await billingClient.updateProjectBillingInfo(request); + console.log(response); + } + + callUpdateProjectBillingInfo(); + // [END cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js new file mode 100644 index 00000000000..c21a6be3aeb --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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 cloudbilling_v1_generated_CloudCatalog_ListServices_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It 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 page size. Defaults to 5000. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListServices` + * call. If unspecified, the first page of results is returned. + */ + // const pageToken = 'abc123' + + // Imports the Billing library + const {CloudCatalogClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudCatalogClient(); + + async function callListServices() { + // Construct request + const request = { + }; + + // Run request + const iterable = await billingClient.listServicesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListServices(); + // [END cloudbilling_v1_generated_CloudCatalog_ListServices_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js new file mode 100644 index 00000000000..71decc1085d --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js @@ -0,0 +1,98 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START cloudbilling_v1_generated_CloudCatalog_ListSkus_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the service. + * Example: "services/DA34-426B-A397" + */ + // const parent = 'abc123' + /** + * Optional inclusive start time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + */ + // const startTime = {} + /** + * Optional exclusive end time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + */ + // const endTime = {} + /** + * The ISO 4217 currency code for the pricing info in the response proto. + * Will use the conversion rate as of start_time. + * Optional. If not specified USD will be used. + */ + // const currencyCode = 'abc123' + /** + * Requested page size. Defaults to 5000. + */ + // const pageSize = 1234 + /** + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListSkus` + * call. If unspecified, the first page of results is returned. + */ + // const pageToken = 'abc123' + + // Imports the Billing library + const {CloudCatalogClient} = require('@google-cloud/billing').v1; + + // Instantiates a client + const billingClient = new CloudCatalogClient(); + + async function callListSkus() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await billingClient.listSkusAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListSkus(); + // [END cloudbilling_v1_generated_CloudCatalog_ListSkus_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json new file mode 100644 index 00000000000..e446c6b0814 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json @@ -0,0 +1,563 @@ +{ + "clientLibrary": { + "name": "nodejs-billing", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.billing.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async", + "title": "CloudBilling getBillingAccount Sample", + "origin": "API_DEFINITION", + "description": " Gets information about a billing account. The current authenticated user must be a [viewer of the billing account](https://cloud.google.com/billing/docs/how-to/billing-access).", + "canonical": true, + "file": "cloud_billing.get_billing_account.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetBillingAccount", + "fullName": "google.cloud.billing.v1.CloudBilling.GetBillingAccount", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.billing.v1.BillingAccount", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "GetBillingAccount", + "fullName": "google.cloud.billing.v1.CloudBilling.GetBillingAccount", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async", + "title": "CloudBilling listBillingAccounts Sample", + "origin": "API_DEFINITION", + "description": " Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).", + "canonical": true, + "file": "cloud_billing.list_billing_accounts.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListBillingAccounts", + "fullName": "google.cloud.billing.v1.CloudBilling.ListBillingAccounts", + "async": true, + "parameters": [ + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.billing.v1.ListBillingAccountsResponse", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "ListBillingAccounts", + "fullName": "google.cloud.billing.v1.CloudBilling.ListBillingAccounts", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async", + "title": "CloudBilling updateBillingAccount Sample", + "origin": "API_DEFINITION", + "description": " Updates a billing account's fields. Currently the only field that can be edited is `display_name`. The current authenticated user must have the `billing.accounts.update` IAM permission, which is typically given to the [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing account.", + "canonical": true, + "file": "cloud_billing.update_billing_account.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateBillingAccount", + "fullName": "google.cloud.billing.v1.CloudBilling.UpdateBillingAccount", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "account", + "type": ".google.cloud.billing.v1.BillingAccount" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.billing.v1.BillingAccount", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "UpdateBillingAccount", + "fullName": "google.cloud.billing.v1.CloudBilling.UpdateBillingAccount", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async", + "title": "CloudBilling createBillingAccount Sample", + "origin": "API_DEFINITION", + "description": " This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned as a reseller account.", + "canonical": true, + "file": "cloud_billing.create_billing_account.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateBillingAccount", + "fullName": "google.cloud.billing.v1.CloudBilling.CreateBillingAccount", + "async": true, + "parameters": [ + { + "name": "billing_account", + "type": ".google.cloud.billing.v1.BillingAccount" + } + ], + "resultType": ".google.cloud.billing.v1.BillingAccount", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "CreateBillingAccount", + "fullName": "google.cloud.billing.v1.CloudBilling.CreateBillingAccount", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async", + "title": "CloudBilling listProjectBillingInfo Sample", + "origin": "API_DEFINITION", + "description": " Lists the projects associated with a billing account. The current authenticated user must have the `billing.resourceAssociations.list` IAM permission, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).", + "canonical": true, + "file": "cloud_billing.list_project_billing_info.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProjectBillingInfo", + "fullName": "google.cloud.billing.v1.CloudBilling.ListProjectBillingInfo", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.billing.v1.ListProjectBillingInfoResponse", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "ListProjectBillingInfo", + "fullName": "google.cloud.billing.v1.CloudBilling.ListProjectBillingInfo", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async", + "title": "CloudBilling getProjectBillingInfo Sample", + "origin": "API_DEFINITION", + "description": " Gets the billing information for a project. The current authenticated user must have the `resourcemanager.projects.get` permission for the project, which can be granted by assigning the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) role.", + "canonical": true, + "file": "cloud_billing.get_project_billing_info.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProjectBillingInfo", + "fullName": "google.cloud.billing.v1.CloudBilling.GetProjectBillingInfo", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.billing.v1.ProjectBillingInfo", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "GetProjectBillingInfo", + "fullName": "google.cloud.billing.v1.CloudBilling.GetProjectBillingInfo", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async", + "title": "CloudBilling updateProjectBillingInfo Sample", + "origin": "API_DEFINITION", + "description": " Sets or updates the billing account associated with a project. You specify the new billing account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the resource name of a billing account. Associating a project with an open billing account enables billing on the project and allows charges for resource usage. If the project already had a billing account, this method changes the billing account used for resource usage charges. *Note:* Incurred charges that have not yet been reported in the transaction history of the Google Cloud Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project. The current authenticated user must have ownership privileges for both the [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](https://cloud.google.com/billing/docs/how-to/billing-access). You can disable billing on the project by setting the `billing_account_name` field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project. Note that associating a project with a *closed* billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an *open* billing account.", + "canonical": true, + "file": "cloud_billing.update_project_billing_info.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProjectBillingInfo", + "fullName": "google.cloud.billing.v1.CloudBilling.UpdateProjectBillingInfo", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "project_billing_info", + "type": ".google.cloud.billing.v1.ProjectBillingInfo" + } + ], + "resultType": ".google.cloud.billing.v1.ProjectBillingInfo", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "UpdateProjectBillingInfo", + "fullName": "google.cloud.billing.v1.CloudBilling.UpdateProjectBillingInfo", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_GetIamPolicy_async", + "title": "CloudBilling getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a billing account. The caller must have the `billing.accounts.getIamPolicy` permission on the account, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).", + "canonical": true, + "file": "cloud_billing.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.billing.v1.CloudBilling.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.billing.v1.CloudBilling.GetIamPolicy", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_SetIamPolicy_async", + "title": "CloudBilling setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy for a billing account. Replaces any existing policy. The caller must have the `billing.accounts.setIamPolicy` permission on the account, which is often given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).", + "canonical": true, + "file": "cloud_billing.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.billing.v1.CloudBilling.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.billing.v1.CloudBilling.SetIamPolicy", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudBilling_TestIamPermissions_async", + "title": "CloudBilling testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Tests the access control policy for a billing account. This method takes the resource and a set of permissions as input and returns the subset of the input permissions that the caller is allowed for that resource.", + "canonical": true, + "file": "cloud_billing.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.billing.v1.CloudBilling.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "CloudBillingClient", + "fullName": "google.cloud.billing.v1.CloudBillingClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.billing.v1.CloudBilling.TestIamPermissions", + "service": { + "shortName": "CloudBilling", + "fullName": "google.cloud.billing.v1.CloudBilling" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudCatalog_ListServices_async", + "title": "CloudBilling listServices Sample", + "origin": "API_DEFINITION", + "description": " Lists all public cloud services.", + "canonical": true, + "file": "cloud_catalog.list_services.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServices", + "fullName": "google.cloud.billing.v1.CloudCatalog.ListServices", + "async": true, + "parameters": [ + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.billing.v1.ListServicesResponse", + "client": { + "shortName": "CloudCatalogClient", + "fullName": "google.cloud.billing.v1.CloudCatalogClient" + }, + "method": { + "shortName": "ListServices", + "fullName": "google.cloud.billing.v1.CloudCatalog.ListServices", + "service": { + "shortName": "CloudCatalog", + "fullName": "google.cloud.billing.v1.CloudCatalog" + } + } + } + }, + { + "regionTag": "cloudbilling_v1_generated_CloudCatalog_ListSkus_async", + "title": "CloudBilling listSkus Sample", + "origin": "API_DEFINITION", + "description": " Lists all publicly available SKUs for a given cloud service.", + "canonical": true, + "file": "cloud_catalog.list_skus.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 90, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListSkus", + "fullName": "google.cloud.billing.v1.CloudCatalog.ListSkus", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "start_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "end_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "currency_code", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.billing.v1.ListSkusResponse", + "client": { + "shortName": "CloudCatalogClient", + "fullName": "google.cloud.billing.v1.CloudCatalogClient" + }, + "method": { + "shortName": "ListSkus", + "fullName": "google.cloud.billing.v1.CloudCatalog.ListSkus", + "service": { + "shortName": "CloudCatalog", + "fullName": "google.cloud.billing.v1.CloudCatalog" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/index.ts b/owl-bot-staging/google-cloud-billing/v1/src/index.ts new file mode 100644 index 00000000000..6cac30c8973 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 CloudBillingClient = v1.CloudBillingClient; +type CloudBillingClient = v1.CloudBillingClient; +const CloudCatalogClient = v1.CloudCatalogClient; +type CloudCatalogClient = v1.CloudCatalogClient; +export {v1, CloudBillingClient, CloudCatalogClient}; +export default {v1, CloudBillingClient, CloudCatalogClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts new file mode 100644 index 00000000000..540b19e2b1b --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts @@ -0,0 +1,1457 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/cloud_billing_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './cloud_billing_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Retrieves the Google Cloud Console billing accounts and associates them with + * projects. + * @class + * @memberof v1 + */ +export class CloudBillingClient { + 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}; + pathTemplates: {[name: string]: gax.PathTemplate}; + cloudBillingStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CloudBillingClient. + * + * @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 CloudBillingClient({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 CloudBillingClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== 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 useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + billingAccountPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}' + ), + servicePathTemplate: new this._gaxModule.PathTemplate( + 'services/{service}' + ), + skuPathTemplate: new this._gaxModule.PathTemplate( + 'services/{service}/skus/{sku}' + ), + }; + + // 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 = { + listBillingAccounts: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'billingAccounts'), + listProjectBillingInfo: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'projectBillingInfo') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.billing.v1.CloudBilling', 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.cloudBillingStub) { + return this.cloudBillingStub; + } + + // Put together the "service stub" for + // google.cloud.billing.v1.CloudBilling. + this.cloudBillingStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.billing.v1.CloudBilling') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.billing.v1.CloudBilling, + 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 cloudBillingStubMethods = + ['getBillingAccount', 'listBillingAccounts', 'updateBillingAccount', 'createBillingAccount', 'listProjectBillingInfo', 'getProjectBillingInfo', 'updateProjectBillingInfo', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of cloudBillingStubMethods) { + const callPromise = this.cloudBillingStub.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.cloudBillingStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudbilling.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 'cloudbilling.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/cloud-billing', + 'https://www.googleapis.com/auth/cloud-billing.readonly', + 'https://www.googleapis.com/auth/cloud-platform' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets information about a billing account. The current authenticated user + * must be a [viewer of the billing + * account](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the billing account to retrieve. For example, + * `billingAccounts/012345-567890-ABCDEF`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. + * 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/cloud_billing.get_billing_account.js + * region_tag:cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async + */ + getBillingAccount( + request?: protos.google.cloud.billing.v1.IGetBillingAccountRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IGetBillingAccountRequest|undefined, {}|undefined + ]>; + getBillingAccount( + request: protos.google.cloud.billing.v1.IGetBillingAccountRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, + {}|null|undefined>): void; + getBillingAccount( + request: protos.google.cloud.billing.v1.IGetBillingAccountRequest, + callback: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, + {}|null|undefined>): void; + getBillingAccount( + request?: protos.google.cloud.billing.v1.IGetBillingAccountRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IGetBillingAccountRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getBillingAccount(request, options, callback); + } +/** + * Updates a billing account's fields. + * Currently the only field that can be edited is `display_name`. + * The current authenticated user must have the `billing.accounts.update` + * IAM permission, which is typically given to the + * [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) + * of the billing account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the billing account resource to be updated. + * @param {google.cloud.billing.v1.BillingAccount} request.account + * Required. The billing account resource to replace the resource on the server. + * @param {google.protobuf.FieldMask} request.updateMask + * The update mask applied to the resource. + * Only "display_name" is currently supported. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. + * 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/cloud_billing.update_billing_account.js + * region_tag:cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async + */ + updateBillingAccount( + request?: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|undefined, {}|undefined + ]>; + updateBillingAccount( + request: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, + {}|null|undefined>): void; + updateBillingAccount( + request: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, + callback: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, + {}|null|undefined>): void; + updateBillingAccount( + request?: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateBillingAccount(request, options, callback); + } +/** + * This method creates [billing + * subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). + * + * Google Cloud resellers should use the + * Channel Services APIs, + * [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) + * and + * [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). + * + * When creating a subaccount, the current authenticated user must have the + * `billing.accounts.update` IAM permission on the parent account, which is + * typically given to billing account + * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). + * This method will return an error if the parent account has not been + * provisioned as a reseller account. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.billing.v1.BillingAccount} request.billingAccount + * Required. The billing account resource to create. + * Currently CreateBillingAccount only supports subaccount creation, so + * any created billing accounts must be under a provided parent billing + * account. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. + * 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/cloud_billing.create_billing_account.js + * region_tag:cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async + */ + createBillingAccount( + request?: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.ICreateBillingAccountRequest|undefined, {}|undefined + ]>; + createBillingAccount( + request: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, + {}|null|undefined>): void; + createBillingAccount( + request: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, + callback: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, + {}|null|undefined>): void; + createBillingAccount( + request?: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount, + protos.google.cloud.billing.v1.ICreateBillingAccountRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof 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.createBillingAccount(request, options, callback); + } +/** + * Gets the billing information for a project. The current authenticated user + * must have the `resourcemanager.projects.get` permission for the project, + * which can be granted by assigning the [Project + * Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) + * role. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the project for which billing information is + * retrieved. For example, `projects/tokyo-rain-123`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. + * 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/cloud_billing.get_project_billing_info.js + * region_tag:cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async + */ + getProjectBillingInfo( + request?: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|undefined, {}|undefined + ]>; + getProjectBillingInfo( + request: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, + {}|null|undefined>): void; + getProjectBillingInfo( + request: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, + callback: Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, + {}|null|undefined>): void; + getProjectBillingInfo( + request?: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProjectBillingInfo(request, options, callback); + } +/** + * Sets or updates the billing account associated with a project. You specify + * the new billing account by setting the `billing_account_name` in the + * `ProjectBillingInfo` resource to the resource name of a billing account. + * Associating a project with an open billing account enables billing on the + * project and allows charges for resource usage. If the project already had a + * billing account, this method changes the billing account used for resource + * usage charges. + * + * *Note:* Incurred charges that have not yet been reported in the transaction + * history of the Google Cloud Console might be billed to the new billing + * account, even if the charge occurred before the new billing account was + * assigned to the project. + * + * The current authenticated user must have ownership privileges for both the + * [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo + * ) and the [billing + * account](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * You can disable billing on the project by setting the + * `billing_account_name` field to empty. This action disassociates the + * current billing account from the project. Any billable activity of your + * in-use services will stop, and your application could stop functioning as + * expected. Any unbilled charges to date will be billed to the previously + * associated account. The current authenticated user must be either an owner + * of the project or an owner of the billing account for the project. + * + * Note that associating a project with a *closed* billing account will have + * much the same effect as disabling billing on the project: any paid + * resources used by the project will be shut down. Thus, unless you wish to + * disable billing, you should always call this method with the name of an + * *open* billing account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the project associated with the billing information + * that you want to update. For example, `projects/tokyo-rain-123`. + * @param {google.cloud.billing.v1.ProjectBillingInfo} request.projectBillingInfo + * The new billing information for the project. Read-only fields are ignored; + * thus, you can leave empty all fields except `billing_account_name`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. + * 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/cloud_billing.update_project_billing_info.js + * region_tag:cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async + */ + updateProjectBillingInfo( + request?: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|undefined, {}|undefined + ]>; + updateProjectBillingInfo( + request: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, + {}|null|undefined>): void; + updateProjectBillingInfo( + request: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, + callback: Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, + {}|null|undefined>): void; + updateProjectBillingInfo( + request?: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.billing.v1.IProjectBillingInfo, + protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProjectBillingInfo(request, options, callback); + } +/** + * Gets the access control policy for a billing account. + * The caller must have the `billing.accounts.getIamPolicy` permission on the + * account, which is often given to billing account + * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.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/cloud_billing.get_iam_policy.js + * region_tag:cloudbilling_v1_generated_CloudBilling_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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); + } +/** + * Sets the access control policy for a billing account. Replaces any existing + * policy. + * The caller must have the `billing.accounts.setIamPolicy` permission on the + * account, which is often given to billing account + * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * 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 a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.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/cloud_billing.set_iam_policy.js + * region_tag:cloudbilling_v1_generated_CloudBilling_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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); + } +/** + * Tests the access control policy for a billing account. This method takes + * the resource and a set of permissions as input and returns the subset of + * the input permissions that the caller is allowed for that resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * 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/cloud_billing.test_iam_permissions.js + * region_tag:cloudbilling_v1_generated_CloudBilling_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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 the billing accounts that the current authenticated user has + * permission to + * [view](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.pageSize + * Requested page size. The maximum page size is 100; this is also the + * default. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListBillingAccounts` + * call. If unspecified, the first page of results is returned. + * @param {string} request.filter + * Options for how to filter the returned billing accounts. + * Currently this only supports filtering for + * [subaccounts](https://cloud.google.com/billing/docs/concepts) under a + * single provided reseller billing account. + * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). + * Boolean algebra and other fields are not currently supported. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. + * 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 `listBillingAccountsAsync()` + * 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. + */ + listBillingAccounts( + request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount[], + protos.google.cloud.billing.v1.IListBillingAccountsRequest|null, + protos.google.cloud.billing.v1.IListBillingAccountsResponse + ]>; + listBillingAccounts( + request: protos.google.cloud.billing.v1.IListBillingAccountsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListBillingAccountsRequest, + protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, + protos.google.cloud.billing.v1.IBillingAccount>): void; + listBillingAccounts( + request: protos.google.cloud.billing.v1.IListBillingAccountsRequest, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListBillingAccountsRequest, + protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, + protos.google.cloud.billing.v1.IBillingAccount>): void; + listBillingAccounts( + request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.billing.v1.IListBillingAccountsRequest, + protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, + protos.google.cloud.billing.v1.IBillingAccount>, + callback?: PaginationCallback< + protos.google.cloud.billing.v1.IListBillingAccountsRequest, + protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, + protos.google.cloud.billing.v1.IBillingAccount>): + Promise<[ + protos.google.cloud.billing.v1.IBillingAccount[], + protos.google.cloud.billing.v1.IListBillingAccountsRequest|null, + protos.google.cloud.billing.v1.IListBillingAccountsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof 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.listBillingAccounts(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 {number} request.pageSize + * Requested page size. The maximum page size is 100; this is also the + * default. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListBillingAccounts` + * call. If unspecified, the first page of results is returned. + * @param {string} request.filter + * Options for how to filter the returned billing accounts. + * Currently this only supports filtering for + * [subaccounts](https://cloud.google.com/billing/docs/concepts) under a + * single provided reseller billing account. + * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). + * Boolean algebra and other fields are not currently supported. + * @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 [BillingAccount]{@link google.cloud.billing.v1.BillingAccount} 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 `listBillingAccountsAsync()` + * 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. + */ + listBillingAccountsStream( + request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listBillingAccounts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listBillingAccounts.createStream( + this.innerApiCalls.listBillingAccounts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listBillingAccounts`, 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 {number} request.pageSize + * Requested page size. The maximum page size is 100; this is also the + * default. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListBillingAccounts` + * call. If unspecified, the first page of results is returned. + * @param {string} request.filter + * Options for how to filter the returned billing accounts. + * Currently this only supports filtering for + * [subaccounts](https://cloud.google.com/billing/docs/concepts) under a + * single provided reseller billing account. + * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). + * Boolean algebra and other fields are not currently supported. + * @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 + * [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. 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/cloud_billing.list_billing_accounts.js + * region_tag:cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async + */ + listBillingAccountsAsync( + request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listBillingAccounts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listBillingAccounts.asyncIterate( + this.innerApiCalls['listBillingAccounts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the projects associated with a billing account. The current + * authenticated user must have the `billing.resourceAssociations.list` IAM + * permission, which is often given to billing account + * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the billing account associated with the projects that + * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. + * @param {number} request.pageSize + * Requested page size. The maximum page size is 100; this is also the + * default. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous `ListProjectBillingInfo` + * call. If unspecified, the first page of results is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. + * 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 `listProjectBillingInfoAsync()` + * 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. + */ + listProjectBillingInfo( + request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IProjectBillingInfo[], + protos.google.cloud.billing.v1.IListProjectBillingInfoRequest|null, + protos.google.cloud.billing.v1.IListProjectBillingInfoResponse + ]>; + listProjectBillingInfo( + request: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, + protos.google.cloud.billing.v1.IProjectBillingInfo>): void; + listProjectBillingInfo( + request: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, + protos.google.cloud.billing.v1.IProjectBillingInfo>): void; + listProjectBillingInfo( + request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, + protos.google.cloud.billing.v1.IProjectBillingInfo>, + callback?: PaginationCallback< + protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, + protos.google.cloud.billing.v1.IProjectBillingInfo>): + Promise<[ + protos.google.cloud.billing.v1.IProjectBillingInfo[], + protos.google.cloud.billing.v1.IListProjectBillingInfoRequest|null, + protos.google.cloud.billing.v1.IListProjectBillingInfoResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProjectBillingInfo(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.name + * Required. The resource name of the billing account associated with the projects that + * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. + * @param {number} request.pageSize + * Requested page size. The maximum page size is 100; this is also the + * default. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous `ListProjectBillingInfo` + * call. If unspecified, the first page of results is returned. + * @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 [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo} 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 `listProjectBillingInfoAsync()` + * 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. + */ + listProjectBillingInfoStream( + request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProjectBillingInfo']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProjectBillingInfo.createStream( + this.innerApiCalls.listProjectBillingInfo as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProjectBillingInfo`, 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.name + * Required. The resource name of the billing account associated with the projects that + * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. + * @param {number} request.pageSize + * Requested page size. The maximum page size is 100; this is also the + * default. + * @param {string} request.pageToken + * A token identifying a page of results to be returned. This should be a + * `next_page_token` value returned from a previous `ListProjectBillingInfo` + * call. If unspecified, the first page of results is returned. + * @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 + * [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. 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/cloud_billing.list_project_billing_info.js + * region_tag:cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async + */ + listProjectBillingInfoAsync( + request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, + 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({ + 'name': request.name ?? '', + }); + const defaultCallSettings = this._defaults['listProjectBillingInfo']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProjectBillingInfo.asyncIterate( + this.innerApiCalls['listProjectBillingInfo'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified billingAccount resource name string. + * + * @param {string} billing_account + * @returns {string} Resource name string. + */ + billingAccountPath(billingAccount:string) { + return this.pathTemplates.billingAccountPathTemplate.render({ + billing_account: billingAccount, + }); + } + + /** + * Parse the billing_account from BillingAccount resource. + * + * @param {string} billingAccountName + * A fully-qualified path representing BillingAccount resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountName(billingAccountName: string) { + return this.pathTemplates.billingAccountPathTemplate.match(billingAccountName).billing_account; + } + + /** + * Return a fully-qualified service resource name string. + * + * @param {string} service + * @returns {string} Resource name string. + */ + servicePath(service:string) { + return this.pathTemplates.servicePathTemplate.render({ + service: service, + }); + } + + /** + * Parse the service from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).service; + } + + /** + * Return a fully-qualified sku resource name string. + * + * @param {string} service + * @param {string} sku + * @returns {string} Resource name string. + */ + skuPath(service:string,sku:string) { + return this.pathTemplates.skuPathTemplate.render({ + service: service, + sku: sku, + }); + } + + /** + * Parse the service from Sku resource. + * + * @param {string} skuName + * A fully-qualified path representing Sku resource. + * @returns {string} A string representing the service. + */ + matchServiceFromSkuName(skuName: string) { + return this.pathTemplates.skuPathTemplate.match(skuName).service; + } + + /** + * Parse the sku from Sku resource. + * + * @param {string} skuName + * A fully-qualified path representing Sku resource. + * @returns {string} A string representing the sku. + */ + matchSkuFromSkuName(skuName: string) { + return this.pathTemplates.skuPathTemplate.match(skuName).sku; + } + + /** + * 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.cloudBillingStub && !this._terminated) { + return this.cloudBillingStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json new file mode 100644 index 00000000000..e98db6a6e4b --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json @@ -0,0 +1,76 @@ +{ + "interfaces": { + "google.cloud.billing.v1.CloudBilling": { + "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": { + "GetBillingAccount": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListBillingAccounts": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateBillingAccount": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateBillingAccount": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProjectBillingInfo": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetProjectBillingInfo": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateProjectBillingInfo": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json new file mode 100644 index 00000000000..e34eb066aa5 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/cloud/billing/v1/cloud_billing.proto", + "../../protos/google/cloud/billing/v1/cloud_catalog.proto" +] diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts new file mode 100644 index 00000000000..eacdffc3461 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts @@ -0,0 +1,791 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/cloud_catalog_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './cloud_catalog_client_config.json'; +const version = require('../../../package.json').version; + +/** + * A catalog of Google Cloud Platform services and SKUs. + * Provides pricing information and metadata on Google Cloud Platform services + * and SKUs. + * @class + * @memberof v1 + */ +export class CloudCatalogClient { + 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}; + pathTemplates: {[name: string]: gax.PathTemplate}; + cloudCatalogStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CloudCatalogClient. + * + * @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 CloudCatalogClient({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 CloudCatalogClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== 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 useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + servicePathTemplate: new this._gaxModule.PathTemplate( + 'services/{service}' + ), + skuPathTemplate: new this._gaxModule.PathTemplate( + 'services/{service}/skus/{sku}' + ), + }; + + // 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 = { + listServices: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services'), + listSkus: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'skus') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.billing.v1.CloudCatalog', 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.cloudCatalogStub) { + return this.cloudCatalogStub; + } + + // Put together the "service stub" for + // google.cloud.billing.v1.CloudCatalog. + this.cloudCatalogStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.billing.v1.CloudCatalog') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.billing.v1.CloudCatalog, + 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 cloudCatalogStubMethods = + ['listServices', 'listSkus']; + for (const methodName of cloudCatalogStubMethods) { + const callPromise = this.cloudCatalogStub.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.cloudCatalogStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudbilling.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 'cloudbilling.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/cloud-billing', + 'https://www.googleapis.com/auth/cloud-billing.readonly', + '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 -- + // ------------------- + + /** + * Lists all public cloud services. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.pageSize + * Requested page size. Defaults to 5000. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListServices` + * call. If unspecified, the first page of results is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Service]{@link google.cloud.billing.v1.Service}. + * 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 `listServicesAsync()` + * 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. + */ + listServices( + request?: protos.google.cloud.billing.v1.IListServicesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.IService[], + protos.google.cloud.billing.v1.IListServicesRequest|null, + protos.google.cloud.billing.v1.IListServicesResponse + ]>; + listServices( + request: protos.google.cloud.billing.v1.IListServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListServicesRequest, + protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, + protos.google.cloud.billing.v1.IService>): void; + listServices( + request: protos.google.cloud.billing.v1.IListServicesRequest, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListServicesRequest, + protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, + protos.google.cloud.billing.v1.IService>): void; + listServices( + request?: protos.google.cloud.billing.v1.IListServicesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.billing.v1.IListServicesRequest, + protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, + protos.google.cloud.billing.v1.IService>, + callback?: PaginationCallback< + protos.google.cloud.billing.v1.IListServicesRequest, + protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, + protos.google.cloud.billing.v1.IService>): + Promise<[ + protos.google.cloud.billing.v1.IService[], + protos.google.cloud.billing.v1.IListServicesRequest|null, + protos.google.cloud.billing.v1.IListServicesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof 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.listServices(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 {number} request.pageSize + * Requested page size. Defaults to 5000. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListServices` + * call. If unspecified, the first page of results is returned. + * @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 [Service]{@link google.cloud.billing.v1.Service} 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 `listServicesAsync()` + * 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. + */ + listServicesStream( + request?: protos.google.cloud.billing.v1.IListServicesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listServices']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServices.createStream( + this.innerApiCalls.listServices as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listServices`, 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 {number} request.pageSize + * Requested page size. Defaults to 5000. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListServices` + * call. If unspecified, the first page of results is returned. + * @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 + * [Service]{@link google.cloud.billing.v1.Service}. 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/cloud_catalog.list_services.js + * region_tag:cloudbilling_v1_generated_CloudCatalog_ListServices_async + */ + listServicesAsync( + request?: protos.google.cloud.billing.v1.IListServicesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listServices']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServices.asyncIterate( + this.innerApiCalls['listServices'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists all publicly available SKUs for a given cloud service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the service. + * Example: "services/DA34-426B-A397" + * @param {google.protobuf.Timestamp} request.startTime + * Optional inclusive start time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + * @param {google.protobuf.Timestamp} request.endTime + * Optional exclusive end time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + * @param {string} request.currencyCode + * The ISO 4217 currency code for the pricing info in the response proto. + * Will use the conversion rate as of start_time. + * Optional. If not specified USD will be used. + * @param {number} request.pageSize + * Requested page size. Defaults to 5000. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListSkus` + * call. If unspecified, the first page of results is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Sku]{@link google.cloud.billing.v1.Sku}. + * 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 `listSkusAsync()` + * 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. + */ + listSkus( + request?: protos.google.cloud.billing.v1.IListSkusRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.billing.v1.ISku[], + protos.google.cloud.billing.v1.IListSkusRequest|null, + protos.google.cloud.billing.v1.IListSkusResponse + ]>; + listSkus( + request: protos.google.cloud.billing.v1.IListSkusRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListSkusRequest, + protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, + protos.google.cloud.billing.v1.ISku>): void; + listSkus( + request: protos.google.cloud.billing.v1.IListSkusRequest, + callback: PaginationCallback< + protos.google.cloud.billing.v1.IListSkusRequest, + protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, + protos.google.cloud.billing.v1.ISku>): void; + listSkus( + request?: protos.google.cloud.billing.v1.IListSkusRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.billing.v1.IListSkusRequest, + protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, + protos.google.cloud.billing.v1.ISku>, + callback?: PaginationCallback< + protos.google.cloud.billing.v1.IListSkusRequest, + protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, + protos.google.cloud.billing.v1.ISku>): + Promise<[ + protos.google.cloud.billing.v1.ISku[], + protos.google.cloud.billing.v1.IListSkusRequest|null, + protos.google.cloud.billing.v1.IListSkusResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listSkus(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the service. + * Example: "services/DA34-426B-A397" + * @param {google.protobuf.Timestamp} request.startTime + * Optional inclusive start time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + * @param {google.protobuf.Timestamp} request.endTime + * Optional exclusive end time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + * @param {string} request.currencyCode + * The ISO 4217 currency code for the pricing info in the response proto. + * Will use the conversion rate as of start_time. + * Optional. If not specified USD will be used. + * @param {number} request.pageSize + * Requested page size. Defaults to 5000. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListSkus` + * call. If unspecified, the first page of results is returned. + * @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 [Sku]{@link google.cloud.billing.v1.Sku} 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 `listSkusAsync()` + * 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. + */ + listSkusStream( + request?: protos.google.cloud.billing.v1.IListSkusRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listSkus']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSkus.createStream( + this.innerApiCalls.listSkus as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listSkus`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the service. + * Example: "services/DA34-426B-A397" + * @param {google.protobuf.Timestamp} request.startTime + * Optional inclusive start time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + * @param {google.protobuf.Timestamp} request.endTime + * Optional exclusive end time of the time range for which the pricing + * versions will be returned. Timestamps in the future are not allowed. + * The time range has to be within a single calendar month in + * America/Los_Angeles timezone. Time range as a whole is optional. If not + * specified, the latest pricing will be returned (up to 12 hours old at + * most). + * @param {string} request.currencyCode + * The ISO 4217 currency code for the pricing info in the response proto. + * Will use the conversion rate as of start_time. + * Optional. If not specified USD will be used. + * @param {number} request.pageSize + * Requested page size. Defaults to 5000. + * @param {string} request.pageToken + * A token identifying a page of results to return. This should be a + * `next_page_token` value returned from a previous `ListSkus` + * call. If unspecified, the first page of results is returned. + * @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 + * [Sku]{@link google.cloud.billing.v1.Sku}. 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/cloud_catalog.list_skus.js + * region_tag:cloudbilling_v1_generated_CloudCatalog_ListSkus_async + */ + listSkusAsync( + request?: protos.google.cloud.billing.v1.IListSkusRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listSkus']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSkus.asyncIterate( + this.innerApiCalls['listSkus'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified service resource name string. + * + * @param {string} service + * @returns {string} Resource name string. + */ + servicePath(service:string) { + return this.pathTemplates.servicePathTemplate.render({ + service: service, + }); + } + + /** + * Parse the service from Service resource. + * + * @param {string} serviceName + * A fully-qualified path representing Service resource. + * @returns {string} A string representing the service. + */ + matchServiceFromServiceName(serviceName: string) { + return this.pathTemplates.servicePathTemplate.match(serviceName).service; + } + + /** + * Return a fully-qualified sku resource name string. + * + * @param {string} service + * @param {string} sku + * @returns {string} Resource name string. + */ + skuPath(service:string,sku:string) { + return this.pathTemplates.skuPathTemplate.render({ + service: service, + sku: sku, + }); + } + + /** + * Parse the service from Sku resource. + * + * @param {string} skuName + * A fully-qualified path representing Sku resource. + * @returns {string} A string representing the service. + */ + matchServiceFromSkuName(skuName: string) { + return this.pathTemplates.skuPathTemplate.match(skuName).service; + } + + /** + * Parse the sku from Sku resource. + * + * @param {string} skuName + * A fully-qualified path representing Sku resource. + * @returns {string} A string representing the sku. + */ + matchSkuFromSkuName(skuName: string) { + return this.pathTemplates.skuPathTemplate.match(skuName).sku; + } + + /** + * 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.cloudCatalogStub && !this._terminated) { + return this.cloudCatalogStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json new file mode 100644 index 00000000000..65eb2dffc09 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json @@ -0,0 +1,36 @@ +{ + "interfaces": { + "google.cloud.billing.v1.CloudCatalog": { + "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": { + "ListServices": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListSkus": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json new file mode 100644 index 00000000000..e34eb066aa5 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/cloud/billing/v1/cloud_billing.proto", + "../../protos/google/cloud/billing/v1/cloud_catalog.proto" +] diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..57395f94def --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json @@ -0,0 +1,173 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.billing.v1", + "libraryPackage": "@google-cloud/billing", + "services": { + "CloudBilling": { + "clients": { + "grpc": { + "libraryClient": "CloudBillingClient", + "rpcs": { + "GetBillingAccount": { + "methods": [ + "getBillingAccount" + ] + }, + "UpdateBillingAccount": { + "methods": [ + "updateBillingAccount" + ] + }, + "CreateBillingAccount": { + "methods": [ + "createBillingAccount" + ] + }, + "GetProjectBillingInfo": { + "methods": [ + "getProjectBillingInfo" + ] + }, + "UpdateProjectBillingInfo": { + "methods": [ + "updateProjectBillingInfo" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "ListBillingAccounts": { + "methods": [ + "listBillingAccounts", + "listBillingAccountsStream", + "listBillingAccountsAsync" + ] + }, + "ListProjectBillingInfo": { + "methods": [ + "listProjectBillingInfo", + "listProjectBillingInfoStream", + "listProjectBillingInfoAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CloudBillingClient", + "rpcs": { + "GetBillingAccount": { + "methods": [ + "getBillingAccount" + ] + }, + "UpdateBillingAccount": { + "methods": [ + "updateBillingAccount" + ] + }, + "CreateBillingAccount": { + "methods": [ + "createBillingAccount" + ] + }, + "GetProjectBillingInfo": { + "methods": [ + "getProjectBillingInfo" + ] + }, + "UpdateProjectBillingInfo": { + "methods": [ + "updateProjectBillingInfo" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "ListBillingAccounts": { + "methods": [ + "listBillingAccounts", + "listBillingAccountsStream", + "listBillingAccountsAsync" + ] + }, + "ListProjectBillingInfo": { + "methods": [ + "listProjectBillingInfo", + "listProjectBillingInfoStream", + "listProjectBillingInfoAsync" + ] + } + } + } + } + }, + "CloudCatalog": { + "clients": { + "grpc": { + "libraryClient": "CloudCatalogClient", + "rpcs": { + "ListServices": { + "methods": [ + "listServices", + "listServicesStream", + "listServicesAsync" + ] + }, + "ListSkus": { + "methods": [ + "listSkus", + "listSkusStream", + "listSkusAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CloudCatalogClient", + "rpcs": { + "ListServices": { + "methods": [ + "listServices", + "listServicesStream", + "listServicesAsync" + ] + }, + "ListSkus": { + "methods": [ + "listSkus", + "listSkusStream", + "listSkusAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts new file mode 100644 index 00000000000..def6d7cf917 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {CloudBillingClient} from './cloud_billing_client'; +export {CloudCatalogClient} from './cloud_catalog_client'; diff --git a/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..09c87aa5083 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 billing = require('@google-cloud/billing'); + +function main() { + const cloudBillingClient = new billing.CloudBillingClient(); + const cloudCatalogClient = new billing.CloudCatalogClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..08be974583e --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {CloudBillingClient, CloudCatalogClient} from '@google-cloud/billing'; + +// check that the client class type name can be used +function doStuffWithCloudBillingClient(client: CloudBillingClient) { + client.close(); +} +function doStuffWithCloudCatalogClient(client: CloudCatalogClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const cloudBillingClient = new CloudBillingClient(); + doStuffWithCloudBillingClient(cloudBillingClient); + // check that the client instance can be created + const cloudCatalogClient = new CloudCatalogClient(); + doStuffWithCloudCatalogClient(cloudCatalogClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-billing/v1/system-test/install.ts b/owl-bot-staging/google-cloud-billing/v1/system-test/install.ts new file mode 100644 index 00000000000..557a57558e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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-billing/v1/test/gapic_cloud_billing_v1.ts b/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_billing_v1.ts new file mode 100644 index 00000000000..5b87b5fffec --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_billing_v1.ts @@ -0,0 +1,1549 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as cloudbillingModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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.CloudBillingClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = cloudbillingModule.v1.CloudBillingClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = cloudbillingModule.v1.CloudBillingClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = cloudbillingModule.v1.CloudBillingClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new cloudbillingModule.v1.CloudBillingClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudBillingStub, undefined); + await client.initialize(); + assert(client.cloudBillingStub); + }); + + it('has close method for the initialized client', done => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.cloudBillingStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudBillingStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getBillingAccount', () => { + it('invokes getBillingAccount without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.BillingAccount() + ); + client.innerApiCalls.getBillingAccount = stubSimpleCall(expectedResponse); + const [response] = await client.getBillingAccount(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getBillingAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getBillingAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getBillingAccount without error using callback', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.BillingAccount() + ); + client.innerApiCalls.getBillingAccount = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBillingAccount( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getBillingAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getBillingAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getBillingAccount with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getBillingAccount = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getBillingAccount(request), expectedError); + const actualRequest = (client.innerApiCalls.getBillingAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getBillingAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getBillingAccount with closed client', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getBillingAccount(request), expectedError); + }); + }); + + describe('updateBillingAccount', () => { + it('invokes updateBillingAccount without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.BillingAccount() + ); + client.innerApiCalls.updateBillingAccount = stubSimpleCall(expectedResponse); + const [response] = await client.updateBillingAccount(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateBillingAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateBillingAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateBillingAccount without error using callback', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.BillingAccount() + ); + client.innerApiCalls.updateBillingAccount = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateBillingAccount( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateBillingAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateBillingAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateBillingAccount with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateBillingAccount = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateBillingAccount(request), expectedError); + const actualRequest = (client.innerApiCalls.updateBillingAccount as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateBillingAccount as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateBillingAccount with closed client', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateBillingAccount(request), expectedError); + }); + }); + + describe('createBillingAccount', () => { + it('invokes createBillingAccount without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.CreateBillingAccountRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.BillingAccount() + ); + client.innerApiCalls.createBillingAccount = stubSimpleCall(expectedResponse); + const [response] = await client.createBillingAccount(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createBillingAccount without error using callback', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.CreateBillingAccountRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.BillingAccount() + ); + client.innerApiCalls.createBillingAccount = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createBillingAccount( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes createBillingAccount with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.CreateBillingAccountRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.createBillingAccount = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createBillingAccount(request), expectedError); + }); + + it('invokes createBillingAccount with closed client', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.CreateBillingAccountRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createBillingAccount(request), expectedError); + }); + }); + + describe('getProjectBillingInfo', () => { + it('invokes getProjectBillingInfo without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.ProjectBillingInfo() + ); + client.innerApiCalls.getProjectBillingInfo = stubSimpleCall(expectedResponse); + const [response] = await client.getProjectBillingInfo(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProjectBillingInfo without error using callback', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.ProjectBillingInfo() + ); + client.innerApiCalls.getProjectBillingInfo = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProjectBillingInfo( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IProjectBillingInfo|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProjectBillingInfo with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProjectBillingInfo = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProjectBillingInfo(request), expectedError); + const actualRequest = (client.innerApiCalls.getProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProjectBillingInfo with closed client', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProjectBillingInfo(request), expectedError); + }); + }); + + describe('updateProjectBillingInfo', () => { + it('invokes updateProjectBillingInfo without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.ProjectBillingInfo() + ); + client.innerApiCalls.updateProjectBillingInfo = stubSimpleCall(expectedResponse); + const [response] = await client.updateProjectBillingInfo(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProjectBillingInfo without error using callback', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.billing.v1.ProjectBillingInfo() + ); + client.innerApiCalls.updateProjectBillingInfo = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProjectBillingInfo( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IProjectBillingInfo|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProjectBillingInfo with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProjectBillingInfo = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProjectBillingInfo(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProjectBillingInfo with closed client', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProjectBillingInfo(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + 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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + 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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + 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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + 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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + 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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + 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 cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('listBillingAccounts', () => { + it('invokes listBillingAccounts without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListBillingAccountsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + ]; + client.innerApiCalls.listBillingAccounts = stubSimpleCall(expectedResponse); + const [response] = await client.listBillingAccounts(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listBillingAccounts without error using callback', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListBillingAccountsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + ]; + client.innerApiCalls.listBillingAccounts = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBillingAccounts( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listBillingAccounts with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListBillingAccountsRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.listBillingAccounts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listBillingAccounts(request), expectedError); + }); + + it('invokes listBillingAccountsStream without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListBillingAccountsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + ]; + client.descriptors.page.listBillingAccounts.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listBillingAccountsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.BillingAccount[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.BillingAccount) => { + 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.listBillingAccounts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listBillingAccounts, request)); + }); + + it('invokes listBillingAccountsStream with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListBillingAccountsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listBillingAccounts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listBillingAccountsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.BillingAccount[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.BillingAccount) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listBillingAccounts.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listBillingAccounts, request)); + }); + + it('uses async iteration with listBillingAccounts without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListBillingAccountsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), + ]; + client.descriptors.page.listBillingAccounts.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.billing.v1.IBillingAccount[] = []; + const iterable = client.listBillingAccountsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listBillingAccounts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listBillingAccounts with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListBillingAccountsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listBillingAccounts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listBillingAccountsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.billing.v1.IBillingAccount[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listBillingAccounts.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('listProjectBillingInfo', () => { + it('invokes listProjectBillingInfo without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + ]; + client.innerApiCalls.listProjectBillingInfo = stubSimpleCall(expectedResponse); + const [response] = await client.listProjectBillingInfo(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProjectBillingInfo without error using callback', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + ]; + client.innerApiCalls.listProjectBillingInfo = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProjectBillingInfo( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IProjectBillingInfo[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProjectBillingInfo with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProjectBillingInfo = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProjectBillingInfo(request), expectedError); + const actualRequest = (client.innerApiCalls.listProjectBillingInfo as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProjectBillingInfo as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProjectBillingInfoStream without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + ]; + client.descriptors.page.listProjectBillingInfo.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProjectBillingInfoStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.ProjectBillingInfo[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.ProjectBillingInfo) => { + 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.listProjectBillingInfo.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProjectBillingInfo, request)); + assert( + (client.descriptors.page.listProjectBillingInfo.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProjectBillingInfoStream with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProjectBillingInfo.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProjectBillingInfoStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.ProjectBillingInfo[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.ProjectBillingInfo) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProjectBillingInfo.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProjectBillingInfo, request)); + assert( + (client.descriptors.page.listProjectBillingInfo.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProjectBillingInfo without error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), + ]; + client.descriptors.page.listProjectBillingInfo.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.billing.v1.IProjectBillingInfo[] = []; + const iterable = client.listProjectBillingInfoAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProjectBillingInfo with error', async () => { + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProjectBillingInfo.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProjectBillingInfoAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.billing.v1.IProjectBillingInfo[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('billingAccount', () => { + const fakePath = "/rendered/path/billingAccount"; + const expectedParameters = { + billing_account: "billingAccountValue", + }; + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.billingAccountPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.billingAccountPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('billingAccountPath', () => { + const result = client.billingAccountPath("billingAccountValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.billingAccountPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchBillingAccountFromBillingAccountName', () => { + const result = client.matchBillingAccountFromBillingAccountName(fakePath); + assert.strictEqual(result, "billingAccountValue"); + assert((client.pathTemplates.billingAccountPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('service', () => { + const fakePath = "/rendered/path/service"; + const expectedParameters = { + service: "serviceValue", + }; + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath("serviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('sku', () => { + const fakePath = "/rendered/path/sku"; + const expectedParameters = { + service: "serviceValue", + sku: "skuValue", + }; + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.skuPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.skuPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('skuPath', () => { + const result = client.skuPath("serviceValue", "skuValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.skuPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchServiceFromSkuName', () => { + const result = client.matchServiceFromSkuName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.skuPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSkuFromSkuName', () => { + const result = client.matchSkuFromSkuName(fakePath); + assert.strictEqual(result, "skuValue"); + assert((client.pathTemplates.skuPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts b/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts new file mode 100644 index 00000000000..2b09f24d4d7 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts @@ -0,0 +1,688 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as cloudcatalogModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .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.CloudCatalogClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = cloudcatalogModule.v1.CloudCatalogClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = cloudcatalogModule.v1.CloudCatalogClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = cloudcatalogModule.v1.CloudCatalogClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudCatalogStub, undefined); + await client.initialize(); + assert(client.cloudCatalogStub); + }); + + it('has close method for the initialized client', done => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.cloudCatalogStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudCatalogStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('listServices', () => { + it('invokes listServices without error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListServicesRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + ]; + client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); + const [response] = await client.listServices(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listServices without error using callback', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListServicesRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + ]; + client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServices( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.IService[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes listServices with error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListServicesRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.listServices = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listServices(request), expectedError); + }); + + it('invokes listServicesStream without error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListServicesRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + ]; + client.descriptors.page.listServices.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.Service[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.Service) => { + 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.listServices.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServices, request)); + }); + + it('invokes listServicesStream with error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListServicesRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listServices.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.Service[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.Service) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listServices.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listServices, request)); + }); + + it('uses async iteration with listServices without error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListServicesRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + generateSampleMessage(new protos.google.cloud.billing.v1.Service()), + ]; + client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.billing.v1.IService[] = []; + const iterable = client.listServicesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listServices with error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListServicesRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServicesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.billing.v1.IService[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('listSkus', () => { + it('invokes listSkus without error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListSkusRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + ]; + client.innerApiCalls.listSkus = stubSimpleCall(expectedResponse); + const [response] = await client.listSkus(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSkus as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSkus as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSkus without error using callback', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListSkusRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + ]; + client.innerApiCalls.listSkus = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSkus( + request, + (err?: Error|null, result?: protos.google.cloud.billing.v1.ISku[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSkus as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSkus as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSkus with error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListSkusRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSkus = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listSkus(request), expectedError); + const actualRequest = (client.innerApiCalls.listSkus as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSkus as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSkusStream without error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListSkusRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + ]; + client.descriptors.page.listSkus.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listSkusStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.Sku[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.Sku) => { + 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.listSkus.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSkus, request)); + assert( + (client.descriptors.page.listSkus.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listSkusStream with error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListSkusRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSkus.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listSkusStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.billing.v1.Sku[] = []; + stream.on('data', (response: protos.google.cloud.billing.v1.Sku) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listSkus.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSkus, request)); + assert( + (client.descriptors.page.listSkus.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSkus without error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListSkusRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), + ]; + client.descriptors.page.listSkus.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.billing.v1.ISku[] = []; + const iterable = client.listSkusAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSkus.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSkus.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSkus with error', async () => { + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.billing.v1.ListSkusRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSkus.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSkusAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.billing.v1.ISku[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSkus.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSkus.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('service', () => { + const fakePath = "/rendered/path/service"; + const expectedParameters = { + service: "serviceValue", + }; + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.servicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('servicePath', () => { + const result = client.servicePath("serviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.servicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchServiceFromServiceName', () => { + const result = client.matchServiceFromServiceName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.servicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('sku', () => { + const fakePath = "/rendered/path/sku"; + const expectedParameters = { + service: "serviceValue", + sku: "skuValue", + }; + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.skuPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.skuPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('skuPath', () => { + const result = client.skuPath("serviceValue", "skuValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.skuPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchServiceFromSkuName', () => { + const result = client.matchServiceFromSkuName(fakePath); + assert.strictEqual(result, "serviceValue"); + assert((client.pathTemplates.skuPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchSkuFromSkuName', () => { + const result = client.matchSkuFromSkuName(fakePath); + assert.strictEqual(result, "skuValue"); + assert((client.pathTemplates.skuPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-billing/v1/tsconfig.json b/owl-bot-staging/google-cloud-billing/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/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-billing/v1/webpack.config.js b/owl-bot-staging/google-cloud-billing/v1/webpack.config.js new file mode 100644 index 00000000000..d2282430c03 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/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: 'CloudBilling', + filename: './cloud-billing.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', +}; From fbd026c0c8db57fdc93e72c72306be9402e15eb9 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 6 Dec 2022 03:55:57 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../google-cloud-billing/v1/.eslintignore | 7 - .../google-cloud-billing/v1/.eslintrc.json | 3 - .../google-cloud-billing/v1/.gitignore | 14 - .../google-cloud-billing/v1/.jsdoc.js | 55 - .../google-cloud-billing/v1/.mocharc.js | 33 - .../google-cloud-billing/v1/.prettierrc.js | 22 - .../google-cloud-billing/v1/README.md | 1 - .../v1/linkinator.config.json | 16 - .../google-cloud-billing/v1/package.json | 65 - .../cloud/billing/v1/cloud_billing.proto | 373 ---- .../cloud/billing/v1/cloud_catalog.proto | 363 ---- .../cloud_billing.create_billing_account.js | 64 - .../v1/cloud_billing.get_billing_account.js | 62 - .../v1/cloud_billing.get_iam_policy.js | 67 - .../cloud_billing.get_project_billing_info.js | 62 - .../v1/cloud_billing.list_billing_accounts.js | 78 - ...cloud_billing.list_project_billing_info.js | 75 - .../v1/cloud_billing.set_iam_policy.js | 77 - .../v1/cloud_billing.test_iam_permissions.js | 70 - .../cloud_billing.update_billing_account.js | 71 - ...oud_billing.update_project_billing_info.js | 67 - .../v1/cloud_catalog.list_services.js | 68 - .../generated/v1/cloud_catalog.list_skus.js | 98 -- ...ppet_metadata.google.cloud.billing.v1.json | 563 ------ .../google-cloud-billing/v1/src/index.ts | 27 - .../v1/src/v1/cloud_billing_client.ts | 1457 ---------------- .../src/v1/cloud_billing_client_config.json | 76 - .../v1/src/v1/cloud_billing_proto_list.json | 4 - .../v1/src/v1/cloud_catalog_client.ts | 791 --------- .../src/v1/cloud_catalog_client_config.json | 36 - .../v1/src/v1/cloud_catalog_proto_list.json | 4 - .../v1/src/v1/gapic_metadata.json | 173 -- .../google-cloud-billing/v1/src/v1/index.ts | 20 - .../system-test/fixtures/sample/src/index.js | 28 - .../system-test/fixtures/sample/src/index.ts | 38 - .../v1/system-test/install.ts | 49 - .../v1/test/gapic_cloud_billing_v1.ts | 1549 ----------------- .../v1/test/gapic_cloud_catalog_v1.ts | 688 -------- .../google-cloud-billing/v1/tsconfig.json | 19 - .../google-cloud-billing/v1/webpack.config.js | 64 - .../src/v1/cloud_billing_client.ts | 3 + .../src/v1/cloud_catalog_client.ts | 3 + 42 files changed, 6 insertions(+), 7397 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-billing/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-billing/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-billing/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-billing/v1/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto delete mode 100644 owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_billing_v1.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts delete mode 100644 owl-bot-staging/google-cloud-billing/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-billing/v1/webpack.config.js diff --git a/owl-bot-staging/google-cloud-billing/v1/.eslintignore b/owl-bot-staging/google-cloud-billing/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-billing/v1/.eslintrc.json b/owl-bot-staging/google-cloud-billing/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-billing/v1/.gitignore b/owl-bot-staging/google-cloud-billing/v1/.gitignore deleted file mode 100644 index 5d32b23782f..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.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-billing/v1/.jsdoc.js b/owl-bot-staging/google-cloud-billing/v1/.jsdoc.js deleted file mode 100644 index a1fe10efe19..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file 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 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/billing', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-billing/v1/.mocharc.js b/owl-bot-staging/google-cloud-billing/v1/.mocharc.js deleted file mode 100644 index 481c522b00f..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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-billing/v1/.prettierrc.js b/owl-bot-staging/google-cloud-billing/v1/.prettierrc.js deleted file mode 100644 index 494e147865d..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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-billing/v1/README.md b/owl-bot-staging/google-cloud-billing/v1/README.md deleted file mode 100644 index 4f22cab915e..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Billing: Nodejs Client diff --git a/owl-bot-staging/google-cloud-billing/v1/linkinator.config.json b/owl-bot-staging/google-cloud-billing/v1/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "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-billing/v1/package.json b/owl-bot-staging/google-cloud-billing/v1/package.json deleted file mode 100644 index 761cb3cfd5d..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@google-cloud/billing", - "version": "0.1.0", - "description": "Billing client for Node.js", - "repository": "googleapis/nodejs-billing", - "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 billing", - "billing", - "cloud billing", - "cloud catalog" - ], - "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.2" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.62", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.0.3", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.3", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto b/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto deleted file mode 100644 index b98f0fd7c26..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto +++ /dev/null @@ -1,373 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.billing.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/protobuf/field_mask.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/billing/v1;billing"; -option java_multiple_files = true; -option java_outer_classname = "CloudBillingProto"; -option java_package = "com.google.cloud.billing.v1"; - -// Retrieves the Google Cloud Console billing accounts and associates them with -// projects. -service CloudBilling { - option (google.api.default_host) = "cloudbilling.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-billing," - "https://www.googleapis.com/auth/cloud-billing.readonly," - "https://www.googleapis.com/auth/cloud-platform"; - - // Gets information about a billing account. The current authenticated user - // must be a [viewer of the billing - // account](https://cloud.google.com/billing/docs/how-to/billing-access). - rpc GetBillingAccount(GetBillingAccountRequest) returns (BillingAccount) { - option (google.api.http) = { - get: "/v1/{name=billingAccounts/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists the billing accounts that the current authenticated user has - // permission to - // [view](https://cloud.google.com/billing/docs/how-to/billing-access). - rpc ListBillingAccounts(ListBillingAccountsRequest) returns (ListBillingAccountsResponse) { - option (google.api.http) = { - get: "/v1/billingAccounts" - }; - option (google.api.method_signature) = ""; - } - - // Updates a billing account's fields. - // Currently the only field that can be edited is `display_name`. - // The current authenticated user must have the `billing.accounts.update` - // IAM permission, which is typically given to the - // [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) - // of the billing account. - rpc UpdateBillingAccount(UpdateBillingAccountRequest) returns (BillingAccount) { - option (google.api.http) = { - patch: "/v1/{name=billingAccounts/*}" - body: "account" - }; - option (google.api.method_signature) = "name,account"; - } - - // This method creates [billing - // subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). - // - // Google Cloud resellers should use the - // Channel Services APIs, - // [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) - // and - // [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). - // - // When creating a subaccount, the current authenticated user must have the - // `billing.accounts.update` IAM permission on the parent account, which is - // typically given to billing account - // [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). - // This method will return an error if the parent account has not been - // provisioned as a reseller account. - rpc CreateBillingAccount(CreateBillingAccountRequest) returns (BillingAccount) { - option (google.api.http) = { - post: "/v1/billingAccounts" - body: "billing_account" - }; - option (google.api.method_signature) = "billing_account"; - } - - // Lists the projects associated with a billing account. The current - // authenticated user must have the `billing.resourceAssociations.list` IAM - // permission, which is often given to billing account - // [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). - rpc ListProjectBillingInfo(ListProjectBillingInfoRequest) returns (ListProjectBillingInfoResponse) { - option (google.api.http) = { - get: "/v1/{name=billingAccounts/*}/projects" - }; - option (google.api.method_signature) = "name"; - } - - // Gets the billing information for a project. The current authenticated user - // must have the `resourcemanager.projects.get` permission for the project, - // which can be granted by assigning the [Project - // Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) - // role. - rpc GetProjectBillingInfo(GetProjectBillingInfoRequest) returns (ProjectBillingInfo) { - option (google.api.http) = { - get: "/v1/{name=projects/*}/billingInfo" - }; - option (google.api.method_signature) = "name"; - } - - // Sets or updates the billing account associated with a project. You specify - // the new billing account by setting the `billing_account_name` in the - // `ProjectBillingInfo` resource to the resource name of a billing account. - // Associating a project with an open billing account enables billing on the - // project and allows charges for resource usage. If the project already had a - // billing account, this method changes the billing account used for resource - // usage charges. - // - // *Note:* Incurred charges that have not yet been reported in the transaction - // history of the Google Cloud Console might be billed to the new billing - // account, even if the charge occurred before the new billing account was - // assigned to the project. - // - // The current authenticated user must have ownership privileges for both the - // [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo - // ) and the [billing - // account](https://cloud.google.com/billing/docs/how-to/billing-access). - // - // You can disable billing on the project by setting the - // `billing_account_name` field to empty. This action disassociates the - // current billing account from the project. Any billable activity of your - // in-use services will stop, and your application could stop functioning as - // expected. Any unbilled charges to date will be billed to the previously - // associated account. The current authenticated user must be either an owner - // of the project or an owner of the billing account for the project. - // - // Note that associating a project with a *closed* billing account will have - // much the same effect as disabling billing on the project: any paid - // resources used by the project will be shut down. Thus, unless you wish to - // disable billing, you should always call this method with the name of an - // *open* billing account. - rpc UpdateProjectBillingInfo(UpdateProjectBillingInfoRequest) returns (ProjectBillingInfo) { - option (google.api.http) = { - put: "/v1/{name=projects/*}/billingInfo" - body: "project_billing_info" - }; - option (google.api.method_signature) = "name,project_billing_info"; - } - - // Gets the access control policy for a billing account. - // The caller must have the `billing.accounts.getIamPolicy` permission on the - // account, which is often given to billing account - // [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - get: "/v1/{resource=billingAccounts/*}:getIamPolicy" - }; - option (google.api.method_signature) = "resource"; - } - - // Sets the access control policy for a billing account. Replaces any existing - // policy. - // The caller must have the `billing.accounts.setIamPolicy` permission on the - // account, which is often given to billing account - // [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v1/{resource=billingAccounts/*}:setIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource,policy"; - } - - // Tests the access control policy for a billing account. This method takes - // the resource and a set of permissions as input and returns the subset of - // the input permissions that the caller is allowed for that resource. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v1/{resource=billingAccounts/*}:testIamPermissions" - body: "*" - }; - option (google.api.method_signature) = "resource,permissions"; - } -} - -// A billing account in the -// [Google Cloud Console](https://console.cloud.google.com/). You can assign a -// billing account to one or more projects. -message BillingAccount { - // Output only. The resource name of the billing account. The resource name has the form - // `billingAccounts/{billing_account_id}`. For example, - // `billingAccounts/012345-567890-ABCDEF` would be the resource name for - // billing account `012345-567890-ABCDEF`. - string name = 1 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.resource_reference) = { - type: "cloudbilling.googleapis.com/BillingAccount" - } - ]; - - // Output only. True if the billing account is open, and will therefore be charged for any - // usage on associated projects. False if the billing account is closed, and - // therefore projects associated with it will be unable to use paid services. - bool open = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The display name given to the billing account, such as `My Billing - // Account`. This name is displayed in the Google Cloud Console. - string display_name = 3; - - // If this account is a - // [subaccount](https://cloud.google.com/billing/docs/concepts), then this - // will be the resource name of the parent billing account that it is being - // resold through. - // Otherwise this will be empty. - string master_billing_account = 4; -} - -// Encapsulation of billing information for a Google Cloud Console project. A -// project has at most one associated billing account at a time (but a billing -// account can be assigned to multiple projects). -message ProjectBillingInfo { - // The resource name for the `ProjectBillingInfo`; has the form - // `projects/{project_id}/billingInfo`. For example, the resource name for the - // billing information for project `tokyo-rain-123` would be - // `projects/tokyo-rain-123/billingInfo`. This field is read-only. - string name = 1; - - // The ID of the project that this `ProjectBillingInfo` represents, such as - // `tokyo-rain-123`. This is a convenience field so that you don't need to - // parse the `name` field to obtain a project ID. This field is read-only. - string project_id = 2; - - // The resource name of the billing account associated with the project, if - // any. For example, `billingAccounts/012345-567890-ABCDEF`. - string billing_account_name = 3; - - // True if the project is associated with an open billing account, to which - // usage on the project is charged. False if the project is associated with a - // closed billing account, or no billing account at all, and therefore cannot - // use paid services. This field is read-only. - bool billing_enabled = 4; -} - -// Request message for `GetBillingAccount`. -message GetBillingAccountRequest { - // Required. The resource name of the billing account to retrieve. For example, - // `billingAccounts/012345-567890-ABCDEF`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudbilling.googleapis.com/BillingAccount" - } - ]; -} - -// Request message for `ListBillingAccounts`. -message ListBillingAccountsRequest { - // Requested page size. The maximum page size is 100; this is also the - // default. - int32 page_size = 1; - - // A token identifying a page of results to return. This should be a - // `next_page_token` value returned from a previous `ListBillingAccounts` - // call. If unspecified, the first page of results is returned. - string page_token = 2; - - // Options for how to filter the returned billing accounts. - // Currently this only supports filtering for - // [subaccounts](https://cloud.google.com/billing/docs/concepts) under a - // single provided reseller billing account. - // (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). - // Boolean algebra and other fields are not currently supported. - string filter = 3; -} - -// Response message for `ListBillingAccounts`. -message ListBillingAccountsResponse { - // A list of billing accounts. - repeated BillingAccount billing_accounts = 1; - - // A token to retrieve the next page of results. To retrieve the next page, - // call `ListBillingAccounts` again with the `page_token` field set to this - // value. This field is empty if there are no more results to retrieve. - string next_page_token = 2; -} - -// Request message for `CreateBillingAccount`. -message CreateBillingAccountRequest { - // Required. The billing account resource to create. - // Currently CreateBillingAccount only supports subaccount creation, so - // any created billing accounts must be under a provided parent billing - // account. - BillingAccount billing_account = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for `UpdateBillingAccount`. -message UpdateBillingAccountRequest { - // Required. The name of the billing account resource to be updated. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudbilling.googleapis.com/BillingAccount" - } - ]; - - // Required. The billing account resource to replace the resource on the server. - BillingAccount account = 2 [(google.api.field_behavior) = REQUIRED]; - - // The update mask applied to the resource. - // Only "display_name" is currently supported. - google.protobuf.FieldMask update_mask = 3; -} - -// Request message for `ListProjectBillingInfo`. -message ListProjectBillingInfoRequest { - // Required. The resource name of the billing account associated with the projects that - // you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudbilling.googleapis.com/BillingAccount" - } - ]; - - // Requested page size. The maximum page size is 100; this is also the - // default. - int32 page_size = 2; - - // A token identifying a page of results to be returned. This should be a - // `next_page_token` value returned from a previous `ListProjectBillingInfo` - // call. If unspecified, the first page of results is returned. - string page_token = 3; -} - -// Request message for `ListProjectBillingInfoResponse`. -message ListProjectBillingInfoResponse { - // A list of `ProjectBillingInfo` resources representing the projects - // associated with the billing account. - repeated ProjectBillingInfo project_billing_info = 1; - - // A token to retrieve the next page of results. To retrieve the next page, - // call `ListProjectBillingInfo` again with the `page_token` field set to this - // value. This field is empty if there are no more results to retrieve. - string next_page_token = 2; -} - -// Request message for `GetProjectBillingInfo`. -message GetProjectBillingInfoRequest { - // Required. The resource name of the project for which billing information is - // retrieved. For example, `projects/tokyo-rain-123`. - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for `UpdateProjectBillingInfo`. -message UpdateProjectBillingInfoRequest { - // Required. The resource name of the project associated with the billing information - // that you want to update. For example, `projects/tokyo-rain-123`. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The new billing information for the project. Read-only fields are ignored; - // thus, you can leave empty all fields except `billing_account_name`. - ProjectBillingInfo project_billing_info = 2; -} diff --git a/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto b/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto deleted file mode 100644 index f3d46e62708..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto +++ /dev/null @@ -1,363 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.billing.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/money.proto"; - -option csharp_namespace = "Google.Cloud.Billing.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/billing/v1;billing"; -option java_multiple_files = true; -option java_outer_classname = "CloudCatalogProto"; -option java_package = "com.google.cloud.billing.v1"; -option objc_class_prefix = "CLDCTLG"; - -// A catalog of Google Cloud Platform services and SKUs. -// Provides pricing information and metadata on Google Cloud Platform services -// and SKUs. -service CloudCatalog { - option (google.api.default_host) = "cloudbilling.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-billing," - "https://www.googleapis.com/auth/cloud-billing.readonly," - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists all public cloud services. - rpc ListServices(ListServicesRequest) returns (ListServicesResponse) { - option (google.api.http) = { - get: "/v1/services" - }; - option (google.api.method_signature) = ""; - } - - // Lists all publicly available SKUs for a given cloud service. - rpc ListSkus(ListSkusRequest) returns (ListSkusResponse) { - option (google.api.http) = { - get: "/v1/{parent=services/*}/skus" - }; - option (google.api.method_signature) = "parent"; - } -} - -// Encapsulates a single service in Google Cloud Platform. -message Service { - option (google.api.resource) = { - type: "cloudbilling.googleapis.com/Service" - pattern: "services/{service}" - }; - - // The resource name for the service. - // Example: "services/DA34-426B-A397" - string name = 1; - - // The identifier for the service. - // Example: "DA34-426B-A397" - string service_id = 2; - - // A human readable display name for this service. - string display_name = 3; - - // The business under which the service is offered. - // Ex. "businessEntities/GCP", "businessEntities/Maps" - string business_entity_name = 4; -} - -// Encapsulates a single SKU in Google Cloud Platform -message Sku { - option (google.api.resource) = { - type: "cloudbilling.googleapis.com/Sku" - pattern: "services/{service}/skus/{sku}" - }; - - // The resource name for the SKU. - // Example: "services/DA34-426B-A397/skus/AA95-CD31-42FE" - string name = 1; - - // The identifier for the SKU. - // Example: "AA95-CD31-42FE" - string sku_id = 2; - - // A human readable description of the SKU, has a maximum length of 256 - // characters. - string description = 3; - - // The category hierarchy of this SKU, purely for organizational purpose. - Category category = 4; - - // List of service regions this SKU is offered at. - // Example: "asia-east1" - // Service regions can be found at https://cloud.google.com/about/locations/ - repeated string service_regions = 5; - - // A timeline of pricing info for this SKU in chronological order. - repeated PricingInfo pricing_info = 6; - - // Identifies the service provider. - // This is 'Google' for first party services in Google Cloud Platform. - string service_provider_name = 7; - - // The geographic taxonomy for this sku. - GeoTaxonomy geo_taxonomy = 8; -} - -// Represents the category hierarchy of a SKU. -message Category { - // The display name of the service this SKU belongs to. - string service_display_name = 1; - - // The type of product the SKU refers to. - // Example: "Compute", "Storage", "Network", "ApplicationServices" etc. - string resource_family = 2; - - // A group classification for related SKUs. - // Example: "RAM", "GPU", "Prediction", "Ops", "GoogleEgress" etc. - string resource_group = 3; - - // Represents how the SKU is consumed. - // Example: "OnDemand", "Preemptible", "Commit1Mo", "Commit1Yr" etc. - string usage_type = 4; -} - -// Represents the pricing information for a SKU at a single point of time. -message PricingInfo { - // The timestamp from which this pricing was effective within the requested - // time range. This is guaranteed to be greater than or equal to the - // start_time field in the request and less than the end_time field in the - // request. If a time range was not specified in the request this field will - // be equivalent to a time within the last 12 hours, indicating the latest - // pricing info. - google.protobuf.Timestamp effective_time = 1; - - // An optional human readable summary of the pricing information, has a - // maximum length of 256 characters. - string summary = 2; - - // Expresses the pricing formula. See `PricingExpression` for an example. - PricingExpression pricing_expression = 3; - - // Aggregation Info. This can be left unspecified if the pricing expression - // doesn't require aggregation. - AggregationInfo aggregation_info = 4; - - // Conversion rate used for currency conversion, from USD to the currency - // specified in the request. This includes any surcharge collected for billing - // in non USD currency. If a currency is not specified in the request this - // defaults to 1.0. - // Example: USD * currency_conversion_rate = JPY - double currency_conversion_rate = 5; -} - -// Expresses a mathematical pricing formula. For Example:- -// -// `usage_unit: GBy` -// `tiered_rates:` -// `[start_usage_amount: 20, unit_price: $10]` -// `[start_usage_amount: 100, unit_price: $5]` -// -// The above expresses a pricing formula where the first 20GB is free, the -// next 80GB is priced at $10 per GB followed by $5 per GB for additional -// usage. -message PricingExpression { - // The price rate indicating starting usage and its corresponding price. - message TierRate { - // Usage is priced at this rate only after this amount. - // Example: start_usage_amount of 10 indicates that the usage will be priced - // at the unit_price after the first 10 usage_units. - double start_usage_amount = 1; - - // The price per unit of usage. - // Example: unit_price of amount $10 indicates that each unit will cost $10. - google.type.Money unit_price = 2; - } - - // The short hand for unit of usage this pricing is specified in. - // Example: usage_unit of "GiBy" means that usage is specified in "Gibi Byte". - string usage_unit = 1; - - // The recommended quantity of units for displaying pricing info. When - // displaying pricing info it is recommended to display: - // (unit_price * display_quantity) per display_quantity usage_unit. - // This field does not affect the pricing formula and is for display purposes - // only. - // Example: If the unit_price is "0.0001 USD", the usage_unit is "GB" and - // the display_quantity is "1000" then the recommended way of displaying the - // pricing info is "0.10 USD per 1000 GB" - double display_quantity = 2; - - // The list of tiered rates for this pricing. The total cost is computed by - // applying each of the tiered rates on usage. This repeated list is sorted - // by ascending order of start_usage_amount. - repeated TierRate tiered_rates = 3; - - // The unit of usage in human readable form. - // Example: "gibi byte". - string usage_unit_description = 4; - - // The base unit for the SKU which is the unit used in usage exports. - // Example: "By" - string base_unit = 5; - - // The base unit in human readable form. - // Example: "byte". - string base_unit_description = 6; - - // Conversion factor for converting from price per usage_unit to price per - // base_unit, and start_usage_amount to start_usage_amount in base_unit. - // unit_price / base_unit_conversion_factor = price per base_unit. - // start_usage_amount * base_unit_conversion_factor = start_usage_amount in - // base_unit. - double base_unit_conversion_factor = 7; -} - -// Represents the aggregation level and interval for pricing of a single SKU. -message AggregationInfo { - // The level at which usage is aggregated to compute cost. - // Example: "ACCOUNT" aggregation level indicates that usage for tiered - // pricing is aggregated across all projects in a single account. - enum AggregationLevel { - AGGREGATION_LEVEL_UNSPECIFIED = 0; - - ACCOUNT = 1; - - PROJECT = 2; - } - - // The interval at which usage is aggregated to compute cost. - // Example: "MONTHLY" aggregation interval indicates that usage for tiered - // pricing is aggregated every month. - enum AggregationInterval { - AGGREGATION_INTERVAL_UNSPECIFIED = 0; - - DAILY = 1; - - MONTHLY = 2; - } - - AggregationLevel aggregation_level = 1; - - AggregationInterval aggregation_interval = 2; - - // The number of intervals to aggregate over. - // Example: If aggregation_level is "DAILY" and aggregation_count is 14, - // aggregation will be over 14 days. - int32 aggregation_count = 3; -} - -// Encapsulates the geographic taxonomy data for a sku. -message GeoTaxonomy { - // The type of Geo Taxonomy: GLOBAL, REGIONAL, or MULTI_REGIONAL. - enum Type { - // The type is not specified. - TYPE_UNSPECIFIED = 0; - - // The sku is global in nature, e.g. a license sku. Global skus are - // available in all regions, and so have an empty region list. - GLOBAL = 1; - - // The sku is available in a specific region, e.g. "us-west2". - REGIONAL = 2; - - // The sku is associated with multiple regions, e.g. "us-west2" and - // "us-east1". - MULTI_REGIONAL = 3; - } - - // The type of Geo Taxonomy: GLOBAL, REGIONAL, or MULTI_REGIONAL. - Type type = 1; - - // The list of regions associated with a sku. Empty for Global skus, which are - // associated with all Google Cloud regions. - repeated string regions = 2; -} - -// Request message for `ListServices`. -message ListServicesRequest { - // Requested page size. Defaults to 5000. - int32 page_size = 1; - - // A token identifying a page of results to return. This should be a - // `next_page_token` value returned from a previous `ListServices` - // call. If unspecified, the first page of results is returned. - string page_token = 2; -} - -// Response message for `ListServices`. -message ListServicesResponse { - // A list of services. - repeated Service services = 1; - - // A token to retrieve the next page of results. To retrieve the next page, - // call `ListServices` again with the `page_token` field set to this - // value. This field is empty if there are no more results to retrieve. - string next_page_token = 2; -} - -// Request message for `ListSkus`. -message ListSkusRequest { - // Required. The name of the service. - // Example: "services/DA34-426B-A397" - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudbilling.googleapis.com/Service" - } - ]; - - // Optional inclusive start time of the time range for which the pricing - // versions will be returned. Timestamps in the future are not allowed. - // The time range has to be within a single calendar month in - // America/Los_Angeles timezone. Time range as a whole is optional. If not - // specified, the latest pricing will be returned (up to 12 hours old at - // most). - google.protobuf.Timestamp start_time = 2; - - // Optional exclusive end time of the time range for which the pricing - // versions will be returned. Timestamps in the future are not allowed. - // The time range has to be within a single calendar month in - // America/Los_Angeles timezone. Time range as a whole is optional. If not - // specified, the latest pricing will be returned (up to 12 hours old at - // most). - google.protobuf.Timestamp end_time = 3; - - // The ISO 4217 currency code for the pricing info in the response proto. - // Will use the conversion rate as of start_time. - // Optional. If not specified USD will be used. - string currency_code = 4; - - // Requested page size. Defaults to 5000. - int32 page_size = 5; - - // A token identifying a page of results to return. This should be a - // `next_page_token` value returned from a previous `ListSkus` - // call. If unspecified, the first page of results is returned. - string page_token = 6; -} - -// Response message for `ListSkus`. -message ListSkusResponse { - // The list of public SKUs of the given service. - repeated Sku skus = 1; - - // A token to retrieve the next page of results. To retrieve the next page, - // call `ListSkus` again with the `page_token` field set to this - // value. This field is empty if there are no more results to retrieve. - string next_page_token = 2; -} diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js deleted file mode 100644 index 06e6462d716..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(billingAccount) { - // [START cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The billing account resource to create. - * Currently CreateBillingAccount only supports subaccount creation, so - * any created billing accounts must be under a provided parent billing - * account. - */ - // const billingAccount = {} - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callCreateBillingAccount() { - // Construct request - const request = { - billingAccount, - }; - - // Run request - const response = await billingClient.createBillingAccount(request); - console.log(response); - } - - callCreateBillingAccount(); - // [END cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js deleted file mode 100644 index 8d420a0e1a5..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the billing account to retrieve. For example, - * `billingAccounts/012345-567890-ABCDEF`. - */ - // const name = 'abc123' - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callGetBillingAccount() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await billingClient.getBillingAccount(request); - console.log(response); - } - - callGetBillingAccount(); - // [END cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js deleted file mode 100644 index df9f6c0a259..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 cloudbilling_v1_generated_CloudBilling_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. - */ - /** - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await billingClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END cloudbilling_v1_generated_CloudBilling_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-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js deleted file mode 100644 index 1b9bd0c1604..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_project_billing_info.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the project for which billing information is - * retrieved. For example, `projects/tokyo-rain-123`. - */ - // const name = 'abc123' - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callGetProjectBillingInfo() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await billingClient.getProjectBillingInfo(request); - console.log(response); - } - - callGetProjectBillingInfo(); - // [END cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js deleted file mode 100644 index 916633c0352..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 page size. The maximum page size is 100; this is also the - * default. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListBillingAccounts` - * call. If unspecified, the first page of results is returned. - */ - // const pageToken = 'abc123' - /** - * Options for how to filter the returned billing accounts. - * Currently this only supports filtering for - * subaccounts (https://cloud.google.com/billing/docs/concepts) under a - * single provided reseller billing account. - * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). - * Boolean algebra and other fields are not currently supported. - */ - // const filter = 'abc123' - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callListBillingAccounts() { - // Construct request - const request = { - }; - - // Run request - const iterable = await billingClient.listBillingAccountsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListBillingAccounts(); - // [END cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js deleted file mode 100644 index 3ab054e3f1d..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the billing account associated with the projects that - * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. - */ - // const name = 'abc123' - /** - * Requested page size. The maximum page size is 100; this is also the - * default. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to be returned. This should be a - * `next_page_token` value returned from a previous `ListProjectBillingInfo` - * call. If unspecified, the first page of results is returned. - */ - // const pageToken = 'abc123' - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callListProjectBillingInfo() { - // Construct request - const request = { - name, - }; - - // Run request - const iterable = await billingClient.listProjectBillingInfoAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProjectBillingInfo(); - // [END cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js deleted file mode 100644 index 41fa9a179ef..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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, policy) { - // [START cloudbilling_v1_generated_CloudBilling_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. - */ - /** - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * 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 a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await billingClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END cloudbilling_v1_generated_CloudBilling_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-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js deleted file mode 100644 index b1ffbd536e5..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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, permissions) { - // [START cloudbilling_v1_generated_CloudBilling_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. - */ - /** - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = 'abc123' - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await billingClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END cloudbilling_v1_generated_CloudBilling_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-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js deleted file mode 100644 index c487c7c3d5c..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, account) { - // [START cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the billing account resource to be updated. - */ - // const name = 'abc123' - /** - * Required. The billing account resource to replace the resource on the server. - */ - // const account = {} - /** - * The update mask applied to the resource. - * Only "display_name" is currently supported. - */ - // const updateMask = {} - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callUpdateBillingAccount() { - // Construct request - const request = { - name, - account, - }; - - // Run request - const response = await billingClient.updateBillingAccount(request); - console.log(response); - } - - callUpdateBillingAccount(); - // [END cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js deleted file mode 100644 index 0168c7c8daa..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the project associated with the billing information - * that you want to update. For example, `projects/tokyo-rain-123`. - */ - // const name = 'abc123' - /** - * The new billing information for the project. Read-only fields are ignored; - * thus, you can leave empty all fields except `billing_account_name`. - */ - // const projectBillingInfo = {} - - // Imports the Billing library - const {CloudBillingClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudBillingClient(); - - async function callUpdateProjectBillingInfo() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await billingClient.updateProjectBillingInfo(request); - console.log(response); - } - - callUpdateProjectBillingInfo(); - // [END cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js deleted file mode 100644 index c21a6be3aeb..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 cloudbilling_v1_generated_CloudCatalog_ListServices_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It 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 page size. Defaults to 5000. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListServices` - * call. If unspecified, the first page of results is returned. - */ - // const pageToken = 'abc123' - - // Imports the Billing library - const {CloudCatalogClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudCatalogClient(); - - async function callListServices() { - // Construct request - const request = { - }; - - // Run request - const iterable = await billingClient.listServicesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListServices(); - // [END cloudbilling_v1_generated_CloudCatalog_ListServices_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js deleted file mode 100644 index 71decc1085d..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START cloudbilling_v1_generated_CloudCatalog_ListSkus_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the service. - * Example: "services/DA34-426B-A397" - */ - // const parent = 'abc123' - /** - * Optional inclusive start time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - */ - // const startTime = {} - /** - * Optional exclusive end time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - */ - // const endTime = {} - /** - * The ISO 4217 currency code for the pricing info in the response proto. - * Will use the conversion rate as of start_time. - * Optional. If not specified USD will be used. - */ - // const currencyCode = 'abc123' - /** - * Requested page size. Defaults to 5000. - */ - // const pageSize = 1234 - /** - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListSkus` - * call. If unspecified, the first page of results is returned. - */ - // const pageToken = 'abc123' - - // Imports the Billing library - const {CloudCatalogClient} = require('@google-cloud/billing').v1; - - // Instantiates a client - const billingClient = new CloudCatalogClient(); - - async function callListSkus() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await billingClient.listSkusAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListSkus(); - // [END cloudbilling_v1_generated_CloudCatalog_ListSkus_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json deleted file mode 100644 index e446c6b0814..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json +++ /dev/null @@ -1,563 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-billing", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.billing.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async", - "title": "CloudBilling getBillingAccount Sample", - "origin": "API_DEFINITION", - "description": " Gets information about a billing account. The current authenticated user must be a [viewer of the billing account](https://cloud.google.com/billing/docs/how-to/billing-access).", - "canonical": true, - "file": "cloud_billing.get_billing_account.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetBillingAccount", - "fullName": "google.cloud.billing.v1.CloudBilling.GetBillingAccount", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.billing.v1.BillingAccount", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "GetBillingAccount", - "fullName": "google.cloud.billing.v1.CloudBilling.GetBillingAccount", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async", - "title": "CloudBilling listBillingAccounts Sample", - "origin": "API_DEFINITION", - "description": " Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).", - "canonical": true, - "file": "cloud_billing.list_billing_accounts.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListBillingAccounts", - "fullName": "google.cloud.billing.v1.CloudBilling.ListBillingAccounts", - "async": true, - "parameters": [ - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.billing.v1.ListBillingAccountsResponse", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "ListBillingAccounts", - "fullName": "google.cloud.billing.v1.CloudBilling.ListBillingAccounts", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async", - "title": "CloudBilling updateBillingAccount Sample", - "origin": "API_DEFINITION", - "description": " Updates a billing account's fields. Currently the only field that can be edited is `display_name`. The current authenticated user must have the `billing.accounts.update` IAM permission, which is typically given to the [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing account.", - "canonical": true, - "file": "cloud_billing.update_billing_account.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateBillingAccount", - "fullName": "google.cloud.billing.v1.CloudBilling.UpdateBillingAccount", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "account", - "type": ".google.cloud.billing.v1.BillingAccount" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.billing.v1.BillingAccount", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "UpdateBillingAccount", - "fullName": "google.cloud.billing.v1.CloudBilling.UpdateBillingAccount", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async", - "title": "CloudBilling createBillingAccount Sample", - "origin": "API_DEFINITION", - "description": " This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned as a reseller account.", - "canonical": true, - "file": "cloud_billing.create_billing_account.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateBillingAccount", - "fullName": "google.cloud.billing.v1.CloudBilling.CreateBillingAccount", - "async": true, - "parameters": [ - { - "name": "billing_account", - "type": ".google.cloud.billing.v1.BillingAccount" - } - ], - "resultType": ".google.cloud.billing.v1.BillingAccount", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "CreateBillingAccount", - "fullName": "google.cloud.billing.v1.CloudBilling.CreateBillingAccount", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async", - "title": "CloudBilling listProjectBillingInfo Sample", - "origin": "API_DEFINITION", - "description": " Lists the projects associated with a billing account. The current authenticated user must have the `billing.resourceAssociations.list` IAM permission, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).", - "canonical": true, - "file": "cloud_billing.list_project_billing_info.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProjectBillingInfo", - "fullName": "google.cloud.billing.v1.CloudBilling.ListProjectBillingInfo", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.billing.v1.ListProjectBillingInfoResponse", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "ListProjectBillingInfo", - "fullName": "google.cloud.billing.v1.CloudBilling.ListProjectBillingInfo", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async", - "title": "CloudBilling getProjectBillingInfo Sample", - "origin": "API_DEFINITION", - "description": " Gets the billing information for a project. The current authenticated user must have the `resourcemanager.projects.get` permission for the project, which can be granted by assigning the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) role.", - "canonical": true, - "file": "cloud_billing.get_project_billing_info.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProjectBillingInfo", - "fullName": "google.cloud.billing.v1.CloudBilling.GetProjectBillingInfo", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.billing.v1.ProjectBillingInfo", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "GetProjectBillingInfo", - "fullName": "google.cloud.billing.v1.CloudBilling.GetProjectBillingInfo", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async", - "title": "CloudBilling updateProjectBillingInfo Sample", - "origin": "API_DEFINITION", - "description": " Sets or updates the billing account associated with a project. You specify the new billing account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the resource name of a billing account. Associating a project with an open billing account enables billing on the project and allows charges for resource usage. If the project already had a billing account, this method changes the billing account used for resource usage charges. *Note:* Incurred charges that have not yet been reported in the transaction history of the Google Cloud Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project. The current authenticated user must have ownership privileges for both the [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](https://cloud.google.com/billing/docs/how-to/billing-access). You can disable billing on the project by setting the `billing_account_name` field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project. Note that associating a project with a *closed* billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an *open* billing account.", - "canonical": true, - "file": "cloud_billing.update_project_billing_info.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProjectBillingInfo", - "fullName": "google.cloud.billing.v1.CloudBilling.UpdateProjectBillingInfo", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "project_billing_info", - "type": ".google.cloud.billing.v1.ProjectBillingInfo" - } - ], - "resultType": ".google.cloud.billing.v1.ProjectBillingInfo", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "UpdateProjectBillingInfo", - "fullName": "google.cloud.billing.v1.CloudBilling.UpdateProjectBillingInfo", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_GetIamPolicy_async", - "title": "CloudBilling getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets the access control policy for a billing account. The caller must have the `billing.accounts.getIamPolicy` permission on the account, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).", - "canonical": true, - "file": "cloud_billing.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.billing.v1.CloudBilling.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.billing.v1.CloudBilling.GetIamPolicy", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_SetIamPolicy_async", - "title": "CloudBilling setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the access control policy for a billing account. Replaces any existing policy. The caller must have the `billing.accounts.setIamPolicy` permission on the account, which is often given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).", - "canonical": true, - "file": "cloud_billing.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.billing.v1.CloudBilling.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.billing.v1.CloudBilling.SetIamPolicy", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudBilling_TestIamPermissions_async", - "title": "CloudBilling testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Tests the access control policy for a billing account. This method takes the resource and a set of permissions as input and returns the subset of the input permissions that the caller is allowed for that resource.", - "canonical": true, - "file": "cloud_billing.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.billing.v1.CloudBilling.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "CloudBillingClient", - "fullName": "google.cloud.billing.v1.CloudBillingClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.billing.v1.CloudBilling.TestIamPermissions", - "service": { - "shortName": "CloudBilling", - "fullName": "google.cloud.billing.v1.CloudBilling" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudCatalog_ListServices_async", - "title": "CloudBilling listServices Sample", - "origin": "API_DEFINITION", - "description": " Lists all public cloud services.", - "canonical": true, - "file": "cloud_catalog.list_services.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListServices", - "fullName": "google.cloud.billing.v1.CloudCatalog.ListServices", - "async": true, - "parameters": [ - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.billing.v1.ListServicesResponse", - "client": { - "shortName": "CloudCatalogClient", - "fullName": "google.cloud.billing.v1.CloudCatalogClient" - }, - "method": { - "shortName": "ListServices", - "fullName": "google.cloud.billing.v1.CloudCatalog.ListServices", - "service": { - "shortName": "CloudCatalog", - "fullName": "google.cloud.billing.v1.CloudCatalog" - } - } - } - }, - { - "regionTag": "cloudbilling_v1_generated_CloudCatalog_ListSkus_async", - "title": "CloudBilling listSkus Sample", - "origin": "API_DEFINITION", - "description": " Lists all publicly available SKUs for a given cloud service.", - "canonical": true, - "file": "cloud_catalog.list_skus.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 90, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListSkus", - "fullName": "google.cloud.billing.v1.CloudCatalog.ListSkus", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "start_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "end_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "currency_code", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.billing.v1.ListSkusResponse", - "client": { - "shortName": "CloudCatalogClient", - "fullName": "google.cloud.billing.v1.CloudCatalogClient" - }, - "method": { - "shortName": "ListSkus", - "fullName": "google.cloud.billing.v1.CloudCatalog.ListSkus", - "service": { - "shortName": "CloudCatalog", - "fullName": "google.cloud.billing.v1.CloudCatalog" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/index.ts b/owl-bot-staging/google-cloud-billing/v1/src/index.ts deleted file mode 100644 index 6cac30c8973..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 CloudBillingClient = v1.CloudBillingClient; -type CloudBillingClient = v1.CloudBillingClient; -const CloudCatalogClient = v1.CloudCatalogClient; -type CloudCatalogClient = v1.CloudCatalogClient; -export {v1, CloudBillingClient, CloudCatalogClient}; -export default {v1, CloudBillingClient, CloudCatalogClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts deleted file mode 100644 index 540b19e2b1b..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts +++ /dev/null @@ -1,1457 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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/cloud_billing_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './cloud_billing_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Retrieves the Google Cloud Console billing accounts and associates them with - * projects. - * @class - * @memberof v1 - */ -export class CloudBillingClient { - 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}; - pathTemplates: {[name: string]: gax.PathTemplate}; - cloudBillingStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CloudBillingClient. - * - * @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 CloudBillingClient({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 CloudBillingClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== 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 useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - billingAccountPathTemplate: new this._gaxModule.PathTemplate( - 'billingAccounts/{billing_account}' - ), - servicePathTemplate: new this._gaxModule.PathTemplate( - 'services/{service}' - ), - skuPathTemplate: new this._gaxModule.PathTemplate( - 'services/{service}/skus/{sku}' - ), - }; - - // 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 = { - listBillingAccounts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'billingAccounts'), - listProjectBillingInfo: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'projectBillingInfo') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.billing.v1.CloudBilling', 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.cloudBillingStub) { - return this.cloudBillingStub; - } - - // Put together the "service stub" for - // google.cloud.billing.v1.CloudBilling. - this.cloudBillingStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.billing.v1.CloudBilling') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.billing.v1.CloudBilling, - 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 cloudBillingStubMethods = - ['getBillingAccount', 'listBillingAccounts', 'updateBillingAccount', 'createBillingAccount', 'listProjectBillingInfo', 'getProjectBillingInfo', 'updateProjectBillingInfo', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of cloudBillingStubMethods) { - const callPromise = this.cloudBillingStub.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.cloudBillingStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudbilling.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 'cloudbilling.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/cloud-billing', - 'https://www.googleapis.com/auth/cloud-billing.readonly', - 'https://www.googleapis.com/auth/cloud-platform' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets information about a billing account. The current authenticated user - * must be a [viewer of the billing - * account](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the billing account to retrieve. For example, - * `billingAccounts/012345-567890-ABCDEF`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. - * 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/cloud_billing.get_billing_account.js - * region_tag:cloudbilling_v1_generated_CloudBilling_GetBillingAccount_async - */ - getBillingAccount( - request?: protos.google.cloud.billing.v1.IGetBillingAccountRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IGetBillingAccountRequest|undefined, {}|undefined - ]>; - getBillingAccount( - request: protos.google.cloud.billing.v1.IGetBillingAccountRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, - {}|null|undefined>): void; - getBillingAccount( - request: protos.google.cloud.billing.v1.IGetBillingAccountRequest, - callback: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, - {}|null|undefined>): void; - getBillingAccount( - request?: protos.google.cloud.billing.v1.IGetBillingAccountRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IGetBillingAccountRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IGetBillingAccountRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getBillingAccount(request, options, callback); - } -/** - * Updates a billing account's fields. - * Currently the only field that can be edited is `display_name`. - * The current authenticated user must have the `billing.accounts.update` - * IAM permission, which is typically given to the - * [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) - * of the billing account. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the billing account resource to be updated. - * @param {google.cloud.billing.v1.BillingAccount} request.account - * Required. The billing account resource to replace the resource on the server. - * @param {google.protobuf.FieldMask} request.updateMask - * The update mask applied to the resource. - * Only "display_name" is currently supported. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. - * 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/cloud_billing.update_billing_account.js - * region_tag:cloudbilling_v1_generated_CloudBilling_UpdateBillingAccount_async - */ - updateBillingAccount( - request?: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|undefined, {}|undefined - ]>; - updateBillingAccount( - request: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, - {}|null|undefined>): void; - updateBillingAccount( - request: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, - callback: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, - {}|null|undefined>): void; - updateBillingAccount( - request?: protos.google.cloud.billing.v1.IUpdateBillingAccountRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.IUpdateBillingAccountRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateBillingAccount(request, options, callback); - } -/** - * This method creates [billing - * subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). - * - * Google Cloud resellers should use the - * Channel Services APIs, - * [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) - * and - * [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). - * - * When creating a subaccount, the current authenticated user must have the - * `billing.accounts.update` IAM permission on the parent account, which is - * typically given to billing account - * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). - * This method will return an error if the parent account has not been - * provisioned as a reseller account. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.billing.v1.BillingAccount} request.billingAccount - * Required. The billing account resource to create. - * Currently CreateBillingAccount only supports subaccount creation, so - * any created billing accounts must be under a provided parent billing - * account. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. - * 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/cloud_billing.create_billing_account.js - * region_tag:cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async - */ - createBillingAccount( - request?: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.ICreateBillingAccountRequest|undefined, {}|undefined - ]>; - createBillingAccount( - request: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, - {}|null|undefined>): void; - createBillingAccount( - request: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, - callback: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, - {}|null|undefined>): void; - createBillingAccount( - request?: protos.google.cloud.billing.v1.ICreateBillingAccountRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.ICreateBillingAccountRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount, - protos.google.cloud.billing.v1.ICreateBillingAccountRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof 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.createBillingAccount(request, options, callback); - } -/** - * Gets the billing information for a project. The current authenticated user - * must have the `resourcemanager.projects.get` permission for the project, - * which can be granted by assigning the [Project - * Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) - * role. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the project for which billing information is - * retrieved. For example, `projects/tokyo-rain-123`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. - * 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/cloud_billing.get_project_billing_info.js - * region_tag:cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async - */ - getProjectBillingInfo( - request?: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|undefined, {}|undefined - ]>; - getProjectBillingInfo( - request: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, - {}|null|undefined>): void; - getProjectBillingInfo( - request: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, - callback: Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, - {}|null|undefined>): void; - getProjectBillingInfo( - request?: protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IGetProjectBillingInfoRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getProjectBillingInfo(request, options, callback); - } -/** - * Sets or updates the billing account associated with a project. You specify - * the new billing account by setting the `billing_account_name` in the - * `ProjectBillingInfo` resource to the resource name of a billing account. - * Associating a project with an open billing account enables billing on the - * project and allows charges for resource usage. If the project already had a - * billing account, this method changes the billing account used for resource - * usage charges. - * - * *Note:* Incurred charges that have not yet been reported in the transaction - * history of the Google Cloud Console might be billed to the new billing - * account, even if the charge occurred before the new billing account was - * assigned to the project. - * - * The current authenticated user must have ownership privileges for both the - * [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo - * ) and the [billing - * account](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * You can disable billing on the project by setting the - * `billing_account_name` field to empty. This action disassociates the - * current billing account from the project. Any billable activity of your - * in-use services will stop, and your application could stop functioning as - * expected. Any unbilled charges to date will be billed to the previously - * associated account. The current authenticated user must be either an owner - * of the project or an owner of the billing account for the project. - * - * Note that associating a project with a *closed* billing account will have - * much the same effect as disabling billing on the project: any paid - * resources used by the project will be shut down. Thus, unless you wish to - * disable billing, you should always call this method with the name of an - * *open* billing account. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the project associated with the billing information - * that you want to update. For example, `projects/tokyo-rain-123`. - * @param {google.cloud.billing.v1.ProjectBillingInfo} request.projectBillingInfo - * The new billing information for the project. Read-only fields are ignored; - * thus, you can leave empty all fields except `billing_account_name`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. - * 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/cloud_billing.update_project_billing_info.js - * region_tag:cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async - */ - updateProjectBillingInfo( - request?: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|undefined, {}|undefined - ]>; - updateProjectBillingInfo( - request: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, - {}|null|undefined>): void; - updateProjectBillingInfo( - request: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, - callback: Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, - {}|null|undefined>): void; - updateProjectBillingInfo( - request?: protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.billing.v1.IProjectBillingInfo, - protos.google.cloud.billing.v1.IUpdateProjectBillingInfoRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateProjectBillingInfo(request, options, callback); - } -/** - * Gets the access control policy for a billing account. - * The caller must have the `billing.accounts.getIamPolicy` permission on the - * account, which is often given to billing account - * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.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/cloud_billing.get_iam_policy.js - * region_tag:cloudbilling_v1_generated_CloudBilling_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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); - } -/** - * Sets the access control policy for a billing account. Replaces any existing - * policy. - * The caller must have the `billing.accounts.setIamPolicy` permission on the - * account, which is often given to billing account - * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * 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 a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.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/cloud_billing.set_iam_policy.js - * region_tag:cloudbilling_v1_generated_CloudBilling_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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); - } -/** - * Tests the access control policy for a billing account. This method takes - * the resource and a set of permissions as input and returns the subset of - * the input permissions that the caller is allowed for that resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * 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/cloud_billing.test_iam_permissions.js - * region_tag:cloudbilling_v1_generated_CloudBilling_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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 the billing accounts that the current authenticated user has - * permission to - * [view](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * @param {Object} request - * The request object that will be sent. - * @param {number} request.pageSize - * Requested page size. The maximum page size is 100; this is also the - * default. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListBillingAccounts` - * call. If unspecified, the first page of results is returned. - * @param {string} request.filter - * Options for how to filter the returned billing accounts. - * Currently this only supports filtering for - * [subaccounts](https://cloud.google.com/billing/docs/concepts) under a - * single provided reseller billing account. - * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). - * Boolean algebra and other fields are not currently supported. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. - * 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 `listBillingAccountsAsync()` - * 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. - */ - listBillingAccounts( - request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount[], - protos.google.cloud.billing.v1.IListBillingAccountsRequest|null, - protos.google.cloud.billing.v1.IListBillingAccountsResponse - ]>; - listBillingAccounts( - request: protos.google.cloud.billing.v1.IListBillingAccountsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListBillingAccountsRequest, - protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, - protos.google.cloud.billing.v1.IBillingAccount>): void; - listBillingAccounts( - request: protos.google.cloud.billing.v1.IListBillingAccountsRequest, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListBillingAccountsRequest, - protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, - protos.google.cloud.billing.v1.IBillingAccount>): void; - listBillingAccounts( - request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.billing.v1.IListBillingAccountsRequest, - protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, - protos.google.cloud.billing.v1.IBillingAccount>, - callback?: PaginationCallback< - protos.google.cloud.billing.v1.IListBillingAccountsRequest, - protos.google.cloud.billing.v1.IListBillingAccountsResponse|null|undefined, - protos.google.cloud.billing.v1.IBillingAccount>): - Promise<[ - protos.google.cloud.billing.v1.IBillingAccount[], - protos.google.cloud.billing.v1.IListBillingAccountsRequest|null, - protos.google.cloud.billing.v1.IListBillingAccountsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof 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.listBillingAccounts(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 {number} request.pageSize - * Requested page size. The maximum page size is 100; this is also the - * default. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListBillingAccounts` - * call. If unspecified, the first page of results is returned. - * @param {string} request.filter - * Options for how to filter the returned billing accounts. - * Currently this only supports filtering for - * [subaccounts](https://cloud.google.com/billing/docs/concepts) under a - * single provided reseller billing account. - * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). - * Boolean algebra and other fields are not currently supported. - * @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 [BillingAccount]{@link google.cloud.billing.v1.BillingAccount} 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 `listBillingAccountsAsync()` - * 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. - */ - listBillingAccountsStream( - request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listBillingAccounts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listBillingAccounts.createStream( - this.innerApiCalls.listBillingAccounts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listBillingAccounts`, 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 {number} request.pageSize - * Requested page size. The maximum page size is 100; this is also the - * default. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListBillingAccounts` - * call. If unspecified, the first page of results is returned. - * @param {string} request.filter - * Options for how to filter the returned billing accounts. - * Currently this only supports filtering for - * [subaccounts](https://cloud.google.com/billing/docs/concepts) under a - * single provided reseller billing account. - * (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). - * Boolean algebra and other fields are not currently supported. - * @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 - * [BillingAccount]{@link google.cloud.billing.v1.BillingAccount}. 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/cloud_billing.list_billing_accounts.js - * region_tag:cloudbilling_v1_generated_CloudBilling_ListBillingAccounts_async - */ - listBillingAccountsAsync( - request?: protos.google.cloud.billing.v1.IListBillingAccountsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listBillingAccounts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listBillingAccounts.asyncIterate( - this.innerApiCalls['listBillingAccounts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the projects associated with a billing account. The current - * authenticated user must have the `billing.resourceAssociations.list` IAM - * permission, which is often given to billing account - * [viewers](https://cloud.google.com/billing/docs/how-to/billing-access). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the billing account associated with the projects that - * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. - * @param {number} request.pageSize - * Requested page size. The maximum page size is 100; this is also the - * default. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This should be a - * `next_page_token` value returned from a previous `ListProjectBillingInfo` - * call. If unspecified, the first page of results is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. - * 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 `listProjectBillingInfoAsync()` - * 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. - */ - listProjectBillingInfo( - request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IProjectBillingInfo[], - protos.google.cloud.billing.v1.IListProjectBillingInfoRequest|null, - protos.google.cloud.billing.v1.IListProjectBillingInfoResponse - ]>; - listProjectBillingInfo( - request: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, - protos.google.cloud.billing.v1.IProjectBillingInfo>): void; - listProjectBillingInfo( - request: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, - protos.google.cloud.billing.v1.IProjectBillingInfo>): void; - listProjectBillingInfo( - request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, - protos.google.cloud.billing.v1.IProjectBillingInfo>, - callback?: PaginationCallback< - protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - protos.google.cloud.billing.v1.IListProjectBillingInfoResponse|null|undefined, - protos.google.cloud.billing.v1.IProjectBillingInfo>): - Promise<[ - protos.google.cloud.billing.v1.IProjectBillingInfo[], - protos.google.cloud.billing.v1.IListProjectBillingInfoRequest|null, - protos.google.cloud.billing.v1.IListProjectBillingInfoResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProjectBillingInfo(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.name - * Required. The resource name of the billing account associated with the projects that - * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. - * @param {number} request.pageSize - * Requested page size. The maximum page size is 100; this is also the - * default. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This should be a - * `next_page_token` value returned from a previous `ListProjectBillingInfo` - * call. If unspecified, the first page of results is returned. - * @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 [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo} 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 `listProjectBillingInfoAsync()` - * 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. - */ - listProjectBillingInfoStream( - request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProjectBillingInfo']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProjectBillingInfo.createStream( - this.innerApiCalls.listProjectBillingInfo as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProjectBillingInfo`, 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.name - * Required. The resource name of the billing account associated with the projects that - * you want to list. For example, `billingAccounts/012345-567890-ABCDEF`. - * @param {number} request.pageSize - * Requested page size. The maximum page size is 100; this is also the - * default. - * @param {string} request.pageToken - * A token identifying a page of results to be returned. This should be a - * `next_page_token` value returned from a previous `ListProjectBillingInfo` - * call. If unspecified, the first page of results is returned. - * @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 - * [ProjectBillingInfo]{@link google.cloud.billing.v1.ProjectBillingInfo}. 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/cloud_billing.list_project_billing_info.js - * region_tag:cloudbilling_v1_generated_CloudBilling_ListProjectBillingInfo_async - */ - listProjectBillingInfoAsync( - request?: protos.google.cloud.billing.v1.IListProjectBillingInfoRequest, - 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({ - 'name': request.name ?? '', - }); - const defaultCallSettings = this._defaults['listProjectBillingInfo']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProjectBillingInfo.asyncIterate( - this.innerApiCalls['listProjectBillingInfo'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified billingAccount resource name string. - * - * @param {string} billing_account - * @returns {string} Resource name string. - */ - billingAccountPath(billingAccount:string) { - return this.pathTemplates.billingAccountPathTemplate.render({ - billing_account: billingAccount, - }); - } - - /** - * Parse the billing_account from BillingAccount resource. - * - * @param {string} billingAccountName - * A fully-qualified path representing BillingAccount resource. - * @returns {string} A string representing the billing_account. - */ - matchBillingAccountFromBillingAccountName(billingAccountName: string) { - return this.pathTemplates.billingAccountPathTemplate.match(billingAccountName).billing_account; - } - - /** - * Return a fully-qualified service resource name string. - * - * @param {string} service - * @returns {string} Resource name string. - */ - servicePath(service:string) { - return this.pathTemplates.servicePathTemplate.render({ - service: service, - }); - } - - /** - * Parse the service from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).service; - } - - /** - * Return a fully-qualified sku resource name string. - * - * @param {string} service - * @param {string} sku - * @returns {string} Resource name string. - */ - skuPath(service:string,sku:string) { - return this.pathTemplates.skuPathTemplate.render({ - service: service, - sku: sku, - }); - } - - /** - * Parse the service from Sku resource. - * - * @param {string} skuName - * A fully-qualified path representing Sku resource. - * @returns {string} A string representing the service. - */ - matchServiceFromSkuName(skuName: string) { - return this.pathTemplates.skuPathTemplate.match(skuName).service; - } - - /** - * Parse the sku from Sku resource. - * - * @param {string} skuName - * A fully-qualified path representing Sku resource. - * @returns {string} A string representing the sku. - */ - matchSkuFromSkuName(skuName: string) { - return this.pathTemplates.skuPathTemplate.match(skuName).sku; - } - - /** - * 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.cloudBillingStub && !this._terminated) { - return this.cloudBillingStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json deleted file mode 100644 index e98db6a6e4b..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client_config.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "interfaces": { - "google.cloud.billing.v1.CloudBilling": { - "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": { - "GetBillingAccount": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListBillingAccounts": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateBillingAccount": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateBillingAccount": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProjectBillingInfo": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetProjectBillingInfo": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateProjectBillingInfo": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json deleted file mode 100644 index e34eb066aa5..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_proto_list.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "../../protos/google/cloud/billing/v1/cloud_billing.proto", - "../../protos/google/cloud/billing/v1/cloud_catalog.proto" -] diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts deleted file mode 100644 index eacdffc3461..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts +++ /dev/null @@ -1,791 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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/cloud_catalog_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './cloud_catalog_client_config.json'; -const version = require('../../../package.json').version; - -/** - * A catalog of Google Cloud Platform services and SKUs. - * Provides pricing information and metadata on Google Cloud Platform services - * and SKUs. - * @class - * @memberof v1 - */ -export class CloudCatalogClient { - 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}; - pathTemplates: {[name: string]: gax.PathTemplate}; - cloudCatalogStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of CloudCatalogClient. - * - * @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 CloudCatalogClient({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 CloudCatalogClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== 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 useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - servicePathTemplate: new this._gaxModule.PathTemplate( - 'services/{service}' - ), - skuPathTemplate: new this._gaxModule.PathTemplate( - 'services/{service}/skus/{sku}' - ), - }; - - // 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 = { - listServices: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services'), - listSkus: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'skus') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.billing.v1.CloudCatalog', 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.cloudCatalogStub) { - return this.cloudCatalogStub; - } - - // Put together the "service stub" for - // google.cloud.billing.v1.CloudCatalog. - this.cloudCatalogStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.billing.v1.CloudCatalog') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.billing.v1.CloudCatalog, - 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 cloudCatalogStubMethods = - ['listServices', 'listSkus']; - for (const methodName of cloudCatalogStubMethods) { - const callPromise = this.cloudCatalogStub.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.cloudCatalogStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudbilling.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 'cloudbilling.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/cloud-billing', - 'https://www.googleapis.com/auth/cloud-billing.readonly', - '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 -- - // ------------------- - - /** - * Lists all public cloud services. - * - * @param {Object} request - * The request object that will be sent. - * @param {number} request.pageSize - * Requested page size. Defaults to 5000. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListServices` - * call. If unspecified, the first page of results is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Service]{@link google.cloud.billing.v1.Service}. - * 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 `listServicesAsync()` - * 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. - */ - listServices( - request?: protos.google.cloud.billing.v1.IListServicesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.IService[], - protos.google.cloud.billing.v1.IListServicesRequest|null, - protos.google.cloud.billing.v1.IListServicesResponse - ]>; - listServices( - request: protos.google.cloud.billing.v1.IListServicesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListServicesRequest, - protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, - protos.google.cloud.billing.v1.IService>): void; - listServices( - request: protos.google.cloud.billing.v1.IListServicesRequest, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListServicesRequest, - protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, - protos.google.cloud.billing.v1.IService>): void; - listServices( - request?: protos.google.cloud.billing.v1.IListServicesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.billing.v1.IListServicesRequest, - protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, - protos.google.cloud.billing.v1.IService>, - callback?: PaginationCallback< - protos.google.cloud.billing.v1.IListServicesRequest, - protos.google.cloud.billing.v1.IListServicesResponse|null|undefined, - protos.google.cloud.billing.v1.IService>): - Promise<[ - protos.google.cloud.billing.v1.IService[], - protos.google.cloud.billing.v1.IListServicesRequest|null, - protos.google.cloud.billing.v1.IListServicesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof 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.listServices(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 {number} request.pageSize - * Requested page size. Defaults to 5000. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListServices` - * call. If unspecified, the first page of results is returned. - * @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 [Service]{@link google.cloud.billing.v1.Service} 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 `listServicesAsync()` - * 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. - */ - listServicesStream( - request?: protos.google.cloud.billing.v1.IListServicesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listServices']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServices.createStream( - this.innerApiCalls.listServices as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listServices`, 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 {number} request.pageSize - * Requested page size. Defaults to 5000. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListServices` - * call. If unspecified, the first page of results is returned. - * @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 - * [Service]{@link google.cloud.billing.v1.Service}. 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/cloud_catalog.list_services.js - * region_tag:cloudbilling_v1_generated_CloudCatalog_ListServices_async - */ - listServicesAsync( - request?: protos.google.cloud.billing.v1.IListServicesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listServices']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listServices.asyncIterate( - this.innerApiCalls['listServices'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists all publicly available SKUs for a given cloud service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the service. - * Example: "services/DA34-426B-A397" - * @param {google.protobuf.Timestamp} request.startTime - * Optional inclusive start time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - * @param {google.protobuf.Timestamp} request.endTime - * Optional exclusive end time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - * @param {string} request.currencyCode - * The ISO 4217 currency code for the pricing info in the response proto. - * Will use the conversion rate as of start_time. - * Optional. If not specified USD will be used. - * @param {number} request.pageSize - * Requested page size. Defaults to 5000. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListSkus` - * call. If unspecified, the first page of results is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Sku]{@link google.cloud.billing.v1.Sku}. - * 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 `listSkusAsync()` - * 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. - */ - listSkus( - request?: protos.google.cloud.billing.v1.IListSkusRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.billing.v1.ISku[], - protos.google.cloud.billing.v1.IListSkusRequest|null, - protos.google.cloud.billing.v1.IListSkusResponse - ]>; - listSkus( - request: protos.google.cloud.billing.v1.IListSkusRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListSkusRequest, - protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, - protos.google.cloud.billing.v1.ISku>): void; - listSkus( - request: protos.google.cloud.billing.v1.IListSkusRequest, - callback: PaginationCallback< - protos.google.cloud.billing.v1.IListSkusRequest, - protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, - protos.google.cloud.billing.v1.ISku>): void; - listSkus( - request?: protos.google.cloud.billing.v1.IListSkusRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.billing.v1.IListSkusRequest, - protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, - protos.google.cloud.billing.v1.ISku>, - callback?: PaginationCallback< - protos.google.cloud.billing.v1.IListSkusRequest, - protos.google.cloud.billing.v1.IListSkusResponse|null|undefined, - protos.google.cloud.billing.v1.ISku>): - Promise<[ - protos.google.cloud.billing.v1.ISku[], - protos.google.cloud.billing.v1.IListSkusRequest|null, - protos.google.cloud.billing.v1.IListSkusResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listSkus(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the service. - * Example: "services/DA34-426B-A397" - * @param {google.protobuf.Timestamp} request.startTime - * Optional inclusive start time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - * @param {google.protobuf.Timestamp} request.endTime - * Optional exclusive end time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - * @param {string} request.currencyCode - * The ISO 4217 currency code for the pricing info in the response proto. - * Will use the conversion rate as of start_time. - * Optional. If not specified USD will be used. - * @param {number} request.pageSize - * Requested page size. Defaults to 5000. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListSkus` - * call. If unspecified, the first page of results is returned. - * @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 [Sku]{@link google.cloud.billing.v1.Sku} 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 `listSkusAsync()` - * 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. - */ - listSkusStream( - request?: protos.google.cloud.billing.v1.IListSkusRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listSkus']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSkus.createStream( - this.innerApiCalls.listSkus as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listSkus`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the service. - * Example: "services/DA34-426B-A397" - * @param {google.protobuf.Timestamp} request.startTime - * Optional inclusive start time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - * @param {google.protobuf.Timestamp} request.endTime - * Optional exclusive end time of the time range for which the pricing - * versions will be returned. Timestamps in the future are not allowed. - * The time range has to be within a single calendar month in - * America/Los_Angeles timezone. Time range as a whole is optional. If not - * specified, the latest pricing will be returned (up to 12 hours old at - * most). - * @param {string} request.currencyCode - * The ISO 4217 currency code for the pricing info in the response proto. - * Will use the conversion rate as of start_time. - * Optional. If not specified USD will be used. - * @param {number} request.pageSize - * Requested page size. Defaults to 5000. - * @param {string} request.pageToken - * A token identifying a page of results to return. This should be a - * `next_page_token` value returned from a previous `ListSkus` - * call. If unspecified, the first page of results is returned. - * @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 - * [Sku]{@link google.cloud.billing.v1.Sku}. 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/cloud_catalog.list_skus.js - * region_tag:cloudbilling_v1_generated_CloudCatalog_ListSkus_async - */ - listSkusAsync( - request?: protos.google.cloud.billing.v1.IListSkusRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listSkus']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSkus.asyncIterate( - this.innerApiCalls['listSkus'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified service resource name string. - * - * @param {string} service - * @returns {string} Resource name string. - */ - servicePath(service:string) { - return this.pathTemplates.servicePathTemplate.render({ - service: service, - }); - } - - /** - * Parse the service from Service resource. - * - * @param {string} serviceName - * A fully-qualified path representing Service resource. - * @returns {string} A string representing the service. - */ - matchServiceFromServiceName(serviceName: string) { - return this.pathTemplates.servicePathTemplate.match(serviceName).service; - } - - /** - * Return a fully-qualified sku resource name string. - * - * @param {string} service - * @param {string} sku - * @returns {string} Resource name string. - */ - skuPath(service:string,sku:string) { - return this.pathTemplates.skuPathTemplate.render({ - service: service, - sku: sku, - }); - } - - /** - * Parse the service from Sku resource. - * - * @param {string} skuName - * A fully-qualified path representing Sku resource. - * @returns {string} A string representing the service. - */ - matchServiceFromSkuName(skuName: string) { - return this.pathTemplates.skuPathTemplate.match(skuName).service; - } - - /** - * Parse the sku from Sku resource. - * - * @param {string} skuName - * A fully-qualified path representing Sku resource. - * @returns {string} A string representing the sku. - */ - matchSkuFromSkuName(skuName: string) { - return this.pathTemplates.skuPathTemplate.match(skuName).sku; - } - - /** - * 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.cloudCatalogStub && !this._terminated) { - return this.cloudCatalogStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json deleted file mode 100644 index 65eb2dffc09..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client_config.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "interfaces": { - "google.cloud.billing.v1.CloudCatalog": { - "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": { - "ListServices": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListSkus": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json deleted file mode 100644 index e34eb066aa5..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_proto_list.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "../../protos/google/cloud/billing/v1/cloud_billing.proto", - "../../protos/google/cloud/billing/v1/cloud_catalog.proto" -] diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 57395f94def..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,173 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.billing.v1", - "libraryPackage": "@google-cloud/billing", - "services": { - "CloudBilling": { - "clients": { - "grpc": { - "libraryClient": "CloudBillingClient", - "rpcs": { - "GetBillingAccount": { - "methods": [ - "getBillingAccount" - ] - }, - "UpdateBillingAccount": { - "methods": [ - "updateBillingAccount" - ] - }, - "CreateBillingAccount": { - "methods": [ - "createBillingAccount" - ] - }, - "GetProjectBillingInfo": { - "methods": [ - "getProjectBillingInfo" - ] - }, - "UpdateProjectBillingInfo": { - "methods": [ - "updateProjectBillingInfo" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "ListBillingAccounts": { - "methods": [ - "listBillingAccounts", - "listBillingAccountsStream", - "listBillingAccountsAsync" - ] - }, - "ListProjectBillingInfo": { - "methods": [ - "listProjectBillingInfo", - "listProjectBillingInfoStream", - "listProjectBillingInfoAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CloudBillingClient", - "rpcs": { - "GetBillingAccount": { - "methods": [ - "getBillingAccount" - ] - }, - "UpdateBillingAccount": { - "methods": [ - "updateBillingAccount" - ] - }, - "CreateBillingAccount": { - "methods": [ - "createBillingAccount" - ] - }, - "GetProjectBillingInfo": { - "methods": [ - "getProjectBillingInfo" - ] - }, - "UpdateProjectBillingInfo": { - "methods": [ - "updateProjectBillingInfo" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "ListBillingAccounts": { - "methods": [ - "listBillingAccounts", - "listBillingAccountsStream", - "listBillingAccountsAsync" - ] - }, - "ListProjectBillingInfo": { - "methods": [ - "listProjectBillingInfo", - "listProjectBillingInfoStream", - "listProjectBillingInfoAsync" - ] - } - } - } - } - }, - "CloudCatalog": { - "clients": { - "grpc": { - "libraryClient": "CloudCatalogClient", - "rpcs": { - "ListServices": { - "methods": [ - "listServices", - "listServicesStream", - "listServicesAsync" - ] - }, - "ListSkus": { - "methods": [ - "listSkus", - "listSkusStream", - "listSkusAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "CloudCatalogClient", - "rpcs": { - "ListServices": { - "methods": [ - "listServices", - "listServicesStream", - "listServicesAsync" - ] - }, - "ListSkus": { - "methods": [ - "listSkus", - "listSkusStream", - "listSkusAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts deleted file mode 100644 index def6d7cf917..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 {CloudBillingClient} from './cloud_billing_client'; -export {CloudCatalogClient} from './cloud_catalog_client'; diff --git a/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 09c87aa5083..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 billing = require('@google-cloud/billing'); - -function main() { - const cloudBillingClient = new billing.CloudBillingClient(); - const cloudCatalogClient = new billing.CloudCatalogClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 08be974583e..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 {CloudBillingClient, CloudCatalogClient} from '@google-cloud/billing'; - -// check that the client class type name can be used -function doStuffWithCloudBillingClient(client: CloudBillingClient) { - client.close(); -} -function doStuffWithCloudCatalogClient(client: CloudCatalogClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const cloudBillingClient = new CloudBillingClient(); - doStuffWithCloudBillingClient(cloudBillingClient); - // check that the client instance can be created - const cloudCatalogClient = new CloudCatalogClient(); - doStuffWithCloudCatalogClient(cloudCatalogClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-billing/v1/system-test/install.ts b/owl-bot-staging/google-cloud-billing/v1/system-test/install.ts deleted file mode 100644 index 557a57558e1..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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-billing/v1/test/gapic_cloud_billing_v1.ts b/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_billing_v1.ts deleted file mode 100644 index 5b87b5fffec..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_billing_v1.ts +++ /dev/null @@ -1,1549 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as cloudbillingModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .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.CloudBillingClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = cloudbillingModule.v1.CloudBillingClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = cloudbillingModule.v1.CloudBillingClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = cloudbillingModule.v1.CloudBillingClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudbillingModule.v1.CloudBillingClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudBillingStub, undefined); - await client.initialize(); - assert(client.cloudBillingStub); - }); - - it('has close method for the initialized client', done => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.cloudBillingStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudBillingStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('getBillingAccount', () => { - it('invokes getBillingAccount without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.BillingAccount() - ); - client.innerApiCalls.getBillingAccount = stubSimpleCall(expectedResponse); - const [response] = await client.getBillingAccount(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBillingAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBillingAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBillingAccount without error using callback', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.BillingAccount() - ); - client.innerApiCalls.getBillingAccount = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBillingAccount( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBillingAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBillingAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBillingAccount with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getBillingAccount = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getBillingAccount(request), expectedError); - const actualRequest = (client.innerApiCalls.getBillingAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBillingAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBillingAccount with closed client', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getBillingAccount(request), expectedError); - }); - }); - - describe('updateBillingAccount', () => { - it('invokes updateBillingAccount without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.BillingAccount() - ); - client.innerApiCalls.updateBillingAccount = stubSimpleCall(expectedResponse); - const [response] = await client.updateBillingAccount(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateBillingAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBillingAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBillingAccount without error using callback', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.BillingAccount() - ); - client.innerApiCalls.updateBillingAccount = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateBillingAccount( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateBillingAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBillingAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBillingAccount with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateBillingAccount = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateBillingAccount(request), expectedError); - const actualRequest = (client.innerApiCalls.updateBillingAccount as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateBillingAccount as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateBillingAccount with closed client', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateBillingAccountRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateBillingAccountRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateBillingAccount(request), expectedError); - }); - }); - - describe('createBillingAccount', () => { - it('invokes createBillingAccount without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.CreateBillingAccountRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.BillingAccount() - ); - client.innerApiCalls.createBillingAccount = stubSimpleCall(expectedResponse); - const [response] = await client.createBillingAccount(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes createBillingAccount without error using callback', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.CreateBillingAccountRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.BillingAccount() - ); - client.innerApiCalls.createBillingAccount = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createBillingAccount( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes createBillingAccount with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.CreateBillingAccountRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.createBillingAccount = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createBillingAccount(request), expectedError); - }); - - it('invokes createBillingAccount with closed client', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.CreateBillingAccountRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createBillingAccount(request), expectedError); - }); - }); - - describe('getProjectBillingInfo', () => { - it('invokes getProjectBillingInfo without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.ProjectBillingInfo() - ); - client.innerApiCalls.getProjectBillingInfo = stubSimpleCall(expectedResponse); - const [response] = await client.getProjectBillingInfo(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProjectBillingInfo without error using callback', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.ProjectBillingInfo() - ); - client.innerApiCalls.getProjectBillingInfo = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProjectBillingInfo( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IProjectBillingInfo|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProjectBillingInfo with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProjectBillingInfo = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProjectBillingInfo(request), expectedError); - const actualRequest = (client.innerApiCalls.getProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProjectBillingInfo with closed client', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.GetProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.GetProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProjectBillingInfo(request), expectedError); - }); - }); - - describe('updateProjectBillingInfo', () => { - it('invokes updateProjectBillingInfo without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.ProjectBillingInfo() - ); - client.innerApiCalls.updateProjectBillingInfo = stubSimpleCall(expectedResponse); - const [response] = await client.updateProjectBillingInfo(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProjectBillingInfo without error using callback', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.billing.v1.ProjectBillingInfo() - ); - client.innerApiCalls.updateProjectBillingInfo = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProjectBillingInfo( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IProjectBillingInfo|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProjectBillingInfo with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProjectBillingInfo = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProjectBillingInfo(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProjectBillingInfo with closed client', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.UpdateProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.UpdateProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProjectBillingInfo(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - 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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - 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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - 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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - 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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - 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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - 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 cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('listBillingAccounts', () => { - it('invokes listBillingAccounts without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListBillingAccountsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - ]; - client.innerApiCalls.listBillingAccounts = stubSimpleCall(expectedResponse); - const [response] = await client.listBillingAccounts(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listBillingAccounts without error using callback', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListBillingAccountsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - ]; - client.innerApiCalls.listBillingAccounts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBillingAccounts( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IBillingAccount[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listBillingAccounts with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListBillingAccountsRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.listBillingAccounts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBillingAccounts(request), expectedError); - }); - - it('invokes listBillingAccountsStream without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListBillingAccountsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - ]; - client.descriptors.page.listBillingAccounts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBillingAccountsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.BillingAccount[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.BillingAccount) => { - 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.listBillingAccounts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBillingAccounts, request)); - }); - - it('invokes listBillingAccountsStream with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListBillingAccountsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listBillingAccounts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBillingAccountsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.BillingAccount[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.BillingAccount) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBillingAccounts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBillingAccounts, request)); - }); - - it('uses async iteration with listBillingAccounts without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListBillingAccountsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - generateSampleMessage(new protos.google.cloud.billing.v1.BillingAccount()), - ]; - client.descriptors.page.listBillingAccounts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.billing.v1.IBillingAccount[] = []; - const iterable = client.listBillingAccountsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBillingAccounts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listBillingAccounts with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListBillingAccountsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listBillingAccounts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBillingAccountsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.billing.v1.IBillingAccount[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBillingAccounts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('listProjectBillingInfo', () => { - it('invokes listProjectBillingInfo without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - ]; - client.innerApiCalls.listProjectBillingInfo = stubSimpleCall(expectedResponse); - const [response] = await client.listProjectBillingInfo(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProjectBillingInfo without error using callback', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - ]; - client.innerApiCalls.listProjectBillingInfo = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProjectBillingInfo( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IProjectBillingInfo[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProjectBillingInfo with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProjectBillingInfo = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProjectBillingInfo(request), expectedError); - const actualRequest = (client.innerApiCalls.listProjectBillingInfo as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProjectBillingInfo as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProjectBillingInfoStream without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - ]; - client.descriptors.page.listProjectBillingInfo.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProjectBillingInfoStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.ProjectBillingInfo[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.ProjectBillingInfo) => { - 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.listProjectBillingInfo.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProjectBillingInfo, request)); - assert( - (client.descriptors.page.listProjectBillingInfo.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProjectBillingInfoStream with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProjectBillingInfo.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProjectBillingInfoStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.ProjectBillingInfo[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.ProjectBillingInfo) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProjectBillingInfo.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProjectBillingInfo, request)); - assert( - (client.descriptors.page.listProjectBillingInfo.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProjectBillingInfo without error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - generateSampleMessage(new protos.google.cloud.billing.v1.ProjectBillingInfo()), - ]; - client.descriptors.page.listProjectBillingInfo.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.billing.v1.IProjectBillingInfo[] = []; - const iterable = client.listProjectBillingInfoAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProjectBillingInfo with error', async () => { - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListProjectBillingInfoRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListProjectBillingInfoRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProjectBillingInfo.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProjectBillingInfoAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.billing.v1.IProjectBillingInfo[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProjectBillingInfo.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('billingAccount', () => { - const fakePath = "/rendered/path/billingAccount"; - const expectedParameters = { - billing_account: "billingAccountValue", - }; - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.billingAccountPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.billingAccountPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('billingAccountPath', () => { - const result = client.billingAccountPath("billingAccountValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.billingAccountPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchBillingAccountFromBillingAccountName', () => { - const result = client.matchBillingAccountFromBillingAccountName(fakePath); - assert.strictEqual(result, "billingAccountValue"); - assert((client.pathTemplates.billingAccountPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('service', () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - service: "serviceValue", - }; - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('sku', () => { - const fakePath = "/rendered/path/sku"; - const expectedParameters = { - service: "serviceValue", - sku: "skuValue", - }; - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.skuPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.skuPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('skuPath', () => { - const result = client.skuPath("serviceValue", "skuValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.skuPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchServiceFromSkuName', () => { - const result = client.matchServiceFromSkuName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.skuPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSkuFromSkuName', () => { - const result = client.matchSkuFromSkuName(fakePath); - assert.strictEqual(result, "skuValue"); - assert((client.pathTemplates.skuPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts b/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts deleted file mode 100644 index 2b09f24d4d7..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts +++ /dev/null @@ -1,688 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as cloudcatalogModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .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.CloudCatalogClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = cloudcatalogModule.v1.CloudCatalogClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = cloudcatalogModule.v1.CloudCatalogClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = cloudcatalogModule.v1.CloudCatalogClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudCatalogStub, undefined); - await client.initialize(); - assert(client.cloudCatalogStub); - }); - - it('has close method for the initialized client', done => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.cloudCatalogStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudCatalogStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - }); - - describe('listServices', () => { - it('invokes listServices without error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListServicesRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCall(expectedResponse); - const [response] = await client.listServices(request); - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listServices without error using callback', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListServicesRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServices( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.IService[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); - - it('invokes listServices with error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListServicesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.listServices = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServices(request), expectedError); - }); - - it('invokes listServicesStream without error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListServicesRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - ]; - client.descriptors.page.listServices.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.Service[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.Service) => { - 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.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - }); - - it('invokes listServicesStream with error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListServicesRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listServices.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.Service[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.Service) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listServices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - }); - - it('uses async iteration with listServices without error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListServicesRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - generateSampleMessage(new protos.google.cloud.billing.v1.Service()), - ]; - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.billing.v1.IService[] = []; - const iterable = client.listServicesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listServices with error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListServicesRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listServicesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.billing.v1.IService[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listServices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('listSkus', () => { - it('invokes listSkus without error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListSkusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - ]; - client.innerApiCalls.listSkus = stubSimpleCall(expectedResponse); - const [response] = await client.listSkus(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSkus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSkus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSkus without error using callback', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListSkusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - ]; - client.innerApiCalls.listSkus = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSkus( - request, - (err?: Error|null, result?: protos.google.cloud.billing.v1.ISku[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSkus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSkus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSkus with error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListSkusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSkus = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSkus(request), expectedError); - const actualRequest = (client.innerApiCalls.listSkus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSkus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSkusStream without error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListSkusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - ]; - client.descriptors.page.listSkus.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSkusStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.Sku[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.Sku) => { - 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.listSkus.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSkus, request)); - assert( - (client.descriptors.page.listSkus.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listSkusStream with error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListSkusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSkus.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSkusStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.billing.v1.Sku[] = []; - stream.on('data', (response: protos.google.cloud.billing.v1.Sku) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSkus.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSkus, request)); - assert( - (client.descriptors.page.listSkus.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSkus without error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListSkusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - generateSampleMessage(new protos.google.cloud.billing.v1.Sku()), - ]; - client.descriptors.page.listSkus.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.billing.v1.ISku[] = []; - const iterable = client.listSkusAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSkus.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSkus.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSkus with error', async () => { - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.billing.v1.ListSkusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.billing.v1.ListSkusRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSkus.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSkusAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.billing.v1.ISku[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSkus.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSkus.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('service', () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - service: "serviceValue", - }; - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.servicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.servicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('servicePath', () => { - const result = client.servicePath("serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchServiceFromServiceName', () => { - const result = client.matchServiceFromServiceName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('sku', () => { - const fakePath = "/rendered/path/sku"; - const expectedParameters = { - service: "serviceValue", - sku: "skuValue", - }; - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.skuPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.skuPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('skuPath', () => { - const result = client.skuPath("serviceValue", "skuValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.skuPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchServiceFromSkuName', () => { - const result = client.matchServiceFromSkuName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.skuPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSkuFromSkuName', () => { - const result = client.matchSkuFromSkuName(fakePath); - assert.strictEqual(result, "skuValue"); - assert((client.pathTemplates.skuPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-billing/v1/tsconfig.json b/owl-bot-staging/google-cloud-billing/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "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-billing/v1/webpack.config.js b/owl-bot-staging/google-cloud-billing/v1/webpack.config.js deleted file mode 100644 index d2282430c03..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// 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: 'CloudBilling', - filename: './cloud-billing.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/packages/google-cloud-billing/src/v1/cloud_billing_client.ts b/packages/google-cloud-billing/src/v1/cloud_billing_client.ts index 642bc23905d..d1c1357644c 100644 --- a/packages/google-cloud-billing/src/v1/cloud_billing_client.ts +++ b/packages/google-cloud-billing/src/v1/cloud_billing_client.ts @@ -121,6 +121,9 @@ export class CloudBillingClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; diff --git a/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts b/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts index 0602dbbe1bf..779dcfde89a 100644 --- a/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts +++ b/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts @@ -122,6 +122,9 @@ export class CloudCatalogClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes;