From dccf6e94c70a25f9be5bcc0a3fea633bf8d43ce2 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 10 Nov 2021 21:38:37 +0000 Subject: [PATCH] docs(samples): add example tags to generated samples (#50) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 408439482 Source-Link: https://github.com/googleapis/googleapis/commit/b9f61843dc80c7c285fc34fd3a40aae55082c2b9 Source-Link: https://github.com/googleapis/googleapis-gen/commit/eb888bc214efc7bf43bf4634b470254565a659a5 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWI4ODhiYzIxNGVmYzdiZjQzYmY0NjM0YjQ3MDI1NDU2NWE2NTlhNSJ9 --- .../linkinator.config.json | 2 +- .../v1/vpc_access_service.create_connector.js | 64 ++++++ .../v1/vpc_access_service.delete_connector.js | 53 +++++ .../v1/vpc_access_service.get_connector.js | 52 +++++ .../v1/vpc_access_service.list_connectors.js | 62 ++++++ .../src/v1/vpc_access_service_client.ts | 202 +++++++++--------- 6 files changed, 328 insertions(+), 107 deletions(-) create mode 100644 packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.create_connector.js create mode 100644 packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.delete_connector.js create mode 100644 packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.get_connector.js create mode 100644 packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.list_connectors.js diff --git a/packages/google-cloud-vpc-access/linkinator.config.json b/packages/google-cloud-vpc-access/linkinator.config.json index 29a223b6db6..0121dfa684f 100644 --- a/packages/google-cloud-vpc-access/linkinator.config.json +++ b/packages/google-cloud-vpc-access/linkinator.config.json @@ -6,5 +6,5 @@ "img.shields.io" ], "silent": true, - "concurrency": 10 + "concurrency": 5 } diff --git a/packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.create_connector.js b/packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.create_connector.js new file mode 100644 index 00000000000..d8cb23ff16d --- /dev/null +++ b/packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.create_connector.js @@ -0,0 +1,64 @@ +// Copyright 2021 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 +// +// 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. + +'use strict'; + +function main(parent, connectorId, connector) { + // [START vpcaccess_v1_generated_VpcAccessService_CreateConnector_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project and location in which the configuration should be created, + * specified in the format `projects/* /locations/*`. + */ + // const parent = 'abc123' + /** + * Required. The ID to use for this connector. + */ + // const connectorId = 'abc123' + /** + * Required. Resource to create. + */ + // const connector = {} + + // Imports the Vpcaccess library + const {VpcAccessServiceClient} = require('@google-cloud/vpc-access').v1; + + // Instantiates a client + const vpcaccessClient = new VpcAccessServiceClient(); + + async function callCreateConnector() { + // Construct request + const request = { + parent, + connectorId, + connector, + }; + + // Run request + const [operation] = await vpcaccessClient.createConnector(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateConnector(); + // [END vpcaccess_v1_generated_VpcAccessService_CreateConnector_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.delete_connector.js b/packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.delete_connector.js new file mode 100644 index 00000000000..d588e30a221 --- /dev/null +++ b/packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.delete_connector.js @@ -0,0 +1,53 @@ +// Copyright 2021 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 +// +// 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. + +'use strict'; + +function main(name) { + // [START vpcaccess_v1_generated_VpcAccessService_DeleteConnector_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of a Serverless VPC Access connector to delete. + */ + // const name = 'abc123' + + // Imports the Vpcaccess library + const {VpcAccessServiceClient} = require('@google-cloud/vpc-access').v1; + + // Instantiates a client + const vpcaccessClient = new VpcAccessServiceClient(); + + async function callDeleteConnector() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await vpcaccessClient.deleteConnector(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteConnector(); + // [END vpcaccess_v1_generated_VpcAccessService_DeleteConnector_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.get_connector.js b/packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.get_connector.js new file mode 100644 index 00000000000..1c81b98addc --- /dev/null +++ b/packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.get_connector.js @@ -0,0 +1,52 @@ +// Copyright 2021 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 +// +// 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. + +'use strict'; + +function main(name) { + // [START vpcaccess_v1_generated_VpcAccessService_GetConnector_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of a Serverless VPC Access connector to get. + */ + // const name = 'abc123' + + // Imports the Vpcaccess library + const {VpcAccessServiceClient} = require('@google-cloud/vpc-access').v1; + + // Instantiates a client + const vpcaccessClient = new VpcAccessServiceClient(); + + async function callGetConnector() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await vpcaccessClient.getConnector(request); + console.log(response); + } + + callGetConnector(); + // [END vpcaccess_v1_generated_VpcAccessService_GetConnector_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.list_connectors.js b/packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.list_connectors.js new file mode 100644 index 00000000000..0742b01081f --- /dev/null +++ b/packages/google-cloud-vpc-access/samples/generated/v1/vpc_access_service.list_connectors.js @@ -0,0 +1,62 @@ +// Copyright 2021 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 +// +// 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. + +'use strict'; + +function main(parent) { + // [START vpcaccess_v1_generated_VpcAccessService_ListConnectors_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project and location from which the routes should be listed. + */ + // const parent = 'abc123' + /** + * Maximum number of functions to return per call. + */ + // const pageSize = 1234 + /** + * Continuation token. + */ + // const pageToken = 'abc123' + + // Imports the Vpcaccess library + const {VpcAccessServiceClient} = require('@google-cloud/vpc-access').v1; + + // Instantiates a client + const vpcaccessClient = new VpcAccessServiceClient(); + + async function callListConnectors() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await vpcaccessClient.listConnectorsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListConnectors(); + // [END vpcaccess_v1_generated_VpcAccessService_ListConnectors_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-vpc-access/src/v1/vpc_access_service_client.ts b/packages/google-cloud-vpc-access/src/v1/vpc_access_service_client.ts index 37f86b8eb24..20ce855b112 100644 --- a/packages/google-cloud-vpc-access/src/v1/vpc_access_service_client.ts +++ b/packages/google-cloud-vpc-access/src/v1/vpc_access_service_client.ts @@ -364,6 +364,24 @@ export class VpcAccessServiceClient { // ------------------- // -- Service calls -- // ------------------- + /** + * Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource + * does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of a Serverless VPC Access connector to get. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Connector]{@link google.cloud.vpcaccess.v1.Connector}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/vpc_access_service.get_connector.js + * region_tag:vpcaccess_v1_generated_VpcAccessService_GetConnector_async + */ getConnector( request?: protos.google.cloud.vpcaccess.v1.IGetConnectorRequest, options?: CallOptions @@ -391,24 +409,6 @@ export class VpcAccessServiceClient { {} | null | undefined > ): void; - /** - * Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource - * does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of a Serverless VPC Access connector to get. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Connector]{@link google.cloud.vpcaccess.v1.Connector}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.getConnector(request); - */ getConnector( request?: protos.google.cloud.vpcaccess.v1.IGetConnectorRequest, optionsOrCallback?: @@ -451,6 +451,30 @@ export class VpcAccessServiceClient { return this.innerApiCalls.getConnector(request, options, callback); } + /** + * Creates a Serverless VPC Access connector, returns an operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location in which the configuration should be created, + * specified in the format `projects/* /locations/*`. + * @param {string} request.connectorId + * Required. The ID to use for this connector. + * @param {google.cloud.vpcaccess.v1.Connector} request.connector + * Required. Resource to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/vpc_access_service.create_connector.js + * region_tag:vpcaccess_v1_generated_VpcAccessService_CreateConnector_async + */ createConnector( request?: protos.google.cloud.vpcaccess.v1.ICreateConnectorRequest, options?: CallOptions @@ -487,31 +511,6 @@ export class VpcAccessServiceClient { {} | null | undefined > ): void; - /** - * Creates a Serverless VPC Access connector, returns an operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location in which the configuration should be created, - * specified in the format `projects/* /locations/*`. - * @param {string} request.connectorId - * Required. The ID to use for this connector. - * @param {google.cloud.vpcaccess.v1.Connector} request.connector - * Required. Resource to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.createConnector(request); - * const [response] = await operation.promise(); - */ createConnector( request?: protos.google.cloud.vpcaccess.v1.ICreateConnectorRequest, optionsOrCallback?: @@ -569,11 +568,8 @@ export class VpcAccessServiceClient { * Please see the * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) * for more details and examples. - * @example - * const decodedOperation = await checkCreateConnectorProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); + * @example include:samples/generated/v1/vpc_access_service.create_connector.js + * region_tag:vpcaccess_v1_generated_VpcAccessService_CreateConnector_async */ async checkCreateConnectorProgress( name: string @@ -597,6 +593,26 @@ export class VpcAccessServiceClient { protos.google.cloud.vpcaccess.v1.OperationMetadata >; } + /** + * Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the + * resource does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of a Serverless VPC Access connector to delete. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/vpc_access_service.delete_connector.js + * region_tag:vpcaccess_v1_generated_VpcAccessService_DeleteConnector_async + */ deleteConnector( request?: protos.google.cloud.vpcaccess.v1.IDeleteConnectorRequest, options?: CallOptions @@ -633,27 +649,6 @@ export class VpcAccessServiceClient { {} | null | undefined > ): void; - /** - * Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the - * resource does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of a Serverless VPC Access connector to delete. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.deleteConnector(request); - * const [response] = await operation.promise(); - */ deleteConnector( request?: protos.google.cloud.vpcaccess.v1.IDeleteConnectorRequest, optionsOrCallback?: @@ -711,11 +706,8 @@ export class VpcAccessServiceClient { * Please see the * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) * for more details and examples. - * @example - * const decodedOperation = await checkDeleteConnectorProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); + * @example include:samples/generated/v1/vpc_access_service.delete_connector.js + * region_tag:vpcaccess_v1_generated_VpcAccessService_DeleteConnector_async */ async checkDeleteConnectorProgress( name: string @@ -739,6 +731,30 @@ export class VpcAccessServiceClient { protos.google.cloud.vpcaccess.v1.OperationMetadata >; } + /** + * Lists Serverless VPC Access connectors. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location from which the routes should be listed. + * @param {number} request.pageSize + * Maximum number of functions to return per call. + * @param {string} request.pageToken + * Continuation token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Connector]{@link google.cloud.vpcaccess.v1.Connector}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listConnectorsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ listConnectors( request?: protos.google.cloud.vpcaccess.v1.IListConnectorsRequest, options?: CallOptions @@ -770,30 +786,6 @@ export class VpcAccessServiceClient { protos.google.cloud.vpcaccess.v1.IConnector > ): void; - /** - * Lists Serverless VPC Access connectors. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location from which the routes should be listed. - * @param {number} request.pageSize - * Maximum number of functions to return per call. - * @param {string} request.pageToken - * Continuation token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Connector]{@link google.cloud.vpcaccess.v1.Connector}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listConnectorsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ listConnectors( request?: protos.google.cloud.vpcaccess.v1.IListConnectorsRequest, optionsOrCallback?: @@ -872,7 +864,8 @@ export class VpcAccessServiceClient { gax.routingHeader.fromParams({ parent: request.parent || '', }); - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listConnectors']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listConnectors.createStream( this.innerApiCalls.listConnectors as gax.GaxCall, @@ -903,11 +896,8 @@ export class VpcAccessServiceClient { * Please see the * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) * for more details and examples. - * @example - * const iterable = client.listConnectorsAsync(request); - * for await (const response of iterable) { - * // process response - * } + * @example include:samples/generated/v1/vpc_access_service.list_connectors.js + * region_tag:vpcaccess_v1_generated_VpcAccessService_ListConnectors_async */ listConnectorsAsync( request?: protos.google.cloud.vpcaccess.v1.IListConnectorsRequest, @@ -921,8 +911,8 @@ export class VpcAccessServiceClient { gax.routingHeader.fromParams({ parent: request.parent || '', }); - options = options || {}; - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listConnectors']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listConnectors.asyncIterate( this.innerApiCalls['listConnectors'] as GaxCall,