This topic describes how to manage resource pool quality of service (QoS) by using Object Storage Service (OSS) SDK for Python 2.0.
Usage notes
The sample code in this topic uses the region ID cn-hangzhou of the China (Hangzhou) region. By default, the public endpoint is used to access resources in a bucket. If you want to access resources in the bucket by using other Alibaba Cloud services in the same region in which the bucket is located, use the internal endpoint. For more information about regions and endpoints, see Regions and endpoints.
Bucket bandwidth management
Configure throttling rules for a bucket in a resource pool
import alibabacloud_oss_v2 as oss
def PutBucketQoSInfo():
# Obtain access credentials from environment variables for authentication
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Set qos_xml_body to an empty string.
qos_xml_body = ""
# Open the file named qos.xml and read its content into the qos_xml_body variable.
with open('qos.xml', 'r') as qos_file:
qos_xml_body = qos_file.read()
# Specify input parameters for the PutBucketQoSInfo operation to specify the QoS rules for the bucket.
req = oss.OperationInput(
op_name = 'PutBucketQoSInfo', # Operation name, specifying the operation to set bucket QoS information
method = 'PUT', # The type of the HTTP method. In this example, PUT is used to update resources.
parameters = {
'qosInfo': '', # The QoS-related parameters.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = qos_xml_body, # The request body, which contains the content read from the qos.xml file.
bucket = 'examplebucket', # The name of the bucket.
)
# Use the invoke_operation method of the client to run the request and obtain the response or error message.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
if __name__ == "__main__":
PutBucketQoSInfo()Query the throttling configurations of a bucket
import alibabacloud_oss_v2 as oss
def GetBucketQoSInfo():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the GetBucketQoSInfo operation to query the QoS configurations of the bucket.
req = oss.OperationInput(
op_name = 'GetBucketQoSInfo', # The name of the operation.
method = 'GET', # The type of the HTTP method.
parameters = {
'qosInfo': '', # The QoS-related parameters.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is not required for GET requests.
bucket = 'examplebucket', # The name of the bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
GetBucketQoSInfo()Delete the throttling configurations of a bucket in a resource pool
import alibabacloud_oss_v2 as oss
def DeleteBucketQoSInfo():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configuration and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the DeleteBucketQoSInfo operation to delete the QoS configurations of the bucket.
req = oss.OperationInput(
op_name = 'DeleteBucketQoSInfo', # The name of the operation.
method = 'DELETE', # The type of the HTTP method. In this example, DELETE is used.
parameters = {
'qosInfo': '', # The QoS-related parameters.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is not required for DELETE requests.
bucket = 'examplebucket', # The name of the bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
if __name__ == "__main__":
DeleteBucketQoSInfo()
Bucket-level bandwidth management for different requesters
Configure throttling rules for a requester accessing a bucket
import alibabacloud_oss_v2 as oss
def PutBucketRequesterQoSInfo():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Set qos_xml_body to an empty string.
qos_xml_body = ""
# Open a file named qos.xml and read its content into the qos_xml_body variable.
with open('qos.xml', 'r') as qos_file:
qos_xml_body = qos_file.read()
# Specify input parameters for the PutBucketRequesterQoSInfo operation to configure throttling rules for a requester accessing a bucket.
req = oss.OperationInput(
op_name = 'PutBucketRequesterQoSInfo', # The name of the operation.
method = 'PUT', # The type of the HTTP method. In this example, PUT is used.
parameters = {
'requesterQosInfo': '', # The QoS-related parameters.
'qosRequester': '2598732222222xxxx', # The unique identifier for the requester, which is used to distinguish different requesters.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = qos_xml_body, # The request body, which contains the content read from the qos.xml file.
bucket = 'examplebucket', # The name of the bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
PutBucketRequesterQoSInfo()Query the throttling configurations of a requester accessing a bucket
import alibabacloud_oss_v2 as oss
def GetBucketRequesterQoSInfo():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the GetBucketRequesterQoSInfo operation to query the throttling configurations of a requester accessing a bucket.
req = oss.OperationInput(
op_name = 'GetBucketRequesterQoSInfo', # The name of the operation.
method = 'GET', # The type of the HTTP method type. In this example, GET is used.
parameters = {
'requesterQosInfo': '', # The QoS-related parameters.
'qosRequester': '2598732222222xxxx', # The unique identifier for the requester, which is used to distinguish different requesters.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is typically not required for GET requests.
bucket = 'examplebucket', # The name of the bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
GetBucketRequesterQoSInfo()Query the throttling configurations of all requesters accessing a bucket
import alibabacloud_oss_v2 as oss
def ListBucketRequesterQoSInfos():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the ListBucketRequesterQoSInfos operation to query the throttling configurations of all requesters accessing a bucket.
req = oss.OperationInput(
op_name = 'ListBucketRequesterQoSInfos', # The name of the operation.
method = 'GET', # The type of the HTTP method type. In this example, GET is used.
parameters = {
'requesterQosInfo': '', # The QoS-related parameters.
# "continuation-token": "2345", # Optional. The token used to obtain results in the next page.
# "max-keys": "1", # Optional. The maximum number of entries returned each time.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is typically not required for GET requests.
bucket = 'examplebucket', # The name of the bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
ListBucketRequesterQoSInfos()Delete the throttling configurations of a requester accessing a bucket
import alibabacloud_oss_v2 as oss
def DeleteBucketRequesterQoSInfo():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the DeleteBucketRequesterQoSInfo operation to delete the throttling configurations of a requester accessing a bucket.
req = oss.OperationInput(
op_name = 'DeleteBucketRequesterQoSInfo', # The name of the operation.
method = 'DELETE', # The type of the HTTP method type. In this example, Delete is used.
parameters = {
'requesterQosInfo': '', # The QoS-related parameters.
'qosRequester': '2598732222222xxxx', # The unique identifier for the requester, which is used to distinguish different requesters.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is typically not required for DELETE requests.
bucket = 'examplebucket', # The name of the bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
DeleteBucketRequesterQoSInfo()Resource pool-level bandwidth management for different requesters
Query all resource pools in the current Alibaba Cloud account
import alibabacloud_oss_v2 as oss
def ListResourcePools():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the ListResourcePools operation.
req = oss.OperationInput(
op_name = 'ListResourcePools', # The name of the operation.
method = 'GET', # The type of the HTTP method type. In this example, GET is used.
parameters = {
'resourcePool': '', # The resource pool parameters.
# "continuation-token": "test-rp-", # Optional. The token used to obtain results in the next page.
# "max-keys": "1", # Optional. The maximum number of entries returned each time.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is typically not required for GET requests.
bucket = None, # The name of the bucket, which is typically not required for GET requests. This operation is not performed on a specific bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == '__main__':
ListResourcePools()
Query the information about a resource pool
import alibabacloud_oss_v2 as oss
def GetResourcePoolInfo():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the GetResourcePoolInfo operation to query information about a resource pool.
req = oss.OperationInput(
op_name = 'GetResourcePoolInfo', # The name of the operation.
method = 'GET', # The type of the HTTP method type. In this example, GET is used.
parameters = {
'resourcePoolInfo': '', # The resource pool parameters.
'resourcePool': 'example-resource-pool', # The name of the resource pool whose information you want to query.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is typically not required for GET requests.
bucket = None, # The name of the bucket, which is not required for GET requests. This operation is not performed on a specific bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
GetResourcePoolInfo()Query the buckets in a resource pool
import alibabacloud_oss_v2 as oss
def ListResourcePoolBucketGroups():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the ListResourcePoolBucketGroups operation.
req = oss.OperationInput(
op_name = 'ListResourcePoolBucketGroups', # The name of the operation.
method = 'GET', # The type of the HTTP method type. In this example, GET is used.
parameters = {
'resourcePoolBucketGroup': '', # The parameters.
'resourcePool': 'example-resource-pool', # The name of the resource pool.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is typically not required for GET requests.
bucket = None, # The name of the bucket, which is not required for GET requests. The operation is not performed on a specific bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
ListResourcePoolBucketGroups()Configure throttling rules for a requester in a resource pool
import alibabacloud_oss_v2 as oss
def PutResourcePoolRequesterQoSInfo():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Initialize qos_xml_body as an empty string
qos_xml_body = ""
# Open a file named qos.xml and read its content into the qos_xml_body variable.
with open('qos.xml', 'r') as qos_file:
qos_xml_body = qos_file.read()
# Specify input parameters for the PutResourcePoolRequesterQoSInfo operation.
req = oss.OperationInput(
op_name = 'PutResourcePoolRequesterQoSInfo', # The name of the operation.
method = 'PUT', # The type of the HTTP method type. In this example, PUT is used.
parameters = {
'requesterQosInfo': '', # The QoS-related parameters.
'resourcePool': 'example-resource-pool', # The name of the resource pool.
'qosRequester': '2598732222222xxxx', # The ID of the requester.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = qos_xml_body, # The request body, which contains the content read from the qos.xml file.
bucket = None, # The name of the bucket, which is not required for PUT requests. The operation is not performed on a specific bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
PutResourcePoolRequesterQoSInfo()Query the throttling configurations of a requester in a resource pool
import alibabacloud_oss_v2 as oss
def GetResourcePoolRequesterQoSInfo():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the GetResourcePoolRequesterQoSInfo operation.
req = oss.OperationInput(
op_name = 'GetResourcePoolRequesterQoSInfo', # The name of the operation.
method = 'GET', # The type of the HTTP method type. In this example, GET is used.
parameters = {
'requesterQosInfo': '', # The QoS-related parameters.
'qosRequester': '2598732222222xxxx', # The unique identifier for the requester, which is used to distinguish different requesters.
'resourcePool': 'example-resource-pool', # The unique identifier for the resource pool, which is used to distinguish different resource pools.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is typically not required for GET requests.
bucket = None, # The name of the bucket, which is not required for GET requests. The operation is not performed on a specific bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
GetResourcePoolRequesterQoSInfo()Query the throttling configurations of all requesters in a resource pool
import alibabacloud_oss_v2 as oss
def ListResourcePoolRequesterQoSInfos():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the ListResourcePoolRequesterQoSInfos operation.
req = oss.OperationInput(
op_name = 'ListResourcePoolRequesterQoSInfos', # The name of the operation.
method = 'GET', # The type of the HTTP method type. In this example, GET is used.
parameters = {
'requesterQosInfo': '', # The QoS-related parameters.
'resourcePool': 'example-resource-pool', # The name of the resource pool.
# "continuation-token": "2345", # Optional. The token used to obtain results in the next page.
# "max-keys": "1", # Optional. The maximum number of entries returned each time.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is not required for GET requests.
bucket = None, # The name of the bucket, which is not required for GET requests. The operation is not performed on a specific bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
ListResourcePoolRequesterQoSInfos()Delete the throttling configurations of a requester in a resource pool
import alibabacloud_oss_v2 as oss
def DeleteResourcePoolRequesterQoSInfo():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configuration and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the DeleteResourcePoolRequesterQoSInfo operation.
req = oss.OperationInput(
op_name = 'DeleteResourcePoolRequesterQoSInfo', # The name of the operation.
method = 'DELETE', # The type of the HTTP method. In this example, DELETE is used.
parameters = {
'requesterQosInfo': '', # The QoS-related parameters.
'resourcePool': 'example-resource-pool', # The name of the resource pool.
'qosRequester': '2598732222222xxxx', # The ID of the requester.
},
headers = None, # he request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is typically not required for Delete requests.
bucket = None, # The name of the bucket, which is not required for DELETE requests. The operation is not performed on a specific bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
DeleteResourcePoolRequesterQoSInfo()Bandwidth management for a bucket group
Add buckets in a resource pool to a bucket group
import alibabacloud_oss_v2 as oss
def PutBucketResourcePoolBucketGroup():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the PutBucketResourcePoolBucketGroup operation.
req = oss.OperationInput(
op_name = 'PutBucketResourcePoolBucketGroup', # The name of the operation.
method = 'PUT', # The type of the HTTP method type. In this example, PUT is used.
parameters = {
'resourcePoolBucketGroup': 'example-group', # The name of the bucket group in the resource pool.
'resourcePool': 'example-resource-pool', # The name of the resource pool.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is typically not required for PUT requests.
bucket = 'examplebucket', # The name of the bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
PutBucketResourcePoolBucketGroup()Query bucket groups in a resource pool
import alibabacloud_oss_v2 as oss
def ListResourcePoolBucketGroups():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the ListResourcePoolBucketGroups operation.
req = oss.OperationInput(
op_name = 'ListResourcePoolBucketGroups', # The name of the operation.
method = 'GET', # The type of the HTTP method type. In this example, GET is used.
parameters = {
'resourcePoolBucketGroup': '', # The parameters.
'resourcePool': 'example-resource-pool', # The name of the resource pool.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # Request body, typically None for GET requests as they don't require a body
bucket = None, # The request body, which is typically not required for GET requests.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
ListResourcePoolBucketGroups()Modify the throttling configurations of a bucket group in a resource pool
import alibabacloud_oss_v2 as oss
def PutResourcePoolBucketGroupQoSInfo():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Set qos_xml_body to an empty string.
qos_xml_body = ""
# Open and read the qos.xml file and write its content into the qos_xml_body variable.
with open('qos.xml', 'r') as qos_file:
qos_xml_body = qos_file.read()
# Specify input parameters for the PutResourcePoolBucketGroupQoSInfo operation.
req = oss.OperationInput(
op_name = 'PutResourcePoolBucketGroupQoSInfo', # The name of the operation.
method = 'PUT', # The type of the HTTP method type. In this example, PUT is used.
parameters = {
'resourcePoolBucketGroupQosInfo': '', # The QoS-related parameters.
'resourcePool': 'example-resource-pool', # The name of the resource pool
'resourcePoolBucketGroup': 'example-group', # The name of the bucket group.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = qos_xml_body, # The request body, which contains the content read from the qos.xml file.
bucket = None, # The name of the bucket, which is not required for PUT requests. This operation is not performed on a specific bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
PutResourcePoolBucketGroupQoSInfo()Query the throttling configurations of a bucket group in a resource pool
import alibabacloud_oss_v2 as oss
def GetResourcePoolBucketGroupQoSInfo():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the GetResourcePoolInfo operation.
req = oss.OperationInput(
op_name = 'GetResourcePoolBucketGroupQoSInfo', # The name of the operation.
method = 'GET', # The type of the HTTP method type. In this example, GET is used.
parameters = {
'resourcePoolBucketGroupQosInfo': '', # The parameters.
'resourcePool': 'example-resource-pool', # The name of the resource pool.
'resourcePoolBucketGroup': 'example-group', # The name of the bucket group.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is typically not required for GET requests.
bucket = None, # The name of the bucket, which is not required for GET requests. This operation is not performed on a specific bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
GetResourcePoolBucketGroupQoSInfo()List the throttling configurations of bucket groups in a resource pool
import alibabacloud_oss_v2 as oss
def ListResourcePoolBucketGroupQoSInfos():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the GetResourcePoolInfo operation.
req = oss.OperationInput(
op_name = 'ListResourcePoolBucketGroupQoSInfos', # The name of the operation.
method = 'GET', # The type of the HTTP method type. In this example, GET is used.
parameters = {
'resourcePoolBucketGroupQosInfo': '', # The parameters.
'resourcePool': 'example-resource-pool', # The name of the resource pool.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is typically not required for GET requests.
bucket = None, # The name of the bucket, which is not required for GET requests. This operation is not performed on a specific bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
ListResourcePoolBucketGroupQoSInfos()Delete the throttling configurations of a bucket group in a resource pool
import alibabacloud_oss_v2 as oss
def DeleteResourcePoolBucketGroupQoSInfo():
# Obtain access credentials from environment variables for authentication.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration file.
cfg = oss.config.load_default()
# Specify the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if your bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSSClient instance by using the configuration file.
client = oss.Client(cfg)
# Specify input parameters for the DeleteResourcePoolBucketGroupQoSInfo operation.
req = oss.OperationInput(
op_name = 'DeleteResourcePoolBucketGroupQoSInfo', # The name of the operation.
method = 'DELETE', # The type of the HTTP method type. In this example, Delete is used.
parameters = {
'resourcePoolBucketGroupQosInfo': '', # The parameters.
'resourcePool': 'example-resource-pool', # The name of the resource pool.
'resourcePoolBucketGroup': 'example-group', # The name of the bucket group.
},
headers = None, # The request headers. If you do not need to specify additional headers, leave the field empty.
body = None, # The request body, which is typically not required for DELETE requests.
bucket = None, # The name of the bucket, which is not required for DELETE requests. This operation is not performed on a specific bucket.
)
# Use the invoke_operation method of the client to execute the request and obtain the response.
resp = client.invoke_operation(req)
# Display the returned HTTP status code.
print(resp.status_code)
# Display the response headers.
print(resp.headers)
# Display the response body, which typically contains the specific data returned by the request.
print(resp.http_response.content)
if __name__ == "__main__":
DeleteResourcePoolBucketGroupQoSInfo()References
For more information about the API operations related to resource pool QoS, see Operations related to the resource pool QoS.
For more information about how to configure bandwidth throttling for buckets and requesters, see Examples of resource pool QoS configuration.