This topic describes how to manage resource pool Quality of Service (QoS) using the OSS SDK for Python V2.
Usage notes
The sample code in this topic uses the region ID
cn-hangzhoufor the China (Hangzhou) region. By default, a public endpoint is used to access resources in a bucket. If you want to access resources in the bucket from other Alibaba Cloud services in the same region, use an internal endpoint. For more information about OSS regions and endpoints, see OSS 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Initialize qos_xml_body as 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()
# Construct an operation input request object to set the QoS information for the bucket.
req = oss.OperationInput(
op_name = 'PutBucketQoSInfo', # The name of the operation. This operation is used to set the QoS information for the bucket.
method = 'PUT', # The HTTP method. In this example, PUT is used to update a resource.
parameters = {
'qosInfo': '', # The list of parameters. This parameter specifies that the QoS information is to be set.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = qos_xml_body, # The request body, which contains the content read from the 'qos.xml' file.
bucket = 'examplebucket', # The name of the destination bucket.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to obtain the QoS information of the bucket.
req = oss.OperationInput(
op_name = 'GetBucketQoSInfo', # The name of the operation. This operation is used to obtain the QoS information of the bucket.
method = 'GET', # The HTTP method. In this example, GET is used to obtain a resource.
parameters = {
'qosInfo': '', # The list of parameters. This parameter specifies that the QoS information is to be obtained.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a GET request. Therefore, this parameter is set to None.
bucket = 'examplebucket', # The name of the destination bucket.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to delete the QoS information of the bucket.
req = oss.OperationInput(
op_name = 'DeleteBucketQoSInfo', # The name of the operation. This operation is used to delete the QoS information of the bucket.
method = 'DELETE', # The HTTP method. In this example, DELETE is used to delete a resource.
parameters = {
'qosInfo': '', # The list of parameters. This parameter specifies that the QoS information is to be deleted.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a DELETE request. Therefore, this parameter is set to None.
bucket = 'examplebucket', # The name of the destination bucket.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Initialize qos_xml_body as 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()
# Construct an operation input request object to set the requester QoS information for the bucket.
req = oss.OperationInput(
op_name = 'PutBucketRequesterQoSInfo', # The name of the operation. This operation is used to set the requester QoS information for the bucket.
method = 'PUT', # The HTTP method. In this example, PUT is used to update a resource.
parameters = {
'requesterQosInfo': '', # The list of parameters. This parameter specifies that the requester QoS information is to be set.
'qosRequester': '2598732222222xxxx', # The unique identifier of the requester, which is used to distinguish different requesters.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = qos_xml_body, # The request body, which contains the content read from the 'qos.xml' file.
bucket = 'examplebucket', # The name of the destination bucket.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to obtain the requester QoS information of the bucket.
req = oss.OperationInput(
op_name = 'GetBucketRequesterQoSInfo', # The name of the operation. This operation is used to obtain the requester QoS information of the bucket.
method = 'GET', # The HTTP method. In this example, GET is used to obtain a resource.
parameters = {
'requesterQosInfo': '', # The list of parameters. This parameter specifies that the requester QoS information is to be obtained.
'qosRequester': '2598732222222xxxx', # The unique identifier of the requester, which is used to distinguish different requesters.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a GET request. Therefore, this parameter is set to None.
bucket = 'examplebucket', # The name of the destination bucket.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to list the requester QoS information of the bucket.
req = oss.OperationInput(
op_name = 'ListBucketRequesterQoSInfos', # The name of the operation. This operation is used to list the requester QoS information of the bucket.
method = 'GET', # The HTTP method. In this example, GET is used to obtain a resource.
parameters = {
'requesterQosInfo': '', # The list of parameters. This parameter specifies that the requester QoS information is to be listed.
# "continuation-token": "2345", # An optional parameter that is used for paged query. This parameter specifies the breakpoint from which the query continues.
# "max-keys": "1", # An optional parameter that is used to limit the maximum number of entries returned.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a GET request. Therefore, this parameter is set to None.
bucket = 'examplebucket', # The name of the destination bucket.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to delete the requester QoS information of the bucket.
req = oss.OperationInput(
op_name = 'DeleteBucketRequesterQoSInfo', # The name of the operation. This operation is used to delete the requester QoS information of the bucket.
method = 'DELETE', # The HTTP method. In this example, DELETE is used to delete a resource.
parameters = {
'requesterQosInfo': '', # The list of parameters. This parameter specifies that the requester QoS information is to be deleted.
'qosRequester': '2598732222222xxxx', # The unique identifier of the requester, which is used to distinguish different requesters.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a DELETE request. Therefore, this parameter is set to None.
bucket = 'examplebucket', # The name of the destination bucket.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to list resource pools.
req = oss.OperationInput(
op_name = 'ListResourcePools', # The name of the operation. This operation is used to list resource pools.
method = 'GET', # The HTTP method. In this example, GET is used to obtain a resource.
parameters = {
'resourcePool': '', # The list of parameters. This parameter specifies that resource pool information is to be listed.
# "continuation-token": "test-rp-", # An optional parameter that is used for paged query. This parameter specifies the breakpoint from which the query continues.
# "max-keys": "1", # An optional parameter that is used to limit the maximum number of entries returned.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a GET request. Therefore, this parameter is set to None.
bucket = None, # The name of the destination bucket. You do not need to specify a bucket. Therefore, this parameter is set to None.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to obtain the information about a resource pool.
req = oss.OperationInput(
op_name = 'GetResourcePoolInfo', # The name of the operation. This operation is used to obtain information about a resource pool.
method = 'GET', # The HTTP method. In this example, GET is used to obtain a resource.
parameters = {
'resourcePoolInfo': '', # The list of parameters. This parameter specifies that the information about the resource pool is to be obtained.
'resourcePool': 'example-resource-pool', # The unique identifier of the resource pool, which is used to distinguish different resource pools.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a GET request. Therefore, this parameter is set to None.
bucket = None, # The name of the destination bucket. You do not need to specify a bucket. Therefore, this parameter is set to None.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to list the bucket groups of a resource pool.
req = oss.OperationInput(
op_name = 'ListResourcePoolBucketGroups', # The name of the operation. This operation is used to list the bucket groups of a resource pool.
method = 'GET', # The HTTP method. In this example, GET is used to obtain a resource.
parameters = {
'resourcePoolBucketGroup': '', # The list of parameters. This parameter specifies that the bucket group information is to be listed.
'resourcePool': 'example-resource-pool', # The unique identifier of the resource pool, which is used to distinguish different resource pools.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a GET request. Therefore, this parameter is set to None.
bucket = None, # The name of the destination bucket. You do not need to specify a bucket. Therefore, this parameter is set to None.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Initialize qos_xml_body as 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()
# Construct an operation input request object to set the QoS information for a requester in a resource pool.
req = oss.OperationInput(
op_name = 'PutResourcePoolRequesterQoSInfo', # The name of the operation. This operation is used to set the QoS information for a requester in a resource pool.
method = 'PUT', # The HTTP method. In this example, PUT is used to update a resource.
parameters = {
'requesterQosInfo': '', # The list of parameters. This parameter specifies that the requester QoS information is to be set.
'resourcePool': 'example-resource-pool', # The unique identifier of the resource pool, which is used to distinguish different resource pools.
'qosRequester': '2598732222222xxxx', # The unique identifier of the requester, which is used to distinguish different requesters.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = qos_xml_body, # The request body, which contains the content read from the 'qos.xml' file.
bucket = None, # The name of the destination bucket. You do not need to specify a bucket. Therefore, this parameter is set to None.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to obtain the QoS information of a requester in a resource pool.
req = oss.OperationInput(
op_name = 'GetResourcePoolRequesterQoSInfo', # The name of the operation. This operation is used to obtain the QoS information of a requester in a resource pool.
method = 'GET', # The HTTP method. In this example, GET is used to obtain a resource.
parameters = {
'requesterQosInfo': '', # The list of parameters. This parameter specifies that the requester QoS information is to be obtained.
'qosRequester': '2598732222222xxxx', # The unique identifier of the requester, which is used to distinguish different requesters.
'resourcePool': 'example-resource-pool', # The unique identifier of the resource pool, which is used to distinguish different resource pools.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a GET request. Therefore, this parameter is set to None.
bucket = None, # The name of the destination bucket. You do not need to specify a bucket. Therefore, this parameter is set to None.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to list the QoS information of requesters in a resource pool.
req = oss.OperationInput(
op_name = 'ListResourcePoolRequesterQoSInfos', # The name of the operation. This operation is used to list the QoS information of requesters in a resource pool.
method = 'GET', # The HTTP method. In this example, GET is used to obtain a resource.
parameters = {
'requesterQosInfo': '', # The list of parameters. This parameter specifies that the requester QoS information is to be listed.
'resourcePool': 'example-resource-pool', # The unique identifier of the resource pool, which is used to distinguish different resource pools.
# "continuation-token": "2345", # An optional parameter that is used for paged query. This parameter specifies the breakpoint from which the query continues.
# "max-keys": "1", # An optional parameter that is used to limit the maximum number of entries returned.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a GET request. Therefore, this parameter is set to None.
bucket = None, # The name of the destination bucket. You do not need to specify a bucket. Therefore, this parameter is set to None.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to delete the QoS information of a requester in a resource pool.
req = oss.OperationInput(
op_name = 'DeleteResourcePoolRequesterQoSInfo', # The name of the operation. This operation is used to delete the QoS information of a requester in a resource pool.
method = 'DELETE', # The HTTP method. In this example, DELETE is used to delete a resource.
parameters = {
'requesterQosInfo': '', # The list of parameters. This parameter specifies that the requester QoS information is to be deleted.
'resourcePool': 'example-resource-pool', # The unique identifier of the resource pool, which is used to distinguish different resource pools.
'qosRequester': '2598732222222xxxx', # The unique identifier of the requester, which is used to distinguish different requesters.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a DELETE request. Therefore, this parameter is set to None.
bucket = None, # The name of the destination bucket. You do not need to specify a bucket. Therefore, this parameter is set to None.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to add a bucket to a specified bucket group in a resource pool.
req = oss.OperationInput(
op_name = 'PutBucketResourcePoolBucketGroup', # The name of the operation. This operation is used to add a bucket to a bucket group in a resource pool.
method = 'PUT', # The HTTP method. In this example, PUT is used to update a resource.
parameters = {
'resourcePoolBucketGroup': 'example-group', # The unique identifier of the bucket group, which is used to distinguish different bucket groups.
'resourcePool': 'example-resource-pool', # The unique identifier of the resource pool, which is used to distinguish different resource pools.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a PUT request that does not need to transfer additional data. Therefore, this parameter is set to None.
bucket = 'examplebucket', # The name of the destination bucket. This parameter specifies that the bucket is to be added to the specified bucket group in the resource pool.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to list the bucket groups of a resource pool.
req = oss.OperationInput(
op_name = 'ListResourcePoolBucketGroups', # The name of the operation. This operation is used to list the bucket groups of a resource pool.
method = 'GET', # The HTTP method. In this example, GET is used to obtain a resource.
parameters = {
'resourcePoolBucketGroup': '', # The list of parameters. This parameter specifies that the bucket group information is to be listed.
'resourcePool': 'example-resource-pool', # The unique identifier of the resource pool, which is used to distinguish different resource pools.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a GET request. Therefore, this parameter is set to None.
bucket = None, # The name of the destination bucket. You do not need to specify a bucket. Therefore, this parameter is set to None.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Initialize qos_xml_body as 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()
# Construct an operation input request object to set the QoS information for a bucket group in a resource pool.
req = oss.OperationInput(
op_name = 'PutResourcePoolBucketGroupQoSInfo', # The name of the operation. This operation is used to set the QoS information for a bucket group in a resource pool.
method = 'PUT', # The HTTP method. In this example, PUT is used to update a resource.
parameters = {
'resourcePoolBucketGroupQosInfo': '', # The list of parameters. This parameter specifies that the QoS information of the bucket group in the resource pool is to be set.
'resourcePool': 'example-resource-pool', # The unique identifier of the resource pool, which is used to distinguish different resource pools.
'resourcePoolBucketGroup': 'example-group', # The unique identifier of the bucket group, which is used to distinguish different bucket groups.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = qos_xml_body, # The request body, which contains the content read from the 'qos.xml' file.
bucket = None, # The name of the destination bucket. You do not need to specify a bucket. Therefore, this parameter is set to None.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to obtain the QoS information of a bucket group in a resource pool.
req = oss.OperationInput(
op_name = 'GetResourcePoolBucketGroupQoSInfo', # The name of the operation. This operation is used to obtain the QoS information of a bucket group in a resource pool.
method = 'GET', # The HTTP method. In this example, GET is used to obtain a resource.
parameters = {
'resourcePoolBucketGroupQosInfo': '', # The list of parameters. This parameter specifies that the QoS information of the bucket group in the resource pool is to be obtained.
'resourcePool': 'example-resource-pool', # The unique identifier of the resource pool, which is used to distinguish different resource pools.
'resourcePoolBucketGroup': 'example-group', # The unique identifier of the bucket group, which is used to distinguish different bucket groups.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a GET request. Therefore, this parameter is set to None.
bucket = None, # The name of the destination bucket. You do not need to specify a bucket. Therefore, this parameter is set to None.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to list the QoS information of bucket groups in a resource pool.
req = oss.OperationInput(
op_name = 'ListResourcePoolBucketGroupQoSInfos', # The name of the operation. This operation is used to list the QoS information of bucket groups in a resource pool.
method = 'GET', # The HTTP method. In this example, GET is used to obtain a resource.
parameters = {
'resourcePoolBucketGroupQosInfo': '', # The list of parameters. This parameter specifies that the QoS information of the bucket groups in the resource pool is to be listed.
'resourcePool': 'example-resource-pool', # The unique identifier of the resource pool, which is used to distinguish different resource pools.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a GET request. Therefore, this parameter is set to None.
bucket = None, # The name of the destination bucket. You do not need to specify a bucket. Therefore, this parameter is set to None.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 identity verification.
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Load default configurations and obtain the configuration object.
cfg = oss.config.load_default()
# Set the credential provider.
cfg.credentials_provider = credentials_provider
# Specify the region in which the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to cn-hangzhou.
cfg.region = "cn-hangzhou"
# Initialize the OSS client using the configuration object.
client = oss.Client(cfg)
# Construct an operation input request object to delete the QoS information of a bucket group in a resource pool.
req = oss.OperationInput(
op_name = 'DeleteResourcePoolBucketGroupQoSInfo', # The name of the operation. This operation is used to delete the QoS information of a bucket group in a resource pool.
method = 'DELETE', # The HTTP method. In this example, DELETE is used to delete a resource.
parameters = {
'resourcePoolBucketGroupQosInfo': '', # The list of parameters. This parameter specifies that the QoS information of the bucket group in the resource pool is to be deleted.
'resourcePool': 'example-resource-pool', # The unique identifier of the resource pool, which is used to distinguish different resource pools.
'resourcePoolBucketGroup': 'example-group', # The unique identifier of the bucket group, which is used to distinguish different bucket groups.
},
headers = None, # The request header. You can set this parameter to None if you do not need to specify special settings.
body = None, # The request body. A request body is not required for a DELETE request. Therefore, this parameter is set to None.
bucket = None, # The name of the destination bucket. You do not need to specify a bucket. Therefore, this parameter is set to None.
)
# Call the invoke_operation method of the client to execute the request and receive the response.
resp = client.invoke_operation(req)
# Print the status code of the response.
print(resp.status_code)
# Print the header of the response.
print(resp.headers)
# Print the content of the response (HTTP response body), which usually contains the specific data returned for 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 resource pool QoS.
For more information about the configuration examples of resource pool QoS, see Examples of resource pool QoS configuration.