华为云调用api获取vpc信息(aksk方式)

华为云调用api获取vpc信息(aksk方式),第1张

华为云调用api获取vpc信息(ak/sk方式)
#encoding=utf-8
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcore.http.http_config import HttpConfig
from huaweicloudsdkvpc.v2 import *
def list_vpc(client):    
        try:        
                request = ListVpcsRequest(limit=100)        
                response = client.list_vpcs(request)    
        except exceptions.ClientRequestException as e:        
                print(e)

if __name__ == "__main__":    
        ak = "xxx"    
        sk = "xxx"    
        endpoint = "xxx"  #api的地址    
        project_id = "xxx" #项目id    
        config = HttpConfig.get_default_config()    
        config.ignore_ssl_verification = True    
        credentails = BasicCredentials(ak,sk,project_id)    
        vpc_client = VpcClient.new_builder()                
                .with_http_config(config)                
                .with_credentials(credentails)                
                .with_endpoint(endpoint)                
                .build()    

        list_vpc(vpc_client)  #获取vpc信息,函数都在vpc_client.py中,点击VpcClient就可以跳转到文件

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5714754.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存