diff --git a/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.create_budget.js b/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.create_budget.js new file mode 100644 index 00000000000..c2e6f9d6df4 --- /dev/null +++ b/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.create_budget.js @@ -0,0 +1,58 @@ +// 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 +// +// 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. + +'use strict'; + +function main(parent, budget) { + // [START billingbudgets_v1_generated_BudgetService_CreateBudget_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the billing account to create the budget in. Values + * are of the form `billingAccounts/{billingAccountId}`. + */ + // const parent = 'abc123' + /** + * Required. Budget to create. + */ + // const budget = '' + + // Imports the Budgets library + const {BudgetServiceClient} = require('@google-cloud/billing-budgets').v1; + + // Instantiates a client + const budgetsClient = new BudgetServiceClient(); + + async function createBudget() { + // Construct request + const request = { + parent, + budget, + }; + + // Run request + const response = await budgetsClient.createBudget(request); + console.log(response); + } + + createBudget(); + // [END billingbudgets_v1_generated_BudgetService_CreateBudget_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.delete_budget.js b/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.delete_budget.js new file mode 100644 index 00000000000..b0976c65c31 --- /dev/null +++ b/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.delete_budget.js @@ -0,0 +1,53 @@ +// 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 +// +// 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. + +'use strict'; + +function main(name) { + // [START billingbudgets_v1_generated_BudgetService_DeleteBudget_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the budget to delete. Values are of the form + * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. + */ + // const name = 'abc123' + + // Imports the Budgets library + const {BudgetServiceClient} = require('@google-cloud/billing-budgets').v1; + + // Instantiates a client + const budgetsClient = new BudgetServiceClient(); + + async function deleteBudget() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await budgetsClient.deleteBudget(request); + console.log(response); + } + + deleteBudget(); + // [END billingbudgets_v1_generated_BudgetService_DeleteBudget_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.get_budget.js b/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.get_budget.js new file mode 100644 index 00000000000..ba11a08a760 --- /dev/null +++ b/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.get_budget.js @@ -0,0 +1,53 @@ +// 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 +// +// 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. + +'use strict'; + +function main(name) { + // [START billingbudgets_v1_generated_BudgetService_GetBudget_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of budget to get. Values are of the form + * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. + */ + // const name = 'abc123' + + // Imports the Budgets library + const {BudgetServiceClient} = require('@google-cloud/billing-budgets').v1; + + // Instantiates a client + const budgetsClient = new BudgetServiceClient(); + + async function getBudget() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await budgetsClient.getBudget(request); + console.log(response); + } + + getBudget(); + // [END billingbudgets_v1_generated_BudgetService_GetBudget_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.list_budgets.js b/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.list_budgets.js new file mode 100644 index 00000000000..eeeb5864b87 --- /dev/null +++ b/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.list_budgets.js @@ -0,0 +1,66 @@ +// 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 +// +// 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. + +'use strict'; + +function main(parent) { + // [START billingbudgets_v1_generated_BudgetService_ListBudgets_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of billing account to list budgets under. Values + * are of the form `billingAccounts/{billingAccountId}`. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of budgets to return per page. + * The default and maximum value are 100. + */ + // const pageSize = 1234 + /** + * Optional. The value returned by the last `ListBudgetsResponse` which + * indicates that this is a continuation of a prior `ListBudgets` call, + * and that the system should return the next page of data. + */ + // const pageToken = 'abc123' + + // Imports the Budgets library + const {BudgetServiceClient} = require('@google-cloud/billing-budgets').v1; + + // Instantiates a client + const budgetsClient = new BudgetServiceClient(); + + async function listBudgets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await budgetsClient.listBudgetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + listBudgets(); + // [END billingbudgets_v1_generated_BudgetService_ListBudgets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.update_budget.js b/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.update_budget.js new file mode 100644 index 00000000000..43e748234da --- /dev/null +++ b/packages/google-cloud-billing-budgets/samples/generated/v1/budget_service.update_budget.js @@ -0,0 +1,62 @@ +// 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 +// +// 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. + +'use strict'; + +function main(budget) { + // [START billingbudgets_v1_generated_BudgetService_UpdateBudget_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The updated budget object. + * The budget to update is specified by the budget name in the budget. + */ + // const budget = '' + /** + * Optional. Indicates which fields in the provided budget to update. + * Read-only fields (such as `name`) cannot be changed. If this is not + * provided, then only fields with non-default values from the request are + * updated. See + * https://developers.google.com/protocol-buffers/docs/proto3#default for more + * details about default values. + */ + // const updateMask = '' + + // Imports the Budgets library + const {BudgetServiceClient} = require('@google-cloud/billing-budgets').v1; + + // Instantiates a client + const budgetsClient = new BudgetServiceClient(); + + async function updateBudget() { + // Construct request + const request = { + budget, + }; + + // Run request + const response = await budgetsClient.updateBudget(request); + console.log(response); + } + + updateBudget(); + // [END billingbudgets_v1_generated_BudgetService_UpdateBudget_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.create_budget.js b/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.create_budget.js new file mode 100644 index 00000000000..2818a894499 --- /dev/null +++ b/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.create_budget.js @@ -0,0 +1,59 @@ +// 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 +// +// 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. + +'use strict'; + +function main(parent, budget) { + // [START billingbudgets_v1beta1_generated_BudgetService_CreateBudget_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the billing account to create the budget in. Values + * are of the form `billingAccounts/{billingAccountId}`. + */ + // const parent = 'abc123' + /** + * Required. Budget to create. + */ + // const budget = '' + + // Imports the Budgets library + const {BudgetServiceClient} = + require('@google-cloud/billing-budgets').v1beta1; + + // Instantiates a client + const budgetsClient = new BudgetServiceClient(); + + async function createBudget() { + // Construct request + const request = { + parent, + budget, + }; + + // Run request + const response = await budgetsClient.createBudget(request); + console.log(response); + } + + createBudget(); + // [END billingbudgets_v1beta1_generated_BudgetService_CreateBudget_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.delete_budget.js b/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.delete_budget.js new file mode 100644 index 00000000000..1fc7a370c56 --- /dev/null +++ b/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.delete_budget.js @@ -0,0 +1,54 @@ +// 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 +// +// 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. + +'use strict'; + +function main(name) { + // [START billingbudgets_v1beta1_generated_BudgetService_DeleteBudget_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of the budget to delete. Values are of the form + * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. + */ + // const name = 'abc123' + + // Imports the Budgets library + const {BudgetServiceClient} = + require('@google-cloud/billing-budgets').v1beta1; + + // Instantiates a client + const budgetsClient = new BudgetServiceClient(); + + async function deleteBudget() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await budgetsClient.deleteBudget(request); + console.log(response); + } + + deleteBudget(); + // [END billingbudgets_v1beta1_generated_BudgetService_DeleteBudget_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.get_budget.js b/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.get_budget.js new file mode 100644 index 00000000000..90d099d2fd0 --- /dev/null +++ b/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.get_budget.js @@ -0,0 +1,54 @@ +// 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 +// +// 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. + +'use strict'; + +function main(name) { + // [START billingbudgets_v1beta1_generated_BudgetService_GetBudget_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of budget to get. Values are of the form + * `billingAccounts/{billingAccountId}/budgets/{budgetId}`. + */ + // const name = 'abc123' + + // Imports the Budgets library + const {BudgetServiceClient} = + require('@google-cloud/billing-budgets').v1beta1; + + // Instantiates a client + const budgetsClient = new BudgetServiceClient(); + + async function getBudget() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await budgetsClient.getBudget(request); + console.log(response); + } + + getBudget(); + // [END billingbudgets_v1beta1_generated_BudgetService_GetBudget_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.list_budgets.js b/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.list_budgets.js new file mode 100644 index 00000000000..b463754a615 --- /dev/null +++ b/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.list_budgets.js @@ -0,0 +1,67 @@ +// 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 +// +// 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. + +'use strict'; + +function main(parent) { + // [START billingbudgets_v1beta1_generated_BudgetService_ListBudgets_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of billing account to list budgets under. Values + * are of the form `billingAccounts/{billingAccountId}`. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of budgets to return per page. + * The default and maximum value are 100. + */ + // const pageSize = 1234 + /** + * Optional. The value returned by the last `ListBudgetsResponse` which + * indicates that this is a continuation of a prior `ListBudgets` call, + * and that the system should return the next page of data. + */ + // const pageToken = 'abc123' + + // Imports the Budgets library + const {BudgetServiceClient} = + require('@google-cloud/billing-budgets').v1beta1; + + // Instantiates a client + const budgetsClient = new BudgetServiceClient(); + + async function listBudgets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await budgetsClient.listBudgetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + listBudgets(); + // [END billingbudgets_v1beta1_generated_BudgetService_ListBudgets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.update_budget.js b/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.update_budget.js new file mode 100644 index 00000000000..af6b23698a1 --- /dev/null +++ b/packages/google-cloud-billing-budgets/samples/generated/v1beta1/budget_service.update_budget.js @@ -0,0 +1,63 @@ +// 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 +// +// 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. + +'use strict'; + +function main(budget) { + // [START billingbudgets_v1beta1_generated_BudgetService_UpdateBudget_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The updated budget object. + * The budget to update is specified by the budget name in the budget. + */ + // const budget = '' + /** + * Optional. Indicates which fields in the provided budget to update. + * Read-only fields (such as `name`) cannot be changed. If this is not + * provided, then only fields with non-default values from the request are + * updated. See + * https://developers.google.com/protocol-buffers/docs/proto3#default for more + * details about default values. + */ + // const updateMask = '' + + // Imports the Budgets library + const {BudgetServiceClient} = + require('@google-cloud/billing-budgets').v1beta1; + + // Instantiates a client + const budgetsClient = new BudgetServiceClient(); + + async function updateBudget() { + // Construct request + const request = { + budget, + }; + + // Run request + const response = await budgetsClient.updateBudget(request); + console.log(response); + } + + updateBudget(); + // [END billingbudgets_v1beta1_generated_BudgetService_UpdateBudget_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-billing-budgets/samples/package.json b/packages/google-cloud-billing-budgets/samples/package.json index 2f2880c7004..735d4ae4c53 100644 --- a/packages/google-cloud-billing-budgets/samples/package.json +++ b/packages/google-cloud-billing-budgets/samples/package.json @@ -9,7 +9,7 @@ "author": "Google LLC", "repository": "googleapis/nodejs-billing-budgets", "engines": { - "node": ">=8" + "node": ">=10" }, "scripts": { "test": "c8 mocha system-test --timeout=800000" diff --git a/packages/google-cloud-billing-budgets/src/v1/budget_service_client.ts b/packages/google-cloud-billing-budgets/src/v1/budget_service_client.ts index 5dfd2b71c7a..6bd1e5ab385 100644 --- a/packages/google-cloud-billing-budgets/src/v1/budget_service_client.ts +++ b/packages/google-cloud-billing-budgets/src/v1/budget_service_client.ts @@ -859,7 +859,8 @@ export class BudgetServiceClient { gax.routingHeader.fromParams({ parent: request.parent || '', }); - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listBudgets']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listBudgets.createStream( this.innerApiCalls.listBudgets as gax.GaxCall, @@ -913,7 +914,8 @@ export class BudgetServiceClient { parent: request.parent || '', }); options = options || {}; - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listBudgets']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listBudgets.asyncIterate( this.innerApiCalls['listBudgets'] as GaxCall, diff --git a/packages/google-cloud-billing-budgets/src/v1beta1/budget_service_client.ts b/packages/google-cloud-billing-budgets/src/v1beta1/budget_service_client.ts index aed44bfe547..b6dc4f2ebeb 100644 --- a/packages/google-cloud-billing-budgets/src/v1beta1/budget_service_client.ts +++ b/packages/google-cloud-billing-budgets/src/v1beta1/budget_service_client.ts @@ -878,7 +878,8 @@ export class BudgetServiceClient { gax.routingHeader.fromParams({ parent: request.parent || '', }); - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listBudgets']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listBudgets.createStream( this.innerApiCalls.listBudgets as gax.GaxCall, @@ -932,7 +933,8 @@ export class BudgetServiceClient { parent: request.parent || '', }); options = options || {}; - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listBudgets']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listBudgets.asyncIterate( this.innerApiCalls['listBudgets'] as GaxCall,