Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
release go sdk 1.0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
karonganyong committed Dec 19, 2019
1 parent 7a404cd commit c11c18b
Show file tree
Hide file tree
Showing 88 changed files with 5,316 additions and 56 deletions.
2 changes: 1 addition & 1 deletion PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: huaweicloud-sdk-python
Version: 1.0.19
Version: 1.0.20
Summary: An SDK for building applications to work with OpenStack
Home-page: https://github.com/huaweicloud/huaweicloud-sdk-python
Author: huawei
Expand Down
28 changes: 28 additions & 0 deletions examples/auth/aksk_auth_global_level.py
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()
29 changes: 29 additions & 0 deletions examples/auth/aksk_auth_project_level.py
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()
24 changes: 24 additions & 0 deletions examples/auth/auth_with_token_id.py
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)
28 changes: 28 additions & 0 deletions examples/auth/token_auth_global_level.py
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()
30 changes: 30 additions & 0 deletions examples/auth/token_auth_project_level.py
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()
15 changes: 15 additions & 0 deletions examples/block_store/v2/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def create_snapshot():
}
print(conn.block_store.create_snapshot(**data))


# update snapshot
def update_snapshot():
snapshot_id = 'xxx'
Expand All @@ -44,6 +45,7 @@ def update_snapshot():
snapshot = conn.block_store.update_snapshot(snapshot_id, **data)
print(snapshot)


# get snapshot
def get_snapshot():
snapshot_id = 'xxx'
Expand All @@ -56,6 +58,7 @@ def delete_snapshot():
snapshot_id = 'xxx'
conn.block_store.delete_snapshot(snapshot_id)


# create snapshot metadata
def create_snapshot_metadata():
snapshot_id = 'xxx'
Expand All @@ -67,12 +70,14 @@ def create_snapshot_metadata():
snapshot_metadata = conn.block_store.create_snapshot_metadata(snapshot_id, **data)
print(snapshot_metadata)


# get snapshot metadata
def get_snapshot_metadata():
snapshot_id = 'xxx'
snapshot_metadata = conn.block_store.get_snapshot_metadata(snapshot_id, key=None)
print(snapshot_metadata)


# update snapshot metadata
def update_snapshot_metadata():
snapshot_id = 'xxx'
Expand All @@ -84,17 +89,26 @@ def update_snapshot_metadata():
snapshot_metadata = conn.block_store.update_snapshot_metadata(snapshot_id, key=None, **data_all)
print(snapshot_metadata)


# delete snapshot metadata
def delete_snapshot_metadata():
snapshot_id = 'xxx'
snapshot_metadata = conn.block_store.delete_snapshot_metadata(snapshot_id, key='delete_key')
print(snapshot_metadata)


# snapshots
def snapshots():
for index in conn.block_store.snapshots():
print(index)


# list snapshots with paginated
def list_snapshots_one_page():
for index in conn.block_store.snapshots(paginated=False, limit=4):
print(index)


if __name__ == '__main__':
create_snapshot()
update_snapshot()
Expand All @@ -105,3 +119,4 @@ def snapshots():
update_snapshot_metadata()
delete_snapshot_metadata()
snapshots()
list_snapshots_one_page()
7 changes: 7 additions & 0 deletions examples/block_store/v2/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ def volumes():
print(index)


# list volumes with paginated
def list_volumes_one_page():
for index in conn.block_store.volumes(paginated=False, limit=3):
print(index)


# get volume
def get_volume():
volume_id = 'xxx'
Expand Down Expand Up @@ -177,6 +183,7 @@ def export_image_by_volume():
update_volume()
expand_volume()
volumes()
list_volumes_one_page()
get_volume()
get_quota_set()
create_volume_metadata()
Expand Down
Empty file added examples/bss/__init__.py
Empty file.
Empty file added examples/bss/v1/__init__.py
Empty file.
69 changes: 69 additions & 0 deletions examples/bss/v1/bill.py
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)
67 changes: 67 additions & 0 deletions examples/bss/v1/customer_management.py
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)
Loading

0 comments on commit c11c18b

Please sign in to comment.