Skip to content

Commit f7ba7ab

Browse files
authored
fix: manage default value marshalling (#1174)
1 parent d3cb57d commit f7ba7ab

File tree

178 files changed

+27048
-13896
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+27048
-13896
lines changed

scaleway-async/scaleway_async/account/v3/marshalling.py

Lines changed: 79 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
resolve_one_of,
1111
)
1212
from .types import (
13+
ContractType,
14+
QualificationArchitectureType,
1315
Contract,
1416
ContractSignature,
1517
QualificationAiMachine,
@@ -46,18 +48,26 @@ def unmarshal_Contract(data: Any) -> Contract:
4648
field = data.get("id", None)
4749
if field is not None:
4850
args["id"] = field
51+
else:
52+
args["id"] = None
4953

5054
field = data.get("type", None)
5155
if field is not None:
5256
args["type_"] = field
57+
else:
58+
args["type_"] = ContractType.UNKNOWN_TYPE
5359

5460
field = data.get("name", None)
5561
if field is not None:
5662
args["name"] = field
63+
else:
64+
args["name"] = None
5765

5866
field = data.get("version", None)
5967
if field is not None:
6068
args["version"] = field
69+
else:
70+
args["version"] = 0
6171

6272
field = data.get("created_at", None)
6373
if field is not None:
@@ -85,10 +95,14 @@ def unmarshal_ContractSignature(data: Any) -> ContractSignature:
8595
field = data.get("id", None)
8696
if field is not None:
8797
args["id"] = field
98+
else:
99+
args["id"] = None
88100

89101
field = data.get("organization_id", None)
90102
if field is not None:
91103
args["organization_id"] = field
104+
else:
105+
args["organization_id"] = None
92106

93107
field = data.get("created_at", None)
94108
if field is not None:
@@ -128,6 +142,8 @@ def unmarshal_QualificationAiMachine(data: Any) -> QualificationAiMachine:
128142
field = data.get("sub_use_case", None)
129143
if field is not None:
130144
args["sub_use_case"] = field
145+
else:
146+
args["sub_use_case"] = None
131147

132148
return QualificationAiMachine(**args)
133149

@@ -143,6 +159,8 @@ def unmarshal_QualificationArchiveData(data: Any) -> QualificationArchiveData:
143159
field = data.get("sub_use_case", None)
144160
if field is not None:
145161
args["sub_use_case"] = field
162+
else:
163+
args["sub_use_case"] = None
146164

147165
return QualificationArchiveData(**args)
148166

@@ -158,6 +176,8 @@ def unmarshal_QualificationContainer(data: Any) -> QualificationContainer:
158176
field = data.get("sub_use_case", None)
159177
if field is not None:
160178
args["sub_use_case"] = field
179+
else:
180+
args["sub_use_case"] = None
161181

162182
return QualificationContainer(**args)
163183

@@ -173,6 +193,8 @@ def unmarshal_QualificationDeploySoftware(data: Any) -> QualificationDeploySoftw
173193
field = data.get("sub_use_case", None)
174194
if field is not None:
175195
args["sub_use_case"] = field
196+
else:
197+
args["sub_use_case"] = None
176198

177199
return QualificationDeploySoftware(**args)
178200

@@ -188,6 +210,8 @@ def unmarshal_QualificationHostApplication(data: Any) -> QualificationHostApplic
188210
field = data.get("sub_use_case", None)
189211
if field is not None:
190212
args["sub_use_case"] = field
213+
else:
214+
args["sub_use_case"] = None
191215

192216
return QualificationHostApplication(**args)
193217

@@ -203,6 +227,8 @@ def unmarshal_QualificationHostWebsite(data: Any) -> QualificationHostWebsite:
203227
field = data.get("sub_use_case", None)
204228
if field is not None:
205229
args["sub_use_case"] = field
230+
else:
231+
args["sub_use_case"] = None
206232

207233
return QualificationHostWebsite(**args)
208234

@@ -218,6 +244,8 @@ def unmarshal_QualificationOtherUseCase(data: Any) -> QualificationOtherUseCase:
218244
field = data.get("sub_use_case", None)
219245
if field is not None:
220246
args["sub_use_case"] = field
247+
else:
248+
args["sub_use_case"] = None
221249

222250
return QualificationOtherUseCase(**args)
223251

@@ -235,6 +263,8 @@ def unmarshal_QualificationSetScalewayEnvironment(
235263
field = data.get("sub_use_case", None)
236264
if field is not None:
237265
args["sub_use_case"] = field
266+
else:
267+
args["sub_use_case"] = None
238268

239269
return QualificationSetScalewayEnvironment(**args)
240270

@@ -250,6 +280,8 @@ def unmarshal_QualificationShareData(data: Any) -> QualificationShareData:
250280
field = data.get("sub_use_case", None)
251281
if field is not None:
252282
args["sub_use_case"] = field
283+
else:
284+
args["sub_use_case"] = None
253285

254286
return QualificationShareData(**args)
255287

@@ -265,6 +297,10 @@ def unmarshal_Qualification(data: Any) -> Qualification:
265297
field = data.get("architecture_type", None)
266298
if field is not None:
267299
args["architecture_type"] = field
300+
else:
301+
args["architecture_type"] = (
302+
QualificationArchitectureType.UNKNOWN_ARCHITECTURE_TYPE
303+
)
268304

269305
field = data.get("host_website", None)
270306
if field is not None:
@@ -336,18 +372,26 @@ def unmarshal_Project(data: Any) -> Project:
336372
field = data.get("id", None)
337373
if field is not None:
338374
args["id"] = field
375+
else:
376+
args["id"] = None
339377

340378
field = data.get("name", None)
341379
if field is not None:
342380
args["name"] = field
381+
else:
382+
args["name"] = None
343383

344384
field = data.get("organization_id", None)
345385
if field is not None:
346386
args["organization_id"] = field
387+
else:
388+
args["organization_id"] = None
347389

348390
field = data.get("description", None)
349391
if field is not None:
350392
args["description"] = field
393+
else:
394+
args["description"] = None
351395

352396
field = data.get("created_at", None)
353397
if field is not None:
@@ -383,10 +427,14 @@ def unmarshal_CheckContractSignatureResponse(
383427
field = data.get("created", None)
384428
if field is not None:
385429
args["created"] = field
430+
else:
431+
args["created"] = False
386432

387433
field = data.get("validated", None)
388434
if field is not None:
389435
args["validated"] = field
436+
else:
437+
args["validated"] = False
390438

391439
return CheckContractSignatureResponse(**args)
392440

@@ -404,6 +452,8 @@ def unmarshal_ListContractSignaturesResponse(
404452
field = data.get("total_count", None)
405453
if field is not None:
406454
args["total_count"] = field
455+
else:
456+
args["total_count"] = 0
407457

408458
field = data.get("contract_signatures", None)
409459
if field is not None:
@@ -412,6 +462,8 @@ def unmarshal_ListContractSignaturesResponse(
412462
if field is not None
413463
else None
414464
)
465+
else:
466+
args["contract_signatures"] = []
415467

416468
return ListContractSignaturesResponse(**args)
417469

@@ -427,12 +479,16 @@ def unmarshal_ListProjectsResponse(data: Any) -> ListProjectsResponse:
427479
field = data.get("total_count", None)
428480
if field is not None:
429481
args["total_count"] = field
482+
else:
483+
args["total_count"] = 0
430484

431485
field = data.get("projects", None)
432486
if field is not None:
433487
args["projects"] = (
434488
[unmarshal_Project(v) for v in field] if field is not None else None
435489
)
490+
else:
491+
args["projects"] = []
436492

437493
return ListProjectsResponse(**args)
438494

@@ -448,6 +504,8 @@ def unmarshal_ProjectQualification(data: Any) -> ProjectQualification:
448504
field = data.get("project_id", None)
449505
if field is not None:
450506
args["project_id"] = field
507+
else:
508+
args["project_id"] = None
451509

452510
field = data.get("qualification", None)
453511
if field is not None:
@@ -468,12 +526,12 @@ def marshal_ContractApiCheckContractSignatureRequest(
468526
output["contract_name"] = request.contract_name
469527

470528
if request.organization_id is not None:
471-
output["organization_id"] = (
472-
request.organization_id or defaults.default_organization_id
473-
)
529+
output["organization_id"] = request.organization_id
530+
else:
531+
output["organization_id"] = defaults.default_organization_id
474532

475533
if request.contract_type is not None:
476-
output["contract_type"] = str(request.contract_type)
534+
output["contract_type"] = request.contract_type
477535

478536
return output
479537

@@ -491,12 +549,12 @@ def marshal_ContractApiCreateContractSignatureRequest(
491549
output["validated"] = request.validated
492550

493551
if request.contract_type is not None:
494-
output["contract_type"] = str(request.contract_type)
552+
output["contract_type"] = request.contract_type
495553

496554
if request.organization_id is not None:
497-
output["organization_id"] = (
498-
request.organization_id or defaults.default_organization_id
499-
)
555+
output["organization_id"] = request.organization_id
556+
else:
557+
output["organization_id"] = defaults.default_organization_id
500558

501559
return output
502560

@@ -514,9 +572,9 @@ def marshal_ProjectApiCreateProjectRequest(
514572
output["name"] = request.name
515573

516574
if request.organization_id is not None:
517-
output["organization_id"] = (
518-
request.organization_id or defaults.default_organization_id
519-
)
575+
output["organization_id"] = request.organization_id
576+
else:
577+
output["organization_id"] = defaults.default_organization_id
520578

521579
return output
522580

@@ -528,7 +586,7 @@ def marshal_QualificationAiMachine(
528586
output: Dict[str, Any] = {}
529587

530588
if request.sub_use_case is not None:
531-
output["sub_use_case"] = str(request.sub_use_case)
589+
output["sub_use_case"] = request.sub_use_case
532590

533591
return output
534592

@@ -540,7 +598,7 @@ def marshal_QualificationArchiveData(
540598
output: Dict[str, Any] = {}
541599

542600
if request.sub_use_case is not None:
543-
output["sub_use_case"] = str(request.sub_use_case)
601+
output["sub_use_case"] = request.sub_use_case
544602

545603
return output
546604

@@ -552,7 +610,7 @@ def marshal_QualificationContainer(
552610
output: Dict[str, Any] = {}
553611

554612
if request.sub_use_case is not None:
555-
output["sub_use_case"] = str(request.sub_use_case)
613+
output["sub_use_case"] = request.sub_use_case
556614

557615
return output
558616

@@ -564,7 +622,7 @@ def marshal_QualificationDeploySoftware(
564622
output: Dict[str, Any] = {}
565623

566624
if request.sub_use_case is not None:
567-
output["sub_use_case"] = str(request.sub_use_case)
625+
output["sub_use_case"] = request.sub_use_case
568626

569627
return output
570628

@@ -576,7 +634,7 @@ def marshal_QualificationHostApplication(
576634
output: Dict[str, Any] = {}
577635

578636
if request.sub_use_case is not None:
579-
output["sub_use_case"] = str(request.sub_use_case)
637+
output["sub_use_case"] = request.sub_use_case
580638

581639
return output
582640

@@ -588,7 +646,7 @@ def marshal_QualificationHostWebsite(
588646
output: Dict[str, Any] = {}
589647

590648
if request.sub_use_case is not None:
591-
output["sub_use_case"] = str(request.sub_use_case)
649+
output["sub_use_case"] = request.sub_use_case
592650

593651
return output
594652

@@ -600,7 +658,7 @@ def marshal_QualificationOtherUseCase(
600658
output: Dict[str, Any] = {}
601659

602660
if request.sub_use_case is not None:
603-
output["sub_use_case"] = str(request.sub_use_case)
661+
output["sub_use_case"] = request.sub_use_case
604662

605663
return output
606664

@@ -612,7 +670,7 @@ def marshal_QualificationSetScalewayEnvironment(
612670
output: Dict[str, Any] = {}
613671

614672
if request.sub_use_case is not None:
615-
output["sub_use_case"] = str(request.sub_use_case)
673+
output["sub_use_case"] = request.sub_use_case
616674

617675
return output
618676

@@ -624,7 +682,7 @@ def marshal_QualificationShareData(
624682
output: Dict[str, Any] = {}
625683

626684
if request.sub_use_case is not None:
627-
output["sub_use_case"] = str(request.sub_use_case)
685+
output["sub_use_case"] = request.sub_use_case
628686

629687
return output
630688

@@ -687,7 +745,7 @@ def marshal_Qualification(
687745
)
688746

689747
if request.architecture_type is not None:
690-
output["architecture_type"] = str(request.architecture_type)
748+
output["architecture_type"] = request.architecture_type
691749

692750
return output
693751

0 commit comments

Comments
 (0)