This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a404cd
commit c11c18b
Showing
88 changed files
with
5,316 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python | ||
# coding=utf-8 | ||
from openstack import connection | ||
|
||
ak = "replace-with-your-ak" | ||
sk = "replace-with-your-sk" | ||
cloud = "myhuaweicloud.com" | ||
domain_id = "replace-with-your-domain-id" | ||
|
||
conn = connection.Connection( | ||
ak=ak, | ||
sk=sk, | ||
cloud=cloud, | ||
domain_id=domain_id, | ||
) | ||
|
||
|
||
def test_list_zones(): | ||
query = { | ||
"limit": 3, | ||
} | ||
data = conn.dns.zones(**query) | ||
for i in data: | ||
print i | ||
|
||
|
||
if __name__ == "__main__": | ||
test_list_zones() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python | ||
# coding=utf-8 | ||
from openstack import connection | ||
|
||
ak = "replace-with-your-ak" | ||
sk = "replace-with-your-sk" | ||
cloud = "myhuaweicloud.com" | ||
project_id = "replace-with-your-project-id" | ||
region = "replace-with-your-region-name" | ||
conn = connection.Connection( | ||
ak=ak, | ||
sk=sk, | ||
cloud=cloud, | ||
project_id=project_id, | ||
region=region | ||
) | ||
|
||
|
||
def test_list_servers(): | ||
query = { | ||
"limit": 3, | ||
} | ||
objs = conn.compute.servers(**query) | ||
for i in objs: | ||
print i | ||
|
||
|
||
if __name__ == "__main__": | ||
test_list_servers() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env python | ||
# coding=utf-8 | ||
from openstack import connection | ||
|
||
auth_token = "replace-with-your-token-id" | ||
auth_url = "https://iam.example.com/v3" | ||
|
||
token_conn = connection.Connection( | ||
auth_url=auth_url, | ||
auth_token=auth_token, | ||
) | ||
|
||
|
||
def test_list_endpoints(conn): | ||
query = { | ||
"limit": 3, | ||
} | ||
objs = conn.identity.endpoints(**query) | ||
for i in objs: | ||
print i | ||
|
||
|
||
if __name__ == "__main__": | ||
test_list_endpoints(token_conn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python | ||
# coding=utf-8 | ||
from openstack import connection | ||
|
||
# create connection | ||
username = "replace-with-your-username" | ||
password = "replace-with-your-password" | ||
domainId = "replace-with-your-domain-id" | ||
userDomainId = "replace-with-your-user-domain-id" | ||
auth_url = "https://iam.example.com/v3" | ||
conn = connection.Connection(auth_url=auth_url, | ||
user_domain_id=userDomainId, | ||
domain_id=domainId, | ||
username=username, | ||
password=password) | ||
|
||
|
||
def test_list_zones(): | ||
query = { | ||
"limit": 3, | ||
} | ||
data = conn.dns.zones(**query) | ||
for i in data: | ||
print i | ||
|
||
|
||
if __name__ == "__main__": | ||
test_list_zones() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env python | ||
# coding=utf-8 | ||
from openstack import connection | ||
|
||
# create connection | ||
username = "replace-with-your-username" | ||
password = "replace-with-your-password" | ||
projectId = "replace-with-your-project-id" | ||
userDomainId = "replace-with-your-user-domain-id" | ||
auth_url = "https://iam.example.com/v3" | ||
conn = connection.Connection(auth_url=auth_url, | ||
user_domain_id=userDomainId, | ||
project_id=projectId, | ||
username=username, | ||
password=password) | ||
|
||
|
||
def list_metrics(): | ||
query = { | ||
"namespace": "SYS.ECS", | ||
"metric_name": "cpu_util", | ||
"limit": 1 | ||
} | ||
metrics = conn.cloud_eye.metrics(**query) | ||
for metric in metrics: | ||
print(metric) | ||
|
||
|
||
if __name__ == "__main__": | ||
list_metrics() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# -*- coding:utf-8 -*- | ||
# Copyright 2019 Huawei Technologies Co.,Ltd. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
# this file except in compliance with the License. You may obtain a copy of the | ||
# License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed | ||
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
# CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
|
||
|
||
from openstack import connection | ||
|
||
# create connection | ||
username = "xxxxxx" | ||
password = "xxxxxx" | ||
userDomainId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx" # user account ID | ||
auth_url = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx" # endpoint url | ||
|
||
if __name__ == '__main__': | ||
conn = connection.Connection(auth_url=auth_url, | ||
user_domain_id=userDomainId, | ||
domain_id=userDomainId, | ||
username=username, | ||
password=password) | ||
data = { | ||
"cycle": "2019-09", | ||
"cloud_service_type_code": "hws.service.type.ebs", | ||
"type": "1", | ||
} | ||
''' | ||
This API can be used to query the expenditure summary bills of a customer on the customer platform. The bills summarize the summary data by month. The data of the previous day is updated once a day. | ||
This API can be invoked using the customer AK/SK or token only. | ||
''' | ||
ff = conn.bss.query_monthly_expenditure_summary(userDomainId, **data) | ||
print(ff) | ||
|
||
data = { | ||
'cycle': "2019-09", | ||
'cloudServiceTypeCode': 'hws.service.type.ec2', | ||
'resourceTypeCode': 'hws.resource.type.vm', | ||
'regionCode': 'cn-north-1', | ||
'resInstanceId': "xxxxxxxxxxxxxxx", | ||
'payMethod': '0', | ||
'offset': '1', | ||
'limit': '10' | ||
} | ||
''' | ||
This API can be used to query usage details of each resource for a customer on the customer platform. The resource details have a latency (a maximum of 24 hours). | ||
This API can be invoked using the customer AK/SK or token only. | ||
''' | ||
ff = conn.bss.query_resource_usage_details(userDomainId, **data) | ||
print(ff) | ||
|
||
data = { | ||
'startTime': '2019-09-01', | ||
'endTime': '2019-09-30', | ||
'payMethod': '1' | ||
} | ||
''' | ||
This API can be used to query the usage details of each resource for a customer on the customer platform. | ||
This API can be invoked using the customer AK/SK or token only. | ||
''' | ||
ff = conn.bss.query_resource_usage_record(userDomainId, **data) | ||
print(ff) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# -*- coding:utf-8 -*- | ||
# Copyright 2019 Huawei Technologies Co.,Ltd. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
# this file except in compliance with the License. You may obtain a copy of the | ||
# License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed | ||
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
# CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
|
||
|
||
from openstack import connection | ||
|
||
# create connection | ||
username = "xxxxxx" | ||
password = "xxxxxx" | ||
userDomainId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx" # user account ID | ||
auth_url = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx" # endpoint url | ||
|
||
if __name__ == '__main__': | ||
conn = connection.Connection(auth_url=auth_url, | ||
user_domain_id=userDomainId, | ||
domain_id=userDomainId, | ||
username=username, | ||
password=password, | ||
verify=False) | ||
|
||
data = { | ||
"searchType": "email", | ||
"searchKey": "[email protected]" | ||
} | ||
''' | ||
This API is used to check whether the account name, and mobile number or email address entered by the customer can be used for registration. | ||
This API can be invoked only by the partner AK/SK or token. | ||
''' | ||
ff = conn.bss.check_customer_register_info(userDomainId, **data) | ||
print(ff) | ||
|
||
data = { | ||
"xAccountId": "xxxxxxxxxxx", | ||
"xAccountType": "xxxxxxxxxxxxxxx", | ||
"domainName": "xxxxxxxxx", | ||
"password": "xxxxxxxxxxx" | ||
} | ||
''' | ||
This API is used to create a HUAWEI CLOUD account for a customer when the customer creates an account on your sales platform, | ||
and bind the customer account on the partner sales platform to the HUAWEI CLOUD account. | ||
In addition, the HUAWEI CLOUD account is bound to the partner account. | ||
This API can be invoked only by the partner AK/SK or token. | ||
''' | ||
ff = conn.bss.create_customer(userDomainId, **data) | ||
print(ff) | ||
|
||
data = { | ||
"cooperationTimeStart": "2019-05-01T00:01:00Z", | ||
"cooperationTimeEnd": "2019-12-01T00:01:00Z" | ||
} | ||
''' | ||
This API is used to query your customers. | ||
This API can be invoked only by the partner account AK/SK or token. | ||
''' | ||
ff = conn.bss.query_customer_list(userDomainId, **data) | ||
print(ff) |
Oops, something went wrong.