Skip to content

Commit 001038d

Browse files
authored
envs management implemented (#520)
envs management implemented Reviewed-by: Anton Sidelnikov
1 parent a97db7d commit 001038d

File tree

18 files changed

+454
-25
lines changed

18 files changed

+454
-25
lines changed

.stestr.blacklist.functional

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ otcextensions.tests.functional.sdk.function_graph.v2.test_log*
4141
otcextensions.tests.functional.sdk.function_graph.v2.test_template*
4242
otcextensions.tests.functional.sdk.function_graph.v2.test_import_export*
4343
otcextensions.tests.functional.sdk.apig.v2.test_gateway
44+
otcextensions.tests.functional.sdk.apig.v2.test_environment

doc/source/sdk/guides/apig.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,45 @@ supported by API Gateway.
163163

164164
.. literalinclude:: ../examples/apig/list_azs.py
165165
:lines: 16-25
166+
167+
Environment
168+
___________
169+
170+
Create Environment
171+
^^^^^^^^^^^^^^^^^^
172+
173+
This example demonstrates how to create a new environment within
174+
a specific API Gateway.
175+
176+
.. literalinclude:: ../examples/apig/create_env.py
177+
:lines: 16-25
178+
179+
180+
Update Environment
181+
^^^^^^^^^^^^^^^^^^
182+
183+
This example demonstrates how to update an existing environment
184+
within a specific API Gateway.
185+
186+
.. literalinclude:: ../examples/apig/update_env.py
187+
:lines: 16-26
188+
189+
190+
Delete Environment
191+
^^^^^^^^^^^^^^^^^^
192+
193+
This example demonstrates how to delete an existing environment
194+
from a specific API Gateway.
195+
196+
.. literalinclude:: ../examples/apig/delete_env.py
197+
:lines: 16-21
198+
199+
200+
List Environments
201+
^^^^^^^^^^^^^^^^^
202+
203+
This example demonstrates how to list all environments associated
204+
with a specific API Gateway.
205+
206+
.. literalinclude:: ../examples/apig/list_envs.py
207+
:lines: 16-20

doc/source/sdk/proxies/apig.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ AZ Operations
1919
.. autoclass:: otcextensions.sdk.apig.v2._proxy.Proxy
2020
:noindex:
2121
:members: azs
22+
23+
Environment Operations
24+
^^^^^^^^^^^^^^^^^^^^^^
25+
.. autoclass:: otcextensions.sdk.apig.v2._proxy.Proxy
26+
:noindex:
27+
:members: create_environment, update_environment, environments,
28+
delete_environment

doc/source/sdk/resources/apig/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ ApiGateway Resources
66

77
v2/gateway
88
v2/az
9+
v2/env
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
otcextensions.sdk.apig.v2.apienvironment
2+
========================================
3+
4+
.. automodule:: otcextensions.sdk.apig.v2.apienvironment
5+
6+
The ApiEnvironment Class
7+
------------------------
8+
9+
The ``ApiEnvironment`` class inherits from
10+
:class:`~otcextensions.sdk.sdk_resource.Resource`.
11+
12+
.. autoclass:: otcextensions.sdk.apig.v2.apienvironment.ApiEnvironment
13+
:members:

examples/apig/create_env.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python3
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
"""
14+
Create env in gateway
15+
"""
16+
import openstack
17+
18+
openstack.enable_logging(True)
19+
conn = openstack.connect(cloud='otc')
20+
attrs = {
21+
"name": "DEV",
22+
"remark": "Development environment"
23+
}
24+
environment = conn.apig.create_environment(gateway="gateway_id",
25+
**attrs)

examples/apig/create_gateway.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828
'available_zone_ids': ['available_zone_ids'],
2929
}
3030

31-
gateway = conn.network.create_gateway(**attrs)
31+
gateway = conn.apig.create_gateway(**attrs)

examples/apig/delete_env.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python3
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
"""
14+
Delete env from gateway
15+
"""
16+
import openstack
17+
18+
openstack.enable_logging(True)
19+
conn = openstack.connect(cloud='otc')
20+
conn.apig.delete_environment(gateway="gateway_id",
21+
environment="env_id",)

examples/apig/list_envs.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python3
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
"""
14+
List envs of specific gateway
15+
"""
16+
import openstack
17+
18+
openstack.enable_logging(True)
19+
conn = openstack.connect(cloud='otc')
20+
environments = list(conn.apig.environments(gateway="gateway_id"))

examples/apig/update_env.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python3
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
"""
14+
Update env in gateway
15+
"""
16+
import openstack
17+
18+
openstack.enable_logging(True)
19+
conn = openstack.connect(cloud='otc')
20+
attrs = {
21+
"name": "DEV",
22+
"remark": "Development environment"
23+
}
24+
environment = conn.apig.update_environment(environment="env_id",
25+
gateway="gateway_id",
26+
**attrs)

0 commit comments

Comments
 (0)