Skip to content

Commit 660369d

Browse files
authored
fix: Fixed bool params and complex types params (#4)
* fix: Fixed bool params and complex types params * fix: Fixed bool params and complex types params * fix: implemented isort * fix: Fixed tests
1 parent 0879408 commit 660369d

33 files changed

Lines changed: 281 additions & 929 deletions

gen/client_generator.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,25 @@
5858
def get_type_for_param(param: dict, swagger: dict | None = None) -> str:
5959
if swagger is None:
6060
swagger = {}
61+
_in = param.get("in")
6162

62-
if param.get("in") in ("query", "path"):
63+
if _in == "path":
6364
return str.__name__
65+
elif _in == "query":
66+
_type = get_path(
67+
param,
68+
"schema.type",
69+
default="string"
70+
)
71+
if _type in SIMPLE_TYPES_MAP:
72+
return SIMPLE_TYPES_MAP[_type]
73+
else:
74+
_items_type = get_path(
75+
param,
76+
"schema.items.type",
77+
default="string"
78+
)
79+
return COMPLEX_TYPES_MAP[(_type, _items_type)]
6480

6581
param_type = param.get("type")
6682
schema_type = get_path(param, "schema.type", None)
@@ -154,6 +170,7 @@ def param_to_function_argument(param: dict, swagger: dict | None = None) -> str:
154170
swagger = {}
155171

156172
name = convert_to_snake_case(param["name"])
173+
157174
_type = get_type_for_param(param, swagger)
158175

159176
is_required = param.get('required', False)
@@ -556,6 +573,7 @@ def create_method_sig(swagger: dict, name: str, params: list[str], body_required
556573
path_params = [
557574
p for p in params if p['name'] not in SPECIAL_HEADERS and p["in"] != "body"
558575
]
576+
559577
elements = [name, ]
560578
sig = ""
561579
_input_parameters_strings = [param_to_function_argument(p)
@@ -575,6 +593,7 @@ def create_method_sig(swagger: dict, name: str, params: list[str], body_required
575593

576594
doc = generate_doc_string(name, path_params, body_required, body_not_required,
577595
swagger, method, path, indent_offset=1)
596+
578597
try:
579598
if len(elements) > 1:
580599
sig = "def %s(self, *, %s, data_partition_id: str | None = None) -> dict:" % tuple(elements)

gen/tests_generator.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,16 @@
99

1010
TYPE_DEFAULTS = {
1111
str: '"text"',
12-
str | None: '"text"',
1312
'str | None': '"text"',
1413
'str': '"text"',
15-
int | None: '10',
1614
'int | None': '10',
1715
dict: '{}',
1816
'dict': '{}',
19-
bool | None: 'False',
20-
list[str]: '["text"]',
17+
'bool | None': 'False',
2118
'list[str]': '["text"]',
22-
list[dict]: '[{}]',
2319
'list[dict]': '[{}]',
24-
list[dict] | None: '[{}]',
25-
dict | None: '{}',
20+
'list[dict] | None': '[{}]',
2621
'dict | None': '{}',
27-
list[str] | None: '["text"]',
2822
'list[str] | None': '["text"]'
2923
}
3024

osdu_client/services/entitlements/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def list_partition_groups(
436436
*,
437437
type: str,
438438
cursor: str | None = None,
439-
limit: str | None = None,
439+
limit: int | None = None,
440440
data_partition_id: str | None = None,
441441
) -> dict:
442442
"""
@@ -445,7 +445,7 @@ def list_partition_groups(
445445
data_partition_id (str): identifier of the data partition to query. If None sets by auth session.
446446
type (str): type
447447
cursor (str): cursor
448-
limit (str): limit
448+
limit (int): limit
449449
Returns:
450450
response data (dict)
451451
Raises:

osdu_client/services/file/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from osdu_client.utils import urljoin
88
from osdu_client.validation import validate_data
99

10-
from .models import FileListRequest, FileLocationRequest, LocationRequest, Record, DeliveryGetFileSignedURLRequest
10+
from .models import DeliveryGetFileSignedURLRequest, FileListRequest, FileLocationRequest, LocationRequest, Record
1111

1212

1313
class FileAPIError(OSDUAPIError):

osdu_client/services/indexer/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def provision_partition(self, data_partition_id: str | None = None) -> dict:
4141
def reindex_kind(
4242
self,
4343
*,
44-
force_clean: str | None = None,
44+
force_clean: bool | None = None,
4545
kind: str,
4646
cursor: str | None = None,
4747
data_partition_id: str | None = None,
@@ -50,7 +50,7 @@ def reindex_kind(
5050
This API allows users to re-index a 'kind' without re-ingesting the records via storage API. Required roles: `service.search.admin`
5151
Args:
5252
data_partition_id (str): identifier of the data partition to query. If None sets by auth session.
53-
force_clean (str): Force Clean
53+
force_clean (bool): Force Clean
5454
kind (str):
5555
cursor (str):
5656
Returns:
@@ -83,13 +83,13 @@ def reindex_kind(
8383
return response.json()
8484

8585
def reindex_partition(
86-
self, *, force_clean: str | None = None, data_partition_id: str | None = None
86+
self, *, force_clean: bool | None = None, data_partition_id: str | None = None
8787
) -> dict:
8888
"""
8989
This API allows users to re-index an entire partition without re-ingesting the records via storage API.Required roles: `users.datalake.ops`
9090
Args:
9191
data_partition_id (str): identifier of the data partition to query. If None sets by auth session.
92-
force_clean (str): Force Clean
92+
force_clean (bool): Force Clean
9393
Returns:
9494
response data (dict)
9595
Raises:

osdu_client/services/legal/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ class LegalClient(OSDUAPIClient):
1818
service_path = "/api/legal/v1/"
1919

2020
def list_legaltags(
21-
self, *, valid: str | None = None, data_partition_id: str | None = None
21+
self, *, valid: bool | None = None, data_partition_id: str | None = None
2222
) -> dict:
2323
"""
2424
This allows for the retrieval of all LegalTags.
2525
Args:
2626
data_partition_id (str): identifier of the data partition to query. If None sets by auth session.
27-
valid (str): If true returns only valid LegalTags, if false returns only invalid LegalTags. Default value is true.
27+
valid (bool): If true returns only valid LegalTags, if false returns only invalid LegalTags. Default value is true.
2828
Returns:
2929
response data (dict)
3030
Raises:
@@ -171,7 +171,7 @@ def validate_legaltags(
171171
def query_legaltags(
172172
self,
173173
*,
174-
valid: str | None = None,
174+
valid: bool | None = None,
175175
query_list: list[str] | None = None,
176176
operator_list: list[str] | None = None,
177177
sort_by: str | None = None,
@@ -183,7 +183,7 @@ def query_legaltags(
183183
This allows search for specific attributes of legaltags including the attributes of extensionproperties
184184
Args:
185185
data_partition_id (str): identifier of the data partition to query. If None sets by auth session.
186-
valid (str): If true returns only valid LegalTags, if false returns only invalid LegalTags. Default value is true.
186+
valid (bool): If true returns only valid LegalTags, if false returns only invalid LegalTags. Default value is true.
187187
query_list (list[str]): Filter condition query
188188
operator_list (list[str]): If there are multiple conditions need to be joined in by logical operators
189189
sort_by (str):

osdu_client/services/policy/client.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def evaluate_policy(
382382
self,
383383
*,
384384
policy_id: str,
385-
include_auth: str | None = None,
385+
include_auth: bool | None = None,
386386
correlation_id: str | None = None,
387387
user_agent: str | None = None,
388388
x_user_id: str | None = None,
@@ -425,7 +425,7 @@ def evaluate_policy(
425425
Args:
426426
data_partition_id (str): identifier of the data partition to query. If None sets by auth session.
427427
policy_id (str):
428-
include_auth (str): Update posted data to include auth (token, xuserid and data partition id) from headers
428+
include_auth (bool): Update posted data to include auth (token, xuserid and data partition id) from headers
429429
correlation_id (str):
430430
user_agent (str):
431431
x_user_id (str): identifier the user in the query
@@ -552,8 +552,8 @@ def get_api_policy_v1_info(
552552
def create_api_policy_v1_compile(
553553
self,
554554
*,
555-
metrics: str | None = None,
556-
instrument: str | None = None,
555+
metrics: bool | None = None,
556+
instrument: bool | None = None,
557557
correlation_id: str | None = None,
558558
user_agent: str | None = None,
559559
x_user_id: str | None = None,
@@ -581,8 +581,8 @@ def create_api_policy_v1_compile(
581581
We recommend leaving query instrumentation off unless you are debugging a performance problem.
582582
Args:
583583
data_partition_id (str): identifier of the data partition to query. If None sets by auth session.
584-
metrics (str): Include report detailed performance metrics on requested on individual API call. Returned inline with the API response
585-
instrument (str): Include instrumentation data wth detailed performance metrics on requested on individual API call. Returned inline with the API response
584+
metrics (bool): Include report detailed performance metrics on requested on individual API call. Returned inline with the API response
585+
instrument (bool): Include instrumentation data wth detailed performance metrics on requested on individual API call. Returned inline with the API response
586586
correlation_id (str):
587587
user_agent (str):
588588
x_user_id (str): identifier the user in the query
@@ -617,7 +617,7 @@ def create_api_policy_v1_compile(
617617
def get_tenant(
618618
self,
619619
*,
620-
all_data: str | None = None,
620+
all_data: bool | None = None,
621621
correlation_id: str | None = None,
622622
user_agent: str | None = None,
623623
x_user_id: str | None = None,
@@ -628,7 +628,7 @@ def get_tenant(
628628
These details are read from OPA configmap.
629629
Args:
630630
data_partition_id (str): identifier of the data partition to query. If None sets by auth session.
631-
all_data (str):
631+
all_data (bool):
632632
correlation_id (str):
633633
user_agent (str):
634634
x_user_id (str): identifier the user in the query
@@ -662,8 +662,8 @@ def update_tenant(
662662
self,
663663
*,
664664
service: str,
665-
polling_min_delay_seconds: str | None = None,
666-
polling_max_delay_seconds: str | None = None,
665+
polling_min_delay_seconds: int | None = None,
666+
polling_max_delay_seconds: int | None = None,
667667
correlation_id: str | None = None,
668668
user_agent: str | None = None,
669669
x_user_id: str | None = None,
@@ -675,8 +675,8 @@ def update_tenant(
675675
Args:
676676
data_partition_id (str): identifier of the data partition to query. If None sets by auth session.
677677
service (str):
678-
polling_min_delay_seconds (str):
679-
polling_max_delay_seconds (str):
678+
polling_min_delay_seconds (int):
679+
polling_max_delay_seconds (int):
680680
correlation_id (str):
681681
user_agent (str):
682682
x_user_id (str): identifier the user in the query
@@ -832,7 +832,7 @@ def validate_policy(
832832
self,
833833
*,
834834
policy_id: str,
835-
template: str | None = None,
835+
template: bool | None = None,
836836
correlation_id: str | None = None,
837837
user_agent: str | None = None,
838838
x_user_id: str | None = None,
@@ -849,7 +849,7 @@ def validate_policy(
849849
Args:
850850
data_partition_id (str): identifier of the data partition to query. If None sets by auth session.
851851
policy_id (str):
852-
template (str):
852+
template (bool):
853853
correlation_id (str):
854854
user_agent (str):
855855
x_user_id (str): identifier the user in the query
@@ -925,7 +925,7 @@ def get_backup(
925925
def bootstrap(
926926
self,
927927
*,
928-
force: str | None = None,
928+
force: bool | None = None,
929929
correlation_id: str | None = None,
930930
user_agent: str | None = None,
931931
x_user_id: str | None = None,
@@ -949,7 +949,7 @@ def bootstrap(
949949
* HTTP_424_FAILED_DEPENDENCY - bundle server caused failure
950950
Args:
951951
data_partition_id (str): identifier of the data partition to query. If None sets by auth session.
952-
force (str):
952+
force (bool):
953953
correlation_id (str):
954954
user_agent (str):
955955
x_user_id (str): identifier the user in the query

0 commit comments

Comments
 (0)