Skip to content

Commit c9b2be6

Browse files
chore(function): handle deprecated_optional fields (#1676)
Co-authored-by: Mia-Cross <lmarabese@scaleway.com>
1 parent 9dbd982 commit c9b2be6

6 files changed

Lines changed: 51 additions & 55 deletions

File tree

scaleway-async/scaleway_async/function/v1beta1/api.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,34 +271,32 @@ async def wait_for_namespace(
271271
async def create_namespace(
272272
self,
273273
*,
274-
activate_vpc_integration: bool,
275274
region: Optional[ScwRegion] = None,
276275
name: Optional[str] = None,
277276
environment_variables: Optional[dict[str, str]] = None,
278277
project_id: Optional[str] = None,
279278
description: Optional[str] = None,
280279
secret_environment_variables: Optional[list[Secret]] = None,
281280
tags: Optional[list[str]] = None,
281+
activate_vpc_integration: Optional[bool] = None,
282282
) -> Namespace:
283283
"""
284284
Create a new namespace.
285285
Create a new namespace in a specified Organization or Project.
286-
:param activate_vpc_integration: Setting this field to true doesn't matter anymore. It will be removed in a near future.
287286
:param region: Region to target. If none is passed will use default region from the config.
288287
:param name:
289288
:param environment_variables: Environment variables of the namespace.
290289
:param project_id: UUID of the project in which the namespace will be created.
291290
:param description: Description of the namespace.
292291
:param secret_environment_variables: Secret environment variables of the namespace.
293292
:param tags: Tags of the Serverless Function Namespace.
293+
:param activate_vpc_integration: Setting this field to true doesn't matter anymore. It will be removed in a near future.
294294
:return: :class:`Namespace <Namespace>`
295295
296296
Usage:
297297
::
298298
299-
result = await api.create_namespace(
300-
activate_vpc_integration=False,
301-
)
299+
result = await api.create_namespace()
302300
"""
303301

304302
param_region = validate_path_param(
@@ -310,14 +308,14 @@ async def create_namespace(
310308
f"/functions/v1beta1/regions/{param_region}/namespaces",
311309
body=marshal_CreateNamespaceRequest(
312310
CreateNamespaceRequest(
313-
activate_vpc_integration=activate_vpc_integration,
314311
region=region,
315312
name=name or random_name(prefix="ns"),
316313
environment_variables=environment_variables,
317314
project_id=project_id,
318315
description=description,
319316
secret_environment_variables=secret_environment_variables,
320317
tags=tags,
318+
activate_vpc_integration=activate_vpc_integration,
321319
),
322320
self.client,
323321
),

scaleway-async/scaleway_async/function/v1beta1/marshalling.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,6 @@ def unmarshal_Namespace(data: Any) -> Namespace:
437437
else:
438438
args["tags"] = []
439439

440-
field = data.get("vpc_integration_activated", None)
441-
if field is not None:
442-
args["vpc_integration_activated"] = field
443-
else:
444-
args["vpc_integration_activated"] = False
445-
446440
field = data.get("description", None)
447441
if field is not None:
448442
args["description"] = field
@@ -461,6 +455,12 @@ def unmarshal_Namespace(data: Any) -> Namespace:
461455
else:
462456
args["updated_at"] = None
463457

458+
field = data.get("vpc_integration_activated", None)
459+
if field is not None:
460+
args["vpc_integration_activated"] = field
461+
else:
462+
args["vpc_integration_activated"] = None
463+
464464
return Namespace(**args)
465465

466466

@@ -1114,9 +1114,6 @@ def marshal_CreateNamespaceRequest(
11141114
) -> dict[str, Any]:
11151115
output: dict[str, Any] = {}
11161116

1117-
if request.activate_vpc_integration is not None:
1118-
output["activate_vpc_integration"] = request.activate_vpc_integration
1119-
11201117
if request.name is not None:
11211118
output["name"] = request.name
11221119

@@ -1140,6 +1137,9 @@ def marshal_CreateNamespaceRequest(
11401137
if request.tags is not None:
11411138
output["tags"] = request.tags
11421139

1140+
if request.activate_vpc_integration is not None:
1141+
output["activate_vpc_integration"] = request.activate_vpc_integration
1142+
11431143
return output
11441144

11451145

scaleway-async/scaleway_async/function/v1beta1/types.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,6 @@ class Namespace:
628628
List of tags applied to the Serverless Function Namespace.
629629
"""
630630

631-
vpc_integration_activated: bool
632-
"""
633-
The value of this field doesn't matter anymore, and will be removed in a near future.
634-
"""
635-
636631
error_message: Optional[str] = None
637632
"""
638633
Error message if the namespace is in "error" state.
@@ -653,6 +648,11 @@ class Namespace:
653648
Last update date of the namespace.
654649
"""
655650

651+
vpc_integration_activated: Optional[bool] = None
652+
"""
653+
The value of this field doesn't matter anymore, and will be removed in a near future.
654+
"""
655+
656656

657657
@dataclass
658658
class Token:
@@ -666,14 +666,14 @@ class Token:
666666
String of the token.
667667
"""
668668

669-
public_key: str
669+
status: TokenStatus
670670
"""
671-
Public key of the token.
671+
Status of the token.
672672
"""
673673

674-
status: TokenStatus
674+
public_key: Optional[str] = None
675675
"""
676-
Status of the token.
676+
Public key of the token.
677677
"""
678678

679679
description: Optional[str] = None
@@ -875,11 +875,6 @@ class CreateFunctionRequest:
875875

876876
@dataclass
877877
class CreateNamespaceRequest:
878-
activate_vpc_integration: bool
879-
"""
880-
Setting this field to true doesn't matter anymore. It will be removed in a near future.
881-
"""
882-
883878
region: Optional[ScwRegion] = None
884879
"""
885880
Region to target. If none is passed will use default region from the config.
@@ -911,6 +906,11 @@ class CreateNamespaceRequest:
911906
Tags of the Serverless Function Namespace.
912907
"""
913908

909+
activate_vpc_integration: Optional[bool] = None
910+
"""
911+
Setting this field to true doesn't matter anymore. It will be removed in a near future.
912+
"""
913+
914914

915915
@dataclass
916916
class CreateTokenRequest:

scaleway/scaleway/function/v1beta1/api.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,34 +269,32 @@ def wait_for_namespace(
269269
def create_namespace(
270270
self,
271271
*,
272-
activate_vpc_integration: bool,
273272
region: Optional[ScwRegion] = None,
274273
name: Optional[str] = None,
275274
environment_variables: Optional[dict[str, str]] = None,
276275
project_id: Optional[str] = None,
277276
description: Optional[str] = None,
278277
secret_environment_variables: Optional[list[Secret]] = None,
279278
tags: Optional[list[str]] = None,
279+
activate_vpc_integration: Optional[bool] = None,
280280
) -> Namespace:
281281
"""
282282
Create a new namespace.
283283
Create a new namespace in a specified Organization or Project.
284-
:param activate_vpc_integration: Setting this field to true doesn't matter anymore. It will be removed in a near future.
285284
:param region: Region to target. If none is passed will use default region from the config.
286285
:param name:
287286
:param environment_variables: Environment variables of the namespace.
288287
:param project_id: UUID of the project in which the namespace will be created.
289288
:param description: Description of the namespace.
290289
:param secret_environment_variables: Secret environment variables of the namespace.
291290
:param tags: Tags of the Serverless Function Namespace.
291+
:param activate_vpc_integration: Setting this field to true doesn't matter anymore. It will be removed in a near future.
292292
:return: :class:`Namespace <Namespace>`
293293
294294
Usage:
295295
::
296296
297-
result = api.create_namespace(
298-
activate_vpc_integration=False,
299-
)
297+
result = api.create_namespace()
300298
"""
301299

302300
param_region = validate_path_param(
@@ -308,14 +306,14 @@ def create_namespace(
308306
f"/functions/v1beta1/regions/{param_region}/namespaces",
309307
body=marshal_CreateNamespaceRequest(
310308
CreateNamespaceRequest(
311-
activate_vpc_integration=activate_vpc_integration,
312309
region=region,
313310
name=name or random_name(prefix="ns"),
314311
environment_variables=environment_variables,
315312
project_id=project_id,
316313
description=description,
317314
secret_environment_variables=secret_environment_variables,
318315
tags=tags,
316+
activate_vpc_integration=activate_vpc_integration,
319317
),
320318
self.client,
321319
),

scaleway/scaleway/function/v1beta1/marshalling.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,6 @@ def unmarshal_Namespace(data: Any) -> Namespace:
437437
else:
438438
args["tags"] = []
439439

440-
field = data.get("vpc_integration_activated", None)
441-
if field is not None:
442-
args["vpc_integration_activated"] = field
443-
else:
444-
args["vpc_integration_activated"] = False
445-
446440
field = data.get("description", None)
447441
if field is not None:
448442
args["description"] = field
@@ -461,6 +455,12 @@ def unmarshal_Namespace(data: Any) -> Namespace:
461455
else:
462456
args["updated_at"] = None
463457

458+
field = data.get("vpc_integration_activated", None)
459+
if field is not None:
460+
args["vpc_integration_activated"] = field
461+
else:
462+
args["vpc_integration_activated"] = None
463+
464464
return Namespace(**args)
465465

466466

scaleway/scaleway/function/v1beta1/types.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,6 @@ class Namespace:
628628
List of tags applied to the Serverless Function Namespace.
629629
"""
630630

631-
vpc_integration_activated: bool
632-
"""
633-
The value of this field doesn't matter anymore, and will be removed in a near future.
634-
"""
635-
636631
error_message: Optional[str] = None
637632
"""
638633
Error message if the namespace is in "error" state.
@@ -653,6 +648,11 @@ class Namespace:
653648
Last update date of the namespace.
654649
"""
655650

651+
vpc_integration_activated: Optional[bool] = None
652+
"""
653+
The value of this field doesn't matter anymore, and will be removed in a near future.
654+
"""
655+
656656

657657
@dataclass
658658
class Token:
@@ -666,14 +666,14 @@ class Token:
666666
String of the token.
667667
"""
668668

669-
public_key: str
669+
status: TokenStatus
670670
"""
671-
Public key of the token.
671+
Status of the token.
672672
"""
673673

674-
status: TokenStatus
674+
public_key: Optional[str] = None
675675
"""
676-
Status of the token.
676+
Public key of the token.
677677
"""
678678

679679
description: Optional[str] = None
@@ -875,11 +875,6 @@ class CreateFunctionRequest:
875875

876876
@dataclass
877877
class CreateNamespaceRequest:
878-
activate_vpc_integration: bool
879-
"""
880-
Setting this field to true doesn't matter anymore. It will be removed in a near future.
881-
"""
882-
883878
region: Optional[ScwRegion] = None
884879
"""
885880
Region to target. If none is passed will use default region from the config.
@@ -911,6 +906,11 @@ class CreateNamespaceRequest:
911906
Tags of the Serverless Function Namespace.
912907
"""
913908

909+
activate_vpc_integration: Optional[bool] = None
910+
"""
911+
Setting this field to true doesn't matter anymore. It will be removed in a near future.
912+
"""
913+
914914

915915
@dataclass
916916
class CreateTokenRequest:

0 commit comments

Comments
 (0)