Skip to content

Commit caed6bb

Browse files
authored
feat: upgrade openapi-generator to v7.12.0 (#46)
The effects of this upgrade are: - Clients will throw custom exceptions for HTTP 409 and HTTP 422 responses - Clients can accept a `ca_cert_data` parameter - List query parameters are encoded - Fixed an issue with incorrect imports in model code that impacted the `BulkPortRequest` model The new version of openapi-generator also introduces a prefix on enum values. To minimize the impact of this upgrade, the `removeEnumValuePrefix` has been set to `true` in the generator config file to disable the new generator behavior.
2 parents a2c7618 + 79810e4 commit caed6bb

15 files changed

Lines changed: 67 additions & 16 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GIT_REPO=equinix-sdk-python
88
PACKAGE_VERSION=$(shell cat version)
99
USER_AGENT=${GIT_REPO}/${PACKAGE_VERSION}
1010

11-
OPENAPI_IMAGE_TAG=v7.10.0
11+
OPENAPI_IMAGE_TAG=v7.12.0
1212
OPENAPI_IMAGE=openapitools/openapi-generator-cli:${OPENAPI_IMAGE_TAG}
1313
CRI=docker # nerdctl
1414
OPENAPI_GENERATOR=${CRI} run --rm -u ${CURRENT_UID}:${CURRENT_GID} -v $(CURDIR):/workdir -w /workdir ${OPENAPI_IMAGE}

config/openapi-generator.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"globalProperties": {
88
"modelTests": false,
99
"apiTests": false
10-
}
10+
},
11+
"removeEnumValuePrefix": true
1112
}

equinix/services/fabricv4/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def parameters_to_url_query(self, params, collection_formats):
513513
if k in collection_formats:
514514
collection_format = collection_formats[k]
515515
if collection_format == 'multi':
516-
new_params.extend((k, str(value)) for value in v)
516+
new_params.extend((k, quote(str(value))) for value in v)
517517
else:
518518
if collection_format == 'ssv':
519519
delimiter = ' '

equinix/services/fabricv4/configuration.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from logging import FileHandler
1515
import multiprocessing
1616
import sys
17-
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict
17+
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
1818
from typing_extensions import NotRequired, Self
1919

2020
import urllib3
@@ -157,6 +157,8 @@ class Configuration:
157157
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
158158
in PEM format.
159159
:param retries: Number of retries for API requests.
160+
:param ca_cert_data: verify the peer using concatenated CA certificate data
161+
in PEM (str) or DER (bytes) format.
160162
161163
:Example:
162164
"""
@@ -171,13 +173,14 @@ def __init__(
171173
username: Optional[str]=None,
172174
password: Optional[str]=None,
173175
access_token: Optional[str]=None,
174-
server_index: Optional[int]=None,
176+
server_index: Optional[int]=None,
175177
server_variables: Optional[ServerVariablesT]=None,
176178
server_operation_index: Optional[Dict[int, int]]=None,
177179
server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
178180
ignore_operation_servers: bool=False,
179181
ssl_ca_cert: Optional[str]=None,
180182
retries: Optional[int] = None,
183+
ca_cert_data: Optional[Union[str, bytes]] = None,
181184
*,
182185
debug: Optional[bool] = None,
183186
) -> None:
@@ -255,6 +258,10 @@ def __init__(
255258
self.ssl_ca_cert = ssl_ca_cert
256259
"""Set this to customize the certificate file to verify the peer.
257260
"""
261+
self.ca_cert_data = ca_cert_data
262+
"""Set this to verify the peer using PEM (str) or DER (bytes)
263+
certificate data.
264+
"""
258265
self.cert_file = None
259266
"""client certificate file
260267
"""

equinix/services/fabricv4/docs/BulkPortRequest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Create bulk port request
66

77
Name | Type | Description | Notes
88
------------ | ------------- | ------------- | -------------
9-
**data** | [**List[PortRequest]**](Port.md) | | [optional]
9+
**data** | [**List[PortRequest]**](PortRequest.md) | | [optional]
1010

1111
## Example
1212

equinix/services/fabricv4/docs/PortsApi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Method | HTTP request | Description
2020
2121
Add to Lag
2222

23-
Add Physical Ports to Virtual Port.<font color=\"red\"> <sup color='red'>Preview</sup></font>
23+
Add Physical Ports to Virtual Port.<font color="red"> <sup color='red'>Preview</sup></font>
2424

2525
### Example
2626

@@ -104,7 +104,7 @@ Name | Type | Description | Notes
104104
105105
Create Port
106106

107-
Create Port creates Equinix Fabric? Port.<font color=\"red\"> <sup color='red'>Preview</sup></font>
107+
Create Port creates Equinix Fabric? Port.<font color="red"> <sup color='red'>Preview</sup></font>
108108

109109
### Example
110110

equinix/services/fabricv4/exceptions.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ def from_response(
146146
if http_resp.status == 404:
147147
raise NotFoundException(http_resp=http_resp, body=body, data=data)
148148

149+
# Added new conditions for 409 and 422
150+
if http_resp.status == 409:
151+
raise ConflictException(http_resp=http_resp, body=body, data=data)
152+
153+
if http_resp.status == 422:
154+
raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
155+
149156
if 500 <= http_resp.status <= 599:
150157
raise ServiceException(http_resp=http_resp, body=body, data=data)
151158
raise ApiException(http_resp=http_resp, body=body, data=data)
@@ -184,6 +191,16 @@ class ServiceException(ApiException):
184191
pass
185192

186193

194+
class ConflictException(ApiException):
195+
"""Exception for HTTP 409 Conflict."""
196+
pass
197+
198+
199+
class UnprocessableEntityException(ApiException):
200+
"""Exception for HTTP 422 Unprocessable Entity."""
201+
pass
202+
203+
187204
def render_path(path_to_item):
188205
"""Returns a string representation of a path"""
189206
result = ""

equinix/services/fabricv4/models/bulk_port_request.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
from pydantic import BaseModel, ConfigDict
1717
from typing import Any, ClassVar, Dict, List, Optional
18-
from equinix.services.fabricv4.models.port import Port
18+
from equinix.services.fabricv4.models.port_request import PortRequest
1919
from typing import Optional, Set
2020
from typing_extensions import Self
2121

2222
class BulkPortRequest(BaseModel):
2323
"""
2424
Create bulk port request
2525
""" # noqa: E501
26-
data: Optional[List[Port]] = None
26+
data: Optional[List[PortRequest]] = None
2727
additional_properties: Dict[str, Any] = {}
2828
__properties: ClassVar[List[str]] = ["data"]
2929

@@ -92,7 +92,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
9292
return cls.model_validate(obj)
9393

9494
_obj = cls.model_validate({
95-
"data": [Port.from_dict(_item) for _item in obj["data"]] if obj.get("data") is not None else None
95+
"data": [PortRequest.from_dict(_item) for _item in obj["data"]] if obj.get("data") is not None else None
9696
})
9797
# store additional fields in additional_properties
9898
for _key in obj.keys():

equinix/services/fabricv4/rest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def __init__(self, configuration) -> None:
7272
"ca_certs": configuration.ssl_ca_cert,
7373
"cert_file": configuration.cert_file,
7474
"key_file": configuration.key_file,
75+
"ca_cert_data": configuration.ca_cert_data,
7576
}
7677
if configuration.assert_hostname is not None:
7778
pool_args['assert_hostname'] = (

equinix/services/fabricv4_README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The `equinix.services.fabricv4` package is automatically generated by the [OpenA
55

66
- API version: 4.20
77
- Package version: 0.8.0
8-
- Generator version: 7.10.0
8+
- Generator version: 7.12.0
99
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
1010
For more information, please visit [https://docs.equinix.com/api-support.htm](https://docs.equinix.com/api-support.htm)
1111

0 commit comments

Comments
 (0)