Use Autoclass (original) (raw)
Discover
Get started
Create buckets
Access and manage buckets
Upload and download objects
Access and manage objects
Tools to access and manage objects using a directory structure
Get insights on your stored data
Cache objects
Control data lifecycles
Make requests
Secure data
Access control
- Overview
- Bucket IP filtering
* Overview
* Create a bucket with IP filtering rules
* Create or update IP filtering rules on an existing bucket
* Get IP bucket filtering rules
* List bucket IP filtering rules
* Delete bucket IP filtering rules
* Disable bucket IP filtering
* Bypass bucket IP filtering rules - Sharing and collaboration scenarios
- Access control best practices
Monitor data and usage
Protection, backup, and recovery
Soft delete
Mount buckets with Cloud Storage FUSE
Performance
Work across products, Clouds, and platforms
Troubleshoot
Use Autoclass
This page shows you how to enable, disable, and check the status of theAutoclass 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 permissionssection:
Required permissions
storage.buckets.getstorage.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, seeSet and manage IAM policies on 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.
Go to Buckets - 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 () 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 () for Included classes, and click Confirm in the overlay window that appears.
Command line
Use the gcloud storage buckets update command with the appropriate flags:
gcloud storage buckets update gs://BUCKET_NAME --default-storage-class=DEFAULT_CLASS AUTOCLASS_FLAG
Where:
BUCKET_NAMEis the name of the relevant bucket. For example,my-bucket.DEFAULT_CLASSsets the storage class metadata for the bucket. When enabling Autoclass,STANDARDis the only valid value and is required if the bucket currently uses a different storage class.AUTOCLASS_FLAGis one of the following:--enable-autoclassto enable Autoclass.--no-enable-autoclassto disable Autoclass.--autoclass-terminal-storage-class=CLASSto set the terminal storage class for Autoclass. CLASScan be eitherNEARLINEorARCHIVE. When using this flag on a bucket with Autoclass disabled, also include the--enable-autoclassflag in the command.
If successful, the response looks similar to the following example:
Updating gs://my-bucket/... Completed 1
Client libraries
C++
For more information, see theCloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
C#
For more information, see theCloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Go
For more information, see theCloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Java
For more information, see theCloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Node.js
For more information, see theCloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
PHP
For more information, see theCloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Python
For more information, see theCloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Ruby
For more information, see theCloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
REST APIs
JSON API
- Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorizationheader. - Create a JSON file that contains the following information:
{
"storageClass": "DEFAULT_CLASS",
"autoclass": {
"enabled": BOOLEAN,
"terminalStorageClass":TERMINAL_CLASS
}
}
Where:DEFAULT_CLASSsets the storage class metadata for the bucket. When enabling Autoclass,STANDARDis the only valid value and is required if the bucket currently uses a different storage class.BOOLEANistrueto enable Autoclass orfalseto disable Autoclass.TERMINAL_CLASSis theterminal 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_NAMEis the path for the JSON file that you created in Step 2.BUCKET_NAMEis 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.
Go to Buckets - 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 classfield.
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
C++
For more information, see theCloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
C#
For more information, see theCloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Go
For more information, see theCloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Java
For more information, see theCloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Node.js
For more information, see theCloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
PHP
For more information, see theCloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Python
For more information, see theCloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Ruby
For more information, see theCloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
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 API with aGET Bucket request that includes the
autoclassfield:
curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://storage.googleapis.com/storage/v1/b/BUCKET_NAME?fields=autoclass"
WhereBUCKET_NAMEis 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.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-09 UTC.