Version Information
The SDK version used in this example is: v3.0
Example Overview
Huawei Cloud provides a server-side SDK for CloudPond. You can directly integrate the server-side SDK to call the APIs related to CloudPond, thereby quickly performing operations on the CloudPond service. This example demonstrates how to create a CloudPond site using the Python SDK.
Prerequisites
Obtaining AK/SK
Before using the SDK, you need to obtain the AK and SK of your account.
You need to have a Huawei Cloud account and the corresponding Access Key (AK) and Secret Access Key (SK). Please create and view your AK/SK on the "My Credentials - Access Keys" page in the Huawei Cloud console. For more information, see Access Keys.
Operating Environment
Python3 or later
Obtaining and Installing the SDK
You can configure the Intelligent Edge Station service SDK dependency using Maven.
For the specific SDK version number, please refer to the SDK Development Center (Product Category: CDN and Intelligent Edge)
# Install the Cloudpond SDK library
pip install huaweicloudsdkcloudpond
# Install Core Library
pip install huaweicloudsdkcore
API and Parameter Description
Sample Code
import os
from huaweicloudsdkcore.auth.credentials import GlobalCredentials
from huaweicloudsdkcore.exceptions.exceptions import ClientRequestException
from huaweicloudsdkcore.exceptions.exceptions import ServerResponseException
from huaweicloudsdkcloudpond.v1.cloudpond_client import CloudPondClient
from huaweicloudsdkcloudpond.v1.model.condition import Condition
from huaweicloudsdkcloudpond.v1.model.create_edge_site import CreateEdgeSite
from huaweicloudsdkcloudpond.v1.model.create_edge_site_request import CreateEdgeSiteRequest
from huaweicloudsdkcloudpond.v1.model.create_edge_site_request_body import CreateEdgeSiteRequestBody
from huaweicloudsdkcloudpond.v1.model.create_location import CreateLocation
from huaweicloudsdkcloudpond.v1.region.cloudpond_region import CloudPondRegion
class CloudPondCreateEdgeSiteDemo:
def __init__(self):
pass
@staticmethod
def main(args):
global_credentials = GlobalCredentials(
# Writing the AK and SK used for authentication directly into the code poses significant security risks.
# It is recommended to store them in ciphertext in configuration files or environment variables and decrypt them when needed to ensure security.
# This example demonstrates how to authenticate using AK and SK stored in environment variables.
# Before running this example, please set the environment variables in your local environment.HUAWEICLOUD_SDK_AK和HUAWEICLOUD_SDK_SK。
ak=os.environ["HUAWEICLOUD_SDK_AK"],
sk=os.environ["HUAWEICLOUD_SDK_SK"]
)
cloudpond_client = CloudPondClient.new_builder() \
.with_credentials(credentials=global_credentials) \
.with_region(region=CloudPondRegion.value_of(region_id="cn-north-3")) \
.build()
request = CreateEdgeSiteRequest(
body=CreateEdgeSiteRequestBody(
edge_site=CreateEdgeSite(
name="{edge site name}",
description="{edge site description}",
region_id="{region id}",
location=CreateLocation(
country="cn",
province="{province}",
city="{city}",
district="{district}",
description="{location description}",
condition=Condition(
environment=0,
space=0,
transport=0
)
)
)
)
)
try:
response = cloudpond_client.create_edge_site(request)
print(response)
except (ClientRequestException, ServerResponseException) as e:
print(str(e.status_code))
print(e.error_msg)
if __name__ == "__main__":
CloudPondCreateEdgeSiteDemo().main(any)
Reference
For more information, please refer to: https://support.huaweicloud.com/productdesc-ies/ies_01_0100.html
Change History
| Release Date | Document Version | Revision Description |
|---|---|---|
| 2023-09-18 | 1.0 | Release |