码迷,mamicode.com
首页 > Windows程序 > 详细

01: 腾讯云API

时间:2019-03-27 14:17:21      阅读:622      评论:0      收藏:0      [点我收藏+]

标签:set   model   int   col   服务器   from   上海   secret   pytho   

1.1 云服务器

  1、腾讯云SDK使用举例

       网址:https://cloud.tencent.com/document/sdk/Python

技术图片
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
# 导入对应产品模块的client models。
from tencentcloud.cvm.v20170312 import cvm_client, models

secretId = "*********************************"
secretKey = "*********************************"
try:
    # 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey
    cred = credential.Credential(secretId=secretId, secretKey=secretKey)

    # 实例化要请求产品(以cvm为例)的client对象
    client = cvm_client.CvmClient(cred, "ap-shanghai")     # 以查询可用区接口为例

    # 实例化一个请求对象
    req = models.DescribeZonesRequest()


    # 通过client对象调用想要访问的接口,需要传入请求对象
    resp = client.DescribeZones(req)
    # 输出json格式的字符串回包
    print ##########################
    print resp.to_json_string()

except TencentCloudSDKException as err:
    print(err)

    
ret = {
    "TotalCount": 5,
    "ZoneSet": [{
        "ZoneState": "UNAVAILABLE",
        "ZoneName": "上海一区",
        "Zone": "ap-shanghai-1",
        "ZoneId": "200001"
    }, {
        "ZoneState": "AVAILABLE",
        "ZoneName": "上海二区",
        "Zone": "ap-shanghai-2",
        "ZoneId": "200002"
    }, {
        "ZoneState": "AVAILABLE",
        "ZoneName": "上海三区",
        "Zone": "ap-shanghai-3",
        "ZoneId": "200003"
    }, {
        "ZoneState": "AVAILABLE",
        "ZoneName": "上海四区",
        "Zone": "ap-shanghai-4",
        "ZoneId": "200004"
    }, {
        "ZoneState": "UNAVAILABLE",
        "ZoneName": "上海五区",
        "Zone": "ap-shanghai-5",
        "ZoneId": "200005"
    }],
    "RequestId": "ebd821c7-ac5c-4dfd-8038-762346bd14d1"
}
腾讯云SDK使用举例

  2、地域相关接口

 

 

 

 

 

 

 

11111111111111111111

01: 腾讯云API

标签:set   model   int   col   服务器   from   上海   secret   pytho   

原文地址:https://www.cnblogs.com/xiaonq/p/10607048.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!