Skip to content

Commit c61c170

Browse files
docs(samples): include metadata file, add exclusions for samples to handwritten libraries (#67)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 429395631 Source-Link: googleapis/googleapis@84594b3 Source-Link: googleapis/googleapis-gen@ed74f97 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWQ3NGY5NzBmZDgyOTE0ODc0ZTZiMjdiMDQ3NjNjZmE2NmJhZmU5YiJ9
1 parent a4315fa commit c61c170

7 files changed

Lines changed: 254 additions & 13 deletions
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
{
2+
"clientLibrary": {
3+
"name": "nodejs-vpcaccess",
4+
"version": "0.1.0",
5+
"language": "TYPESCRIPT",
6+
"apis": [
7+
{
8+
"id": "google.cloud.vpcaccess.v1",
9+
"version": "v1"
10+
}
11+
]
12+
},
13+
"snippets": [
14+
{
15+
"regionTag": "vpcaccess_v1_generated_VpcAccessService_CreateConnector_async",
16+
"title": "VpcAccessService createConnector Sample",
17+
"origin": "API_DEFINITION",
18+
"description": " Creates a Serverless VPC Access connector, returns an operation.",
19+
"canonical": true,
20+
"file": "vpc_access_service.create_connector.js",
21+
"language": "JAVASCRIPT",
22+
"segments": [
23+
{
24+
"start": 25,
25+
"end": 62,
26+
"type": "FULL"
27+
}
28+
],
29+
"clientMethod": {
30+
"shortName": "CreateConnector",
31+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.CreateConnector",
32+
"async": true,
33+
"parameters": [
34+
{
35+
"name": "parent",
36+
"type": "TYPE_STRING"
37+
},
38+
{
39+
"name": "connector_id",
40+
"type": "TYPE_STRING"
41+
},
42+
{
43+
"name": "connector",
44+
"type": ".google.cloud.vpcaccess.v1.Connector"
45+
}
46+
],
47+
"resultType": ".google.longrunning.Operation",
48+
"client": {
49+
"shortName": "VpcAccessServiceClient",
50+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessServiceClient"
51+
},
52+
"method": {
53+
"shortName": "CreateConnector",
54+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.CreateConnector",
55+
"service": {
56+
"shortName": "VpcAccessService",
57+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService"
58+
}
59+
}
60+
}
61+
},
62+
{
63+
"regionTag": "vpcaccess_v1_generated_VpcAccessService_GetConnector_async",
64+
"title": "VpcAccessService getConnector Sample",
65+
"origin": "API_DEFINITION",
66+
"description": " Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.",
67+
"canonical": true,
68+
"file": "vpc_access_service.get_connector.js",
69+
"language": "JAVASCRIPT",
70+
"segments": [
71+
{
72+
"start": 25,
73+
"end": 50,
74+
"type": "FULL"
75+
}
76+
],
77+
"clientMethod": {
78+
"shortName": "GetConnector",
79+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.GetConnector",
80+
"async": true,
81+
"parameters": [
82+
{
83+
"name": "name",
84+
"type": "TYPE_STRING"
85+
}
86+
],
87+
"resultType": ".google.cloud.vpcaccess.v1.Connector",
88+
"client": {
89+
"shortName": "VpcAccessServiceClient",
90+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessServiceClient"
91+
},
92+
"method": {
93+
"shortName": "GetConnector",
94+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.GetConnector",
95+
"service": {
96+
"shortName": "VpcAccessService",
97+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService"
98+
}
99+
}
100+
}
101+
},
102+
{
103+
"regionTag": "vpcaccess_v1_generated_VpcAccessService_ListConnectors_async",
104+
"title": "VpcAccessService listConnectors Sample",
105+
"origin": "API_DEFINITION",
106+
"description": " Lists Serverless VPC Access connectors.",
107+
"canonical": true,
108+
"file": "vpc_access_service.list_connectors.js",
109+
"language": "JAVASCRIPT",
110+
"segments": [
111+
{
112+
"start": 25,
113+
"end": 60,
114+
"type": "FULL"
115+
}
116+
],
117+
"clientMethod": {
118+
"shortName": "ListConnectors",
119+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.ListConnectors",
120+
"async": true,
121+
"parameters": [
122+
{
123+
"name": "parent",
124+
"type": "TYPE_STRING"
125+
},
126+
{
127+
"name": "page_size",
128+
"type": "TYPE_INT32"
129+
},
130+
{
131+
"name": "page_token",
132+
"type": "TYPE_STRING"
133+
}
134+
],
135+
"resultType": ".google.cloud.vpcaccess.v1.ListConnectorsResponse",
136+
"client": {
137+
"shortName": "VpcAccessServiceClient",
138+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessServiceClient"
139+
},
140+
"method": {
141+
"shortName": "ListConnectors",
142+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.ListConnectors",
143+
"service": {
144+
"shortName": "VpcAccessService",
145+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService"
146+
}
147+
}
148+
}
149+
},
150+
{
151+
"regionTag": "vpcaccess_v1_generated_VpcAccessService_DeleteConnector_async",
152+
"title": "VpcAccessService deleteConnector Sample",
153+
"origin": "API_DEFINITION",
154+
"description": " Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.",
155+
"canonical": true,
156+
"file": "vpc_access_service.delete_connector.js",
157+
"language": "JAVASCRIPT",
158+
"segments": [
159+
{
160+
"start": 25,
161+
"end": 51,
162+
"type": "FULL"
163+
}
164+
],
165+
"clientMethod": {
166+
"shortName": "DeleteConnector",
167+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.DeleteConnector",
168+
"async": true,
169+
"parameters": [
170+
{
171+
"name": "name",
172+
"type": "TYPE_STRING"
173+
}
174+
],
175+
"resultType": ".google.longrunning.Operation",
176+
"client": {
177+
"shortName": "VpcAccessServiceClient",
178+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessServiceClient"
179+
},
180+
"method": {
181+
"shortName": "DeleteConnector",
182+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.DeleteConnector",
183+
"service": {
184+
"shortName": "VpcAccessService",
185+
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService"
186+
}
187+
}
188+
}
189+
}
190+
]
191+
}

packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.create_connector.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
// Copyright 2021 Google LLC
1+
// Copyright 2022 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// https://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
//
15+
// ** This file is automatically generated by gapic-generator-typescript. **
16+
// ** https://github.com/googleapis/gapic-generator-typescript **
17+
// ** All changes to this file may be overwritten. **
18+
1419

1520

1621
'use strict';

packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.delete_connector.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
// Copyright 2021 Google LLC
1+
// Copyright 2022 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// https://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
//
15+
// ** This file is automatically generated by gapic-generator-typescript. **
16+
// ** https://github.com/googleapis/gapic-generator-typescript **
17+
// ** All changes to this file may be overwritten. **
18+
1419

1520

1621
'use strict';

packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.get_connector.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
// Copyright 2021 Google LLC
1+
// Copyright 2022 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// https://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
//
15+
// ** This file is automatically generated by gapic-generator-typescript. **
16+
// ** https://github.com/googleapis/gapic-generator-typescript **
17+
// ** All changes to this file may be overwritten. **
18+
1419

1520

1621
'use strict';

packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.list_connectors.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
// Copyright 2021 Google LLC
1+
// Copyright 2022 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// https://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
//
15+
// ** This file is automatically generated by gapic-generator-typescript. **
16+
// ** https://github.com/googleapis/gapic-generator-typescript **
17+
// ** All changes to this file may be overwritten. **
18+
1419

1520

1621
'use strict';

packages/google-cloud-vpc-access/src/v1/vpc_access_service_client.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,9 +1019,8 @@ export class VpcAccessServiceClient {
10191019
* @returns {Promise} A promise that resolves when the client is closed.
10201020
*/
10211021
close(): Promise<void> {
1022-
this.initialize();
1023-
if (!this._terminated) {
1024-
return this.vpcAccessServiceStub!.then(stub => {
1022+
if (this.vpcAccessServiceStub && !this._terminated) {
1023+
return this.vpcAccessServiceStub.then(stub => {
10251024
this._terminated = true;
10261025
stub.close();
10271026
this.operationsClient.close();

packages/google-cloud-vpc-access/test/gapic_vpc_access_service_v1.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,27 @@ describe('v1.VpcAccessServiceClient', () => {
185185
assert(client.vpcAccessServiceStub);
186186
});
187187

188-
it('has close method', () => {
188+
it('has close method for the initialized client', done => {
189189
const client = new vpcaccessserviceModule.v1.VpcAccessServiceClient({
190190
credentials: {client_email: 'bogus', private_key: 'bogus'},
191191
projectId: 'bogus',
192192
});
193-
client.close();
193+
client.initialize();
194+
assert(client.vpcAccessServiceStub);
195+
client.close().then(() => {
196+
done();
197+
});
198+
});
199+
200+
it('has close method for the non-initialized client', done => {
201+
const client = new vpcaccessserviceModule.v1.VpcAccessServiceClient({
202+
credentials: {client_email: 'bogus', private_key: 'bogus'},
203+
projectId: 'bogus',
204+
});
205+
assert.strictEqual(client.vpcAccessServiceStub, undefined);
206+
client.close().then(() => {
207+
done();
208+
});
194209
});
195210

196211
it('has getProjectId method', async () => {
@@ -336,6 +351,22 @@ describe('v1.VpcAccessServiceClient', () => {
336351
.calledWith(request, expectedOptions, undefined)
337352
);
338353
});
354+
355+
it('invokes getConnector with closed client', async () => {
356+
const client = new vpcaccessserviceModule.v1.VpcAccessServiceClient({
357+
credentials: {client_email: 'bogus', private_key: 'bogus'},
358+
projectId: 'bogus',
359+
});
360+
client.initialize();
361+
const request = generateSampleMessage(
362+
new protos.google.cloud.vpcaccess.v1.GetConnectorRequest()
363+
);
364+
request.name = '';
365+
const expectedHeaderRequestParams = 'name=';
366+
const expectedError = new Error('The client has already been closed.');
367+
client.close();
368+
await assert.rejects(client.getConnector(request), expectedError);
369+
});
339370
});
340371

341372
describe('createConnector', () => {

0 commit comments

Comments
 (0)