Skip to content

Commit 7b5d280

Browse files
authored
Fix allow patch error (#661)
Fix allow patch error In this PR I fixed the following type of errror: allow_patch = True requires commit_method = 'PATCH', but the default is PUT. Since allow_commit = True already handles PUT updates, I removed the conflicting allow_patch = True. Reviewed-by: Anton Sidelnikov
1 parent feda2e1 commit 7b5d280

33 files changed

Lines changed: 302 additions & 133 deletions

File tree

doc/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
pygments_style = "native"
8080

8181
autodoc_member_order = "bysource"
82+
autodoc_class_signature = "separated"
8283

8384
# Locations to exclude when looking for source files.
8485
exclude_patterns = []

doc/source/sdk/guides/privatenat.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,12 @@ This interface is used to assign a transit IP address.
199199

200200
.. literalinclude:: ../examples/natv3/create_private_transit_ip.py
201201
:lines: 16-28
202+
203+
Delete Private Transit IP Address
204+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
205+
206+
This interface is used to delete a transit IP address.
207+
:class:`~otcextensions.sdk.natv3.v3.transit_ip.PrivateTransitIp`.
208+
209+
.. literalinclude:: ../examples/natv3/delete_private_transit_ip.py
210+
:lines: 16-22

doc/source/sdk/guides/vpcep.rst

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ List Services
2222

2323
This interface is used to query an VPCEP services list and to filter
2424
the output with query parameters.
25-
:class:`~otcextensions.sdk.vpcep.v2.service.Service`.
25+
:class:`~otcextensions.sdk.vpcep.v1.service.Service`.
2626

2727
.. literalinclude:: ../examples/vpcep/list_endpoints.py
2828
:lines: 14-20
@@ -32,7 +32,7 @@ Create Service
3232

3333
This interface is used to create a VPCEP service with
3434
parameters.
35-
:class:`~otcextensions.sdk.vpcep.v2.service.Service`.
35+
:class:`~otcextensions.sdk.vpcep.v1.service.Service`.
3636

3737
.. literalinclude:: ../examples/vpcep/create_service.py
3838
:lines: 14-30
@@ -42,7 +42,7 @@ Get Service
4242

4343
This interface is used to get a VPCEP service by ID
4444
or an instance of class.
45-
:class:`~otcextensions.sdk.vpcep.v2.service.Service`.
45+
:class:`~otcextensions.sdk.vpcep.v1.service.Service`.
4646

4747
.. literalinclude:: ../examples/vpcep/get_service.py
4848
:lines: 14-21
@@ -52,7 +52,7 @@ Find Service
5252

5353
This interface is used to find a VPCEP service by ID
5454
or name.
55-
:class:`~otcextensions.sdk.vpcep.v2.service.Service`.
55+
:class:`~otcextensions.sdk.vpcep.v1.service.Service`.
5656

5757
.. literalinclude:: ../examples/vpcep/find_service.py
5858
:lines: 14-21
@@ -62,7 +62,7 @@ Delete Service
6262

6363
This interface is used to delete a VPCEP service by ID
6464
or an instance of class
65-
:class:`~otcextensions.sdk.vpcep.v2.service.Service`.
65+
:class:`~otcextensions.sdk.vpcep.v1.service.Service`.
6666

6767
.. literalinclude:: ../examples/vpcep/delete_service.py
6868
:lines: 14-20
@@ -72,7 +72,7 @@ List Service Whitelist
7272

7373
This interface is used to query an VPCEP service whitelist and to filter
7474
the output with query parameters.
75-
:class:`~otcextensions.sdk.vpcep.v2.whitelist.Whitelist`.
75+
:class:`~otcextensions.sdk.vpcep.v1.whitelist.Whitelist`.
7676

7777
.. literalinclude:: ../examples/vpcep/list_service_whitelist.py
7878
:lines: 14-22
@@ -81,7 +81,7 @@ Manage Service Whitelist
8181
^^^^^^^^^^^^^^^^^^^^^^^^
8282

8383
This interface is used to manage a VPCEP service whitelist.
84-
:class:`~otcextensions.sdk.vpcep.v2.whitelist.Whitelist`.
84+
:class:`~otcextensions.sdk.vpcep.v1.whitelist.Whitelist`.
8585

8686
.. literalinclude:: ../examples/vpcep/manage_service_whitelist.py
8787
:lines: 14-26
@@ -91,7 +91,7 @@ List Service Connections
9191

9292
This interface is used to query an VPCEP service connections and to filter
9393
the output with query parameters.
94-
:class:`~otcextensions.sdk.vpcep.v2.connection.Connection`.
94+
:class:`~otcextensions.sdk.vpcep.v1.connection.Connection`.
9595

9696
.. literalinclude:: ../examples/vpcep/list_service_connections.py
9797
:lines: 14-22
@@ -100,7 +100,7 @@ Manage Service Connections
100100
^^^^^^^^^^^^^^^^^^^^^^^^^^
101101

102102
This interface is used to manage a VPCEP service connections.
103-
:class:`~otcextensions.sdk.vpcep.v2.connection.Connection`.
103+
:class:`~otcextensions.sdk.vpcep.v1.connection.Connection`.
104104

105105
.. literalinclude:: ../examples/vpcep/manage_service_connections.py
106106
:lines: 14-25
@@ -116,7 +116,7 @@ List Endpoints
116116

117117
This interface is used to query an VPC endpoint list and to filter
118118
the output with query parameters.
119-
:class:`~otcextensions.sdk.vpcep.v2.endpoint.Endpoint`.
119+
:class:`~otcextensions.sdk.vpcep.v1.endpoint.Endpoint`.
120120

121121
.. literalinclude:: ../examples/vpcep/list_endpoints.py
122122
:lines: 14-20
@@ -126,7 +126,7 @@ Create Endpoint
126126

127127
This interface is used to create a VPC endpoint with
128128
parameters.
129-
:class:`~otcextensions.sdk.vpcep.v2.endpoint.Endpoint`.
129+
:class:`~otcextensions.sdk.vpcep.v1.endpoint.Endpoint`.
130130

131131
.. literalinclude:: ../examples/vpcep/create_endpoint.py
132132
:lines: 14-28
@@ -136,7 +136,7 @@ Get Endpoint
136136

137137
This interface is used to get a VPC endpoint by ID
138138
or an instance of class
139-
:class:`~otcextensions.sdk.vpcep.v2.endpoint.Endpoint`.
139+
:class:`~otcextensions.sdk.vpcep.v1.endpoint.Endpoint`.
140140

141141
.. literalinclude:: ../examples/vpcep/get_endpoint.py
142142
:lines: 14-21
@@ -146,7 +146,7 @@ Delete Endpoint
146146

147147
This interface is used to delete a VPC endpoint by ID
148148
or an instance of class
149-
:class:`~otcextensions.sdk.vpcep.v2.endpoint.Endpoint`.
149+
:class:`~otcextensions.sdk.vpcep.v1.endpoint.Endpoint`.
150150

151151
.. literalinclude:: ../examples/vpcep/delete_endpoint.py
152152
:lines: 14-20
@@ -159,8 +159,7 @@ List Resource Quota
159159

160160
This interface is used to query quota of vpc endpoint and endpoint_service
161161
on a specific tenant.
162-
:class:`~otcextensions.sdk.vpcep.v2.quota.Quota`.
162+
:class:`~otcextensions.sdk.vpcep.v1.quota.Quota`.
163163

164164
.. literalinclude:: ../examples/vpcep/list_resource_quota.py
165165
:lines: 14-20
166-

doc/source/sdk/proxies/privatenat.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ Private NAT Gateway Operations
1616

1717
.. autoclass:: otcextensions.sdk.natv3.v3._proxy.Proxy
1818
:noindex:
19-
:members: private_nat_gateways, get_private_nat_gateway, private_dnat_rules, create_private_dnat_rule, update_private_dnat_rule, delete_private_dnat_rule, private_snat_rules, create_private_snat_rule, update_private_snat_rule, delete_private_snat_rule, private_transit_ips, get_private_transit_ip, create_private_transit_ip
19+
:members: private_nat_gateways, get_private_nat_gateway, private_dnat_rules, create_private_dnat_rule,
20+
update_private_dnat_rule, delete_private_dnat_rule, private_snat_rules, create_private_snat_rule,
21+
update_private_snat_rule, delete_private_snat_rule, private_transit_ips, get_private_transit_ip,
22+
create_private_transit_ip, delete_private_transit_ip

doc/source/sdk/resources/vpcep/v1/connection.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
otcextensions.sdk.vpecp.v1.connection
1+
otcextensions.sdk.vpcep.v1.connection
22
=====================================
33

44
.. automodule:: otcextensions.sdk.vpcep.v1.connection
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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 a private transit IP address.
15+
"""
16+
17+
import openstack
18+
19+
openstack.enable_logging(True)
20+
conn = openstack.connect(cloud="otc")
21+
22+
conn.natv3.delete_private_transit_ip("a2845109-3b2f-4627-b08f-09a726c0a6e7")

otcextensions/osclient/privatenat/v3/transit_ip.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import logging
1616

17+
from osc_lib import exceptions
1718
from osc_lib import utils
1819
from osc_lib.command import command
1920

@@ -262,3 +263,27 @@ def take_action(self, parsed_args):
262263
data = utils.get_item_properties(obj, columns)
263264

264265
return display_columns, data
266+
267+
268+
class DeletePrivateTransitIp(command.Command):
269+
_description = _("Delete a private transit IP address.")
270+
271+
def get_parser(self, prog_name):
272+
parser = super(DeletePrivateTransitIp, self).get_parser(prog_name)
273+
parser.add_argument(
274+
"transit_ip",
275+
metavar="<transit_ip>",
276+
help=_("Specifies the transit IP address ID."),
277+
)
278+
return parser
279+
280+
def take_action(self, parsed_args):
281+
client = self.app.client_manager.privatenat
282+
283+
try:
284+
client.delete_private_transit_ip(parsed_args.transit_ip)
285+
except Exception as e:
286+
msg = _(
287+
"Failed to delete private transit IP address with ID '%(id)s': %(e)s"
288+
) % {"id": parsed_args.transit_ip, "e": e}
289+
raise exceptions.CommandError(msg)

otcextensions/sdk/apig/v2/custom_authorizer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class CustomAuthorizer(resource.Resource):
2424
allow_list = True
2525
allow_fetch = True
2626
allow_create = True
27-
allow_patch = True
2827
allow_delete = True
2928
allow_commit = True
3029

otcextensions/sdk/cce/v3/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def _translate_response(
123123

124124
self._body.attributes.update(body_attrs)
125125
self._body.clean()
126-
if self.commit_jsonpatch or self.allow_patch:
126+
if self.allow_patch:
127127
# We need the original body to compare against
128128
self._original_body = body_attrs.copy()
129129
except ValueError:

otcextensions/sdk/css/v1/cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def _translate_response(
439439

440440
self._body.attributes.update(body_attrs)
441441
self._body.clean()
442-
if self.commit_jsonpatch or self.allow_patch:
442+
if self.allow_patch:
443443
# We need the original body to compare against
444444
self._original_body = body_attrs.copy()
445445
except ValueError:

0 commit comments

Comments
 (0)