diff --git a/packages/google-cloud-ids/linkinator.config.json b/packages/google-cloud-ids/linkinator.config.json index 0121dfa684f..befd23c8633 100644 --- a/packages/google-cloud-ids/linkinator.config.json +++ b/packages/google-cloud-ids/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-cloud-ids/samples/generated/v1/i_d_s.create_endpoint.js b/packages/google-cloud-ids/samples/generated/v1/i_d_s.create_endpoint.js index 614796d3981..23d114235b4 100644 --- a/packages/google-cloud-ids/samples/generated/v1/i_d_s.create_endpoint.js +++ b/packages/google-cloud-ids/samples/generated/v1/i_d_s.create_endpoint.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-ids/samples/generated/v1/i_d_s.delete_endpoint.js b/packages/google-cloud-ids/samples/generated/v1/i_d_s.delete_endpoint.js index 626f8265336..3d9877a677f 100644 --- a/packages/google-cloud-ids/samples/generated/v1/i_d_s.delete_endpoint.js +++ b/packages/google-cloud-ids/samples/generated/v1/i_d_s.delete_endpoint.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-ids/samples/generated/v1/i_d_s.get_endpoint.js b/packages/google-cloud-ids/samples/generated/v1/i_d_s.get_endpoint.js index b28916e6916..7805c92c0ba 100644 --- a/packages/google-cloud-ids/samples/generated/v1/i_d_s.get_endpoint.js +++ b/packages/google-cloud-ids/samples/generated/v1/i_d_s.get_endpoint.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-ids/samples/generated/v1/i_d_s.list_endpoints.js b/packages/google-cloud-ids/samples/generated/v1/i_d_s.list_endpoints.js index c355a58290d..ee669fc1b1c 100644 --- a/packages/google-cloud-ids/samples/generated/v1/i_d_s.list_endpoints.js +++ b/packages/google-cloud-ids/samples/generated/v1/i_d_s.list_endpoints.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-ids/samples/generated/v1/snippet_metadata.google.cloud.ids.v1.json b/packages/google-cloud-ids/samples/generated/v1/snippet_metadata.google.cloud.ids.v1.json new file mode 100644 index 00000000000..be95dd9b28a --- /dev/null +++ b/packages/google-cloud-ids/samples/generated/v1/snippet_metadata.google.cloud.ids.v1.json @@ -0,0 +1,207 @@ +{ + "clientLibrary": { + "name": "nodejs-ids", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.ids.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "ids_v1_generated_IDS_ListEndpoints_async", + "title": "IDS listEndpoints Sample", + "origin": "API_DEFINITION", + "description": " Lists Endpoints in a given project and location.", + "canonical": true, + "file": "i_d_s.list_endpoints.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 74, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListEndpoints", + "fullName": "google.cloud.ids.v1.IDS.ListEndpoints", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.ids.v1.ListEndpointsResponse", + "client": { + "shortName": "IDSClient", + "fullName": "google.cloud.ids.v1.IDSClient" + }, + "method": { + "shortName": "ListEndpoints", + "fullName": "google.cloud.ids.v1.IDS.ListEndpoints", + "service": { + "shortName": "IDS", + "fullName": "google.cloud.ids.v1.IDS" + } + } + } + }, + { + "regionTag": "ids_v1_generated_IDS_GetEndpoint_async", + "title": "IDS getEndpoint Sample", + "origin": "API_DEFINITION", + "description": " Gets details of a single Endpoint.", + "canonical": true, + "file": "i_d_s.get_endpoint.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetEndpoint", + "fullName": "google.cloud.ids.v1.IDS.GetEndpoint", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.ids.v1.Endpoint", + "client": { + "shortName": "IDSClient", + "fullName": "google.cloud.ids.v1.IDSClient" + }, + "method": { + "shortName": "GetEndpoint", + "fullName": "google.cloud.ids.v1.IDS.GetEndpoint", + "service": { + "shortName": "IDS", + "fullName": "google.cloud.ids.v1.IDS" + } + } + } + }, + { + "regionTag": "ids_v1_generated_IDS_CreateEndpoint_async", + "title": "IDS createEndpoint Sample", + "origin": "API_DEFINITION", + "description": " Creates a new Endpoint in a given project and location.", + "canonical": true, + "file": "i_d_s.create_endpoint.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateEndpoint", + "fullName": "google.cloud.ids.v1.IDS.CreateEndpoint", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "endpoint_id", + "type": "TYPE_STRING" + }, + { + "name": "endpoint", + "type": ".google.cloud.ids.v1.Endpoint" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "IDSClient", + "fullName": "google.cloud.ids.v1.IDSClient" + }, + "method": { + "shortName": "CreateEndpoint", + "fullName": "google.cloud.ids.v1.IDS.CreateEndpoint", + "service": { + "shortName": "IDS", + "fullName": "google.cloud.ids.v1.IDS" + } + } + } + }, + { + "regionTag": "ids_v1_generated_IDS_DeleteEndpoint_async", + "title": "IDS deleteEndpoint Sample", + "origin": "API_DEFINITION", + "description": " Deletes a single Endpoint.", + "canonical": true, + "file": "i_d_s.delete_endpoint.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteEndpoint", + "fullName": "google.cloud.ids.v1.IDS.DeleteEndpoint", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "IDSClient", + "fullName": "google.cloud.ids.v1.IDSClient" + }, + "method": { + "shortName": "DeleteEndpoint", + "fullName": "google.cloud.ids.v1.IDS.DeleteEndpoint", + "service": { + "shortName": "IDS", + "fullName": "google.cloud.ids.v1.IDS" + } + } + } + } + ] +} diff --git a/packages/google-cloud-ids/src/v1/i_d_s_client.ts b/packages/google-cloud-ids/src/v1/i_d_s_client.ts index 2bfc4dda487..a9f170a423f 100644 --- a/packages/google-cloud-ids/src/v1/i_d_s_client.ts +++ b/packages/google-cloud-ids/src/v1/i_d_s_client.ts @@ -1094,9 +1094,8 @@ export class IDSClient { * @returns {Promise} A promise that resolves when the client is closed. */ close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.iDSStub!.then(stub => { + if (this.iDSStub && !this._terminated) { + return this.iDSStub.then(stub => { this._terminated = true; stub.close(); this.operationsClient.close(); diff --git a/packages/google-cloud-ids/test/gapic_i_d_s_v1.ts b/packages/google-cloud-ids/test/gapic_i_d_s_v1.ts index 2d952652ba6..d8011d021b9 100644 --- a/packages/google-cloud-ids/test/gapic_i_d_s_v1.ts +++ b/packages/google-cloud-ids/test/gapic_i_d_s_v1.ts @@ -183,12 +183,27 @@ describe('v1.IDSClient', () => { assert(client.iDSStub); }); - it('has close method', () => { + it('has close method for the initialized client', done => { const client = new idsModule.v1.IDSClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - client.close(); + client.initialize(); + assert(client.iDSStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new idsModule.v1.IDSClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.iDSStub, undefined); + client.close().then(() => { + done(); + }); }); it('has getProjectId method', async () => { @@ -334,6 +349,22 @@ describe('v1.IDSClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + it('invokes getEndpoint with closed client', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.GetEndpointRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getEndpoint(request), expectedError); + }); }); describe('createEndpoint', () => {