download method
Future<Object>
download(
- String name, {
- String? $fields,
- DownloadOptions downloadOptions = commons.DownloadOptions.metadata,
Download a file attached to a case.
Note: HTTP requests must append "?alt=media" to the URL. EXAMPLES: cURL:
name="projects/some-project/cases/43594844/attachments/0674M00000WijAnZAJ"
curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)"
\ "https://cloudsupport.googleapis.com/v2/$name:download?alt=media" ```
Python: ```python import googleapiclient.discovery api_version = "v2"
supportApiService = googleapiclient.discovery.build(
serviceName="cloudsupport", version=api_version,
discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}",
) request = supportApiService.media().download(
name="projects/some-project/cases/43595344/attachments/0684M00000Pw6pHQAR"
) request.uri = request.uri.split("?")[0] + "?alt=media"
print(request.execute()) ```
Request parameters:
[name] - The name of the file attachment to download.
Value must have pattern
`^\[^/\]+/\[^/\]+/cases/\[^/\]+/attachments/\[^/\]+$`.
[$fields] - Selector specifying which fields to include in a partial
response.
[downloadOptions] - Options for downloading. A download can be either a
Metadata (default) or Media download. Partial Media downloads are possible
as well.
Completes with a
- [Media] for Metadata downloads (see [downloadOptions]).
- [commons.Media] for Media downloads (see [downloadOptions]).
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<core.Object> download(
core.String name, {
core.String? $fields,
commons.DownloadOptions downloadOptions = commons.DownloadOptions.metadata,
}) async {
final queryParams_ = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final url_ = 'v2/' + core.Uri.encodeFull('$name') + ':download';
final response_ = await _requester.request(
url_,
'GET',
queryParams: queryParams_,
downloadOptions: downloadOptions,
);
if (downloadOptions.isMetadataDownload) {
return Media.fromJson(response_ as core.Map<core.String, core.dynamic>);
} else {
return response_ as commons.Media;
}
}