Skip to content

Commit 04ab476

Browse files
Merge pull request #15 from opalsecurity/andrewsy-docs-update
[COR-1980] Update openapi generator version in README
2 parents ab6775b + ab27090 commit 04ab476

File tree

4 files changed

+174
-41
lines changed

4 files changed

+174
-41
lines changed

.openapi-generator/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.9.0
1+
7.10.0

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ This Python package is automatically generated by the [OpenAPI Generator](https:
55

66
- API version: 1.0
77
- Package version: 1.0.0
8-
- Generator version: 7.9.0
8+
- Generator version: 7.10.0
99
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
1010
For more information, please visit [https://www.opal.dev/](https://www.opal.dev/)
1111

1212
## Requirements.
1313

14-
Python 3.7+
14+
Python 3.8+
1515

1616
## Installation & Usage
1717
### pip install

opal/configuration.py

Lines changed: 153 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,124 @@
1414

1515

1616
import copy
17+
import http.client as httplib
1718
import logging
1819
from logging import FileHandler
1920
import multiprocessing
2021
import sys
21-
from typing import Optional
22+
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict
23+
from typing_extensions import NotRequired, Self
24+
2225
import urllib3
2326

24-
import http.client as httplib
2527

2628
JSON_SCHEMA_VALIDATION_KEYWORDS = {
2729
'multipleOf', 'maximum', 'exclusiveMaximum',
2830
'minimum', 'exclusiveMinimum', 'maxLength',
2931
'minLength', 'pattern', 'maxItems', 'minItems'
3032
}
3133

34+
ServerVariablesT = Dict[str, str]
35+
36+
GenericAuthSetting = TypedDict(
37+
"GenericAuthSetting",
38+
{
39+
"type": str,
40+
"in": str,
41+
"key": str,
42+
"value": str,
43+
},
44+
)
45+
46+
47+
OAuth2AuthSetting = TypedDict(
48+
"OAuth2AuthSetting",
49+
{
50+
"type": Literal["oauth2"],
51+
"in": Literal["header"],
52+
"key": Literal["Authorization"],
53+
"value": str,
54+
},
55+
)
56+
57+
58+
APIKeyAuthSetting = TypedDict(
59+
"APIKeyAuthSetting",
60+
{
61+
"type": Literal["api_key"],
62+
"in": str,
63+
"key": str,
64+
"value": Optional[str],
65+
},
66+
)
67+
68+
69+
BasicAuthSetting = TypedDict(
70+
"BasicAuthSetting",
71+
{
72+
"type": Literal["basic"],
73+
"in": Literal["header"],
74+
"key": Literal["Authorization"],
75+
"value": Optional[str],
76+
},
77+
)
78+
79+
80+
BearerFormatAuthSetting = TypedDict(
81+
"BearerFormatAuthSetting",
82+
{
83+
"type": Literal["bearer"],
84+
"in": Literal["header"],
85+
"format": Literal["JWT"],
86+
"key": Literal["Authorization"],
87+
"value": str,
88+
},
89+
)
90+
91+
92+
BearerAuthSetting = TypedDict(
93+
"BearerAuthSetting",
94+
{
95+
"type": Literal["bearer"],
96+
"in": Literal["header"],
97+
"key": Literal["Authorization"],
98+
"value": str,
99+
},
100+
)
101+
102+
103+
HTTPSignatureAuthSetting = TypedDict(
104+
"HTTPSignatureAuthSetting",
105+
{
106+
"type": Literal["http-signature"],
107+
"in": Literal["header"],
108+
"key": Literal["Authorization"],
109+
"value": None,
110+
},
111+
)
112+
113+
114+
AuthSettings = TypedDict(
115+
"AuthSettings",
116+
{
117+
"BearerAuth": BearerAuthSetting,
118+
},
119+
total=False,
120+
)
121+
122+
123+
class HostSettingVariable(TypedDict):
124+
description: str
125+
default_value: str
126+
enum_values: List[str]
127+
128+
129+
class HostSetting(TypedDict):
130+
url: str
131+
description: str
132+
variables: NotRequired[Dict[str, HostSettingVariable]]
133+
134+
32135
class Configuration:
33136
"""This class contains various settings of the API client.
34137
@@ -63,20 +166,26 @@ class Configuration:
63166
:Example:
64167
"""
65168

66-
_default = None
67-
68-
def __init__(self, host=None,
69-
api_key=None, api_key_prefix=None,
70-
username=None, password=None,
71-
access_token=None,
72-
server_index=None, server_variables=None,
73-
server_operation_index=None, server_operation_variables=None,
74-
ignore_operation_servers=False,
75-
ssl_ca_cert=None,
76-
retries=None,
77-
*,
78-
debug: Optional[bool] = None
79-
) -> None:
169+
_default: ClassVar[Optional[Self]] = None
170+
171+
def __init__(
172+
self,
173+
host: Optional[str]=None,
174+
api_key: Optional[Dict[str, str]]=None,
175+
api_key_prefix: Optional[Dict[str, str]]=None,
176+
username: Optional[str]=None,
177+
password: Optional[str]=None,
178+
access_token: Optional[str]=None,
179+
server_index: Optional[int]=None,
180+
server_variables: Optional[ServerVariablesT]=None,
181+
server_operation_index: Optional[Dict[int, int]]=None,
182+
server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
183+
ignore_operation_servers: bool=False,
184+
ssl_ca_cert: Optional[str]=None,
185+
retries: Optional[int] = None,
186+
*,
187+
debug: Optional[bool] = None,
188+
) -> None:
80189
"""Constructor
81190
"""
82191
self._base_path = "https://api.opal.dev/v1" if host is None else host
@@ -200,7 +309,7 @@ def __init__(self, host=None,
200309
"""date format
201310
"""
202311

203-
def __deepcopy__(self, memo):
312+
def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
204313
cls = self.__class__
205314
result = cls.__new__(cls)
206315
memo[id(self)] = result
@@ -214,11 +323,11 @@ def __deepcopy__(self, memo):
214323
result.debug = self.debug
215324
return result
216325

217-
def __setattr__(self, name, value):
326+
def __setattr__(self, name: str, value: Any) -> None:
218327
object.__setattr__(self, name, value)
219328

220329
@classmethod
221-
def set_default(cls, default):
330+
def set_default(cls, default: Optional[Self]) -> None:
222331
"""Set default instance of configuration.
223332
224333
It stores default configuration, which can be
@@ -229,7 +338,7 @@ def set_default(cls, default):
229338
cls._default = default
230339

231340
@classmethod
232-
def get_default_copy(cls):
341+
def get_default_copy(cls) -> Self:
233342
"""Deprecated. Please use `get_default` instead.
234343
235344
Deprecated. Please use `get_default` instead.
@@ -239,7 +348,7 @@ def get_default_copy(cls):
239348
return cls.get_default()
240349

241350
@classmethod
242-
def get_default(cls):
351+
def get_default(cls) -> Self:
243352
"""Return the default configuration.
244353
245354
This method returns newly created, based on default constructor,
@@ -249,11 +358,11 @@ def get_default(cls):
249358
:return: The configuration object.
250359
"""
251360
if cls._default is None:
252-
cls._default = Configuration()
361+
cls._default = cls()
253362
return cls._default
254363

255364
@property
256-
def logger_file(self):
365+
def logger_file(self) -> Optional[str]:
257366
"""The logger file.
258367
259368
If the logger_file is None, then add stream handler and remove file
@@ -265,7 +374,7 @@ def logger_file(self):
265374
return self.__logger_file
266375

267376
@logger_file.setter
268-
def logger_file(self, value):
377+
def logger_file(self, value: Optional[str]) -> None:
269378
"""The logger file.
270379
271380
If the logger_file is None, then add stream handler and remove file
@@ -284,7 +393,7 @@ def logger_file(self, value):
284393
logger.addHandler(self.logger_file_handler)
285394

286395
@property
287-
def debug(self):
396+
def debug(self) -> bool:
288397
"""Debug status
289398
290399
:param value: The debug status, True or False.
@@ -293,7 +402,7 @@ def debug(self):
293402
return self.__debug
294403

295404
@debug.setter
296-
def debug(self, value):
405+
def debug(self, value: bool) -> None:
297406
"""Debug status
298407
299408
:param value: The debug status, True or False.
@@ -315,7 +424,7 @@ def debug(self, value):
315424
httplib.HTTPConnection.debuglevel = 0
316425

317426
@property
318-
def logger_format(self):
427+
def logger_format(self) -> str:
319428
"""The logger format.
320429
321430
The logger_formatter will be updated when sets logger_format.
@@ -326,7 +435,7 @@ def logger_format(self):
326435
return self.__logger_format
327436

328437
@logger_format.setter
329-
def logger_format(self, value):
438+
def logger_format(self, value: str) -> None:
330439
"""The logger format.
331440
332441
The logger_formatter will be updated when sets logger_format.
@@ -337,7 +446,7 @@ def logger_format(self, value):
337446
self.__logger_format = value
338447
self.logger_formatter = logging.Formatter(self.__logger_format)
339448

340-
def get_api_key_with_prefix(self, identifier, alias=None):
449+
def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
341450
"""Gets API key (with prefix if set).
342451
343452
:param identifier: The identifier of apiKey.
@@ -354,7 +463,9 @@ def get_api_key_with_prefix(self, identifier, alias=None):
354463
else:
355464
return key
356465

357-
def get_basic_auth_token(self):
466+
return None
467+
468+
def get_basic_auth_token(self) -> Optional[str]:
358469
"""Gets HTTP basic authentication header (string).
359470
360471
:return: The token for basic HTTP authentication.
@@ -369,12 +480,12 @@ def get_basic_auth_token(self):
369480
basic_auth=username + ':' + password
370481
).get('authorization')
371482

372-
def auth_settings(self):
483+
def auth_settings(self)-> AuthSettings:
373484
"""Gets Auth Settings dict for api client.
374485
375486
:return: The Auth Settings information dict.
376487
"""
377-
auth = {}
488+
auth: AuthSettings = {}
378489
if self.access_token is not None:
379490
auth['BearerAuth'] = {
380491
'type': 'bearer',
@@ -384,7 +495,7 @@ def auth_settings(self):
384495
}
385496
return auth
386497

387-
def to_debug_report(self):
498+
def to_debug_report(self) -> str:
388499
"""Gets the essential information for debugging.
389500
390501
:return: The report for debugging.
@@ -396,7 +507,7 @@ def to_debug_report(self):
396507
"SDK Package Version: 1.0.0".\
397508
format(env=sys.platform, pyversion=sys.version)
398509

399-
def get_host_settings(self):
510+
def get_host_settings(self) -> List[HostSetting]:
400511
"""Gets an array of host settings
401512
402513
:return: An array of host settings
@@ -408,7 +519,12 @@ def get_host_settings(self):
408519
}
409520
]
410521

411-
def get_host_from_settings(self, index, variables=None, servers=None):
522+
def get_host_from_settings(
523+
self,
524+
index: Optional[int],
525+
variables: Optional[ServerVariablesT]=None,
526+
servers: Optional[List[HostSetting]]=None,
527+
) -> str:
412528
"""Gets host URL based on the index and variables
413529
:param index: array index of the host settings
414530
:param variables: hash of variable and the corresponding value
@@ -448,12 +564,12 @@ def get_host_from_settings(self, index, variables=None, servers=None):
448564
return url
449565

450566
@property
451-
def host(self):
567+
def host(self) -> str:
452568
"""Return generated host."""
453569
return self.get_host_from_settings(self.server_index, variables=self.server_variables)
454570

455571
@host.setter
456-
def host(self, value):
572+
def host(self, value: str) -> None:
457573
"""Fix base path."""
458574
self._base_path = value
459575
self.server_index = None

pyproject.toml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ warn_unused_ignores = true
4949

5050
## Getting these passing should be easy
5151
strict_equality = true
52-
strict_concatenate = true
52+
extra_checks = true
5353

5454
## Strongly recommend enabling this one as soon as you can
5555
check_untyped_defs = true
@@ -70,3 +70,20 @@ disallow_any_generics = true
7070
#
7171
### This one can be tricky to get passing if you use a lot of untyped libraries
7272
#warn_return_any = true
73+
74+
[[tool.mypy.overrides]]
75+
module = [
76+
"opal.configuration",
77+
]
78+
warn_unused_ignores = true
79+
strict_equality = true
80+
extra_checks = true
81+
check_untyped_defs = true
82+
disallow_subclassing_any = true
83+
disallow_untyped_decorators = true
84+
disallow_any_generics = true
85+
disallow_untyped_calls = true
86+
disallow_incomplete_defs = true
87+
disallow_untyped_defs = true
88+
no_implicit_reexport = true
89+
warn_return_any = true

0 commit comments

Comments
 (0)