create method

Future<TransferConfig> create(
  1. TransferConfig request,
  2. String parent, {
  3. String? authorizationCode,
  4. String? serviceAccountName,
  5. String? versionInfo,
  6. String? $fields,
})

Creates a new data transfer configuration.

request - The metadata request object.

Request parameters:

parent - 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. Value must have pattern ^projects/\[^/\]+$.

authorizationCode - Optional OAuth2 authorization code to use with this transfer configuration. 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.

serviceAccountName - Optional service account email. 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.

versionInfo - 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.

$fields - Selector specifying which fields to include in a partial response.

Completes with a TransferConfig.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<TransferConfig> create(
  TransferConfig request,
  core.String parent, {
  core.String? authorizationCode,
  core.String? serviceAccountName,
  core.String? versionInfo,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (authorizationCode != null) 'authorizationCode': [authorizationCode],
    if (serviceAccountName != null)
      'serviceAccountName': [serviceAccountName],
    if (versionInfo != null) 'versionInfo': [versionInfo],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v1/' + core.Uri.encodeFull('$parent') + '/transferConfigs';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return TransferConfig.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}