upload method

Future<UploadKfpArtifactMediaResponse> upload(
  1. UploadKfpArtifactRequest request,
  2. String parent, {
  3. String? $fields,
  4. Media? uploadMedia,
})

Directly uploads a KFP artifact.

The returned Operation will complete once the resource is uploaded. Package, Version, and File resources will be created based on the uploaded artifact. Uploaded artifacts that conflict with existing resources will be overwritten.

request - The metadata request object.

Request parameters:

parent - The resource name of the repository where the KFP artifact will be uploaded. Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+/repositories/\[^/\]+$.

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

uploadMedia - The media to upload.

Completes with a UploadKfpArtifactMediaResponse.

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<UploadKfpArtifactMediaResponse> upload(
  UploadKfpArtifactRequest 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>>{
    if ($fields != null) 'fields': [$fields],
  };

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

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