diff --git a/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.delete_resource.js b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.delete_resource.js index efc3f9de82f..175c0b63c30 100644 --- a/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.delete_resource.js +++ b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.delete_resource.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-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.get_resource.js b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.get_resource.js index 785db18697b..0fa94673477 100644 --- a/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.get_resource.js +++ b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.get_resource.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-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.patch_resource.js b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.patch_resource.js index ce00bce9d93..b317496df66 100644 --- a/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.patch_resource.js +++ b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.patch_resource.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-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.post_resource.js b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.post_resource.js index 530e6f22a87..e707127b774 100644 --- a/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.post_resource.js +++ b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.post_resource.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-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.put_resource.js b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.put_resource.js index bb7b27c6348..2326f91bdca 100644 --- a/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.put_resource.js +++ b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/gateway_service.put_resource.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-gkeconnect-gateway/samples/generated/v1beta1/snippet_metadata.google.cloud.gkeconnect.gateway.v1beta1.json b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/snippet_metadata.google.cloud.gkeconnect.gateway.v1beta1.json new file mode 100644 index 00000000000..e326d26df55 --- /dev/null +++ b/packages/google-cloud-gkeconnect-gateway/samples/generated/v1beta1/snippet_metadata.google.cloud.gkeconnect.gateway.v1beta1.json @@ -0,0 +1,255 @@ +{ + "clientLibrary": { + "name": "nodejs-gateway", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.gkeconnect.gateway.v1beta1", + "version": "v1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "connectgateway_v1beta1_generated_GatewayService_GetResource_async", + "title": "GatewayService getResource Sample", + "origin": "API_DEFINITION", + "description": " GetResource performs an HTTP GET request on the Kubernetes API Server.", + "canonical": true, + "file": "gateway_service.get_resource.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetResource", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService.GetResource", + "async": true, + "parameters": [ + { + "name": "content_type", + "type": "TYPE_STRING" + }, + { + "name": "data", + "type": "TYPE_BYTES" + }, + { + "name": "extensions", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "GatewayServiceClient", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayServiceClient" + }, + "method": { + "shortName": "GetResource", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService.GetResource", + "service": { + "shortName": "GatewayService", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService" + } + } + } + }, + { + "regionTag": "connectgateway_v1beta1_generated_GatewayService_PostResource_async", + "title": "GatewayService postResource Sample", + "origin": "API_DEFINITION", + "description": " PostResource performs an HTTP POST on the Kubernetes API Server.", + "canonical": true, + "file": "gateway_service.post_resource.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PostResource", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PostResource", + "async": true, + "parameters": [ + { + "name": "content_type", + "type": "TYPE_STRING" + }, + { + "name": "data", + "type": "TYPE_BYTES" + }, + { + "name": "extensions", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "GatewayServiceClient", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayServiceClient" + }, + "method": { + "shortName": "PostResource", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PostResource", + "service": { + "shortName": "GatewayService", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService" + } + } + } + }, + { + "regionTag": "connectgateway_v1beta1_generated_GatewayService_DeleteResource_async", + "title": "GatewayService deleteResource Sample", + "origin": "API_DEFINITION", + "description": " DeleteResource performs an HTTP DELETE on the Kubernetes API Server.", + "canonical": true, + "file": "gateway_service.delete_resource.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteResource", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService.DeleteResource", + "async": true, + "parameters": [ + { + "name": "content_type", + "type": "TYPE_STRING" + }, + { + "name": "data", + "type": "TYPE_BYTES" + }, + { + "name": "extensions", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "GatewayServiceClient", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayServiceClient" + }, + "method": { + "shortName": "DeleteResource", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService.DeleteResource", + "service": { + "shortName": "GatewayService", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService" + } + } + } + }, + { + "regionTag": "connectgateway_v1beta1_generated_GatewayService_PutResource_async", + "title": "GatewayService putResource Sample", + "origin": "API_DEFINITION", + "description": " PutResource performs an HTTP PUT on the Kubernetes API Server.", + "canonical": true, + "file": "gateway_service.put_resource.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PutResource", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PutResource", + "async": true, + "parameters": [ + { + "name": "content_type", + "type": "TYPE_STRING" + }, + { + "name": "data", + "type": "TYPE_BYTES" + }, + { + "name": "extensions", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "GatewayServiceClient", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayServiceClient" + }, + "method": { + "shortName": "PutResource", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PutResource", + "service": { + "shortName": "GatewayService", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService" + } + } + } + }, + { + "regionTag": "connectgateway_v1beta1_generated_GatewayService_PatchResource_async", + "title": "GatewayService patchResource Sample", + "origin": "API_DEFINITION", + "description": " PatchResource performs an HTTP PATCH on the Kubernetes API Server.", + "canonical": true, + "file": "gateway_service.patch_resource.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PatchResource", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PatchResource", + "async": true, + "parameters": [ + { + "name": "content_type", + "type": "TYPE_STRING" + }, + { + "name": "data", + "type": "TYPE_BYTES" + }, + { + "name": "extensions", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "GatewayServiceClient", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayServiceClient" + }, + "method": { + "shortName": "PatchResource", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService.PatchResource", + "service": { + "shortName": "GatewayService", + "fullName": "google.cloud.gkeconnect.gateway.v1beta1.GatewayService" + } + } + } + } + ] +} diff --git a/packages/google-cloud-gkeconnect-gateway/src/v1beta1/gateway_service_client.ts b/packages/google-cloud-gkeconnect-gateway/src/v1beta1/gateway_service_client.ts index 2eadc1d29f6..95f66c072b8 100644 --- a/packages/google-cloud-gkeconnect-gateway/src/v1beta1/gateway_service_client.ts +++ b/packages/google-cloud-gkeconnect-gateway/src/v1beta1/gateway_service_client.ts @@ -720,9 +720,8 @@ export class GatewayServiceClient { * @returns {Promise} A promise that resolves when the client is closed. */ close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.gatewayServiceStub!.then(stub => { + if (this.gatewayServiceStub && !this._terminated) { + return this.gatewayServiceStub.then(stub => { this._terminated = true; stub.close(); }); diff --git a/packages/google-cloud-gkeconnect-gateway/test/gapic_gateway_service_v1beta1.ts b/packages/google-cloud-gkeconnect-gateway/test/gapic_gateway_service_v1beta1.ts index 8dac7c810b7..41665ef55d6 100644 --- a/packages/google-cloud-gkeconnect-gateway/test/gapic_gateway_service_v1beta1.ts +++ b/packages/google-cloud-gkeconnect-gateway/test/gapic_gateway_service_v1beta1.ts @@ -90,12 +90,27 @@ describe('v1beta1.GatewayServiceClient', () => { assert(client.gatewayServiceStub); }); - it('has close method', () => { + it('has close method for the initialized client', done => { const client = new gatewayserviceModule.v1beta1.GatewayServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - client.close(); + client.initialize(); + assert(client.gatewayServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new gatewayserviceModule.v1beta1.GatewayServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.gatewayServiceStub, undefined); + client.close().then(() => { + done(); + }); }); it('has getProjectId method', async () => { @@ -208,6 +223,18 @@ describe('v1beta1.GatewayServiceClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + it('invokes getResource with closed client', async () => { + const client = new gatewayserviceModule.v1beta1.GatewayServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.api.HttpBody()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getResource(request), expectedError); + }); }); describe('postResource', () => { @@ -286,6 +313,18 @@ describe('v1beta1.GatewayServiceClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + it('invokes postResource with closed client', async () => { + const client = new gatewayserviceModule.v1beta1.GatewayServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.api.HttpBody()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.postResource(request), expectedError); + }); }); describe('deleteResource', () => { @@ -364,6 +403,18 @@ describe('v1beta1.GatewayServiceClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + it('invokes deleteResource with closed client', async () => { + const client = new gatewayserviceModule.v1beta1.GatewayServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.api.HttpBody()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteResource(request), expectedError); + }); }); describe('putResource', () => { @@ -442,6 +493,18 @@ describe('v1beta1.GatewayServiceClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + it('invokes putResource with closed client', async () => { + const client = new gatewayserviceModule.v1beta1.GatewayServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.api.HttpBody()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.putResource(request), expectedError); + }); }); describe('patchResource', () => { @@ -520,5 +583,17 @@ describe('v1beta1.GatewayServiceClient', () => { .calledWith(request, expectedOptions, undefined) ); }); + + it('invokes patchResource with closed client', async () => { + const client = new gatewayserviceModule.v1beta1.GatewayServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.api.HttpBody()); + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.patchResource(request), expectedError); + }); }); });