diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.check_valid_creds.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.check_valid_creds.js new file mode 100644 index 00000000000..7894851c6af --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.check_valid_creds.js @@ -0,0 +1,55 @@ +// 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 bigquerydatatransfer_v1_generated_DataTransferService_CheckValidCreds_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The data source in the form: + * `projects/{project_id}/dataSources/{data_source_id}` or + * `projects/{project_id}/locations/{location_id}/dataSources/{data_source_id}`. + */ + // const name = 'abc123' + + // Imports the Datatransfer library + const {DataTransferServiceClient} = + require('@google-cloud/bigquery-data-transfer').v1; + + // Instantiates a client + const datatransferClient = new DataTransferServiceClient(); + + async function checkValidCreds() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await datatransferClient.checkValidCreds(request); + console.log(response); + } + + checkValidCreds(); + // [END bigquerydatatransfer_v1_generated_DataTransferService_CheckValidCreds_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.create_transfer_config.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.create_transfer_config.js new file mode 100644 index 00000000000..7876bd4646a --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.create_transfer_config.js @@ -0,0 +1,95 @@ +// 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, transferConfig) { + // [START bigquerydatatransfer_v1_generated_DataTransferService_CreateTransferConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The BigQuery project id where the transfer configuration should be created. + * Must be in the format projects/{project_id}/locations/{location_id} or + * projects/{project_id}. If specified location and location of the + * destination bigquery dataset do not match - the request will fail. + */ + // const parent = 'abc123' + /** + * Required. Data transfer configuration to create. + */ + // const transferConfig = '' + /** + * Optional OAuth2 authorization code to use with this transfer configuration. + * This is required if new credentials are needed, as indicated by + * `CheckValidCreds`. + * In order to obtain authorization_code, please make a + * request to + * https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?client_id=&scope=&redirect_uri= + * * client_id should be OAuth client_id of BigQuery DTS API for the given + * data source returned by ListDataSources method. + * * data_source_scopes are the scopes returned by ListDataSources method. + * * redirect_uri is an optional parameter. If not specified, then + * authorization code is posted to the opener of authorization flow window. + * Otherwise it will be sent to the redirect uri. A special value of + * urn:ietf:wg:oauth:2.0:oob means that authorization code should be + * returned in the title bar of the browser, with the page text prompting + * the user to copy the code and paste it in the application. + */ + // const authorizationCode = 'abc123' + /** + * Optional version info. If users want to find a very recent access token, + * that is, immediately after approving access, users have to set the + * version_info claim in the token request. To obtain the version_info, users + * must use the "none+gsession" response type. which be return a + * version_info back in the authorization response which be be put in a JWT + * claim in the token request. + */ + // const versionInfo = 'abc123' + /** + * Optional service account name. If this field is set, transfer config will + * be created with this service account credentials. It requires that + * requesting user calling this API has permissions to act as this service + * account. + */ + // const serviceAccountName = 'abc123' + + // Imports the Datatransfer library + const {DataTransferServiceClient} = + require('@google-cloud/bigquery-data-transfer').v1; + + // Instantiates a client + const datatransferClient = new DataTransferServiceClient(); + + async function createTransferConfig() { + // Construct request + const request = { + parent, + transferConfig, + }; + + // Run request + const response = await datatransferClient.createTransferConfig(request); + console.log(response); + } + + createTransferConfig(); + // [END bigquerydatatransfer_v1_generated_DataTransferService_CreateTransferConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.delete_transfer_config.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.delete_transfer_config.js new file mode 100644 index 00000000000..12423e70abe --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.delete_transfer_config.js @@ -0,0 +1,55 @@ +// 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 bigquerydatatransfer_v1_generated_DataTransferService_DeleteTransferConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The field will contain name of the resource requested, for example: + * `projects/{project_id}/transferConfigs/{config_id}` or + * `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}` + */ + // const name = 'abc123' + + // Imports the Datatransfer library + const {DataTransferServiceClient} = + require('@google-cloud/bigquery-data-transfer').v1; + + // Instantiates a client + const datatransferClient = new DataTransferServiceClient(); + + async function deleteTransferConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await datatransferClient.deleteTransferConfig(request); + console.log(response); + } + + deleteTransferConfig(); + // [END bigquerydatatransfer_v1_generated_DataTransferService_DeleteTransferConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.delete_transfer_run.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.delete_transfer_run.js new file mode 100644 index 00000000000..4fe9ff0e478 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.delete_transfer_run.js @@ -0,0 +1,55 @@ +// 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 bigquerydatatransfer_v1_generated_DataTransferService_DeleteTransferRun_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The field will contain name of the resource requested, for example: + * `projects/{project_id}/transferConfigs/{config_id}/runs/{run_id}` or + * `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}/runs/{run_id}` + */ + // const name = 'abc123' + + // Imports the Datatransfer library + const {DataTransferServiceClient} = + require('@google-cloud/bigquery-data-transfer').v1; + + // Instantiates a client + const datatransferClient = new DataTransferServiceClient(); + + async function deleteTransferRun() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await datatransferClient.deleteTransferRun(request); + console.log(response); + } + + deleteTransferRun(); + // [END bigquerydatatransfer_v1_generated_DataTransferService_DeleteTransferRun_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_data_source.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_data_source.js new file mode 100644 index 00000000000..014fe51d3f3 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_data_source.js @@ -0,0 +1,55 @@ +// 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 bigquerydatatransfer_v1_generated_DataTransferService_GetDataSource_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The field will contain name of the resource requested, for example: + * `projects/{project_id}/dataSources/{data_source_id}` or + * `projects/{project_id}/locations/{location_id}/dataSources/{data_source_id}` + */ + // const name = 'abc123' + + // Imports the Datatransfer library + const {DataTransferServiceClient} = + require('@google-cloud/bigquery-data-transfer').v1; + + // Instantiates a client + const datatransferClient = new DataTransferServiceClient(); + + async function getDataSource() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await datatransferClient.getDataSource(request); + console.log(response); + } + + getDataSource(); + // [END bigquerydatatransfer_v1_generated_DataTransferService_GetDataSource_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_transfer_config.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_transfer_config.js new file mode 100644 index 00000000000..d096f3d7d36 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_transfer_config.js @@ -0,0 +1,55 @@ +// 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 bigquerydatatransfer_v1_generated_DataTransferService_GetTransferConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The field will contain name of the resource requested, for example: + * `projects/{project_id}/transferConfigs/{config_id}` or + * `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}` + */ + // const name = 'abc123' + + // Imports the Datatransfer library + const {DataTransferServiceClient} = + require('@google-cloud/bigquery-data-transfer').v1; + + // Instantiates a client + const datatransferClient = new DataTransferServiceClient(); + + async function getTransferConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await datatransferClient.getTransferConfig(request); + console.log(response); + } + + getTransferConfig(); + // [END bigquerydatatransfer_v1_generated_DataTransferService_GetTransferConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_transfer_run.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_transfer_run.js new file mode 100644 index 00000000000..df72a9d5d48 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_transfer_run.js @@ -0,0 +1,55 @@ +// 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 bigquerydatatransfer_v1_generated_DataTransferService_GetTransferRun_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The field will contain name of the resource requested, for example: + * `projects/{project_id}/transferConfigs/{config_id}/runs/{run_id}` or + * `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}/runs/{run_id}` + */ + // const name = 'abc123' + + // Imports the Datatransfer library + const {DataTransferServiceClient} = + require('@google-cloud/bigquery-data-transfer').v1; + + // Instantiates a client + const datatransferClient = new DataTransferServiceClient(); + + async function getTransferRun() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await datatransferClient.getTransferRun(request); + console.log(response); + } + + getTransferRun(); + // [END bigquerydatatransfer_v1_generated_DataTransferService_GetTransferRun_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_data_sources.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_data_sources.js new file mode 100644 index 00000000000..a00e9fbb45b --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_data_sources.js @@ -0,0 +1,69 @@ +// 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 bigquerydatatransfer_v1_generated_DataTransferService_ListDataSources_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The BigQuery project id for which data sources should be returned. + * Must be in the form: `projects/{project_id}` or + * `projects/{project_id}/locations/{location_id} + */ + // const parent = 'abc123' + /** + * Pagination token, which can be used to request a specific page + * of `ListDataSourcesRequest` list results. For multiple-page + * results, `ListDataSourcesResponse` outputs + * a `next_page` token, which can be used as the + * `page_token` value to request the next page of list results. + */ + // const pageToken = 'abc123' + /** + * Page size. The default page size is the maximum value of 1000 results. + */ + // const pageSize = 1234 + + // Imports the Datatransfer library + const {DataTransferServiceClient} = + require('@google-cloud/bigquery-data-transfer').v1; + + // Instantiates a client + const datatransferClient = new DataTransferServiceClient(); + + async function listDataSources() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await datatransferClient.listDataSourcesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + listDataSources(); + // [END bigquerydatatransfer_v1_generated_DataTransferService_ListDataSources_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_configs.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_configs.js new file mode 100644 index 00000000000..e3d2c31053a --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_configs.js @@ -0,0 +1,73 @@ +// 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 bigquerydatatransfer_v1_generated_DataTransferService_ListTransferConfigs_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The BigQuery project id for which data sources + * should be returned: `projects/{project_id}` or + * `projects/{project_id}/locations/{location_id}` + */ + // const parent = 'abc123' + /** + * When specified, only configurations of requested data sources are returned. + */ + // const dataSourceIds = 'abc123' + /** + * Pagination token, which can be used to request a specific page + * of `ListTransfersRequest` list results. For multiple-page + * results, `ListTransfersResponse` outputs + * a `next_page` token, which can be used as the + * `page_token` value to request the next page of list results. + */ + // const pageToken = 'abc123' + /** + * Page size. The default page size is the maximum value of 1000 results. + */ + // const pageSize = 1234 + + // Imports the Datatransfer library + const {DataTransferServiceClient} = + require('@google-cloud/bigquery-data-transfer').v1; + + // Instantiates a client + const datatransferClient = new DataTransferServiceClient(); + + async function listTransferConfigs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await datatransferClient.listTransferConfigsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + listTransferConfigs(); + // [END bigquerydatatransfer_v1_generated_DataTransferService_ListTransferConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_logs.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_logs.js new file mode 100644 index 00000000000..0ec5eb757f4 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_logs.js @@ -0,0 +1,74 @@ +// 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 bigquerydatatransfer_v1_generated_DataTransferService_ListTransferLogs_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Transfer run name in the form: + * `projects/{project_id}/transferConfigs/{config_id}/runs/{run_id}` or + * `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}/runs/{run_id}` + */ + // const parent = 'abc123' + /** + * Pagination token, which can be used to request a specific page + * of `ListTransferLogsRequest` list results. For multiple-page + * results, `ListTransferLogsResponse` outputs + * a `next_page` token, which can be used as the + * `page_token` value to request the next page of list results. + */ + // const pageToken = 'abc123' + /** + * Page size. The default page size is the maximum value of 1000 results. + */ + // const pageSize = 1234 + /** + * Message types to return. If not populated - INFO, WARNING and ERROR + * messages are returned. + */ + // const messageTypes = 1234 + + // Imports the Datatransfer library + const {DataTransferServiceClient} = + require('@google-cloud/bigquery-data-transfer').v1; + + // Instantiates a client + const datatransferClient = new DataTransferServiceClient(); + + async function listTransferLogs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await datatransferClient.listTransferLogsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + listTransferLogs(); + // [END bigquerydatatransfer_v1_generated_DataTransferService_ListTransferLogs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_runs.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_runs.js new file mode 100644 index 00000000000..5d1dcc13982 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_runs.js @@ -0,0 +1,78 @@ +// 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 bigquerydatatransfer_v1_generated_DataTransferService_ListTransferRuns_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Name of transfer configuration for which transfer runs should be retrieved. + * Format of transfer configuration resource name is: + * `projects/{project_id}/transferConfigs/{config_id}` or + * `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}`. + */ + // const parent = 'abc123' + /** + * When specified, only transfer runs with requested states are returned. + */ + // const states = 1234 + /** + * Pagination token, which can be used to request a specific page + * of `ListTransferRunsRequest` list results. For multiple-page + * results, `ListTransferRunsResponse` outputs + * a `next_page` token, which can be used as the + * `page_token` value to request the next page of list results. + */ + // const pageToken = 'abc123' + /** + * Page size. The default page size is the maximum value of 1000 results. + */ + // const pageSize = 1234 + /** + * Indicates how run attempts are to be pulled. + */ + // const runAttempt = '' + + // Imports the Datatransfer library + const {DataTransferServiceClient} = + require('@google-cloud/bigquery-data-transfer').v1; + + // Instantiates a client + const datatransferClient = new DataTransferServiceClient(); + + async function listTransferRuns() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await datatransferClient.listTransferRunsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + listTransferRuns(); + // [END bigquerydatatransfer_v1_generated_DataTransferService_ListTransferRuns_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.schedule_transfer_runs.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.schedule_transfer_runs.js new file mode 100644 index 00000000000..04bd053da78 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.schedule_transfer_runs.js @@ -0,0 +1,67 @@ +// 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, startTime, endTime) { + // [START bigquerydatatransfer_v1_generated_DataTransferService_ScheduleTransferRuns_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Transfer configuration name in the form: + * `projects/{project_id}/transferConfigs/{config_id}` or + * `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}`. + */ + // const parent = 'abc123' + /** + * Required. Start time of the range of transfer runs. For example, + * `"2017-05-25T00:00:00+00:00"`. + */ + // const startTime = '' + /** + * Required. End time of the range of transfer runs. For example, + * `"2017-05-30T00:00:00+00:00"`. + */ + // const endTime = '' + + // Imports the Datatransfer library + const {DataTransferServiceClient} = + require('@google-cloud/bigquery-data-transfer').v1; + + // Instantiates a client + const datatransferClient = new DataTransferServiceClient(); + + async function scheduleTransferRuns() { + // Construct request + const request = { + parent, + startTime, + endTime, + }; + + // Run request + const response = await datatransferClient.scheduleTransferRuns(request); + console.log(response); + } + + scheduleTransferRuns(); + // [END bigquerydatatransfer_v1_generated_DataTransferService_ScheduleTransferRuns_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.start_manual_transfer_runs.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.start_manual_transfer_runs.js new file mode 100644 index 00000000000..45b87bc5ea3 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.start_manual_transfer_runs.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() { + // [START bigquerydatatransfer_v1_generated_DataTransferService_StartManualTransferRuns_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Transfer configuration name in the form: + * `projects/{project_id}/transferConfigs/{config_id}` or + * `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}`. + */ + // const parent = 'abc123' + /** + * Time range for the transfer runs that should be started. + */ + // const requestedTimeRange = '' + /** + * Specific run_time for a transfer run to be started. The + * requested_run_time must not be in the future. + */ + // const requestedRunTime = '' + + // Imports the Datatransfer library + const {DataTransferServiceClient} = + require('@google-cloud/bigquery-data-transfer').v1; + + // Instantiates a client + const datatransferClient = new DataTransferServiceClient(); + + async function startManualTransferRuns() { + // Construct request + const request = {}; + + // Run request + const response = await datatransferClient.startManualTransferRuns(request); + console.log(response); + } + + startManualTransferRuns(); + // [END bigquerydatatransfer_v1_generated_DataTransferService_StartManualTransferRuns_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.update_transfer_config.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.update_transfer_config.js new file mode 100644 index 00000000000..3defad83838 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.update_transfer_config.js @@ -0,0 +1,93 @@ +// 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(transferConfig, updateMask) { + // [START bigquerydatatransfer_v1_generated_DataTransferService_UpdateTransferConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Data transfer configuration to create. + */ + // const transferConfig = '' + /** + * Optional OAuth2 authorization code to use with this transfer configuration. + * If it is provided, the transfer configuration will be associated with the + * authorizing user. + * In order to obtain authorization_code, please make a + * request to + * https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?client_id=&scope=&redirect_uri= + * * client_id should be OAuth client_id of BigQuery DTS API for the given + * data source returned by ListDataSources method. + * * data_source_scopes are the scopes returned by ListDataSources method. + * * redirect_uri is an optional parameter. If not specified, then + * authorization code is posted to the opener of authorization flow window. + * Otherwise it will be sent to the redirect uri. A special value of + * urn:ietf:wg:oauth:2.0:oob means that authorization code should be + * returned in the title bar of the browser, with the page text prompting + * the user to copy the code and paste it in the application. + */ + // const authorizationCode = 'abc123' + /** + * Required. Required list of fields to be updated in this request. + */ + // const updateMask = '' + /** + * Optional version info. If users want to find a very recent access token, + * that is, immediately after approving access, users have to set the + * version_info claim in the token request. To obtain the version_info, users + * must use the "none+gsession" response type. which be return a + * version_info back in the authorization response which be be put in a JWT + * claim in the token request. + */ + // const versionInfo = 'abc123' + /** + * Optional service account name. If this field is set and + * "service_account_name" is set in update_mask, transfer config will be + * updated to use this service account credentials. It requires that + * requesting user calling this API has permissions to act as this service + * account. + */ + // const serviceAccountName = 'abc123' + + // Imports the Datatransfer library + const {DataTransferServiceClient} = + require('@google-cloud/bigquery-data-transfer').v1; + + // Instantiates a client + const datatransferClient = new DataTransferServiceClient(); + + async function updateTransferConfig() { + // Construct request + const request = { + transferConfig, + updateMask, + }; + + // Run request + const response = await datatransferClient.updateTransferConfig(request); + console.log(response); + } + + updateTransferConfig(); + // [END bigquerydatatransfer_v1_generated_DataTransferService_UpdateTransferConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datatransfer/samples/package.json b/packages/google-cloud-bigquery-datatransfer/samples/package.json index 625ebdc395f..b14cb493ac7 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/package.json +++ b/packages/google-cloud-bigquery-datatransfer/samples/package.json @@ -3,7 +3,7 @@ "license": "Apache-2.0", "author": "Google Inc.", "engines": { - "node": ">=8" + "node": ">=10" }, "files": [ "*.js" diff --git a/packages/google-cloud-bigquery-datatransfer/src/v1/data_transfer_service_client.ts b/packages/google-cloud-bigquery-datatransfer/src/v1/data_transfer_service_client.ts index 73331b026c0..3fb14963dd2 100644 --- a/packages/google-cloud-bigquery-datatransfer/src/v1/data_transfer_service_client.ts +++ b/packages/google-cloud-bigquery-datatransfer/src/v1/data_transfer_service_client.ts @@ -1600,7 +1600,8 @@ export class DataTransferServiceClient { gax.routingHeader.fromParams({ parent: request.parent || '', }); - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listDataSources']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listDataSources.createStream( this.innerApiCalls.listDataSources as gax.GaxCall, @@ -1656,7 +1657,8 @@ export class DataTransferServiceClient { parent: request.parent || '', }); options = options || {}; - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listDataSources']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listDataSources.asyncIterate( this.innerApiCalls['listDataSources'] as GaxCall, @@ -1814,7 +1816,8 @@ export class DataTransferServiceClient { gax.routingHeader.fromParams({ parent: request.parent || '', }); - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listTransferConfigs']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listTransferConfigs.createStream( this.innerApiCalls.listTransferConfigs as gax.GaxCall, @@ -1872,7 +1875,8 @@ export class DataTransferServiceClient { parent: request.parent || '', }); options = options || {}; - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listTransferConfigs']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listTransferConfigs.asyncIterate( this.innerApiCalls['listTransferConfigs'] as GaxCall, @@ -2035,7 +2039,8 @@ export class DataTransferServiceClient { gax.routingHeader.fromParams({ parent: request.parent || '', }); - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listTransferRuns']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listTransferRuns.createStream( this.innerApiCalls.listTransferRuns as gax.GaxCall, @@ -2096,7 +2101,8 @@ export class DataTransferServiceClient { parent: request.parent || '', }); options = options || {}; - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listTransferRuns']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listTransferRuns.asyncIterate( this.innerApiCalls['listTransferRuns'] as GaxCall, @@ -2255,7 +2261,8 @@ export class DataTransferServiceClient { gax.routingHeader.fromParams({ parent: request.parent || '', }); - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listTransferLogs']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listTransferLogs.createStream( this.innerApiCalls.listTransferLogs as gax.GaxCall, @@ -2314,7 +2321,8 @@ export class DataTransferServiceClient { parent: request.parent || '', }); options = options || {}; - const callSettings = new gax.CallSettings(options); + const defaultCallSettings = this._defaults['listTransferLogs']; + const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listTransferLogs.asyncIterate( this.innerApiCalls['listTransferLogs'] as GaxCall,