Use Autoclass (original) (raw)

Skip to main content

Use Autoclass

Overview

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

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

  1. In the Google Cloud console, go to the Cloud Storage Buckets page.
    Go to Buckets
  2. In the list of buckets, click the name of the desired bucket.
  3. In the Bucket details page, click the Configuration tab.
  4. Click the Edit icon () for Default storage class.
  5. 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.
  6. Click Confirm.
  7. 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:

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

  1. Have gcloud CLI installed and initialized, which lets you generate an access token for the Authorization header.
  2. 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 is true to enable Autoclass or false to disable Autoclass.
    • TERMINAL_CLASS is theterminal storage class to use when Autoclass is enabled.
  3. 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

  1. In the Google Cloud console, go to the Cloud Storage Buckets page.
    Go to Buckets
  2. Click the name of the bucket whose status you want to check.
  3. Click the Configuration tab.
  4. 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

  1. Have gcloud CLI installed and initialized, which lets you generate an access token for the Authorization header.
  2. Use cURL to call the JSON API with aGET Bucket request that includes the autoclass 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

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.