Configuring Direct Reading for Archive Storage Objects in a Bucket
Function
Direct reading means that you can directly perform operations on Archive Storage objects without restoring them.
By default, direct reading is disabled for Archive Storage objects in a bucket.
This API is used to enable or disable direct reading for Archive Storage objects in a bucket.
- When direct reading is enabled for Archive Storage objects in a bucket:
- You can directly perform operations on Archive Storage objects in the bucket regardless of whether they have been restored.
- If Archive Storage objects are not restored, your operations on them will be charged separately.
- When direct reading is disabled for Archive Storage objects in a bucket:
- You need to restore objects in the bucket before you can operate them.
Direct reading means that you can directly perform operations on objects without restoring them. For more information about direct reading of Archive Storage data, see Direct Reading.
Restrictions
- To configure direct reading for Archive Storage objects in a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutDirectColdAccessConfiguration granted using IAM or PutDirectColdAccessConfiguration granted using a bucket policy). For details, see Introduction to OBS Access Control, IAM Custom Policies, and Creating a Custom Bucket Policy.
- The mapping between OBS regions and endpoints must comply with what is listed in Regions and Endpoints.
Method
func (obsClient ObsClient) SetBucketDirectColdAccess(input *SetBucketDirectColdAccessInput) (output *BaseModel, err error)
Request Parameters
| Parameter | Type | Mandatory (Yes/No) | Description |
|---|---|---|---|
| input | Yes | Explanation: Request parameter for configuring direct reading for Archive Storage objects in a bucket. For details, see Table 2. Restrictions: None Value range: None Default value: None |
| Parameter | Type | Mandatory (Yes/No) | Description |
|---|---|---|---|
| Bucket | string | Yes | Explanation: Bucket name. Restrictions:
Value range: None Default value: None |
| DirectColdAccessConfiguration | Yes | Explanation: Direct reading configuration of Archive Storage objects in a bucket. Restrictions: None Value range: See Table 3. Default value: None |
| Parameter | Type | Mandatory (Yes/No) | Description |
|---|---|---|---|
| Status | Yes | Explanation: Direct reading status of Archive Storage objects in a bucket. Restrictions: None Value range: See Table 4. Default value: None |
| 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. |
Responses
| Parameter | Type | Description |
|---|---|---|
| output | Explanation: Returned results. For details, see Table 6. Value range: None | |
| err | error | Explanation: The error message returned by the server. Value range: None |
| Parameter | Type | Description |
|---|---|---|
| StatusCode | int | Explanation: HTTP status code Restrictions: None 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. Default value: None |
| RequestId | string | Explanation: Request ID returned by the OBS server Restrictions: None Value range: None Default value: None |
| ResponseHeaders | map[string][]string | Explanation: HTTP response headers Restrictions: None Value range: None Default value: None |
Sample Code
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())
}
input := &obs.SetBucketDirectColdAccessInput{}
// Specify a bucket name.
input.Bucket = "examplebucket"
// Specify the status.
input.DirectColdAccessConfiguration.Status = obs.DirectColdAccessStatusEnabled
// Set the direct reading status for Archive Storage objects in the bucket.
output, err := obsClient.SetBucketDirectColdAccess(input)
if err == nil {
fmt.Printf("Set bucket(%s)'s direct cold successful!\n", input.Bucket)
fmt.Printf("RequestId:%s\n", output.RequestId)
return
}
fmt.Printf("Set bucket(%s)'s direct cold fail!\n", input.Bucket)
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)
}
} What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot