Skip to content

Commit

Permalink
docs(samples): include metadata file, add exclusions for samples to h…
Browse files Browse the repository at this point in the history
…andwritten libraries (#67)

- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 429395631

Source-Link: googleapis/googleapis@84594b3

Source-Link: googleapis/googleapis-gen@ed74f97
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWQ3NGY5NzBmZDgyOTE0ODc0ZTZiMjdiMDQ3NjNjZmE2NmJhZmU5YiJ9
  • Loading branch information
gcf-owl-bot[bot] authored Feb 18, 2022
1 parent c94f8ce commit f6d719f
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
{
"clientLibrary": {
"name": "nodejs-vpcaccess",
"version": "0.1.0",
"language": "TYPESCRIPT",
"apis": [
{
"id": "google.cloud.vpcaccess.v1",
"version": "v1"
}
]
},
"snippets": [
{
"regionTag": "vpcaccess_v1_generated_VpcAccessService_CreateConnector_async",
"title": "VpcAccessService createConnector Sample",
"origin": "API_DEFINITION",
"description": " Creates a Serverless VPC Access connector, returns an operation.",
"canonical": true,
"file": "vpc_access_service.create_connector.js",
"language": "JAVASCRIPT",
"segments": [
{
"start": 25,
"end": 62,
"type": "FULL"
}
],
"clientMethod": {
"shortName": "CreateConnector",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.CreateConnector",
"async": true,
"parameters": [
{
"name": "parent",
"type": "TYPE_STRING"
},
{
"name": "connector_id",
"type": "TYPE_STRING"
},
{
"name": "connector",
"type": ".google.cloud.vpcaccess.v1.Connector"
}
],
"resultType": ".google.longrunning.Operation",
"client": {
"shortName": "VpcAccessServiceClient",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessServiceClient"
},
"method": {
"shortName": "CreateConnector",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.CreateConnector",
"service": {
"shortName": "VpcAccessService",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService"
}
}
}
},
{
"regionTag": "vpcaccess_v1_generated_VpcAccessService_GetConnector_async",
"title": "VpcAccessService getConnector Sample",
"origin": "API_DEFINITION",
"description": " Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.",
"canonical": true,
"file": "vpc_access_service.get_connector.js",
"language": "JAVASCRIPT",
"segments": [
{
"start": 25,
"end": 50,
"type": "FULL"
}
],
"clientMethod": {
"shortName": "GetConnector",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.GetConnector",
"async": true,
"parameters": [
{
"name": "name",
"type": "TYPE_STRING"
}
],
"resultType": ".google.cloud.vpcaccess.v1.Connector",
"client": {
"shortName": "VpcAccessServiceClient",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessServiceClient"
},
"method": {
"shortName": "GetConnector",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.GetConnector",
"service": {
"shortName": "VpcAccessService",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService"
}
}
}
},
{
"regionTag": "vpcaccess_v1_generated_VpcAccessService_ListConnectors_async",
"title": "VpcAccessService listConnectors Sample",
"origin": "API_DEFINITION",
"description": " Lists Serverless VPC Access connectors.",
"canonical": true,
"file": "vpc_access_service.list_connectors.js",
"language": "JAVASCRIPT",
"segments": [
{
"start": 25,
"end": 60,
"type": "FULL"
}
],
"clientMethod": {
"shortName": "ListConnectors",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.ListConnectors",
"async": true,
"parameters": [
{
"name": "parent",
"type": "TYPE_STRING"
},
{
"name": "page_size",
"type": "TYPE_INT32"
},
{
"name": "page_token",
"type": "TYPE_STRING"
}
],
"resultType": ".google.cloud.vpcaccess.v1.ListConnectorsResponse",
"client": {
"shortName": "VpcAccessServiceClient",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessServiceClient"
},
"method": {
"shortName": "ListConnectors",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.ListConnectors",
"service": {
"shortName": "VpcAccessService",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService"
}
}
}
},
{
"regionTag": "vpcaccess_v1_generated_VpcAccessService_DeleteConnector_async",
"title": "VpcAccessService deleteConnector Sample",
"origin": "API_DEFINITION",
"description": " Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.",
"canonical": true,
"file": "vpc_access_service.delete_connector.js",
"language": "JAVASCRIPT",
"segments": [
{
"start": 25,
"end": 51,
"type": "FULL"
}
],
"clientMethod": {
"shortName": "DeleteConnector",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.DeleteConnector",
"async": true,
"parameters": [
{
"name": "name",
"type": "TYPE_STRING"
}
],
"resultType": ".google.longrunning.Operation",
"client": {
"shortName": "VpcAccessServiceClient",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessServiceClient"
},
"method": {
"shortName": "DeleteConnector",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService.DeleteConnector",
"service": {
"shortName": "VpcAccessService",
"fullName": "google.cloud.vpcaccess.v1.VpcAccessService"
}
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1019,9 +1019,8 @@ export class VpcAccessServiceClient {
* @returns {Promise} A promise that resolves when the client is closed.
*/
close(): Promise<void> {
this.initialize();
if (!this._terminated) {
return this.vpcAccessServiceStub!.then(stub => {
if (this.vpcAccessServiceStub && !this._terminated) {
return this.vpcAccessServiceStub.then(stub => {
this._terminated = true;
stub.close();
this.operationsClient.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,27 @@ describe('v1.VpcAccessServiceClient', () => {
assert(client.vpcAccessServiceStub);
});

it('has close method', () => {
it('has close method for the initialized client', done => {
const client = new vpcaccessserviceModule.v1.VpcAccessServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.close();
client.initialize();
assert(client.vpcAccessServiceStub);
client.close().then(() => {
done();
});
});

it('has close method for the non-initialized client', done => {
const client = new vpcaccessserviceModule.v1.VpcAccessServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
assert.strictEqual(client.vpcAccessServiceStub, undefined);
client.close().then(() => {
done();
});
});

it('has getProjectId method', async () => {
Expand Down Expand Up @@ -336,6 +351,22 @@ describe('v1.VpcAccessServiceClient', () => {
.calledWith(request, expectedOptions, undefined)
);
});

it('invokes getConnector with closed client', async () => {
const client = new vpcaccessserviceModule.v1.VpcAccessServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
const request = generateSampleMessage(
new protos.google.cloud.vpcaccess.v1.GetConnectorRequest()
);
request.name = '';
const expectedHeaderRequestParams = 'name=';
const expectedError = new Error('The client has already been closed.');
client.close();
await assert.rejects(client.getConnector(request), expectedError);
});
});

describe('createConnector', () => {
Expand Down

0 comments on commit f6d719f

Please sign in to comment.