upload method

Creates an enterprise file from the content provided by user.

Returns a public download url for end user.

request - The metadata request object.

Request parameters:

customer - Required. The customer for which the file upload will apply. Value must have pattern ^customers/\[^/\]+$.

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

uploadMedia - The media to upload.

Completes with a GoogleChromePolicyVersionsV1UploadPolicyFileResponse.

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<GoogleChromePolicyVersionsV1UploadPolicyFileResponse> upload(
  GoogleChromePolicyVersionsV1UploadPolicyFileRequest request,
  core.String customer, {
  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('$customer') +
        '/policies/files:uploadPolicyFile';
  } else {
    url_ = '/upload/v1/' +
        core.Uri.encodeFull('$customer') +
        '/policies/files:uploadPolicyFile';
  }

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