Help Center/ Object Storage Service/ SDK Reference/ Go/ Bucket APIs (SDK for Go)/ Direct Reading/ Obtaining the Direct Reading Configuration of Archive Storage Objects in a Bucket
Updated on 2026-11-09 GMT+08:00

Obtaining the Direct Reading Configuration of Archive Storage Objects in a Bucket

Function

A bucket owner can call this API to obtain the direct reading status of Archive Storage objects in the bucket.

If direct reading has never been configured for Archive Storage objects in the bucket or the direct reading configuration has been deleted, no direct reading status will be returned after this API call.

If direct reading of Archive Storage objects is configured for a bucket, you can call this API to obtain the direct reading status of Archive Storage objects in the bucket. For more information about direct reading of Archive Storage data, see Direct Reading.

Restrictions

Method

func (obsClient ObsClient) GetBucketDirectColdAccess(BucketName *string) (output *GetBucketDirectColdAccessOutput, err error)

Request Parameters

Table 1 List of request parameters

Parameter

Type

Mandatory (Yes/No)

Description

BucketName

string

Yes

Explanation:

Bucket name.

Restrictions:

  • A bucket name:
    • Must be unique across all accounts and regions. The name of a deleted bucket can be reused for another bucket or a parallel file system at least 30 minutes after the deletion.
    • Must be 3 to 63 characters long. Only lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot start or end with a period (.) or hyphen (-). It also cannot contain two consecutive periods (..) or have a period (.) and a hyphen (-) adjacent to each other.
    • Cannot be formatted as an IP address.
  • If you repeatedly create buckets with the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.

Value range:

None

Default value:

None

Responses

Table 2 List of returned results

Parameter

Type

Description

output

*GetBucketDirectColdAccessOutput

Explanation:

Returned results. For details, see Table 3.

Value range:

None

err

error

Explanation:

The error message returned by the server.

Value range:

None

Table 3 GetBucketDirectColdAccessOutput

Parameter

Type

Description

StatusCode

int

Explanation:

HTTP status code.

Value range:

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response. For more information, see Status Code.

RequestId

string

Explanation:

Request ID returned by the OBS server.

Value range:

None

ResponseHeaders

map[string][]string

Explanation:

HTTP response headers.

Value range:

None

DirectColdAccessConfiguration

DirectColdAccessConfiguration

Yes

Explanation:

Direct reading configuration of Archive Storage objects in a bucket.

Value range:

See Table 4.

Table 4 DirectColdAccessConfiguration

Parameter

Type

Mandatory (Yes/No)

Description

Status

DirectColdAccessStatus

Yes

Explanation:

Direct reading status of Archive Storage objects in a bucket.

Value range:

See Table 5.

Default value:

None

Table 5 DirectColdAccessStatus

Constant

Original Value

Description

DirectColdAccessStatusEnabled

Enabled

Direct reading is enabled for Archive Storage objects in the bucket.

DirectColdAccessStatusDisabled

Disabled

Direct reading is disabled for Archive Storage objects in the bucket.

Sample Code

This example obtains the direct reading status of Archive Storage objects in bucket examplebucket.

package main
import (
    "fmt"


    "os"
)
func main() {
    // Obtain an AK/SK pair using environment variables or import an AK/SK pair in other ways. Using hard coding may result in leakage.
    // Obtain an AK/SK pair on the management console.
    ak := os.Getenv("AccessKeyID")
    sk := os.Getenv("SecretAccessKey")
    // (Optional) If you use a temporary AK/SK pair and a security token to access OBS, you are not advised to use hard coding, which may result in information leakage. You can obtain an AK/SK pair using environment variables or import an AK/SK pair in other ways.
    securityToken := os.Getenv("SecurityToken")


    // Enter the endpoint corresponding to the bucket. CN-Hong Kong is used here as an example. Replace it with the one currently in use.
    endPoint := "https://obs.ap-southeast-1.myhuaweicloud.com"




    // Create an obsClient instance.
    // If you use a temporary AK/SK pair and a security token to access OBS, use the obs.WithSecurityToken method to specify a security token when creating an instance.
    obsClient, err := obs.New(ak, sk, endPoint, obs.WithSecurityToken(securityToken))
    if err != nil {
        fmt.Printf("Create obsClient error, errMsg: %s", err.Error())
    }
    // Specify a bucket name.
    bucketName := "examplebucket"
    // Obtain the direct reading status of Archive Storage objects in the bucket.
    output, err := obsClient.GetBucketDirectColdAccess(bucketName)
    if err == nil {
        fmt.Printf("Get bucket(%s)'s direct cold successful!\n", bucketName)
        fmt.Printf("Direct cold access status: %s\n", output.Status)
        fmt.Printf("RequestId:%s\n", output.RequestId)
        return
    }
    fmt.Printf("Get bucket(%s)'s direct cold fail!\n", bucketName)
    if obsError, ok := err.(obs.ObsError); ok {
        fmt.Println("An ObsError was found, which means your request sent to OBS was rejected with an error response.")
        fmt.Println(obsError.Error())
    } else {
        fmt.Println("An Exception was found, which means the client encountered an internal problem when attempting to communicate with OBS, for example, the client was unable to access the network.")
        fmt.Println(err)
    }
}