Overview
Python SDK consists of the public and product components of Alibaba Cloud Python SDK. The public component relies on aliyun-python-sdk-core, and the product component relies on aliyun-python-sdk-cr. For more information about each interface, see API overview.
Installation
To install the public component of Python SDK, see Getting started Python SDK. Run the following command to install the product component of Python SDK.
pip install aliyun-python-sdk-cr
API call example
#!/usr/bin/env python
# coding=utf-8
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkcore.client import AcsClient
from aliyunsdkcr.request.v20160607 import GetImageLayerRequest
# Set a client
apiClient = AcsClient('AccessKeyId', 'AccessKeySecret', 'cn-hangzhou')
# Build a request
request = GetImageLayerRequest.GetImageLayerRequest()
# Set the parameters
request.set_RepoNamespace("repoNamespaceName")
request.set_RepoName("repoName")
request.set_Tag("tag")
request.set_endpoint("cr.cn-hangzhou.aliyuncs.com")
# Make a request
try:
response = apiClient.do_action_with_exception(request)
print(response)
except ServerException as e:
print(e)
except ClientException as e:
print(e)