Bu konu, Object Storage Service (OSS) Python 2.0 SDK kullanarak kaynak havuzu hizmet kalitesi (QoS) ayarlarının nasıl yönetileceğini açıklar.
Kullanım notları
Bu konudaki örnek kodlar, Çin (Hangzhou) bölgesinin bölge kimliği olan cn-hangzhou değerini kullanır. Varsayılan olarak, bir paket içindeki kaynaklara erişmek için genel uç nokta kullanılır. Paketi barındıran aynı bölgedeki diğer Alibaba Cloud hizmetleri üzerinden paketteki kaynaklara erişmek istiyorsanız dahili uç noktayı kullanın. Bölgeler ve uç noktalar hakkında daha fazla bilgi için bkz. Bölgeler ve uç noktalar.
Paket bant genişliği yönetimi
Kaynak havuzundaki bir paket için kısıtlama kurallarını yapılandırın
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()
qos.xml dosyası aşağıdaki yapılandırmayı içerir:
<QoSConfiguration>
<TotalUploadBandwidth>100</TotalUploadBandwidth>
<IntranetUploadBandwidth>-1</IntranetUploadBandwidth>
<ExtranetUploadBandwidth>20</ExtranetUploadBandwidth>
<TotalDownloadBandwidth>100</TotalDownloadBandwidth>
<IntranetDownloadBandwidth>-1</IntranetDownloadBandwidth>
<ExtranetDownloadBandwidth>20</ExtranetDownloadBandwidth>
<TotalQps>10000</TotalQps>
<IntranetQps>-1</IntranetQps>
<ExtranetQps>-1</ExtranetQps>
</QoSConfiguration>
Bir paketin kısıtlama yapılandırmalarını sorgulayın
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()
Kaynak havuzundaki bir paketin kısıtlama yapılandırmalarını silin
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()
Farklı istek sahipleri için paket düzeyinde bant genişliği yönetimi
Bir pakete erişen bir istek sahibi için kısıtlama kurallarını yapılandırın
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()
qos.xml dosyası aşağıdaki yapılandırmayı içerir:
<QoSConfiguration>
<TotalUploadBandwidth>100</TotalUploadBandwidth>
<IntranetUploadBandwidth>-1</IntranetUploadBandwidth>
<ExtranetUploadBandwidth>20</ExtranetUploadBandwidth>
<TotalDownloadBandwidth>100</TotalDownloadBandwidth>
<IntranetDownloadBandwidth>-1</IntranetDownloadBandwidth>
<ExtranetDownloadBandwidth>20</ExtranetDownloadBandwidth>
<TotalQps>10000</TotalQps>
<IntranetQps>-1</IntranetQps>
<ExtranetQps>-1</ExtranetQps>
</QoSConfiguration>
Bir pakete erişen bir istek sahibinin kısıtlama yapılandırmalarını sorgulayın
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()
Bir pakete erişen tüm istek sahiplerinin kısıtlama yapılandırmalarını sorgulayın
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()
Bir pakete erişen bir istek sahibinin kısıtlama yapılandırmalarını silin
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()
Farklı istek sahipleri için kaynak havuzu düzeyinde bant genişliği yönetimi
Mevcut Alibaba Cloud hesabındaki tüm kaynak havuzlarını sorgulayın
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()
Bir kaynak havuzu hakkında bilgi sorgulayın
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()
Bir kaynak havuzundaki paketleri sorgulayın
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()
Kaynak havuzundaki bir istek sahibi için kısıtlama kurallarını yapılandırın
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()
qos.xml dosyası aşağıdaki yapılandırmayı içerir:
<QoSConfiguration>
<TotalUploadBandwidth>100</TotalUploadBandwidth>
<IntranetUploadBandwidth>-1</IntranetUploadBandwidth>
<ExtranetUploadBandwidth>20</ExtranetUploadBandwidth>
<TotalDownloadBandwidth>100</TotalDownloadBandwidth>
<IntranetDownloadBandwidth>-1</IntranetDownloadBandwidth>
<ExtranetDownloadBandwidth>20</ExtranetDownloadBandwidth>
<TotalQps>10000</TotalQps>
<IntranetQps>-1</IntranetQps>
<ExtranetQps>-1</ExtranetQps>
</QoSConfiguration>
Kaynak havuzundaki bir istek sahibinin kısıtlama yapılandırmalarını sorgulayın
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()
Kaynak havuzundaki tüm istek sahiplerinin kısıtlama yapılandırmalarını sorgulayın
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()
Kaynak havuzundaki bir istek sahibinin kısıtlama yapılandırmalarını silin
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()
Paket grubu için bant genişliği yönetimi
Kaynak havuzundaki paketleri bir paket grubuna ekleyin
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()
Kaynak havuzundaki paket gruplarını sorgulayın
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()
Kaynak havuzundaki bir paket grubunun kısıtlama yapılandırmalarını değiştirin
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()
qos.xml dosyası aşağıdaki yapılandırmayı içerir:
<QoSConfiguration>
<TotalUploadBandwidth>100</TotalUploadBandwidth>
<IntranetUploadBandwidth>-1</IntranetUploadBandwidth>
<ExtranetUploadBandwidth>20</ExtranetUploadBandwidth>
<TotalDownloadBandwidth>100</TotalDownloadBandwidth>
<IntranetDownloadBandwidth>-1</IntranetDownloadBandwidth>
<ExtranetDownloadBandwidth>20</ExtranetDownloadBandwidth>
<TotalQps>10000</TotalQps>
<IntranetQps>-1</IntranetQps>
<ExtranetQps>-1</ExtranetQps>
</QoSConfiguration>
Kaynak havuzundaki bir paket grubunun kısıtlama yapılandırmalarını sorgulayın
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()
Kaynak havuzundaki paket gruplarının kısıtlama yapılandırmalarını listeleyin
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()
Kaynak havuzundaki bir paket grubunun kısıtlama yapılandırmalarını silin
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()
İlgili başlıklar
Kaynak havuzu QoS ile ilgili API işlemleri hakkında daha fazla bilgi için bkz. Kaynak havuzu QoS ile ilgili işlemler.
Paketler ve istek sahipleri için bant genişliği kısıtlamasının nasıl yapılandırılacağı hakkında daha fazla bilgi için bkz. Kaynak havuzu QoS yapılandırması örnekleri.