diff --git a/packages/google-cloud-billing/README.md b/packages/google-cloud-billing/README.md index f91fec725cc..104dc88395a 100644 --- a/packages/google-cloud-billing/README.md +++ b/packages/google-cloud-billing/README.md @@ -2,7 +2,7 @@ [//]: # "To regenerate it, use `python -m synthtool`." Google Cloud Platform logo -# [Cloud Billing: Node.js Client](https://github.com/googleapis/google-cloud-node) +# [Cloud Billing: Node.js Client](https://github.com/googleapis/google-cloud-node/tree/main/packages/google-cloud-billing) [![release level](https://img.shields.io/badge/release%20level-stable-brightgreen.svg?style=flat)](https://cloud.google.com/terms/launch-stages) [![npm version](https://img.shields.io/npm/v/@google-cloud/billing.svg)](https://www.npmjs.org/package/@google-cloud/billing) @@ -84,24 +84,23 @@ listBillingAccounts(); ## Samples -Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/tree/main/samples) directory. Each sample's `README.md` has instructions for running its sample. +Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/tree/main/packages/google-cloud-billing/samples) directory. Each sample's `README.md` has instructions for running its sample. | Sample | Source Code | Try it | | --------------------------- | --------------------------------- | ------ | -| Cloud_billing.create_billing_account | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js,samples/README.md) | -| Cloud_billing.get_billing_account | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_billing_account.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_billing_account.js,samples/README.md) | -| Cloud_billing.get_iam_policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_iam_policy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_iam_policy.js,samples/README.md) | -| Cloud_billing.get_project_billing_info | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_project_billing_info.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_project_billing_info.js,samples/README.md) | -| Cloud_billing.list_billing_accounts | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_billing_accounts.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_billing_accounts.js,samples/README.md) | -| Cloud_billing.list_project_billing_info | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_project_billing_info.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_project_billing_info.js,samples/README.md) | -| Cloud_billing.set_iam_policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.set_iam_policy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.set_iam_policy.js,samples/README.md) | -| Cloud_billing.test_iam_permissions | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.test_iam_permissions.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.test_iam_permissions.js,samples/README.md) | -| Cloud_billing.update_billing_account | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_billing_account.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_billing_account.js,samples/README.md) | -| Cloud_billing.update_project_billing_info | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_project_billing_info.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_project_billing_info.js,samples/README.md) | -| Cloud_catalog.list_services | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_services.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_services.js,samples/README.md) | -| Cloud_catalog.list_skus | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_skus.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_skus.js,samples/README.md) | -| Quickstart | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/quickstart.js,samples/README.md) | -| Quickstart | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/test/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/test/quickstart.js,samples/README.md) | +| Cloud_billing.create_billing_account | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js,packages/google-cloud-billing/samples/README.md) | +| Cloud_billing.get_billing_account | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_billing_account.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_billing_account.js,packages/google-cloud-billing/samples/README.md) | +| Cloud_billing.get_iam_policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_iam_policy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_iam_policy.js,packages/google-cloud-billing/samples/README.md) | +| Cloud_billing.get_project_billing_info | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_project_billing_info.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.get_project_billing_info.js,packages/google-cloud-billing/samples/README.md) | +| Cloud_billing.list_billing_accounts | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_billing_accounts.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_billing_accounts.js,packages/google-cloud-billing/samples/README.md) | +| Cloud_billing.list_project_billing_info | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_project_billing_info.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.list_project_billing_info.js,packages/google-cloud-billing/samples/README.md) | +| Cloud_billing.set_iam_policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.set_iam_policy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.set_iam_policy.js,packages/google-cloud-billing/samples/README.md) | +| Cloud_billing.test_iam_permissions | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.test_iam_permissions.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.test_iam_permissions.js,packages/google-cloud-billing/samples/README.md) | +| Cloud_billing.update_billing_account | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_billing_account.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_billing_account.js,packages/google-cloud-billing/samples/README.md) | +| Cloud_billing.update_project_billing_info | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_project_billing_info.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_billing.update_project_billing_info.js,packages/google-cloud-billing/samples/README.md) | +| Cloud_catalog.list_services | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_services.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_services.js,packages/google-cloud-billing/samples/README.md) | +| Cloud_catalog.list_skus | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_skus.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/generated/v1/cloud_catalog.list_skus.js,packages/google-cloud-billing/samples/README.md) | +| Quickstart | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/quickstart.js,packages/google-cloud-billing/samples/README.md) | 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 213967d9eee..ae64248d637 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 @@ -239,26 +239,32 @@ message BillingAccount { // project has at most one associated billing account at a time (but a billing // account can be assigned to multiple projects). message ProjectBillingInfo { - // The resource name for the `ProjectBillingInfo`; has the form + 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`. This field is read-only. - string name = 1; + string name = 1 [(google.api.field_behavior) = 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. This field is read-only. - string project_id = 2; + // 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. This field + // is read-only. + 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; - // True if the project is associated with an open billing account, to which - // usage on the project is charged. False if the project is associated with a - // closed billing account, or no billing account at all, and therefore cannot - // use paid services. This field is read-only. - bool billing_enabled = 4; + // 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. This field is read-only. + bool billing_enabled = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; } // Request message for `GetBillingAccount`. @@ -370,7 +376,12 @@ message ListProjectBillingInfoResponse { 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]; + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudbilling.googleapis.com/ProjectBillingInfo" + } + ]; } // Request message for `UpdateProjectBillingInfo`. diff --git a/packages/google-cloud-billing/protos/protos.json b/packages/google-cloud-billing/protos/protos.json index 57e1430804e..cfde46b727b 100644 --- a/packages/google-cloud-billing/protos/protos.json +++ b/packages/google-cloud-billing/protos/protos.json @@ -242,14 +242,24 @@ } }, "ProjectBillingInfo": { + "options": { + "(google.api.resource).type": "cloudbilling.googleapis.com/ProjectBillingInfo", + "(google.api.resource).pattern": "projects/{project}/billingInfo" + }, "fields": { "name": { "type": "string", - "id": 1 + "id": 1, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } }, "projectId": { "type": "string", - "id": 2 + "id": 2, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } }, "billingAccountName": { "type": "string", @@ -257,7 +267,10 @@ }, "billingEnabled": { "type": "bool", - "id": 4 + "id": 4, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } } } }, @@ -375,7 +388,8 @@ "type": "string", "id": 1, "options": { - "(google.api.field_behavior)": "REQUIRED" + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "cloudbilling.googleapis.com/ProjectBillingInfo" } } } diff --git a/packages/google-cloud-billing/samples/README.md b/packages/google-cloud-billing/samples/README.md index e03c9bc784e..4f0048d7f02 100644 --- a/packages/google-cloud-billing/samples/README.md +++ b/packages/google-cloud-billing/samples/README.md @@ -25,7 +25,6 @@ * [Cloud_catalog.list_services](#cloud_catalog.list_services) * [Cloud_catalog.list_skus](#cloud_catalog.list_skus) * [Quickstart](#quickstart) - * [Quickstart](#quickstart) ## Before you begin @@ -258,23 +257,6 @@ __Usage:__ `node packages/google-cloud-billing/samples/quickstart.js` ------ - - - - -### Quickstart - -View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-billing/samples/test/quickstart.js). - -[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-billing/samples/test/quickstart.js,samples/README.md) - -__Usage:__ - - -`node packages/google-cloud-billing/samples/test/quickstart.js` - - diff --git a/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json b/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json index 86471f1dee0..c5f1e05346e 100644 --- a/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json +++ b/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-billing", - "version": "3.3.1", + "version": "3.3.2", "language": "TYPESCRIPT", "apis": [ { 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 a775297baeb..1b1edb1d2dc 100644 --- a/packages/google-cloud-billing/src/v1/cloud_billing_client.ts +++ b/packages/google-cloud-billing/src/v1/cloud_billing_client.ts @@ -182,6 +182,9 @@ export class CloudBillingClient { billingAccountPathTemplate: new this._gaxModule.PathTemplate( 'billingAccounts/{billing_account}' ), + projectBillingInfoPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/billingInfo' + ), servicePathTemplate: new this._gaxModule.PathTemplate( 'services/{service}' ), @@ -1609,6 +1612,31 @@ export class CloudBillingClient { ).billing_account; } + /** + * 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. * 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 a7f63761b12..be58d3310db 100644 --- a/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts +++ b/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts @@ -180,6 +180,9 @@ export class CloudCatalogClient { // 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}' ), @@ -760,6 +763,31 @@ export class CloudCatalogClient { // -- 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. * 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 f0625f299a5..fe4d000464c 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,50 @@ describe('v1.CloudBillingClient', () => { }); }); + 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 = { 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 5d622d5061c..a82ba426aa2 100644 --- a/packages/google-cloud-billing/test/gapic_cloud_catalog_v1.ts +++ b/packages/google-cloud-billing/test/gapic_cloud_catalog_v1.ts @@ -729,6 +729,50 @@ describe('v1.CloudCatalogClient', () => { }); 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 = {