ITPub博客

【Python】阿里云python sdk快速入门

原创 DevOps 作者:小亮520cl 时间:2018-08-10 15:28:56 0 删除 编辑

1 示列代码如下

# -*- coding: utf8 -*-
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkecs.request.v20140526 import DescribeInstancesRequest
from aliyunsdkecs.request.v20140526 import StopInstanceRequest
from aliyunsdkrds.request.v20140815 import DescribeDBInstancesRequest
# 创建 AcsClient 实例
client = AcsClient(
"XXXXXXXXXX", 
"XXXXXXXXXXXXX",
"XXXXXXXXX"
);
# 创建 request,并设置参数
request = DescribeDBInstancesRequest.DescribeDBInstancesRequest()
request.set_PageSize(10)
# 发起 API 请求并打印返回
response = client.do_action_with_exception(request)
print response


返回结果

{
    "Items": {
        "DBInstance": [
            {
                "LockMode": "Unlock", 
                "DBInstanceNetType": "Intranet", 
                "DBInstanceClass": "mysql.n2.medium.1", 
                "ResourceGroupId": "rg-acfnsgk4qv2czbi", 
                "DBInstanceId": "rm-6gjs5qm4oo40cvnij", 
                "VpcCloudInstanceId": "xxxxxx", 
                "ZoneId": "ap-south-1a", 
                "ReadOnlyDBInstanceIds": {
                    "ReadOnlyDBInstanceId": [ ]
                }, 
                "InstanceNetworkType": "VPC", 
                "DBInstanceDescription": "xxxxxxxxxx", 
                "ConnectionMode": "Standard", 
                "VSwitchId": "xxxxxxxxx", 
                "VpcId": "xxxxxxxx", 
                "Engine": "MySQL", 
                "MutriORsignle": false, 
                "InsId": 1, 
                "ExpireTime": "", 
                "CreateTime": "2018-08-06T15:35Z", 
                "DBInstanceType": "Primary", 
                "RegionId": "ap-south-1", 
                "EngineVersion": "5.7", 
                "LockReason": "", 
                "DBInstanceStatus": "Running", 
                "PayType": "Postpaid"
            }, 
            {
                "LockMode": "Unlock", 
                "DBInstanceNetType": "Intranet", 
                "DBInstanceClass": "rds.mysql.s2.large", 
                "ResourceGroupId": "rg-acfnsgk4qv2czbi", 
                "DBInstanceId": "rm-6gjie25ei5u6sd588", 
                "VpcCloudInstanceId": "rm-6gjie25ei5u6sd588", 
                "ZoneId": "ap-south-1a", 
                "ReadOnlyDBInstanceIds": {
                    "ReadOnlyDBInstanceId": [ ]
                }, 
                "InstanceNetworkType": "VPC", 
                "DBInstanceDescription": "xxxxxxxxx", 
                "ConnectionMode": "Safe", 
                "VSwitchId": "vsw-a2d94448xglixxx85czqq208lne", 
                "VpcId": "vpc-a2dqe44k2xxk0ci69aewq27vx", 
                "Engine": "MySQL", 
                "MutriORsignle": false, 
                "InsId": 1, 
                "ExpireTime": "2018-08-24T16:00:00Z", 
                "CreateTime": "2018-07-24T21:40Z", 
                "DBInstanceType": "Primary", 
                "RegionId": "ap-south-1", 
                "EngineVersion": "5.6", 
                "LockReason": "", 
                "DBInstanceStatus": "Running", 
                "PayType": "Prepaid"
            }
        ]
    }, 
    "TotalRecordCount": 2, 
    "PageNumber": 1, 
    "RequestId": "DF7ECC24-F87E-4834-83A4-885DA62825E1", 
    "PageRecordCount": 2
}



具体怎么使用参考如下:

https://www.alibabacloud.com/help/zh/doc-detail/67121.htm?spm=a2c63.p38356.b99.28.2ae55ccdRbyzZp  (sdk使用)

https://www.alibabacloud.com/help/zh/doc-detail/26232.htm?spm=a2c63.p38356.b99.280.14dd75ab5Bazcz   (rds的api接口)


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29096438/viewspace-2199788/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-09-12

  • 博文量
    526
  • 访问量
    943864