Get bucket metadata (original) (raw)
This page shows you how get information on the metadata of your Cloud Storage buckets, excluding IAM policies and ACLs.
In order to get the required permissions for getting the metadata of a Cloud Storage bucket, ask your administrator to grant you the Storage Admin (roles/storage.admin) role on the bucket.
This role contains the permissions required to get the metadata of a bucket. To see the exact permissions that are required, expand theRequired permissions section:
Console
- In the Google Cloud console, go to the Cloud Storage Buckets page.
Go to Buckets - In the bucket list, click the name of the bucket whose metadata you want to view.
- Click the Configuration tab to view bucket details such as the included regions, storage class, permissions, and replication type.
Command line
Use the gcloud storage buckets describe command:
gcloud storage buckets describe gs://BUCKET_NAME
Where:
BUCKET_NAMEis the name of the bucket whose metadata you want to view. For example,my-awesome-bucket.
If successful, the response looks similar to the following example:
defaultEventBasedHold: false etag: CAE= iamConfiguration: bucketPolicyOnly: enabled: true ...
Client libraries
Terraform
You can use a Terraform resource to view a bucket's metadata.
REST APIs
JSON API
- Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorizationheader. - Use cURL to call the JSON APIwith a GET Bucket request:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://storage.googleapis.com/storage/v1/b/BUCKET_NAME"
WhereBUCKET_NAMEis the name of the relevant bucket. For example,my-bucket.
Optionally, you can narrow down the metadata results by using thefieldsquery string parameter. For example:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://storage.googleapis.com/storage/v1/b/BUCKET_NAME?fields=FIELD1%2CFIELD2"
WhereFIELD#is a bucket property you want to include in the result. For example,projectNumberandstorageClass.
The response looks like the following example:
{ "projectNumber": "123456789012", "storageClass": "STANDARD" }
XML API
- Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorizationheader. - Use cURL to call the XML API with aGET Bucket request:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://storage.googleapis.com/BUCKET_NAME?QUERY_PARAMETER"
Where:BUCKET_NAMEis the name of the relevant bucket. For example,my-bucket.QUERY_PARAMETERis the metadata field you want to return. For example,storageClassfor getting the bucket's storage class. You can only use one query parameter at a time with the XML API. For a list of metadata fields supported by the XML API, see the GET Bucket reference page.
The response looks like the following example:<StorageClass>STANDARD</StorageClass>.