diff --git a/scaleway-async/scaleway_async/edge_services/v1beta1/__init__.py b/scaleway-async/scaleway_async/edge_services/v1beta1/__init__.py index 2450691a7..d0f1b2d16 100644 --- a/scaleway-async/scaleway_async/edge_services/v1beta1/__init__.py +++ b/scaleway-async/scaleway_async/edge_services/v1beta1/__init__.py @@ -10,6 +10,7 @@ from .types import ListPurgeRequestsRequestOrderBy from .types import ListRouteStagesRequestOrderBy from .types import ListTLSStagesRequestOrderBy +from .types import ListVPCEndpointsRequestOrderBy from .types import ListWafStagesRequestOrderBy from .types import PipelineErrorCode from .types import PipelineErrorSeverity @@ -54,6 +55,7 @@ from .types import ListHeadStagesResponseHeadStage from .types import PipelineStages from .types import PurgeRequest +from .types import VPCEndpoint from .types import SetHeadStageRequestAddNewHeadStage from .types import SetHeadStageRequestRemoveHeadStage from .types import SetHeadStageRequestSwapHeadStage @@ -73,6 +75,7 @@ from .types import CreatePurgeRequestRequest from .types import CreateRouteStageRequest from .types import CreateTLSStageRequest +from .types import CreateVPCEndpointRequest from .types import CreateWafStageRequest from .types import DeleteBackendStageRequest from .types import DeleteCacheStageRequest @@ -81,6 +84,7 @@ from .types import DeletePipelineRequest from .types import DeleteRouteStageRequest from .types import DeleteTLSStageRequest +from .types import DeleteVPCEndpointRequest from .types import DeleteWafStageRequest from .types import GetBackendStageRequest from .types import GetBillingRequest @@ -92,6 +96,7 @@ from .types import GetPurgeRequestRequest from .types import GetRouteStageRequest from .types import GetTLSStageRequest +from .types import GetVPCEndpointRequest from .types import GetWafStageRequest from .types import HeadStageResponse from .types import ListBackendStagesRequest @@ -115,6 +120,8 @@ from .types import ListRouteStagesResponse from .types import ListTLSStagesRequest from .types import ListTLSStagesResponse +from .types import ListVPCEndpointsRequest +from .types import ListVPCEndpointsResponse from .types import ListWafStagesRequest from .types import ListWafStagesResponse from .types import Plan @@ -145,6 +152,7 @@ "ListPurgeRequestsRequestOrderBy", "ListRouteStagesRequestOrderBy", "ListTLSStagesRequestOrderBy", + "ListVPCEndpointsRequestOrderBy", "ListWafStagesRequestOrderBy", "PipelineErrorCode", "PipelineErrorSeverity", @@ -189,6 +197,7 @@ "ListHeadStagesResponseHeadStage", "PipelineStages", "PurgeRequest", + "VPCEndpoint", "SetHeadStageRequestAddNewHeadStage", "SetHeadStageRequestRemoveHeadStage", "SetHeadStageRequestSwapHeadStage", @@ -208,6 +217,7 @@ "CreatePurgeRequestRequest", "CreateRouteStageRequest", "CreateTLSStageRequest", + "CreateVPCEndpointRequest", "CreateWafStageRequest", "DeleteBackendStageRequest", "DeleteCacheStageRequest", @@ -216,6 +226,7 @@ "DeletePipelineRequest", "DeleteRouteStageRequest", "DeleteTLSStageRequest", + "DeleteVPCEndpointRequest", "DeleteWafStageRequest", "GetBackendStageRequest", "GetBillingRequest", @@ -227,6 +238,7 @@ "GetPurgeRequestRequest", "GetRouteStageRequest", "GetTLSStageRequest", + "GetVPCEndpointRequest", "GetWafStageRequest", "HeadStageResponse", "ListBackendStagesRequest", @@ -250,6 +262,8 @@ "ListRouteStagesResponse", "ListTLSStagesRequest", "ListTLSStagesResponse", + "ListVPCEndpointsRequest", + "ListVPCEndpointsResponse", "ListWafStagesRequest", "ListWafStagesResponse", "Plan", diff --git a/scaleway-async/scaleway_async/edge_services/v1beta1/api.py b/scaleway-async/scaleway_async/edge_services/v1beta1/api.py index e4f926f5f..b42d15086 100644 --- a/scaleway-async/scaleway_async/edge_services/v1beta1/api.py +++ b/scaleway-async/scaleway_async/edge_services/v1beta1/api.py @@ -4,6 +4,9 @@ from typing import Awaitable, Optional, Union from scaleway_core.api import API +from scaleway_core.bridge import ( + Region as ScwRegion, +) from scaleway_core.utils import ( WaitForOptions, validate_path_param, @@ -19,6 +22,7 @@ ListPurgeRequestsRequestOrderBy, ListRouteStagesRequestOrderBy, ListTLSStagesRequestOrderBy, + ListVPCEndpointsRequestOrderBy, ListWafStagesRequestOrderBy, PlanName, SearchBackendStagesRequestOrderBy, @@ -43,6 +47,7 @@ CreatePurgeRequestRequest, CreateRouteStageRequest, CreateTLSStageRequest, + CreateVPCEndpointRequest, CreateWafStageRequest, DNSStage, GetBillingResponse, @@ -59,6 +64,7 @@ ListRouteRulesResponse, ListRouteStagesResponse, ListTLSStagesResponse, + ListVPCEndpointsResponse, ListWafStagesResponse, Pipeline, PipelineStages, @@ -88,6 +94,7 @@ UpdateRouteStageRequest, UpdateTLSStageRequest, UpdateWafStageRequest, + VPCEndpoint, WafStage, ) from .content import ( @@ -103,6 +110,7 @@ unmarshal_TLSStage, unmarshal_WafStage, unmarshal_PurgeRequest, + unmarshal_VPCEndpoint, unmarshal_AddRouteRulesResponse, unmarshal_CheckDomainResponse, unmarshal_CheckLbOriginResponse, @@ -120,6 +128,7 @@ unmarshal_ListRouteRulesResponse, unmarshal_ListRouteStagesResponse, unmarshal_ListTLSStagesResponse, + unmarshal_ListVPCEndpointsResponse, unmarshal_ListWafStagesResponse, unmarshal_Plan, unmarshal_SetRouteRulesResponse, @@ -134,6 +143,7 @@ marshal_CreatePurgeRequestRequest, marshal_CreateRouteStageRequest, marshal_CreateTLSStageRequest, + marshal_CreateVPCEndpointRequest, marshal_CreateWafStageRequest, marshal_SelectPlanRequest, marshal_SetHeadStageRequest, @@ -248,6 +258,7 @@ async def create_pipeline( name: str, description: str, project_id: Optional[str] = None, + vpc_endpoint_ids: Optional[list[str]] = None, ) -> Pipeline: """ Create pipeline. @@ -255,6 +266,7 @@ async def create_pipeline( :param name: Name of the pipeline. :param description: Description of the pipeline. :param project_id: Project ID in which the pipeline will be created. + :param vpc_endpoint_ids: :return: :class:`Pipeline ` Usage: @@ -274,6 +286,7 @@ async def create_pipeline( name=name, description=description, project_id=project_id, + vpc_endpoint_ids=vpc_endpoint_ids, ), self.client, ), @@ -434,6 +447,7 @@ async def update_pipeline( pipeline_id: str, name: Optional[str] = None, description: Optional[str] = None, + vpc_endpoint_ids: Optional[list[str]] = None, ) -> Pipeline: """ Update pipeline. @@ -441,6 +455,7 @@ async def update_pipeline( :param pipeline_id: ID of the pipeline to update. :param name: Name of the pipeline. :param description: Description of the pipeline. + :param vpc_endpoint_ids: :return: :class:`Pipeline ` Usage: @@ -461,6 +476,7 @@ async def update_pipeline( pipeline_id=pipeline_id, name=name, description=description, + vpc_endpoint_ids=vpc_endpoint_ids, ), self.client, ), @@ -496,6 +512,170 @@ async def delete_pipeline( self._throw_on_error(res) + async def get_vpc_endpoint( + self, + *, + vpc_endpoint_id: str, + ) -> VPCEndpoint: + """ + :param vpc_endpoint_id: + :return: :class:`VPCEndpoint ` + + Usage: + :: + + result = await api.get_vpc_endpoint( + vpc_endpoint_id="example", + ) + """ + + param_vpc_endpoint_id = validate_path_param("vpc_endpoint_id", vpc_endpoint_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/vpc-endpoints/{param_vpc_endpoint_id}", + ) + + self._throw_on_error(res) + return unmarshal_VPCEndpoint(res.json()) + + async def list_vpc_endpoints( + self, + *, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListVPCEndpointsRequestOrderBy] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + ) -> ListVPCEndpointsResponse: + """ + :param page: + :param page_size: + :param order_by: + :param project_id: + :param organization_id: + :return: :class:`ListVPCEndpointsResponse ` + + Usage: + :: + + result = await api.list_vpc_endpoints() + """ + + res = self._request( + "GET", + "/edge-services/v1beta1/vpc-endpoints", + params={ + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListVPCEndpointsResponse(res.json()) + + async def list_vpc_endpoints_all( + self, + *, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListVPCEndpointsRequestOrderBy] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + ) -> list[VPCEndpoint]: + """ + :param page: + :param page_size: + :param order_by: + :param project_id: + :param organization_id: + :return: :class:`list[VPCEndpoint] ` + + Usage: + :: + + result = await api.list_vpc_endpoints_all() + """ + + return await fetch_all_pages_async( + type=ListVPCEndpointsResponse, + key="vpc_endpoints", + fetcher=self.list_vpc_endpoints, + args={ + "page": page, + "page_size": page_size, + "order_by": order_by, + "project_id": project_id, + "organization_id": organization_id, + }, + ) + + async def create_vpc_endpoint( + self, + *, + private_network_id: str, + project_id: Optional[str] = None, + region: Optional[ScwRegion] = None, + ) -> VPCEndpoint: + """ + :param private_network_id: + :param project_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`VPCEndpoint ` + + Usage: + :: + + result = await api.create_vpc_endpoint( + private_network_id="example", + ) + """ + + res = self._request( + "POST", + "/edge-services/v1beta1/vpc-endpoints", + body=marshal_CreateVPCEndpointRequest( + CreateVPCEndpointRequest( + private_network_id=private_network_id, + project_id=project_id, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_VPCEndpoint(res.json()) + + async def delete_vpc_endpoint( + self, + *, + vpc_endpoint_id: str, + ) -> None: + """ + :param vpc_endpoint_id: + + Usage: + :: + + result = await api.delete_vpc_endpoint( + vpc_endpoint_id="example", + ) + """ + + param_vpc_endpoint_id = validate_path_param("vpc_endpoint_id", vpc_endpoint_id) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/vpc-endpoints/{param_vpc_endpoint_id}", + ) + + self._throw_on_error(res) + async def list_head_stages( self, *, @@ -704,6 +884,7 @@ async def create_dns_stage( backend_stage_id: Optional[str] = None, pipeline_id: str, wildcard_domain: Optional[bool] = None, + full_private: Optional[bool] = None, ) -> DNSStage: """ Create DNS stage. @@ -717,6 +898,7 @@ async def create_dns_stage( One-Of ('next'): at most one of 'tls_stage_id', 'cache_stage_id', 'backend_stage_id' could be set. :param pipeline_id: Pipeline ID the DNS stage belongs to. :param wildcard_domain: Support of wildcard (subdomains) for the given domain (a wildcard certificate is required to make it work). + :param full_private: When true, Fully Qualified Domain Names are accessible exclusively within the VPC. :return: :class:`DNSStage ` Usage: @@ -737,6 +919,7 @@ async def create_dns_stage( fqdns=fqdns, pipeline_id=pipeline_id, wildcard_domain=wildcard_domain, + full_private=full_private, tls_stage_id=tls_stage_id, cache_stage_id=cache_stage_id, backend_stage_id=backend_stage_id, @@ -786,6 +969,7 @@ async def update_dns_stage( cache_stage_id: Optional[str] = None, backend_stage_id: Optional[str] = None, wildcard_domain: Optional[bool] = None, + full_private: Optional[bool] = None, ) -> DNSStage: """ Update DNS stage. @@ -799,6 +983,7 @@ async def update_dns_stage( :param backend_stage_id: Backend stage ID the DNS stage will be linked to. One-Of ('next'): at most one of 'tls_stage_id', 'cache_stage_id', 'backend_stage_id' could be set. :param wildcard_domain: Support of wildcard (subdomains) for the given domain (a wildcard certificate is required to make it work). + :param full_private: When true, Fully Qualified Domain Names are accessible exclusively within the VPC. :return: :class:`DNSStage ` Usage: @@ -819,6 +1004,7 @@ async def update_dns_stage( dns_stage_id=dns_stage_id, fqdns=fqdns, wildcard_domain=wildcard_domain, + full_private=full_private, tls_stage_id=tls_stage_id, cache_stage_id=cache_stage_id, backend_stage_id=backend_stage_id, diff --git a/scaleway-async/scaleway_async/edge_services/v1beta1/marshalling.py b/scaleway-async/scaleway_async/edge_services/v1beta1/marshalling.py index dc2db3b83..0ffae9663 100644 --- a/scaleway-async/scaleway_async/edge_services/v1beta1/marshalling.py +++ b/scaleway-async/scaleway_async/edge_services/v1beta1/marshalling.py @@ -37,6 +37,7 @@ WafStage, PipelineStages, PurgeRequest, + VPCEndpoint, RuleHttpMatchHostFilter, RuleHttpMatchPathFilter, RuleHttpMatch, @@ -62,6 +63,7 @@ ListRouteRulesResponse, ListRouteStagesResponse, ListTLSStagesResponse, + ListVPCEndpointsResponse, ListWafStagesResponse, Plan, SetRouteRulesResponse, @@ -78,6 +80,7 @@ CreatePurgeRequestRequest, CreateRouteStageRequest, CreateTLSStageRequest, + CreateVPCEndpointRequest, CreateWafStageRequest, SelectPlanRequest, SetHeadStageRequestAddNewHeadStage, @@ -140,6 +143,12 @@ def unmarshal_ScalewayLb(data: Any) -> ScalewayLb: else: args["has_websocket"] = False + field = data.get("private_network_id", None) + if field is not None: + args["private_network_id"] = field + else: + args["private_network_id"] = None + return ScalewayLb(**args) @@ -401,6 +410,12 @@ def unmarshal_DNSStage(data: Any) -> DNSStage: else: args["default_fqdn"] = None + field = data.get("default_private_fqdn", None) + if field is not None: + args["default_private_fqdn"] = field + else: + args["default_private_fqdn"] = None + field = data.get("fqdns", None) if field is not None: args["fqdns"] = field @@ -431,6 +446,12 @@ def unmarshal_DNSStage(data: Any) -> DNSStage: else: args["wildcard_domain"] = False + field = data.get("full_private", None) + if field is not None: + args["full_private"] = field + else: + args["full_private"] = False + field = data.get("created_at", None) if field is not None: args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field @@ -557,6 +578,12 @@ def unmarshal_Pipeline(data: Any) -> Pipeline: else: args["organization_id"] = None + field = data.get("vpc_endpoint_ids", None) + if field is not None: + args["vpc_endpoint_ids"] = field + else: + args["vpc_endpoint_ids"] = [] + field = data.get("created_at", None) if field is not None: args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field @@ -912,6 +939,41 @@ def unmarshal_PurgeRequest(data: Any) -> PurgeRequest: return PurgeRequest(**args) +def unmarshal_VPCEndpoint(data: Any) -> VPCEndpoint: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'VPCEndpoint' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + else: + args["project_id"] = None + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = 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 VPCEndpoint(**args) + + def unmarshal_RuleHttpMatchHostFilter(data: Any) -> RuleHttpMatchHostFilter: if not isinstance(data, dict): raise TypeError( @@ -1597,6 +1659,31 @@ def unmarshal_ListTLSStagesResponse(data: Any) -> ListTLSStagesResponse: return ListTLSStagesResponse(**args) +def unmarshal_ListVPCEndpointsResponse(data: Any) -> ListVPCEndpointsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListVPCEndpointsResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = None + + field = data.get("vpc_endpoints", None) + if field is not None: + args["vpc_endpoints"] = ( + [unmarshal_VPCEndpoint(v) for v in field] if field is not None else None + ) + else: + args["vpc_endpoints"] = None + + return ListVPCEndpointsResponse(**args) + + def unmarshal_ListWafStagesResponse(data: Any) -> ListWafStagesResponse: if not isinstance(data, dict): raise TypeError( @@ -1821,6 +1908,9 @@ def marshal_ScalewayLb( if request.has_websocket is not None: output["has_websocket"] = request.has_websocket + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + return output @@ -2044,6 +2134,9 @@ def marshal_CreateDNSStageRequest( if request.wildcard_domain is not None: output["wildcard_domain"] = request.wildcard_domain + if request.full_private is not None: + output["full_private"] = request.full_private + return output @@ -2064,6 +2157,9 @@ def marshal_CreatePipelineRequest( else: output["project_id"] = defaults.default_project_id + if request.vpc_endpoint_ids is not None: + output["vpc_endpoint_ids"] = request.vpc_endpoint_ids + return output @@ -2170,6 +2266,28 @@ def marshal_CreateTLSStageRequest( return output +def marshal_CreateVPCEndpointRequest( + request: CreateVPCEndpointRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + + if request.project_id is not None: + output["project_id"] = request.project_id + else: + output["project_id"] = defaults.default_project_id + + if request.region is not None: + output["region"] = request.region + else: + output["region"] = defaults.default_region + + return output + + def marshal_CreateWafStageRequest( request: CreateWafStageRequest, defaults: ProfileDefaults, @@ -2400,6 +2518,9 @@ def marshal_UpdateDNSStageRequest( if request.wildcard_domain is not None: output["wildcard_domain"] = request.wildcard_domain + if request.full_private is not None: + output["full_private"] = request.full_private + return output @@ -2415,6 +2536,9 @@ def marshal_UpdatePipelineRequest( if request.description is not None: output["description"] = request.description + if request.vpc_endpoint_ids is not None: + output["vpc_endpoint_ids"] = request.vpc_endpoint_ids + return output diff --git a/scaleway-async/scaleway_async/edge_services/v1beta1/types.py b/scaleway-async/scaleway_async/edge_services/v1beta1/types.py index c0fcb66db..cae8cdb92 100644 --- a/scaleway-async/scaleway_async/edge_services/v1beta1/types.py +++ b/scaleway-async/scaleway_async/edge_services/v1beta1/types.py @@ -105,6 +105,16 @@ def __str__(self) -> str: return str(self.value) +class ListVPCEndpointsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + class ListWafStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_ASC = "created_at_asc" CREATED_AT_DESC = "created_at_desc" @@ -318,6 +328,8 @@ class ScalewayLb: Defines whether to forward websocket requests to the load balancer. """ + private_network_id: Optional[str] = None + @dataclass class RuleHttpMatchHostFilter: @@ -520,6 +532,7 @@ class DNSStage: Default Fully Qualified Domain Name attached to the stage. """ + default_private_fqdn: str fqdns: list[str] """ List of additional (custom) Fully Qualified Domain Names attached to the stage. @@ -545,6 +558,11 @@ class DNSStage: Support of wildcard (subdomains) for the given domain (a wildcard certificate is required to make it work). """ + full_private: bool + """ + Fully Qualified Domain Names are accessible exclusively within the VPC. + """ + created_at: Optional[datetime] = None """ Date the DNS stage was created. @@ -599,6 +617,7 @@ class Pipeline: Organization ID of the pipeline. """ + vpc_endpoint_ids: list[str] created_at: Optional[datetime] = None """ Date the pipeline was created. @@ -861,6 +880,18 @@ class PurgeRequest: all: Optional[bool] = False +@dataclass +class VPCEndpoint: + id: str + project_id: str + region: ScwRegion + """ + Region to target. If none is passed will use default region from the config. + """ + + private_network_id: str + + @dataclass class SetHeadStageRequestAddNewHeadStage: new_stage_id: str @@ -1010,6 +1041,11 @@ class CreateDNSStageRequest: Support of wildcard (subdomains) for the given domain (a wildcard certificate is required to make it work). """ + full_private: Optional[bool] = False + """ + When true, Fully Qualified Domain Names are accessible exclusively within the VPC. + """ + tls_stage_id: Optional[str] = None cache_stage_id: Optional[str] = None @@ -1034,6 +1070,8 @@ class CreatePipelineRequest: Project ID in which the pipeline will be created. """ + vpc_endpoint_ids: Optional[list[str]] = field(default_factory=list) + @dataclass class CreatePurgeRequestRequest: @@ -1085,6 +1123,16 @@ class CreateTLSStageRequest: waf_stage_id: Optional[str] = None +@dataclass +class CreateVPCEndpointRequest: + private_network_id: str + project_id: Optional[str] = None + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class CreateWafStageRequest: pipeline_id: str @@ -1158,6 +1206,11 @@ class DeleteTLSStageRequest: """ +@dataclass +class DeleteVPCEndpointRequest: + vpc_endpoint_id: str + + @dataclass class DeleteWafStageRequest: waf_stage_id: str @@ -1300,6 +1353,11 @@ class GetTLSStageRequest: """ +@dataclass +class GetVPCEndpointRequest: + vpc_endpoint_id: str + + @dataclass class GetWafStageRequest: waf_stage_id: str @@ -1711,6 +1769,21 @@ class ListTLSStagesResponse: """ +@dataclass +class ListVPCEndpointsRequest: + page: Optional[int] = None + page_size: Optional[int] = None + order_by: Optional[ListVPCEndpointsRequestOrderBy] = None + project_id: Optional[str] = None + organization_id: Optional[str] = None + + +@dataclass +class ListVPCEndpointsResponse: + total_count: int + vpc_endpoints: list[VPCEndpoint] + + @dataclass class ListWafStagesRequest: pipeline_id: str @@ -1891,6 +1964,11 @@ class UpdateDNSStageRequest: Support of wildcard (subdomains) for the given domain (a wildcard certificate is required to make it work). """ + full_private: Optional[bool] = False + """ + When true, Fully Qualified Domain Names are accessible exclusively within the VPC. + """ + tls_stage_id: Optional[str] = None cache_stage_id: Optional[str] = None @@ -1915,6 +1993,8 @@ class UpdatePipelineRequest: Description of the pipeline. """ + vpc_endpoint_ids: Optional[list[str]] = field(default_factory=list) + @dataclass class UpdateRouteStageRequest: diff --git a/scaleway/scaleway/edge_services/v1beta1/__init__.py b/scaleway/scaleway/edge_services/v1beta1/__init__.py index 2450691a7..d0f1b2d16 100644 --- a/scaleway/scaleway/edge_services/v1beta1/__init__.py +++ b/scaleway/scaleway/edge_services/v1beta1/__init__.py @@ -10,6 +10,7 @@ from .types import ListPurgeRequestsRequestOrderBy from .types import ListRouteStagesRequestOrderBy from .types import ListTLSStagesRequestOrderBy +from .types import ListVPCEndpointsRequestOrderBy from .types import ListWafStagesRequestOrderBy from .types import PipelineErrorCode from .types import PipelineErrorSeverity @@ -54,6 +55,7 @@ from .types import ListHeadStagesResponseHeadStage from .types import PipelineStages from .types import PurgeRequest +from .types import VPCEndpoint from .types import SetHeadStageRequestAddNewHeadStage from .types import SetHeadStageRequestRemoveHeadStage from .types import SetHeadStageRequestSwapHeadStage @@ -73,6 +75,7 @@ from .types import CreatePurgeRequestRequest from .types import CreateRouteStageRequest from .types import CreateTLSStageRequest +from .types import CreateVPCEndpointRequest from .types import CreateWafStageRequest from .types import DeleteBackendStageRequest from .types import DeleteCacheStageRequest @@ -81,6 +84,7 @@ from .types import DeletePipelineRequest from .types import DeleteRouteStageRequest from .types import DeleteTLSStageRequest +from .types import DeleteVPCEndpointRequest from .types import DeleteWafStageRequest from .types import GetBackendStageRequest from .types import GetBillingRequest @@ -92,6 +96,7 @@ from .types import GetPurgeRequestRequest from .types import GetRouteStageRequest from .types import GetTLSStageRequest +from .types import GetVPCEndpointRequest from .types import GetWafStageRequest from .types import HeadStageResponse from .types import ListBackendStagesRequest @@ -115,6 +120,8 @@ from .types import ListRouteStagesResponse from .types import ListTLSStagesRequest from .types import ListTLSStagesResponse +from .types import ListVPCEndpointsRequest +from .types import ListVPCEndpointsResponse from .types import ListWafStagesRequest from .types import ListWafStagesResponse from .types import Plan @@ -145,6 +152,7 @@ "ListPurgeRequestsRequestOrderBy", "ListRouteStagesRequestOrderBy", "ListTLSStagesRequestOrderBy", + "ListVPCEndpointsRequestOrderBy", "ListWafStagesRequestOrderBy", "PipelineErrorCode", "PipelineErrorSeverity", @@ -189,6 +197,7 @@ "ListHeadStagesResponseHeadStage", "PipelineStages", "PurgeRequest", + "VPCEndpoint", "SetHeadStageRequestAddNewHeadStage", "SetHeadStageRequestRemoveHeadStage", "SetHeadStageRequestSwapHeadStage", @@ -208,6 +217,7 @@ "CreatePurgeRequestRequest", "CreateRouteStageRequest", "CreateTLSStageRequest", + "CreateVPCEndpointRequest", "CreateWafStageRequest", "DeleteBackendStageRequest", "DeleteCacheStageRequest", @@ -216,6 +226,7 @@ "DeletePipelineRequest", "DeleteRouteStageRequest", "DeleteTLSStageRequest", + "DeleteVPCEndpointRequest", "DeleteWafStageRequest", "GetBackendStageRequest", "GetBillingRequest", @@ -227,6 +238,7 @@ "GetPurgeRequestRequest", "GetRouteStageRequest", "GetTLSStageRequest", + "GetVPCEndpointRequest", "GetWafStageRequest", "HeadStageResponse", "ListBackendStagesRequest", @@ -250,6 +262,8 @@ "ListRouteStagesResponse", "ListTLSStagesRequest", "ListTLSStagesResponse", + "ListVPCEndpointsRequest", + "ListVPCEndpointsResponse", "ListWafStagesRequest", "ListWafStagesResponse", "Plan", diff --git a/scaleway/scaleway/edge_services/v1beta1/api.py b/scaleway/scaleway/edge_services/v1beta1/api.py index 3de5e5a11..9ae01e2f7 100644 --- a/scaleway/scaleway/edge_services/v1beta1/api.py +++ b/scaleway/scaleway/edge_services/v1beta1/api.py @@ -4,6 +4,9 @@ from typing import Optional from scaleway_core.api import API +from scaleway_core.bridge import ( + Region as ScwRegion, +) from scaleway_core.utils import ( WaitForOptions, validate_path_param, @@ -19,6 +22,7 @@ ListPurgeRequestsRequestOrderBy, ListRouteStagesRequestOrderBy, ListTLSStagesRequestOrderBy, + ListVPCEndpointsRequestOrderBy, ListWafStagesRequestOrderBy, PlanName, SearchBackendStagesRequestOrderBy, @@ -43,6 +47,7 @@ CreatePurgeRequestRequest, CreateRouteStageRequest, CreateTLSStageRequest, + CreateVPCEndpointRequest, CreateWafStageRequest, DNSStage, GetBillingResponse, @@ -59,6 +64,7 @@ ListRouteRulesResponse, ListRouteStagesResponse, ListTLSStagesResponse, + ListVPCEndpointsResponse, ListWafStagesResponse, Pipeline, PipelineStages, @@ -88,6 +94,7 @@ UpdateRouteStageRequest, UpdateTLSStageRequest, UpdateWafStageRequest, + VPCEndpoint, WafStage, ) from .content import ( @@ -103,6 +110,7 @@ unmarshal_TLSStage, unmarshal_WafStage, unmarshal_PurgeRequest, + unmarshal_VPCEndpoint, unmarshal_AddRouteRulesResponse, unmarshal_CheckDomainResponse, unmarshal_CheckLbOriginResponse, @@ -120,6 +128,7 @@ unmarshal_ListRouteRulesResponse, unmarshal_ListRouteStagesResponse, unmarshal_ListTLSStagesResponse, + unmarshal_ListVPCEndpointsResponse, unmarshal_ListWafStagesResponse, unmarshal_Plan, unmarshal_SetRouteRulesResponse, @@ -134,6 +143,7 @@ marshal_CreatePurgeRequestRequest, marshal_CreateRouteStageRequest, marshal_CreateTLSStageRequest, + marshal_CreateVPCEndpointRequest, marshal_CreateWafStageRequest, marshal_SelectPlanRequest, marshal_SetHeadStageRequest, @@ -248,6 +258,7 @@ def create_pipeline( name: str, description: str, project_id: Optional[str] = None, + vpc_endpoint_ids: Optional[list[str]] = None, ) -> Pipeline: """ Create pipeline. @@ -255,6 +266,7 @@ def create_pipeline( :param name: Name of the pipeline. :param description: Description of the pipeline. :param project_id: Project ID in which the pipeline will be created. + :param vpc_endpoint_ids: :return: :class:`Pipeline ` Usage: @@ -274,6 +286,7 @@ def create_pipeline( name=name, description=description, project_id=project_id, + vpc_endpoint_ids=vpc_endpoint_ids, ), self.client, ), @@ -432,6 +445,7 @@ def update_pipeline( pipeline_id: str, name: Optional[str] = None, description: Optional[str] = None, + vpc_endpoint_ids: Optional[list[str]] = None, ) -> Pipeline: """ Update pipeline. @@ -439,6 +453,7 @@ def update_pipeline( :param pipeline_id: ID of the pipeline to update. :param name: Name of the pipeline. :param description: Description of the pipeline. + :param vpc_endpoint_ids: :return: :class:`Pipeline ` Usage: @@ -459,6 +474,7 @@ def update_pipeline( pipeline_id=pipeline_id, name=name, description=description, + vpc_endpoint_ids=vpc_endpoint_ids, ), self.client, ), @@ -494,6 +510,170 @@ def delete_pipeline( self._throw_on_error(res) + def get_vpc_endpoint( + self, + *, + vpc_endpoint_id: str, + ) -> VPCEndpoint: + """ + :param vpc_endpoint_id: + :return: :class:`VPCEndpoint ` + + Usage: + :: + + result = api.get_vpc_endpoint( + vpc_endpoint_id="example", + ) + """ + + param_vpc_endpoint_id = validate_path_param("vpc_endpoint_id", vpc_endpoint_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/vpc-endpoints/{param_vpc_endpoint_id}", + ) + + self._throw_on_error(res) + return unmarshal_VPCEndpoint(res.json()) + + def list_vpc_endpoints( + self, + *, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListVPCEndpointsRequestOrderBy] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + ) -> ListVPCEndpointsResponse: + """ + :param page: + :param page_size: + :param order_by: + :param project_id: + :param organization_id: + :return: :class:`ListVPCEndpointsResponse ` + + Usage: + :: + + result = api.list_vpc_endpoints() + """ + + res = self._request( + "GET", + "/edge-services/v1beta1/vpc-endpoints", + params={ + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListVPCEndpointsResponse(res.json()) + + def list_vpc_endpoints_all( + self, + *, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListVPCEndpointsRequestOrderBy] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + ) -> list[VPCEndpoint]: + """ + :param page: + :param page_size: + :param order_by: + :param project_id: + :param organization_id: + :return: :class:`list[VPCEndpoint] ` + + Usage: + :: + + result = api.list_vpc_endpoints_all() + """ + + return fetch_all_pages( + type=ListVPCEndpointsResponse, + key="vpc_endpoints", + fetcher=self.list_vpc_endpoints, + args={ + "page": page, + "page_size": page_size, + "order_by": order_by, + "project_id": project_id, + "organization_id": organization_id, + }, + ) + + def create_vpc_endpoint( + self, + *, + private_network_id: str, + project_id: Optional[str] = None, + region: Optional[ScwRegion] = None, + ) -> VPCEndpoint: + """ + :param private_network_id: + :param project_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`VPCEndpoint ` + + Usage: + :: + + result = api.create_vpc_endpoint( + private_network_id="example", + ) + """ + + res = self._request( + "POST", + "/edge-services/v1beta1/vpc-endpoints", + body=marshal_CreateVPCEndpointRequest( + CreateVPCEndpointRequest( + private_network_id=private_network_id, + project_id=project_id, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_VPCEndpoint(res.json()) + + def delete_vpc_endpoint( + self, + *, + vpc_endpoint_id: str, + ) -> None: + """ + :param vpc_endpoint_id: + + Usage: + :: + + result = api.delete_vpc_endpoint( + vpc_endpoint_id="example", + ) + """ + + param_vpc_endpoint_id = validate_path_param("vpc_endpoint_id", vpc_endpoint_id) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/vpc-endpoints/{param_vpc_endpoint_id}", + ) + + self._throw_on_error(res) + def list_head_stages( self, *, @@ -702,6 +882,7 @@ def create_dns_stage( backend_stage_id: Optional[str] = None, pipeline_id: str, wildcard_domain: Optional[bool] = None, + full_private: Optional[bool] = None, ) -> DNSStage: """ Create DNS stage. @@ -715,6 +896,7 @@ def create_dns_stage( One-Of ('next'): at most one of 'tls_stage_id', 'cache_stage_id', 'backend_stage_id' could be set. :param pipeline_id: Pipeline ID the DNS stage belongs to. :param wildcard_domain: Support of wildcard (subdomains) for the given domain (a wildcard certificate is required to make it work). + :param full_private: When true, Fully Qualified Domain Names are accessible exclusively within the VPC. :return: :class:`DNSStage ` Usage: @@ -735,6 +917,7 @@ def create_dns_stage( fqdns=fqdns, pipeline_id=pipeline_id, wildcard_domain=wildcard_domain, + full_private=full_private, tls_stage_id=tls_stage_id, cache_stage_id=cache_stage_id, backend_stage_id=backend_stage_id, @@ -784,6 +967,7 @@ def update_dns_stage( cache_stage_id: Optional[str] = None, backend_stage_id: Optional[str] = None, wildcard_domain: Optional[bool] = None, + full_private: Optional[bool] = None, ) -> DNSStage: """ Update DNS stage. @@ -797,6 +981,7 @@ def update_dns_stage( :param backend_stage_id: Backend stage ID the DNS stage will be linked to. One-Of ('next'): at most one of 'tls_stage_id', 'cache_stage_id', 'backend_stage_id' could be set. :param wildcard_domain: Support of wildcard (subdomains) for the given domain (a wildcard certificate is required to make it work). + :param full_private: When true, Fully Qualified Domain Names are accessible exclusively within the VPC. :return: :class:`DNSStage ` Usage: @@ -817,6 +1002,7 @@ def update_dns_stage( dns_stage_id=dns_stage_id, fqdns=fqdns, wildcard_domain=wildcard_domain, + full_private=full_private, tls_stage_id=tls_stage_id, cache_stage_id=cache_stage_id, backend_stage_id=backend_stage_id, diff --git a/scaleway/scaleway/edge_services/v1beta1/marshalling.py b/scaleway/scaleway/edge_services/v1beta1/marshalling.py index dc2db3b83..0ffae9663 100644 --- a/scaleway/scaleway/edge_services/v1beta1/marshalling.py +++ b/scaleway/scaleway/edge_services/v1beta1/marshalling.py @@ -37,6 +37,7 @@ WafStage, PipelineStages, PurgeRequest, + VPCEndpoint, RuleHttpMatchHostFilter, RuleHttpMatchPathFilter, RuleHttpMatch, @@ -62,6 +63,7 @@ ListRouteRulesResponse, ListRouteStagesResponse, ListTLSStagesResponse, + ListVPCEndpointsResponse, ListWafStagesResponse, Plan, SetRouteRulesResponse, @@ -78,6 +80,7 @@ CreatePurgeRequestRequest, CreateRouteStageRequest, CreateTLSStageRequest, + CreateVPCEndpointRequest, CreateWafStageRequest, SelectPlanRequest, SetHeadStageRequestAddNewHeadStage, @@ -140,6 +143,12 @@ def unmarshal_ScalewayLb(data: Any) -> ScalewayLb: else: args["has_websocket"] = False + field = data.get("private_network_id", None) + if field is not None: + args["private_network_id"] = field + else: + args["private_network_id"] = None + return ScalewayLb(**args) @@ -401,6 +410,12 @@ def unmarshal_DNSStage(data: Any) -> DNSStage: else: args["default_fqdn"] = None + field = data.get("default_private_fqdn", None) + if field is not None: + args["default_private_fqdn"] = field + else: + args["default_private_fqdn"] = None + field = data.get("fqdns", None) if field is not None: args["fqdns"] = field @@ -431,6 +446,12 @@ def unmarshal_DNSStage(data: Any) -> DNSStage: else: args["wildcard_domain"] = False + field = data.get("full_private", None) + if field is not None: + args["full_private"] = field + else: + args["full_private"] = False + field = data.get("created_at", None) if field is not None: args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field @@ -557,6 +578,12 @@ def unmarshal_Pipeline(data: Any) -> Pipeline: else: args["organization_id"] = None + field = data.get("vpc_endpoint_ids", None) + if field is not None: + args["vpc_endpoint_ids"] = field + else: + args["vpc_endpoint_ids"] = [] + field = data.get("created_at", None) if field is not None: args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field @@ -912,6 +939,41 @@ def unmarshal_PurgeRequest(data: Any) -> PurgeRequest: return PurgeRequest(**args) +def unmarshal_VPCEndpoint(data: Any) -> VPCEndpoint: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'VPCEndpoint' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + else: + args["project_id"] = None + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = 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 VPCEndpoint(**args) + + def unmarshal_RuleHttpMatchHostFilter(data: Any) -> RuleHttpMatchHostFilter: if not isinstance(data, dict): raise TypeError( @@ -1597,6 +1659,31 @@ def unmarshal_ListTLSStagesResponse(data: Any) -> ListTLSStagesResponse: return ListTLSStagesResponse(**args) +def unmarshal_ListVPCEndpointsResponse(data: Any) -> ListVPCEndpointsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListVPCEndpointsResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = None + + field = data.get("vpc_endpoints", None) + if field is not None: + args["vpc_endpoints"] = ( + [unmarshal_VPCEndpoint(v) for v in field] if field is not None else None + ) + else: + args["vpc_endpoints"] = None + + return ListVPCEndpointsResponse(**args) + + def unmarshal_ListWafStagesResponse(data: Any) -> ListWafStagesResponse: if not isinstance(data, dict): raise TypeError( @@ -1821,6 +1908,9 @@ def marshal_ScalewayLb( if request.has_websocket is not None: output["has_websocket"] = request.has_websocket + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + return output @@ -2044,6 +2134,9 @@ def marshal_CreateDNSStageRequest( if request.wildcard_domain is not None: output["wildcard_domain"] = request.wildcard_domain + if request.full_private is not None: + output["full_private"] = request.full_private + return output @@ -2064,6 +2157,9 @@ def marshal_CreatePipelineRequest( else: output["project_id"] = defaults.default_project_id + if request.vpc_endpoint_ids is not None: + output["vpc_endpoint_ids"] = request.vpc_endpoint_ids + return output @@ -2170,6 +2266,28 @@ def marshal_CreateTLSStageRequest( return output +def marshal_CreateVPCEndpointRequest( + request: CreateVPCEndpointRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + + if request.project_id is not None: + output["project_id"] = request.project_id + else: + output["project_id"] = defaults.default_project_id + + if request.region is not None: + output["region"] = request.region + else: + output["region"] = defaults.default_region + + return output + + def marshal_CreateWafStageRequest( request: CreateWafStageRequest, defaults: ProfileDefaults, @@ -2400,6 +2518,9 @@ def marshal_UpdateDNSStageRequest( if request.wildcard_domain is not None: output["wildcard_domain"] = request.wildcard_domain + if request.full_private is not None: + output["full_private"] = request.full_private + return output @@ -2415,6 +2536,9 @@ def marshal_UpdatePipelineRequest( if request.description is not None: output["description"] = request.description + if request.vpc_endpoint_ids is not None: + output["vpc_endpoint_ids"] = request.vpc_endpoint_ids + return output diff --git a/scaleway/scaleway/edge_services/v1beta1/types.py b/scaleway/scaleway/edge_services/v1beta1/types.py index c0fcb66db..cae8cdb92 100644 --- a/scaleway/scaleway/edge_services/v1beta1/types.py +++ b/scaleway/scaleway/edge_services/v1beta1/types.py @@ -105,6 +105,16 @@ def __str__(self) -> str: return str(self.value) +class ListVPCEndpointsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + class ListWafStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_ASC = "created_at_asc" CREATED_AT_DESC = "created_at_desc" @@ -318,6 +328,8 @@ class ScalewayLb: Defines whether to forward websocket requests to the load balancer. """ + private_network_id: Optional[str] = None + @dataclass class RuleHttpMatchHostFilter: @@ -520,6 +532,7 @@ class DNSStage: Default Fully Qualified Domain Name attached to the stage. """ + default_private_fqdn: str fqdns: list[str] """ List of additional (custom) Fully Qualified Domain Names attached to the stage. @@ -545,6 +558,11 @@ class DNSStage: Support of wildcard (subdomains) for the given domain (a wildcard certificate is required to make it work). """ + full_private: bool + """ + Fully Qualified Domain Names are accessible exclusively within the VPC. + """ + created_at: Optional[datetime] = None """ Date the DNS stage was created. @@ -599,6 +617,7 @@ class Pipeline: Organization ID of the pipeline. """ + vpc_endpoint_ids: list[str] created_at: Optional[datetime] = None """ Date the pipeline was created. @@ -861,6 +880,18 @@ class PurgeRequest: all: Optional[bool] = False +@dataclass +class VPCEndpoint: + id: str + project_id: str + region: ScwRegion + """ + Region to target. If none is passed will use default region from the config. + """ + + private_network_id: str + + @dataclass class SetHeadStageRequestAddNewHeadStage: new_stage_id: str @@ -1010,6 +1041,11 @@ class CreateDNSStageRequest: Support of wildcard (subdomains) for the given domain (a wildcard certificate is required to make it work). """ + full_private: Optional[bool] = False + """ + When true, Fully Qualified Domain Names are accessible exclusively within the VPC. + """ + tls_stage_id: Optional[str] = None cache_stage_id: Optional[str] = None @@ -1034,6 +1070,8 @@ class CreatePipelineRequest: Project ID in which the pipeline will be created. """ + vpc_endpoint_ids: Optional[list[str]] = field(default_factory=list) + @dataclass class CreatePurgeRequestRequest: @@ -1085,6 +1123,16 @@ class CreateTLSStageRequest: waf_stage_id: Optional[str] = None +@dataclass +class CreateVPCEndpointRequest: + private_network_id: str + project_id: Optional[str] = None + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class CreateWafStageRequest: pipeline_id: str @@ -1158,6 +1206,11 @@ class DeleteTLSStageRequest: """ +@dataclass +class DeleteVPCEndpointRequest: + vpc_endpoint_id: str + + @dataclass class DeleteWafStageRequest: waf_stage_id: str @@ -1300,6 +1353,11 @@ class GetTLSStageRequest: """ +@dataclass +class GetVPCEndpointRequest: + vpc_endpoint_id: str + + @dataclass class GetWafStageRequest: waf_stage_id: str @@ -1711,6 +1769,21 @@ class ListTLSStagesResponse: """ +@dataclass +class ListVPCEndpointsRequest: + page: Optional[int] = None + page_size: Optional[int] = None + order_by: Optional[ListVPCEndpointsRequestOrderBy] = None + project_id: Optional[str] = None + organization_id: Optional[str] = None + + +@dataclass +class ListVPCEndpointsResponse: + total_count: int + vpc_endpoints: list[VPCEndpoint] + + @dataclass class ListWafStagesRequest: pipeline_id: str @@ -1891,6 +1964,11 @@ class UpdateDNSStageRequest: Support of wildcard (subdomains) for the given domain (a wildcard certificate is required to make it work). """ + full_private: Optional[bool] = False + """ + When true, Fully Qualified Domain Names are accessible exclusively within the VPC. + """ + tls_stage_id: Optional[str] = None cache_stage_id: Optional[str] = None @@ -1915,6 +1993,8 @@ class UpdatePipelineRequest: Description of the pipeline. """ + vpc_endpoint_ids: Optional[list[str]] = field(default_factory=list) + @dataclass class UpdateRouteStageRequest: