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

Commit 87f2812

Browse files
committed
release python sdk 1.0.23
1 parent 07bd878 commit 87f2812

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+3339
-529
lines changed

PKG-INFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 1.1
22
Name: huaweicloud-sdk-python
3-
Version: 1.0.22
3+
Version: 1.0.23
44
Summary: An SDK for building applications to work with OpenStack
55
Home-page: https://github.com/huaweicloud/huaweicloud-sdk-python
66
Author: huawei

examples/bss/v1/customer_management.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
user_domain_id=userDomainId,
2727
domain_id=userDomainId,
2828
username=username,
29-
password=password,
30-
verify=False)
29+
password=password)
3130

3231
data = {
3332
"searchType": "email",

examples/compute/v2/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def create_server():
2525
"flavor_id": "s1.medium",
2626
"security_groups":[
2727
{
28-
"name": "Sys-default"
28+
"name": "default"
2929
}
3030
],
3131
"networks":[

examples/ecs/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def create_server():
2525
"flavor_id": "s1.medium",
2626
"security_groups":[
2727
{
28-
"name": "Sys-default"
28+
"name": "default"
2929
}
3030
],
3131
"networks":[

examples/eps/v1/__init__.py

Whitespace-only changes.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import sys
2+
import warnings
3+
import os
4+
5+
from openstack import utils
6+
from openstack import connection
7+
8+
username = "*************"
9+
password = '*************'
10+
userDomainId = "*************"
11+
auth_url = "https://iam.xxx.com/v3" # endpoint url
12+
13+
conn = connection.Connection(auth_url=auth_url,
14+
user_domain_id=userDomainId,
15+
domain_id=userDomainId,
16+
username=username,
17+
password=password)
18+
19+
def create_enterprise_project(_conn):
20+
data = {
21+
"name": "test56",
22+
"description": "test56"
23+
}
24+
res = _conn.eps.create_enterprise_project(**data)
25+
print res
26+
27+
28+
def list_enterprise_projects(_conn):
29+
query = {
30+
"name": "test"
31+
}
32+
enterprise_projects = _conn.eps.list_enterprise_projects(**query)
33+
print enterprise_projects
34+
35+
36+
def get_enterprise_project(_conn):
37+
enterpriseProjectId = "0e00f529-7d13-4d47-8c62-496a27ecb3c6"
38+
result = _conn.eps.get_enterprise_project( enterpriseProjectId)
39+
print result
40+
41+
def enterprise_project_quotas(_conn):
42+
result = _conn.eps.enterprise_project_quotas()
43+
print result
44+
45+
def update_enterprise_project(_conn):
46+
enterpriseProjectId = "0278f73a-c3dc-4089-99af-3cb2cf42f76b"
47+
data = {
48+
"name": "test008",
49+
"description": "test008"
50+
}
51+
result = _conn.eps.update_enterprise_project( enterpriseProjectId, **data)
52+
print result
53+
54+
55+
def filter_resource_enterprise_project(_conn):
56+
enterpriseProjectId = "0278f73a-c3dc-4089-99af-3cb2cf42f76b"
57+
data = {
58+
"projects": ["0605767f6f00d5762ff9c001c70e7359"],
59+
"limit": 10,
60+
"offset": 0,
61+
"resource_types": ["ecs", "scaling_group", "images", "disk", "vpcs"]
62+
}
63+
result = _conn.eps.filter_resource_enterprise_project( enterpriseProjectId, **data)
64+
print result
65+
66+
67+
def migrate_resource_enterprise_project(_conn):
68+
enterpriseProjectId = "0278f73a-c3dc-4089-99af-3cb2cf42f76b"
69+
data = {
70+
"project_id": "0605767f6f00d5762ff9c001c70e7359",
71+
"associated": False,
72+
"cloud_resource_type": "vpcs",
73+
"resource_id": "3dd93a56-2a1f-470e-91a4-3376ebde2fb6"
74+
}
75+
result = _conn.eps.migrate_resource_enterprise_project( enterpriseProjectId, **data)
76+
print result
77+
78+
def enable_enterprise_project(_conn):
79+
enterpriseProjectId = "07b780ee-91ca-4861-a468-9f35ebd95586"
80+
data = {
81+
"action": "enable"
82+
}
83+
result = _conn.eps.operate_enterprise_project( enterpriseProjectId, **data)
84+
print result
85+
86+
def disable_enterprise_project(_conn):
87+
enterpriseProjectId = "07b780ee-91ca-4861-a468-9f35ebd95586"
88+
data = {
89+
"action": "disable"
90+
}
91+
result = _conn.eps.operate_enterprise_project( enterpriseProjectId, **data)
92+
print result
93+
94+
if __name__ == '__main__':
95+
create_enterprise_project(conn)
96+
list_enterprise_projects(conn)
97+
get_enterprise_project(conn)
98+
enterprise_project_quotas(conn)
99+
update_enterprise_project(conn)
100+
filter_resource_enterprise_project(conn)
101+
migrate_resource_enterprise_project(conn)
102+
enable_enterprise_project(conn)
103+
disable_enterprise_project(conn)
104+
pass

examples/iam/v3/agency.py

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
#!/usr/bin/python
2+
# coding=utf-8
3+
4+
from openstack import connection
5+
6+
username = "**********"
7+
password = "**********"
8+
userDomainId = "**********"
9+
auth_url = "**********"
10+
11+
# create connection
12+
conn = connection.Connection(
13+
auth_url=auth_url,
14+
user_domain_id=userDomainId,
15+
domain_id=userDomainId,
16+
username=username,
17+
password=password
18+
)
19+
20+
21+
# Query an agency list
22+
# GET /v3.0/OS-AGENCY/agencies
23+
def get_agency_list():
24+
agencies = conn.iam.agencies(domain_id=userDomainId)
25+
# agencies = conn.iam.agencies(domain_id=userDomainId, name="**********", trust_domain_id="**********")
26+
for agency in agencies:
27+
print(agency)
28+
29+
30+
# Query agency details
31+
# GET /v3.0/OS-AGENCY/agencies/{agency_id}
32+
def get_agency():
33+
agency_id = "**********"
34+
agency = conn.iam.get_agency(agency_id)
35+
print(agency)
36+
37+
38+
# Create agency
39+
# POST /v3.0/OS-AGENCY/agencies
40+
def create_agency():
41+
agency = {
42+
"name": "**********",
43+
"domain_id": "**********",
44+
"trust_domain_id": "**********",
45+
"trust_domain_name": "**********",
46+
"duration": "**********",
47+
"description": "**********"
48+
}
49+
agency = conn.iam.create_agency(**agency)
50+
print(agency)
51+
52+
53+
# Update agency
54+
# POST /v3.0/OS-AGENCY/agencies
55+
def update_agency():
56+
agency_id = "**********"
57+
agency = {
58+
"agency": {
59+
"trust_domain_id": "**********",
60+
"trust_domain_name": "**********",
61+
"description": "**********",
62+
"duration": "**********"
63+
}
64+
}
65+
agency = conn.iam.update_agency(agency_id, **agency)
66+
print(agency)
67+
68+
69+
# Delete agency
70+
# DELETE /v3.0/OS-CREDENTIAL/credentials/{access_key}
71+
def delete_agency():
72+
agency_id = "**********"
73+
conn.iam.delete_agency(agency_id)
74+
75+
76+
# Query domain permissions of an agency
77+
# GET /v3.0/OS-AGENCY/domains/{domain_id}/agencies/{agency_id}/roles
78+
def list_domain_agency_role():
79+
domain_id = "**********"
80+
agency_id = "**********"
81+
roles = conn.iam.list_domain_agency_role(domain_id, agency_id)
82+
for role in roles:
83+
print(role)
84+
85+
86+
# Query project permissions of an agency
87+
# GET /v3.0/OS-AGENCY/projects/{project_id}/agencies/{agency_id}/roles
88+
def list_project_agency_role():
89+
project_id = "**********"
90+
agency_id = "**********"
91+
roles = conn.iam.list_project_agency_role(project_id, agency_id)
92+
for role in roles:
93+
print(role)
94+
95+
96+
# Grant domain permission to an agency
97+
# PUT /v3.0/OS-AGENCY/domains/{domain_id}/agencies/{agency_id}/roles/{role_id}
98+
def grant_domain_agency_role():
99+
domain_id = "**********"
100+
agency_id = "**********"
101+
role_id = "**********"
102+
result = conn.iam.grant_domain_agency_role(domain_id, agency_id, role_id)
103+
if result is True:
104+
print("Grant domain permission to an agency successfully")
105+
else:
106+
print("Grant domain permission to an agency failure")
107+
108+
109+
# Grant project permission to an agency
110+
# PUT /v3.0/OS-AGENCY/projects/{project_id}/agencies/{agency_id}/roles/{role_id}
111+
def grant_project_agency_role():
112+
project_id = "**********"
113+
agency_id = "**********"
114+
role_id = "**********"
115+
result = conn.iam.grant_project_agency_role(project_id, agency_id, role_id)
116+
if result is True:
117+
print("Grant project permission to an agency successfully")
118+
else:
119+
print("Grant project permission to an agency failure")
120+
121+
122+
# Query whether an agency has specific domain permission
123+
# HEAD /v3.0/OS-AGENCY/domains/{domain_id}/agencies/{agency_id}/roles/{role_id}
124+
def check_domain_agency_role():
125+
domain_id = "**********"
126+
agency_id = "**********"
127+
role_id = "**********"
128+
result = conn.iam.check_domain_agency_role(domain_id, agency_id, role_id)
129+
if result is True:
130+
print("The agency has this domain permission")
131+
else:
132+
print("The agency doesn't have this domain permission")
133+
134+
135+
# Query whether an agency has specific project permission
136+
# HEAD /v3.0/OS-AGENCY/projects/{project_id}/agencies/{agency_id}/roles/{role_id}
137+
def check_project_agency_role():
138+
project_id = "**********"
139+
agency_id = "**********"
140+
role_id = "**********"
141+
result = conn.iam.check_project_agency_role(project_id, agency_id, role_id)
142+
if result is True:
143+
print("The agency has this project permission")
144+
else:
145+
print("The agency doesn't have this project permission")
146+
147+
148+
# Delete domain permission of an agency
149+
# DELETE /v3.0/OS-AGENCY/domains/{domain_id}/agencies/{agency_id}/roles/{role_id}
150+
def delete_domain_agency_role():
151+
domain_id = "**********"
152+
agency_id = "**********"
153+
role_id = "**********"
154+
result = conn.iam.delete_domain_agency_role(domain_id, agency_id, role_id)
155+
if result is True:
156+
print("Delete domain permission of an agency successfully")
157+
else:
158+
print("Delete domain permission of an agency failure")
159+
160+
161+
# Delete project permission of an agency
162+
# DELETE /v3.0/OS-AGENCY/projects/{project_id}/agencies/{agency_id}/roles/{role_id}
163+
def delete_project_agency_role():
164+
project_id = "**********"
165+
agency_id = "**********"
166+
role_id = "**********"
167+
result = conn.iam.delete_project_agency_role(project_id, agency_id, role_id)
168+
if result is True:
169+
print("Delete project permission of an agency successfully")
170+
else:
171+
print("Delete project permission of an agency failure")
172+
173+
174+
if __name__ == "__main__":
175+
get_agency_list()
176+
get_agency()
177+
create_agency()
178+
update_agency()
179+
delete_agency()
180+
list_domain_agency_role()
181+
list_project_agency_role()
182+
grant_domain_agency_role()
183+
grant_project_agency_role()
184+
check_domain_agency_role()
185+
check_project_agency_role()
186+
delete_domain_agency_role()
187+
delete_project_agency_role()

0 commit comments

Comments
 (0)