All Products
Search
Document Center

Object Storage Service:list-buckets(get-service)

Last Updated:Aug 27, 2024

Lists all buckets owned by a requester.

Usage notes

  • To list all buckets owned by a requester, you must have the oss: ListBuckets(GetService) permission. For more information, see Attach a custom policy to a RAM user.

  • You can specify the prefix, marker, or max-keys parameter to query the buckets that meet the specified conditions.

  • If all buckets are returned when you run the command, the response parameters in the XML format do not contain the Prefix, Marker, MaxKeys, IsTruncated, or NextMarker response elements.

Command syntax

ossutil api list-buckets [flags]

Parameter

Type

Description

--marker

string

The name of the bucket.

--max-keys

int

The maximum number of buckets that can be returned for the request.

--prefix

string

The prefix that the names of the buckets that you want to return must contain.

--resource-group-id

string

The ID of the resource group to which the bucket belongs.

Note
  • The list-buckets command corresponds to the ListBuckets (GetService) operation. For more information about the parameters in the ListBuckets (GetService) operation, see ListBuckets(GetService).

  • For more information about supported global command-line options, see Global command-line options.

Examples

  • Run the following command to list all buckets that are owned by the requester:

    ossutil api list-buckets
  • Run the following command to list all buckets that are owned by the requester and display the buckets in the JSON format:

    ossutil api list-buckets --output-format json
  • Run the following command to list all buckets that are owned by the requester and display the buckets in the YAML format:

    ossutil api list-buckets --output-format yaml
  • Run the following command to list the buckets whose names contain the example prefix and that are owned by the requester:

    ossutil api list-buckets --prefix example
  • Run the following command to list the first 100 buckets that are owned by the requester:

    ossutil api list-buckets --max-keys 100
  • Run the following command to list the buckets whose names are alphabetically after examplebucket and that are owned by the requester:

    ossutil api list-buckets --marker examplebucket
  • Run the following command to list the buckets that belong to a resource group whose ID is rg-123:

    ossutil api list-buckets --resource-group-id rg-123