upload method

Uploads a source archive to a Google Cloud Storage bucket through Cloud Run.

The uploaded source object should be used for Cloud Run resource deployments. User is responsible for managing the lifecycle of the uploaded object. If uploading through the Cloud Run API to Cloud Storage is not desired, you can use the IAM Deny Policy to deny the run.locations.uploadSource permission for all principals.

request - The metadata request object.

Request parameters:

parent - Required. The project and location in which the source archive should be uploaded to, specified in the format `projects / * /locations /

  • . Value must have pattern ^projects/[^/]+/locations/[^/]+$`.

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

uploadMedia - The media to upload.

Completes with a GoogleCloudRunV2UploadSourceResponse.

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<GoogleCloudRunV2UploadSourceResponse> upload(
  GoogleCloudRunV2UploadSourceRequest request,
  core.String parent, {
  core.String? $fields,
  commons.Media? uploadMedia,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    'fields': ?$fields == null ? null : [$fields],
  };

  core.String url_;
  if (uploadMedia == null) {
    url_ = 'v2/' + core.Uri.encodeFull('$parent') + ':uploadSource';
  } else {
    url_ = '/upload/v2/' + core.Uri.encodeFull('$parent') + ':uploadSource';
  }

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