Skip to content

Commit 995325f

Browse files
committed
feat(ssl): tests implemented
1 parent 084d856 commit 995325f

23 files changed

+971
-5
lines changed

doc/source/sdk/guides/apig.rst

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,3 +1370,95 @@ API Gateway.
13701370

13711371
.. literalinclude:: ../examples/apig/list_tags.py
13721372
:lines: 16-21
1373+
1374+
SSL Certificate
1375+
---------------
1376+
1377+
Querying SSL Certificates
1378+
^^^^^^^^^^^^^^^^^^^^^^^^^^
1379+
1380+
This example demonstrates how to list SSL certificates configured
1381+
in the API Gateway.
1382+
1383+
.. literalinclude:: ../examples/apig/list_ssl_cert.py
1384+
:lines: 16-26
1385+
1386+
Creating an SSL Certificate
1387+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1388+
1389+
This example demonstrates how to create a new SSL certificate.
1390+
1391+
.. literalinclude:: ../examples/apig/create_ssl_cert.py
1392+
:lines: 16-30
1393+
1394+
Binding a Domain Name with SSL Certificates
1395+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1396+
1397+
This example demonstrates how to bind one or more SSL certificates
1398+
to a domain name.
1399+
1400+
.. literalinclude:: ../examples/apig/bind_domain_to_cert.py
1401+
:lines: 16-36
1402+
1403+
Unbinding a Domain Name's SSL Certificates
1404+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1405+
1406+
This example demonstrates how to unbind SSL certificates from a
1407+
domain name.
1408+
1409+
.. literalinclude:: ../examples/apig/unbind_domain_from_cert.py
1410+
:lines: 16-28
1411+
1412+
Querying Certificate Details
1413+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414+
1415+
This example demonstrates how to retrieve details of a specific
1416+
SSL certificate.
1417+
1418+
.. literalinclude:: ../examples/apig/get_ssl_cert.py
1419+
:lines: 16-20
1420+
1421+
Deleting an SSL Certificate
1422+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1423+
1424+
This example demonstrates how to delete an SSL certificate
1425+
from the API Gateway.
1426+
1427+
.. literalinclude:: ../examples/apig/delete_ssl_certificate.py
1428+
:lines: 16-20
1429+
1430+
Modifying an SSL Certificate
1431+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1432+
1433+
This example demonstrates how to update an existing SSL
1434+
certificate's metadata or contents.
1435+
1436+
.. literalinclude:: ../examples/apig/update_ssl_cert.py
1437+
:lines: 16-31
1438+
1439+
Binding an SSL Certificate to a Domain Name
1440+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1441+
1442+
This example demonstrates how to bind a specific SSL certificate
1443+
to a domain name.
1444+
1445+
.. literalinclude:: ../examples/apig/bind_certificates_for_domain.py
1446+
:lines: 16-29
1447+
1448+
Unbinding an SSL Certificate from a Domain Name
1449+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1450+
1451+
This example demonstrates how to unbind a specific SSL certificate
1452+
from a domain name.
1453+
1454+
.. literalinclude:: ../examples/apig/unbind_cert_from_domain.py
1455+
:lines: 16-29
1456+
1457+
Querying Domain Names of an SSL Certificate
1458+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1459+
1460+
This example demonstrates how to list all domain names associated
1461+
with a given SSL certificate.
1462+
1463+
.. literalinclude:: ../examples/apig/list_domain_for_cert.py
1464+
:lines: 16-22

doc/source/sdk/proxies/apig.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,12 @@ Tag Operations
192192
.. autoclass:: otcextensions.sdk.apig.v2._proxy.Proxy
193193
:noindex:
194194
:members: tags
195+
196+
SSL Certificate Operations
197+
^^^^^^^^^^^^^^^^^^^^^^^^^^
198+
.. autoclass:: otcextensions.sdk.apig.v2._proxy.Proxy
199+
:noindex:
200+
:members: create_ssl_certificate, get_ssl_certificate, ssl_certificates,
201+
update_ssl_certificate, delete_ssl_certificate, bind_domain_to_certificate,
202+
unbind_domain_from_certificate, domains_for_certificate,
203+
bind_ssl_certificates_for_domain, unbind_ssl_certificates_for_domain

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ ApiGateway Resources
3434
v2/group_response
3535
v2/error_response
3636
v2/tag
37+
v2/ssl_certificate
38+
v2/ssl_domain
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
otcextensions.sdk.apig.v2.ssl_certificate
2+
=========================================
3+
4+
.. automodule:: otcextensions.sdk.apig.v2.ssl_certificate
5+
6+
The SslCertificate Class
7+
------------------------
8+
The ``SslCertificate`` class inherits from
9+
:class:`~otcextensions.sdk.sdk_resource.Resource`.
10+
11+
.. autoclass:: otcextensions.sdk.apig.v2.api_call.SslCertificate
12+
:members:
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
otcextensions.sdk.apig.v2.ssl_domain
2+
====================================
3+
4+
.. automodule:: otcextensions.sdk.apig.v2.ssl_domain
5+
6+
The SslDomain Class
7+
-------------------
8+
The ``SslDomain`` class inherits from
9+
:class:`~otcextensions.sdk.sdk_resource.Resource`.
10+
11+
.. autoclass:: otcextensions.sdk.apig.v2.api_call.SslDomain
12+
:members:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
Bind SSL certificate to domain
15+
"""
16+
import openstack
17+
18+
openstack.enable_logging(True)
19+
conn = openstack.connect(cloud='otc')
20+
attrs = {
21+
"domains": [{
22+
"domain": "test-domain-ssl-cert.com",
23+
"instance_ids": ["gateway_id"]
24+
}]
25+
}
26+
conn.apig.bind_ssl_certificates_for_domain(
27+
ssl_certificate="cert_id",
28+
**attrs
29+
)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
Bind domain to SSL certificate
15+
"""
16+
import openstack
17+
18+
openstack.enable_logging(True)
19+
conn = openstack.connect(cloud='otc')
20+
attrs = {
21+
"url_domain": "test-domain-ssl-cert.com"
22+
}
23+
domain = conn.apig.bind_domain_name(
24+
gateway="gateway_id",
25+
group="group_id",
26+
**attrs
27+
)
28+
attrs = {
29+
"certificate_ids": ["cert_id"]
30+
}
31+
conn.apig.bind_domain_to_certificate(
32+
gateway="gateway_id",
33+
group="group_id",
34+
domain=domain.id,
35+
**attrs
36+
)

examples/apig/create_ssl_cert.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 SSL certificate
15+
"""
16+
import openstack
17+
from pathlib import Path
18+
19+
openstack.enable_logging(True)
20+
conn = openstack.connect(cloud='otc')
21+
attrs = {
22+
"name": "cert_demo",
23+
"cert_content": Path("/mnt/c/Users/sand1/fullchain.pem")
24+
.read_text().replace('\r\n', '\n'),
25+
"private_key": Path("/mnt/c/Users/sand1/privkey.pem")
26+
.read_text().replace('\r\n', '\n'),
27+
"type": "instance",
28+
"instance_id": "gateway_id"
29+
}
30+
cert = conn.apig.create_ssl_certificate(**attrs)

examples/apig/delete_ssl_cert.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+
Delete SSL certificate
15+
"""
16+
import openstack
17+
18+
openstack.enable_logging(True)
19+
conn = openstack.connect(cloud='otc')
20+
conn.apig.self.delete_ssl_certificate(ssl_certificate="cert_id")

examples/apig/get_ssl_cert.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+
Get SSL certificate
15+
"""
16+
import openstack
17+
18+
openstack.enable_logging(True)
19+
conn = openstack.connect(cloud='otc')
20+
cert = conn.apig.self.get_ssl_certificate(ssl_certificate="cert_id")

0 commit comments

Comments
 (0)