示例简介
华为云提供了智能边缘小站服务端SDK,您可以直接集成服务端SDK来调用智能边缘小站的相关API,从而实现对智能边缘小站服务的快速操作。
该示例展示了如何通过Python版SDK查询边缘小站列表。
前置条件
获取AK/SK
开发者在使用前需先获取账号的ak、sk。
您需要拥有华为云账号以及该账号对应的 Access Key(AK)和 Secret Access Key(SK)。
请在华为云控制台“我的凭证-访问密钥”页面上创建和查看您的 AK/SK。更多信息请查看访问密钥。
运行环境
Python3及其以上版本
SDK获取和安装
具体的SDK版本号请参见 SDK开发中心 (产品类别:边缘云服务)
Copied!
pip install huaweicloudsdkies
接口及参数说明
接口及参数说明
示例代码
Copied!
from huaweicloudsdkcore.auth.credentials import GlobalCredentials
from huaweicloudsdkcore.exceptions.exceptions import ClientRequestException
from huaweicloudsdkcore.exceptions.exceptions import ServerResponseException
from huaweicloudsdkies.v1.ies_client import IesClient
from huaweicloudsdkies.v1.model.list_edge_sites_request import ListEdgeSitesRequest
from huaweicloudsdkies.v1.region.ies_region import IesRegion
import os
class IESListEdgeSitesDemo:
def __init__(self):
pass
@staticmethod
def main(args):
ak = os.environ["HUAWEICLOUD_SDK_AK"]
sk = os.environ["HUAWEICLOUD_SDK_SK"]
global_credentials = GlobalCredentials(
ak="ak",
sk="sk"
)
ies_client = IesClient.new_builder() \
.with_credentials(credentials=global_credentials) \
.with_region(region=IesRegion.value_of(region_id="cn-north-4")) \
.build()
request = ListEdgeSitesRequest(
limit=10
)
try:
response = ies_client.list_edge_sites(request)
print(response)
except (ClientRequestException, ServerResponseException) as e:
print(str(e.status_code))
print(e)
if __name__ == "__main__":
IESListEdgeSitesDemo().main(any)
参考
更多信息请参考:https://support.huaweicloud.com/productdesc-ies/ies_01_0100.html
修订记录
发布日期 |
文档版本 |
修订说明 |
2022-04-28 |
1.0 |
文档首次发布 |
版本说明
本示例基于华为云SDK开发
示例简介
华为云提供了智能边缘小站服务端SDK,您可以直接集成服务端SDK来调用智能边缘小站的相关API,从而实现对智能边缘小站服务的快速操作。
该示例展示了如何通过Python版SDK查询边缘小站列表。
前置条件
获取AK/SK
开发者在使用前需先获取账号的ak、sk。
您需要拥有华为云账号以及该账号对应的 Access Key(AK)和 Secret Access Key(SK)。 请在华为云控制台“我的凭证-访问密钥”页面上创建和查看您的 AK/SK。更多信息请查看访问密钥。
运行环境
Python3及其以上版本
SDK获取和安装
具体的SDK版本号请参见 SDK开发中心 (产品类别:边缘云服务)
接口及参数说明
接口及参数说明
示例代码
from huaweicloudsdkcore.auth.credentials import GlobalCredentials from huaweicloudsdkcore.exceptions.exceptions import ClientRequestException from huaweicloudsdkcore.exceptions.exceptions import ServerResponseException from huaweicloudsdkies.v1.ies_client import IesClient from huaweicloudsdkies.v1.model.list_edge_sites_request import ListEdgeSitesRequest from huaweicloudsdkies.v1.region.ies_region import IesRegion import os class IESListEdgeSitesDemo: def __init__(self): pass @staticmethod def main(args): # 认证用的ak和sk直接写到代码中有很大的安全风险,建议在配置文件或者环境变量中密文存放,使用时解密,确保安全; # 本示例以ak和sk保存在环境变量中来实现身份验证为例,运行本示例前请先在本地环境中设置环境变量HUAWEICLOUD_SDK_AK和HUAWEICLOUD_SDK_SK。 ak = os.environ["HUAWEICLOUD_SDK_AK"] sk = os.environ["HUAWEICLOUD_SDK_SK"] global_credentials = GlobalCredentials( ak="ak", sk="sk" ) ies_client = IesClient.new_builder() \ .with_credentials(credentials=global_credentials) \ .with_region(region=IesRegion.value_of(region_id="cn-north-4")) \ .build() # 查询边缘小站列表请求 request = ListEdgeSitesRequest( limit=10 ) try: response = ies_client.list_edge_sites(request) print(response) except (ClientRequestException, ServerResponseException) as e: print(str(e.status_code)) print(e) if __name__ == "__main__": IESListEdgeSitesDemo().main(any)
参考
更多信息请参考:https://support.huaweicloud.com/productdesc-ies/ies_01_0100.html
修订记录