This page shows you how to enable, disable, and check the status of the Autoclass feature, which is set on a bucket in Cloud Storage.
Required roles
To get the permissions that you need to set and manage Autoclass on a bucket,
ask your administrator to grant you the Storage Admin (roles/storage.admin
)
IAM role on the bucket. This predefined role contains
the permissions required to set and manage Autoclass on a bucket. To see the
exact permissions that are required, expand the Required permissions
section:
Required permissions
storage.buckets.get
storage.buckets.list
- This permission is only required for using the Google Cloud console to perform the tasks on this page.
storage.buckets.update
You can also get these permissions with custom roles.
For information about granting roles on buckets, see Use IAM with buckets.
Set Autoclass for a bucket
To set Autoclass for a bucket, complete the following instructions:
Console
- In the Google Cloud console, go to the Cloud Storage Buckets page.
In the list of buckets, click the name of the desired bucket.
In the Bucket details page, click the Configuration tab.
Click the Edit icon (edit) for Default storage class.
In the overlay window, select Autoclass to enable Autoclass. To disable Autoclass, select Set a default class, and then select a default storage class for the bucket.
Click Confirm.
To switch the terminal storage class for a bucket that has Autoclass enabled, click the Edit icon (edit) for Included classes, and click Confirm in the overlay window that appears.
Command line
Use the gcloud storage buckets update
command with the
appropriate flag:
gcloud storage buckets update gs://BUCKET_NAME FLAG
Where:
BUCKET_NAME
is the name of the relevant bucket. For example,my-bucket
.FLAG
is one of the following:--enable-autoclass
to enable Autoclass.--no-enable-autoclass
to disable Autoclass.--autoclass-terminal-storage-class=CLASS
to set the terminal storage class for Autoclass. CLASS can be eitherNEARLINE
orARCHIVE
.
If successful, the response looks similar to the following example:
Updating gs://my-bucket/... Completed 1
Client libraries
For more information, see the
Cloud Storage C++ API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
For more information, see the
Cloud Storage C# API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
For more information, see the
Cloud Storage Go API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
For more information, see the
Cloud Storage Java API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
For more information, see the
Cloud Storage Node.js API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
For more information, see the
Cloud Storage PHP API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
For more information, see the
Cloud Storage Python API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
For more information, see the
Cloud Storage Ruby API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
C++
C#
Go
Java
Node.js
PHP
Python
Ruby
REST APIs
JSON API
Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorization
header.Create a JSON file that contains the following information:
{ "storageClass": "DEFAULT_CLASS", "autoclass": { "enabled": BOOLEAN, "terminalStorageClass":TERMINAL_CLASS } }
Where:
DEFAULT_CLASS
sets the storage class metadata for the bucket. When enabling Autoclass,STANDARD
is the only valid value and is required if the bucket currently uses a different storage class.BOOLEAN
istrue
to enable Autoclass orfalse
to disable Autoclass.TERMINAL_CLASS
is the terminal storage class to use when Autoclass is enabled.
Use
cURL
to call the JSON API with aPATCH
Bucket request:curl -X PATCH --data-binary @JSON_FILE_NAME \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME?fields=autoclass"
Where:
JSON_FILE_NAME
is the path for the JSON file that you created in Step 2.BUCKET_NAME
is the name of the relevant bucket. For example,my-bucket
.
XML API
This feature cannot be managed through the XML API. Use the Google Cloud console or another tool instead.
View a bucket's Autoclass status
To view the Autoclass status for an individual bucket:
Console
- In the Google Cloud console, go to the Cloud Storage Buckets page.
Click the name of the bucket whose status you want to check.
Click the Configuration tab.
The status for Autoclass is displayed in the Default storage class field.
If Autoclass is enabled, the field reads Managed with Autoclass, and the Included classes field displays the storage classes that objects can transition between.
Command line
Use the gcloud storage buckets describe
command with the
--format
flag:
gcloud storage buckets describe gs://BUCKET_NAME --format="default(autoclass)"
Where BUCKET_NAME
is the name of the bucket
whose status you want to view. For example, my-bucket
.
If successful, the response looks similar to the following example:
autoclass: enabled: true terminalStorageClass: ARCHIVE terminalStorageClassUpdateTime: '2023-02-10T16:11:02.384000+00:00' toggleTime: '2022-11-09T16:01:40.775000+00:00'
Client libraries
For more information, see the
Cloud Storage C++ API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
For more information, see the
Cloud Storage C# API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
For more information, see the
Cloud Storage Go API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
For more information, see the
Cloud Storage Java API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
For more information, see the
Cloud Storage Node.js API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
For more information, see the
Cloud Storage PHP API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
For more information, see the
Cloud Storage Python API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
For more information, see the
Cloud Storage Ruby API
reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials.
For more information, see
Set up authentication for client libraries.
C++
C#
Go
Java
Node.js
PHP
Python
Ruby
REST APIs
JSON API
Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorization
header.Use
cURL
to call the JSON API with aGET
Bucket request that includes theautoclass
field:curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME?fields=autoclass"
Where
BUCKET_NAME
is the name of the relevant bucket. For example,my-bucket
.If the bucket has Autoclass enabled, the response looks like the following example:
{ "autoclass": { "enabled": "BOOLEAN", "toggleTime": "DATETIME", "terminalStorageClass": "STORAGE_CLASS", "terminalStorageClassUpdateTime": "DATETIME" }, }
XML API
This feature cannot be managed through the XML API. Use the Google Cloud console or another tool instead.
What's next
- Learn more about Autoclass.
- Learn about Object Lifecycle Management, which automatically changes an object's storage class when it meets criteria you specify.