From ddbc5a0e830180a58fe4faf08bafd1bea000a5df Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 6 Dec 2022 15:32:43 -0800 Subject: [PATCH] chore: Enable requesting numeric enums in "transport=rest" responses for services supporting this (Java, Go, Python, PHP, TypeScript, C#, and Ruby), even if they do not yet turn on REST transport (#3660) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: added Location API methods docs: updated comments PiperOrigin-RevId: 489094434 Source-Link: https://github.com/googleapis/googleapis/commit/71673d86fb33c0922826230de38f33ce132394a7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/10177232d420006610ae9fb740d9f13efe975cb9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpZ3F1ZXJ5LWRhdGF0cmFuc2Zlci8uT3dsQm90LnlhbWwiLCJoIjoiMTAxNzcyMzJkNDIwMDA2NjEwYWU5ZmI3NDBkOWYxM2VmZTk3NWNiOSJ9 * chore: Enable requesting numeric enums in "transport=rest" responses for services supporting this (Java, Go, Python, PHP, TypeScript, C#, and Ruby), even if they do not yet turn on REST transport chore: disallow "transport=rest" for services where numeric enums are not confirmed to be supported (except in PHP and Java) PiperOrigin-RevId: 493113566 Source-Link: https://github.com/googleapis/googleapis/commit/758f0d1217d9c7fe398aa5efb1057ce4b6409e55 Source-Link: https://github.com/googleapis/googleapis-gen/commit/78bd8f05e1276363eb14eae70e91fe4bc20703ab Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpZ3F1ZXJ5LWRhdGF0cmFuc2Zlci8uT3dsQm90LnlhbWwiLCJoIjoiNzhiZDhmMDVlMTI3NjM2M2ViMTRlYWU3MGU5MWZlNGJjMjA3MDNhYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com> --- .../datatransfer/v1/datatransfer.proto | 144 ++++++----- .../bigquery/datatransfer/v1/transfer.proto | 6 +- ...transfer_service.create_transfer_config.js | 55 +++-- ...ta_transfer_service.enroll_data_sources.js | 3 +- ...data_transfer_service.list_data_sources.js | 2 +- ..._transfer_service.list_transfer_configs.js | 2 +- ...transfer_service.update_transfer_config.js | 56 +++-- ...google.cloud.bigquery.datatransfer.v1.json | 8 +- .../src/v1/data_transfer_service_client.ts | 231 +++++++++++++----- .../test/gapic_data_transfer_service_v1.ts | 210 +++++++++++++++- 10 files changed, 539 insertions(+), 178 deletions(-) diff --git a/packages/google-cloud-bigquery-datatransfer/protos/google/cloud/bigquery/datatransfer/v1/datatransfer.proto b/packages/google-cloud-bigquery-datatransfer/protos/google/cloud/bigquery/datatransfer/v1/datatransfer.proto index 28dd2d8e355..63ea08720cc 100644 --- a/packages/google-cloud-bigquery-datatransfer/protos/google/cloud/bigquery/datatransfer/v1/datatransfer.proto +++ b/packages/google-cloud-bigquery-datatransfer/protos/google/cloud/bigquery/datatransfer/v1/datatransfer.proto @@ -1,4 +1,4 @@ -// 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. @@ -217,10 +217,12 @@ service DataTransferService { // Enroll data sources in a user project. This allows users to create transfer // configurations for these data sources. They will also appear in the - // ListDataSources RPC and as such, will appear in the BigQuery UI - // 'https://bigquery.cloud.google.com' (and the documents can be found at - // https://cloud.google.com/bigquery/bigquery-web-ui and - // https://cloud.google.com/bigquery/docs/working-with-transfers). + // ListDataSources RPC and as such, will appear in the + // [BigQuery UI](https://console.cloud.google.com/bigquery), and the documents + // can be found in the public guide for + // [BigQuery Web UI](https://cloud.google.com/bigquery/bigquery-web-ui) and + // [Data Transfer + // Service](https://cloud.google.com/bigquery/docs/working-with-transfers). rpc EnrollDataSources(EnrollDataSourcesRequest) returns (google.protobuf.Empty) { option (google.api.http) = { post: "/v1/{name=projects/*/locations/*}:enrollDataSources" @@ -287,7 +289,7 @@ message DataSourceParameter { // For integer and double values specifies minimum allowed value. google.protobuf.DoubleValue min_value = 9; - // For integer and double values specifies maxminum allowed value. + // For integer and double values specifies maximum allowed value. google.protobuf.DoubleValue max_value = 10; // Deprecated. This field has no effect. @@ -438,7 +440,7 @@ message GetDataSourceRequest { message ListDataSourcesRequest { // 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} + // `projects/{project_id}/locations/{location_id}` string parent = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference) = { @@ -470,9 +472,9 @@ message ListDataSourcesResponse { } // A request to create a data transfer configuration. If new credentials are -// needed for this transfer configuration, an authorization code must be -// provided. If an authorization code is provided, the transfer configuration -// will be associated with the user id corresponding to the authorization code. +// needed for this transfer configuration, authorization info must be provided. +// If authorization info is provided, the transfer configuration will be +// associated with the user id corresponding to the authorization info. // Otherwise, the transfer configuration will be associated with the calling // user. message CreateTransferConfigRequest { @@ -491,78 +493,99 @@ message CreateTransferConfigRequest { TransferConfig transfer_config = 2 [(google.api.field_behavior) = REQUIRED]; // 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= + // This is required only if `transferConfig.dataSourceId` is 'youtube_channel' + // and new credentials are needed, as indicated by `CheckValidCreds`. In order + // to obtain authorization_code, make a request to the following URL: + //
+  // https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=authorization_code&client_id=client_id&scope=data_source_scopes
+  // 
+ // * The client_id is the OAuth client_id of the a data source as + // returned by ListDataSources method. + // * data_source_scopes are the scopes returned by ListDataSources + // method. // - // * 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. + // Note that this should not be set when `service_account_name` is used to + // create the transfer config. string authorization_code = 3; - // 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. + // Optional version info. This is required only if + // `transferConfig.dataSourceId` is not 'youtube_channel' and new credentials + // are needed, as indicated by `CheckValidCreds`. In order to obtain version + // info, make a request to the following URL: + //
+  // https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=version_info&client_id=client_id&scope=data_source_scopes
+  // 
+ // * The client_id is the OAuth client_id of the a data source as + // returned by ListDataSources method. + // * data_source_scopes are the scopes returned by ListDataSources + // method. + // + // Note that this should not be set when `service_account_name` is used to + // create the transfer config. string version_info = 5; - // 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 + // Optional service account name. If this field is set, the transfer config + // will be created with this service account's credentials. It requires that + // the requesting user calling this API has permissions to act as this service // account. + // + // Note that not all data sources support service account credentials when + // creating a transfer config. For the latest list of data sources, read about + // [using service + // accounts](https://cloud.google.com/bigquery-transfer/docs/use-service-accounts). string service_account_name = 6; } // A request to update a transfer configuration. To update the user id of the -// transfer configuration, an authorization code needs to be provided. +// transfer configuration, authorization info needs to be provided. message UpdateTransferConfigRequest { // Required. Data transfer configuration to create. TransferConfig transfer_config = 1 [(google.api.field_behavior) = REQUIRED]; // 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= + // This is required only if `transferConfig.dataSourceId` is 'youtube_channel' + // and new credentials are needed, as indicated by `CheckValidCreds`. In order + // to obtain authorization_code, make a request to the following URL: + //
+  // https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=authorization_code&client_id=client_id&scope=data_source_scopes
+  // 
+ // * The client_id is the OAuth client_id of the a data source as + // returned by ListDataSources method. + // * data_source_scopes are the scopes returned by ListDataSources + // method. // - // * 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. + // Note that this should not be set when `service_account_name` is used to + // update the transfer config. string authorization_code = 3; // Required. Required list of fields to be updated in this request. google.protobuf.FieldMask update_mask = 4 [(google.api.field_behavior) = REQUIRED]; - // 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. + // Optional version info. This is required only if + // `transferConfig.dataSourceId` is not 'youtube_channel' and new credentials + // are needed, as indicated by `CheckValidCreds`. In order to obtain version + // info, make a request to the following URL: + //
+  // https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=version_info&client_id=client_id&scope=data_source_scopes
+  // 
+ // * The client_id is the OAuth client_id of the a data source as + // returned by ListDataSources method. + // * data_source_scopes are the scopes returned by ListDataSources + // method. + // + // Note that this should not be set when `service_account_name` is used to + // update the transfer config. string version_info = 5; - // 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 + // Optional service account name. If this field is set, the transfer config + // will be created with this service account's credentials. It requires that + // the requesting user calling this API has permissions to act as this service // account. + // + // Note that not all data sources support service account credentials when + // creating a transfer config. For the latest list of data sources, read about + // [using service + // accounts](https://cloud.google.com/bigquery-transfer/docs/use-service-accounts). string service_account_name = 6; } @@ -621,7 +644,7 @@ message DeleteTransferRunRequest { // A request to list data transfers configured for a BigQuery project. message ListTransferConfigsRequest { - // Required. The BigQuery project id for which data sources + // Required. The BigQuery project id for which transfer configs // should be returned: `projects/{project_id}` or // `projects/{project_id}/locations/{location_id}` string parent = 1 [ @@ -844,8 +867,7 @@ message StartManualTransferRunsResponse { // A request to enroll a set of data sources so they are visible in the // BigQuery UI's `Transfer` tab. message EnrollDataSourcesRequest { - // The name of the project resource in the form: - // `projects/{project_id}` + // The name of the project resource in the form: `projects/{project_id}` string name = 1; // Data sources that are enrolled. It is required to provide at least one diff --git a/packages/google-cloud-bigquery-datatransfer/protos/google/cloud/bigquery/datatransfer/v1/transfer.proto b/packages/google-cloud-bigquery-datatransfer/protos/google/cloud/bigquery/datatransfer/v1/transfer.proto index 9092b4b9e53..97d16306920 100644 --- a/packages/google-cloud-bigquery-datatransfer/protos/google/cloud/bigquery/datatransfer/v1/transfer.proto +++ b/packages/google-cloud-bigquery-datatransfer/protos/google/cloud/bigquery/datatransfer/v1/transfer.proto @@ -1,4 +1,4 @@ -// 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. @@ -133,7 +133,9 @@ message TransferConfig { // User specified display name for the data transfer. string display_name = 3; - // Data source id. Cannot be changed once data transfer is created. + // Data source ID. This cannot be changed once data transfer is created. The + // full list of available data source IDs can be returned through an API call: + // https://cloud.google.com/bigquery-transfer/docs/reference/datatransfer/rest/v1/projects.locations.dataSources/list string data_source_id = 5; // Parameters specific to each data source. For more information see the 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 index a2ddfb165b1..f4880c6db60 100644 --- 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 @@ -41,36 +41,45 @@ function main(parent, transferConfig) { // 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. + * This is required only if `transferConfig.dataSourceId` is 'youtube_channel' + * and new credentials are needed, as indicated by `CheckValidCreds`. In order + * to obtain authorization_code, make a request to the following URL: + *
+   *  https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=authorization_code&client_id=client_id&scope=data_source_scopes
+   *  
+ * * The client_id is the OAuth client_id of the a data source as + * returned by ListDataSources method. + * * data_source_scopes are the scopes returned by ListDataSources + * method. + * Note that this should not be set when `service_account_name` is used to + * create the transfer config. */ // 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. + * Optional version info. This is required only if + * `transferConfig.dataSourceId` is not 'youtube_channel' and new credentials + * are needed, as indicated by `CheckValidCreds`. In order to obtain version + * info, make a request to the following URL: + *
+   *  https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=version_info&client_id=client_id&scope=data_source_scopes
+   *  
+ * * The client_id is the OAuth client_id of the a data source as + * returned by ListDataSources method. + * * data_source_scopes are the scopes returned by ListDataSources + * method. + * Note that this should not be set when `service_account_name` is used to + * create the transfer config. */ // 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 + * Optional service account name. If this field is set, the transfer config + * will be created with this service account's credentials. It requires that + * the requesting user calling this API has permissions to act as this service * account. + * Note that not all data sources support service account credentials when + * creating a transfer config. For the latest list of data sources, read about + * using service + * accounts (https://cloud.google.com/bigquery-transfer/docs/use-service-accounts). */ // const serviceAccountName = 'abc123' diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.enroll_data_sources.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.enroll_data_sources.js index e0553ce148a..2c72c758a86 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.enroll_data_sources.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.enroll_data_sources.js @@ -29,8 +29,7 @@ function main() { * TODO(developer): Uncomment these variables before running the sample. */ /** - * The name of the project resource in the form: - * `projects/{project_id}` + * The name of the project resource in the form: `projects/{project_id}` */ // const name = 'abc123' /** 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 index 516866b4bc9..42423977f22 100644 --- 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 @@ -31,7 +31,7 @@ function main(parent) { /** * 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} + * `projects/{project_id}/locations/{location_id}` */ // const parent = 'abc123' /** 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 index 9e4f144680a..fa35e812e1c 100644 --- 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 @@ -29,7 +29,7 @@ function main(parent) { * TODO(developer): Uncomment these variables before running the sample. */ /** - * Required. The BigQuery project id for which data sources + * Required. The BigQuery project id for which transfer configs * should be returned: `projects/{project_id}` or * `projects/{project_id}/locations/{location_id}` */ 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 index f6e55317a09..106d899e851 100644 --- 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 @@ -34,20 +34,18 @@ function main(transferConfig, updateMask) { // 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. + * This is required only if `transferConfig.dataSourceId` is 'youtube_channel' + * and new credentials are needed, as indicated by `CheckValidCreds`. In order + * to obtain authorization_code, make a request to the following URL: + *
+   *  https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=authorization_code&client_id=client_id&scope=data_source_scopes
+   *  
+ * * The client_id is the OAuth client_id of the a data source as + * returned by ListDataSources method. + * * data_source_scopes are the scopes returned by ListDataSources + * method. + * Note that this should not be set when `service_account_name` is used to + * update the transfer config. */ // const authorizationCode = 'abc123' /** @@ -55,20 +53,30 @@ function main(transferConfig, updateMask) { */ // 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. + * Optional version info. This is required only if + * `transferConfig.dataSourceId` is not 'youtube_channel' and new credentials + * are needed, as indicated by `CheckValidCreds`. In order to obtain version + * info, make a request to the following URL: + *
+   *  https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=version_info&client_id=client_id&scope=data_source_scopes
+   *  
+ * * The client_id is the OAuth client_id of the a data source as + * returned by ListDataSources method. + * * data_source_scopes are the scopes returned by ListDataSources + * method. + * Note that this should not be set when `service_account_name` is used to + * update the transfer config. */ // 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 + * Optional service account name. If this field is set, the transfer config + * will be created with this service account's credentials. It requires that + * the requesting user calling this API has permissions to act as this service * account. + * Note that not all data sources support service account credentials when + * creating a transfer config. For the latest list of data sources, read about + * using service + * accounts (https://cloud.google.com/bigquery-transfer/docs/use-service-accounts). */ // const serviceAccountName = 'abc123' diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/snippet_metadata.google.cloud.bigquery.datatransfer.v1.json b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/snippet_metadata.google.cloud.bigquery.datatransfer.v1.json index fd12754de75..e730b97953b 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/snippet_metadata.google.cloud.bigquery.datatransfer.v1.json +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/snippet_metadata.google.cloud.bigquery.datatransfer.v1.json @@ -110,7 +110,7 @@ "segments": [ { "start": 25, - "end": 95, + "end": 104, "type": "FULL" } ], @@ -166,7 +166,7 @@ "segments": [ { "start": 25, - "end": 93, + "end": 101, "type": "FULL" } ], @@ -671,14 +671,14 @@ "regionTag": "bigquerydatatransfer_v1_generated_DataTransferService_EnrollDataSources_async", "title": "DataTransferService enrollDataSources Sample", "origin": "API_DEFINITION", - "description": " Enroll data sources in a user project. This allows users to create transfer configurations for these data sources. They will also appear in the ListDataSources RPC and as such, will appear in the BigQuery UI 'https://bigquery.cloud.google.com' (and the documents can be found at https://cloud.google.com/bigquery/bigquery-web-ui and https://cloud.google.com/bigquery/docs/working-with-transfers).", + "description": " Enroll data sources in a user project. This allows users to create transfer configurations for these data sources. They will also appear in the ListDataSources RPC and as such, will appear in the [BigQuery UI](https://console.cloud.google.com/bigquery), and the documents can be found in the public guide for [BigQuery Web UI](https://cloud.google.com/bigquery/bigquery-web-ui) and [Data Transfer Service](https://cloud.google.com/bigquery/docs/working-with-transfers).", "canonical": true, "file": "data_transfer_service.enroll_data_sources.js", "language": "JAVASCRIPT", "segments": [ { "start": 25, - "end": 58, + "end": 57, "type": "FULL" } ], 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 8095cc77edf..8c7a4c27b2f 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 @@ -25,6 +25,8 @@ import type { ClientOptions, PaginationCallback, GaxCall, + LocationsClient, + LocationProtos, } from 'google-gax'; import {Transform} from 'stream'; import * as protos from '../../protos/protos'; @@ -59,6 +61,7 @@ export class DataTransferServiceClient { }; warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; dataTransferServiceStub?: Promise<{[name: string]: Function}>; @@ -120,6 +123,9 @@ export class DataTransferServiceClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; @@ -152,6 +158,10 @@ export class DataTransferServiceClient { if (servicePath === staticMembers.servicePath) { this.auth.defaultScopes = staticMembers.scopes; } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; @@ -488,33 +498,44 @@ export class DataTransferServiceClient { * Required. Data transfer configuration to create. * @param {string} request.authorizationCode * 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= + * This is required only if `transferConfig.dataSourceId` is 'youtube_channel' + * and new credentials are needed, as indicated by `CheckValidCreds`. In order + * to obtain authorization_code, make a request to the following URL: + *
+   *   https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=authorization_code&client_id=client_id&scope=data_source_scopes
+   *   
+ * * The client_id is the OAuth client_id of the a data source as + * returned by ListDataSources method. + * * data_source_scopes are the scopes returned by ListDataSources + * method. * - * * 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. + * Note that this should not be set when `service_account_name` is used to + * create the transfer config. * @param {string} request.versionInfo - * 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. + * Optional version info. This is required only if + * `transferConfig.dataSourceId` is not 'youtube_channel' and new credentials + * are needed, as indicated by `CheckValidCreds`. In order to obtain version + * info, make a request to the following URL: + *
+   *   https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=version_info&client_id=client_id&scope=data_source_scopes
+   *   
+ * * The client_id is the OAuth client_id of the a data source as + * returned by ListDataSources method. + * * data_source_scopes are the scopes returned by ListDataSources + * method. + * + * Note that this should not be set when `service_account_name` is used to + * create the transfer config. * @param {string} request.serviceAccountName - * 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 + * Optional service account name. If this field is set, the transfer config + * will be created with this service account's credentials. It requires that + * the requesting user calling this API has permissions to act as this service * account. + * + * Note that not all data sources support service account credentials when + * creating a transfer config. For the latest list of data sources, read about + * [using service + * accounts](https://cloud.google.com/bigquery-transfer/docs/use-service-accounts). * @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. @@ -615,36 +636,46 @@ export class DataTransferServiceClient { * Required. Data transfer configuration to create. * @param {string} request.authorizationCode * 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= + * This is required only if `transferConfig.dataSourceId` is 'youtube_channel' + * and new credentials are needed, as indicated by `CheckValidCreds`. In order + * to obtain authorization_code, make a request to the following URL: + *
+   *   https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=authorization_code&client_id=client_id&scope=data_source_scopes
+   *   
+ * * The client_id is the OAuth client_id of the a data source as + * returned by ListDataSources method. + * * data_source_scopes are the scopes returned by ListDataSources + * method. * - * * 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. + * Note that this should not be set when `service_account_name` is used to + * update the transfer config. * @param {google.protobuf.FieldMask} request.updateMask * Required. Required list of fields to be updated in this request. * @param {string} request.versionInfo - * 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. + * Optional version info. This is required only if + * `transferConfig.dataSourceId` is not 'youtube_channel' and new credentials + * are needed, as indicated by `CheckValidCreds`. In order to obtain version + * info, make a request to the following URL: + *
+   *   https://www.gstatic.com/bigquerydatatransfer/oauthz/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=version_info&client_id=client_id&scope=data_source_scopes
+   *   
+ * * The client_id is the OAuth client_id of the a data source as + * returned by ListDataSources method. + * * data_source_scopes are the scopes returned by ListDataSources + * method. + * + * Note that this should not be set when `service_account_name` is used to + * update the transfer config. * @param {string} request.serviceAccountName - * 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 + * Optional service account name. If this field is set, the transfer config + * will be created with this service account's credentials. It requires that + * the requesting user calling this API has permissions to act as this service * account. + * + * Note that not all data sources support service account credentials when + * creating a transfer config. For the latest list of data sources, read about + * [using service + * accounts](https://cloud.google.com/bigquery-transfer/docs/use-service-accounts). * @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. @@ -1461,16 +1492,17 @@ export class DataTransferServiceClient { /** * Enroll data sources in a user project. This allows users to create transfer * configurations for these data sources. They will also appear in the - * ListDataSources RPC and as such, will appear in the BigQuery UI - * 'https://bigquery.cloud.google.com' (and the documents can be found at - * https://cloud.google.com/bigquery/bigquery-web-ui and - * https://cloud.google.com/bigquery/docs/working-with-transfers). + * ListDataSources RPC and as such, will appear in the + * [BigQuery UI](https://console.cloud.google.com/bigquery), and the documents + * can be found in the public guide for + * [BigQuery Web UI](https://cloud.google.com/bigquery/bigquery-web-ui) and + * [Data Transfer + * Service](https://cloud.google.com/bigquery/docs/working-with-transfers). * * @param {Object} request * The request object that will be sent. * @param {string} request.name - * The name of the project resource in the form: - * `projects/{project_id}` + * The name of the project resource in the form: `projects/{project_id}` * @param {string[]} request.dataSourceIds * Data sources that are enrolled. It is required to provide at least one * data source id. @@ -1573,7 +1605,7 @@ export class DataTransferServiceClient { * @param {string} request.parent * 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} + * `projects/{project_id}/locations/{location_id}` * @param {string} request.pageToken * Pagination token, which can be used to request a specific page * of `ListDataSourcesRequest` list results. For multiple-page @@ -1677,7 +1709,7 @@ export class DataTransferServiceClient { * @param {string} request.parent * 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} + * `projects/{project_id}/locations/{location_id}` * @param {string} request.pageToken * Pagination token, which can be used to request a specific page * of `ListDataSourcesRequest` list results. For multiple-page @@ -1729,7 +1761,7 @@ export class DataTransferServiceClient { * @param {string} request.parent * 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} + * `projects/{project_id}/locations/{location_id}` * @param {string} request.pageToken * Pagination token, which can be used to request a specific page * of `ListDataSourcesRequest` list results. For multiple-page @@ -1779,7 +1811,7 @@ export class DataTransferServiceClient { * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * Required. The BigQuery project id for which data sources + * Required. The BigQuery project id for which transfer configs * should be returned: `projects/{project_id}` or * `projects/{project_id}/locations/{location_id}` * @param {string[]} request.dataSourceIds @@ -1885,7 +1917,7 @@ export class DataTransferServiceClient { * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * Required. The BigQuery project id for which data sources + * Required. The BigQuery project id for which transfer configs * should be returned: `projects/{project_id}` or * `projects/{project_id}/locations/{location_id}` * @param {string[]} request.dataSourceIds @@ -1939,7 +1971,7 @@ export class DataTransferServiceClient { * @param {Object} request * The request object that will be sent. * @param {string} request.parent - * Required. The BigQuery project id for which data sources + * Required. The BigQuery project id for which transfer configs * should be returned: `projects/{project_id}` or * `projects/{project_id}/locations/{location_id}` * @param {string[]} request.dataSourceIds @@ -2424,6 +2456,86 @@ export class DataTransferServiceClient { callSettings ) as AsyncIterable; } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @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 [Location]{@link google.cloud.location.Location}. + * 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.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * 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.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + // -------------------- // -- Path templates -- // -------------------- @@ -2824,6 +2936,7 @@ export class DataTransferServiceClient { return this.dataTransferServiceStub.then(stub => { this._terminated = true; stub.close(); + this.locationsClient.close(); }); } return Promise.resolve(); diff --git a/packages/google-cloud-bigquery-datatransfer/test/gapic_data_transfer_service_v1.ts b/packages/google-cloud-bigquery-datatransfer/test/gapic_data_transfer_service_v1.ts index 14bf3b8ce21..c968843f47f 100644 --- a/packages/google-cloud-bigquery-datatransfer/test/gapic_data_transfer_service_v1.ts +++ b/packages/google-cloud-bigquery-datatransfer/test/gapic_data_transfer_service_v1.ts @@ -25,7 +25,7 @@ import * as datatransferserviceModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -3177,6 +3177,214 @@ describe('v1.DataTransferServiceClient', () => { ); }); }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); describe('Path templates', () => { describe('project', () => {