This topic describes how to use Go SDK V2 to manage and configure resource pool Quality of Service (QoS).
Precautions
The sample code in this topic uses the China (Hangzhou) region ID
cn-hangzhouas an example. By default, the public Endpoint is used. If you want to access OSS from other Alibaba Cloud products in the same region, use an internal network Endpoint. For more information about the mappings between OSS-supported regions and Endpoints, see Regions and Endpoints.
Bucket bandwidth management
Configure throttling for a bucket in a resource pool
package main
import (
"bytes"
"context"
"crypto/md5"
"encoding/base64"
"fmt"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func PutBucketQoSInfo() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the bucket name.
bucketName := "examplebucket"
// Read the content of the QoS configuration file.
qosConf, err := os.ReadFile("qos.xml")
if err != nil {
// If an error occurs when reading the QoS configuration file, print the error message and exit the program.
fmt.Printf("failed to read qos.xml: %v\n", err)
os.Exit(1)
}
// Calculate the MD5 hash of the input data and convert it to a Base64-encoded string.
calcMd5 := func(input []byte) string {
if len(input) == 0 {
return "1B2M2Y8AsgTpgAmY7PhCfg=="
}
h := md5.New()
h.Write(input)
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "PutBucketQoSInfo", // Action
Method: "PUT", // HTTP method
Parameters: map[string]string{
"qosInfo": "", // QoS-related parameters
},
Headers: map[string]string{
"Content-MD5": calcMd5(qosConf), // Set the Content-MD5 header for the request body to ensure data integrity.
},
Body: bytes.NewReader(qosConf), // Request body that contains the QoS configuration.
Bucket: oss.Ptr(bucketName), // Bucket name
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Print the operation result.
fmt.Println("The result of PutBucketQoSInfo:", res.Status)
}Get the throttling configuration of a bucket
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func GetBucketQoSInfo() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the bucket name.
bucketName := "examplebucket"
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "GetBucketQoSInfo", // Action
Method: "GET", // HTTP method
Parameters: map[string]string{
"qosInfo": "", // QoS-related parameters
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // The request body is typically empty for a GET request.
Bucket: oss.Ptr(bucketName), // Bucket name
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Read the response body.
body, err := io.ReadAll(res.Body)
if err != nil {
// If an error occurs when reading the response body, print the error message and exit the program.
fmt.Printf("failed to read response body: %v\n", err)
os.Exit(1)
}
// Close the response body to release resources.
if res.Body != nil {
res.Body.Close()
}
// Print the operation result.
fmt.Println("The result of GetBucketQoSInfo:", string(body))
}Delete the throttling configuration of a specific bucket in a resource pool
package main
import (
"context"
"fmt"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func DeleteBucketQoSInfo() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the bucket name.
bucketName := "examplebucket"
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "DeleteBucketQoSInfo", // Action
Method: "DELETE", // HTTP method
Parameters: map[string]string{
"qosInfo": "", // QoS-related parameters
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // The request body is typically empty for a DELETE request.
Bucket: oss.Ptr(bucketName), // Bucket name
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Print the operation result.
fmt.Println("The result of DeleteBucketQoSInfo:", res.Status)
}Bandwidth management for different requesters at the bucket level
Configure throttling for a requester at the bucket level
package main
import (
"bytes"
"context"
"crypto/md5"
"encoding/base64"
"fmt"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func PutBucketRequesterQoSInfo() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the bucket name and requester ID.
bucketName := "examplebucket"
requester := "2598732222222xxxx"
// Read the content of the QoS configuration file.
qosConf, err := os.ReadFile("qos.xml")
if err != nil {
// If an error occurs when reading the QoS configuration file, print the error message and exit the program.
fmt.Printf("failed to read qos.xml: %v\n", err)
os.Exit(1)
}
// Calculate the MD5 hash of the input data and convert it to a Base64-encoded string.
calcMd5 := func(input []byte) string {
if len(input) == 0 {
return "1B2M2Y8AsgTpgAmY7PhCfg=="
}
h := md5.New()
h.Write(input)
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "PutBucketRequesterQoSInfo", // The action must match the actual operation.
Method: "PUT", // HTTP method
Parameters: map[string]string{
"requesterQosInfo": "", // Requester QoS-related parameters.
"qosRequester": requester, // Requester ID
},
Headers: map[string]string{
"Content-MD5": calcMd5(qosConf), // Set the Content-MD5 header for the request body to ensure data integrity.
},
Body: bytes.NewReader(qosConf), // Request body that contains the QoS configuration.
Bucket: oss.Ptr(bucketName), // Bucket name
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Print the operation result.
fmt.Println("The result of PutBucketRequesterQoSInfo:", res.Status)
}Get the throttling configuration for a specific requester at the bucket level
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func GetBucketRequesterQoSInfo() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the bucket name and requester ID.
bucketName := "examplebucket"
requester := "2598732222222xxxx"
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "GetBucketRequesterQoSInfo", // Action
Method: "GET", // HTTP method
Parameters: map[string]string{
"requesterQosInfo": "", // Requester QoS-related parameters.
"qosRequester": requester, // Requester ID
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // The request body is typically empty for a GET request.
Bucket: oss.Ptr(bucketName), // Bucket name
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Read the response body.
body, err := io.ReadAll(res.Body)
if err != nil {
// If an error occurs when reading the response body, print the error message and exit the program.
fmt.Printf("failed to read response body: %v\n", err)
os.Exit(1)
}
// Close the response body to release resources.
if res.Body != nil {
res.Body.Close()
}
// Print the operation result.
fmt.Println("The result of GetBucketRequesterQoSInfo:", string(body))
}Get the throttling configurations for all requesters at the bucket level
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func ListBucketRequesterQoSInfos() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the bucket name.
bucketName := "examplebucket"
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "ListBucketRequesterQoSInfos", // Action
Method: "GET", // HTTP method
Parameters: map[string]string{
"requesterQosInfo": "", // Requester QoS-related parameters.
// Optional parameters:
// "continuation-token": "25987311111111xxxx", // The continuation token for paging.
// "max-keys": "1", // The maximum number of entries to return.
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // The request body is typically empty for a GET request.
Bucket: oss.Ptr(bucketName), // Bucket name
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Read the response body.
body, err := io.ReadAll(res.Body)
if err != nil {
// If an error occurs when reading the response body, print the error message and exit the program.
fmt.Printf("failed to read response body: %v\n", err)
os.Exit(1)
}
// Close the response body to release resources.
if res.Body != nil {
res.Body.Close()
}
// Print the operation result.
fmt.Println("The result of ListBucketRequesterQoSInfos:", string(body))
}Delete the throttling configuration for a requester of a bucket
package main
import (
"context"
"fmt"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func DeleteBucketRequesterQoSInfo() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the bucket name and requester ID.
bucketName := "examplebucket"
requester := "2033310434633xxxx"
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "DeleteBucketRequesterQoSInfo", // Action
Method: "DELETE", // HTTP method
Parameters: map[string]string{
"requesterQosInfo": "", // Requester QoS-related parameters.
"qosRequester": requester, // Requester ID
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // The request body is typically empty for a DELETE request.
Bucket: oss.Ptr(bucketName), // Bucket name
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Print the operation result.
fmt.Println("The result of DeleteBucketRequesterQoSInfo:", res.Status)
}Bandwidth management for different requesters at the resource pool level
Get information about all resource pools under the current account
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func ListResourcePools() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "ListResourcePools", // Action
Method: "GET", // HTTP method
Parameters: map[string]string{
"resourcePool": "", // Resource pool-related parameters.
// Optional parameters:
// "continuation-token": "example-resource-pool", // The continuation token for paging.
// "max-keys": "1", // The maximum number of entries to return.
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // The request body is typically empty for a GET request.
Bucket: nil, // This operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Read the response body.
body, err := io.ReadAll(res.Body)
if err != nil {
// If an error occurs when reading the response body, print the error message and exit the program.
fmt.Printf("failed to read response body: %v\n", err)
os.Exit(1)
}
// Close the response body to release resources.
if res.Body != nil {
res.Body.Close()
}
// Print the operation result.
fmt.Println("The result of ListResourcePools:", string(body))
}Get information about a specific resource pool
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func GetResourcePoolInfo() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "GetResourcePoolInfo", // Action
Method: "GET", // HTTP method
Parameters: map[string]string{
"resourcePoolInfo": "", // Resource pool information-related parameters.
"resourcePool": "example-resource-pool", // The name of the resource pool to query.
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // The request body is typically empty for a GET request.
Bucket: nil, // This operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Read the response body.
body, err := io.ReadAll(res.Body)
if err != nil {
// If an error occurs when reading the response body, print the error message and exit the program.
fmt.Printf("failed to read response body: %v\n", err)
os.Exit(1)
}
// Close the response body to release resources.
if res.Body != nil {
res.Body.Close()
}
// Print the operation result.
fmt.Println("The result of GetResourcePoolInfo:", string(body))
}Get the list of buckets in a specific resource pool
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func ListResourcePoolBuckets() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "ListResourcePoolBucketGroups", // Action
Method: "GET", // HTTP method
Parameters: map[string]string{ // Parameter list
"resourcePool": "example-resource-pool", // Resource pool name
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // Request body
Bucket: nil, // The bucket name is empty because this operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Read the response body.
body, err := io.ReadAll(res.Body)
if err != nil {
// If an error occurs when reading the response body, print the error message and exit the program.
fmt.Printf("failed to read response body: %v\n", err)
os.Exit(1)
}
// Close the response body to release resources.
if res.Body != nil {
res.Body.Close()
}
// Print the operation result.
fmt.Println("The result of ListResourcePoolBucketGroups:", string(body))
}Configure throttling for a requester in a resource pool
package main
import (
"bytes"
"context"
"crypto/md5"
"encoding/base64"
"fmt"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func PutResourcePoolRequesterQoSInfo() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the resource pool name and requester ID.
resourcePool := "example-resource-pool"
requester := "2598733333333xxxx"
// Read the content of the QoS configuration file.
qosConf, err := os.ReadFile("qos.xml")
if err != nil {
// If an error occurs when reading the QoS configuration file, print the error message and exit the program.
fmt.Printf("failed to read qos.xml: %v\n", err)
os.Exit(1)
}
// Calculate the MD5 hash of the input data and convert it to a Base64-encoded string.
calcMd5 := func(input []byte) string {
if len(input) == 0 {
return "1B2M2Y8AsgTpgAmY7PhCfg=="
}
h := md5.New()
h.Write(input)
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "PutResourcePoolRequesterQoSInfo", // Action
Method: "PUT", // HTTP method
Parameters: map[string]string{
"requesterQosInfo": "", // Requester QoS-related parameters.
"resourcePool": resourcePool, // Resource pool name
"qosRequester": requester, // Requester ID
},
Headers: map[string]string{
"Content-MD5": calcMd5(qosConf), // Set the Content-MD5 header for the request body to ensure data integrity.
},
Body: bytes.NewReader(qosConf), // Request body that contains the QoS configuration.
Bucket: nil, // This operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Print the operation result.
fmt.Println("The result of PutResourcePoolRequesterQoSInfo:", res.Status)
}Get the throttling configuration for a specific requester in a resource pool
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func GetResourcePoolRequesterQoSInfo() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the resource pool name and requester ID.
resourcePool := "example-resource-pool"
requester := "2598732222222xxxx"
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "GetResourcePoolRequesterQoSInfo", // Action
Method: "GET", // HTTP method
Parameters: map[string]string{
"requesterQosInfo": "", // Requester QoS-related parameters.
"resourcePool": resourcePool, // Resource pool name
"qosRequester": requester, // Requester ID
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // A request body is not typically required for a GET request.
Bucket: nil, // This operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Read the response body.
body, err := io.ReadAll(res.Body)
if err != nil {
// If an error occurs when reading the response body, print the error message and exit the program.
fmt.Printf("failed to read response body: %v\n", err)
os.Exit(1)
}
// Close the response body to release resources.
if res.Body != nil {
res.Body.Close()
}
// Print the operation result.
fmt.Println("The result of GetResourcePoolRequesterQoSInfo:", string(body))
}Get the throttling configurations for all requesters in a resource pool
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func ListResourcePoolRequesterQoSInfos() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the resource pool name.
resourcePool := "example-resource-pool"
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "ListResourcePoolRequesterQoSInfos", // Action
Method: "GET", // HTTP method
Parameters: map[string]string{
"requesterQosInfo": "", // Requester QoS-related parameters.
"resourcePool": resourcePool, // Resource pool name
// Optional parameters:
// "continuation-token": "25987311111111xxxx", // The continuation token for paging.
// "max-keys": "1", // The maximum number of entries to return.
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // A request body is not typically required for a GET request.
Bucket: nil, // This operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Read the response body.
body, err := io.ReadAll(res.Body)
if err != nil {
// If an error occurs when reading the response body, print the error message and exit the program.
fmt.Printf("failed to read response body: %v\n", err)
os.Exit(1)
}
// Close the response body to release resources.
if res.Body != nil {
res.Body.Close()
}
// Print the operation result.
fmt.Println("The result of ListResourcePoolRequesterQoSInfos:", string(body))
}Delete the throttling configuration for a specific requester in a resource pool
package main
import (
"context"
"fmt"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func DeleteResourcePoolRequesterQoSInfo() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the resource pool name and requester ID.
resourcePool := "example-resource-pool"
requester := "2598732222222xxxx"
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "DeleteResourcePoolRequesterQoSInfo", // Action
Method: "DELETE", // HTTP method
Parameters: map[string]string{
"requesterQosInfo": "", // Requester QoS-related parameters.
"resourcePool": resourcePool, // Resource pool name
"qosRequester": requester, // Requester ID
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // A request body is not typically required for a DELETE request.
Bucket: nil, // This operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Print the operation result.
fmt.Println("The result of DeleteResourcePoolRequesterQoSInfo:", res.Status)
}Resource pool priority QoS management
Set the priority QoS configuration for a resource pool
package main
import (
"bytes"
"context"
"crypto/md5"
"encoding/base64"
"fmt"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func PutResourcePoolPriorityQosConfiguration() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the resource pool name.
resourcePool := "hz-rp-01"
// Read the content of the priority QoS configuration file.
qosConf, err := os.ReadFile("priority-qos.xml")
if err != nil {
// If an error occurs when reading the QoS configuration file, print the error message and exit the program.
fmt.Printf("failed to read qos.xml: %v\n", err)
os.Exit(1)
}
// Calculate the MD5 hash of the input data and convert it to a Base64-encoded string.
calcMd5 := func(input []byte) string {
if len(input) == 0 {
return "1B2M2Y8AsgTpgAmY7PhCfg=="
}
h := md5.New()
h.Write(input)
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "PutResourcePoolPriorityQoSConfiguration", // Action
Method: "PUT", // HTTP method
Parameters: map[string]string{
"priorityQos": "", // Priority QoS-related parameters.
"resourcePool": resourcePool, // Resource pool name
},
Headers: map[string]string{
"Content-MD5": calcMd5(qosConf), // Set the Content-MD5 header for the request body to ensure data integrity.
},
Body: bytes.NewReader(qosConf), // Request body that contains the QoS configuration.
Bucket: nil, // This operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Print the operation result.
fmt.Println("The result of PutResourcePoolPriorityQoSConfiguration:", res.Status)
}Get the priority QoS configuration of a resource pool
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func GetResourcePoolPriorityQosConfiguration() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the resource pool name.
resourcePool := "hz-rp-01"
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "GetResourcePoolPriorityQoSConfiguration", // Action
Method: "GET", // HTTP method
Parameters: map[string]string{
"priorityQos": "", // Priority QoS-related parameters.
"resourcePool": resourcePool, // Resource pool name
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // A request body is not typically required for a GET request.
Bucket: nil, // This operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Read the response body.
body, err := io.ReadAll(res.Body)
if err != nil {
// If an error occurs when reading the response body, print the error message and exit the program.
fmt.Printf("failed to read response body: %v\n", err)
os.Exit(1)
}
// Close the response body to release resources.
if res.Body != nil {
res.Body.Close()
}
// Print the operation result.
fmt.Println("The result of GetResourcePoolPriorityQosConfiguration:", string(body))
}Delete the priority QoS configuration of a resource pool
package main
import (
"bytes"
"context"
"crypto/md5"
"encoding/base64"
"fmt"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func DeleteResourcePoolPriorityQosConfiguration() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the resource pool name.
resourcePool := "hz-rp-01"
// Read the content of the priority QoS configuration file.
qosConf, err := os.ReadFile("priority-qos.xml")
if err != nil {
// If an error occurs when reading the QoS configuration file, print the error message and exit the program.
fmt.Printf("failed to read qos.xml: %v\n", err)
os.Exit(1)
}
// Calculate the MD5 hash of the input data and convert it to a Base64-encoded string.
calcMd5 := func(input []byte) string {
if len(input) == 0 {
return "1B2M2Y8AsgTpgAmY7PhCfg=="
}
h := md5.New()
h.Write(input)
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "DeleteResourcePoolPriorityQosConfiguration", // Action
Method: "DELETE", // HTTP method
Parameters: map[string]string{
"priorityQos": "", // Priority QoS-related parameters.
"resourcePool": resourcePool, // Resource pool name
},
Headers: map[string]string{
"Content-MD5": calcMd5(qosConf), // Set the Content-MD5 header for the request body to ensure data integrity.
},
Body: bytes.NewReader(qosConf), // Request body that contains the QoS configuration.
Bucket: nil, // This operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Print the operation result.
fmt.Println("The result of DeleteResourcePoolPriorityQosConfiguration:", res.Status)
}Set the priority QoS configuration for a requester in a resource pool
package main
import (
"bytes"
"context"
"crypto/md5"
"encoding/base64"
"fmt"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func PutResourcePoolRequesterPriorityQosConfiguration() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the resource pool name.
resourcePool := "hz-rp-01"
// Read the content of the requester priority QoS configuration file.
qosConf, err := os.ReadFile("requester-priority-qos.xml")
if err != nil {
// If an error occurs when reading the QoS configuration file, print the error message and exit the program.
fmt.Printf("failed to read qos.xml: %v\n", err)
os.Exit(1)
}
// Calculate the MD5 hash of the input data and convert it to a Base64-encoded string.
calcMd5 := func(input []byte) string {
if len(input) == 0 {
return "1B2M2Y8AsgTpgAmY7PhCfg=="
}
h := md5.New()
h.Write(input)
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "PutResourcePoolRequesterPriorityQoSConfiguration", // Action
Method: "PUT", // HTTP method
Parameters: map[string]string{
"requesterPriorityQos": "", // Requester priority QoS-related parameters.
"resourcePool": resourcePool, // Resource pool name
},
Headers: map[string]string{
"Content-MD5": calcMd5(qosConf), // Set the Content-MD5 header for the request body to ensure data integrity.
},
Body: bytes.NewReader(qosConf), // Request body that contains the QoS configuration.
Bucket: nil, // This operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Print the operation result.
fmt.Println("The result of PutResourcePoolRequesterPriorityQoSConfiguration:", res.Status)
}Get the priority QoS configuration for a requester in a resource pool
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func GetResourcePoolRequesterPriorityQosConfiguration() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the resource pool name.
resourcePool := "hz-rp-01"
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "GetResourcePoolRequesterPriorityQoSConfiguration", // Action
Method: "GET", // HTTP method
Parameters: map[string]string{
"requesterPriorityQos": "", // Requester priority QoS-related parameters.
"resourcePool": resourcePool, // Resource pool name
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // A request body is not typically required for a GET request.
Bucket: nil, // This operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Read the response body.
body, err := io.ReadAll(res.Body)
if err != nil {
// If an error occurs when reading the response body, print the error message and exit the program.
fmt.Printf("failed to read response body: %v\n", err)
os.Exit(1)
}
// Close the response body to release resources.
if res.Body != nil {
res.Body.Close()
}
// Print the operation result.
fmt.Println("The result of GetResourcePoolRequesterPriorityQosConfiguration:", string(body))
}Delete the priority QoS configuration for a requester in a resource pool
package main
import (
"bytes"
"context"
"crypto/md5"
"encoding/base64"
"fmt"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func DeleteResourcePoolRequesterPriorityQosConfiguration() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the resource pool name.
resourcePool := "hz-rp-01"
// Read the content of the requester priority QoS configuration file.
qosConf, err := os.ReadFile("priority-qos.xml")
if err != nil {
// If an error occurs when reading the QoS configuration file, print the error message and exit the program.
fmt.Printf("failed to read qos.xml: %v\n", err)
os.Exit(1)
}
// Calculate the MD5 hash of the input data and convert it to a Base64-encoded string.
calcMd5 := func(input []byte) string {
if len(input) == 0 {
return "1B2M2Y8AsgTpgAmY7PhCfg=="
}
h := md5.New()
h.Write(input)
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "DeleteResourcePoolRequesterPriorityQoSConfiguration", // Action
Method: "DELETE", // HTTP method
Parameters: map[string]string{
"requesterPriorityQos": "", // Requester priority QoS-related parameters.
"resourcePool": resourcePool, // Resource pool name
},
Headers: map[string]string{
"Content-MD5": calcMd5(qosConf), // Set the Content-MD5 header for the request body to ensure data integrity.
},
Body: bytes.NewReader(qosConf), // Request body that contains the QoS configuration.
Bucket: nil, // This operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Print the operation result.
fmt.Println("The result of DeleteResourcePoolRequesterPriorityQosConfiguration:", res.Status)
}Bucket group bandwidth management
Add a bucket from a resource pool to a specific bucket group
package main
import (
"context"
"fmt"
"io"
"os"
"strings"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
// The PutBucketResourcePoolBucketGroup function adds a bucket to a specified bucket group in a resource pool.
func PutBucketResourcePoolBucketGroup() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "PutBucketResourcePoolBucketGroup", // Action
Method: "PUT", // HTTP method
Parameters: map[string]string{ // Parameter list
"resourcePoolBucketGroup": "example-group", // Resource pool bucket group name
"resourcePool": "example-resource-pool", // Resource pool name
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // Request body
Bucket: oss.Ptr("test-bucket"), // Bucket name
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
var body []byte
if b, ok := res.Body.(io.Reader); ok {
buf := new(strings.Builder)
_, _ = io.Copy(buf, b)
body = []byte(buf.String())
} else {
body = []byte(fmt.Sprintf("%v", res.Body))
}
// Print the operation result.
fmt.Println("The result of PutBucketResourcePoolBucketGroup:", string(body))
}Get the list of bucket groups in a specific resource pool
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
// The ListResourcePoolBucketGroups function lists the bucket groups in a specified resource pool.
func ListResourcePoolBucketGroups() {
// Define the region. This example uses "cn-hangzhou".
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "ListResourcePoolBucketGroups", // Action
Method: "GET", // HTTP method
Parameters: map[string]string{ // Parameter list
"resourcePool": "example-resource-pool", // Resource pool name
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // Request body
Bucket: nil, // The bucket name is empty because this operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Read the response body.
body, err := io.ReadAll(res.Body)
if err != nil {
// If an error occurs when reading the response body, print the error message and exit the program.
fmt.Printf("failed to read response body: %v\n", err)
os.Exit(1)
}
// Close the response body to release resources.
if res.Body != nil {
res.Body.Close()
}
// Print the operation result.
fmt.Println("The result of ListResourcePoolBucketGroups:", string(body))
}Modify the throttling configuration of a bucket group in a resource pool
package main
import (
"bytes"
"context"
"crypto/md5"
"encoding/base64"
"fmt"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
func PutResourcePoolBucketGroupQosInfo() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the resource pool name and the bucket group name.
resourcePool := "example-resource-pool"
group := "example-group"
// Read the content of the QoS configuration file.
qosConf, err := os.ReadFile("qos.xml")
if err != nil {
// If an error occurs when reading the QoS configuration file, print the error message and exit the program.
fmt.Printf("failed to read qos.xml: %v\n", err)
os.Exit(1)
}
// Calculate the MD5 hash of the input data and convert it to a Base64-encoded string.
calcMd5 := func(input []byte) string {
if len(input) == 0 {
return "1B2M2Y8AsgTpgAmY7PhCfg=="
}
h := md5.New()
h.Write(input)
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "PutResourcePoolBucketGroupQoSInfo", // Action
Method: "PUT", // HTTP method
Parameters: map[string]string{ // Parameter list
"resourcePool": resourcePool, // Resource pool name
"resourcePoolBucketGroup": group, // Bucket group name
"resourcePoolBucketGroupQosInfo": "", // QoS-related parameters
},
Headers: map[string]string{ // HTTP headers
"Content-MD5": calcMd5(qosConf), // Set the Content-MD5 header for the request body to ensure data integrity.
},
Body: bytes.NewReader(qosConf), // Request body that contains the QoS configuration.
Bucket: nil, // The bucket name is empty because this operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Print the operation result.
fmt.Println("The result of PutResourcePoolBucketGroupQoSInfo:", res.Status)
}Get the throttling configuration of a bucket group in a resource pool
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
// The GetResourcePoolBucketGroupQosInfo function gets the QoS information of a specified bucket group in a resource pool.
func GetResourcePoolBucketGroupQosInfo() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the resource pool name and the bucket group name.
resourcePool := "example-resource-pool"
ResourcePoolBucketGroup := "example-group"
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "GetResourcePoolBucketGroupQoSInfo", // Action
Method: "GET", // HTTP method
Parameters: map[string]string{ // Parameter list
"resourcePool": resourcePool, // Resource pool name
"resourcePoolBucketGroup": ResourcePoolBucketGroup, // Bucket group name
"resourcePoolBucketGroupQoSInfo": "", // QoS-related parameters
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // The request body is typically empty for a GET request.
Bucket: nil, // The bucket name is empty because this operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Read the response body.
body, err := io.ReadAll(res.Body)
if err != nil {
// If an error occurs when reading the response body, print the error message and exit the program.
fmt.Printf("failed to read response body: %v\n", err)
os.Exit(1)
}
// Close the response body to release resources.
if res.Body != nil {
res.Body.Close()
}
// Print the operation result.
fmt.Println("The result of GetResourcePoolBucketGroupQoSInfo:", string(body))
}List the throttling configurations of bucket groups in a resource pool
package main
import (
"context"
"fmt"
"io"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
// The ListResourcePoolBucketGroupQosInfos function lists the QoS information of all bucket groups in a specified resource pool.
func ListResourcePoolBucketGroupQosInfos() {
// Specify the region where the bucket is located. For example, set the region to cn-hangzhou for China (Hangzhou).
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the resource pool name.
resourcePool := "example-resource-pool"
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "ListResourcePoolBucketGroupQoSInfos", // Action
Method: "GET", // HTTP method
Parameters: map[string]string{ // Parameter list
"resourcePool": resourcePool, // Resource pool name
// Optional parameters:
// "continuation-token": "25987311111111xxxx", // The continuation token for paging.
// "max-keys": "1", // The maximum number of entries to return.
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // The request body is typically empty for a GET request.
Bucket: nil, // The bucket name is empty because this operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Read the response body.
body, err := io.ReadAll(res.Body)
if err != nil {
// If an error occurs when reading the response body, print the error message and exit the program.
fmt.Printf("failed to read response body: %v\n", err)
os.Exit(1)
}
// Close the response body to release resources.
if res.Body != nil {
res.Body.Close()
}
// Print the operation result.
fmt.Println("The result of ListResourcePoolBucketGroupQoSInfos:", string(body))
}Delete the throttling configuration of a bucket group in a resource pool
package main
import (
"context"
"fmt"
"os"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)
// The DeleteResourcePoolBucketGroupQosInfo function deletes the QoS information of a specified bucket group in a resource pool.
func DeleteResourcePoolBucketGroupQosInfo() {
// Define the region. This example uses "cn-hangzhou".
var region = "cn-hangzhou"
// Load the default configurations and set the credential provider and region.
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region)
// Create an OSS client.
client := oss.NewClient(cfg)
// Define the resource pool name and the bucket group name.
resourcePool := "example-resource-pool"
group := "example-group"
// Create the input parameters for the operation, including the action, method type, and parameters.
input := &oss.OperationInput{
OpName: "DeleteResourcePoolBucketGroupQoSInfo", // Action
Method: "DELETE", // HTTP method
Parameters: map[string]string{ // Parameter list
"resourcePool": resourcePool, // Resource pool name
"resourcePoolBucketGroup": group, // Bucket group name
"resourcePoolBucketGroupQoSInfo": "", // QoS-related parameters
},
Headers: map[string]string{}, // HTTP headers
Body: nil, // The request body is typically empty for a DELETE request.
Bucket: nil, // The bucket name is empty because this operation does not target a specific bucket.
}
// Execute the operation and receive the response or an error.
res, err := client.InvokeOperation(context.TODO(), input)
if err != nil {
// If an error occurs, print the error message and exit the program.
fmt.Printf("invoke operation got error: %v\n", err)
os.Exit(1)
}
// Print the operation result.
fmt.Println("The result of DeleteResourcePoolBucketGroupQoSInfo:", res.Status)
}References
For more information about the API operations for resource pool QoS, see Resource pool QoS operations.
For more configuration examples of resource pool QoS, see Resource pool QoS configuration examples.