insert method

Future<Job> insert(
  1. Job request,
  2. String projectId, {
  3. String? $fields,
  4. UploadOptions uploadOptions = commons.UploadOptions.defaultOptions,
  5. Media? uploadMedia,
})

Starts a new asynchronous job.

This API has two different kinds of endpoint URIs, as this method supports a variety of use cases. * The Metadata URI is used for most interactions, as it accepts the job configuration directly. * The Upload URI is ONLY for the case when you're sending both a load job configuration and a data stream together. In this case, the Upload URI accepts the job configuration and the data as two distinct multipart MIME parts.

request - The metadata request object.

Request parameters:

projectId - Project ID of project that will be billed for the job. Value must have pattern ^\[^/\]+$.

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

uploadMedia - The media to upload.

uploadOptions - Options for the media upload. Streaming Media without the length being known ahead of time is only supported via resumable uploads.

Completes with a Job.

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<Job> insert(
  Job request,
  core.String projectId, {
  core.String? $fields,
  commons.UploadOptions uploadOptions = commons.UploadOptions.defaultOptions,
  commons.Media? uploadMedia,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  core.String url_;
  if (uploadMedia == null) {
    url_ = 'projects/' + core.Uri.encodeFull('$projectId') + '/jobs';
  } else if (uploadOptions is commons.ResumableUploadOptions) {
    url_ = '/resumable/upload/bigquery/v2/projects/' +
        core.Uri.encodeFull('$projectId') +
        '/jobs';
  } else {
    url_ = '/upload/bigquery/v2/projects/' +
        core.Uri.encodeFull('$projectId') +
        '/jobs';
  }

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