From 4c17fbc6210929dde3a79f4474bdded4a424217c Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 28 Sep 2021 23:32:35 +0000 Subject: [PATCH] docs(samples): add auto-generated samples for Node with api short name in region tag (#221) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 399287285 Source-Link: https://github.com/googleapis/googleapis/commit/15759865d1c54e3d46429010f7e472fe6c3d3715 Source-Link: https://github.com/googleapis/googleapis-gen/commit/b27fff623a5d8d586b703b5e4919856abe7c2eb3 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjI3ZmZmNjIzYTVkOGQ1ODZiNzAzYjVlNDkxOTg1NmFiZTdjMmViMyJ9 --- .../v1/dashboards_service.create_dashboard.js | 65 ++++++++++++++++++ .../v1/dashboards_service.delete_dashboard.js | 54 +++++++++++++++ .../v1/dashboards_service.get_dashboard.js | 56 ++++++++++++++++ .../v1/dashboards_service.list_dashboards.js | 67 +++++++++++++++++++ .../v1/dashboards_service.update_dashboard.js | 58 ++++++++++++++++ .../samples/package.json | 2 +- .../src/v1/dashboards_service_client.ts | 6 +- 7 files changed, 305 insertions(+), 3 deletions(-) create mode 100644 packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.create_dashboard.js create mode 100644 packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.delete_dashboard.js create mode 100644 packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.get_dashboard.js create mode 100644 packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.list_dashboards.js create mode 100644 packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.update_dashboard.js diff --git a/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.create_dashboard.js b/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.create_dashboard.js new file mode 100644 index 00000000000..4099e623938 --- /dev/null +++ b/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.create_dashboard.js @@ -0,0 +1,65 @@ +// 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, dashboard) { + // [START monitoring_v1_generated_DashboardsService_CreateDashboard_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project on which to execute the request. The format is: + * projects/[PROJECT_ID_OR_NUMBER] + * The `[PROJECT_ID_OR_NUMBER]` must match the dashboard resource name. + */ + // const parent = 'abc123' + /** + * Required. The initial dashboard specification. + */ + // const dashboard = '' + /** + * If set, validate the request and preview the review, but do not actually + * save it. + */ + // const validateOnly = true + + // Imports the Dashboard library + const {DashboardsServiceClient} = + require('@google-cloud/monitoring-dashboards').v1; + + // Instantiates a client + const dashboardClient = new DashboardsServiceClient(); + + async function createDashboard() { + // Construct request + const request = { + parent, + dashboard, + }; + + // Run request + const response = await dashboardClient.createDashboard(request); + console.log(response); + } + + createDashboard(); + // [END monitoring_v1_generated_DashboardsService_CreateDashboard_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.delete_dashboard.js b/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.delete_dashboard.js new file mode 100644 index 00000000000..855c7b5a1eb --- /dev/null +++ b/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.delete_dashboard.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 monitoring_v1_generated_DashboardsService_DeleteDashboard_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Dashboard. The format is: + * projects/[PROJECT_ID_OR_NUMBER]/dashboards/[DASHBOARD_ID] + */ + // const name = 'abc123' + + // Imports the Dashboard library + const {DashboardsServiceClient} = + require('@google-cloud/monitoring-dashboards').v1; + + // Instantiates a client + const dashboardClient = new DashboardsServiceClient(); + + async function deleteDashboard() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await dashboardClient.deleteDashboard(request); + console.log(response); + } + + deleteDashboard(); + // [END monitoring_v1_generated_DashboardsService_DeleteDashboard_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.get_dashboard.js b/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.get_dashboard.js new file mode 100644 index 00000000000..1b9d2536246 --- /dev/null +++ b/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.get_dashboard.js @@ -0,0 +1,56 @@ +// 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 monitoring_v1_generated_DashboardsService_GetDashboard_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Dashboard. The format is one of: + * - `dashboards/[DASHBOARD_ID]` (for system dashboards) + * - `projects/[PROJECT_ID_OR_NUMBER]/dashboards/[DASHBOARD_ID]` + * (for custom dashboards). + */ + // const name = 'abc123' + + // Imports the Dashboard library + const {DashboardsServiceClient} = + require('@google-cloud/monitoring-dashboards').v1; + + // Instantiates a client + const dashboardClient = new DashboardsServiceClient(); + + async function getDashboard() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await dashboardClient.getDashboard(request); + console.log(response); + } + + getDashboard(); + // [END monitoring_v1_generated_DashboardsService_GetDashboard_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.list_dashboards.js b/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.list_dashboards.js new file mode 100644 index 00000000000..f47bb407f61 --- /dev/null +++ b/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.list_dashboards.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 monitoring_v1_generated_DashboardsService_ListDashboards_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The scope of the dashboards to list. The format is: + * projects/[PROJECT_ID_OR_NUMBER] + */ + // const parent = 'abc123' + /** + * A positive number that is the maximum number of results to return. + * If unspecified, a default of 1000 is used. + */ + // const pageSize = 1234 + /** + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + */ + // const pageToken = 'abc123' + + // Imports the Dashboard library + const {DashboardsServiceClient} = + require('@google-cloud/monitoring-dashboards').v1; + + // Instantiates a client + const dashboardClient = new DashboardsServiceClient(); + + async function listDashboards() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await dashboardClient.listDashboardsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + listDashboards(); + // [END monitoring_v1_generated_DashboardsService_ListDashboards_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.update_dashboard.js b/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.update_dashboard.js new file mode 100644 index 00000000000..43f4cc96619 --- /dev/null +++ b/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.update_dashboard.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(dashboard) { + // [START monitoring_v1_generated_DashboardsService_UpdateDashboard_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The dashboard that will replace the existing dashboard. + */ + // const dashboard = '' + /** + * If set, validate the request and preview the review, but do not actually + * save it. + */ + // const validateOnly = true + + // Imports the Dashboard library + const {DashboardsServiceClient} = + require('@google-cloud/monitoring-dashboards').v1; + + // Instantiates a client + const dashboardClient = new DashboardsServiceClient(); + + async function updateDashboard() { + // Construct request + const request = { + dashboard, + }; + + // Run request + const response = await dashboardClient.updateDashboard(request); + console.log(response); + } + + updateDashboard(); + // [END monitoring_v1_generated_DashboardsService_UpdateDashboard_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-monitoring-dashboard/samples/package.json b/packages/google-monitoring-dashboard/samples/package.json index 5468955fbf9..0b5742b3b86 100644 --- a/packages/google-monitoring-dashboard/samples/package.json +++ b/packages/google-monitoring-dashboard/samples/package.json @@ -4,7 +4,7 @@ "license": "Apache-2.0", "author": "Google LLC", "engines": { - "node": ">=8" + "node": ">=10" }, "files": [ "*.js" diff --git a/packages/google-monitoring-dashboard/src/v1/dashboards_service_client.ts b/packages/google-monitoring-dashboard/src/v1/dashboards_service_client.ts index 170124b167e..d39343d1aab 100644 --- a/packages/google-monitoring-dashboard/src/v1/dashboards_service_client.ts +++ b/packages/google-monitoring-dashboard/src/v1/dashboards_service_client.ts @@ -873,7 +873,8 @@ export class DashboardsServiceClient { gax.routingHeader.fromParams({ parent: request.parent || '', }); - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listDashboards']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listDashboards.createStream( this.innerApiCalls.listDashboards as gax.GaxCall, @@ -928,7 +929,8 @@ export class DashboardsServiceClient { parent: request.parent || '', }); options = options || {}; - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listDashboards']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listDashboards.asyncIterate( this.innerApiCalls['listDashboards'] as GaxCall,