class Media extends Resource (View source)

The "media" collection of methods.

Typical usage is:

 $cloudsupportService = new Google\Service\CloudSupport(...);
 $media = $cloudsupportService->media;

Methods

download(string $name, array $optParams = [])

Download a file attached to a case. Note: HTTP requests must append "?alt=media" to the URL. EXAMPLES: cURL: shell 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:


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()) ```
(media.download)

upload(string $parent, CreateAttachmentRequest $postBody, array $optParams = [])

Create a file attachment on a case or Cloud resource. The attachment must have the following fields set: filename. EXAMPLES: cURL: shell echo "This text is in a file I'm uploading using CSAPI." \ > "./example_file.txt" case="projects/some-project/cases/43594844" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ --data-binary @"./example_file.txt" \ "https://cloudsupport.googleapis.com/upload/v2beta/$c ase/attachments?attachment.filename=uploaded_via_curl.txt" Python:


supportApiService = googleapiclient.discovery.build(
serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https:
//cloudsupport.googleapis.com/$discovery/rest?version={api_version}", )
file_path = "./example_file.txt" with open(file_path, "w") as file:
file.write( "This text is inside a file I'm going to upload using the Cloud
Support API.", ) request = supportApiService.media().upload(
parent="projects/some-project/cases/43595344", media_body=file_path )
request.uri = request.uri.split("?")[0] +
"?attachment.filename=uploaded_via_python.txt" print(request.execute()) ```
(media.upload)

Details

Media download(string $name, array $optParams = [])

Download a file attached to a case. Note: HTTP requests must append "?alt=media" to the URL. EXAMPLES: cURL: shell 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:


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()) ```
(media.download)

Parameters

string $name

The name of the file attachment to download.

array $optParams

Optional parameters.

Return Value

Media

Exceptions

Exception

Attachment upload(string $parent, CreateAttachmentRequest $postBody, array $optParams = [])

Create a file attachment on a case or Cloud resource. The attachment must have the following fields set: filename. EXAMPLES: cURL: shell echo "This text is in a file I'm uploading using CSAPI." \ > "./example_file.txt" case="projects/some-project/cases/43594844" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ --data-binary @"./example_file.txt" \ "https://cloudsupport.googleapis.com/upload/v2beta/$c ase/attachments?attachment.filename=uploaded_via_curl.txt" Python:


supportApiService = googleapiclient.discovery.build(
serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https:
//cloudsupport.googleapis.com/$discovery/rest?version={api_version}", )
file_path = "./example_file.txt" with open(file_path, "w") as file:
file.write( "This text is inside a file I'm going to upload using the Cloud
Support API.", ) request = supportApiService.media().upload(
parent="projects/some-project/cases/43595344", media_body=file_path )
request.uri = request.uri.split("?")[0] +
"?attachment.filename=uploaded_via_python.txt" print(request.execute()) ```
(media.upload)

Parameters

string $parent

Required. The name of the case or Cloud resource to which the attachment should be attached.

CreateAttachmentRequest $postBody
array $optParams

Optional parameters.

Return Value

Attachment

Exceptions

Exception