generateUploadUrl method

Future<GenerateUploadUrlResponse> generateUploadUrl(
  1. GenerateUploadUrlRequest request,
  2. String parent, {
  3. String? $fields,
})

Returns a signed URL for uploading a function source code.

For more information about the signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls. Once the function source code upload is complete, the used signed URL should be provided in CreateFunction or UpdateFunction request as a reference to the function source code. When uploading source code to the generated signed URL, please follow these restrictions: * Source file type should be a zip file. * No credentials should be attached - the signed URLs provide access to the target bucket using internal service identity; if credentials were attached, the identity from the credentials would be used, but that identity does not have permissions to upload files to the URL. When making a HTTP PUT request, specify this header: * content-type: application/zip Do not specify this header: * Authorization: Bearer YOUR_TOKEN

request - The metadata request object.

Request parameters:

parent - Required. The project and location in which the Google Cloud Storage signed URL should be generated, specified in the format projects / * /locations / * . Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+$.

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

Completes with a GenerateUploadUrlResponse.

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<GenerateUploadUrlResponse> generateUploadUrl(
  GenerateUploadUrlRequest request,
  core.String parent, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final url_ =
      'v2/' + core.Uri.encodeFull('$parent') + '/functions:generateUploadUrl';

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