import os
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkgsl.v3.gsl_client import GslClient
from huaweicloudsdkgsl.v3.model.list_pro_price_plans_request import ListProPricePlansRequest
from huaweicloudsdkgsl.v3.region.gsl_region import GslRegion
class PricePlansApplication:
__AK = os.environ["HUAWEICLOUD_SDK_AK"]
__SK = os.environ["HUAWEICLOUD_SDK_SK"]
__IAM_ENDPOINT = "https://<IamEndpoint>"
def __init__(self):
pass
@staticmethod
def main(args):
auth = BasicCredentials(
ak=PricePlansApplication.__AK,
sk=PricePlansApplication.__SK,
).with_iam_endpoint(endpoint=PricePlansApplication.__IAM_ENDPOINT)
gsl_client = GslClient.new_builder() \
.with_credentials(credentials=auth) \
.with_region(region=GslRegion.CN_NORTH_4) \
.build()
PricePlansApplication.__get_price_plans_list(gsl_client)
@staticmethod
def __get_price_plans_list(gsl_client):
offset = 1
limit = 10
carrier_type = 1
try:
response = gsl_client.list_pro_price_plans(
ListProPricePlansRequest(
offset=offset,
limit=limit,
carrier_type=carrier_type
)
)
print(response)
except exceptions.ClientRequestException as e:
print(e.status_code)
print(e.request_id)
print(e.error_code)
print(e.error_msg)
if __name__ == "__main__":
PricePlansApplication().main(any)