diff --git a/packages/google-monitoring-dashboard/linkinator.config.json b/packages/google-monitoring-dashboard/linkinator.config.json index 0121dfa684f..befd23c8633 100644 --- a/packages/google-monitoring-dashboard/linkinator.config.json +++ b/packages/google-monitoring-dashboard/linkinator.config.json @@ -3,8 +3,14 @@ "skip": [ "https://codecov.io/gh/googleapis/", "www.googleapis.com", - "img.shields.io" + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" ], "silent": true, - "concurrency": 5 + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 } 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 index c294e7ce90f..a57de83932f 100644 --- 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 @@ -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-monitoring-dashboard/samples/generated/v1/dashboards_service.delete_dashboard.js b/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.delete_dashboard.js index 24c8560d91d..b18a86cd5f9 100644 --- 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 @@ -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-monitoring-dashboard/samples/generated/v1/dashboards_service.get_dashboard.js b/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.get_dashboard.js index 6d9416c607b..9594ed7c9f1 100644 --- 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 @@ -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-monitoring-dashboard/samples/generated/v1/dashboards_service.list_dashboards.js b/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.list_dashboards.js index e408bc146d7..674a79b86d8 100644 --- 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 @@ -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-monitoring-dashboard/samples/generated/v1/dashboards_service.update_dashboard.js b/packages/google-monitoring-dashboard/samples/generated/v1/dashboards_service.update_dashboard.js index e04edc0e95f..39e61da4ab8 100644 --- 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 @@ -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-monitoring-dashboard/samples/generated/v1/snippet_metadata.google.monitoring.dashboard.v1.json b/packages/google-monitoring-dashboard/samples/generated/v1/snippet_metadata.google.monitoring.dashboard.v1.json new file mode 100644 index 00000000000..26f912e681b --- /dev/null +++ b/packages/google-monitoring-dashboard/samples/generated/v1/snippet_metadata.google.monitoring.dashboard.v1.json @@ -0,0 +1,235 @@ +{ + "clientLibrary": { + "name": "nodejs-dashboard", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.monitoring.dashboard.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "monitoring_v1_generated_DashboardsService_CreateDashboard_async", + "title": "DashboardsService createDashboard Sample", + "origin": "API_DEFINITION", + "description": " Creates a new custom dashboard. For examples on how you can use this API to create dashboards, see [Managing dashboards by API](https://cloud.google.com/monitoring/dashboards/api-dashboard). This method requires the `monitoring.dashboards.create` permission on the specified project. For more information about permissions, see [Cloud Identity and Access Management](https://cloud.google.com/iam).", + "canonical": true, + "file": "dashboards_service.create_dashboard.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateDashboard", + "fullName": "google.monitoring.dashboard.v1.DashboardsService.CreateDashboard", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "dashboard", + "type": ".google.monitoring.dashboard.v1.Dashboard" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.monitoring.dashboard.v1.Dashboard", + "client": { + "shortName": "DashboardsServiceClient", + "fullName": "google.monitoring.dashboard.v1.DashboardsServiceClient" + }, + "method": { + "shortName": "CreateDashboard", + "fullName": "google.monitoring.dashboard.v1.DashboardsService.CreateDashboard", + "service": { + "shortName": "DashboardsService", + "fullName": "google.monitoring.dashboard.v1.DashboardsService" + } + } + } + }, + { + "regionTag": "monitoring_v1_generated_DashboardsService_ListDashboards_async", + "title": "DashboardsService listDashboards Sample", + "origin": "API_DEFINITION", + "description": " Lists the existing dashboards. This method requires the `monitoring.dashboards.list` permission on the specified project. For more information, see [Cloud Identity and Access Management](https://cloud.google.com/iam).", + "canonical": true, + "file": "dashboards_service.list_dashboards.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListDashboards", + "fullName": "google.monitoring.dashboard.v1.DashboardsService.ListDashboards", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.monitoring.dashboard.v1.ListDashboardsResponse", + "client": { + "shortName": "DashboardsServiceClient", + "fullName": "google.monitoring.dashboard.v1.DashboardsServiceClient" + }, + "method": { + "shortName": "ListDashboards", + "fullName": "google.monitoring.dashboard.v1.DashboardsService.ListDashboards", + "service": { + "shortName": "DashboardsService", + "fullName": "google.monitoring.dashboard.v1.DashboardsService" + } + } + } + }, + { + "regionTag": "monitoring_v1_generated_DashboardsService_GetDashboard_async", + "title": "DashboardsService getDashboard Sample", + "origin": "API_DEFINITION", + "description": " Fetches a specific dashboard. This method requires the `monitoring.dashboards.get` permission on the specified dashboard. For more information, see [Cloud Identity and Access Management](https://cloud.google.com/iam).", + "canonical": true, + "file": "dashboards_service.get_dashboard.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDashboard", + "fullName": "google.monitoring.dashboard.v1.DashboardsService.GetDashboard", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.monitoring.dashboard.v1.Dashboard", + "client": { + "shortName": "DashboardsServiceClient", + "fullName": "google.monitoring.dashboard.v1.DashboardsServiceClient" + }, + "method": { + "shortName": "GetDashboard", + "fullName": "google.monitoring.dashboard.v1.DashboardsService.GetDashboard", + "service": { + "shortName": "DashboardsService", + "fullName": "google.monitoring.dashboard.v1.DashboardsService" + } + } + } + }, + { + "regionTag": "monitoring_v1_generated_DashboardsService_DeleteDashboard_async", + "title": "DashboardsService deleteDashboard Sample", + "origin": "API_DEFINITION", + "description": " Deletes an existing custom dashboard. This method requires the `monitoring.dashboards.delete` permission on the specified dashboard. For more information, see [Cloud Identity and Access Management](https://cloud.google.com/iam).", + "canonical": true, + "file": "dashboards_service.delete_dashboard.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteDashboard", + "fullName": "google.monitoring.dashboard.v1.DashboardsService.DeleteDashboard", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "DashboardsServiceClient", + "fullName": "google.monitoring.dashboard.v1.DashboardsServiceClient" + }, + "method": { + "shortName": "DeleteDashboard", + "fullName": "google.monitoring.dashboard.v1.DashboardsService.DeleteDashboard", + "service": { + "shortName": "DashboardsService", + "fullName": "google.monitoring.dashboard.v1.DashboardsService" + } + } + } + }, + { + "regionTag": "monitoring_v1_generated_DashboardsService_UpdateDashboard_async", + "title": "DashboardsService updateDashboard Sample", + "origin": "API_DEFINITION", + "description": " Replaces an existing custom dashboard with a new definition. This method requires the `monitoring.dashboards.update` permission on the specified dashboard. For more information, see [Cloud Identity and Access Management](https://cloud.google.com/iam).", + "canonical": true, + "file": "dashboards_service.update_dashboard.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateDashboard", + "fullName": "google.monitoring.dashboard.v1.DashboardsService.UpdateDashboard", + "async": true, + "parameters": [ + { + "name": "dashboard", + "type": ".google.monitoring.dashboard.v1.Dashboard" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.monitoring.dashboard.v1.Dashboard", + "client": { + "shortName": "DashboardsServiceClient", + "fullName": "google.monitoring.dashboard.v1.DashboardsServiceClient" + }, + "method": { + "shortName": "UpdateDashboard", + "fullName": "google.monitoring.dashboard.v1.DashboardsService.UpdateDashboard", + "service": { + "shortName": "DashboardsService", + "fullName": "google.monitoring.dashboard.v1.DashboardsService" + } + } + } + } + ] +} 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 8e68d7b0cc5..ec613a1af10 100644 --- a/packages/google-monitoring-dashboard/src/v1/dashboards_service_client.ts +++ b/packages/google-monitoring-dashboard/src/v1/dashboards_service_client.ts @@ -1044,9 +1044,8 @@ export class DashboardsServiceClient { * @returns {Promise} A promise that resolves when the client is closed. */ close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.dashboardsServiceStub!.then(stub => { + if (this.dashboardsServiceStub && !this._terminated) { + return this.dashboardsServiceStub.then(stub => { this._terminated = true; stub.close(); }); diff --git a/packages/google-monitoring-dashboard/test/gapic_dashboards_service_v1.ts b/packages/google-monitoring-dashboard/test/gapic_dashboards_service_v1.ts index 1a7941f2b37..4119d470a73 100644 --- a/packages/google-monitoring-dashboard/test/gapic_dashboards_service_v1.ts +++ b/packages/google-monitoring-dashboard/test/gapic_dashboards_service_v1.ts @@ -153,12 +153,27 @@ describe('v1.DashboardsServiceClient', () => { assert(client.dashboardsServiceStub); }); - it('has close method', () => { + it('has close method for the initialized client', done => { const client = new dashboardsserviceModule.v1.DashboardsServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - client.close(); + client.initialize(); + assert(client.dashboardsServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new dashboardsserviceModule.v1.DashboardsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.dashboardsServiceStub, undefined); + client.close().then(() => { + done(); + }); }); it('has getProjectId method', async () => { @@ -304,6 +319,22 @@ describe('v1.DashboardsServiceClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + it('invokes createDashboard with closed client', async () => { + const client = new dashboardsserviceModule.v1.DashboardsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.dashboard.v1.CreateDashboardRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createDashboard(request), expectedError); + }); }); describe('getDashboard', () => { @@ -415,6 +446,22 @@ describe('v1.DashboardsServiceClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + it('invokes getDashboard with closed client', async () => { + const client = new dashboardsserviceModule.v1.DashboardsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.dashboard.v1.GetDashboardRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDashboard(request), expectedError); + }); }); describe('deleteDashboard', () => { @@ -526,6 +573,22 @@ describe('v1.DashboardsServiceClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + it('invokes deleteDashboard with closed client', async () => { + const client = new dashboardsserviceModule.v1.DashboardsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.dashboard.v1.DeleteDashboardRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteDashboard(request), expectedError); + }); }); describe('updateDashboard', () => { @@ -640,6 +703,23 @@ describe('v1.DashboardsServiceClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + it('invokes updateDashboard with closed client', async () => { + const client = new dashboardsserviceModule.v1.DashboardsServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.monitoring.dashboard.v1.UpdateDashboardRequest() + ); + request.dashboard = {}; + request.dashboard.name = ''; + const expectedHeaderRequestParams = 'dashboard.name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateDashboard(request), expectedError); + }); }); describe('listDashboards', () => {