Tüm Ürünler
Search
Belge Merkezi

:Kaynak Havuzu QoS Yönetimi (Go SDK V2)

Son Güncelleme:Oct 02, 2026

Bu konuda, Go SDK V2 kullanılarak kaynak havuzu Hizmet Kalitesi (QoS) özelliklerinin nasıl yönetileceği ve yapılandırılacağı açıklanmaktadır.

Notlar

  • Bu konudaki örnek kodlar Çin (Hangzhou) bölgesini referans alır. Bölge kimliği cn-hangzhou olarak ayarlanmıştır. Varsayılan olarak genel bir uç nokta kullanılır. OSS ile aynı bölgedeki diğer Alibaba Cloud ürünlerinden OSS'ye erişmek istiyorsanız özel ağ uç noktasını kullanın. OSS bölgeleri ile uç noktalar arasındaki eşleştirmeler hakkında daha fazla bilgi için bkz. Bölgeler ve Uç Noktalar.

Paket Bant Genişliği Yönetimi

Kaynak Havuzundaki Paketler İçin Kısıtlama Ayarlayın

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 main() {
	// 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 while 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 other parameters.
	input := &oss.OperationInput{
		OpName: "PutBucketQoSInfo", // The action.
		Method: "PUT",              // The HTTP method.
		Parameters: map[string]string{
			"qosInfo": "", // QoS-related parameters.
		},
		Headers: map[string]string{
			"Content-MD5": calcMd5(qosConf), // Set the MD5 hash of the request body for data integrity validation.
		},
		Body:   bytes.NewReader(qosConf), // The request body, which contains the QoS configuration content.
		Bucket: oss.Ptr(bucketName),      // The 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)
}

Paket Kısıtlama Yapılandırmalarını Alın

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 main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "GetBucketQoSInfo", // The action.
		Method: "GET",              // The HTTP method.
		Parameters: map[string]string{
			"qosInfo": "", // QoS-related parameters.
		},
		Headers: map[string]string{}, // The HTTP headers.
		Body:    nil,                 // The request body. It is usually empty for a GET request.
		Bucket:  oss.Ptr(bucketName), // The 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 while 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 ensure that resources are released.
	if res.Body != nil {
		res.Body.Close()
	}

	// Print the operation result.
	fmt.Println("The result of GetBucketQoSInfo:", string(body))
}

Kaynak Havuzundaki Belirli Bir Paketin Kısıtlama Yapılandırmalarını Silin

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 main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "DeleteBucketQoSInfo", // The action.
		Method: "DELETE",              // The HTTP method.
		Parameters: map[string]string{
			"qosInfo": "", // QoS-related parameters.
		},
		Headers: map[string]string{}, // The HTTP headers.
		Body:    nil,                 // The request body. It is usually empty for a DELETE request.
		Bucket:  oss.Ptr(bucketName), // The 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)
}

Paket Düzeyinde Farklı İstekte Bulunanlar İçin Bant Genişliği Yönetimi

Paket Düzeyinde Bir İstekte Bulunan İçin Kısıtlama Ayarlayın

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 main() {
	// 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 while 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 other parameters.
	input := &oss.OperationInput{
		OpName: "PutBucketRequesterQoSInfo", // The action must match the actual operation.
		Method: "PUT",                       // The HTTP method.
		Parameters: map[string]string{
			"requesterQosInfo": "",        // Requester QoS-related parameters.
			"qosRequester":     requester, // The requester ID.
		},
		Headers: map[string]string{
			"Content-MD5": calcMd5(qosConf), // Set the MD5 hash of the request body for data integrity validation.
		},
		Body:   bytes.NewReader(qosConf), // The request body, which contains the QoS configuration content.
		Bucket: oss.Ptr(bucketName),      // The 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)
}

Paket Düzeyinde Belirli Bir İstekte Bulunan İçin Kısıtlama Yapılandırmalarını Alın

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 main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "GetBucketRequesterQoSInfo", // The action.
		Method: "GET",                       // The HTTP method.
		Parameters: map[string]string{
			"requesterQosInfo": "",        // Requester QoS-related parameters.
			"qosRequester":     requester, // The requester ID.
		},
		Headers: map[string]string{}, // The HTTP headers.
		Body:    nil,                 // The request body. It is usually empty for a GET request.
		Bucket:  oss.Ptr(bucketName), // The 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 while 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 ensure that resources are released.
	if res.Body != nil {
		res.Body.Close()
	}

	// Print the operation result.
	fmt.Println("The result of GetBucketRequesterQoSInfo:", string(body))
}

Paket Düzeyindeki Tüm İstekte Bulunanlar İçin Kısıtlama Yapılandırmalarını Alın

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 main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "ListBucketRequesterQoSInfos", // The action.
		Method: "GET",                         // The 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{}, // The HTTP headers.
		Body:    nil,                 // The request body. It is usually empty for a GET request.
		Bucket:  oss.Ptr(bucketName), // The 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 while 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 ensure that resources are released.
	if res.Body != nil {
		res.Body.Close()
	}

	// Print the operation result.
	fmt.Println("The result of ListBucketRequesterQoSInfos:", string(body))
}

Bir Paketin İstekte Bulunanı İçin Kısıtlama Yapılandırmalarını Silin

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 main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "DeleteBucketRequesterQoSInfo", // The action.
		Method: "DELETE",                       // The HTTP method.
		Parameters: map[string]string{
			"requesterQosInfo": "",        // Requester QoS-related parameters.
			"qosRequester":     requester, // The requester ID.
		},
		Headers: map[string]string{}, // The HTTP headers.
		Body:    nil,                 // The request body. It is usually empty for a DELETE request.
		Bucket:  oss.Ptr(bucketName), // The 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)
}

Kaynak Havuzu Düzeyinde Farklı İstekte Bulunanlar İçin Bant Genişliği Yönetimi

Geçerli Hesaptaki Tüm Kaynak Havuzları Hakkında Bilgi Alın

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 main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "ListResourcePools", // The action.
		Method: "GET",               // The 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{}, // The HTTP headers.
		Body:    nil,                 // The request body. It is usually empty for a GET request.
		Bucket:  nil,                 // This operation does not apply to 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 while 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 ensure that resources are released.
	if res.Body != nil {
		res.Body.Close()
	}

	// Print the operation result.
	fmt.Println("The result of ListResourcePools:", string(body))
}

Belirli Bir Kaynak Havuzu Hakkında Bilgi Alın

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 main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "GetResourcePoolInfo", // The action.
		Method: "GET",                 // The HTTP method.
		Parameters: map[string]string{
			"resourcePoolInfo": "",         // Resource pool-related parameters.
			"resourcePool":     "example-resource-pool", // The name of the resource pool whose information you want to query.
		},
		Headers: map[string]string{}, // The HTTP headers.
		Body:    nil,                 // The request body. It is usually empty for a GET request.
		Bucket:  nil,                 // This operation does not apply to 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 while 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 ensure that resources are released.
	if res.Body != nil {
		res.Body.Close()
	}

	// Print the operation result.
	fmt.Println("The result of GetResourcePoolInfo:", string(body))
}

Belirli Bir Kaynak Havuzundaki Paketlerin Listesini Alın

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 main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "ListResourcePoolBucketGroups", // The action.
		Method: "GET",                          // The HTTP method.
		Parameters: map[string]string{ // The parameter list.
			"resourcePool": "example-resource-pool", // The resource pool name.
		},
		Headers: map[string]string{}, // The HTTP headers.
		Body:    nil,                 // The request body.
		Bucket:  nil,                 // The bucket name. This is left empty because the operation does not apply to 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 while 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 ensure that resources are released.
	if res.Body != nil {
		res.Body.Close()
	}

	// Print the operation result.
	fmt.Println("The result of ListResourcePoolBucketGroups:", string(body))
}

Kaynak Havuzunun Bir İstekte Bulunanı İçin Kısıtlama Yapılandırın

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 main() {
	// 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 while 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 other parameters.
	input := &oss.OperationInput{
		OpName: "PutResourcePoolRequesterQoSInfo", // The action.
		Method: "PUT",                             // The HTTP method.
		Parameters: map[string]string{
			"requesterQosInfo": "",           // Requester QoS-related parameters.
			"resourcePool":     resourcePool, // The resource pool name.
			"qosRequester":     requester,    // The requester ID.
		},
		Headers: map[string]string{
			"Content-MD5": calcMd5(qosConf), // Set the MD5 hash of the request body for data integrity validation.
		},
		Body:   bytes.NewReader(qosConf), // The request body, which contains the QoS configuration content.
		Bucket: nil,                      // This operation does not apply to 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)
}

Kaynak Havuzundaki Belirli Bir İstekte Bulunan İçin Kısıtlama Yapılandırmalarını Alın

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 main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "GetResourcePoolRequesterQoSInfo", // The action.
		Method: "GET",                             // The HTTP method.
		Parameters: map[string]string{
			"requesterQosInfo": "",           // Requester QoS-related parameters.
			"resourcePool":     resourcePool, // The resource pool name.
			"qosRequester":     requester,    // The requester ID.
		},
		Headers: map[string]string{}, // The HTTP headers.
		Body:    nil,                 // A request body is usually not required for a GET request.
		Bucket:  nil,                 // This operation does not apply to 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 while 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 ensure that resources are released.
	if res.Body != nil {
		res.Body.Close()
	}

	// Print the operation result.
	fmt.Println("The result of GetResourcePoolRequesterQoSInfo:", string(body))
}

Kaynak Havuzundaki Tüm İstekte Bulunanlar İçin Kısıtlama Yapılandırmalarını Alın

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 main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "ListResourcePoolRequesterQoSInfos", // The action.
		Method: "GET",                               // The HTTP method.
		Parameters: map[string]string{
			"requesterQosInfo": "",           // Requester QoS-related parameters.
			"resourcePool":     resourcePool, // The 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{}, // The HTTP headers.
		Body:    nil,                 // A request body is usually not required for a GET request.
		Bucket:  nil,                 // This operation does not apply to 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 while 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 ensure that resources are released.
	if res.Body != nil {
		res.Body.Close()
	}

	// Print the operation result.
	fmt.Println("The result of ListResourcePoolRequesterQoSInfos:", string(body))
}

Kaynak Havuzundaki Belirli Bir İstekte Bulunan İçin Kısıtlama Yapılandırmalarını Silin

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 main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "DeleteResourcePoolRequesterQoSInfo", // The action.
		Method: "DELETE",                             // The HTTP method.
		Parameters: map[string]string{
			"requesterQosInfo": "",           // Requester QoS-related parameters.
			"resourcePool":     resourcePool, // The resource pool name.
			"qosRequester":     requester,    // The requester ID.
		},
		Headers: map[string]string{}, // The HTTP headers.
		Body:    nil,                 // A request body is usually not required for a DELETE request.
		Bucket:  nil,                 // This operation does not apply to 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)
}

Kaynak Havuzu Öncelikli QoS Yönetimi

Kaynak Havuzu İçin Öncelikli QoS Yapılandırmalarını Ayarlayın

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 main() {
	// 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 while 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 other parameters.
	input := &oss.OperationInput{
		OpName: "PutResourcePoolPriorityQoSConfiguration", // The action.
		Method: "PUT",                                     // The HTTP method.
		Parameters: map[string]string{
			"priorityQos":  "",           // Priority QoS-related parameters.
			"resourcePool": resourcePool, // The resource pool name.
		},
		Headers: map[string]string{
			"Content-MD5": calcMd5(qosConf), // Set the MD5 hash of the request body for data integrity validation.
		},
		Body:   bytes.NewReader(qosConf), // The request body, which contains the QoS configuration content.
		Bucket: nil,                      // This operation does not apply to 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)
}

Kaynak Havuzunun Öncelikli QoS Yapılandırmalarını Alın

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 main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "GetResourcePoolPriorityQoSConfiguration", // The action.
		Method: "GET",                                     // The HTTP method.
		Parameters: map[string]string{
			"priorityQos":  "",           // Priority QoS-related parameters.
			"resourcePool": resourcePool, // The resource pool name.
		},
		Headers: map[string]string{}, // The HTTP headers.
		Body:    nil,                 // A request body is usually not required for a GET request.
		Bucket:  nil,                 // This operation does not apply to 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 while 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 ensure that resources are released.
	if res.Body != nil {
		res.Body.Close()
	}

	// Print the operation result.
	fmt.Println("The result of GetResourcePoolPriorityQosConfiguration:", string(body))
}

Kaynak Havuzunun Öncelikli QoS Yapılandırmalarını Silin

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 main() {
	// 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 while 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 other parameters.
	input := &oss.OperationInput{
		OpName: "DeleteResourcePoolPriorityQosConfiguration", // The action.
		Method: "DELETE",                                     // The HTTP method.
		Parameters: map[string]string{
			"priorityQos":  "",           // Priority QoS-related parameters.
			"resourcePool": resourcePool, // The resource pool name.
		},
		Headers: map[string]string{
			"Content-MD5": calcMd5(qosConf), // Set the MD5 hash of the request body for data integrity validation.
		},
		Body:   bytes.NewReader(qosConf), // The request body, which contains the QoS configuration content.
		Bucket: nil,                      // This operation does not apply to 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)
}

Kaynak Havuzundaki Bir İstekte Bulunan İçin Öncelikli QoS Yapılandırmalarını Ayarlayın

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 main() {
	// 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 while 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 other parameters.
	input := &oss.OperationInput{
		OpName: "PutResourcePoolRequesterPriorityQoSConfiguration", // The action.
		Method: "PUT",                                              // The HTTP method.
		Parameters: map[string]string{
			"requesterPriorityQos": "", // Requester priority QoS-related parameters.
			"resourcePool":         resourcePool, // The resource pool name.
		},
		Headers: map[string]string{
			"Content-MD5": calcMd5(qosConf), // Set the MD5 hash of the request body for data integrity validation.
		},
		Body:   bytes.NewReader(qosConf), // The request body, which contains the QoS configuration content.
		Bucket: nil,                      // This operation does not apply to 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)
}

Kaynak Havuzundaki Bir İstekte Bulunan İçin Öncelikli QoS Yapılandırmalarını Alın

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 main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "GetResourcePoolRequesterPriorityQoSConfiguration", // The action.
		Method: "GET",                                              // The HTTP method.
		Parameters: map[string]string{
			"requesterPriorityQos": "", // Requester priority QoS-related parameters.
			"resourcePool":         resourcePool, // The resource pool name.
		},
		Headers: map[string]string{}, // The HTTP headers.
		Body:    nil,                 // A request body is usually not required for a GET request.
		Bucket:  nil,                 // This operation does not apply to 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 while 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 ensure that resources are released.
	if res.Body != nil {
		res.Body.Close()
	}

	// Print the operation result.
	fmt.Println("The result of GetResourcePoolRequesterPriorityQosConfiguration:", string(body))
}

Kaynak Havuzundaki Bir İstekte Bulunan İçin Öncelikli QoS Yapılandırmalarını Silin

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 main() {
	// 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 while 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 other parameters.
	input := &oss.OperationInput{
		OpName: "DeleteResourcePoolRequesterPriorityQoSConfiguration", // The action.
		Method: "DELETE",                                              // The HTTP method.
		Parameters: map[string]string{
			"requesterPriorityQos": "", // Requester priority QoS-related parameters.
			"resourcePool":         resourcePool, // The resource pool name.
		},
		Headers: map[string]string{
			"Content-MD5": calcMd5(qosConf), // Set the MD5 hash of the request body for data integrity validation.
		},
		Body:   bytes.NewReader(qosConf), // The request body, which contains the QoS configuration content.
		Bucket: nil,                      // This operation does not apply to 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)
}

Paket Grubu Bant Genişliği Yönetimi

Kaynak Havuzundan Belirli Bir Paket Grubuna Bir Paket Ekleyin

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 in a resource pool to a specified bucket group.
func main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "PutBucketResourcePoolBucketGroup", // The action.
		Method: "PUT",                              // The HTTP method.
		Parameters: map[string]string{ // The parameter list.
			"resourcePoolBucketGroup": "example-group",           // The name of the bucket group in the resource pool.
			"resourcePool":            "example-resource-pool", // The resource pool name.
		},
		Headers: map[string]string{},    // The HTTP headers.
		Body:    nil,                    // The request body.
		Bucket:  oss.Ptr("test-bucket"), // The 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))
}

Belirli Bir Kaynak Havuzundaki Paket Gruplarının Listesini Alın

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 main() {
	// Define the region. For example, use "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 other parameters.
	input := &oss.OperationInput{
		OpName: "ListResourcePoolBucketGroups", // The action.
		Method: "GET",                          // The HTTP method.
		Parameters: map[string]string{ // The parameter list.
			"resourcePool": "example-resource-pool", // The resource pool name.
		},
		Headers: map[string]string{}, // The HTTP headers.
		Body:    nil,                 // The request body.
		Bucket:  nil,                 // The bucket name. This is left empty because the operation does not apply to 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 while 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 ensure that resources are released.
	if res.Body != nil {
		res.Body.Close()
	}

	// Print the operation result.
	fmt.Println("The result of ListResourcePoolBucketGroups:", string(body))
}

Kaynak Havuzundaki Bir Paket Grubunun Kısıtlama Yapılandırmalarını Değiştirin

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 main() {
	// 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 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 while 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 other parameters.
	input := &oss.OperationInput{
		OpName: "PutResourcePoolBucketGroupQoSInfo", // The action.
		Method: "PUT",                               // The HTTP method.
		Parameters: map[string]string{ // The parameter list.
			"resourcePool":                   resourcePool, // The resource pool name.
			"resourcePoolBucketGroup":        group,        // The bucket group name.
			"resourcePoolBucketGroupQosInfo": "",           // QoS-related parameters.
		},
		Headers: map[string]string{ // The HTTP headers.
			"Content-MD5": calcMd5(qosConf), // Set the MD5 hash of the request body for data integrity validation.
		},
		Body:   bytes.NewReader(qosConf), // The request body, which contains the QoS configuration content.
		Bucket: nil,                      // The bucket name. This is left empty because the operation does not apply to 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)
}

Kaynak Havuzundaki Bir Paket Grubunun Kısıtlama Yapılandırmalarını Alın

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 main() {
	// 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 bucket group name.
	resourcePool := "example-resource-pool"
	ResourcePoolBucketGroup := "example-group"

	// Create the input parameters for the operation, including the action, method type, and other parameters.
	input := &oss.OperationInput{
		OpName: "GetResourcePoolBucketGroupQoSInfo", // The action.
		Method: "GET",                               // The HTTP method.
		Parameters: map[string]string{ // The parameter list.
			"resourcePool":                   resourcePool,            // The resource pool name.
			"resourcePoolBucketGroup":        ResourcePoolBucketGroup, // The bucket group name.
			"resourcePoolBucketGroupQoSInfo": "",                      // QoS-related parameters.
		},
		Headers: map[string]string{}, // The HTTP headers.
		Body:    nil,                 // The request body. It is usually empty for a GET request.
		Bucket:  nil,                 // The bucket name. This is left empty because the operation does not apply to 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 while 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 ensure that resources are released.
	if res.Body != nil {
		res.Body.Close()
	}

	// Print the operation result.
	fmt.Println("The result of GetResourcePoolBucketGroupQoSInfo:", string(body))
}

Kaynak Havuzundaki Paket Gruplarının Kısıtlama Yapılandırmalarını Listeleyin

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 main() {
	// 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 other parameters.
	input := &oss.OperationInput{
		OpName: "ListResourcePoolBucketGroupQoSInfos", // The action.
		Method: "GET",                                 // The HTTP method.
		Parameters: map[string]string{ // The parameter list.
			"resourcePool": resourcePool, // The 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{}, // The HTTP headers.
		Body:    nil,                 // The request body. It is usually empty for a GET request.
		Bucket:  nil,                 // The bucket name. This is left empty because the operation does not apply to 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 while 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 ensure that resources are released.
	if res.Body != nil {
		res.Body.Close()
	}

	// Print the operation result.
	fmt.Println("The result of ListResourcePoolBucketGroupQoSInfos:", string(body))
}

Kaynak Havuzundaki Bir Paket Grubunun Kısıtlama Yapılandırmalarını Silin

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 main() {
	// Define the region. For example, use "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 bucket group name.
	resourcePool := "example-resource-pool"
	group := "example-group"

	// Create the input parameters for the operation, including the action, method type, and other parameters.
	input := &oss.OperationInput{
		OpName: "DeleteResourcePoolBucketGroupQoSInfo", // The action.
		Method: "DELETE",                               // The HTTP method.
		Parameters: map[string]string{ // The parameter list.
			"resourcePool":                   resourcePool, // The resource pool name.
			"resourcePoolBucketGroup":        group,        // The bucket group name.
			"resourcePoolBucketGroupQoSInfo": "",           // QoS-related parameters.
		},
		Headers: map[string]string{}, // The HTTP headers.
		Body:    nil,                 // The request body. It is usually empty for a DELETE request.
		Bucket:  nil,                 // The bucket name. This is left empty because the operation does not apply to 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)
}

İlgili Başlıklar