From 2f89e86912fd09e4f21ea98db8b00e924e98744d Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 6 Sep 2023 21:56:46 +0000 Subject: [PATCH 1/2] fix: fixed resource_reference for name in GetProjectBillingInfo PiperOrigin-RevId: 563189185 Source-Link: https://github.com/googleapis/googleapis/commit/4967815ba02bf23737213651b04f6347c823d086 Source-Link: https://github.com/googleapis/googleapis-gen/commit/9f06f3e0bc0e16662a264e3ddc2ef39bf7ad93ec Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpbGxpbmcvLk93bEJvdC55YW1sIiwiaCI6IjlmMDZmM2UwYmMwZTE2NjYyYTI2NGUzZGRjMmVmMzliZjdhZDkzZWMifQ== --- .../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 + .../google-cloud-billing/v1/package.json | 59 + .../cloud/billing/v1/cloud_billing.proto | 397 ++++ .../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 | 76 + .../v1/cloud_billing.set_iam_policy.js | 77 + .../v1/cloud_billing.test_iam_permissions.js | 70 + .../cloud_billing.update_billing_account.js | 72 + ...oud_billing.update_project_billing_info.js | 69 + .../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 | 1500 +++++++++++++++ .../src/v1/cloud_billing_client_config.json | 76 + .../v1/src/v1/cloud_billing_proto_list.json | 4 + .../v1/src/v1/cloud_catalog_client.ts | 810 +++++++++ .../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 | 1609 +++++++++++++++++ .../v1/test/gapic_cloud_catalog_v1.ts | 718 ++++++++ .../google-cloud-billing/v1/tsconfig.json | 19 + .../google-cloud-billing/v1/webpack.config.js | 64 + 39 files changed, 7555 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/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..d4f03a0df2e --- /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..52a5a884211 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2023 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/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..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-billing/v1/.prettierrc.js b/owl-bot-staging/google-cloud-billing/v1/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-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/package.json b/owl-bot-staging/google-cloud-billing/v1/package.json new file mode 100644 index 00000000000..f681d9db4c4 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/package.json @@ -0,0 +1,59 @@ +{ + "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", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} 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..241a624bf1a --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto @@ -0,0 +1,397 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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 = "cloud.google.com/go/billing/apiv1/billingpb;billingpb"; +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 { + option (google.api.resource) = { + type: "cloudbilling.googleapis.com/ProjectBillingInfo" + pattern: "projects/{project}/billingInfo" + }; + + // Output only. 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`. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. 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. + string project_id = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The resource name of the billing account associated with the project, if + // any. For example, `billingAccounts/012345-567890-ABCDEF`. + string billing_account_name = 3; + + // Output only. 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. + bool billing_enabled = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// 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, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; +} + +// 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. Output-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..ed1028dcc50 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto @@ -0,0 +1,363 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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 = "cloud.google.com/go/billing/apiv1/billingpb;billingpb"; +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..0f0b859ecab --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.create_billing_account.js @@ -0,0 +1,64 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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..f4b7caa1aee --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_billing_account.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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..f469ae8a9ed --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.get_iam_policy.js @@ -0,0 +1,67 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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..251ca2b34ff --- /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 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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..acea3f19a26 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_billing_accounts.js @@ -0,0 +1,78 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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..8fe2bd4bed4 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js @@ -0,0 +1,76 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(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..df5114628b9 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.set_iam_policy.js @@ -0,0 +1,77 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(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..706187f9fbd --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.test_iam_permissions.js @@ -0,0 +1,70 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(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 = ['abc','def'] + + // 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..5235304c131 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js @@ -0,0 +1,72 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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..d6f55c65bd4 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js @@ -0,0 +1,69 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(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. Output-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..a06bee8c811 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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..7e9f491fc7b --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js @@ -0,0 +1,98 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(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..e0304cd18fa --- /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": 64, + "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": 68, + "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": 61, + "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..d2f98787fb1 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/index.ts @@ -0,0 +1,27 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as 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..2b7ae2e8f76 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts @@ -0,0 +1,1500 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CloudBillingClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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 { + 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}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectBillingInfoPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/billingInfo' + ), + 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 {@link protos.google.cloud.billing.v1.BillingAccount|BillingAccount}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/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 {@link protos.google.cloud.billing.v1.BillingAccount|BillingAccount}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/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 {@link protos.google.cloud.billing.v1.BillingAccount|BillingAccount}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/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 {@link protos.google.cloud.billing.v1.ProjectBillingInfo|ProjectBillingInfo}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/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. Output-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 {@link protos.google.cloud.billing.v1.ProjectBillingInfo|ProjectBillingInfo}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/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 {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/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 {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/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 {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/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 {@link protos.google.cloud.billing.v1.BillingAccount|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link protos.google.cloud.billing.v1.BillingAccount|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.billing.v1.BillingAccount|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link protos.google.cloud.billing.v1.ProjectBillingInfo|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link protos.google.cloud.billing.v1.ProjectBillingInfo|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.billing.v1.ProjectBillingInfo|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified projectBillingInfo resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectBillingInfoPath(project:string) { + return this.pathTemplates.projectBillingInfoPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from ProjectBillingInfo resource. + * + * @param {string} projectBillingInfoName + * A fully-qualified path representing ProjectBillingInfo resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectBillingInfoName(projectBillingInfoName: string) { + return this.pathTemplates.projectBillingInfoPathTemplate.match(projectBillingInfoName).project; + } + + /** + * 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..1a33cb1a6b4 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts @@ -0,0 +1,810 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CloudCatalogClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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 { + 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 = { + projectBillingInfoPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/billingInfo' + ), + 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 {@link protos.google.cloud.billing.v1.Service|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link protos.google.cloud.billing.v1.Service|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.billing.v1.Service|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link protos.google.cloud.billing.v1.Sku|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link protos.google.cloud.billing.v1.Sku|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.billing.v1.Sku|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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 projectBillingInfo resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectBillingInfoPath(project:string) { + return this.pathTemplates.projectBillingInfoPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from ProjectBillingInfo resource. + * + * @param {string} projectBillingInfoName + * A fully-qualified path representing ProjectBillingInfo resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectBillingInfoName(projectBillingInfoName: string) { + return this.pathTemplates.projectBillingInfoPathTemplate.match(projectBillingInfoName).project; + } + + /** + * 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..4a2e6d700cb --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {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..16c13ba6eea --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,28 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const 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..54e4fc48443 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,38 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {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..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-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..892357aa807 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_billing_v1.ts @@ -0,0 +1,1609 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectBillingInfo', () => { + const fakePath = "/rendered/path/projectBillingInfo"; + const expectedParameters = { + project: "projectValue", + }; + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectBillingInfoPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectBillingInfoPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectBillingInfoPath', () => { + const result = client.projectBillingInfoPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectBillingInfoPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectBillingInfoName', () => { + const result = client.matchProjectFromProjectBillingInfoName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectBillingInfoPathTemplate.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..856ef5f04b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts @@ -0,0 +1,718 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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('projectBillingInfo', () => { + const fakePath = "/rendered/path/projectBillingInfo"; + const expectedParameters = { + project: "projectValue", + }; + const client = new cloudcatalogModule.v1.CloudCatalogClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectBillingInfoPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectBillingInfoPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectBillingInfoPath', () => { + const result = client.projectBillingInfoPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectBillingInfoPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectBillingInfoName', () => { + const result = client.matchProjectFromProjectBillingInfoName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectBillingInfoPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + 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 161af32ec4f2ed076f7be64db6562729e44c0440 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 6 Sep 2023 22:01:15 +0000 Subject: [PATCH 2/2] =?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 - .../google-cloud-billing/v1/package.json | 59 - .../cloud/billing/v1/cloud_billing.proto | 397 ---- .../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 | 76 - .../v1/cloud_billing.set_iam_policy.js | 77 - .../v1/cloud_billing.test_iam_permissions.js | 70 - .../cloud_billing.update_billing_account.js | 72 - ...oud_billing.update_project_billing_info.js | 69 - .../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 | 1500 --------------- .../src/v1/cloud_billing_client_config.json | 76 - .../v1/src/v1/cloud_billing_proto_list.json | 4 - .../v1/src/v1/cloud_catalog_client.ts | 810 --------- .../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 | 1609 ----------------- .../v1/test/gapic_cloud_catalog_v1.ts | 718 -------- .../google-cloud-billing/v1/tsconfig.json | 19 - .../google-cloud-billing/v1/webpack.config.js | 64 - .../cloud/billing/v1/cloud_billing.proto | 2 +- .../google-cloud-billing/protos/protos.json | 2 +- .../src/v1/cloud_billing_client.ts | 26 + .../test/gapic_cloud_billing_v1.ts | 38 + 43 files changed, 66 insertions(+), 7557 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/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 d4f03a0df2e..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 52a5a884211..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2023 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/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 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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/package.json b/owl-bot-staging/google-cloud-billing/v1/package.json deleted file mode 100644 index f681d9db4c4..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/package.json +++ /dev/null @@ -1,59 +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", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", - "jsdoc-fresh": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} 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 241a624bf1a..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_billing.proto +++ /dev/null @@ -1,397 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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 = "cloud.google.com/go/billing/apiv1/billingpb;billingpb"; -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 { - option (google.api.resource) = { - type: "cloudbilling.googleapis.com/ProjectBillingInfo" - pattern: "projects/{project}/billingInfo" - }; - - // Output only. 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`. - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. 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. - string project_id = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The resource name of the billing account associated with the project, if - // any. For example, `billingAccounts/012345-567890-ABCDEF`. - string billing_account_name = 3; - - // Output only. 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. - bool billing_enabled = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// 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, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; -} - -// 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. Output-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 ed1028dcc50..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/protos/google/cloud/billing/v1/cloud_catalog.proto +++ /dev/null @@ -1,363 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.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 = "cloud.google.com/go/billing/apiv1/billingpb;billingpb"; -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 0f0b859ecab..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 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 f4b7caa1aee..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 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 f469ae8a9ed..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 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 251ca2b34ff..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 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 acea3f19a26..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 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 8fe2bd4bed4..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.list_project_billing_info.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 df5114628b9..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 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 706187f9fbd..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 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 = ['abc','def'] - - // 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 5235304c131..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_billing_account.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 d6f55c65bd4..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_billing.update_project_billing_info.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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. Output-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 a06bee8c811..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_services.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 7e9f491fc7b..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/samples/generated/v1/cloud_catalog.list_skus.js +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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 e0304cd18fa..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": 64, - "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": 68, - "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": 61, - "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 d2f98787fb1..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 2b7ae2e8f76..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_billing_client.ts +++ /dev/null @@ -1,1500 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new CloudBillingClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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 { - 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}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - projectBillingInfoPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/billingInfo' - ), - 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 {@link protos.google.cloud.billing.v1.BillingAccount|BillingAccount}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/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 {@link protos.google.cloud.billing.v1.BillingAccount|BillingAccount}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/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 {@link protos.google.cloud.billing.v1.BillingAccount|BillingAccount}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/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 {@link protos.google.cloud.billing.v1.ProjectBillingInfo|ProjectBillingInfo}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/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. Output-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 {@link protos.google.cloud.billing.v1.ProjectBillingInfo|ProjectBillingInfo}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/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 {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/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 {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/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 {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/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 {@link protos.google.cloud.billing.v1.BillingAccount|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link protos.google.cloud.billing.v1.BillingAccount|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.billing.v1.BillingAccount|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link protos.google.cloud.billing.v1.ProjectBillingInfo|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link protos.google.cloud.billing.v1.ProjectBillingInfo|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.billing.v1.ProjectBillingInfo|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified projectBillingInfo resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectBillingInfoPath(project:string) { - return this.pathTemplates.projectBillingInfoPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from ProjectBillingInfo resource. - * - * @param {string} projectBillingInfoName - * A fully-qualified path representing ProjectBillingInfo resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectBillingInfoName(projectBillingInfoName: string) { - return this.pathTemplates.projectBillingInfoPathTemplate.match(projectBillingInfoName).project; - } - - /** - * 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 1a33cb1a6b4..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/cloud_catalog_client.ts +++ /dev/null @@ -1,810 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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} [options.fallback] - Use HTTP/1.1 REST mode. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new CloudCatalogClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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 { - 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 = { - projectBillingInfoPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/billingInfo' - ), - 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 {@link protos.google.cloud.billing.v1.Service|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link protos.google.cloud.billing.v1.Service|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.billing.v1.Service|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link protos.google.cloud.billing.v1.Sku|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link protos.google.cloud.billing.v1.Sku|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.billing.v1.Sku|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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 projectBillingInfo resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectBillingInfoPath(project:string) { - return this.pathTemplates.projectBillingInfoPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from ProjectBillingInfo resource. - * - * @param {string} projectBillingInfoName - * A fully-qualified path representing ProjectBillingInfo resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectBillingInfoName(projectBillingInfoName: string) { - return this.pathTemplates.projectBillingInfoPathTemplate.match(projectBillingInfoName).project; - } - - /** - * 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 4a2e6d700cb..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/src/v1/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 16c13ba6eea..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 54e4fc48443..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 892357aa807..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_billing_v1.ts +++ /dev/null @@ -1,1609 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectBillingInfo', () => { - const fakePath = "/rendered/path/projectBillingInfo"; - const expectedParameters = { - project: "projectValue", - }; - const client = new cloudbillingModule.v1.CloudBillingClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectBillingInfoPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectBillingInfoPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectBillingInfoPath', () => { - const result = client.projectBillingInfoPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectBillingInfoPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectBillingInfoName', () => { - const result = client.matchProjectFromProjectBillingInfoName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectBillingInfoPathTemplate.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 856ef5f04b0..00000000000 --- a/owl-bot-staging/google-cloud-billing/v1/test/gapic_cloud_catalog_v1.ts +++ /dev/null @@ -1,718 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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('projectBillingInfo', () => { - const fakePath = "/rendered/path/projectBillingInfo"; - const expectedParameters = { - project: "projectValue", - }; - const client = new cloudcatalogModule.v1.CloudCatalogClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectBillingInfoPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectBillingInfoPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectBillingInfoPath', () => { - const result = client.projectBillingInfoPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectBillingInfoPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectBillingInfoName', () => { - const result = client.matchProjectFromProjectBillingInfoName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectBillingInfoPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - 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 0b056754559..241a624bf1a 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 @@ -378,7 +378,7 @@ message GetProjectBillingInfoRequest { string name = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference) = { - type: "cloudbilling.googleapis.com/ProjectBillingInfo" + type: "cloudresourcemanager.googleapis.com/Project" } ]; } diff --git a/packages/google-cloud-billing/protos/protos.json b/packages/google-cloud-billing/protos/protos.json index 8d2aa521b29..36512558258 100644 --- a/packages/google-cloud-billing/protos/protos.json +++ b/packages/google-cloud-billing/protos/protos.json @@ -389,7 +389,7 @@ "id": 1, "options": { "(google.api.field_behavior)": "REQUIRED", - "(google.api.resource_reference).type": "cloudbilling.googleapis.com/ProjectBillingInfo" + "(google.api.resource_reference).type": "cloudresourcemanager.googleapis.com/Project" } } } 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 7e2732d48bb..077c9947388 100644 --- a/packages/google-cloud-billing/src/v1/cloud_billing_client.ts +++ b/packages/google-cloud-billing/src/v1/cloud_billing_client.ts @@ -181,6 +181,9 @@ export class CloudBillingClient { billingAccountPathTemplate: new this._gaxModule.PathTemplate( 'billingAccounts/{billing_account}' ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), projectBillingInfoPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/billingInfo' ), @@ -1598,6 +1601,29 @@ export class CloudBillingClient { ).billing_account; } + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project: string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + /** * Return a fully-qualified projectBillingInfo resource name string. * diff --git a/packages/google-cloud-billing/test/gapic_cloud_billing_v1.ts b/packages/google-cloud-billing/test/gapic_cloud_billing_v1.ts index fe4d000464c..34829ea26fb 100644 --- a/packages/google-cloud-billing/test/gapic_cloud_billing_v1.ts +++ b/packages/google-cloud-billing/test/gapic_cloud_billing_v1.ts @@ -1860,6 +1860,44 @@ describe('v1.CloudBillingClient', () => { }); }); + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new cloudbillingModule.v1.CloudBillingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + describe('projectBillingInfo', () => { const fakePath = '/rendered/path/projectBillingInfo'; const expectedParameters = {