Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

523 api group management for apig #524

Merged
merged 2 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .stestr.blacklist.functional
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ otcextensions.tests.functional.sdk.function_graph.v2.test_dependency*
otcextensions.tests.functional.sdk.function_graph.v2.test_log*
otcextensions.tests.functional.sdk.function_graph.v2.test_template*
otcextensions.tests.functional.sdk.function_graph.v2.test_import_export*
otcextensions.tests.functional.sdk.apig.v2.test_gateway
otcextensions.tests.functional.sdk.apig.v2.test_environment
otcextensions.tests.functional.sdk.apig.v2*
56 changes: 56 additions & 0 deletions doc/source/sdk/guides/apig.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,59 @@ with a specific API Gateway.

.. literalinclude:: ../examples/apig/list_envs.py
:lines: 16-20

Api Group
_________

Create Api Group
^^^^^^^^^^^^^^^^

This example demonstrates how to create a new API group in the API Gateway.

.. literalinclude:: ../examples/apig/create_api_group.py
:lines: 16-25

Update Api Group
^^^^^^^^^^^^^^^^

This example demonstrates how to update an existing API group
in the API Gateway.

.. literalinclude:: ../examples/apig/update_api_group.py
:lines: 16-27

Delete Api Group
^^^^^^^^^^^^^^^^

This example demonstrates how to delete an existing API group from
the API Gateway.

.. literalinclude:: ../examples/apig/delete_api_group.py
:lines: 16-21

List Api Groups
^^^^^^^^^^^^^^^

This example demonstrates how to list all API groups associated
with a specific API Gateway.

.. literalinclude:: ../examples/apig/list_api_groups.py
:lines: 16-20

Get Api Group
^^^^^^^^^^^^^

This example demonstrates how to retrieve details of a specific
API group from the API Gateway.

.. literalinclude:: ../examples/apig/get_api_group.py
:lines: 16-21

Verify Api Group Name
^^^^^^^^^^^^^^^^^^^^^

This example demonstrates how to verify whether a given API group
name is available in the API Gateway.

.. literalinclude:: ../examples/apig/verify_api_group_name.py
:lines: 16-23
7 changes: 7 additions & 0 deletions doc/source/sdk/proxies/apig.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ Environment Operations
:noindex:
:members: create_environment, update_environment, environments,
delete_environment

Api Group Operations
^^^^^^^^^^^^^^^^^^^^
.. autoclass:: otcextensions.sdk.apig.v2._proxy.Proxy
:noindex:
:members: create_api_group, update_api_group, delete_api_group,
get_api_group, api_groups, verify_api_group_name
1 change: 1 addition & 0 deletions doc/source/sdk/resources/apig/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ ApiGateway Resources
v2/gateway
v2/az
v2/env
v2/group
13 changes: 13 additions & 0 deletions doc/source/sdk/resources/apig/v2/group.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
otcextensions.sdk.apig.v2.apigroup
==================================

.. automodule:: otcextensions.sdk.apig.v2.apigroup

The ApiGroup Class
------------------

The ``ApiGroup`` class inherits from
:class:`~otcextensions.sdk.sdk_resource.Resource`.

.. autoclass:: otcextensions.sdk.apig.v2.apigroup.ApiGroup
:members:
25 changes: 25 additions & 0 deletions examples/apig/create_api_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
# 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.
"""
Create API group for gateway
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"name": "api_group_001",
"remark": "API group 1"
}
created = conn.apig.create_api_group(gateway="gateway_id",
**attrs)
21 changes: 21 additions & 0 deletions examples/apig/delete_api_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
# 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.
"""
Delete API group from gateway
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.apig.delete_api_group(gateway='gateway_id',
api_group='api_group_id')
21 changes: 21 additions & 0 deletions examples/apig/get_api_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
# 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.
"""
Get API group for gateway
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
found = conn.apig.get_api_group(gateway='gateway_id',
api_group='api_group_id')
20 changes: 20 additions & 0 deletions examples/apig/list_api_groups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python3
# 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.
"""
Get list of API groups for gateway
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
groups = list(conn.apig.api_groups(gateway="gateway_id"))
27 changes: 27 additions & 0 deletions examples/apig/update_api_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3
# 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.
"""
Update API group for gateway
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
'name': 'name',
'remark': 'new_remark'
}
updated = conn.apig.update_api_group(
gateway='gateway_id',
api_group='api_group_id',
**attrs)
23 changes: 23 additions & 0 deletions examples/apig/verify_api_group_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
# 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.
"""
Verify name of API group for gateway
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"group_name": "api_group_002"
}
conn.apig.verify_api_group_name(gateway="gateway_id", **attrs)
89 changes: 89 additions & 0 deletions otcextensions/sdk/apig/v2/_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from otcextensions.sdk.apig.v2 import gateway as _gateway
from otcextensions.sdk.apig.v2 import az as _az
from otcextensions.sdk.apig.v2 import apienvironment as _api_environment
from otcextensions.sdk.apig.v2 import apigroup as _api_group


class Proxy(proxy.Proxy):
Expand Down Expand Up @@ -330,3 +331,91 @@ def environments(self, gateway, **attrs):
paginated=False,
gateway_id=gateway.id,
**attrs)

def create_api_group(self, gateway, **attrs):
"""Create a new API group for a specific API Gateway.

This method creates an API group associated with the given API Gateway.

:param gateway: The ID of the gateway or an instance of
:class:`~otcextensions.sdk.apig.v2.gateway.Gateway`
:param attrs: Additional attributes for creating the API group.

:returns: An instance of
:class:`~otcextensions.sdk.apig.v2.api_group.ApiGroup`
"""
gateway = self._get_resource(_gateway.Gateway, gateway)
return self._create(_api_group.ApiGroup,
gateway_id=gateway.id,
**attrs)

def update_api_group(self, gateway, api_group, **attrs):
"""Update an existing API group for a specific API Gateway.

This method updates the attributes of an API group associated with
the given API Gateway.

:param gateway: The ID of the gateway or an instance of
:class:`~otcextensions.sdk.apig.v2.gateway.Gateway`
:param api_group: The ID of the API group or an instance of
:class:`~otcextensions.sdk.apig.v2.api_group.ApiGroup`
:param attrs: Additional attributes for updating the API group.

:returns: The updated instance of
:class:`~otcextensions.sdk.apig.v2.api_group.ApiGroup`
"""
gateway = self._get_resource(_gateway.Gateway, gateway)
api_group = self._get_resource(_api_group.ApiGroup, api_group)
return api_group._update_group(self, gateway=gateway, **attrs)

def delete_api_group(self, gateway, api_group, **attrs):
"""Delete an API group from a specific API Gateway.

This method deletes the specified API group associated with
the given API Gateway.

:param gateway: The ID of the gateway or an instance of
:class:`~otcextensions.sdk.apig.v2.gateway.Gateway`
:param api_group: The ID of the API group or an instance of
:class:`~otcextensions.sdk.apig.v2.api_group.ApiGroup`
:param attrs: Additional parameters for deleting the API group.

:returns: None
"""
gateway = self._get_resource(_gateway.Gateway, gateway)
api_group = self._get_resource(_api_group.ApiGroup, api_group)
return self._delete(_api_group.ApiGroup,
api_group,
gateway_id=gateway.id,
**attrs)

def get_api_group(self, gateway, api_group):
"""Retrieve details of a specific API group.

This method retrieves the details of an API group associated
with the given API Gateway.

:param gateway: The ID of the gateway or an instance of
:class:`~otcextensions.sdk.apig.v2.gateway.Gateway`
:param api_group: The ID of the API group or an instance of
:class:`~otcextensions.sdk.apig.v2.api_group.ApiGroup`

:returns: An instance of
:class:`~otcextensions.sdk.apig.v2.api_group.ApiGroup`
"""
gateway = self._get_resource(_gateway.Gateway, gateway)
return self._get(_api_group.ApiGroup,
api_group,
gateway_id=gateway.id)

def api_groups(self, gateway, **attrs):
gateway = self._get_resource(_gateway.Gateway, gateway)
return self._list(_api_group.ApiGroup,
paginated=False,
gateway_id=gateway.id,
**attrs)

def verify_api_group_name(self, gateway, **attrs):
gateway = self._get_resource(_gateway.Gateway, gateway)
api_group = _api_group.ApiGroup()
return api_group._verify_name(self, gateway=gateway, **attrs)
Loading