Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion scaleway-async/scaleway_async/function/v1beta1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ async def wait_for_namespace(
async def create_namespace(
self,
*,
activate_vpc_integration: bool,
region: Optional[ScwRegion] = None,
name: Optional[str] = None,
environment_variables: Optional[Dict[str, str]] = None,
Expand All @@ -282,6 +283,7 @@ async def create_namespace(
"""
Create a new namespace.
Create a new namespace in a specified Organization or Project.
:param activate_vpc_integration: When activated, functions in the namespace can be connected to a Private Network.
:param region: Region to target. If none is passed will use default region from the config.
:param name:
:param environment_variables: Environment variables of the namespace.
Expand All @@ -294,7 +296,9 @@ async def create_namespace(
Usage:
::

result = await api.create_namespace()
result = await api.create_namespace(
activate_vpc_integration=False,
)
"""

param_region = validate_path_param(
Expand All @@ -306,6 +310,7 @@ async def create_namespace(
f"/functions/v1beta1/regions/{param_region}/namespaces",
body=marshal_CreateNamespaceRequest(
CreateNamespaceRequest(
activate_vpc_integration=activate_vpc_integration,
region=region,
name=name or random_name(prefix="ns"),
environment_variables=environment_variables,
Expand Down Expand Up @@ -602,6 +607,7 @@ async def create_function(
http_option: Optional[FunctionHttpOption] = None,
sandbox: Optional[FunctionSandbox] = None,
tags: Optional[List[str]] = None,
private_network_id: Optional[str] = None,
) -> Function:
"""
Create a new function.
Expand All @@ -624,6 +630,9 @@ async def create_function(
- enabled: Serve both HTTP and HTTPS traffic.
:param sandbox: Execution environment of the function.
:param tags: Tags of the Serverless Function.
:param private_network_id: When connected to a Private Network, the function can access other Scaleway resources in this Private Network.

Note: this feature is currently in beta and requires a namespace with VPC integration activated, using the `activate_vpc_integration` flag.
:return: :class:`Function <Function>`

Usage:
Expand Down Expand Up @@ -659,6 +668,7 @@ async def create_function(
http_option=http_option,
sandbox=sandbox,
tags=tags,
private_network_id=private_network_id,
),
self.client,
),
Expand Down Expand Up @@ -686,6 +696,7 @@ async def update_function(
http_option: Optional[FunctionHttpOption] = None,
sandbox: Optional[FunctionSandbox] = None,
tags: Optional[List[str]] = None,
private_network_id: Optional[str] = None,
) -> Function:
"""
Update an existing function.
Expand All @@ -708,6 +719,9 @@ async def update_function(
- enabled: Serve both HTTP and HTTPS traffic.
:param sandbox: Execution environment of the function.
:param tags: Tags of the Serverless Function.
:param private_network_id: When connected to a Private Network, the function can access other Scaleway resources in this Private Network.

Note: this feature is currently in beta and requires a namespace with VPC integration activated, using the `activate_vpc_integration` flag.
:return: :class:`Function <Function>`

Usage:
Expand Down Expand Up @@ -744,6 +758,7 @@ async def update_function(
http_option=http_option,
sandbox=sandbox,
tags=tags,
private_network_id=private_network_id,
),
self.client,
),
Expand Down
33 changes: 27 additions & 6 deletions scaleway-async/scaleway_async/function/v1beta1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ def unmarshal_Function(data: Any) -> Function:
else:
args["ready_at"] = None

field = data.get("private_network_id", None)
if field is not None:
args["private_network_id"] = field
else:
args["private_network_id"] = None

return Function(**args)


Expand Down Expand Up @@ -310,6 +316,12 @@ def unmarshal_Namespace(data: Any) -> Namespace:
if field is not None:
args["registry_namespace_id"] = field

field = data.get("error_message", None)
if field is not None:
args["error_message"] = field
else:
args["error_message"] = None

field = data.get("registry_endpoint", None)
if field is not None:
args["registry_endpoint"] = field
Expand All @@ -330,12 +342,6 @@ def unmarshal_Namespace(data: Any) -> Namespace:
if field is not None:
args["tags"] = field

field = data.get("error_message", None)
if field is not None:
args["error_message"] = field
else:
args["error_message"] = None

field = data.get("description", None)
if field is not None:
args["description"] = field
Expand All @@ -354,6 +360,12 @@ def unmarshal_Namespace(data: Any) -> Namespace:
else:
args["updated_at"] = None

field = data.get("vpc_integration_activated", None)
if field is not None:
args["vpc_integration_activated"] = field
else:
args["vpc_integration_activated"] = None

return Namespace(**args)


Expand Down Expand Up @@ -899,6 +911,9 @@ def marshal_CreateFunctionRequest(
if request.tags is not None:
output["tags"] = request.tags

if request.private_network_id is not None:
output["private_network_id"] = request.private_network_id

return output


Expand All @@ -908,6 +923,9 @@ def marshal_CreateNamespaceRequest(
) -> Dict[str, Any]:
output: Dict[str, Any] = {}

if request.activate_vpc_integration is not None:
output["activate_vpc_integration"] = request.activate_vpc_integration

if request.name is not None:
output["name"] = request.name

Expand Down Expand Up @@ -1114,6 +1132,9 @@ def marshal_UpdateFunctionRequest(
if request.tags is not None:
output["tags"] = request.tags

if request.private_network_id is not None:
output["private_network_id"] = request.private_network_id

return output


Expand Down
40 changes: 35 additions & 5 deletions scaleway-async/scaleway_async/function/v1beta1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,11 @@ class Function:
Last date when the function was successfully deployed and set to ready.
"""

private_network_id: Optional[str]
"""
When connected to a Private Network, the function can access other Scaleway resources in this Private Network.
"""


@dataclass
class Namespace:
Expand Down Expand Up @@ -621,6 +626,11 @@ class Namespace:
UUID of the registry namespace.
"""

error_message: Optional[str]
"""
Error message if the namespace is in "error" state.
"""

registry_endpoint: str
"""
Registry endpoint of the namespace.
Expand All @@ -641,11 +651,6 @@ class Namespace:
List of tags applied to the Serverless Function Namespace.
"""

error_message: Optional[str]
"""
Error message if the namespace is in "error" state.
"""

description: Optional[str]
"""
Description of the namespace.
Expand All @@ -661,6 +666,12 @@ class Namespace:
Last update date of the namespace.
"""

vpc_integration_activated: Optional[bool]
"""
When activated, functions in the namespace can be connected to a Private Network.
Note that activating the VPC integration can only be done when creating a new namespace.
"""


@dataclass
class Token:
Expand Down Expand Up @@ -877,9 +888,21 @@ class CreateFunctionRequest:
Tags of the Serverless Function.
"""

private_network_id: Optional[str]
"""
When connected to a Private Network, the function can access other Scaleway resources in this Private Network.

Note: this feature is currently in beta and requires a namespace with VPC integration activated, using the `activate_vpc_integration` flag.
"""


@dataclass
class CreateNamespaceRequest:
activate_vpc_integration: bool
"""
When activated, functions in the namespace can be connected to a Private Network.
"""

region: Optional[ScwRegion]
"""
Region to target. If none is passed will use default region from the config.
Expand Down Expand Up @@ -1577,6 +1600,13 @@ class UpdateFunctionRequest:
Tags of the Serverless Function.
"""

private_network_id: Optional[str]
"""
When connected to a Private Network, the function can access other Scaleway resources in this Private Network.

Note: this feature is currently in beta and requires a namespace with VPC integration activated, using the `activate_vpc_integration` flag.
"""


@dataclass
class UpdateNamespaceRequest:
Expand Down
17 changes: 16 additions & 1 deletion scaleway/scaleway/function/v1beta1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def wait_for_namespace(
def create_namespace(
self,
*,
activate_vpc_integration: bool,
region: Optional[ScwRegion] = None,
name: Optional[str] = None,
environment_variables: Optional[Dict[str, str]] = None,
Expand All @@ -280,6 +281,7 @@ def create_namespace(
"""
Create a new namespace.
Create a new namespace in a specified Organization or Project.
:param activate_vpc_integration: When activated, functions in the namespace can be connected to a Private Network.
:param region: Region to target. If none is passed will use default region from the config.
:param name:
:param environment_variables: Environment variables of the namespace.
Expand All @@ -292,7 +294,9 @@ def create_namespace(
Usage:
::

result = api.create_namespace()
result = api.create_namespace(
activate_vpc_integration=False,
)
"""

param_region = validate_path_param(
Expand All @@ -304,6 +308,7 @@ def create_namespace(
f"/functions/v1beta1/regions/{param_region}/namespaces",
body=marshal_CreateNamespaceRequest(
CreateNamespaceRequest(
activate_vpc_integration=activate_vpc_integration,
region=region,
name=name or random_name(prefix="ns"),
environment_variables=environment_variables,
Expand Down Expand Up @@ -598,6 +603,7 @@ def create_function(
http_option: Optional[FunctionHttpOption] = None,
sandbox: Optional[FunctionSandbox] = None,
tags: Optional[List[str]] = None,
private_network_id: Optional[str] = None,
) -> Function:
"""
Create a new function.
Expand All @@ -620,6 +626,9 @@ def create_function(
- enabled: Serve both HTTP and HTTPS traffic.
:param sandbox: Execution environment of the function.
:param tags: Tags of the Serverless Function.
:param private_network_id: When connected to a Private Network, the function can access other Scaleway resources in this Private Network.

Note: this feature is currently in beta and requires a namespace with VPC integration activated, using the `activate_vpc_integration` flag.
:return: :class:`Function <Function>`

Usage:
Expand Down Expand Up @@ -655,6 +664,7 @@ def create_function(
http_option=http_option,
sandbox=sandbox,
tags=tags,
private_network_id=private_network_id,
),
self.client,
),
Expand Down Expand Up @@ -682,6 +692,7 @@ def update_function(
http_option: Optional[FunctionHttpOption] = None,
sandbox: Optional[FunctionSandbox] = None,
tags: Optional[List[str]] = None,
private_network_id: Optional[str] = None,
) -> Function:
"""
Update an existing function.
Expand All @@ -704,6 +715,9 @@ def update_function(
- enabled: Serve both HTTP and HTTPS traffic.
:param sandbox: Execution environment of the function.
:param tags: Tags of the Serverless Function.
:param private_network_id: When connected to a Private Network, the function can access other Scaleway resources in this Private Network.

Note: this feature is currently in beta and requires a namespace with VPC integration activated, using the `activate_vpc_integration` flag.
:return: :class:`Function <Function>`

Usage:
Expand Down Expand Up @@ -740,6 +754,7 @@ def update_function(
http_option=http_option,
sandbox=sandbox,
tags=tags,
private_network_id=private_network_id,
),
self.client,
),
Expand Down
Loading