diff --git a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js index fecf344b33a..219d3230931 100644 --- a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js +++ b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_billing_account.js b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_billing_account.js index 1cb29dbb4ac..fc835c34e12 100644 --- a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_billing_account.js +++ b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_billing_account.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_iam_policy.js b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_iam_policy.js index 0d2608c7c07..595d4926b7b 100644 --- a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_iam_policy.js +++ b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_iam_policy.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_project_billing_info.js b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_project_billing_info.js index 7a516838b10..b8a9fcb4c41 100644 --- a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_project_billing_info.js +++ b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_project_billing_info.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_billing_accounts.js b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_billing_accounts.js index 9d514b78e96..24238125419 100644 --- a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_billing_accounts.js +++ b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_billing_accounts.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_project_billing_info.js b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_project_billing_info.js index 480a899f493..e7b16d3c863 100644 --- a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_project_billing_info.js +++ b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_project_billing_info.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.set_iam_policy.js b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.set_iam_policy.js index d5310890b6b..d6eb9135d90 100644 --- a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.set_iam_policy.js +++ b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.set_iam_policy.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.test_iam_permissions.js b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.test_iam_permissions.js index de6b0f58cea..f3c3ea34f11 100644 --- a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.test_iam_permissions.js +++ b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.test_iam_permissions.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_billing_account.js b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_billing_account.js index a014b620888..8b24c9f78ca 100644 --- a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_billing_account.js +++ b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_billing_account.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_project_billing_info.js b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_project_billing_info.js index 5f40a9fd252..69fe0a80ace 100644 --- a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_project_billing_info.js +++ b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_project_billing_info.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_services.js b/packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_services.js index 4213e914632..2a27e9dc98a 100644 --- a/packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_services.js +++ b/packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_services.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_skus.js b/packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_skus.js index 7d39ef17514..3dd60ebae66 100644 --- a/packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_skus.js +++ b/packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_skus.js @@ -1,16 +1,21 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + 'use strict'; diff --git a/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json b/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json new file mode 100644 index 00000000000..f60caa6e326 --- /dev/null +++ b/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json @@ -0,0 +1,559 @@ +{ + "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": 51, + "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": 67, + "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": 60, + "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": " Creates a billing account. This method can only be used to create [billing subaccounts](https://cloud.google.com/billing/docs/concepts) by GCP resellers. When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the master account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the master account has not been provisioned as a reseller account.", + "canonical": true, + "file": "cloud_billing.create_billing_account.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "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": 64, + "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 [permission to view the project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ).", + "canonical": true, + "file": "cloud_billing.get_project_billing_info.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "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 GCP Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project. The current authenticated user must have ownership privileges for both the [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](https://cloud.google.com/billing/docs/how-to/billing-access). You can disable billing on the project by setting the `billing_account_name` field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project. Note that associating a project with a *closed* billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an *open* billing account.", + "canonical": true, + "file": "cloud_billing.update_project_billing_info.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "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": 56, + "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": 59, + "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" + } + ], + "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": 59, + "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": 57, + "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": 87, + "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/packages/google-cloud-billing/src/v1/cloud_billing_client.ts b/packages/google-cloud-billing/src/v1/cloud_billing_client.ts index d1a8d61071e..be3f6e6a095 100644 --- a/packages/google-cloud-billing/src/v1/cloud_billing_client.ts +++ b/packages/google-cloud-billing/src/v1/cloud_billing_client.ts @@ -1638,9 +1638,8 @@ export class CloudBillingClient { * @returns {Promise} A promise that resolves when the client is closed. */ close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.cloudBillingStub!.then(stub => { + if (this.cloudBillingStub && !this._terminated) { + return this.cloudBillingStub.then(stub => { this._terminated = true; stub.close(); }); diff --git a/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts b/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts index 5abede40784..bb04f02c75d 100644 --- a/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts +++ b/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts @@ -807,9 +807,8 @@ export class CloudCatalogClient { * @returns {Promise} A promise that resolves when the client is closed. */ close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.cloudCatalogStub!.then(stub => { + if (this.cloudCatalogStub && !this._terminated) { + return this.cloudCatalogStub.then(stub => { this._terminated = true; stub.close(); }); 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 5b38c019802..355734d0c4f 100644 --- a/packages/google-cloud-billing/test/gapic_cloud_billing_v1.ts +++ b/packages/google-cloud-billing/test/gapic_cloud_billing_v1.ts @@ -151,12 +151,27 @@ describe('v1.CloudBillingClient', () => { assert(client.cloudBillingStub); }); - it('has close method', () => { + 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.close(); + 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 () => { @@ -302,6 +317,22 @@ describe('v1.CloudBillingClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getBillingAccount(request), expectedError); + }); }); describe('updateBillingAccount', () => { @@ -414,6 +445,22 @@ describe('v1.CloudBillingClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateBillingAccount(request), expectedError); + }); }); describe('createBillingAccount', () => { @@ -502,6 +549,20 @@ describe('v1.CloudBillingClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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', () => { @@ -617,6 +678,25 @@ describe('v1.CloudBillingClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.getProjectBillingInfo(request), + expectedError + ); + }); }); describe('updateProjectBillingInfo', () => { @@ -732,6 +812,25 @@ describe('v1.CloudBillingClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.updateProjectBillingInfo(request), + expectedError + ); + }); }); describe('getIamPolicy', () => { @@ -843,6 +942,22 @@ describe('v1.CloudBillingClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); }); describe('setIamPolicy', () => { @@ -954,6 +1069,22 @@ describe('v1.CloudBillingClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); }); describe('testIamPermissions', () => { @@ -1066,6 +1197,22 @@ describe('v1.CloudBillingClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + 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() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); }); describe('listBillingAccounts', () => { diff --git a/packages/google-cloud-billing/test/gapic_cloud_catalog_v1.ts b/packages/google-cloud-billing/test/gapic_cloud_catalog_v1.ts index 03870cd4b9e..87c81aedd95 100644 --- a/packages/google-cloud-billing/test/gapic_cloud_catalog_v1.ts +++ b/packages/google-cloud-billing/test/gapic_cloud_catalog_v1.ts @@ -151,12 +151,27 @@ describe('v1.CloudCatalogClient', () => { assert(client.cloudCatalogStub); }); - it('has close method', () => { + 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.close(); + 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 () => {