diff --git a/scaleway-async/scaleway_async/edge_services/v1beta1/__init__.py b/scaleway-async/scaleway_async/edge_services/v1beta1/__init__.py new file mode 100644 index 000000000..88bf53a51 --- /dev/null +++ b/scaleway-async/scaleway_async/edge_services/v1beta1/__init__.py @@ -0,0 +1,253 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from .types import DNSStageType +from .types import LbOriginError +from .types import ListBackendStagesRequestOrderBy +from .types import ListCacheStagesRequestOrderBy +from .types import ListDNSStagesRequestOrderBy +from .types import ListPipelinesRequestOrderBy +from .types import ListPipelinesWithStagesRequestOrderBy +from .types import ListPurgeRequestsRequestOrderBy +from .types import ListRouteStagesRequestOrderBy +from .types import ListTLSStagesRequestOrderBy +from .types import ListWafStagesRequestOrderBy +from .types import PipelineErrorCode +from .types import PipelineErrorSeverity +from .types import PipelineErrorStage +from .types import PipelineErrorType +from .types import PipelineStatus +from .content import PIPELINE_TRANSIENT_STATUSES +from .types import PlanName +from .types import PurgeRequestStatus +from .content import PURGE_REQUEST_TRANSIENT_STATUSES +from .types import RuleHttpMatchMethodFilter +from .types import RuleHttpMatchPathFilterPathFilterType +from .types import SearchBackendStagesRequestOrderBy +from .types import WafStageMode +from .types import ScalewayLb +from .types import RuleHttpMatchPathFilter +from .types import ScalewayLbBackendConfig +from .types import ScalewayS3BackendConfig +from .types import PipelineError +from .types import TLSSecret +from .types import RuleHttpMatch +from .types import BackendStage +from .types import CacheStage +from .types import DNSStage +from .types import Pipeline +from .types import RouteStage +from .types import TLSStage +from .types import WafStage +from .types import SetRouteRulesRequestRouteRule +from .types import RouteRule +from .types import CheckPEMChainRequestSecretChain +from .types import PlanDetails +from .types import PlanUsageDetails +from .types import HeadStageResponseHeadStage +from .types import ListHeadStagesResponseHeadStage +from .types import PipelineStages +from .types import PurgeRequest +from .types import SetHeadStageRequestAddNewHeadStage +from .types import SetHeadStageRequestRemoveHeadStage +from .types import SetHeadStageRequestSwapHeadStage +from .types import TLSSecretsConfig +from .types import AddRouteRulesRequest +from .types import AddRouteRulesResponse +from .types import CheckDomainRequest +from .types import CheckDomainResponse +from .types import CheckLbOriginRequest +from .types import CheckLbOriginResponse +from .types import CheckPEMChainRequest +from .types import CheckPEMChainResponse +from .types import CreateBackendStageRequest +from .types import CreateCacheStageRequest +from .types import CreateDNSStageRequest +from .types import CreatePipelineRequest +from .types import CreatePurgeRequestRequest +from .types import CreateRouteStageRequest +from .types import CreateTLSStageRequest +from .types import CreateWafStageRequest +from .types import DeleteBackendStageRequest +from .types import DeleteCacheStageRequest +from .types import DeleteCurrentPlanRequest +from .types import DeleteDNSStageRequest +from .types import DeletePipelineRequest +from .types import DeleteRouteStageRequest +from .types import DeleteTLSStageRequest +from .types import DeleteWafStageRequest +from .types import GetBackendStageRequest +from .types import GetBillingRequest +from .types import GetBillingResponse +from .types import GetCacheStageRequest +from .types import GetCurrentPlanRequest +from .types import GetDNSStageRequest +from .types import GetPipelineRequest +from .types import GetPurgeRequestRequest +from .types import GetRouteStageRequest +from .types import GetTLSStageRequest +from .types import GetWafStageRequest +from .types import HeadStageResponse +from .types import ListBackendStagesRequest +from .types import ListBackendStagesResponse +from .types import ListCacheStagesRequest +from .types import ListCacheStagesResponse +from .types import ListDNSStagesRequest +from .types import ListDNSStagesResponse +from .types import ListHeadStagesRequest +from .types import ListHeadStagesResponse +from .types import ListPipelinesRequest +from .types import ListPipelinesResponse +from .types import ListPipelinesWithStagesRequest +from .types import ListPipelinesWithStagesResponse +from .types import ListPlansResponse +from .types import ListPurgeRequestsRequest +from .types import ListPurgeRequestsResponse +from .types import ListRouteRulesRequest +from .types import ListRouteRulesResponse +from .types import ListRouteStagesRequest +from .types import ListRouteStagesResponse +from .types import ListTLSStagesRequest +from .types import ListTLSStagesResponse +from .types import ListWafStagesRequest +from .types import ListWafStagesResponse +from .types import Plan +from .types import SearchBackendStagesRequest +from .types import SelectPlanRequest +from .types import SetHeadStageRequest +from .types import SetRouteRulesRequest +from .types import SetRouteRulesResponse +from .types import UpdateBackendStageRequest +from .types import UpdateCacheStageRequest +from .types import UpdateDNSStageRequest +from .types import UpdatePipelineRequest +from .types import UpdateRouteStageRequest +from .types import UpdateTLSStageRequest +from .types import UpdateWafStageRequest +from .api import EdgeServicesV1Beta1API + +__all__ = [ + "DNSStageType", + "LbOriginError", + "ListBackendStagesRequestOrderBy", + "ListCacheStagesRequestOrderBy", + "ListDNSStagesRequestOrderBy", + "ListPipelinesRequestOrderBy", + "ListPipelinesWithStagesRequestOrderBy", + "ListPurgeRequestsRequestOrderBy", + "ListRouteStagesRequestOrderBy", + "ListTLSStagesRequestOrderBy", + "ListWafStagesRequestOrderBy", + "PipelineErrorCode", + "PipelineErrorSeverity", + "PipelineErrorStage", + "PipelineErrorType", + "PipelineStatus", + "PIPELINE_TRANSIENT_STATUSES", + "PlanName", + "PurgeRequestStatus", + "PURGE_REQUEST_TRANSIENT_STATUSES", + "RuleHttpMatchMethodFilter", + "RuleHttpMatchPathFilterPathFilterType", + "SearchBackendStagesRequestOrderBy", + "WafStageMode", + "ScalewayLb", + "RuleHttpMatchPathFilter", + "ScalewayLbBackendConfig", + "ScalewayS3BackendConfig", + "PipelineError", + "TLSSecret", + "RuleHttpMatch", + "BackendStage", + "CacheStage", + "DNSStage", + "Pipeline", + "RouteStage", + "TLSStage", + "WafStage", + "SetRouteRulesRequestRouteRule", + "RouteRule", + "CheckPEMChainRequestSecretChain", + "PlanDetails", + "PlanUsageDetails", + "HeadStageResponseHeadStage", + "ListHeadStagesResponseHeadStage", + "PipelineStages", + "PurgeRequest", + "SetHeadStageRequestAddNewHeadStage", + "SetHeadStageRequestRemoveHeadStage", + "SetHeadStageRequestSwapHeadStage", + "TLSSecretsConfig", + "AddRouteRulesRequest", + "AddRouteRulesResponse", + "CheckDomainRequest", + "CheckDomainResponse", + "CheckLbOriginRequest", + "CheckLbOriginResponse", + "CheckPEMChainRequest", + "CheckPEMChainResponse", + "CreateBackendStageRequest", + "CreateCacheStageRequest", + "CreateDNSStageRequest", + "CreatePipelineRequest", + "CreatePurgeRequestRequest", + "CreateRouteStageRequest", + "CreateTLSStageRequest", + "CreateWafStageRequest", + "DeleteBackendStageRequest", + "DeleteCacheStageRequest", + "DeleteCurrentPlanRequest", + "DeleteDNSStageRequest", + "DeletePipelineRequest", + "DeleteRouteStageRequest", + "DeleteTLSStageRequest", + "DeleteWafStageRequest", + "GetBackendStageRequest", + "GetBillingRequest", + "GetBillingResponse", + "GetCacheStageRequest", + "GetCurrentPlanRequest", + "GetDNSStageRequest", + "GetPipelineRequest", + "GetPurgeRequestRequest", + "GetRouteStageRequest", + "GetTLSStageRequest", + "GetWafStageRequest", + "HeadStageResponse", + "ListBackendStagesRequest", + "ListBackendStagesResponse", + "ListCacheStagesRequest", + "ListCacheStagesResponse", + "ListDNSStagesRequest", + "ListDNSStagesResponse", + "ListHeadStagesRequest", + "ListHeadStagesResponse", + "ListPipelinesRequest", + "ListPipelinesResponse", + "ListPipelinesWithStagesRequest", + "ListPipelinesWithStagesResponse", + "ListPlansResponse", + "ListPurgeRequestsRequest", + "ListPurgeRequestsResponse", + "ListRouteRulesRequest", + "ListRouteRulesResponse", + "ListRouteStagesRequest", + "ListRouteStagesResponse", + "ListTLSStagesRequest", + "ListTLSStagesResponse", + "ListWafStagesRequest", + "ListWafStagesResponse", + "Plan", + "SearchBackendStagesRequest", + "SelectPlanRequest", + "SetHeadStageRequest", + "SetRouteRulesRequest", + "SetRouteRulesResponse", + "UpdateBackendStageRequest", + "UpdateCacheStageRequest", + "UpdateDNSStageRequest", + "UpdatePipelineRequest", + "UpdateRouteStageRequest", + "UpdateTLSStageRequest", + "UpdateWafStageRequest", + "EdgeServicesV1Beta1API", +] diff --git a/scaleway-async/scaleway_async/edge_services/v1beta1/api.py b/scaleway-async/scaleway_async/edge_services/v1beta1/api.py new file mode 100644 index 000000000..045850ee2 --- /dev/null +++ b/scaleway-async/scaleway_async/edge_services/v1beta1/api.py @@ -0,0 +1,2614 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Awaitable, List, Optional, Union + +from scaleway_core.api import API +from scaleway_core.utils import ( + WaitForOptions, + validate_path_param, + fetch_all_pages_async, + wait_for_resource_async, +) +from .types import ( + ListBackendStagesRequestOrderBy, + ListCacheStagesRequestOrderBy, + ListDNSStagesRequestOrderBy, + ListPipelinesRequestOrderBy, + ListPipelinesWithStagesRequestOrderBy, + ListPurgeRequestsRequestOrderBy, + ListRouteStagesRequestOrderBy, + ListTLSStagesRequestOrderBy, + ListWafStagesRequestOrderBy, + PlanName, + SearchBackendStagesRequestOrderBy, + WafStageMode, + AddRouteRulesRequest, + AddRouteRulesResponse, + BackendStage, + CacheStage, + CheckDomainRequest, + CheckDomainResponse, + CheckLbOriginRequest, + CheckLbOriginResponse, + CheckPEMChainRequest, + CheckPEMChainRequestSecretChain, + CheckPEMChainResponse, + CreateBackendStageRequest, + CreateCacheStageRequest, + CreateDNSStageRequest, + CreatePipelineRequest, + CreatePurgeRequestRequest, + CreateRouteStageRequest, + CreateTLSStageRequest, + CreateWafStageRequest, + DNSStage, + GetBillingResponse, + HeadStageResponse, + ListBackendStagesResponse, + ListCacheStagesResponse, + ListDNSStagesResponse, + ListHeadStagesResponse, + ListHeadStagesResponseHeadStage, + ListPipelinesResponse, + ListPipelinesWithStagesResponse, + ListPlansResponse, + ListPurgeRequestsResponse, + ListRouteRulesResponse, + ListRouteStagesResponse, + ListTLSStagesResponse, + ListWafStagesResponse, + Pipeline, + PipelineStages, + Plan, + PurgeRequest, + RouteStage, + ScalewayLb, + ScalewayLbBackendConfig, + ScalewayS3BackendConfig, + SelectPlanRequest, + SetHeadStageRequest, + SetHeadStageRequestAddNewHeadStage, + SetHeadStageRequestRemoveHeadStage, + SetHeadStageRequestSwapHeadStage, + SetRouteRulesRequest, + SetRouteRulesRequestRouteRule, + SetRouteRulesResponse, + TLSSecret, + TLSSecretsConfig, + TLSStage, + UpdateBackendStageRequest, + UpdateCacheStageRequest, + UpdateDNSStageRequest, + UpdatePipelineRequest, + UpdateRouteStageRequest, + UpdateTLSStageRequest, + UpdateWafStageRequest, + WafStage, +) +from .content import ( + PIPELINE_TRANSIENT_STATUSES, + PURGE_REQUEST_TRANSIENT_STATUSES, +) +from .marshalling import ( + unmarshal_BackendStage, + unmarshal_CacheStage, + unmarshal_DNSStage, + unmarshal_Pipeline, + unmarshal_RouteStage, + unmarshal_TLSStage, + unmarshal_WafStage, + unmarshal_PurgeRequest, + unmarshal_AddRouteRulesResponse, + unmarshal_CheckDomainResponse, + unmarshal_CheckLbOriginResponse, + unmarshal_CheckPEMChainResponse, + unmarshal_GetBillingResponse, + unmarshal_HeadStageResponse, + unmarshal_ListBackendStagesResponse, + unmarshal_ListCacheStagesResponse, + unmarshal_ListDNSStagesResponse, + unmarshal_ListHeadStagesResponse, + unmarshal_ListPipelinesResponse, + unmarshal_ListPipelinesWithStagesResponse, + unmarshal_ListPlansResponse, + unmarshal_ListPurgeRequestsResponse, + unmarshal_ListRouteRulesResponse, + unmarshal_ListRouteStagesResponse, + unmarshal_ListTLSStagesResponse, + unmarshal_ListWafStagesResponse, + unmarshal_Plan, + unmarshal_SetRouteRulesResponse, + marshal_AddRouteRulesRequest, + marshal_CheckDomainRequest, + marshal_CheckLbOriginRequest, + marshal_CheckPEMChainRequest, + marshal_CreateBackendStageRequest, + marshal_CreateCacheStageRequest, + marshal_CreateDNSStageRequest, + marshal_CreatePipelineRequest, + marshal_CreatePurgeRequestRequest, + marshal_CreateRouteStageRequest, + marshal_CreateTLSStageRequest, + marshal_CreateWafStageRequest, + marshal_SelectPlanRequest, + marshal_SetHeadStageRequest, + marshal_SetRouteRulesRequest, + marshal_UpdateBackendStageRequest, + marshal_UpdateCacheStageRequest, + marshal_UpdateDNSStageRequest, + marshal_UpdatePipelineRequest, + marshal_UpdateRouteStageRequest, + marshal_UpdateTLSStageRequest, + marshal_UpdateWafStageRequest, +) + + +class EdgeServicesV1Beta1API(API): + """ """ + + async def list_pipelines( + self, + *, + order_by: Optional[ListPipelinesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + has_backend_stage_lb: Optional[bool] = None, + ) -> ListPipelinesResponse: + """ + List pipelines. + List all pipelines, for a Scaleway Organization or Scaleway Project. By default, the pipelines returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of pipelines in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of pipelines to return per page. + :param name: Pipeline name to filter for. Only pipelines with this string within their name will be returned. + :param organization_id: Organization ID to filter for. Only pipelines from this Organization will be returned. + :param project_id: Project ID to filter for. Only pipelines from this Project will be returned. + :param has_backend_stage_lb: Filter on backend stage. Only pipelines with a Load Balancer origin will be returned. + :return: :class:`ListPipelinesResponse ` + + Usage: + :: + + result = await api.list_pipelines() + """ + + res = self._request( + "GET", + "/edge-services/v1beta1/pipelines", + params={ + "has_backend_stage_lb": has_backend_stage_lb, + "name": name, + "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_ListPipelinesResponse(res.json()) + + async def list_pipelines_all( + self, + *, + order_by: Optional[ListPipelinesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + has_backend_stage_lb: Optional[bool] = None, + ) -> List[Pipeline]: + """ + List pipelines. + List all pipelines, for a Scaleway Organization or Scaleway Project. By default, the pipelines returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of pipelines in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of pipelines to return per page. + :param name: Pipeline name to filter for. Only pipelines with this string within their name will be returned. + :param organization_id: Organization ID to filter for. Only pipelines from this Organization will be returned. + :param project_id: Project ID to filter for. Only pipelines from this Project will be returned. + :param has_backend_stage_lb: Filter on backend stage. Only pipelines with a Load Balancer origin will be returned. + :return: :class:`List[Pipeline] ` + + Usage: + :: + + result = await api.list_pipelines_all() + """ + + return await fetch_all_pages_async( + type=ListPipelinesResponse, + key="pipelines", + fetcher=self.list_pipelines, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "name": name, + "organization_id": organization_id, + "project_id": project_id, + "has_backend_stage_lb": has_backend_stage_lb, + }, + ) + + async def create_pipeline( + self, + *, + name: str, + description: str, + project_id: Optional[str] = None, + ) -> Pipeline: + """ + Create pipeline. + Create a new pipeline. You must specify a `dns_stage_id` to form a stage-chain that goes all the way to the backend stage (origin), so the HTTP request will be processed according to the stages you created. + :param name: Name of the pipeline. + :param description: Description of the pipeline. + :param project_id: Project ID in which the pipeline will be created. + :return: :class:`Pipeline ` + + Usage: + :: + + result = await api.create_pipeline( + name="example", + description="example", + ) + """ + + res = self._request( + "POST", + "/edge-services/v1beta1/pipelines", + body=marshal_CreatePipelineRequest( + CreatePipelineRequest( + name=name, + description=description, + project_id=project_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Pipeline(res.json()) + + async def get_pipeline( + self, + *, + pipeline_id: str, + ) -> Pipeline: + """ + Get pipeline. + Retrieve information about an existing pipeline, specified by its `pipeline_id`. Its full details, including errors, are returned in the response object. + :param pipeline_id: ID of the requested pipeline. + :return: :class:`Pipeline ` + + Usage: + :: + + result = await api.get_pipeline( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}", + ) + + self._throw_on_error(res) + return unmarshal_Pipeline(res.json()) + + async def wait_for_pipeline( + self, + *, + pipeline_id: str, + options: Optional[ + WaitForOptions[Pipeline, Union[bool, Awaitable[bool]]] + ] = None, + ) -> Pipeline: + """ + Get pipeline. + Retrieve information about an existing pipeline, specified by its `pipeline_id`. Its full details, including errors, are returned in the response object. + :param pipeline_id: ID of the requested pipeline. + :return: :class:`Pipeline ` + + Usage: + :: + + result = await api.get_pipeline( + pipeline_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in PIPELINE_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_pipeline, + options=options, + args={ + "pipeline_id": pipeline_id, + }, + ) + + async def list_pipelines_with_stages( + self, + *, + order_by: Optional[ListPipelinesWithStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + ) -> ListPipelinesWithStagesResponse: + """ + :param order_by: + :param page: + :param page_size: + :param name: + :param organization_id: + :param project_id: + :return: :class:`ListPipelinesWithStagesResponse ` + + Usage: + :: + + result = await api.list_pipelines_with_stages() + """ + + res = self._request( + "GET", + "/edge-services/v1beta1/pipelines-stages", + params={ + "name": name, + "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_ListPipelinesWithStagesResponse(res.json()) + + async def list_pipelines_with_stages_all( + self, + *, + order_by: Optional[ListPipelinesWithStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + ) -> List[PipelineStages]: + """ + :param order_by: + :param page: + :param page_size: + :param name: + :param organization_id: + :param project_id: + :return: :class:`List[PipelineStages] ` + + Usage: + :: + + result = await api.list_pipelines_with_stages_all() + """ + + return await fetch_all_pages_async( + type=ListPipelinesWithStagesResponse, + key="pipelines", + fetcher=self.list_pipelines_with_stages, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "name": name, + "organization_id": organization_id, + "project_id": project_id, + }, + ) + + async def update_pipeline( + self, + *, + pipeline_id: str, + name: Optional[str] = None, + description: Optional[str] = None, + ) -> Pipeline: + """ + Update pipeline. + Update the parameters of an existing pipeline, specified by its `pipeline_id`. Parameters which can be updated include the `name`, `description` and `dns_stage_id`. + :param pipeline_id: ID of the pipeline to update. + :param name: Name of the pipeline. + :param description: Description of the pipeline. + :return: :class:`Pipeline ` + + Usage: + :: + + result = await api.update_pipeline( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "PATCH", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}", + body=marshal_UpdatePipelineRequest( + UpdatePipelineRequest( + pipeline_id=pipeline_id, + name=name, + description=description, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Pipeline(res.json()) + + async def delete_pipeline( + self, + *, + pipeline_id: str, + ) -> None: + """ + Delete pipeline. + Delete an existing pipeline, specified by its `pipeline_id`. Deleting a pipeline is permanent, and cannot be undone. Note that all stages linked to the pipeline are also deleted. + :param pipeline_id: ID of the pipeline to delete. + + Usage: + :: + + result = await api.delete_pipeline( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}", + ) + + self._throw_on_error(res) + + async def list_head_stages( + self, + *, + pipeline_id: str, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListHeadStagesResponse: + """ + :param pipeline_id: ID of the pipeline to update. + :param page: Page number to return, from the paginated results. + :param page_size: Number of head stages to return per page. + :return: :class:`ListHeadStagesResponse ` + + Usage: + :: + + result = await api.list_head_stages( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/head-stages", + params={ + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListHeadStagesResponse(res.json()) + + async def list_head_stages_all( + self, + *, + pipeline_id: str, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ListHeadStagesResponseHeadStage]: + """ + :param pipeline_id: ID of the pipeline to update. + :param page: Page number to return, from the paginated results. + :param page_size: Number of head stages to return per page. + :return: :class:`List[ListHeadStagesResponseHeadStage] ` + + Usage: + :: + + result = await api.list_head_stages_all( + pipeline_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListHeadStagesResponse, + key="head_stages", + fetcher=self.list_head_stages, + args={ + "pipeline_id": pipeline_id, + "page": page, + "page_size": page_size, + }, + ) + + async def set_head_stage( + self, + *, + pipeline_id: str, + add_new_head_stage: Optional[SetHeadStageRequestAddNewHeadStage] = None, + remove_head_stage: Optional[SetHeadStageRequestRemoveHeadStage] = None, + swap_head_stage: Optional[SetHeadStageRequestSwapHeadStage] = None, + ) -> HeadStageResponse: + """ + Configure a entry point to your pipeline. You must specify a `head stage` to form a stage-chain that goes all the way to the backend stage (origin), so the HTTP request will be processed according to the stages you created. + You must specify either a `add_new_head_stage` (to add a new head stage), `remove_head_stage` (to remove a head stage) or `swap_head_stage` (to replace a head stage). + :param pipeline_id: ID of the pipeline to update. + :param add_new_head_stage: Add a new head stage. + One-Of ('action'): at most one of 'add_new_head_stage', 'remove_head_stage', 'swap_head_stage' could be set. + :param remove_head_stage: Remove a head stage. + One-Of ('action'): at most one of 'add_new_head_stage', 'remove_head_stage', 'swap_head_stage' could be set. + :param swap_head_stage: Replace a head stage with a new one. + One-Of ('action'): at most one of 'add_new_head_stage', 'remove_head_stage', 'swap_head_stage' could be set. + :return: :class:`HeadStageResponse ` + + Usage: + :: + + result = await api.set_head_stage( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/set-head-stage", + body=marshal_SetHeadStageRequest( + SetHeadStageRequest( + pipeline_id=pipeline_id, + add_new_head_stage=add_new_head_stage, + remove_head_stage=remove_head_stage, + swap_head_stage=swap_head_stage, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_HeadStageResponse(res.json()) + + async def list_dns_stages( + self, + *, + order_by: Optional[ListDNSStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + fqdn: Optional[str] = None, + ) -> ListDNSStagesResponse: + """ + List DNS stages. + List all DNS stages, for a Scaleway Organization or Scaleway Project. By default, the DNS stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of DNS stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of DNS stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only DNS stages from this pipeline will be returned. + :param fqdn: Fully Qualified Domain Name to filter for (in the format subdomain.example.com). Only DNS stages with this FQDN will be returned. + :return: :class:`ListDNSStagesResponse ` + + Usage: + :: + + result = await api.list_dns_stages( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/dns-stages", + params={ + "fqdn": fqdn, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListDNSStagesResponse(res.json()) + + async def list_dns_stages_all( + self, + *, + order_by: Optional[ListDNSStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + fqdn: Optional[str] = None, + ) -> List[DNSStage]: + """ + List DNS stages. + List all DNS stages, for a Scaleway Organization or Scaleway Project. By default, the DNS stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of DNS stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of DNS stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only DNS stages from this pipeline will be returned. + :param fqdn: Fully Qualified Domain Name to filter for (in the format subdomain.example.com). Only DNS stages with this FQDN will be returned. + :return: :class:`List[DNSStage] ` + + Usage: + :: + + result = await api.list_dns_stages_all( + pipeline_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListDNSStagesResponse, + key="stages", + fetcher=self.list_dns_stages, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "pipeline_id": pipeline_id, + "fqdn": fqdn, + }, + ) + + async def create_dns_stage( + self, + *, + fqdns: Optional[List[str]] = None, + tls_stage_id: Optional[str] = None, + cache_stage_id: Optional[str] = None, + backend_stage_id: Optional[str] = None, + pipeline_id: str, + ) -> DNSStage: + """ + Create DNS stage. + Create a new DNS stage. You must specify the `fqdns` field to customize the domain endpoint, using a domain you already own. + :param fqdns: Fully Qualified Domain Name (in the format subdomain.example.com) to attach to the stage. + :param tls_stage_id: TLS 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 cache_stage_id: Cache 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 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 pipeline_id: Pipeline ID the DNS stage belongs to. + :return: :class:`DNSStage ` + + Usage: + :: + + result = await api.create_dns_stage( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/dns-stages", + body=marshal_CreateDNSStageRequest( + CreateDNSStageRequest( + fqdns=fqdns, + pipeline_id=pipeline_id, + tls_stage_id=tls_stage_id, + cache_stage_id=cache_stage_id, + backend_stage_id=backend_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_DNSStage(res.json()) + + async def get_dns_stage( + self, + *, + dns_stage_id: str, + ) -> DNSStage: + """ + Get DNS stage. + Retrieve information about an existing DNS stage, specified by its `dns_stage_id`. Its full details, including FQDNs, are returned in the response object. + :param dns_stage_id: ID of the requested DNS stage. + :return: :class:`DNSStage ` + + Usage: + :: + + result = await api.get_dns_stage( + dns_stage_id="example", + ) + """ + + param_dns_stage_id = validate_path_param("dns_stage_id", dns_stage_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/dns-stages/{param_dns_stage_id}", + ) + + self._throw_on_error(res) + return unmarshal_DNSStage(res.json()) + + async def update_dns_stage( + self, + *, + dns_stage_id: str, + fqdns: Optional[List[str]] = None, + tls_stage_id: Optional[str] = None, + cache_stage_id: Optional[str] = None, + backend_stage_id: Optional[str] = None, + ) -> DNSStage: + """ + Update DNS stage. + Update the parameters of an existing DNS stage, specified by its `dns_stage_id`. + :param dns_stage_id: ID of the DNS stage to update. + :param fqdns: Fully Qualified Domain Name (in the format subdomain.example.com) attached to the stage. + :param tls_stage_id: TLS 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 cache_stage_id: Cache 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 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. + :return: :class:`DNSStage ` + + Usage: + :: + + result = await api.update_dns_stage( + dns_stage_id="example", + ) + """ + + param_dns_stage_id = validate_path_param("dns_stage_id", dns_stage_id) + + res = self._request( + "PATCH", + f"/edge-services/v1beta1/dns-stages/{param_dns_stage_id}", + body=marshal_UpdateDNSStageRequest( + UpdateDNSStageRequest( + dns_stage_id=dns_stage_id, + fqdns=fqdns, + tls_stage_id=tls_stage_id, + cache_stage_id=cache_stage_id, + backend_stage_id=backend_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_DNSStage(res.json()) + + async def delete_dns_stage( + self, + *, + dns_stage_id: str, + ) -> None: + """ + Delete DNS stage. + Delete an existing DNS stage, specified by its `dns_stage_id`. Deleting a DNS stage is permanent, and cannot be undone. + :param dns_stage_id: ID of the DNS stage to delete. + + Usage: + :: + + result = await api.delete_dns_stage( + dns_stage_id="example", + ) + """ + + param_dns_stage_id = validate_path_param("dns_stage_id", dns_stage_id) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/dns-stages/{param_dns_stage_id}", + ) + + self._throw_on_error(res) + + async def list_tls_stages( + self, + *, + order_by: Optional[ListTLSStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + secret_id: Optional[str] = None, + secret_region: Optional[str] = None, + ) -> ListTLSStagesResponse: + """ + List TLS stages. + List all TLS stages, for a Scaleway Organization or Scaleway Project. By default, the TLS stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of TLS stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of TLS stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only TLS stages from this pipeline will be returned. + :param secret_id: Secret ID to filter for. Only TLS stages with this Secret ID will be returned. + :param secret_region: Secret region to filter for. Only TLS stages with a Secret in this region will be returned. + :return: :class:`ListTLSStagesResponse ` + + Usage: + :: + + result = await api.list_tls_stages( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/tls-stages", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "secret_id": secret_id, + "secret_region": secret_region, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListTLSStagesResponse(res.json()) + + async def list_tls_stages_all( + self, + *, + order_by: Optional[ListTLSStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + secret_id: Optional[str] = None, + secret_region: Optional[str] = None, + ) -> List[TLSStage]: + """ + List TLS stages. + List all TLS stages, for a Scaleway Organization or Scaleway Project. By default, the TLS stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of TLS stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of TLS stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only TLS stages from this pipeline will be returned. + :param secret_id: Secret ID to filter for. Only TLS stages with this Secret ID will be returned. + :param secret_region: Secret region to filter for. Only TLS stages with a Secret in this region will be returned. + :return: :class:`List[TLSStage] ` + + Usage: + :: + + result = await api.list_tls_stages_all( + pipeline_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListTLSStagesResponse, + key="stages", + fetcher=self.list_tls_stages, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "pipeline_id": pipeline_id, + "secret_id": secret_id, + "secret_region": secret_region, + }, + ) + + async def create_tls_stage( + self, + *, + secrets: Optional[List[TLSSecret]] = None, + managed_certificate: Optional[bool] = None, + cache_stage_id: Optional[str] = None, + backend_stage_id: Optional[str] = None, + pipeline_id: str, + route_stage_id: Optional[str] = None, + waf_stage_id: Optional[str] = None, + ) -> TLSStage: + """ + Create TLS stage. + Create a new TLS stage. You must specify either the `secrets` or `managed_certificate` fields to customize the SSL/TLS certificate of your endpoint. Choose `secrets` if you are using a pre-existing certificate held in Scaleway Secret Manager, or `managed_certificate` to let Scaleway generate and manage a Let's Encrypt certificate for your customized endpoint. + :param secrets: Secret (from Scaleway Secret Manager) containing your custom certificate. + :param managed_certificate: True when Scaleway generates and manages a Let's Encrypt certificate for the TLS stage/custom endpoint. + :param cache_stage_id: Cache stage ID the TLS stage will be linked to. + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :param backend_stage_id: Backend stage ID the TLS stage will be linked to. + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :param pipeline_id: Pipeline ID the TLS stage belongs to. + :param route_stage_id: + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :param waf_stage_id: + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :return: :class:`TLSStage ` + + Usage: + :: + + result = await api.create_tls_stage( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/tls-stages", + body=marshal_CreateTLSStageRequest( + CreateTLSStageRequest( + secrets=secrets, + managed_certificate=managed_certificate, + pipeline_id=pipeline_id, + cache_stage_id=cache_stage_id, + backend_stage_id=backend_stage_id, + route_stage_id=route_stage_id, + waf_stage_id=waf_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_TLSStage(res.json()) + + async def get_tls_stage( + self, + *, + tls_stage_id: str, + ) -> TLSStage: + """ + Get TLS stage. + Retrieve information about an existing TLS stage, specified by its `tls_stage_id`. Its full details, including secrets and certificate expiration date are returned in the response object. + :param tls_stage_id: ID of the requested TLS stage. + :return: :class:`TLSStage ` + + Usage: + :: + + result = await api.get_tls_stage( + tls_stage_id="example", + ) + """ + + param_tls_stage_id = validate_path_param("tls_stage_id", tls_stage_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/tls-stages/{param_tls_stage_id}", + ) + + self._throw_on_error(res) + return unmarshal_TLSStage(res.json()) + + async def update_tls_stage( + self, + *, + tls_stage_id: str, + tls_secrets_config: Optional[TLSSecretsConfig] = None, + managed_certificate: Optional[bool] = None, + cache_stage_id: Optional[str] = None, + backend_stage_id: Optional[str] = None, + route_stage_id: Optional[str] = None, + waf_stage_id: Optional[str] = None, + ) -> TLSStage: + """ + Update TLS stage. + Update the parameters of an existing TLS stage, specified by its `tls_stage_id`. Both `tls_secrets_config` and `managed_certificate` parameters can be updated. + :param tls_stage_id: ID of the TLS stage to update. + :param tls_secrets_config: Secret (from Scaleway Secret-Manager) containing your custom certificate. + :param managed_certificate: True when Scaleway generates and manages a Let's Encrypt certificate for the TLS stage/custom endpoint. + :param cache_stage_id: Cache stage ID the TLS stage will be linked to. + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :param backend_stage_id: Backend stage ID the TLS stage will be linked to. + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :param route_stage_id: + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :param waf_stage_id: + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :return: :class:`TLSStage ` + + Usage: + :: + + result = await api.update_tls_stage( + tls_stage_id="example", + ) + """ + + param_tls_stage_id = validate_path_param("tls_stage_id", tls_stage_id) + + res = self._request( + "PATCH", + f"/edge-services/v1beta1/tls-stages/{param_tls_stage_id}", + body=marshal_UpdateTLSStageRequest( + UpdateTLSStageRequest( + tls_stage_id=tls_stage_id, + tls_secrets_config=tls_secrets_config, + managed_certificate=managed_certificate, + cache_stage_id=cache_stage_id, + backend_stage_id=backend_stage_id, + route_stage_id=route_stage_id, + waf_stage_id=waf_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_TLSStage(res.json()) + + async def delete_tls_stage( + self, + *, + tls_stage_id: str, + ) -> None: + """ + Delete TLS stage. + Delete an existing TLS stage, specified by its `tls_stage_id`. Deleting a TLS stage is permanent, and cannot be undone. + :param tls_stage_id: ID of the TLS stage to delete. + + Usage: + :: + + result = await api.delete_tls_stage( + tls_stage_id="example", + ) + """ + + param_tls_stage_id = validate_path_param("tls_stage_id", tls_stage_id) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/tls-stages/{param_tls_stage_id}", + ) + + self._throw_on_error(res) + + async def list_cache_stages( + self, + *, + order_by: Optional[ListCacheStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + ) -> ListCacheStagesResponse: + """ + List cache stages. + List all cache stages, for a Scaleway Organization or Scaleway Project. By default, the cache stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of cache stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of cache stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only cache stages from this pipeline will be returned. + :return: :class:`ListCacheStagesResponse ` + + Usage: + :: + + result = await api.list_cache_stages( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/cache-stages", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListCacheStagesResponse(res.json()) + + async def list_cache_stages_all( + self, + *, + order_by: Optional[ListCacheStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + ) -> List[CacheStage]: + """ + List cache stages. + List all cache stages, for a Scaleway Organization or Scaleway Project. By default, the cache stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of cache stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of cache stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only cache stages from this pipeline will be returned. + :return: :class:`List[CacheStage] ` + + Usage: + :: + + result = await api.list_cache_stages_all( + pipeline_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListCacheStagesResponse, + key="stages", + fetcher=self.list_cache_stages, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "pipeline_id": pipeline_id, + }, + ) + + async def create_cache_stage( + self, + *, + fallback_ttl: Optional[str] = None, + backend_stage_id: Optional[str] = None, + pipeline_id: str, + waf_stage_id: Optional[str] = None, + route_stage_id: Optional[str] = None, + ) -> CacheStage: + """ + Create cache stage. + Create a new cache stage. You must specify the `fallback_ttl` field to customize the TTL of the cache. + :param fallback_ttl: Time To Live (TTL) in seconds. Defines how long content is cached. + :param backend_stage_id: Backend stage ID the cache stage will be linked to. + One-Of ('next'): at most one of 'backend_stage_id', 'waf_stage_id', 'route_stage_id' could be set. + :param pipeline_id: Pipeline ID the Cache stage belongs to. + :param waf_stage_id: + One-Of ('next'): at most one of 'backend_stage_id', 'waf_stage_id', 'route_stage_id' could be set. + :param route_stage_id: + One-Of ('next'): at most one of 'backend_stage_id', 'waf_stage_id', 'route_stage_id' could be set. + :return: :class:`CacheStage ` + + Usage: + :: + + result = await api.create_cache_stage( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/cache-stages", + body=marshal_CreateCacheStageRequest( + CreateCacheStageRequest( + fallback_ttl=fallback_ttl, + pipeline_id=pipeline_id, + backend_stage_id=backend_stage_id, + waf_stage_id=waf_stage_id, + route_stage_id=route_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CacheStage(res.json()) + + async def get_cache_stage( + self, + *, + cache_stage_id: str, + ) -> CacheStage: + """ + Get cache stage. + Retrieve information about an existing cache stage, specified by its `cache_stage_id`. Its full details, including Time To Live (TTL), are returned in the response object. + :param cache_stage_id: ID of the requested cache stage. + :return: :class:`CacheStage ` + + Usage: + :: + + result = await api.get_cache_stage( + cache_stage_id="example", + ) + """ + + param_cache_stage_id = validate_path_param("cache_stage_id", cache_stage_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/cache-stages/{param_cache_stage_id}", + ) + + self._throw_on_error(res) + return unmarshal_CacheStage(res.json()) + + async def update_cache_stage( + self, + *, + cache_stage_id: str, + fallback_ttl: Optional[str] = None, + backend_stage_id: Optional[str] = None, + waf_stage_id: Optional[str] = None, + route_stage_id: Optional[str] = None, + ) -> CacheStage: + """ + Update cache stage. + Update the parameters of an existing cache stage, specified by its `cache_stage_id`. Parameters which can be updated include the `fallback_ttl` and `backend_stage_id`. + :param cache_stage_id: ID of the cache stage to update. + :param fallback_ttl: Time To Live (TTL) in seconds. Defines how long content is cached. + :param backend_stage_id: Backend stage ID the cache stage will be linked to. + One-Of ('next'): at most one of 'backend_stage_id', 'waf_stage_id', 'route_stage_id' could be set. + :param waf_stage_id: + One-Of ('next'): at most one of 'backend_stage_id', 'waf_stage_id', 'route_stage_id' could be set. + :param route_stage_id: + One-Of ('next'): at most one of 'backend_stage_id', 'waf_stage_id', 'route_stage_id' could be set. + :return: :class:`CacheStage ` + + Usage: + :: + + result = await api.update_cache_stage( + cache_stage_id="example", + ) + """ + + param_cache_stage_id = validate_path_param("cache_stage_id", cache_stage_id) + + res = self._request( + "PATCH", + f"/edge-services/v1beta1/cache-stages/{param_cache_stage_id}", + body=marshal_UpdateCacheStageRequest( + UpdateCacheStageRequest( + cache_stage_id=cache_stage_id, + fallback_ttl=fallback_ttl, + backend_stage_id=backend_stage_id, + waf_stage_id=waf_stage_id, + route_stage_id=route_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CacheStage(res.json()) + + async def delete_cache_stage( + self, + *, + cache_stage_id: str, + ) -> None: + """ + Delete cache stage. + Delete an existing cache stage, specified by its `cache_stage_id`. Deleting a cache stage is permanent, and cannot be undone. + :param cache_stage_id: ID of the cache stage to delete. + + Usage: + :: + + result = await api.delete_cache_stage( + cache_stage_id="example", + ) + """ + + param_cache_stage_id = validate_path_param("cache_stage_id", cache_stage_id) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/cache-stages/{param_cache_stage_id}", + ) + + self._throw_on_error(res) + + async def list_backend_stages( + self, + *, + order_by: Optional[ListBackendStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + bucket_name: Optional[str] = None, + bucket_region: Optional[str] = None, + lb_id: Optional[str] = None, + ) -> ListBackendStagesResponse: + """ + List backend stages. + List all backend stages, for a Scaleway Organization or Scaleway Project. By default, the backend stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of backend stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of backend stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only backend stages from this pipeline will be returned. + :param bucket_name: Bucket name to filter for. Only backend stages from this Bucket will be returned. + :param bucket_region: Bucket region to filter for. Only backend stages with buckets in this region will be returned. + :param lb_id: Load Balancer ID to filter for. Only backend stages with this Load Balancer will be returned. + :return: :class:`ListBackendStagesResponse ` + + Usage: + :: + + result = await api.list_backend_stages( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/backend-stages", + params={ + "bucket_name": bucket_name, + "bucket_region": bucket_region, + "lb_id": lb_id, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListBackendStagesResponse(res.json()) + + async def list_backend_stages_all( + self, + *, + order_by: Optional[ListBackendStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + bucket_name: Optional[str] = None, + bucket_region: Optional[str] = None, + lb_id: Optional[str] = None, + ) -> List[BackendStage]: + """ + List backend stages. + List all backend stages, for a Scaleway Organization or Scaleway Project. By default, the backend stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of backend stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of backend stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only backend stages from this pipeline will be returned. + :param bucket_name: Bucket name to filter for. Only backend stages from this Bucket will be returned. + :param bucket_region: Bucket region to filter for. Only backend stages with buckets in this region will be returned. + :param lb_id: Load Balancer ID to filter for. Only backend stages with this Load Balancer will be returned. + :return: :class:`List[BackendStage] ` + + Usage: + :: + + result = await api.list_backend_stages_all( + pipeline_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListBackendStagesResponse, + key="stages", + fetcher=self.list_backend_stages, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "pipeline_id": pipeline_id, + "bucket_name": bucket_name, + "bucket_region": bucket_region, + "lb_id": lb_id, + }, + ) + + async def create_backend_stage( + self, + *, + scaleway_s3: Optional[ScalewayS3BackendConfig] = None, + scaleway_lb: Optional[ScalewayLbBackendConfig] = None, + pipeline_id: str, + ) -> BackendStage: + """ + Create backend stage. + Create a new backend stage. You must specify either a `scaleway_s3` (for a Scaleway Object Storage bucket) or `scaleway_lb` (for a Scaleway Load Balancer) field to configure the origin. + :param scaleway_s3: Scaleway Object Storage origin bucket (S3) linked to the backend stage. + One-Of ('backend_config'): at most one of 'scaleway_s3', 'scaleway_lb' could be set. + :param scaleway_lb: Scaleway Load Balancer origin linked to the backend stage. + One-Of ('backend_config'): at most one of 'scaleway_s3', 'scaleway_lb' could be set. + :param pipeline_id: Pipeline ID the Backend stage belongs to. + :return: :class:`BackendStage ` + + Usage: + :: + + result = await api.create_backend_stage( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/backend-stages", + body=marshal_CreateBackendStageRequest( + CreateBackendStageRequest( + pipeline_id=pipeline_id, + scaleway_s3=scaleway_s3, + scaleway_lb=scaleway_lb, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_BackendStage(res.json()) + + async def get_backend_stage( + self, + *, + backend_stage_id: str, + ) -> BackendStage: + """ + Get backend stage. + Retrieve information about an existing backend stage, specified by its `backend_stage_id`. Its full details, including `scaleway_s3` or `scaleway_lb`, are returned in the response object. + :param backend_stage_id: ID of the requested backend stage. + :return: :class:`BackendStage ` + + Usage: + :: + + result = await api.get_backend_stage( + backend_stage_id="example", + ) + """ + + param_backend_stage_id = validate_path_param( + "backend_stage_id", backend_stage_id + ) + + res = self._request( + "GET", + f"/edge-services/v1beta1/backend-stages/{param_backend_stage_id}", + ) + + self._throw_on_error(res) + return unmarshal_BackendStage(res.json()) + + async def update_backend_stage( + self, + *, + backend_stage_id: str, + pipeline_id: str, + scaleway_s3: Optional[ScalewayS3BackendConfig] = None, + scaleway_lb: Optional[ScalewayLbBackendConfig] = None, + ) -> BackendStage: + """ + Update backend stage. + Update the parameters of an existing backend stage, specified by its `backend_stage_id`. + :param backend_stage_id: ID of the backend stage to update. + :param pipeline_id: Pipeline ID the Backend stage belongs to. + :param scaleway_s3: Scaleway Object Storage origin bucket (S3) linked to the backend stage. + One-Of ('backend_config'): at most one of 'scaleway_s3', 'scaleway_lb' could be set. + :param scaleway_lb: Scaleway Load Balancer origin linked to the backend stage. + One-Of ('backend_config'): at most one of 'scaleway_s3', 'scaleway_lb' could be set. + :return: :class:`BackendStage ` + + Usage: + :: + + result = await api.update_backend_stage( + backend_stage_id="example", + pipeline_id="example", + ) + """ + + param_backend_stage_id = validate_path_param( + "backend_stage_id", backend_stage_id + ) + + res = self._request( + "PATCH", + f"/edge-services/v1beta1/backend-stages/{param_backend_stage_id}", + body=marshal_UpdateBackendStageRequest( + UpdateBackendStageRequest( + backend_stage_id=backend_stage_id, + pipeline_id=pipeline_id, + scaleway_s3=scaleway_s3, + scaleway_lb=scaleway_lb, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_BackendStage(res.json()) + + async def delete_backend_stage( + self, + *, + backend_stage_id: str, + ) -> None: + """ + Delete backend stage. + Delete an existing backend stage, specified by its `backend_stage_id`. Deleting a backend stage is permanent, and cannot be undone. + :param backend_stage_id: ID of the backend stage to delete. + + Usage: + :: + + result = await api.delete_backend_stage( + backend_stage_id="example", + ) + """ + + param_backend_stage_id = validate_path_param( + "backend_stage_id", backend_stage_id + ) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/backend-stages/{param_backend_stage_id}", + ) + + self._throw_on_error(res) + + async def list_waf_stages( + self, + *, + order_by: Optional[ListWafStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + ) -> ListWafStagesResponse: + """ + List WAF stages. + List all WAF stages, for a Scaleway Organization or Scaleway Project. By default, the WAF stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of WAF stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of WAF stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only WAF stages from this pipeline will be returned. + :return: :class:`ListWafStagesResponse ` + + Usage: + :: + + result = await api.list_waf_stages( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/waf-stages", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListWafStagesResponse(res.json()) + + async def list_waf_stages_all( + self, + *, + order_by: Optional[ListWafStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + ) -> List[WafStage]: + """ + List WAF stages. + List all WAF stages, for a Scaleway Organization or Scaleway Project. By default, the WAF stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of WAF stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of WAF stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only WAF stages from this pipeline will be returned. + :return: :class:`List[WafStage] ` + + Usage: + :: + + result = await api.list_waf_stages_all( + pipeline_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListWafStagesResponse, + key="stages", + fetcher=self.list_waf_stages, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "pipeline_id": pipeline_id, + }, + ) + + async def create_waf_stage( + self, + *, + pipeline_id: str, + paranoia_level: int, + mode: Optional[WafStageMode] = None, + backend_stage_id: Optional[str] = None, + ) -> WafStage: + """ + Create WAF stage. + Create a new WAF stage. You must specify the `mode` and `paranoia_level` fields to customize the WAF. + :param pipeline_id: Pipeline ID the WAF stage belongs to. + :param paranoia_level: Sensitivity level (`1`,`2`,`3`,`4`) to use when classifying requests as malicious. With a high level, requests are more likely to be classed as malicious, and false positives are expected. With a lower level, requests are more likely to be classed as benign. + :param mode: Mode defining WAF behavior (`disable`/`log_only`/`enable`). + :param backend_stage_id: ID of the backend stage to forward requests to after the WAF stage. + One-Of ('next'): at most one of 'backend_stage_id' could be set. + :return: :class:`WafStage ` + + Usage: + :: + + result = await api.create_waf_stage( + pipeline_id="example", + paranoia_level=1, + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/waf-stages", + body=marshal_CreateWafStageRequest( + CreateWafStageRequest( + pipeline_id=pipeline_id, + paranoia_level=paranoia_level, + mode=mode, + backend_stage_id=backend_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_WafStage(res.json()) + + async def get_waf_stage( + self, + *, + waf_stage_id: str, + ) -> WafStage: + """ + Get WAF stage. + Retrieve information about an existing WAF stage, specified by its `waf_stage_id`. Its full details are returned in the response object. + :param waf_stage_id: ID of the requested WAF stage. + :return: :class:`WafStage ` + + Usage: + :: + + result = await api.get_waf_stage( + waf_stage_id="example", + ) + """ + + param_waf_stage_id = validate_path_param("waf_stage_id", waf_stage_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/waf-stages/{param_waf_stage_id}", + ) + + self._throw_on_error(res) + return unmarshal_WafStage(res.json()) + + async def update_waf_stage( + self, + *, + waf_stage_id: str, + mode: Optional[WafStageMode] = None, + paranoia_level: Optional[int] = None, + backend_stage_id: Optional[str] = None, + ) -> WafStage: + """ + Update WAF stage. + Update the parameters of an existing WAF stage, specified by its `waf_stage_id`. Both `mode` and `paranoia_level` parameters can be updated. + :param waf_stage_id: ID of the WAF stage to update. + :param mode: Mode defining WAF behavior (`disable`/`log_only`/`enable`). + :param paranoia_level: Sensitivity level (`1`,`2`,`3`,`4`) to use when classifying requests as malicious. With a high level, requests are more likely to be classed as malicious, and false positives are expected. With a lower level, requests are more likely to be classed as benign. + :param backend_stage_id: ID of the backend stage to forward requests to after the WAF stage. + One-Of ('next'): at most one of 'backend_stage_id' could be set. + :return: :class:`WafStage ` + + Usage: + :: + + result = await api.update_waf_stage( + waf_stage_id="example", + ) + """ + + param_waf_stage_id = validate_path_param("waf_stage_id", waf_stage_id) + + res = self._request( + "PATCH", + f"/edge-services/v1beta1/waf-stages/{param_waf_stage_id}", + body=marshal_UpdateWafStageRequest( + UpdateWafStageRequest( + waf_stage_id=waf_stage_id, + mode=mode, + paranoia_level=paranoia_level, + backend_stage_id=backend_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_WafStage(res.json()) + + async def delete_waf_stage( + self, + *, + waf_stage_id: str, + ) -> None: + """ + Delete WAF stage. + Delete an existing WAF stage, specified by its `waf_stage_id`. Deleting a WAF stage is permanent, and cannot be undone. + :param waf_stage_id: ID of the WAF stage to delete. + + Usage: + :: + + result = await api.delete_waf_stage( + waf_stage_id="example", + ) + """ + + param_waf_stage_id = validate_path_param("waf_stage_id", waf_stage_id) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/waf-stages/{param_waf_stage_id}", + ) + + self._throw_on_error(res) + + async def list_route_stages( + self, + *, + order_by: Optional[ListRouteStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + ) -> ListRouteStagesResponse: + """ + List route stages. + List all route stages, for a given pipeline. By default, the route stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of route stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of route stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only route stages from this pipeline will be returned. + :return: :class:`ListRouteStagesResponse ` + + Usage: + :: + + result = await api.list_route_stages( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/route-stages", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListRouteStagesResponse(res.json()) + + async def list_route_stages_all( + self, + *, + order_by: Optional[ListRouteStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + ) -> List[RouteStage]: + """ + List route stages. + List all route stages, for a given pipeline. By default, the route stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of route stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of route stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only route stages from this pipeline will be returned. + :return: :class:`List[RouteStage] ` + + Usage: + :: + + result = await api.list_route_stages_all( + pipeline_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListRouteStagesResponse, + key="stages", + fetcher=self.list_route_stages, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "pipeline_id": pipeline_id, + }, + ) + + async def create_route_stage( + self, + *, + pipeline_id: str, + waf_stage_id: Optional[str] = None, + ) -> RouteStage: + """ + Create route stage. + Create a new route stage. You must specify the `waf_stage_id` field to customize the route. + :param pipeline_id: Pipeline ID the route stage belongs to. + :param waf_stage_id: ID of the WAF stage HTTP requests should be forwarded to when no rules are matched. + One-Of ('next'): at most one of 'waf_stage_id' could be set. + :return: :class:`RouteStage ` + + Usage: + :: + + result = await api.create_route_stage( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/route-stages", + body=marshal_CreateRouteStageRequest( + CreateRouteStageRequest( + pipeline_id=pipeline_id, + waf_stage_id=waf_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_RouteStage(res.json()) + + async def get_route_stage( + self, + *, + route_stage_id: str, + ) -> RouteStage: + """ + Get route stage. + Retrieve information about an existing route stage, specified by its `route_stage_id`. The summary of the route stage (without route rules) is returned in the response object. + :param route_stage_id: ID of the requested route stage. + :return: :class:`RouteStage ` + + Usage: + :: + + result = await api.get_route_stage( + route_stage_id="example", + ) + """ + + param_route_stage_id = validate_path_param("route_stage_id", route_stage_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/route-stages/{param_route_stage_id}", + ) + + self._throw_on_error(res) + return unmarshal_RouteStage(res.json()) + + async def update_route_stage( + self, + *, + route_stage_id: str, + waf_stage_id: Optional[str] = None, + ) -> RouteStage: + """ + Update route stage. + Update the parameters of an existing route stage, specified by its `route_stage_id`. + :param route_stage_id: ID of the route stage to update. + :param waf_stage_id: ID of the WAF stage HTTP requests should be forwarded to when no rules are matched. + One-Of ('next'): at most one of 'waf_stage_id' could be set. + :return: :class:`RouteStage ` + + Usage: + :: + + result = await api.update_route_stage( + route_stage_id="example", + ) + """ + + param_route_stage_id = validate_path_param("route_stage_id", route_stage_id) + + res = self._request( + "PATCH", + f"/edge-services/v1beta1/route-stages/{param_route_stage_id}", + body=marshal_UpdateRouteStageRequest( + UpdateRouteStageRequest( + route_stage_id=route_stage_id, + waf_stage_id=waf_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_RouteStage(res.json()) + + async def delete_route_stage( + self, + *, + route_stage_id: str, + ) -> None: + """ + Delete route stage. + Delete an existing route stage, specified by its `route_stage_id`. Deleting a route stage is permanent, and cannot be undone. + :param route_stage_id: ID of the route stage to delete. + + Usage: + :: + + result = await api.delete_route_stage( + route_stage_id="example", + ) + """ + + param_route_stage_id = validate_path_param("route_stage_id", route_stage_id) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/route-stages/{param_route_stage_id}", + ) + + self._throw_on_error(res) + + async def list_route_rules( + self, + *, + route_stage_id: str, + ) -> ListRouteRulesResponse: + """ + List route rules. + List all route rules of an existing route stage, specified by its `route_stage_id`. + :param route_stage_id: Route stage ID to filter for. Only route rules from this route stage will be returned. + :return: :class:`ListRouteRulesResponse ` + + Usage: + :: + + result = await api.list_route_rules( + route_stage_id="example", + ) + """ + + param_route_stage_id = validate_path_param("route_stage_id", route_stage_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/{param_route_stage_id}/route-rules", + ) + + self._throw_on_error(res) + return unmarshal_ListRouteRulesResponse(res.json()) + + async def set_route_rules( + self, + *, + route_stage_id: str, + route_rules: Optional[List[SetRouteRulesRequestRouteRule]] = None, + ) -> SetRouteRulesResponse: + """ + Set route rules. + Set the rules of an existing route stage, specified by its `route_stage_id`. + :param route_stage_id: ID of the route stage to update. + :param route_rules: List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`. + :return: :class:`SetRouteRulesResponse ` + + Usage: + :: + + result = await api.set_route_rules( + route_stage_id="example", + ) + """ + + param_route_stage_id = validate_path_param("route_stage_id", route_stage_id) + + res = self._request( + "PUT", + f"/edge-services/v1beta1/route-stages/{param_route_stage_id}/route-rules", + body=marshal_SetRouteRulesRequest( + SetRouteRulesRequest( + route_stage_id=route_stage_id, + route_rules=route_rules, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_SetRouteRulesResponse(res.json()) + + async def add_route_rules( + self, + *, + route_stage_id: str, + route_rules: Optional[List[SetRouteRulesRequestRouteRule]] = None, + after_position: Optional[int] = None, + before_position: Optional[int] = None, + ) -> AddRouteRulesResponse: + """ + Add route rules. + Add route rules to an existing route stage, specified by its `route_stage_id`. + :param route_stage_id: ID of the route stage to update. + :param route_rules: List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`. + :param after_position: Add rules after the given position. + One-Of ('position'): at most one of 'after_position', 'before_position' could be set. + :param before_position: Add rules before the given position. + One-Of ('position'): at most one of 'after_position', 'before_position' could be set. + :return: :class:`AddRouteRulesResponse ` + + Usage: + :: + + result = await api.add_route_rules( + route_stage_id="example", + ) + """ + + param_route_stage_id = validate_path_param("route_stage_id", route_stage_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/route-stages/{param_route_stage_id}/route-rules", + body=marshal_AddRouteRulesRequest( + AddRouteRulesRequest( + route_stage_id=route_stage_id, + route_rules=route_rules, + after_position=after_position, + before_position=before_position, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_AddRouteRulesResponse(res.json()) + + async def check_domain( + self, + *, + fqdn: str, + cname: str, + project_id: Optional[str] = None, + ) -> CheckDomainResponse: + """ + :param fqdn: + :param cname: + :param project_id: + :return: :class:`CheckDomainResponse ` + + Usage: + :: + + result = await api.check_domain( + fqdn="example", + cname="example", + ) + """ + + res = self._request( + "POST", + "/edge-services/v1beta1/check-domain", + body=marshal_CheckDomainRequest( + CheckDomainRequest( + fqdn=fqdn, + cname=cname, + project_id=project_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CheckDomainResponse(res.json()) + + async def check_pem_chain( + self, + *, + fqdn: str, + project_id: Optional[str] = None, + secret: Optional[CheckPEMChainRequestSecretChain] = None, + raw: Optional[str] = None, + ) -> CheckPEMChainResponse: + """ + :param fqdn: + :param project_id: + :param secret: + One-Of ('chain'): at most one of 'secret', 'raw' could be set. + :param raw: + One-Of ('chain'): at most one of 'secret', 'raw' could be set. + :return: :class:`CheckPEMChainResponse ` + + Usage: + :: + + result = await api.check_pem_chain( + fqdn="example", + ) + """ + + res = self._request( + "POST", + "/edge-services/v1beta1/check-pem-chain", + body=marshal_CheckPEMChainRequest( + CheckPEMChainRequest( + fqdn=fqdn, + project_id=project_id, + secret=secret, + raw=raw, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CheckPEMChainResponse(res.json()) + + async def search_backend_stages( + self, + *, + order_by: Optional[SearchBackendStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + project_id: Optional[str] = None, + bucket_name: Optional[str] = None, + bucket_region: Optional[str] = None, + lb_id: Optional[str] = None, + ) -> ListBackendStagesResponse: + """ + :param order_by: + :param page: + :param page_size: + :param project_id: + :param bucket_name: + :param bucket_region: + :param lb_id: + :return: :class:`ListBackendStagesResponse ` + + Usage: + :: + + result = await api.search_backend_stages() + """ + + res = self._request( + "GET", + "/edge-services/v1beta1/search-backend-stages", + params={ + "bucket_name": bucket_name, + "bucket_region": bucket_region, + "lb_id": lb_id, + "order_by": order_by, + "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_ListBackendStagesResponse(res.json()) + + async def list_purge_requests( + self, + *, + order_by: Optional[ListPurgeRequestsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + pipeline_id: Optional[str] = None, + ) -> ListPurgeRequestsResponse: + """ + List purge requests. + List all purge requests, for a Scaleway Organization or Scaleway Project. This enables you to retrieve a history of all previously-made purge requests. By default, the purge requests returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of purge requests in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of purge requests to return per page. + :param organization_id: Organization ID to filter for. Only purge requests from this Project will be returned. + :param project_id: Project ID to filter for. Only purge requests from this Project will be returned. + :param pipeline_id: Pipeline ID to filter for. Only purge requests from this pipeline will be returned. + :return: :class:`ListPurgeRequestsResponse ` + + Usage: + :: + + result = await api.list_purge_requests() + """ + + res = self._request( + "GET", + "/edge-services/v1beta1/purge-requests", + 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, + "pipeline_id": pipeline_id, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListPurgeRequestsResponse(res.json()) + + async def list_purge_requests_all( + self, + *, + order_by: Optional[ListPurgeRequestsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + pipeline_id: Optional[str] = None, + ) -> List[PurgeRequest]: + """ + List purge requests. + List all purge requests, for a Scaleway Organization or Scaleway Project. This enables you to retrieve a history of all previously-made purge requests. By default, the purge requests returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of purge requests in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of purge requests to return per page. + :param organization_id: Organization ID to filter for. Only purge requests from this Project will be returned. + :param project_id: Project ID to filter for. Only purge requests from this Project will be returned. + :param pipeline_id: Pipeline ID to filter for. Only purge requests from this pipeline will be returned. + :return: :class:`List[PurgeRequest] ` + + Usage: + :: + + result = await api.list_purge_requests_all() + """ + + return await fetch_all_pages_async( + type=ListPurgeRequestsResponse, + key="purge_requests", + fetcher=self.list_purge_requests, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "organization_id": organization_id, + "project_id": project_id, + "pipeline_id": pipeline_id, + }, + ) + + async def create_purge_request( + self, + *, + pipeline_id: str, + assets: Optional[List[str]] = None, + all: Optional[bool] = None, + ) -> PurgeRequest: + """ + Create purge request. + Create a new purge request. You must specify either the `all` field (to purge all content) or a list of `assets` (to define the precise assets to purge). + :param pipeline_id: Pipeline ID in which the purge request will be created. + :param assets: List of asserts to purge. + One-Of ('target'): at most one of 'assets', 'all' could be set. + :param all: Defines whether to purge all content. + One-Of ('target'): at most one of 'assets', 'all' could be set. + :return: :class:`PurgeRequest ` + + Usage: + :: + + result = await api.create_purge_request( + pipeline_id="example", + ) + """ + + res = self._request( + "POST", + "/edge-services/v1beta1/purge-requests", + body=marshal_CreatePurgeRequestRequest( + CreatePurgeRequestRequest( + pipeline_id=pipeline_id, + assets=assets, + all=all, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_PurgeRequest(res.json()) + + async def get_purge_request( + self, + *, + purge_request_id: str, + ) -> PurgeRequest: + """ + Get purge request. + Retrieve information about a purge request, specified by its `purge_request_id`. Its full details, including `status` and `target`, are returned in the response object. + :param purge_request_id: ID of the requested purge request. + :return: :class:`PurgeRequest ` + + Usage: + :: + + result = await api.get_purge_request( + purge_request_id="example", + ) + """ + + param_purge_request_id = validate_path_param( + "purge_request_id", purge_request_id + ) + + res = self._request( + "GET", + f"/edge-services/v1beta1/purge-requests/{param_purge_request_id}", + ) + + self._throw_on_error(res) + return unmarshal_PurgeRequest(res.json()) + + async def wait_for_purge_request( + self, + *, + purge_request_id: str, + options: Optional[ + WaitForOptions[PurgeRequest, Union[bool, Awaitable[bool]]] + ] = None, + ) -> PurgeRequest: + """ + Get purge request. + Retrieve information about a purge request, specified by its `purge_request_id`. Its full details, including `status` and `target`, are returned in the response object. + :param purge_request_id: ID of the requested purge request. + :return: :class:`PurgeRequest ` + + Usage: + :: + + result = await api.get_purge_request( + purge_request_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = ( + lambda res: res.status not in PURGE_REQUEST_TRANSIENT_STATUSES + ) + + return await wait_for_resource_async( + fetcher=self.get_purge_request, + options=options, + args={ + "purge_request_id": purge_request_id, + }, + ) + + async def check_lb_origin( + self, + *, + lb: Optional[ScalewayLb] = None, + ) -> CheckLbOriginResponse: + """ + :param lb: + :return: :class:`CheckLbOriginResponse ` + + Usage: + :: + + result = await api.check_lb_origin() + """ + + res = self._request( + "POST", + "/edge-services/v1beta1/check-lb-origin", + body=marshal_CheckLbOriginRequest( + CheckLbOriginRequest( + lb=lb, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CheckLbOriginResponse(res.json()) + + async def list_plans( + self, + ) -> ListPlansResponse: + """ + + :return: :class:`ListPlansResponse ` + + Usage: + :: + + result = await api.list_plans() + """ + + res = self._request( + "GET", + "/edge-services/v1beta1/plans", + ) + + self._throw_on_error(res) + return unmarshal_ListPlansResponse(res.json()) + + async def select_plan( + self, + *, + project_id: Optional[str] = None, + plan_name: Optional[PlanName] = None, + ) -> Plan: + """ + :param project_id: + :param plan_name: + :return: :class:`Plan ` + + Usage: + :: + + result = await api.select_plan() + """ + + res = self._request( + "PATCH", + "/edge-services/v1beta1/current-plan", + body=marshal_SelectPlanRequest( + SelectPlanRequest( + project_id=project_id, + plan_name=plan_name, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Plan(res.json()) + + async def get_current_plan( + self, + *, + project_id: Optional[str] = None, + ) -> Plan: + """ + :param project_id: + :return: :class:`Plan ` + + Usage: + :: + + result = await api.get_current_plan() + """ + + param_project_id = validate_path_param( + "project_id", project_id or self.client.default_project_id + ) + + res = self._request( + "GET", + f"/edge-services/v1beta1/current-plan/{param_project_id}", + ) + + self._throw_on_error(res) + return unmarshal_Plan(res.json()) + + async def delete_current_plan( + self, + *, + project_id: Optional[str] = None, + ) -> None: + """ + :param project_id: + + Usage: + :: + + result = await api.delete_current_plan() + """ + + param_project_id = validate_path_param( + "project_id", project_id or self.client.default_project_id + ) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/current-plan/{param_project_id}", + ) + + self._throw_on_error(res) + + async def get_billing( + self, + *, + project_id: Optional[str] = None, + ) -> GetBillingResponse: + """ + Gives information on the currently selected Edge Services subscription plan, resource usage and associated billing information for this calendar month (including whether consumption falls within or exceeds the currently selected subscription plan.). + :param project_id: + :return: :class:`GetBillingResponse ` + + Usage: + :: + + result = await api.get_billing() + """ + + param_project_id = validate_path_param( + "project_id", project_id or self.client.default_project_id + ) + + res = self._request( + "GET", + f"/edge-services/v1beta1/billing/{param_project_id}", + ) + + self._throw_on_error(res) + return unmarshal_GetBillingResponse(res.json()) diff --git a/scaleway-async/scaleway_async/edge_services/v1beta1/content.py b/scaleway-async/scaleway_async/edge_services/v1beta1/content.py new file mode 100644 index 000000000..ad1b5e0e6 --- /dev/null +++ b/scaleway-async/scaleway_async/edge_services/v1beta1/content.py @@ -0,0 +1,21 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + PipelineStatus, + PurgeRequestStatus, +) + +PIPELINE_TRANSIENT_STATUSES: List[PipelineStatus] = [ + PipelineStatus.PENDING, +] +""" +Lists transient statutes of the enum :class:`PipelineStatus `. +""" +PURGE_REQUEST_TRANSIENT_STATUSES: List[PurgeRequestStatus] = [ + PurgeRequestStatus.PENDING, +] +""" +Lists transient statutes of the enum :class:`PurgeRequestStatus `. +""" diff --git a/scaleway-async/scaleway_async/edge_services/v1beta1/marshalling.py b/scaleway-async/scaleway_async/edge_services/v1beta1/marshalling.py new file mode 100644 index 000000000..b01c7d7cf --- /dev/null +++ b/scaleway-async/scaleway_async/edge_services/v1beta1/marshalling.py @@ -0,0 +1,1901 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any, Dict +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.bridge import ( + unmarshal_Money, +) +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) +from .types import ( + RuleHttpMatchMethodFilter, + ScalewayLb, + ScalewayLbBackendConfig, + ScalewayS3BackendConfig, + BackendStage, + CacheStage, + DNSStage, + PipelineError, + Pipeline, + RouteStage, + TLSSecret, + TLSStage, + WafStage, + PipelineStages, + PurgeRequest, + RuleHttpMatchPathFilter, + RuleHttpMatch, + RouteRule, + AddRouteRulesResponse, + CheckDomainResponse, + CheckLbOriginResponse, + CheckPEMChainResponse, + PlanDetails, + PlanUsageDetails, + GetBillingResponse, + HeadStageResponseHeadStage, + HeadStageResponse, + ListBackendStagesResponse, + ListCacheStagesResponse, + ListDNSStagesResponse, + ListHeadStagesResponseHeadStage, + ListHeadStagesResponse, + ListPipelinesResponse, + ListPipelinesWithStagesResponse, + ListPlansResponse, + ListPurgeRequestsResponse, + ListRouteRulesResponse, + ListRouteStagesResponse, + ListTLSStagesResponse, + ListWafStagesResponse, + Plan, + SetRouteRulesResponse, + SetRouteRulesRequestRouteRule, + AddRouteRulesRequest, + CheckDomainRequest, + CheckLbOriginRequest, + CheckPEMChainRequestSecretChain, + CheckPEMChainRequest, + CreateBackendStageRequest, + CreateCacheStageRequest, + CreateDNSStageRequest, + CreatePipelineRequest, + CreatePurgeRequestRequest, + CreateRouteStageRequest, + CreateTLSStageRequest, + CreateWafStageRequest, + SelectPlanRequest, + SetHeadStageRequestAddNewHeadStage, + SetHeadStageRequestRemoveHeadStage, + SetHeadStageRequestSwapHeadStage, + SetHeadStageRequest, + SetRouteRulesRequest, + UpdateBackendStageRequest, + UpdateCacheStageRequest, + UpdateDNSStageRequest, + UpdatePipelineRequest, + UpdateRouteStageRequest, + TLSSecretsConfig, + UpdateTLSStageRequest, + UpdateWafStageRequest, +) + + +def unmarshal_ScalewayLb(data: Any) -> ScalewayLb: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ScalewayLb' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + + field = data.get("frontend_id", None) + if field is not None: + args["frontend_id"] = field + + field = data.get("is_ssl", None) + if field is not None: + args["is_ssl"] = field + else: + args["is_ssl"] = None + + field = data.get("domain_name", None) + if field is not None: + args["domain_name"] = field + else: + args["domain_name"] = None + + return ScalewayLb(**args) + + +def unmarshal_ScalewayLbBackendConfig(data: Any) -> ScalewayLbBackendConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ScalewayLbBackendConfig' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("lbs", None) + if field is not None: + args["lbs"] = ( + [unmarshal_ScalewayLb(v) for v in field] if field is not None else None + ) + + return ScalewayLbBackendConfig(**args) + + +def unmarshal_ScalewayS3BackendConfig(data: Any) -> ScalewayS3BackendConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ScalewayS3BackendConfig' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("bucket_name", None) + if field is not None: + args["bucket_name"] = field + else: + args["bucket_name"] = None + + field = data.get("bucket_region", None) + if field is not None: + args["bucket_region"] = field + else: + args["bucket_region"] = None + + field = data.get("is_website", None) + if field is not None: + args["is_website"] = field + else: + args["is_website"] = None + + return ScalewayS3BackendConfig(**args) + + +def unmarshal_BackendStage(data: Any) -> BackendStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'BackendStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("pipeline_id", None) + if field is not None: + args["pipeline_id"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("scaleway_s3", None) + if field is not None: + args["scaleway_s3"] = unmarshal_ScalewayS3BackendConfig(field) + else: + args["scaleway_s3"] = None + + field = data.get("scaleway_lb", None) + if field is not None: + args["scaleway_lb"] = unmarshal_ScalewayLbBackendConfig(field) + else: + args["scaleway_lb"] = None + + return BackendStage(**args) + + +def unmarshal_CacheStage(data: Any) -> CacheStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CacheStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("pipeline_id", None) + if field is not None: + args["pipeline_id"] = field + + field = data.get("fallback_ttl", None) + if field is not None: + args["fallback_ttl"] = field + else: + args["fallback_ttl"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("backend_stage_id", None) + if field is not None: + args["backend_stage_id"] = field + else: + args["backend_stage_id"] = None + + field = data.get("waf_stage_id", None) + if field is not None: + args["waf_stage_id"] = field + else: + args["waf_stage_id"] = None + + field = data.get("route_stage_id", None) + if field is not None: + args["route_stage_id"] = field + else: + args["route_stage_id"] = None + + return CacheStage(**args) + + +def unmarshal_DNSStage(data: Any) -> DNSStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'DNSStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("fqdns", None) + if field is not None: + args["fqdns"] = field + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + field = data.get("pipeline_id", None) + if field is not None: + args["pipeline_id"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("tls_stage_id", None) + if field is not None: + args["tls_stage_id"] = field + else: + args["tls_stage_id"] = None + + field = data.get("cache_stage_id", None) + if field is not None: + args["cache_stage_id"] = field + else: + args["cache_stage_id"] = None + + field = data.get("backend_stage_id", None) + if field is not None: + args["backend_stage_id"] = field + else: + args["backend_stage_id"] = None + + return DNSStage(**args) + + +def unmarshal_PipelineError(data: Any) -> PipelineError: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'PipelineError' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("stage", None) + if field is not None: + args["stage"] = field + + field = data.get("code", None) + if field is not None: + args["code"] = field + + field = data.get("severity", None) + if field is not None: + args["severity"] = field + + field = data.get("message", None) + if field is not None: + args["message"] = field + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + return PipelineError(**args) + + +def unmarshal_Pipeline(data: Any) -> Pipeline: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Pipeline' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("description", None) + if field is not None: + args["description"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("errors", None) + if field is not None: + args["errors"] = ( + [unmarshal_PipelineError(v) for v in field] if field is not None else None + ) + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return Pipeline(**args) + + +def unmarshal_RouteStage(data: Any) -> RouteStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'RouteStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("pipeline_id", None) + if field is not None: + args["pipeline_id"] = field + + field = data.get("waf_stage_id", None) + if field is not None: + args["waf_stage_id"] = field + else: + args["waf_stage_id"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return RouteStage(**args) + + +def unmarshal_TLSSecret(data: Any) -> TLSSecret: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'TLSSecret' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("secret_id", None) + if field is not None: + args["secret_id"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + return TLSSecret(**args) + + +def unmarshal_TLSStage(data: Any) -> TLSStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'TLSStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("secrets", None) + if field is not None: + args["secrets"] = ( + [unmarshal_TLSSecret(v) for v in field] if field is not None else None + ) + + field = data.get("managed_certificate", None) + if field is not None: + args["managed_certificate"] = field + + field = data.get("pipeline_id", None) + if field is not None: + args["pipeline_id"] = field + + field = data.get("certificate_expires_at", None) + if field is not None: + args["certificate_expires_at"] = ( + parser.isoparse(field) if isinstance(field, str) else field + ) + else: + args["certificate_expires_at"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("cache_stage_id", None) + if field is not None: + args["cache_stage_id"] = field + else: + args["cache_stage_id"] = None + + field = data.get("backend_stage_id", None) + if field is not None: + args["backend_stage_id"] = field + else: + args["backend_stage_id"] = None + + field = data.get("waf_stage_id", None) + if field is not None: + args["waf_stage_id"] = field + else: + args["waf_stage_id"] = None + + field = data.get("route_stage_id", None) + if field is not None: + args["route_stage_id"] = field + else: + args["route_stage_id"] = None + + return TLSStage(**args) + + +def unmarshal_WafStage(data: Any) -> WafStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'WafStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("pipeline_id", None) + if field is not None: + args["pipeline_id"] = field + + field = data.get("mode", None) + if field is not None: + args["mode"] = field + + field = data.get("paranoia_level", None) + if field is not None: + args["paranoia_level"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("backend_stage_id", None) + if field is not None: + args["backend_stage_id"] = field + else: + args["backend_stage_id"] = None + + return WafStage(**args) + + +def unmarshal_PipelineStages(data: Any) -> PipelineStages: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'PipelineStages' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("dns_stages", None) + if field is not None: + args["dns_stages"] = ( + [unmarshal_DNSStage(v) for v in field] if field is not None else None + ) + + field = data.get("tls_stages", None) + if field is not None: + args["tls_stages"] = ( + [unmarshal_TLSStage(v) for v in field] if field is not None else None + ) + + field = data.get("cache_stages", None) + if field is not None: + args["cache_stages"] = ( + [unmarshal_CacheStage(v) for v in field] if field is not None else None + ) + + field = data.get("backend_stages", None) + if field is not None: + args["backend_stages"] = ( + [unmarshal_BackendStage(v) for v in field] if field is not None else None + ) + + field = data.get("waf_stages", None) + if field is not None: + args["waf_stages"] = ( + [unmarshal_WafStage(v) for v in field] if field is not None else None + ) + + field = data.get("route_stages", None) + if field is not None: + args["route_stages"] = ( + [unmarshal_RouteStage(v) for v in field] if field is not None else None + ) + + field = data.get("pipeline", None) + if field is not None: + args["pipeline"] = unmarshal_Pipeline(field) + else: + args["pipeline"] = None + + return PipelineStages(**args) + + +def unmarshal_PurgeRequest(data: Any) -> PurgeRequest: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'PurgeRequest' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("pipeline_id", None) + if field is not None: + args["pipeline_id"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("assets", None) + if field is not None: + args["assets"] = field + else: + args["assets"] = None + + field = data.get("all", None) + if field is not None: + args["all"] = field + else: + args["all"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return PurgeRequest(**args) + + +def unmarshal_RuleHttpMatchPathFilter(data: Any) -> RuleHttpMatchPathFilter: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'RuleHttpMatchPathFilter' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("path_filter_type", None) + if field is not None: + args["path_filter_type"] = field + + field = data.get("value", None) + if field is not None: + args["value"] = field + + return RuleHttpMatchPathFilter(**args) + + +def unmarshal_RuleHttpMatch(data: Any) -> RuleHttpMatch: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'RuleHttpMatch' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("method_filters", None) + if field is not None: + args["method_filters"] = ( + [RuleHttpMatchMethodFilter(v) for v in field] if field is not None else None + ) + + field = data.get("path_filter", None) + if field is not None: + args["path_filter"] = unmarshal_RuleHttpMatchPathFilter(field) + else: + args["path_filter"] = None + + return RuleHttpMatch(**args) + + +def unmarshal_RouteRule(data: Any) -> RouteRule: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'RouteRule' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("position", None) + if field is not None: + args["position"] = field + + field = data.get("route_stage_id", None) + if field is not None: + args["route_stage_id"] = field + + field = data.get("rule_http_match", None) + if field is not None: + args["rule_http_match"] = unmarshal_RuleHttpMatch(field) + else: + args["rule_http_match"] = None + + field = data.get("backend_stage_id", None) + if field is not None: + args["backend_stage_id"] = field + else: + args["backend_stage_id"] = None + + return RouteRule(**args) + + +def unmarshal_AddRouteRulesResponse(data: Any) -> AddRouteRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'AddRouteRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("route_rules", None) + if field is not None: + args["route_rules"] = ( + [unmarshal_RouteRule(v) for v in field] if field is not None else None + ) + + return AddRouteRulesResponse(**args) + + +def unmarshal_CheckDomainResponse(data: Any) -> CheckDomainResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CheckDomainResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("is_valid", None) + if field is not None: + args["is_valid"] = field + + return CheckDomainResponse(**args) + + +def unmarshal_CheckLbOriginResponse(data: Any) -> CheckLbOriginResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CheckLbOriginResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("is_valid", None) + if field is not None: + args["is_valid"] = field + + field = data.get("error_type", None) + if field is not None: + args["error_type"] = field + + return CheckLbOriginResponse(**args) + + +def unmarshal_CheckPEMChainResponse(data: Any) -> CheckPEMChainResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CheckPEMChainResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("is_valid", None) + if field is not None: + args["is_valid"] = field + + return CheckPEMChainResponse(**args) + + +def unmarshal_PlanDetails(data: Any) -> PlanDetails: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'PlanDetails' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("plan_name", None) + if field is not None: + args["plan_name"] = field + + field = data.get("package_gb", None) + if field is not None: + args["package_gb"] = field + + field = data.get("pipeline_limit", None) + if field is not None: + args["pipeline_limit"] = field + + field = data.get("waf_requests", None) + if field is not None: + args["waf_requests"] = field + + return PlanDetails(**args) + + +def unmarshal_PlanUsageDetails(data: Any) -> PlanUsageDetails: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'PlanUsageDetails' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("plan_cost", None) + if field is not None: + args["plan_cost"] = unmarshal_Money(field) + else: + args["plan_cost"] = None + + return PlanUsageDetails(**args) + + +def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetBillingResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("current_plan", None) + if field is not None: + args["current_plan"] = unmarshal_PlanDetails(field) + else: + args["current_plan"] = None + + field = data.get("pipeline_number", None) + if field is not None: + args["pipeline_number"] = field + + field = data.get("current_plan_cache_usage", None) + if field is not None: + args["current_plan_cache_usage"] = field + + field = data.get("extra_cache_usage", None) + if field is not None: + args["extra_cache_usage"] = field + + field = data.get("current_plan_waf_usage", None) + if field is not None: + args["current_plan_waf_usage"] = field + + field = data.get("extra_waf_usage", None) + if field is not None: + args["extra_waf_usage"] = field + + field = data.get("plan_cost", None) + if field is not None: + args["plan_cost"] = unmarshal_Money(field) + else: + args["plan_cost"] = None + + field = data.get("extra_pipelines_cost", None) + if field is not None: + args["extra_pipelines_cost"] = unmarshal_Money(field) + else: + args["extra_pipelines_cost"] = None + + field = data.get("plans_usage_details", None) + if field is not None: + args["plans_usage_details"] = ( + {key: unmarshal_PlanUsageDetails(value) for key, value in field.items()} + if field is not None + else None + ) + + field = data.get("extra_cache_cost", None) + if field is not None: + args["extra_cache_cost"] = unmarshal_Money(field) + else: + args["extra_cache_cost"] = None + + field = data.get("extra_waf_cost", None) + if field is not None: + args["extra_waf_cost"] = unmarshal_Money(field) + else: + args["extra_waf_cost"] = None + + field = data.get("waf_add_on", None) + if field is not None: + args["waf_add_on"] = unmarshal_Money(field) + else: + args["waf_add_on"] = None + + field = data.get("total_cost", None) + if field is not None: + args["total_cost"] = unmarshal_Money(field) + else: + args["total_cost"] = None + + return GetBillingResponse(**args) + + +def unmarshal_HeadStageResponseHeadStage(data: Any) -> HeadStageResponseHeadStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'HeadStageResponseHeadStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("dns_stage_id", None) + if field is not None: + args["dns_stage_id"] = field + else: + args["dns_stage_id"] = None + + return HeadStageResponseHeadStage(**args) + + +def unmarshal_HeadStageResponse(data: Any) -> HeadStageResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'HeadStageResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("head_stage", None) + if field is not None: + args["head_stage"] = unmarshal_HeadStageResponseHeadStage(field) + else: + args["head_stage"] = None + + return HeadStageResponse(**args) + + +def unmarshal_ListBackendStagesResponse(data: Any) -> ListBackendStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListBackendStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("stages", None) + if field is not None: + args["stages"] = ( + [unmarshal_BackendStage(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListBackendStagesResponse(**args) + + +def unmarshal_ListCacheStagesResponse(data: Any) -> ListCacheStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListCacheStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("stages", None) + if field is not None: + args["stages"] = ( + [unmarshal_CacheStage(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListCacheStagesResponse(**args) + + +def unmarshal_ListDNSStagesResponse(data: Any) -> ListDNSStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListDNSStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("stages", None) + if field is not None: + args["stages"] = ( + [unmarshal_DNSStage(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListDNSStagesResponse(**args) + + +def unmarshal_ListHeadStagesResponseHeadStage( + data: Any, +) -> ListHeadStagesResponseHeadStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListHeadStagesResponseHeadStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("dns_stage_id", None) + if field is not None: + args["dns_stage_id"] = field + else: + args["dns_stage_id"] = None + + return ListHeadStagesResponseHeadStage(**args) + + +def unmarshal_ListHeadStagesResponse(data: Any) -> ListHeadStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListHeadStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("head_stages", None) + if field is not None: + args["head_stages"] = ( + [unmarshal_ListHeadStagesResponseHeadStage(v) for v in field] + if field is not None + else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListHeadStagesResponse(**args) + + +def unmarshal_ListPipelinesResponse(data: Any) -> ListPipelinesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListPipelinesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("pipelines", None) + if field is not None: + args["pipelines"] = ( + [unmarshal_Pipeline(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListPipelinesResponse(**args) + + +def unmarshal_ListPipelinesWithStagesResponse( + data: Any, +) -> ListPipelinesWithStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListPipelinesWithStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("pipelines", None) + if field is not None: + args["pipelines"] = ( + [unmarshal_PipelineStages(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListPipelinesWithStagesResponse(**args) + + +def unmarshal_ListPlansResponse(data: Any) -> ListPlansResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListPlansResponse' 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 + + field = data.get("plans", None) + if field is not None: + args["plans"] = ( + [unmarshal_PlanDetails(v) for v in field] if field is not None else None + ) + + return ListPlansResponse(**args) + + +def unmarshal_ListPurgeRequestsResponse(data: Any) -> ListPurgeRequestsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListPurgeRequestsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("purge_requests", None) + if field is not None: + args["purge_requests"] = ( + [unmarshal_PurgeRequest(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListPurgeRequestsResponse(**args) + + +def unmarshal_ListRouteRulesResponse(data: Any) -> ListRouteRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListRouteRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("route_rules", None) + if field is not None: + args["route_rules"] = ( + [unmarshal_RouteRule(v) for v in field] if field is not None else None + ) + + return ListRouteRulesResponse(**args) + + +def unmarshal_ListRouteStagesResponse(data: Any) -> ListRouteStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListRouteStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("stages", None) + if field is not None: + args["stages"] = ( + [unmarshal_RouteStage(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListRouteStagesResponse(**args) + + +def unmarshal_ListTLSStagesResponse(data: Any) -> ListTLSStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListTLSStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("stages", None) + if field is not None: + args["stages"] = ( + [unmarshal_TLSStage(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListTLSStagesResponse(**args) + + +def unmarshal_ListWafStagesResponse(data: Any) -> ListWafStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListWafStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("stages", None) + if field is not None: + args["stages"] = ( + [unmarshal_WafStage(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListWafStagesResponse(**args) + + +def unmarshal_Plan(data: Any) -> Plan: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Plan' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("plan_name", None) + if field is not None: + args["plan_name"] = field + + return Plan(**args) + + +def unmarshal_SetRouteRulesResponse(data: Any) -> SetRouteRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SetRouteRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("route_rules", None) + if field is not None: + args["route_rules"] = ( + [unmarshal_RouteRule(v) for v in field] if field is not None else None + ) + + return SetRouteRulesResponse(**args) + + +def marshal_RuleHttpMatchPathFilter( + request: RuleHttpMatchPathFilter, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.path_filter_type is not None: + output["path_filter_type"] = str(request.path_filter_type) + + if request.value is not None: + output["value"] = request.value + + return output + + +def marshal_RuleHttpMatch( + request: RuleHttpMatch, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.method_filters is not None: + output["method_filters"] = [str(item) for item in request.method_filters] + + if request.path_filter is not None: + output["path_filter"] = marshal_RuleHttpMatchPathFilter( + request.path_filter, defaults + ) + + return output + + +def marshal_SetRouteRulesRequestRouteRule( + request: SetRouteRulesRequestRouteRule, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("rule_http_match", request.rule_http_match), + ] + ), + ) + output.update( + resolve_one_of( + [ + OneOfPossibility("backend_stage_id", request.backend_stage_id), + ] + ), + ) + + return output + + +def marshal_AddRouteRulesRequest( + request: AddRouteRulesRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("after_position", request.after_position), + OneOfPossibility("before_position", request.before_position), + ] + ), + ) + + if request.route_rules is not None: + output["route_rules"] = [ + marshal_SetRouteRulesRequestRouteRule(item, defaults) + for item in request.route_rules + ] + + return output + + +def marshal_CheckDomainRequest( + request: CheckDomainRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.fqdn is not None: + output["fqdn"] = request.fqdn + + if request.cname is not None: + output["cname"] = request.cname + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + return output + + +def marshal_ScalewayLb( + request: ScalewayLb, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.id is not None: + output["id"] = request.id + + if request.zone is not None: + output["zone"] = request.zone or defaults.default_zone + + if request.frontend_id is not None: + output["frontend_id"] = request.frontend_id + + if request.is_ssl is not None: + output["is_ssl"] = request.is_ssl + + if request.domain_name is not None: + output["domain_name"] = request.domain_name + + return output + + +def marshal_CheckLbOriginRequest( + request: CheckLbOriginRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.lb is not None: + output["lb"] = marshal_ScalewayLb(request.lb, defaults) + + return output + + +def marshal_CheckPEMChainRequestSecretChain( + request: CheckPEMChainRequestSecretChain, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.secret_id is not None: + output["secret_id"] = request.secret_id + + if request.secret_region is not None: + output["secret_region"] = request.secret_region + + return output + + +def marshal_CheckPEMChainRequest( + request: CheckPEMChainRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("secret", request.secret), + OneOfPossibility("raw", request.raw), + ] + ), + ) + + if request.fqdn is not None: + output["fqdn"] = request.fqdn + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + return output + + +def marshal_ScalewayLbBackendConfig( + request: ScalewayLbBackendConfig, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.lbs is not None: + output["lbs"] = [marshal_ScalewayLb(item, defaults) for item in request.lbs] + + return output + + +def marshal_ScalewayS3BackendConfig( + request: ScalewayS3BackendConfig, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.bucket_name is not None: + output["bucket_name"] = request.bucket_name + + if request.bucket_region is not None: + output["bucket_region"] = request.bucket_region + + if request.is_website is not None: + output["is_website"] = request.is_website + + return output + + +def marshal_CreateBackendStageRequest( + request: CreateBackendStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("scaleway_s3", request.scaleway_s3), + OneOfPossibility("scaleway_lb", request.scaleway_lb), + ] + ), + ) + + return output + + +def marshal_CreateCacheStageRequest( + request: CreateCacheStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("backend_stage_id", request.backend_stage_id), + OneOfPossibility("waf_stage_id", request.waf_stage_id), + OneOfPossibility("route_stage_id", request.route_stage_id), + ] + ), + ) + + if request.fallback_ttl is not None: + output["fallback_ttl"] = request.fallback_ttl + + return output + + +def marshal_CreateDNSStageRequest( + request: CreateDNSStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("tls_stage_id", request.tls_stage_id), + OneOfPossibility("cache_stage_id", request.cache_stage_id), + OneOfPossibility("backend_stage_id", request.backend_stage_id), + ] + ), + ) + + if request.fqdns is not None: + output["fqdns"] = request.fqdns + + return output + + +def marshal_CreatePipelineRequest( + request: CreatePipelineRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.description is not None: + output["description"] = request.description + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + return output + + +def marshal_CreatePurgeRequestRequest( + request: CreatePurgeRequestRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("assets", request.assets), + OneOfPossibility("all", request.all), + ] + ), + ) + + if request.pipeline_id is not None: + output["pipeline_id"] = request.pipeline_id + + return output + + +def marshal_CreateRouteStageRequest( + request: CreateRouteStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("waf_stage_id", request.waf_stage_id), + ] + ), + ) + + return output + + +def marshal_TLSSecret( + request: TLSSecret, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.secret_id is not None: + output["secret_id"] = request.secret_id + + if request.region is not None: + output["region"] = request.region or defaults.default_region + + return output + + +def marshal_CreateTLSStageRequest( + request: CreateTLSStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("cache_stage_id", request.cache_stage_id), + OneOfPossibility("backend_stage_id", request.backend_stage_id), + OneOfPossibility("route_stage_id", request.route_stage_id), + OneOfPossibility("waf_stage_id", request.waf_stage_id), + ] + ), + ) + + if request.secrets is not None: + output["secrets"] = [ + marshal_TLSSecret(item, defaults) for item in request.secrets + ] + + if request.managed_certificate is not None: + output["managed_certificate"] = request.managed_certificate + + return output + + +def marshal_CreateWafStageRequest( + request: CreateWafStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("backend_stage_id", request.backend_stage_id), + ] + ), + ) + + if request.paranoia_level is not None: + output["paranoia_level"] = request.paranoia_level + + if request.mode is not None: + output["mode"] = str(request.mode) + + return output + + +def marshal_SelectPlanRequest( + request: SelectPlanRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.plan_name is not None: + output["plan_name"] = str(request.plan_name) + + return output + + +def marshal_SetHeadStageRequestAddNewHeadStage( + request: SetHeadStageRequestAddNewHeadStage, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.new_stage_id is not None: + output["new_stage_id"] = request.new_stage_id + + return output + + +def marshal_SetHeadStageRequestRemoveHeadStage( + request: SetHeadStageRequestRemoveHeadStage, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.remove_stage_id is not None: + output["remove_stage_id"] = request.remove_stage_id + + return output + + +def marshal_SetHeadStageRequestSwapHeadStage( + request: SetHeadStageRequestSwapHeadStage, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.new_stage_id is not None: + output["new_stage_id"] = request.new_stage_id + + if request.current_stage_id is not None: + output["current_stage_id"] = request.current_stage_id + + return output + + +def marshal_SetHeadStageRequest( + request: SetHeadStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("add_new_head_stage", request.add_new_head_stage), + OneOfPossibility("remove_head_stage", request.remove_head_stage), + OneOfPossibility("swap_head_stage", request.swap_head_stage), + ] + ), + ) + + return output + + +def marshal_SetRouteRulesRequest( + request: SetRouteRulesRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.route_rules is not None: + output["route_rules"] = [ + marshal_SetRouteRulesRequestRouteRule(item, defaults) + for item in request.route_rules + ] + + return output + + +def marshal_UpdateBackendStageRequest( + request: UpdateBackendStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("scaleway_s3", request.scaleway_s3), + OneOfPossibility("scaleway_lb", request.scaleway_lb), + ] + ), + ) + + if request.pipeline_id is not None: + output["pipeline_id"] = request.pipeline_id + + return output + + +def marshal_UpdateCacheStageRequest( + request: UpdateCacheStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("backend_stage_id", request.backend_stage_id), + OneOfPossibility("waf_stage_id", request.waf_stage_id), + OneOfPossibility("route_stage_id", request.route_stage_id), + ] + ), + ) + + if request.fallback_ttl is not None: + output["fallback_ttl"] = request.fallback_ttl + + return output + + +def marshal_UpdateDNSStageRequest( + request: UpdateDNSStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("tls_stage_id", request.tls_stage_id), + OneOfPossibility("cache_stage_id", request.cache_stage_id), + OneOfPossibility("backend_stage_id", request.backend_stage_id), + ] + ), + ) + + if request.fqdns is not None: + output["fqdns"] = request.fqdns + + return output + + +def marshal_UpdatePipelineRequest( + request: UpdatePipelineRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.description is not None: + output["description"] = request.description + + return output + + +def marshal_UpdateRouteStageRequest( + request: UpdateRouteStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("waf_stage_id", request.waf_stage_id), + ] + ), + ) + + return output + + +def marshal_TLSSecretsConfig( + request: TLSSecretsConfig, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.tls_secrets is not None: + output["tls_secrets"] = [ + marshal_TLSSecret(item, defaults) for item in request.tls_secrets + ] + + return output + + +def marshal_UpdateTLSStageRequest( + request: UpdateTLSStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("cache_stage_id", request.cache_stage_id), + OneOfPossibility("backend_stage_id", request.backend_stage_id), + OneOfPossibility("route_stage_id", request.route_stage_id), + OneOfPossibility("waf_stage_id", request.waf_stage_id), + ] + ), + ) + + if request.tls_secrets_config is not None: + output["tls_secrets_config"] = marshal_TLSSecretsConfig( + request.tls_secrets_config, defaults + ) + + if request.managed_certificate is not None: + output["managed_certificate"] = request.managed_certificate + + return output + + +def marshal_UpdateWafStageRequest( + request: UpdateWafStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("backend_stage_id", request.backend_stage_id), + ] + ), + ) + + if request.mode is not None: + output["mode"] = str(request.mode) + + if request.paranoia_level is not None: + output["paranoia_level"] = request.paranoia_level + + return output diff --git a/scaleway-async/scaleway_async/edge_services/v1beta1/types.py b/scaleway-async/scaleway_async/edge_services/v1beta1/types.py new file mode 100644 index 000000000..424d86ece --- /dev/null +++ b/scaleway-async/scaleway_async/edge_services/v1beta1/types.py @@ -0,0 +1,1780 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import Dict, List, Optional + +from scaleway_core.bridge import ( + Money, + Region as ScwRegion, + Zone as ScwZone, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class DNSStageType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_TYPE = "unknown_type" + AUTO = "auto" + MANAGED = "managed" + CUSTOM = "custom" + + def __str__(self) -> str: + return str(self.value) + + +class LbOriginError(str, Enum, metaclass=StrEnumMeta): + UNKNOWN = "unknown" + TIMEOUT = "timeout" + CONNECTION_REFUSED = "connection_refused" + TLS_ERROR = "tls_error" + + def __str__(self) -> str: + return str(self.value) + + +class ListBackendStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListCacheStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListDNSStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListPipelinesRequestOrderBy(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 ListPipelinesWithStagesRequestOrderBy(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 ListPurgeRequestsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListRouteStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListTLSStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_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" + + def __str__(self) -> str: + return str(self.value) + + +class PipelineErrorCode(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_CODE = "unknown_code" + DNS_INVALID_FORMAT = "dns_invalid_format" + DNS_INVALID_TLD = "dns_invalid_tld" + DNS_FORBIDDEN_ROOT_DOMAIN = "dns_forbidden_root_domain" + DNS_FORBIDDEN_SCW_CLOUD = "dns_forbidden_scw_cloud" + DNS_DOMAIN_DONT_EXIST = "dns_domain_dont_exist" + DNS_CNAME_DONT_EXIST = "dns_cname_dont_exist" + DNS_CNAME_RESOLVE = "dns_cname_resolve" + DNS_FQDN_ALREADY_EXISTS = "dns_fqdn_already_exists" + DNS_FQDN_ALREADY_IN_USE = "dns_fqdn_already_in_use" + TLS_CERT_DELETED = "tls_cert_deleted" + TLS_CERT_DISABLED = "tls_cert_disabled" + TLS_CERT_EXPIRED = "tls_cert_expired" + TLS_CERT_INVALID_FORMAT = "tls_cert_invalid_format" + TLS_CERT_MISSING = "tls_cert_missing" + TLS_CHAIN_ORDER = "tls_chain_order" + TLS_KEY_INVALID_FORMAT = "tls_key_invalid_format" + TLS_KEY_MISSING = "tls_key_missing" + TLS_KEY_TOO_MANY = "tls_key_too_many" + TLS_MANAGED_DOMAIN_RATE_LIMIT = "tls_managed_domain_rate_limit" + TLS_MANAGED_INTERNAL = "tls_managed_internal" + TLS_PAIR_MISMATCH = "tls_pair_mismatch" + TLS_ROOT_INCONSISTENT = "tls_root_inconsistent" + TLS_ROOT_INCORRECT = "tls_root_incorrect" + TLS_ROOT_MISSING = "tls_root_missing" + TLS_SAN_MISMATCH = "tls_san_mismatch" + TLS_SELF_SIGNED = "tls_self_signed" + PIPELINE_INVALID_WORKFLOW = "pipeline_invalid_workflow" + PIPELINE_MISSING_HEAD_STAGE = "pipeline_missing_head_stage" + + def __str__(self) -> str: + return str(self.value) + + +class PipelineErrorSeverity(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_SEVERITY = "unknown_severity" + WARNING = "warning" + CRITICAL = "critical" + + def __str__(self) -> str: + return str(self.value) + + +class PipelineErrorStage(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STAGE = "unknown_stage" + DNS = "dns" + TLS = "tls" + CACHE = "cache" + BACKEND = "backend" + + def __str__(self) -> str: + return str(self.value) + + +class PipelineErrorType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_TYPE = "unknown_type" + RUNTIME = "runtime" + CONFIG = "config" + + def __str__(self) -> str: + return str(self.value) + + +class PipelineStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + READY = "ready" + ERROR = "error" + PENDING = "pending" + WARNING = "warning" + + def __str__(self) -> str: + return str(self.value) + + +class PlanName(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_NAME = "unknown_name" + STARTER = "starter" + PROFESSIONAL = "professional" + ADVANCED = "advanced" + + def __str__(self) -> str: + return str(self.value) + + +class PurgeRequestStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + DONE = "done" + ERROR = "error" + PENDING = "pending" + + def __str__(self) -> str: + return str(self.value) + + +class RuleHttpMatchMethodFilter(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_METHOD_FILTER = "unknown_method_filter" + GET = "get" + POST = "post" + PUT = "put" + PATCH = "patch" + DELETE = "delete" + HEAD = "head" + OPTIONS = "options" + + def __str__(self) -> str: + return str(self.value) + + +class RuleHttpMatchPathFilterPathFilterType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_PATH_FILTER = "unknown_path_filter" + REGEX = "regex" + + def __str__(self) -> str: + return str(self.value) + + +class SearchBackendStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class WafStageMode(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_MODE = "unknown_mode" + DISABLE = "disable" + LOG_ONLY = "log_only" + ENABLE = "enable" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class ScalewayLb: + id: str + """ + ID of the Load Balancer. + """ + + zone: ScwZone + """ + Zone of the Load Balancer. + """ + + frontend_id: str + """ + ID of the frontend linked to the Load Balancer. + """ + + is_ssl: Optional[bool] + """ + Defines whether the Load Balancer's frontend handles SSL connections. + """ + + domain_name: Optional[str] + """ + Fully Qualified Domain Name (in the format subdomain.example.com) to use in HTTP requests sent towards your Load Balancer. + """ + + +@dataclass +class RuleHttpMatchPathFilter: + path_filter_type: RuleHttpMatchPathFilterPathFilterType + """ + Type of filter to match for the HTTP URL path. For now, all path filters must be written in regex and use the `regex` type. + """ + + value: str + """ + Value to be matched for the HTTP URL path. + """ + + +@dataclass +class ScalewayLbBackendConfig: + lbs: List[ScalewayLb] + """ + Load Balancer information. + """ + + +@dataclass +class ScalewayS3BackendConfig: + bucket_name: Optional[str] + """ + Name of the Bucket. + """ + + bucket_region: Optional[str] + """ + Region of the Bucket. + """ + + is_website: Optional[bool] + """ + Defines whether the bucket website feature is enabled. + """ + + +@dataclass +class PipelineError: + stage: PipelineErrorStage + + code: PipelineErrorCode + + severity: PipelineErrorSeverity + + message: str + + type_: PipelineErrorType + + +@dataclass +class TLSSecret: + secret_id: str + """ + ID of the Secret. + """ + + region: ScwRegion + """ + Region of the Secret. + """ + + +@dataclass +class RuleHttpMatch: + method_filters: List[RuleHttpMatchMethodFilter] + """ + HTTP methods to filter for. A request using any of these methods will be considered to match the rule. Possible values are `get`, `post`, `put`, `patch`, `delete`, `head`, `options`. All methods will match if none is provided. + """ + + path_filter: Optional[RuleHttpMatchPathFilter] + """ + HTTP URL path to filter for. A request whose path matches the given filter will be considered to match the rule. All paths will match if none is provided. + """ + + +@dataclass +class BackendStage: + id: str + """ + ID of the backend stage. + """ + + pipeline_id: str + """ + Pipeline ID the backend stage belongs to. + """ + + created_at: Optional[datetime] + """ + Date the backend stage was created. + """ + + updated_at: Optional[datetime] + """ + Date the backend stage was last updated. + """ + + scaleway_s3: Optional[ScalewayS3BackendConfig] + + scaleway_lb: Optional[ScalewayLbBackendConfig] + + +@dataclass +class CacheStage: + id: str + """ + ID of the cache stage. + """ + + pipeline_id: str + """ + Pipeline ID the cache stage belongs to. + """ + + fallback_ttl: Optional[str] + """ + Time To Live (TTL) in seconds. Defines how long content is cached. + """ + + created_at: Optional[datetime] + """ + Date the cache stage was created. + """ + + updated_at: Optional[datetime] + """ + Date the cache stage was last updated. + """ + + backend_stage_id: Optional[str] + + waf_stage_id: Optional[str] + + route_stage_id: Optional[str] + + +@dataclass +class DNSStage: + id: str + """ + ID of the DNS stage. + """ + + fqdns: List[str] + """ + List of Fully Qualified Domain Names attached to the stage. + """ + + type_: DNSStageType + """ + Type of the stage. + """ + + pipeline_id: str + """ + Pipeline ID the DNS stage belongs to. + """ + + created_at: Optional[datetime] + """ + Date the DNS stage was created. + """ + + updated_at: Optional[datetime] + """ + Date the DNS stage was last updated. + """ + + tls_stage_id: Optional[str] + + cache_stage_id: Optional[str] + + backend_stage_id: Optional[str] + + +@dataclass +class Pipeline: + id: str + """ + ID of the pipeline. + """ + + name: str + """ + Name of the pipeline. + """ + + description: str + """ + Description of the pipeline. + """ + + status: PipelineStatus + """ + Status of the pipeline. + """ + + errors: List[PipelineError] + """ + Errors of the pipeline. + """ + + project_id: str + """ + Project ID of the pipeline. + """ + + organization_id: str + """ + Organization ID of the pipeline. + """ + + created_at: Optional[datetime] + """ + Date the pipeline was created. + """ + + updated_at: Optional[datetime] + """ + Date the pipeline was last updated. + """ + + +@dataclass +class RouteStage: + id: str + """ + ID of the route stage. + """ + + pipeline_id: str + """ + Pipeline ID the route stage belongs to. + """ + + created_at: Optional[datetime] + """ + Date the route stage was created. + """ + + updated_at: Optional[datetime] + """ + Date the route stage was last updated. + """ + + waf_stage_id: Optional[str] + + +@dataclass +class TLSStage: + id: str + """ + ID of the TLS stage. + """ + + secrets: List[TLSSecret] + """ + Secret (from Scaleway Secret Manager) containing your custom certificate. + """ + + managed_certificate: bool + """ + True when Scaleway generates and manages a Let's Encrypt certificate for the TLS stage/custom endpoint. + """ + + pipeline_id: str + """ + Pipeline ID the TLS stage belongs to. + """ + + certificate_expires_at: Optional[datetime] + """ + Expiration date of the certificate. + """ + + created_at: Optional[datetime] + """ + Date the TLS stage was created. + """ + + updated_at: Optional[datetime] + """ + Date the TLS stage was last updated. + """ + + cache_stage_id: Optional[str] + + backend_stage_id: Optional[str] + + waf_stage_id: Optional[str] + + route_stage_id: Optional[str] + + +@dataclass +class WafStage: + id: str + """ + ID of the WAF stage. + """ + + pipeline_id: str + """ + Pipeline ID the WAF stage belongs to. + """ + + mode: WafStageMode + """ + Mode defining WAF behavior (`disable`/`log_only`/`enable`). + """ + + paranoia_level: int + """ + Sensitivity level (`1`,`2`,`3`,`4`) to use when classifying requests as malicious. With a high level, requests are more likely to be classed as malicious, and false positives are expected. With a lower level, requests are more likely to be classed as benign. + """ + + created_at: Optional[datetime] + """ + Date the WAF stage was created. + """ + + updated_at: Optional[datetime] + """ + Date the WAF stage was last updated. + """ + + backend_stage_id: Optional[str] + + +@dataclass +class SetRouteRulesRequestRouteRule: + rule_http_match: Optional[RuleHttpMatch] + + backend_stage_id: Optional[str] + + +@dataclass +class RouteRule: + position: int + """ + Position of the rule which determines the order of processing within the route stage. + """ + + route_stage_id: str + """ + Route stage ID the route rule belongs to. + """ + + rule_http_match: Optional[RuleHttpMatch] + + backend_stage_id: Optional[str] + + +@dataclass +class CheckPEMChainRequestSecretChain: + secret_id: str + + secret_region: str + + +@dataclass +class PlanDetails: + plan_name: PlanName + """ + Subscription plan name. + """ + + package_gb: int + """ + Amount of egress data from cache included in subscription plan. + """ + + pipeline_limit: int + """ + Number of pipelines included in subscription plan. + """ + + waf_requests: int + """ + Number of WAF requests included in subscription plan. + """ + + +@dataclass +class PlanUsageDetails: + plan_cost: Optional[Money] + """ + Cost to date (this month) for the corresponding Edge Services subscription plan. + """ + + +@dataclass +class HeadStageResponseHeadStage: + dns_stage_id: Optional[str] + + +@dataclass +class ListHeadStagesResponseHeadStage: + dns_stage_id: Optional[str] + + +@dataclass +class PipelineStages: + dns_stages: List[DNSStage] + + tls_stages: List[TLSStage] + + cache_stages: List[CacheStage] + + backend_stages: List[BackendStage] + + waf_stages: List[WafStage] + + route_stages: List[RouteStage] + + pipeline: Optional[Pipeline] + + +@dataclass +class PurgeRequest: + id: str + """ + ID of the purge request. + """ + + pipeline_id: str + """ + Pipeline ID the purge request belongs to. + """ + + status: PurgeRequestStatus + """ + Status of the purge request. + """ + + created_at: Optional[datetime] + """ + Date the purge request was created. + """ + + updated_at: Optional[datetime] + """ + Date the purge request was last updated. + """ + + assets: Optional[List[str]] + + all: Optional[bool] + + +@dataclass +class SetHeadStageRequestAddNewHeadStage: + new_stage_id: str + + +@dataclass +class SetHeadStageRequestRemoveHeadStage: + remove_stage_id: str + + +@dataclass +class SetHeadStageRequestSwapHeadStage: + new_stage_id: str + + current_stage_id: str + + +@dataclass +class TLSSecretsConfig: + tls_secrets: List[TLSSecret] + """ + Secret information (from Secret Manager). + """ + + +@dataclass +class AddRouteRulesRequest: + route_stage_id: str + """ + ID of the route stage to update. + """ + + route_rules: Optional[List[SetRouteRulesRequestRouteRule]] + """ + List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`. + """ + + after_position: Optional[int] + + before_position: Optional[int] + + +@dataclass +class AddRouteRulesResponse: + route_rules: List[RouteRule] + """ + List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`. + """ + + +@dataclass +class CheckDomainRequest: + fqdn: str + + cname: str + + project_id: Optional[str] + + +@dataclass +class CheckDomainResponse: + is_valid: bool + + +@dataclass +class CheckLbOriginRequest: + lb: Optional[ScalewayLb] + + +@dataclass +class CheckLbOriginResponse: + is_valid: bool + + error_type: LbOriginError + + +@dataclass +class CheckPEMChainRequest: + fqdn: str + + project_id: Optional[str] + + secret: Optional[CheckPEMChainRequestSecretChain] + + raw: Optional[str] + + +@dataclass +class CheckPEMChainResponse: + is_valid: bool + + +@dataclass +class CreateBackendStageRequest: + pipeline_id: str + """ + Pipeline ID the Backend stage belongs to. + """ + + scaleway_s3: Optional[ScalewayS3BackendConfig] + + scaleway_lb: Optional[ScalewayLbBackendConfig] + + +@dataclass +class CreateCacheStageRequest: + fallback_ttl: Optional[str] + """ + Time To Live (TTL) in seconds. Defines how long content is cached. + """ + + pipeline_id: str + """ + Pipeline ID the Cache stage belongs to. + """ + + backend_stage_id: Optional[str] + + waf_stage_id: Optional[str] + + route_stage_id: Optional[str] + + +@dataclass +class CreateDNSStageRequest: + fqdns: Optional[List[str]] + """ + Fully Qualified Domain Name (in the format subdomain.example.com) to attach to the stage. + """ + + pipeline_id: str + """ + Pipeline ID the DNS stage belongs to. + """ + + tls_stage_id: Optional[str] + + cache_stage_id: Optional[str] + + backend_stage_id: Optional[str] + + +@dataclass +class CreatePipelineRequest: + name: str + """ + Name of the pipeline. + """ + + description: str + """ + Description of the pipeline. + """ + + project_id: Optional[str] + """ + Project ID in which the pipeline will be created. + """ + + +@dataclass +class CreatePurgeRequestRequest: + pipeline_id: str + """ + Pipeline ID in which the purge request will be created. + """ + + assets: Optional[List[str]] + + all: Optional[bool] + + +@dataclass +class CreateRouteStageRequest: + pipeline_id: str + """ + Pipeline ID the route stage belongs to. + """ + + waf_stage_id: Optional[str] + + +@dataclass +class CreateTLSStageRequest: + secrets: Optional[List[TLSSecret]] + """ + Secret (from Scaleway Secret Manager) containing your custom certificate. + """ + + managed_certificate: Optional[bool] + """ + True when Scaleway generates and manages a Let's Encrypt certificate for the TLS stage/custom endpoint. + """ + + pipeline_id: str + """ + Pipeline ID the TLS stage belongs to. + """ + + cache_stage_id: Optional[str] + + backend_stage_id: Optional[str] + + route_stage_id: Optional[str] + + waf_stage_id: Optional[str] + + +@dataclass +class CreateWafStageRequest: + pipeline_id: str + """ + Pipeline ID the WAF stage belongs to. + """ + + paranoia_level: int + """ + Sensitivity level (`1`,`2`,`3`,`4`) to use when classifying requests as malicious. With a high level, requests are more likely to be classed as malicious, and false positives are expected. With a lower level, requests are more likely to be classed as benign. + """ + + mode: Optional[WafStageMode] + """ + Mode defining WAF behavior (`disable`/`log_only`/`enable`). + """ + + backend_stage_id: Optional[str] + + +@dataclass +class DeleteBackendStageRequest: + backend_stage_id: str + """ + ID of the backend stage to delete. + """ + + +@dataclass +class DeleteCacheStageRequest: + cache_stage_id: str + """ + ID of the cache stage to delete. + """ + + +@dataclass +class DeleteCurrentPlanRequest: + project_id: Optional[str] + + +@dataclass +class DeleteDNSStageRequest: + dns_stage_id: str + """ + ID of the DNS stage to delete. + """ + + +@dataclass +class DeletePipelineRequest: + pipeline_id: str + """ + ID of the pipeline to delete. + """ + + +@dataclass +class DeleteRouteStageRequest: + route_stage_id: str + """ + ID of the route stage to delete. + """ + + +@dataclass +class DeleteTLSStageRequest: + tls_stage_id: str + """ + ID of the TLS stage to delete. + """ + + +@dataclass +class DeleteWafStageRequest: + waf_stage_id: str + """ + ID of the WAF stage to delete. + """ + + +@dataclass +class GetBackendStageRequest: + backend_stage_id: str + """ + ID of the requested backend stage. + """ + + +@dataclass +class GetBillingRequest: + project_id: Optional[str] + + +@dataclass +class GetBillingResponse: + current_plan: Optional[PlanDetails] + """ + Information on the currently-selected, active Edge Services subscription plan. + """ + + pipeline_number: int + """ + Total number of pipelines currently configured. + """ + + current_plan_cache_usage: int + """ + Total amount of data egressed from the cache in gigabytes from the beginning of the month, for the active subscription plan. + """ + + extra_cache_usage: int + """ + Total amount of extra data egressed from cache in gigabytes from the beginning of the month, not included in the subscription plans. + """ + + current_plan_waf_usage: int + """ + Total number of requests processed by the WAF since the beginning of the current month, for the active subscription plan. + """ + + extra_waf_usage: int + """ + Total number of extra requests processed by the WAF from the beginning of the month, not included in the subscription plans. + """ + + plan_cost: Optional[Money] + """ + Cost to date (this month) for Edge Service subscription plans. This comprises the pro-rata cost of the current subscription plan, and any previous subscription plans that were active earlier in the month. + """ + + extra_pipelines_cost: Optional[Money] + """ + Cost to date (this month) of pipelines not included in the subscription plans. + """ + + plans_usage_details: Dict[str, PlanUsageDetails] + """ + Detailed costs and usage for all Edge Services subscription plans that were activated during the month. + """ + + extra_cache_cost: Optional[Money] + """ + Cost to date (this month) of the data egressed from the cache that is not included in the subscription plans. + """ + + extra_waf_cost: Optional[Money] + """ + Cost to date (this month) of the extra requests processed by the WAF that were not included in the subscription plans. + """ + + waf_add_on: Optional[Money] + """ + Cost of activating WAF add-on (where subscription plan does not include WAF). + """ + + total_cost: Optional[Money] + """ + Total cost to date (this month) of all Edge Services resources including active subscription plan, previously active plans, extra pipelines and extra egress cache data. + """ + + +@dataclass +class GetCacheStageRequest: + cache_stage_id: str + """ + ID of the requested cache stage. + """ + + +@dataclass +class GetCurrentPlanRequest: + project_id: Optional[str] + + +@dataclass +class GetDNSStageRequest: + dns_stage_id: str + """ + ID of the requested DNS stage. + """ + + +@dataclass +class GetPipelineRequest: + pipeline_id: str + """ + ID of the requested pipeline. + """ + + +@dataclass +class GetPurgeRequestRequest: + purge_request_id: str + """ + ID of the requested purge request. + """ + + +@dataclass +class GetRouteStageRequest: + route_stage_id: str + """ + ID of the requested route stage. + """ + + +@dataclass +class GetTLSStageRequest: + tls_stage_id: str + """ + ID of the requested TLS stage. + """ + + +@dataclass +class GetWafStageRequest: + waf_stage_id: str + """ + ID of the requested WAF stage. + """ + + +@dataclass +class HeadStageResponse: + head_stage: Optional[HeadStageResponseHeadStage] + """ + Modified or created head stage. + """ + + +@dataclass +class ListBackendStagesRequest: + order_by: Optional[ListBackendStagesRequestOrderBy] + """ + Sort order of backend stages in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of backend stages to return per page. + """ + + pipeline_id: str + """ + Pipeline ID to filter for. Only backend stages from this pipeline will be returned. + """ + + bucket_name: Optional[str] + """ + Bucket name to filter for. Only backend stages from this Bucket will be returned. + """ + + bucket_region: Optional[str] + """ + Bucket region to filter for. Only backend stages with buckets in this region will be returned. + """ + + lb_id: Optional[str] + """ + Load Balancer ID to filter for. Only backend stages with this Load Balancer will be returned. + """ + + +@dataclass +class ListBackendStagesResponse: + stages: List[BackendStage] + """ + Paginated list of backend stages. + """ + + total_count: int + """ + Count of all backend stages matching the requested criteria. + """ + + +@dataclass +class ListCacheStagesRequest: + order_by: Optional[ListCacheStagesRequestOrderBy] + """ + Sort order of cache stages in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of cache stages to return per page. + """ + + pipeline_id: str + """ + Pipeline ID to filter for. Only cache stages from this pipeline will be returned. + """ + + +@dataclass +class ListCacheStagesResponse: + stages: List[CacheStage] + """ + Paginated list of cache stages. + """ + + total_count: int + """ + Count of all cache stages matching the requested criteria. + """ + + +@dataclass +class ListDNSStagesRequest: + order_by: Optional[ListDNSStagesRequestOrderBy] + """ + Sort order of DNS stages in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of DNS stages to return per page. + """ + + pipeline_id: str + """ + Pipeline ID to filter for. Only DNS stages from this pipeline will be returned. + """ + + fqdn: Optional[str] + """ + Fully Qualified Domain Name to filter for (in the format subdomain.example.com). Only DNS stages with this FQDN will be returned. + """ + + +@dataclass +class ListDNSStagesResponse: + stages: List[DNSStage] + """ + Paginated list of DNS stages. + """ + + total_count: int + """ + Count of all DNS stages matching the requested criteria. + """ + + +@dataclass +class ListHeadStagesRequest: + pipeline_id: str + """ + ID of the pipeline to update. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of head stages to return per page. + """ + + +@dataclass +class ListHeadStagesResponse: + head_stages: List[ListHeadStagesResponseHeadStage] + """ + Number of head stages to return per page. + """ + + total_count: int + """ + Count of all head stages matching the requested pipeline_id. + """ + + +@dataclass +class ListPipelinesRequest: + order_by: Optional[ListPipelinesRequestOrderBy] + """ + Sort order of pipelines in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of pipelines to return per page. + """ + + name: Optional[str] + """ + Pipeline name to filter for. Only pipelines with this string within their name will be returned. + """ + + organization_id: Optional[str] + """ + Organization ID to filter for. Only pipelines from this Organization will be returned. + """ + + project_id: Optional[str] + """ + Project ID to filter for. Only pipelines from this Project will be returned. + """ + + has_backend_stage_lb: Optional[bool] + """ + Filter on backend stage. Only pipelines with a Load Balancer origin will be returned. + """ + + +@dataclass +class ListPipelinesResponse: + pipelines: List[Pipeline] + """ + Paginated list of pipelines. + """ + + total_count: int + """ + Count of all pipelines matching the requested criteria. + """ + + +@dataclass +class ListPipelinesWithStagesRequest: + order_by: Optional[ListPipelinesWithStagesRequestOrderBy] + + page: Optional[int] + + page_size: Optional[int] + + name: Optional[str] + + organization_id: Optional[str] + + project_id: Optional[str] + + +@dataclass +class ListPipelinesWithStagesResponse: + pipelines: List[PipelineStages] + + total_count: int + + +@dataclass +class ListPlansResponse: + total_count: int + + plans: List[PlanDetails] + + +@dataclass +class ListPurgeRequestsRequest: + order_by: Optional[ListPurgeRequestsRequestOrderBy] + """ + Sort order of purge requests in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of purge requests to return per page. + """ + + organization_id: Optional[str] + """ + Organization ID to filter for. Only purge requests from this Project will be returned. + """ + + project_id: Optional[str] + """ + Project ID to filter for. Only purge requests from this Project will be returned. + """ + + pipeline_id: Optional[str] + """ + Pipeline ID to filter for. Only purge requests from this pipeline will be returned. + """ + + +@dataclass +class ListPurgeRequestsResponse: + purge_requests: List[PurgeRequest] + """ + Paginated list of purge requests. + """ + + total_count: int + """ + Count of all purge requests matching the requested criteria. + """ + + +@dataclass +class ListRouteRulesRequest: + route_stage_id: str + """ + Route stage ID to filter for. Only route rules from this route stage will be returned. + """ + + +@dataclass +class ListRouteRulesResponse: + route_rules: List[RouteRule] + """ + List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`. + """ + + +@dataclass +class ListRouteStagesRequest: + order_by: Optional[ListRouteStagesRequestOrderBy] + """ + Sort order of route stages in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of route stages to return per page. + """ + + pipeline_id: str + """ + Pipeline ID to filter for. Only route stages from this pipeline will be returned. + """ + + +@dataclass +class ListRouteStagesResponse: + stages: List[RouteStage] + """ + Paginated list of summarized route stages. + """ + + total_count: int + """ + Count of all route stages matching the requested criteria. + """ + + +@dataclass +class ListTLSStagesRequest: + order_by: Optional[ListTLSStagesRequestOrderBy] + """ + Sort order of TLS stages in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of TLS stages to return per page. + """ + + pipeline_id: str + """ + Pipeline ID to filter for. Only TLS stages from this pipeline will be returned. + """ + + secret_id: Optional[str] + """ + Secret ID to filter for. Only TLS stages with this Secret ID will be returned. + """ + + secret_region: Optional[str] + """ + Secret region to filter for. Only TLS stages with a Secret in this region will be returned. + """ + + +@dataclass +class ListTLSStagesResponse: + stages: List[TLSStage] + """ + Paginated list of TLS stages. + """ + + total_count: int + """ + Count of all TLS stages matching the requested criteria. + """ + + +@dataclass +class ListWafStagesRequest: + order_by: Optional[ListWafStagesRequestOrderBy] + """ + Sort order of WAF stages in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of WAF stages to return per page. + """ + + pipeline_id: str + """ + Pipeline ID to filter for. Only WAF stages from this pipeline will be returned. + """ + + +@dataclass +class ListWafStagesResponse: + stages: List[WafStage] + """ + Paginated list of WAF stages. + """ + + total_count: int + """ + Count of all WAF stages matching the requested criteria. + """ + + +@dataclass +class Plan: + plan_name: PlanName + + +@dataclass +class SearchBackendStagesRequest: + order_by: Optional[SearchBackendStagesRequestOrderBy] + + page: Optional[int] + + page_size: Optional[int] + + project_id: Optional[str] + + bucket_name: Optional[str] + + bucket_region: Optional[str] + + lb_id: Optional[str] + + +@dataclass +class SelectPlanRequest: + project_id: Optional[str] + + plan_name: Optional[PlanName] + + +@dataclass +class SetHeadStageRequest: + pipeline_id: str + """ + ID of the pipeline to update. + """ + + add_new_head_stage: Optional[SetHeadStageRequestAddNewHeadStage] + + remove_head_stage: Optional[SetHeadStageRequestRemoveHeadStage] + + swap_head_stage: Optional[SetHeadStageRequestSwapHeadStage] + + +@dataclass +class SetRouteRulesRequest: + route_stage_id: str + """ + ID of the route stage to update. + """ + + route_rules: Optional[List[SetRouteRulesRequestRouteRule]] + """ + List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`. + """ + + +@dataclass +class SetRouteRulesResponse: + route_rules: List[RouteRule] + """ + List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`. + """ + + +@dataclass +class UpdateBackendStageRequest: + backend_stage_id: str + """ + ID of the backend stage to update. + """ + + pipeline_id: str + """ + Pipeline ID the Backend stage belongs to. + """ + + scaleway_s3: Optional[ScalewayS3BackendConfig] + + scaleway_lb: Optional[ScalewayLbBackendConfig] + + +@dataclass +class UpdateCacheStageRequest: + cache_stage_id: str + """ + ID of the cache stage to update. + """ + + fallback_ttl: Optional[str] + """ + Time To Live (TTL) in seconds. Defines how long content is cached. + """ + + backend_stage_id: Optional[str] + + waf_stage_id: Optional[str] + + route_stage_id: Optional[str] + + +@dataclass +class UpdateDNSStageRequest: + dns_stage_id: str + """ + ID of the DNS stage to update. + """ + + fqdns: Optional[List[str]] + """ + Fully Qualified Domain Name (in the format subdomain.example.com) attached to the stage. + """ + + tls_stage_id: Optional[str] + + cache_stage_id: Optional[str] + + backend_stage_id: Optional[str] + + +@dataclass +class UpdatePipelineRequest: + pipeline_id: str + """ + ID of the pipeline to update. + """ + + name: Optional[str] + """ + Name of the pipeline. + """ + + description: Optional[str] + """ + Description of the pipeline. + """ + + +@dataclass +class UpdateRouteStageRequest: + route_stage_id: str + """ + ID of the route stage to update. + """ + + waf_stage_id: Optional[str] + + +@dataclass +class UpdateTLSStageRequest: + tls_stage_id: str + """ + ID of the TLS stage to update. + """ + + tls_secrets_config: Optional[TLSSecretsConfig] + """ + Secret (from Scaleway Secret-Manager) containing your custom certificate. + """ + + managed_certificate: Optional[bool] + """ + True when Scaleway generates and manages a Let's Encrypt certificate for the TLS stage/custom endpoint. + """ + + cache_stage_id: Optional[str] + + backend_stage_id: Optional[str] + + route_stage_id: Optional[str] + + waf_stage_id: Optional[str] + + +@dataclass +class UpdateWafStageRequest: + waf_stage_id: str + """ + ID of the WAF stage to update. + """ + + mode: Optional[WafStageMode] + """ + Mode defining WAF behavior (`disable`/`log_only`/`enable`). + """ + + paranoia_level: Optional[int] + """ + Sensitivity level (`1`,`2`,`3`,`4`) to use when classifying requests as malicious. With a high level, requests are more likely to be classed as malicious, and false positives are expected. With a lower level, requests are more likely to be classed as benign. + """ + + backend_stage_id: Optional[str] diff --git a/scaleway/scaleway/edge_services/v1beta1/__init__.py b/scaleway/scaleway/edge_services/v1beta1/__init__.py new file mode 100644 index 000000000..88bf53a51 --- /dev/null +++ b/scaleway/scaleway/edge_services/v1beta1/__init__.py @@ -0,0 +1,253 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from .types import DNSStageType +from .types import LbOriginError +from .types import ListBackendStagesRequestOrderBy +from .types import ListCacheStagesRequestOrderBy +from .types import ListDNSStagesRequestOrderBy +from .types import ListPipelinesRequestOrderBy +from .types import ListPipelinesWithStagesRequestOrderBy +from .types import ListPurgeRequestsRequestOrderBy +from .types import ListRouteStagesRequestOrderBy +from .types import ListTLSStagesRequestOrderBy +from .types import ListWafStagesRequestOrderBy +from .types import PipelineErrorCode +from .types import PipelineErrorSeverity +from .types import PipelineErrorStage +from .types import PipelineErrorType +from .types import PipelineStatus +from .content import PIPELINE_TRANSIENT_STATUSES +from .types import PlanName +from .types import PurgeRequestStatus +from .content import PURGE_REQUEST_TRANSIENT_STATUSES +from .types import RuleHttpMatchMethodFilter +from .types import RuleHttpMatchPathFilterPathFilterType +from .types import SearchBackendStagesRequestOrderBy +from .types import WafStageMode +from .types import ScalewayLb +from .types import RuleHttpMatchPathFilter +from .types import ScalewayLbBackendConfig +from .types import ScalewayS3BackendConfig +from .types import PipelineError +from .types import TLSSecret +from .types import RuleHttpMatch +from .types import BackendStage +from .types import CacheStage +from .types import DNSStage +from .types import Pipeline +from .types import RouteStage +from .types import TLSStage +from .types import WafStage +from .types import SetRouteRulesRequestRouteRule +from .types import RouteRule +from .types import CheckPEMChainRequestSecretChain +from .types import PlanDetails +from .types import PlanUsageDetails +from .types import HeadStageResponseHeadStage +from .types import ListHeadStagesResponseHeadStage +from .types import PipelineStages +from .types import PurgeRequest +from .types import SetHeadStageRequestAddNewHeadStage +from .types import SetHeadStageRequestRemoveHeadStage +from .types import SetHeadStageRequestSwapHeadStage +from .types import TLSSecretsConfig +from .types import AddRouteRulesRequest +from .types import AddRouteRulesResponse +from .types import CheckDomainRequest +from .types import CheckDomainResponse +from .types import CheckLbOriginRequest +from .types import CheckLbOriginResponse +from .types import CheckPEMChainRequest +from .types import CheckPEMChainResponse +from .types import CreateBackendStageRequest +from .types import CreateCacheStageRequest +from .types import CreateDNSStageRequest +from .types import CreatePipelineRequest +from .types import CreatePurgeRequestRequest +from .types import CreateRouteStageRequest +from .types import CreateTLSStageRequest +from .types import CreateWafStageRequest +from .types import DeleteBackendStageRequest +from .types import DeleteCacheStageRequest +from .types import DeleteCurrentPlanRequest +from .types import DeleteDNSStageRequest +from .types import DeletePipelineRequest +from .types import DeleteRouteStageRequest +from .types import DeleteTLSStageRequest +from .types import DeleteWafStageRequest +from .types import GetBackendStageRequest +from .types import GetBillingRequest +from .types import GetBillingResponse +from .types import GetCacheStageRequest +from .types import GetCurrentPlanRequest +from .types import GetDNSStageRequest +from .types import GetPipelineRequest +from .types import GetPurgeRequestRequest +from .types import GetRouteStageRequest +from .types import GetTLSStageRequest +from .types import GetWafStageRequest +from .types import HeadStageResponse +from .types import ListBackendStagesRequest +from .types import ListBackendStagesResponse +from .types import ListCacheStagesRequest +from .types import ListCacheStagesResponse +from .types import ListDNSStagesRequest +from .types import ListDNSStagesResponse +from .types import ListHeadStagesRequest +from .types import ListHeadStagesResponse +from .types import ListPipelinesRequest +from .types import ListPipelinesResponse +from .types import ListPipelinesWithStagesRequest +from .types import ListPipelinesWithStagesResponse +from .types import ListPlansResponse +from .types import ListPurgeRequestsRequest +from .types import ListPurgeRequestsResponse +from .types import ListRouteRulesRequest +from .types import ListRouteRulesResponse +from .types import ListRouteStagesRequest +from .types import ListRouteStagesResponse +from .types import ListTLSStagesRequest +from .types import ListTLSStagesResponse +from .types import ListWafStagesRequest +from .types import ListWafStagesResponse +from .types import Plan +from .types import SearchBackendStagesRequest +from .types import SelectPlanRequest +from .types import SetHeadStageRequest +from .types import SetRouteRulesRequest +from .types import SetRouteRulesResponse +from .types import UpdateBackendStageRequest +from .types import UpdateCacheStageRequest +from .types import UpdateDNSStageRequest +from .types import UpdatePipelineRequest +from .types import UpdateRouteStageRequest +from .types import UpdateTLSStageRequest +from .types import UpdateWafStageRequest +from .api import EdgeServicesV1Beta1API + +__all__ = [ + "DNSStageType", + "LbOriginError", + "ListBackendStagesRequestOrderBy", + "ListCacheStagesRequestOrderBy", + "ListDNSStagesRequestOrderBy", + "ListPipelinesRequestOrderBy", + "ListPipelinesWithStagesRequestOrderBy", + "ListPurgeRequestsRequestOrderBy", + "ListRouteStagesRequestOrderBy", + "ListTLSStagesRequestOrderBy", + "ListWafStagesRequestOrderBy", + "PipelineErrorCode", + "PipelineErrorSeverity", + "PipelineErrorStage", + "PipelineErrorType", + "PipelineStatus", + "PIPELINE_TRANSIENT_STATUSES", + "PlanName", + "PurgeRequestStatus", + "PURGE_REQUEST_TRANSIENT_STATUSES", + "RuleHttpMatchMethodFilter", + "RuleHttpMatchPathFilterPathFilterType", + "SearchBackendStagesRequestOrderBy", + "WafStageMode", + "ScalewayLb", + "RuleHttpMatchPathFilter", + "ScalewayLbBackendConfig", + "ScalewayS3BackendConfig", + "PipelineError", + "TLSSecret", + "RuleHttpMatch", + "BackendStage", + "CacheStage", + "DNSStage", + "Pipeline", + "RouteStage", + "TLSStage", + "WafStage", + "SetRouteRulesRequestRouteRule", + "RouteRule", + "CheckPEMChainRequestSecretChain", + "PlanDetails", + "PlanUsageDetails", + "HeadStageResponseHeadStage", + "ListHeadStagesResponseHeadStage", + "PipelineStages", + "PurgeRequest", + "SetHeadStageRequestAddNewHeadStage", + "SetHeadStageRequestRemoveHeadStage", + "SetHeadStageRequestSwapHeadStage", + "TLSSecretsConfig", + "AddRouteRulesRequest", + "AddRouteRulesResponse", + "CheckDomainRequest", + "CheckDomainResponse", + "CheckLbOriginRequest", + "CheckLbOriginResponse", + "CheckPEMChainRequest", + "CheckPEMChainResponse", + "CreateBackendStageRequest", + "CreateCacheStageRequest", + "CreateDNSStageRequest", + "CreatePipelineRequest", + "CreatePurgeRequestRequest", + "CreateRouteStageRequest", + "CreateTLSStageRequest", + "CreateWafStageRequest", + "DeleteBackendStageRequest", + "DeleteCacheStageRequest", + "DeleteCurrentPlanRequest", + "DeleteDNSStageRequest", + "DeletePipelineRequest", + "DeleteRouteStageRequest", + "DeleteTLSStageRequest", + "DeleteWafStageRequest", + "GetBackendStageRequest", + "GetBillingRequest", + "GetBillingResponse", + "GetCacheStageRequest", + "GetCurrentPlanRequest", + "GetDNSStageRequest", + "GetPipelineRequest", + "GetPurgeRequestRequest", + "GetRouteStageRequest", + "GetTLSStageRequest", + "GetWafStageRequest", + "HeadStageResponse", + "ListBackendStagesRequest", + "ListBackendStagesResponse", + "ListCacheStagesRequest", + "ListCacheStagesResponse", + "ListDNSStagesRequest", + "ListDNSStagesResponse", + "ListHeadStagesRequest", + "ListHeadStagesResponse", + "ListPipelinesRequest", + "ListPipelinesResponse", + "ListPipelinesWithStagesRequest", + "ListPipelinesWithStagesResponse", + "ListPlansResponse", + "ListPurgeRequestsRequest", + "ListPurgeRequestsResponse", + "ListRouteRulesRequest", + "ListRouteRulesResponse", + "ListRouteStagesRequest", + "ListRouteStagesResponse", + "ListTLSStagesRequest", + "ListTLSStagesResponse", + "ListWafStagesRequest", + "ListWafStagesResponse", + "Plan", + "SearchBackendStagesRequest", + "SelectPlanRequest", + "SetHeadStageRequest", + "SetRouteRulesRequest", + "SetRouteRulesResponse", + "UpdateBackendStageRequest", + "UpdateCacheStageRequest", + "UpdateDNSStageRequest", + "UpdatePipelineRequest", + "UpdateRouteStageRequest", + "UpdateTLSStageRequest", + "UpdateWafStageRequest", + "EdgeServicesV1Beta1API", +] diff --git a/scaleway/scaleway/edge_services/v1beta1/api.py b/scaleway/scaleway/edge_services/v1beta1/api.py new file mode 100644 index 000000000..06c92a1c4 --- /dev/null +++ b/scaleway/scaleway/edge_services/v1beta1/api.py @@ -0,0 +1,2610 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import List, Optional + +from scaleway_core.api import API +from scaleway_core.utils import ( + WaitForOptions, + validate_path_param, + fetch_all_pages, + wait_for_resource, +) +from .types import ( + ListBackendStagesRequestOrderBy, + ListCacheStagesRequestOrderBy, + ListDNSStagesRequestOrderBy, + ListPipelinesRequestOrderBy, + ListPipelinesWithStagesRequestOrderBy, + ListPurgeRequestsRequestOrderBy, + ListRouteStagesRequestOrderBy, + ListTLSStagesRequestOrderBy, + ListWafStagesRequestOrderBy, + PlanName, + SearchBackendStagesRequestOrderBy, + WafStageMode, + AddRouteRulesRequest, + AddRouteRulesResponse, + BackendStage, + CacheStage, + CheckDomainRequest, + CheckDomainResponse, + CheckLbOriginRequest, + CheckLbOriginResponse, + CheckPEMChainRequest, + CheckPEMChainRequestSecretChain, + CheckPEMChainResponse, + CreateBackendStageRequest, + CreateCacheStageRequest, + CreateDNSStageRequest, + CreatePipelineRequest, + CreatePurgeRequestRequest, + CreateRouteStageRequest, + CreateTLSStageRequest, + CreateWafStageRequest, + DNSStage, + GetBillingResponse, + HeadStageResponse, + ListBackendStagesResponse, + ListCacheStagesResponse, + ListDNSStagesResponse, + ListHeadStagesResponse, + ListHeadStagesResponseHeadStage, + ListPipelinesResponse, + ListPipelinesWithStagesResponse, + ListPlansResponse, + ListPurgeRequestsResponse, + ListRouteRulesResponse, + ListRouteStagesResponse, + ListTLSStagesResponse, + ListWafStagesResponse, + Pipeline, + PipelineStages, + Plan, + PurgeRequest, + RouteStage, + ScalewayLb, + ScalewayLbBackendConfig, + ScalewayS3BackendConfig, + SelectPlanRequest, + SetHeadStageRequest, + SetHeadStageRequestAddNewHeadStage, + SetHeadStageRequestRemoveHeadStage, + SetHeadStageRequestSwapHeadStage, + SetRouteRulesRequest, + SetRouteRulesRequestRouteRule, + SetRouteRulesResponse, + TLSSecret, + TLSSecretsConfig, + TLSStage, + UpdateBackendStageRequest, + UpdateCacheStageRequest, + UpdateDNSStageRequest, + UpdatePipelineRequest, + UpdateRouteStageRequest, + UpdateTLSStageRequest, + UpdateWafStageRequest, + WafStage, +) +from .content import ( + PIPELINE_TRANSIENT_STATUSES, + PURGE_REQUEST_TRANSIENT_STATUSES, +) +from .marshalling import ( + unmarshal_BackendStage, + unmarshal_CacheStage, + unmarshal_DNSStage, + unmarshal_Pipeline, + unmarshal_RouteStage, + unmarshal_TLSStage, + unmarshal_WafStage, + unmarshal_PurgeRequest, + unmarshal_AddRouteRulesResponse, + unmarshal_CheckDomainResponse, + unmarshal_CheckLbOriginResponse, + unmarshal_CheckPEMChainResponse, + unmarshal_GetBillingResponse, + unmarshal_HeadStageResponse, + unmarshal_ListBackendStagesResponse, + unmarshal_ListCacheStagesResponse, + unmarshal_ListDNSStagesResponse, + unmarshal_ListHeadStagesResponse, + unmarshal_ListPipelinesResponse, + unmarshal_ListPipelinesWithStagesResponse, + unmarshal_ListPlansResponse, + unmarshal_ListPurgeRequestsResponse, + unmarshal_ListRouteRulesResponse, + unmarshal_ListRouteStagesResponse, + unmarshal_ListTLSStagesResponse, + unmarshal_ListWafStagesResponse, + unmarshal_Plan, + unmarshal_SetRouteRulesResponse, + marshal_AddRouteRulesRequest, + marshal_CheckDomainRequest, + marshal_CheckLbOriginRequest, + marshal_CheckPEMChainRequest, + marshal_CreateBackendStageRequest, + marshal_CreateCacheStageRequest, + marshal_CreateDNSStageRequest, + marshal_CreatePipelineRequest, + marshal_CreatePurgeRequestRequest, + marshal_CreateRouteStageRequest, + marshal_CreateTLSStageRequest, + marshal_CreateWafStageRequest, + marshal_SelectPlanRequest, + marshal_SetHeadStageRequest, + marshal_SetRouteRulesRequest, + marshal_UpdateBackendStageRequest, + marshal_UpdateCacheStageRequest, + marshal_UpdateDNSStageRequest, + marshal_UpdatePipelineRequest, + marshal_UpdateRouteStageRequest, + marshal_UpdateTLSStageRequest, + marshal_UpdateWafStageRequest, +) + + +class EdgeServicesV1Beta1API(API): + """ """ + + def list_pipelines( + self, + *, + order_by: Optional[ListPipelinesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + has_backend_stage_lb: Optional[bool] = None, + ) -> ListPipelinesResponse: + """ + List pipelines. + List all pipelines, for a Scaleway Organization or Scaleway Project. By default, the pipelines returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of pipelines in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of pipelines to return per page. + :param name: Pipeline name to filter for. Only pipelines with this string within their name will be returned. + :param organization_id: Organization ID to filter for. Only pipelines from this Organization will be returned. + :param project_id: Project ID to filter for. Only pipelines from this Project will be returned. + :param has_backend_stage_lb: Filter on backend stage. Only pipelines with a Load Balancer origin will be returned. + :return: :class:`ListPipelinesResponse ` + + Usage: + :: + + result = api.list_pipelines() + """ + + res = self._request( + "GET", + "/edge-services/v1beta1/pipelines", + params={ + "has_backend_stage_lb": has_backend_stage_lb, + "name": name, + "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_ListPipelinesResponse(res.json()) + + def list_pipelines_all( + self, + *, + order_by: Optional[ListPipelinesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + has_backend_stage_lb: Optional[bool] = None, + ) -> List[Pipeline]: + """ + List pipelines. + List all pipelines, for a Scaleway Organization or Scaleway Project. By default, the pipelines returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of pipelines in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of pipelines to return per page. + :param name: Pipeline name to filter for. Only pipelines with this string within their name will be returned. + :param organization_id: Organization ID to filter for. Only pipelines from this Organization will be returned. + :param project_id: Project ID to filter for. Only pipelines from this Project will be returned. + :param has_backend_stage_lb: Filter on backend stage. Only pipelines with a Load Balancer origin will be returned. + :return: :class:`List[Pipeline] ` + + Usage: + :: + + result = api.list_pipelines_all() + """ + + return fetch_all_pages( + type=ListPipelinesResponse, + key="pipelines", + fetcher=self.list_pipelines, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "name": name, + "organization_id": organization_id, + "project_id": project_id, + "has_backend_stage_lb": has_backend_stage_lb, + }, + ) + + def create_pipeline( + self, + *, + name: str, + description: str, + project_id: Optional[str] = None, + ) -> Pipeline: + """ + Create pipeline. + Create a new pipeline. You must specify a `dns_stage_id` to form a stage-chain that goes all the way to the backend stage (origin), so the HTTP request will be processed according to the stages you created. + :param name: Name of the pipeline. + :param description: Description of the pipeline. + :param project_id: Project ID in which the pipeline will be created. + :return: :class:`Pipeline ` + + Usage: + :: + + result = api.create_pipeline( + name="example", + description="example", + ) + """ + + res = self._request( + "POST", + "/edge-services/v1beta1/pipelines", + body=marshal_CreatePipelineRequest( + CreatePipelineRequest( + name=name, + description=description, + project_id=project_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Pipeline(res.json()) + + def get_pipeline( + self, + *, + pipeline_id: str, + ) -> Pipeline: + """ + Get pipeline. + Retrieve information about an existing pipeline, specified by its `pipeline_id`. Its full details, including errors, are returned in the response object. + :param pipeline_id: ID of the requested pipeline. + :return: :class:`Pipeline ` + + Usage: + :: + + result = api.get_pipeline( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}", + ) + + self._throw_on_error(res) + return unmarshal_Pipeline(res.json()) + + def wait_for_pipeline( + self, + *, + pipeline_id: str, + options: Optional[WaitForOptions[Pipeline, bool]] = None, + ) -> Pipeline: + """ + Get pipeline. + Retrieve information about an existing pipeline, specified by its `pipeline_id`. Its full details, including errors, are returned in the response object. + :param pipeline_id: ID of the requested pipeline. + :return: :class:`Pipeline ` + + Usage: + :: + + result = api.get_pipeline( + pipeline_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in PIPELINE_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_pipeline, + options=options, + args={ + "pipeline_id": pipeline_id, + }, + ) + + def list_pipelines_with_stages( + self, + *, + order_by: Optional[ListPipelinesWithStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + ) -> ListPipelinesWithStagesResponse: + """ + :param order_by: + :param page: + :param page_size: + :param name: + :param organization_id: + :param project_id: + :return: :class:`ListPipelinesWithStagesResponse ` + + Usage: + :: + + result = api.list_pipelines_with_stages() + """ + + res = self._request( + "GET", + "/edge-services/v1beta1/pipelines-stages", + params={ + "name": name, + "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_ListPipelinesWithStagesResponse(res.json()) + + def list_pipelines_with_stages_all( + self, + *, + order_by: Optional[ListPipelinesWithStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + ) -> List[PipelineStages]: + """ + :param order_by: + :param page: + :param page_size: + :param name: + :param organization_id: + :param project_id: + :return: :class:`List[PipelineStages] ` + + Usage: + :: + + result = api.list_pipelines_with_stages_all() + """ + + return fetch_all_pages( + type=ListPipelinesWithStagesResponse, + key="pipelines", + fetcher=self.list_pipelines_with_stages, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "name": name, + "organization_id": organization_id, + "project_id": project_id, + }, + ) + + def update_pipeline( + self, + *, + pipeline_id: str, + name: Optional[str] = None, + description: Optional[str] = None, + ) -> Pipeline: + """ + Update pipeline. + Update the parameters of an existing pipeline, specified by its `pipeline_id`. Parameters which can be updated include the `name`, `description` and `dns_stage_id`. + :param pipeline_id: ID of the pipeline to update. + :param name: Name of the pipeline. + :param description: Description of the pipeline. + :return: :class:`Pipeline ` + + Usage: + :: + + result = api.update_pipeline( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "PATCH", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}", + body=marshal_UpdatePipelineRequest( + UpdatePipelineRequest( + pipeline_id=pipeline_id, + name=name, + description=description, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Pipeline(res.json()) + + def delete_pipeline( + self, + *, + pipeline_id: str, + ) -> None: + """ + Delete pipeline. + Delete an existing pipeline, specified by its `pipeline_id`. Deleting a pipeline is permanent, and cannot be undone. Note that all stages linked to the pipeline are also deleted. + :param pipeline_id: ID of the pipeline to delete. + + Usage: + :: + + result = api.delete_pipeline( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}", + ) + + self._throw_on_error(res) + + def list_head_stages( + self, + *, + pipeline_id: str, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListHeadStagesResponse: + """ + :param pipeline_id: ID of the pipeline to update. + :param page: Page number to return, from the paginated results. + :param page_size: Number of head stages to return per page. + :return: :class:`ListHeadStagesResponse ` + + Usage: + :: + + result = api.list_head_stages( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/head-stages", + params={ + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListHeadStagesResponse(res.json()) + + def list_head_stages_all( + self, + *, + pipeline_id: str, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ListHeadStagesResponseHeadStage]: + """ + :param pipeline_id: ID of the pipeline to update. + :param page: Page number to return, from the paginated results. + :param page_size: Number of head stages to return per page. + :return: :class:`List[ListHeadStagesResponseHeadStage] ` + + Usage: + :: + + result = api.list_head_stages_all( + pipeline_id="example", + ) + """ + + return fetch_all_pages( + type=ListHeadStagesResponse, + key="head_stages", + fetcher=self.list_head_stages, + args={ + "pipeline_id": pipeline_id, + "page": page, + "page_size": page_size, + }, + ) + + def set_head_stage( + self, + *, + pipeline_id: str, + add_new_head_stage: Optional[SetHeadStageRequestAddNewHeadStage] = None, + remove_head_stage: Optional[SetHeadStageRequestRemoveHeadStage] = None, + swap_head_stage: Optional[SetHeadStageRequestSwapHeadStage] = None, + ) -> HeadStageResponse: + """ + Configure a entry point to your pipeline. You must specify a `head stage` to form a stage-chain that goes all the way to the backend stage (origin), so the HTTP request will be processed according to the stages you created. + You must specify either a `add_new_head_stage` (to add a new head stage), `remove_head_stage` (to remove a head stage) or `swap_head_stage` (to replace a head stage). + :param pipeline_id: ID of the pipeline to update. + :param add_new_head_stage: Add a new head stage. + One-Of ('action'): at most one of 'add_new_head_stage', 'remove_head_stage', 'swap_head_stage' could be set. + :param remove_head_stage: Remove a head stage. + One-Of ('action'): at most one of 'add_new_head_stage', 'remove_head_stage', 'swap_head_stage' could be set. + :param swap_head_stage: Replace a head stage with a new one. + One-Of ('action'): at most one of 'add_new_head_stage', 'remove_head_stage', 'swap_head_stage' could be set. + :return: :class:`HeadStageResponse ` + + Usage: + :: + + result = api.set_head_stage( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/set-head-stage", + body=marshal_SetHeadStageRequest( + SetHeadStageRequest( + pipeline_id=pipeline_id, + add_new_head_stage=add_new_head_stage, + remove_head_stage=remove_head_stage, + swap_head_stage=swap_head_stage, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_HeadStageResponse(res.json()) + + def list_dns_stages( + self, + *, + order_by: Optional[ListDNSStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + fqdn: Optional[str] = None, + ) -> ListDNSStagesResponse: + """ + List DNS stages. + List all DNS stages, for a Scaleway Organization or Scaleway Project. By default, the DNS stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of DNS stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of DNS stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only DNS stages from this pipeline will be returned. + :param fqdn: Fully Qualified Domain Name to filter for (in the format subdomain.example.com). Only DNS stages with this FQDN will be returned. + :return: :class:`ListDNSStagesResponse ` + + Usage: + :: + + result = api.list_dns_stages( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/dns-stages", + params={ + "fqdn": fqdn, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListDNSStagesResponse(res.json()) + + def list_dns_stages_all( + self, + *, + order_by: Optional[ListDNSStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + fqdn: Optional[str] = None, + ) -> List[DNSStage]: + """ + List DNS stages. + List all DNS stages, for a Scaleway Organization or Scaleway Project. By default, the DNS stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of DNS stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of DNS stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only DNS stages from this pipeline will be returned. + :param fqdn: Fully Qualified Domain Name to filter for (in the format subdomain.example.com). Only DNS stages with this FQDN will be returned. + :return: :class:`List[DNSStage] ` + + Usage: + :: + + result = api.list_dns_stages_all( + pipeline_id="example", + ) + """ + + return fetch_all_pages( + type=ListDNSStagesResponse, + key="stages", + fetcher=self.list_dns_stages, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "pipeline_id": pipeline_id, + "fqdn": fqdn, + }, + ) + + def create_dns_stage( + self, + *, + fqdns: Optional[List[str]] = None, + tls_stage_id: Optional[str] = None, + cache_stage_id: Optional[str] = None, + backend_stage_id: Optional[str] = None, + pipeline_id: str, + ) -> DNSStage: + """ + Create DNS stage. + Create a new DNS stage. You must specify the `fqdns` field to customize the domain endpoint, using a domain you already own. + :param fqdns: Fully Qualified Domain Name (in the format subdomain.example.com) to attach to the stage. + :param tls_stage_id: TLS 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 cache_stage_id: Cache 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 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 pipeline_id: Pipeline ID the DNS stage belongs to. + :return: :class:`DNSStage ` + + Usage: + :: + + result = api.create_dns_stage( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/dns-stages", + body=marshal_CreateDNSStageRequest( + CreateDNSStageRequest( + fqdns=fqdns, + pipeline_id=pipeline_id, + tls_stage_id=tls_stage_id, + cache_stage_id=cache_stage_id, + backend_stage_id=backend_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_DNSStage(res.json()) + + def get_dns_stage( + self, + *, + dns_stage_id: str, + ) -> DNSStage: + """ + Get DNS stage. + Retrieve information about an existing DNS stage, specified by its `dns_stage_id`. Its full details, including FQDNs, are returned in the response object. + :param dns_stage_id: ID of the requested DNS stage. + :return: :class:`DNSStage ` + + Usage: + :: + + result = api.get_dns_stage( + dns_stage_id="example", + ) + """ + + param_dns_stage_id = validate_path_param("dns_stage_id", dns_stage_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/dns-stages/{param_dns_stage_id}", + ) + + self._throw_on_error(res) + return unmarshal_DNSStage(res.json()) + + def update_dns_stage( + self, + *, + dns_stage_id: str, + fqdns: Optional[List[str]] = None, + tls_stage_id: Optional[str] = None, + cache_stage_id: Optional[str] = None, + backend_stage_id: Optional[str] = None, + ) -> DNSStage: + """ + Update DNS stage. + Update the parameters of an existing DNS stage, specified by its `dns_stage_id`. + :param dns_stage_id: ID of the DNS stage to update. + :param fqdns: Fully Qualified Domain Name (in the format subdomain.example.com) attached to the stage. + :param tls_stage_id: TLS 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 cache_stage_id: Cache 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 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. + :return: :class:`DNSStage ` + + Usage: + :: + + result = api.update_dns_stage( + dns_stage_id="example", + ) + """ + + param_dns_stage_id = validate_path_param("dns_stage_id", dns_stage_id) + + res = self._request( + "PATCH", + f"/edge-services/v1beta1/dns-stages/{param_dns_stage_id}", + body=marshal_UpdateDNSStageRequest( + UpdateDNSStageRequest( + dns_stage_id=dns_stage_id, + fqdns=fqdns, + tls_stage_id=tls_stage_id, + cache_stage_id=cache_stage_id, + backend_stage_id=backend_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_DNSStage(res.json()) + + def delete_dns_stage( + self, + *, + dns_stage_id: str, + ) -> None: + """ + Delete DNS stage. + Delete an existing DNS stage, specified by its `dns_stage_id`. Deleting a DNS stage is permanent, and cannot be undone. + :param dns_stage_id: ID of the DNS stage to delete. + + Usage: + :: + + result = api.delete_dns_stage( + dns_stage_id="example", + ) + """ + + param_dns_stage_id = validate_path_param("dns_stage_id", dns_stage_id) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/dns-stages/{param_dns_stage_id}", + ) + + self._throw_on_error(res) + + def list_tls_stages( + self, + *, + order_by: Optional[ListTLSStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + secret_id: Optional[str] = None, + secret_region: Optional[str] = None, + ) -> ListTLSStagesResponse: + """ + List TLS stages. + List all TLS stages, for a Scaleway Organization or Scaleway Project. By default, the TLS stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of TLS stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of TLS stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only TLS stages from this pipeline will be returned. + :param secret_id: Secret ID to filter for. Only TLS stages with this Secret ID will be returned. + :param secret_region: Secret region to filter for. Only TLS stages with a Secret in this region will be returned. + :return: :class:`ListTLSStagesResponse ` + + Usage: + :: + + result = api.list_tls_stages( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/tls-stages", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "secret_id": secret_id, + "secret_region": secret_region, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListTLSStagesResponse(res.json()) + + def list_tls_stages_all( + self, + *, + order_by: Optional[ListTLSStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + secret_id: Optional[str] = None, + secret_region: Optional[str] = None, + ) -> List[TLSStage]: + """ + List TLS stages. + List all TLS stages, for a Scaleway Organization or Scaleway Project. By default, the TLS stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of TLS stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of TLS stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only TLS stages from this pipeline will be returned. + :param secret_id: Secret ID to filter for. Only TLS stages with this Secret ID will be returned. + :param secret_region: Secret region to filter for. Only TLS stages with a Secret in this region will be returned. + :return: :class:`List[TLSStage] ` + + Usage: + :: + + result = api.list_tls_stages_all( + pipeline_id="example", + ) + """ + + return fetch_all_pages( + type=ListTLSStagesResponse, + key="stages", + fetcher=self.list_tls_stages, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "pipeline_id": pipeline_id, + "secret_id": secret_id, + "secret_region": secret_region, + }, + ) + + def create_tls_stage( + self, + *, + secrets: Optional[List[TLSSecret]] = None, + managed_certificate: Optional[bool] = None, + cache_stage_id: Optional[str] = None, + backend_stage_id: Optional[str] = None, + pipeline_id: str, + route_stage_id: Optional[str] = None, + waf_stage_id: Optional[str] = None, + ) -> TLSStage: + """ + Create TLS stage. + Create a new TLS stage. You must specify either the `secrets` or `managed_certificate` fields to customize the SSL/TLS certificate of your endpoint. Choose `secrets` if you are using a pre-existing certificate held in Scaleway Secret Manager, or `managed_certificate` to let Scaleway generate and manage a Let's Encrypt certificate for your customized endpoint. + :param secrets: Secret (from Scaleway Secret Manager) containing your custom certificate. + :param managed_certificate: True when Scaleway generates and manages a Let's Encrypt certificate for the TLS stage/custom endpoint. + :param cache_stage_id: Cache stage ID the TLS stage will be linked to. + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :param backend_stage_id: Backend stage ID the TLS stage will be linked to. + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :param pipeline_id: Pipeline ID the TLS stage belongs to. + :param route_stage_id: + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :param waf_stage_id: + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :return: :class:`TLSStage ` + + Usage: + :: + + result = api.create_tls_stage( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/tls-stages", + body=marshal_CreateTLSStageRequest( + CreateTLSStageRequest( + secrets=secrets, + managed_certificate=managed_certificate, + pipeline_id=pipeline_id, + cache_stage_id=cache_stage_id, + backend_stage_id=backend_stage_id, + route_stage_id=route_stage_id, + waf_stage_id=waf_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_TLSStage(res.json()) + + def get_tls_stage( + self, + *, + tls_stage_id: str, + ) -> TLSStage: + """ + Get TLS stage. + Retrieve information about an existing TLS stage, specified by its `tls_stage_id`. Its full details, including secrets and certificate expiration date are returned in the response object. + :param tls_stage_id: ID of the requested TLS stage. + :return: :class:`TLSStage ` + + Usage: + :: + + result = api.get_tls_stage( + tls_stage_id="example", + ) + """ + + param_tls_stage_id = validate_path_param("tls_stage_id", tls_stage_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/tls-stages/{param_tls_stage_id}", + ) + + self._throw_on_error(res) + return unmarshal_TLSStage(res.json()) + + def update_tls_stage( + self, + *, + tls_stage_id: str, + tls_secrets_config: Optional[TLSSecretsConfig] = None, + managed_certificate: Optional[bool] = None, + cache_stage_id: Optional[str] = None, + backend_stage_id: Optional[str] = None, + route_stage_id: Optional[str] = None, + waf_stage_id: Optional[str] = None, + ) -> TLSStage: + """ + Update TLS stage. + Update the parameters of an existing TLS stage, specified by its `tls_stage_id`. Both `tls_secrets_config` and `managed_certificate` parameters can be updated. + :param tls_stage_id: ID of the TLS stage to update. + :param tls_secrets_config: Secret (from Scaleway Secret-Manager) containing your custom certificate. + :param managed_certificate: True when Scaleway generates and manages a Let's Encrypt certificate for the TLS stage/custom endpoint. + :param cache_stage_id: Cache stage ID the TLS stage will be linked to. + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :param backend_stage_id: Backend stage ID the TLS stage will be linked to. + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :param route_stage_id: + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :param waf_stage_id: + One-Of ('next'): at most one of 'cache_stage_id', 'backend_stage_id', 'route_stage_id', 'waf_stage_id' could be set. + :return: :class:`TLSStage ` + + Usage: + :: + + result = api.update_tls_stage( + tls_stage_id="example", + ) + """ + + param_tls_stage_id = validate_path_param("tls_stage_id", tls_stage_id) + + res = self._request( + "PATCH", + f"/edge-services/v1beta1/tls-stages/{param_tls_stage_id}", + body=marshal_UpdateTLSStageRequest( + UpdateTLSStageRequest( + tls_stage_id=tls_stage_id, + tls_secrets_config=tls_secrets_config, + managed_certificate=managed_certificate, + cache_stage_id=cache_stage_id, + backend_stage_id=backend_stage_id, + route_stage_id=route_stage_id, + waf_stage_id=waf_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_TLSStage(res.json()) + + def delete_tls_stage( + self, + *, + tls_stage_id: str, + ) -> None: + """ + Delete TLS stage. + Delete an existing TLS stage, specified by its `tls_stage_id`. Deleting a TLS stage is permanent, and cannot be undone. + :param tls_stage_id: ID of the TLS stage to delete. + + Usage: + :: + + result = api.delete_tls_stage( + tls_stage_id="example", + ) + """ + + param_tls_stage_id = validate_path_param("tls_stage_id", tls_stage_id) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/tls-stages/{param_tls_stage_id}", + ) + + self._throw_on_error(res) + + def list_cache_stages( + self, + *, + order_by: Optional[ListCacheStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + ) -> ListCacheStagesResponse: + """ + List cache stages. + List all cache stages, for a Scaleway Organization or Scaleway Project. By default, the cache stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of cache stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of cache stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only cache stages from this pipeline will be returned. + :return: :class:`ListCacheStagesResponse ` + + Usage: + :: + + result = api.list_cache_stages( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/cache-stages", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListCacheStagesResponse(res.json()) + + def list_cache_stages_all( + self, + *, + order_by: Optional[ListCacheStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + ) -> List[CacheStage]: + """ + List cache stages. + List all cache stages, for a Scaleway Organization or Scaleway Project. By default, the cache stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of cache stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of cache stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only cache stages from this pipeline will be returned. + :return: :class:`List[CacheStage] ` + + Usage: + :: + + result = api.list_cache_stages_all( + pipeline_id="example", + ) + """ + + return fetch_all_pages( + type=ListCacheStagesResponse, + key="stages", + fetcher=self.list_cache_stages, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "pipeline_id": pipeline_id, + }, + ) + + def create_cache_stage( + self, + *, + fallback_ttl: Optional[str] = None, + backend_stage_id: Optional[str] = None, + pipeline_id: str, + waf_stage_id: Optional[str] = None, + route_stage_id: Optional[str] = None, + ) -> CacheStage: + """ + Create cache stage. + Create a new cache stage. You must specify the `fallback_ttl` field to customize the TTL of the cache. + :param fallback_ttl: Time To Live (TTL) in seconds. Defines how long content is cached. + :param backend_stage_id: Backend stage ID the cache stage will be linked to. + One-Of ('next'): at most one of 'backend_stage_id', 'waf_stage_id', 'route_stage_id' could be set. + :param pipeline_id: Pipeline ID the Cache stage belongs to. + :param waf_stage_id: + One-Of ('next'): at most one of 'backend_stage_id', 'waf_stage_id', 'route_stage_id' could be set. + :param route_stage_id: + One-Of ('next'): at most one of 'backend_stage_id', 'waf_stage_id', 'route_stage_id' could be set. + :return: :class:`CacheStage ` + + Usage: + :: + + result = api.create_cache_stage( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/cache-stages", + body=marshal_CreateCacheStageRequest( + CreateCacheStageRequest( + fallback_ttl=fallback_ttl, + pipeline_id=pipeline_id, + backend_stage_id=backend_stage_id, + waf_stage_id=waf_stage_id, + route_stage_id=route_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CacheStage(res.json()) + + def get_cache_stage( + self, + *, + cache_stage_id: str, + ) -> CacheStage: + """ + Get cache stage. + Retrieve information about an existing cache stage, specified by its `cache_stage_id`. Its full details, including Time To Live (TTL), are returned in the response object. + :param cache_stage_id: ID of the requested cache stage. + :return: :class:`CacheStage ` + + Usage: + :: + + result = api.get_cache_stage( + cache_stage_id="example", + ) + """ + + param_cache_stage_id = validate_path_param("cache_stage_id", cache_stage_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/cache-stages/{param_cache_stage_id}", + ) + + self._throw_on_error(res) + return unmarshal_CacheStage(res.json()) + + def update_cache_stage( + self, + *, + cache_stage_id: str, + fallback_ttl: Optional[str] = None, + backend_stage_id: Optional[str] = None, + waf_stage_id: Optional[str] = None, + route_stage_id: Optional[str] = None, + ) -> CacheStage: + """ + Update cache stage. + Update the parameters of an existing cache stage, specified by its `cache_stage_id`. Parameters which can be updated include the `fallback_ttl` and `backend_stage_id`. + :param cache_stage_id: ID of the cache stage to update. + :param fallback_ttl: Time To Live (TTL) in seconds. Defines how long content is cached. + :param backend_stage_id: Backend stage ID the cache stage will be linked to. + One-Of ('next'): at most one of 'backend_stage_id', 'waf_stage_id', 'route_stage_id' could be set. + :param waf_stage_id: + One-Of ('next'): at most one of 'backend_stage_id', 'waf_stage_id', 'route_stage_id' could be set. + :param route_stage_id: + One-Of ('next'): at most one of 'backend_stage_id', 'waf_stage_id', 'route_stage_id' could be set. + :return: :class:`CacheStage ` + + Usage: + :: + + result = api.update_cache_stage( + cache_stage_id="example", + ) + """ + + param_cache_stage_id = validate_path_param("cache_stage_id", cache_stage_id) + + res = self._request( + "PATCH", + f"/edge-services/v1beta1/cache-stages/{param_cache_stage_id}", + body=marshal_UpdateCacheStageRequest( + UpdateCacheStageRequest( + cache_stage_id=cache_stage_id, + fallback_ttl=fallback_ttl, + backend_stage_id=backend_stage_id, + waf_stage_id=waf_stage_id, + route_stage_id=route_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CacheStage(res.json()) + + def delete_cache_stage( + self, + *, + cache_stage_id: str, + ) -> None: + """ + Delete cache stage. + Delete an existing cache stage, specified by its `cache_stage_id`. Deleting a cache stage is permanent, and cannot be undone. + :param cache_stage_id: ID of the cache stage to delete. + + Usage: + :: + + result = api.delete_cache_stage( + cache_stage_id="example", + ) + """ + + param_cache_stage_id = validate_path_param("cache_stage_id", cache_stage_id) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/cache-stages/{param_cache_stage_id}", + ) + + self._throw_on_error(res) + + def list_backend_stages( + self, + *, + order_by: Optional[ListBackendStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + bucket_name: Optional[str] = None, + bucket_region: Optional[str] = None, + lb_id: Optional[str] = None, + ) -> ListBackendStagesResponse: + """ + List backend stages. + List all backend stages, for a Scaleway Organization or Scaleway Project. By default, the backend stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of backend stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of backend stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only backend stages from this pipeline will be returned. + :param bucket_name: Bucket name to filter for. Only backend stages from this Bucket will be returned. + :param bucket_region: Bucket region to filter for. Only backend stages with buckets in this region will be returned. + :param lb_id: Load Balancer ID to filter for. Only backend stages with this Load Balancer will be returned. + :return: :class:`ListBackendStagesResponse ` + + Usage: + :: + + result = api.list_backend_stages( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/backend-stages", + params={ + "bucket_name": bucket_name, + "bucket_region": bucket_region, + "lb_id": lb_id, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListBackendStagesResponse(res.json()) + + def list_backend_stages_all( + self, + *, + order_by: Optional[ListBackendStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + bucket_name: Optional[str] = None, + bucket_region: Optional[str] = None, + lb_id: Optional[str] = None, + ) -> List[BackendStage]: + """ + List backend stages. + List all backend stages, for a Scaleway Organization or Scaleway Project. By default, the backend stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of backend stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of backend stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only backend stages from this pipeline will be returned. + :param bucket_name: Bucket name to filter for. Only backend stages from this Bucket will be returned. + :param bucket_region: Bucket region to filter for. Only backend stages with buckets in this region will be returned. + :param lb_id: Load Balancer ID to filter for. Only backend stages with this Load Balancer will be returned. + :return: :class:`List[BackendStage] ` + + Usage: + :: + + result = api.list_backend_stages_all( + pipeline_id="example", + ) + """ + + return fetch_all_pages( + type=ListBackendStagesResponse, + key="stages", + fetcher=self.list_backend_stages, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "pipeline_id": pipeline_id, + "bucket_name": bucket_name, + "bucket_region": bucket_region, + "lb_id": lb_id, + }, + ) + + def create_backend_stage( + self, + *, + scaleway_s3: Optional[ScalewayS3BackendConfig] = None, + scaleway_lb: Optional[ScalewayLbBackendConfig] = None, + pipeline_id: str, + ) -> BackendStage: + """ + Create backend stage. + Create a new backend stage. You must specify either a `scaleway_s3` (for a Scaleway Object Storage bucket) or `scaleway_lb` (for a Scaleway Load Balancer) field to configure the origin. + :param scaleway_s3: Scaleway Object Storage origin bucket (S3) linked to the backend stage. + One-Of ('backend_config'): at most one of 'scaleway_s3', 'scaleway_lb' could be set. + :param scaleway_lb: Scaleway Load Balancer origin linked to the backend stage. + One-Of ('backend_config'): at most one of 'scaleway_s3', 'scaleway_lb' could be set. + :param pipeline_id: Pipeline ID the Backend stage belongs to. + :return: :class:`BackendStage ` + + Usage: + :: + + result = api.create_backend_stage( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/backend-stages", + body=marshal_CreateBackendStageRequest( + CreateBackendStageRequest( + pipeline_id=pipeline_id, + scaleway_s3=scaleway_s3, + scaleway_lb=scaleway_lb, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_BackendStage(res.json()) + + def get_backend_stage( + self, + *, + backend_stage_id: str, + ) -> BackendStage: + """ + Get backend stage. + Retrieve information about an existing backend stage, specified by its `backend_stage_id`. Its full details, including `scaleway_s3` or `scaleway_lb`, are returned in the response object. + :param backend_stage_id: ID of the requested backend stage. + :return: :class:`BackendStage ` + + Usage: + :: + + result = api.get_backend_stage( + backend_stage_id="example", + ) + """ + + param_backend_stage_id = validate_path_param( + "backend_stage_id", backend_stage_id + ) + + res = self._request( + "GET", + f"/edge-services/v1beta1/backend-stages/{param_backend_stage_id}", + ) + + self._throw_on_error(res) + return unmarshal_BackendStage(res.json()) + + def update_backend_stage( + self, + *, + backend_stage_id: str, + pipeline_id: str, + scaleway_s3: Optional[ScalewayS3BackendConfig] = None, + scaleway_lb: Optional[ScalewayLbBackendConfig] = None, + ) -> BackendStage: + """ + Update backend stage. + Update the parameters of an existing backend stage, specified by its `backend_stage_id`. + :param backend_stage_id: ID of the backend stage to update. + :param pipeline_id: Pipeline ID the Backend stage belongs to. + :param scaleway_s3: Scaleway Object Storage origin bucket (S3) linked to the backend stage. + One-Of ('backend_config'): at most one of 'scaleway_s3', 'scaleway_lb' could be set. + :param scaleway_lb: Scaleway Load Balancer origin linked to the backend stage. + One-Of ('backend_config'): at most one of 'scaleway_s3', 'scaleway_lb' could be set. + :return: :class:`BackendStage ` + + Usage: + :: + + result = api.update_backend_stage( + backend_stage_id="example", + pipeline_id="example", + ) + """ + + param_backend_stage_id = validate_path_param( + "backend_stage_id", backend_stage_id + ) + + res = self._request( + "PATCH", + f"/edge-services/v1beta1/backend-stages/{param_backend_stage_id}", + body=marshal_UpdateBackendStageRequest( + UpdateBackendStageRequest( + backend_stage_id=backend_stage_id, + pipeline_id=pipeline_id, + scaleway_s3=scaleway_s3, + scaleway_lb=scaleway_lb, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_BackendStage(res.json()) + + def delete_backend_stage( + self, + *, + backend_stage_id: str, + ) -> None: + """ + Delete backend stage. + Delete an existing backend stage, specified by its `backend_stage_id`. Deleting a backend stage is permanent, and cannot be undone. + :param backend_stage_id: ID of the backend stage to delete. + + Usage: + :: + + result = api.delete_backend_stage( + backend_stage_id="example", + ) + """ + + param_backend_stage_id = validate_path_param( + "backend_stage_id", backend_stage_id + ) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/backend-stages/{param_backend_stage_id}", + ) + + self._throw_on_error(res) + + def list_waf_stages( + self, + *, + order_by: Optional[ListWafStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + ) -> ListWafStagesResponse: + """ + List WAF stages. + List all WAF stages, for a Scaleway Organization or Scaleway Project. By default, the WAF stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of WAF stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of WAF stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only WAF stages from this pipeline will be returned. + :return: :class:`ListWafStagesResponse ` + + Usage: + :: + + result = api.list_waf_stages( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/waf-stages", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListWafStagesResponse(res.json()) + + def list_waf_stages_all( + self, + *, + order_by: Optional[ListWafStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + ) -> List[WafStage]: + """ + List WAF stages. + List all WAF stages, for a Scaleway Organization or Scaleway Project. By default, the WAF stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of WAF stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of WAF stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only WAF stages from this pipeline will be returned. + :return: :class:`List[WafStage] ` + + Usage: + :: + + result = api.list_waf_stages_all( + pipeline_id="example", + ) + """ + + return fetch_all_pages( + type=ListWafStagesResponse, + key="stages", + fetcher=self.list_waf_stages, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "pipeline_id": pipeline_id, + }, + ) + + def create_waf_stage( + self, + *, + pipeline_id: str, + paranoia_level: int, + mode: Optional[WafStageMode] = None, + backend_stage_id: Optional[str] = None, + ) -> WafStage: + """ + Create WAF stage. + Create a new WAF stage. You must specify the `mode` and `paranoia_level` fields to customize the WAF. + :param pipeline_id: Pipeline ID the WAF stage belongs to. + :param paranoia_level: Sensitivity level (`1`,`2`,`3`,`4`) to use when classifying requests as malicious. With a high level, requests are more likely to be classed as malicious, and false positives are expected. With a lower level, requests are more likely to be classed as benign. + :param mode: Mode defining WAF behavior (`disable`/`log_only`/`enable`). + :param backend_stage_id: ID of the backend stage to forward requests to after the WAF stage. + One-Of ('next'): at most one of 'backend_stage_id' could be set. + :return: :class:`WafStage ` + + Usage: + :: + + result = api.create_waf_stage( + pipeline_id="example", + paranoia_level=1, + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/waf-stages", + body=marshal_CreateWafStageRequest( + CreateWafStageRequest( + pipeline_id=pipeline_id, + paranoia_level=paranoia_level, + mode=mode, + backend_stage_id=backend_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_WafStage(res.json()) + + def get_waf_stage( + self, + *, + waf_stage_id: str, + ) -> WafStage: + """ + Get WAF stage. + Retrieve information about an existing WAF stage, specified by its `waf_stage_id`. Its full details are returned in the response object. + :param waf_stage_id: ID of the requested WAF stage. + :return: :class:`WafStage ` + + Usage: + :: + + result = api.get_waf_stage( + waf_stage_id="example", + ) + """ + + param_waf_stage_id = validate_path_param("waf_stage_id", waf_stage_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/waf-stages/{param_waf_stage_id}", + ) + + self._throw_on_error(res) + return unmarshal_WafStage(res.json()) + + def update_waf_stage( + self, + *, + waf_stage_id: str, + mode: Optional[WafStageMode] = None, + paranoia_level: Optional[int] = None, + backend_stage_id: Optional[str] = None, + ) -> WafStage: + """ + Update WAF stage. + Update the parameters of an existing WAF stage, specified by its `waf_stage_id`. Both `mode` and `paranoia_level` parameters can be updated. + :param waf_stage_id: ID of the WAF stage to update. + :param mode: Mode defining WAF behavior (`disable`/`log_only`/`enable`). + :param paranoia_level: Sensitivity level (`1`,`2`,`3`,`4`) to use when classifying requests as malicious. With a high level, requests are more likely to be classed as malicious, and false positives are expected. With a lower level, requests are more likely to be classed as benign. + :param backend_stage_id: ID of the backend stage to forward requests to after the WAF stage. + One-Of ('next'): at most one of 'backend_stage_id' could be set. + :return: :class:`WafStage ` + + Usage: + :: + + result = api.update_waf_stage( + waf_stage_id="example", + ) + """ + + param_waf_stage_id = validate_path_param("waf_stage_id", waf_stage_id) + + res = self._request( + "PATCH", + f"/edge-services/v1beta1/waf-stages/{param_waf_stage_id}", + body=marshal_UpdateWafStageRequest( + UpdateWafStageRequest( + waf_stage_id=waf_stage_id, + mode=mode, + paranoia_level=paranoia_level, + backend_stage_id=backend_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_WafStage(res.json()) + + def delete_waf_stage( + self, + *, + waf_stage_id: str, + ) -> None: + """ + Delete WAF stage. + Delete an existing WAF stage, specified by its `waf_stage_id`. Deleting a WAF stage is permanent, and cannot be undone. + :param waf_stage_id: ID of the WAF stage to delete. + + Usage: + :: + + result = api.delete_waf_stage( + waf_stage_id="example", + ) + """ + + param_waf_stage_id = validate_path_param("waf_stage_id", waf_stage_id) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/waf-stages/{param_waf_stage_id}", + ) + + self._throw_on_error(res) + + def list_route_stages( + self, + *, + order_by: Optional[ListRouteStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + ) -> ListRouteStagesResponse: + """ + List route stages. + List all route stages, for a given pipeline. By default, the route stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of route stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of route stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only route stages from this pipeline will be returned. + :return: :class:`ListRouteStagesResponse ` + + Usage: + :: + + result = api.list_route_stages( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/route-stages", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListRouteStagesResponse(res.json()) + + def list_route_stages_all( + self, + *, + order_by: Optional[ListRouteStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pipeline_id: str, + ) -> List[RouteStage]: + """ + List route stages. + List all route stages, for a given pipeline. By default, the route stages returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of route stages in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of route stages to return per page. + :param pipeline_id: Pipeline ID to filter for. Only route stages from this pipeline will be returned. + :return: :class:`List[RouteStage] ` + + Usage: + :: + + result = api.list_route_stages_all( + pipeline_id="example", + ) + """ + + return fetch_all_pages( + type=ListRouteStagesResponse, + key="stages", + fetcher=self.list_route_stages, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "pipeline_id": pipeline_id, + }, + ) + + def create_route_stage( + self, + *, + pipeline_id: str, + waf_stage_id: Optional[str] = None, + ) -> RouteStage: + """ + Create route stage. + Create a new route stage. You must specify the `waf_stage_id` field to customize the route. + :param pipeline_id: Pipeline ID the route stage belongs to. + :param waf_stage_id: ID of the WAF stage HTTP requests should be forwarded to when no rules are matched. + One-Of ('next'): at most one of 'waf_stage_id' could be set. + :return: :class:`RouteStage ` + + Usage: + :: + + result = api.create_route_stage( + pipeline_id="example", + ) + """ + + param_pipeline_id = validate_path_param("pipeline_id", pipeline_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/pipelines/{param_pipeline_id}/route-stages", + body=marshal_CreateRouteStageRequest( + CreateRouteStageRequest( + pipeline_id=pipeline_id, + waf_stage_id=waf_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_RouteStage(res.json()) + + def get_route_stage( + self, + *, + route_stage_id: str, + ) -> RouteStage: + """ + Get route stage. + Retrieve information about an existing route stage, specified by its `route_stage_id`. The summary of the route stage (without route rules) is returned in the response object. + :param route_stage_id: ID of the requested route stage. + :return: :class:`RouteStage ` + + Usage: + :: + + result = api.get_route_stage( + route_stage_id="example", + ) + """ + + param_route_stage_id = validate_path_param("route_stage_id", route_stage_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/route-stages/{param_route_stage_id}", + ) + + self._throw_on_error(res) + return unmarshal_RouteStage(res.json()) + + def update_route_stage( + self, + *, + route_stage_id: str, + waf_stage_id: Optional[str] = None, + ) -> RouteStage: + """ + Update route stage. + Update the parameters of an existing route stage, specified by its `route_stage_id`. + :param route_stage_id: ID of the route stage to update. + :param waf_stage_id: ID of the WAF stage HTTP requests should be forwarded to when no rules are matched. + One-Of ('next'): at most one of 'waf_stage_id' could be set. + :return: :class:`RouteStage ` + + Usage: + :: + + result = api.update_route_stage( + route_stage_id="example", + ) + """ + + param_route_stage_id = validate_path_param("route_stage_id", route_stage_id) + + res = self._request( + "PATCH", + f"/edge-services/v1beta1/route-stages/{param_route_stage_id}", + body=marshal_UpdateRouteStageRequest( + UpdateRouteStageRequest( + route_stage_id=route_stage_id, + waf_stage_id=waf_stage_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_RouteStage(res.json()) + + def delete_route_stage( + self, + *, + route_stage_id: str, + ) -> None: + """ + Delete route stage. + Delete an existing route stage, specified by its `route_stage_id`. Deleting a route stage is permanent, and cannot be undone. + :param route_stage_id: ID of the route stage to delete. + + Usage: + :: + + result = api.delete_route_stage( + route_stage_id="example", + ) + """ + + param_route_stage_id = validate_path_param("route_stage_id", route_stage_id) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/route-stages/{param_route_stage_id}", + ) + + self._throw_on_error(res) + + def list_route_rules( + self, + *, + route_stage_id: str, + ) -> ListRouteRulesResponse: + """ + List route rules. + List all route rules of an existing route stage, specified by its `route_stage_id`. + :param route_stage_id: Route stage ID to filter for. Only route rules from this route stage will be returned. + :return: :class:`ListRouteRulesResponse ` + + Usage: + :: + + result = api.list_route_rules( + route_stage_id="example", + ) + """ + + param_route_stage_id = validate_path_param("route_stage_id", route_stage_id) + + res = self._request( + "GET", + f"/edge-services/v1beta1/{param_route_stage_id}/route-rules", + ) + + self._throw_on_error(res) + return unmarshal_ListRouteRulesResponse(res.json()) + + def set_route_rules( + self, + *, + route_stage_id: str, + route_rules: Optional[List[SetRouteRulesRequestRouteRule]] = None, + ) -> SetRouteRulesResponse: + """ + Set route rules. + Set the rules of an existing route stage, specified by its `route_stage_id`. + :param route_stage_id: ID of the route stage to update. + :param route_rules: List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`. + :return: :class:`SetRouteRulesResponse ` + + Usage: + :: + + result = api.set_route_rules( + route_stage_id="example", + ) + """ + + param_route_stage_id = validate_path_param("route_stage_id", route_stage_id) + + res = self._request( + "PUT", + f"/edge-services/v1beta1/route-stages/{param_route_stage_id}/route-rules", + body=marshal_SetRouteRulesRequest( + SetRouteRulesRequest( + route_stage_id=route_stage_id, + route_rules=route_rules, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_SetRouteRulesResponse(res.json()) + + def add_route_rules( + self, + *, + route_stage_id: str, + route_rules: Optional[List[SetRouteRulesRequestRouteRule]] = None, + after_position: Optional[int] = None, + before_position: Optional[int] = None, + ) -> AddRouteRulesResponse: + """ + Add route rules. + Add route rules to an existing route stage, specified by its `route_stage_id`. + :param route_stage_id: ID of the route stage to update. + :param route_rules: List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`. + :param after_position: Add rules after the given position. + One-Of ('position'): at most one of 'after_position', 'before_position' could be set. + :param before_position: Add rules before the given position. + One-Of ('position'): at most one of 'after_position', 'before_position' could be set. + :return: :class:`AddRouteRulesResponse ` + + Usage: + :: + + result = api.add_route_rules( + route_stage_id="example", + ) + """ + + param_route_stage_id = validate_path_param("route_stage_id", route_stage_id) + + res = self._request( + "POST", + f"/edge-services/v1beta1/route-stages/{param_route_stage_id}/route-rules", + body=marshal_AddRouteRulesRequest( + AddRouteRulesRequest( + route_stage_id=route_stage_id, + route_rules=route_rules, + after_position=after_position, + before_position=before_position, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_AddRouteRulesResponse(res.json()) + + def check_domain( + self, + *, + fqdn: str, + cname: str, + project_id: Optional[str] = None, + ) -> CheckDomainResponse: + """ + :param fqdn: + :param cname: + :param project_id: + :return: :class:`CheckDomainResponse ` + + Usage: + :: + + result = api.check_domain( + fqdn="example", + cname="example", + ) + """ + + res = self._request( + "POST", + "/edge-services/v1beta1/check-domain", + body=marshal_CheckDomainRequest( + CheckDomainRequest( + fqdn=fqdn, + cname=cname, + project_id=project_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CheckDomainResponse(res.json()) + + def check_pem_chain( + self, + *, + fqdn: str, + project_id: Optional[str] = None, + secret: Optional[CheckPEMChainRequestSecretChain] = None, + raw: Optional[str] = None, + ) -> CheckPEMChainResponse: + """ + :param fqdn: + :param project_id: + :param secret: + One-Of ('chain'): at most one of 'secret', 'raw' could be set. + :param raw: + One-Of ('chain'): at most one of 'secret', 'raw' could be set. + :return: :class:`CheckPEMChainResponse ` + + Usage: + :: + + result = api.check_pem_chain( + fqdn="example", + ) + """ + + res = self._request( + "POST", + "/edge-services/v1beta1/check-pem-chain", + body=marshal_CheckPEMChainRequest( + CheckPEMChainRequest( + fqdn=fqdn, + project_id=project_id, + secret=secret, + raw=raw, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CheckPEMChainResponse(res.json()) + + def search_backend_stages( + self, + *, + order_by: Optional[SearchBackendStagesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + project_id: Optional[str] = None, + bucket_name: Optional[str] = None, + bucket_region: Optional[str] = None, + lb_id: Optional[str] = None, + ) -> ListBackendStagesResponse: + """ + :param order_by: + :param page: + :param page_size: + :param project_id: + :param bucket_name: + :param bucket_region: + :param lb_id: + :return: :class:`ListBackendStagesResponse ` + + Usage: + :: + + result = api.search_backend_stages() + """ + + res = self._request( + "GET", + "/edge-services/v1beta1/search-backend-stages", + params={ + "bucket_name": bucket_name, + "bucket_region": bucket_region, + "lb_id": lb_id, + "order_by": order_by, + "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_ListBackendStagesResponse(res.json()) + + def list_purge_requests( + self, + *, + order_by: Optional[ListPurgeRequestsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + pipeline_id: Optional[str] = None, + ) -> ListPurgeRequestsResponse: + """ + List purge requests. + List all purge requests, for a Scaleway Organization or Scaleway Project. This enables you to retrieve a history of all previously-made purge requests. By default, the purge requests returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of purge requests in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of purge requests to return per page. + :param organization_id: Organization ID to filter for. Only purge requests from this Project will be returned. + :param project_id: Project ID to filter for. Only purge requests from this Project will be returned. + :param pipeline_id: Pipeline ID to filter for. Only purge requests from this pipeline will be returned. + :return: :class:`ListPurgeRequestsResponse ` + + Usage: + :: + + result = api.list_purge_requests() + """ + + res = self._request( + "GET", + "/edge-services/v1beta1/purge-requests", + 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, + "pipeline_id": pipeline_id, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListPurgeRequestsResponse(res.json()) + + def list_purge_requests_all( + self, + *, + order_by: Optional[ListPurgeRequestsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + pipeline_id: Optional[str] = None, + ) -> List[PurgeRequest]: + """ + List purge requests. + List all purge requests, for a Scaleway Organization or Scaleway Project. This enables you to retrieve a history of all previously-made purge requests. By default, the purge requests returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param order_by: Sort order of purge requests in the response. + :param page: Page number to return, from the paginated results. + :param page_size: Number of purge requests to return per page. + :param organization_id: Organization ID to filter for. Only purge requests from this Project will be returned. + :param project_id: Project ID to filter for. Only purge requests from this Project will be returned. + :param pipeline_id: Pipeline ID to filter for. Only purge requests from this pipeline will be returned. + :return: :class:`List[PurgeRequest] ` + + Usage: + :: + + result = api.list_purge_requests_all() + """ + + return fetch_all_pages( + type=ListPurgeRequestsResponse, + key="purge_requests", + fetcher=self.list_purge_requests, + args={ + "order_by": order_by, + "page": page, + "page_size": page_size, + "organization_id": organization_id, + "project_id": project_id, + "pipeline_id": pipeline_id, + }, + ) + + def create_purge_request( + self, + *, + pipeline_id: str, + assets: Optional[List[str]] = None, + all: Optional[bool] = None, + ) -> PurgeRequest: + """ + Create purge request. + Create a new purge request. You must specify either the `all` field (to purge all content) or a list of `assets` (to define the precise assets to purge). + :param pipeline_id: Pipeline ID in which the purge request will be created. + :param assets: List of asserts to purge. + One-Of ('target'): at most one of 'assets', 'all' could be set. + :param all: Defines whether to purge all content. + One-Of ('target'): at most one of 'assets', 'all' could be set. + :return: :class:`PurgeRequest ` + + Usage: + :: + + result = api.create_purge_request( + pipeline_id="example", + ) + """ + + res = self._request( + "POST", + "/edge-services/v1beta1/purge-requests", + body=marshal_CreatePurgeRequestRequest( + CreatePurgeRequestRequest( + pipeline_id=pipeline_id, + assets=assets, + all=all, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_PurgeRequest(res.json()) + + def get_purge_request( + self, + *, + purge_request_id: str, + ) -> PurgeRequest: + """ + Get purge request. + Retrieve information about a purge request, specified by its `purge_request_id`. Its full details, including `status` and `target`, are returned in the response object. + :param purge_request_id: ID of the requested purge request. + :return: :class:`PurgeRequest ` + + Usage: + :: + + result = api.get_purge_request( + purge_request_id="example", + ) + """ + + param_purge_request_id = validate_path_param( + "purge_request_id", purge_request_id + ) + + res = self._request( + "GET", + f"/edge-services/v1beta1/purge-requests/{param_purge_request_id}", + ) + + self._throw_on_error(res) + return unmarshal_PurgeRequest(res.json()) + + def wait_for_purge_request( + self, + *, + purge_request_id: str, + options: Optional[WaitForOptions[PurgeRequest, bool]] = None, + ) -> PurgeRequest: + """ + Get purge request. + Retrieve information about a purge request, specified by its `purge_request_id`. Its full details, including `status` and `target`, are returned in the response object. + :param purge_request_id: ID of the requested purge request. + :return: :class:`PurgeRequest ` + + Usage: + :: + + result = api.get_purge_request( + purge_request_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = ( + lambda res: res.status not in PURGE_REQUEST_TRANSIENT_STATUSES + ) + + return wait_for_resource( + fetcher=self.get_purge_request, + options=options, + args={ + "purge_request_id": purge_request_id, + }, + ) + + def check_lb_origin( + self, + *, + lb: Optional[ScalewayLb] = None, + ) -> CheckLbOriginResponse: + """ + :param lb: + :return: :class:`CheckLbOriginResponse ` + + Usage: + :: + + result = api.check_lb_origin() + """ + + res = self._request( + "POST", + "/edge-services/v1beta1/check-lb-origin", + body=marshal_CheckLbOriginRequest( + CheckLbOriginRequest( + lb=lb, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CheckLbOriginResponse(res.json()) + + def list_plans( + self, + ) -> ListPlansResponse: + """ + + :return: :class:`ListPlansResponse ` + + Usage: + :: + + result = api.list_plans() + """ + + res = self._request( + "GET", + "/edge-services/v1beta1/plans", + ) + + self._throw_on_error(res) + return unmarshal_ListPlansResponse(res.json()) + + def select_plan( + self, + *, + project_id: Optional[str] = None, + plan_name: Optional[PlanName] = None, + ) -> Plan: + """ + :param project_id: + :param plan_name: + :return: :class:`Plan ` + + Usage: + :: + + result = api.select_plan() + """ + + res = self._request( + "PATCH", + "/edge-services/v1beta1/current-plan", + body=marshal_SelectPlanRequest( + SelectPlanRequest( + project_id=project_id, + plan_name=plan_name, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Plan(res.json()) + + def get_current_plan( + self, + *, + project_id: Optional[str] = None, + ) -> Plan: + """ + :param project_id: + :return: :class:`Plan ` + + Usage: + :: + + result = api.get_current_plan() + """ + + param_project_id = validate_path_param( + "project_id", project_id or self.client.default_project_id + ) + + res = self._request( + "GET", + f"/edge-services/v1beta1/current-plan/{param_project_id}", + ) + + self._throw_on_error(res) + return unmarshal_Plan(res.json()) + + def delete_current_plan( + self, + *, + project_id: Optional[str] = None, + ) -> None: + """ + :param project_id: + + Usage: + :: + + result = api.delete_current_plan() + """ + + param_project_id = validate_path_param( + "project_id", project_id or self.client.default_project_id + ) + + res = self._request( + "DELETE", + f"/edge-services/v1beta1/current-plan/{param_project_id}", + ) + + self._throw_on_error(res) + + def get_billing( + self, + *, + project_id: Optional[str] = None, + ) -> GetBillingResponse: + """ + Gives information on the currently selected Edge Services subscription plan, resource usage and associated billing information for this calendar month (including whether consumption falls within or exceeds the currently selected subscription plan.). + :param project_id: + :return: :class:`GetBillingResponse ` + + Usage: + :: + + result = api.get_billing() + """ + + param_project_id = validate_path_param( + "project_id", project_id or self.client.default_project_id + ) + + res = self._request( + "GET", + f"/edge-services/v1beta1/billing/{param_project_id}", + ) + + self._throw_on_error(res) + return unmarshal_GetBillingResponse(res.json()) diff --git a/scaleway/scaleway/edge_services/v1beta1/content.py b/scaleway/scaleway/edge_services/v1beta1/content.py new file mode 100644 index 000000000..ad1b5e0e6 --- /dev/null +++ b/scaleway/scaleway/edge_services/v1beta1/content.py @@ -0,0 +1,21 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + PipelineStatus, + PurgeRequestStatus, +) + +PIPELINE_TRANSIENT_STATUSES: List[PipelineStatus] = [ + PipelineStatus.PENDING, +] +""" +Lists transient statutes of the enum :class:`PipelineStatus `. +""" +PURGE_REQUEST_TRANSIENT_STATUSES: List[PurgeRequestStatus] = [ + PurgeRequestStatus.PENDING, +] +""" +Lists transient statutes of the enum :class:`PurgeRequestStatus `. +""" diff --git a/scaleway/scaleway/edge_services/v1beta1/marshalling.py b/scaleway/scaleway/edge_services/v1beta1/marshalling.py new file mode 100644 index 000000000..b01c7d7cf --- /dev/null +++ b/scaleway/scaleway/edge_services/v1beta1/marshalling.py @@ -0,0 +1,1901 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any, Dict +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.bridge import ( + unmarshal_Money, +) +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) +from .types import ( + RuleHttpMatchMethodFilter, + ScalewayLb, + ScalewayLbBackendConfig, + ScalewayS3BackendConfig, + BackendStage, + CacheStage, + DNSStage, + PipelineError, + Pipeline, + RouteStage, + TLSSecret, + TLSStage, + WafStage, + PipelineStages, + PurgeRequest, + RuleHttpMatchPathFilter, + RuleHttpMatch, + RouteRule, + AddRouteRulesResponse, + CheckDomainResponse, + CheckLbOriginResponse, + CheckPEMChainResponse, + PlanDetails, + PlanUsageDetails, + GetBillingResponse, + HeadStageResponseHeadStage, + HeadStageResponse, + ListBackendStagesResponse, + ListCacheStagesResponse, + ListDNSStagesResponse, + ListHeadStagesResponseHeadStage, + ListHeadStagesResponse, + ListPipelinesResponse, + ListPipelinesWithStagesResponse, + ListPlansResponse, + ListPurgeRequestsResponse, + ListRouteRulesResponse, + ListRouteStagesResponse, + ListTLSStagesResponse, + ListWafStagesResponse, + Plan, + SetRouteRulesResponse, + SetRouteRulesRequestRouteRule, + AddRouteRulesRequest, + CheckDomainRequest, + CheckLbOriginRequest, + CheckPEMChainRequestSecretChain, + CheckPEMChainRequest, + CreateBackendStageRequest, + CreateCacheStageRequest, + CreateDNSStageRequest, + CreatePipelineRequest, + CreatePurgeRequestRequest, + CreateRouteStageRequest, + CreateTLSStageRequest, + CreateWafStageRequest, + SelectPlanRequest, + SetHeadStageRequestAddNewHeadStage, + SetHeadStageRequestRemoveHeadStage, + SetHeadStageRequestSwapHeadStage, + SetHeadStageRequest, + SetRouteRulesRequest, + UpdateBackendStageRequest, + UpdateCacheStageRequest, + UpdateDNSStageRequest, + UpdatePipelineRequest, + UpdateRouteStageRequest, + TLSSecretsConfig, + UpdateTLSStageRequest, + UpdateWafStageRequest, +) + + +def unmarshal_ScalewayLb(data: Any) -> ScalewayLb: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ScalewayLb' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + + field = data.get("frontend_id", None) + if field is not None: + args["frontend_id"] = field + + field = data.get("is_ssl", None) + if field is not None: + args["is_ssl"] = field + else: + args["is_ssl"] = None + + field = data.get("domain_name", None) + if field is not None: + args["domain_name"] = field + else: + args["domain_name"] = None + + return ScalewayLb(**args) + + +def unmarshal_ScalewayLbBackendConfig(data: Any) -> ScalewayLbBackendConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ScalewayLbBackendConfig' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("lbs", None) + if field is not None: + args["lbs"] = ( + [unmarshal_ScalewayLb(v) for v in field] if field is not None else None + ) + + return ScalewayLbBackendConfig(**args) + + +def unmarshal_ScalewayS3BackendConfig(data: Any) -> ScalewayS3BackendConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ScalewayS3BackendConfig' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("bucket_name", None) + if field is not None: + args["bucket_name"] = field + else: + args["bucket_name"] = None + + field = data.get("bucket_region", None) + if field is not None: + args["bucket_region"] = field + else: + args["bucket_region"] = None + + field = data.get("is_website", None) + if field is not None: + args["is_website"] = field + else: + args["is_website"] = None + + return ScalewayS3BackendConfig(**args) + + +def unmarshal_BackendStage(data: Any) -> BackendStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'BackendStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("pipeline_id", None) + if field is not None: + args["pipeline_id"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("scaleway_s3", None) + if field is not None: + args["scaleway_s3"] = unmarshal_ScalewayS3BackendConfig(field) + else: + args["scaleway_s3"] = None + + field = data.get("scaleway_lb", None) + if field is not None: + args["scaleway_lb"] = unmarshal_ScalewayLbBackendConfig(field) + else: + args["scaleway_lb"] = None + + return BackendStage(**args) + + +def unmarshal_CacheStage(data: Any) -> CacheStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CacheStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("pipeline_id", None) + if field is not None: + args["pipeline_id"] = field + + field = data.get("fallback_ttl", None) + if field is not None: + args["fallback_ttl"] = field + else: + args["fallback_ttl"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("backend_stage_id", None) + if field is not None: + args["backend_stage_id"] = field + else: + args["backend_stage_id"] = None + + field = data.get("waf_stage_id", None) + if field is not None: + args["waf_stage_id"] = field + else: + args["waf_stage_id"] = None + + field = data.get("route_stage_id", None) + if field is not None: + args["route_stage_id"] = field + else: + args["route_stage_id"] = None + + return CacheStage(**args) + + +def unmarshal_DNSStage(data: Any) -> DNSStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'DNSStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("fqdns", None) + if field is not None: + args["fqdns"] = field + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + field = data.get("pipeline_id", None) + if field is not None: + args["pipeline_id"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("tls_stage_id", None) + if field is not None: + args["tls_stage_id"] = field + else: + args["tls_stage_id"] = None + + field = data.get("cache_stage_id", None) + if field is not None: + args["cache_stage_id"] = field + else: + args["cache_stage_id"] = None + + field = data.get("backend_stage_id", None) + if field is not None: + args["backend_stage_id"] = field + else: + args["backend_stage_id"] = None + + return DNSStage(**args) + + +def unmarshal_PipelineError(data: Any) -> PipelineError: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'PipelineError' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("stage", None) + if field is not None: + args["stage"] = field + + field = data.get("code", None) + if field is not None: + args["code"] = field + + field = data.get("severity", None) + if field is not None: + args["severity"] = field + + field = data.get("message", None) + if field is not None: + args["message"] = field + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + return PipelineError(**args) + + +def unmarshal_Pipeline(data: Any) -> Pipeline: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Pipeline' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("description", None) + if field is not None: + args["description"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("errors", None) + if field is not None: + args["errors"] = ( + [unmarshal_PipelineError(v) for v in field] if field is not None else None + ) + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return Pipeline(**args) + + +def unmarshal_RouteStage(data: Any) -> RouteStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'RouteStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("pipeline_id", None) + if field is not None: + args["pipeline_id"] = field + + field = data.get("waf_stage_id", None) + if field is not None: + args["waf_stage_id"] = field + else: + args["waf_stage_id"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return RouteStage(**args) + + +def unmarshal_TLSSecret(data: Any) -> TLSSecret: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'TLSSecret' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("secret_id", None) + if field is not None: + args["secret_id"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + return TLSSecret(**args) + + +def unmarshal_TLSStage(data: Any) -> TLSStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'TLSStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("secrets", None) + if field is not None: + args["secrets"] = ( + [unmarshal_TLSSecret(v) for v in field] if field is not None else None + ) + + field = data.get("managed_certificate", None) + if field is not None: + args["managed_certificate"] = field + + field = data.get("pipeline_id", None) + if field is not None: + args["pipeline_id"] = field + + field = data.get("certificate_expires_at", None) + if field is not None: + args["certificate_expires_at"] = ( + parser.isoparse(field) if isinstance(field, str) else field + ) + else: + args["certificate_expires_at"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("cache_stage_id", None) + if field is not None: + args["cache_stage_id"] = field + else: + args["cache_stage_id"] = None + + field = data.get("backend_stage_id", None) + if field is not None: + args["backend_stage_id"] = field + else: + args["backend_stage_id"] = None + + field = data.get("waf_stage_id", None) + if field is not None: + args["waf_stage_id"] = field + else: + args["waf_stage_id"] = None + + field = data.get("route_stage_id", None) + if field is not None: + args["route_stage_id"] = field + else: + args["route_stage_id"] = None + + return TLSStage(**args) + + +def unmarshal_WafStage(data: Any) -> WafStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'WafStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("pipeline_id", None) + if field is not None: + args["pipeline_id"] = field + + field = data.get("mode", None) + if field is not None: + args["mode"] = field + + field = data.get("paranoia_level", None) + if field is not None: + args["paranoia_level"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("backend_stage_id", None) + if field is not None: + args["backend_stage_id"] = field + else: + args["backend_stage_id"] = None + + return WafStage(**args) + + +def unmarshal_PipelineStages(data: Any) -> PipelineStages: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'PipelineStages' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("dns_stages", None) + if field is not None: + args["dns_stages"] = ( + [unmarshal_DNSStage(v) for v in field] if field is not None else None + ) + + field = data.get("tls_stages", None) + if field is not None: + args["tls_stages"] = ( + [unmarshal_TLSStage(v) for v in field] if field is not None else None + ) + + field = data.get("cache_stages", None) + if field is not None: + args["cache_stages"] = ( + [unmarshal_CacheStage(v) for v in field] if field is not None else None + ) + + field = data.get("backend_stages", None) + if field is not None: + args["backend_stages"] = ( + [unmarshal_BackendStage(v) for v in field] if field is not None else None + ) + + field = data.get("waf_stages", None) + if field is not None: + args["waf_stages"] = ( + [unmarshal_WafStage(v) for v in field] if field is not None else None + ) + + field = data.get("route_stages", None) + if field is not None: + args["route_stages"] = ( + [unmarshal_RouteStage(v) for v in field] if field is not None else None + ) + + field = data.get("pipeline", None) + if field is not None: + args["pipeline"] = unmarshal_Pipeline(field) + else: + args["pipeline"] = None + + return PipelineStages(**args) + + +def unmarshal_PurgeRequest(data: Any) -> PurgeRequest: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'PurgeRequest' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("pipeline_id", None) + if field is not None: + args["pipeline_id"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("assets", None) + if field is not None: + args["assets"] = field + else: + args["assets"] = None + + field = data.get("all", None) + if field is not None: + args["all"] = field + else: + args["all"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return PurgeRequest(**args) + + +def unmarshal_RuleHttpMatchPathFilter(data: Any) -> RuleHttpMatchPathFilter: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'RuleHttpMatchPathFilter' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("path_filter_type", None) + if field is not None: + args["path_filter_type"] = field + + field = data.get("value", None) + if field is not None: + args["value"] = field + + return RuleHttpMatchPathFilter(**args) + + +def unmarshal_RuleHttpMatch(data: Any) -> RuleHttpMatch: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'RuleHttpMatch' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("method_filters", None) + if field is not None: + args["method_filters"] = ( + [RuleHttpMatchMethodFilter(v) for v in field] if field is not None else None + ) + + field = data.get("path_filter", None) + if field is not None: + args["path_filter"] = unmarshal_RuleHttpMatchPathFilter(field) + else: + args["path_filter"] = None + + return RuleHttpMatch(**args) + + +def unmarshal_RouteRule(data: Any) -> RouteRule: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'RouteRule' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("position", None) + if field is not None: + args["position"] = field + + field = data.get("route_stage_id", None) + if field is not None: + args["route_stage_id"] = field + + field = data.get("rule_http_match", None) + if field is not None: + args["rule_http_match"] = unmarshal_RuleHttpMatch(field) + else: + args["rule_http_match"] = None + + field = data.get("backend_stage_id", None) + if field is not None: + args["backend_stage_id"] = field + else: + args["backend_stage_id"] = None + + return RouteRule(**args) + + +def unmarshal_AddRouteRulesResponse(data: Any) -> AddRouteRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'AddRouteRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("route_rules", None) + if field is not None: + args["route_rules"] = ( + [unmarshal_RouteRule(v) for v in field] if field is not None else None + ) + + return AddRouteRulesResponse(**args) + + +def unmarshal_CheckDomainResponse(data: Any) -> CheckDomainResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CheckDomainResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("is_valid", None) + if field is not None: + args["is_valid"] = field + + return CheckDomainResponse(**args) + + +def unmarshal_CheckLbOriginResponse(data: Any) -> CheckLbOriginResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CheckLbOriginResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("is_valid", None) + if field is not None: + args["is_valid"] = field + + field = data.get("error_type", None) + if field is not None: + args["error_type"] = field + + return CheckLbOriginResponse(**args) + + +def unmarshal_CheckPEMChainResponse(data: Any) -> CheckPEMChainResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CheckPEMChainResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("is_valid", None) + if field is not None: + args["is_valid"] = field + + return CheckPEMChainResponse(**args) + + +def unmarshal_PlanDetails(data: Any) -> PlanDetails: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'PlanDetails' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("plan_name", None) + if field is not None: + args["plan_name"] = field + + field = data.get("package_gb", None) + if field is not None: + args["package_gb"] = field + + field = data.get("pipeline_limit", None) + if field is not None: + args["pipeline_limit"] = field + + field = data.get("waf_requests", None) + if field is not None: + args["waf_requests"] = field + + return PlanDetails(**args) + + +def unmarshal_PlanUsageDetails(data: Any) -> PlanUsageDetails: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'PlanUsageDetails' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("plan_cost", None) + if field is not None: + args["plan_cost"] = unmarshal_Money(field) + else: + args["plan_cost"] = None + + return PlanUsageDetails(**args) + + +def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetBillingResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("current_plan", None) + if field is not None: + args["current_plan"] = unmarshal_PlanDetails(field) + else: + args["current_plan"] = None + + field = data.get("pipeline_number", None) + if field is not None: + args["pipeline_number"] = field + + field = data.get("current_plan_cache_usage", None) + if field is not None: + args["current_plan_cache_usage"] = field + + field = data.get("extra_cache_usage", None) + if field is not None: + args["extra_cache_usage"] = field + + field = data.get("current_plan_waf_usage", None) + if field is not None: + args["current_plan_waf_usage"] = field + + field = data.get("extra_waf_usage", None) + if field is not None: + args["extra_waf_usage"] = field + + field = data.get("plan_cost", None) + if field is not None: + args["plan_cost"] = unmarshal_Money(field) + else: + args["plan_cost"] = None + + field = data.get("extra_pipelines_cost", None) + if field is not None: + args["extra_pipelines_cost"] = unmarshal_Money(field) + else: + args["extra_pipelines_cost"] = None + + field = data.get("plans_usage_details", None) + if field is not None: + args["plans_usage_details"] = ( + {key: unmarshal_PlanUsageDetails(value) for key, value in field.items()} + if field is not None + else None + ) + + field = data.get("extra_cache_cost", None) + if field is not None: + args["extra_cache_cost"] = unmarshal_Money(field) + else: + args["extra_cache_cost"] = None + + field = data.get("extra_waf_cost", None) + if field is not None: + args["extra_waf_cost"] = unmarshal_Money(field) + else: + args["extra_waf_cost"] = None + + field = data.get("waf_add_on", None) + if field is not None: + args["waf_add_on"] = unmarshal_Money(field) + else: + args["waf_add_on"] = None + + field = data.get("total_cost", None) + if field is not None: + args["total_cost"] = unmarshal_Money(field) + else: + args["total_cost"] = None + + return GetBillingResponse(**args) + + +def unmarshal_HeadStageResponseHeadStage(data: Any) -> HeadStageResponseHeadStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'HeadStageResponseHeadStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("dns_stage_id", None) + if field is not None: + args["dns_stage_id"] = field + else: + args["dns_stage_id"] = None + + return HeadStageResponseHeadStage(**args) + + +def unmarshal_HeadStageResponse(data: Any) -> HeadStageResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'HeadStageResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("head_stage", None) + if field is not None: + args["head_stage"] = unmarshal_HeadStageResponseHeadStage(field) + else: + args["head_stage"] = None + + return HeadStageResponse(**args) + + +def unmarshal_ListBackendStagesResponse(data: Any) -> ListBackendStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListBackendStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("stages", None) + if field is not None: + args["stages"] = ( + [unmarshal_BackendStage(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListBackendStagesResponse(**args) + + +def unmarshal_ListCacheStagesResponse(data: Any) -> ListCacheStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListCacheStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("stages", None) + if field is not None: + args["stages"] = ( + [unmarshal_CacheStage(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListCacheStagesResponse(**args) + + +def unmarshal_ListDNSStagesResponse(data: Any) -> ListDNSStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListDNSStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("stages", None) + if field is not None: + args["stages"] = ( + [unmarshal_DNSStage(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListDNSStagesResponse(**args) + + +def unmarshal_ListHeadStagesResponseHeadStage( + data: Any, +) -> ListHeadStagesResponseHeadStage: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListHeadStagesResponseHeadStage' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("dns_stage_id", None) + if field is not None: + args["dns_stage_id"] = field + else: + args["dns_stage_id"] = None + + return ListHeadStagesResponseHeadStage(**args) + + +def unmarshal_ListHeadStagesResponse(data: Any) -> ListHeadStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListHeadStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("head_stages", None) + if field is not None: + args["head_stages"] = ( + [unmarshal_ListHeadStagesResponseHeadStage(v) for v in field] + if field is not None + else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListHeadStagesResponse(**args) + + +def unmarshal_ListPipelinesResponse(data: Any) -> ListPipelinesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListPipelinesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("pipelines", None) + if field is not None: + args["pipelines"] = ( + [unmarshal_Pipeline(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListPipelinesResponse(**args) + + +def unmarshal_ListPipelinesWithStagesResponse( + data: Any, +) -> ListPipelinesWithStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListPipelinesWithStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("pipelines", None) + if field is not None: + args["pipelines"] = ( + [unmarshal_PipelineStages(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListPipelinesWithStagesResponse(**args) + + +def unmarshal_ListPlansResponse(data: Any) -> ListPlansResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListPlansResponse' 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 + + field = data.get("plans", None) + if field is not None: + args["plans"] = ( + [unmarshal_PlanDetails(v) for v in field] if field is not None else None + ) + + return ListPlansResponse(**args) + + +def unmarshal_ListPurgeRequestsResponse(data: Any) -> ListPurgeRequestsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListPurgeRequestsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("purge_requests", None) + if field is not None: + args["purge_requests"] = ( + [unmarshal_PurgeRequest(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListPurgeRequestsResponse(**args) + + +def unmarshal_ListRouteRulesResponse(data: Any) -> ListRouteRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListRouteRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("route_rules", None) + if field is not None: + args["route_rules"] = ( + [unmarshal_RouteRule(v) for v in field] if field is not None else None + ) + + return ListRouteRulesResponse(**args) + + +def unmarshal_ListRouteStagesResponse(data: Any) -> ListRouteStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListRouteStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("stages", None) + if field is not None: + args["stages"] = ( + [unmarshal_RouteStage(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListRouteStagesResponse(**args) + + +def unmarshal_ListTLSStagesResponse(data: Any) -> ListTLSStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListTLSStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("stages", None) + if field is not None: + args["stages"] = ( + [unmarshal_TLSStage(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListTLSStagesResponse(**args) + + +def unmarshal_ListWafStagesResponse(data: Any) -> ListWafStagesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListWafStagesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("stages", None) + if field is not None: + args["stages"] = ( + [unmarshal_WafStage(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListWafStagesResponse(**args) + + +def unmarshal_Plan(data: Any) -> Plan: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Plan' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("plan_name", None) + if field is not None: + args["plan_name"] = field + + return Plan(**args) + + +def unmarshal_SetRouteRulesResponse(data: Any) -> SetRouteRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SetRouteRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("route_rules", None) + if field is not None: + args["route_rules"] = ( + [unmarshal_RouteRule(v) for v in field] if field is not None else None + ) + + return SetRouteRulesResponse(**args) + + +def marshal_RuleHttpMatchPathFilter( + request: RuleHttpMatchPathFilter, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.path_filter_type is not None: + output["path_filter_type"] = str(request.path_filter_type) + + if request.value is not None: + output["value"] = request.value + + return output + + +def marshal_RuleHttpMatch( + request: RuleHttpMatch, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.method_filters is not None: + output["method_filters"] = [str(item) for item in request.method_filters] + + if request.path_filter is not None: + output["path_filter"] = marshal_RuleHttpMatchPathFilter( + request.path_filter, defaults + ) + + return output + + +def marshal_SetRouteRulesRequestRouteRule( + request: SetRouteRulesRequestRouteRule, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("rule_http_match", request.rule_http_match), + ] + ), + ) + output.update( + resolve_one_of( + [ + OneOfPossibility("backend_stage_id", request.backend_stage_id), + ] + ), + ) + + return output + + +def marshal_AddRouteRulesRequest( + request: AddRouteRulesRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("after_position", request.after_position), + OneOfPossibility("before_position", request.before_position), + ] + ), + ) + + if request.route_rules is not None: + output["route_rules"] = [ + marshal_SetRouteRulesRequestRouteRule(item, defaults) + for item in request.route_rules + ] + + return output + + +def marshal_CheckDomainRequest( + request: CheckDomainRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.fqdn is not None: + output["fqdn"] = request.fqdn + + if request.cname is not None: + output["cname"] = request.cname + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + return output + + +def marshal_ScalewayLb( + request: ScalewayLb, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.id is not None: + output["id"] = request.id + + if request.zone is not None: + output["zone"] = request.zone or defaults.default_zone + + if request.frontend_id is not None: + output["frontend_id"] = request.frontend_id + + if request.is_ssl is not None: + output["is_ssl"] = request.is_ssl + + if request.domain_name is not None: + output["domain_name"] = request.domain_name + + return output + + +def marshal_CheckLbOriginRequest( + request: CheckLbOriginRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.lb is not None: + output["lb"] = marshal_ScalewayLb(request.lb, defaults) + + return output + + +def marshal_CheckPEMChainRequestSecretChain( + request: CheckPEMChainRequestSecretChain, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.secret_id is not None: + output["secret_id"] = request.secret_id + + if request.secret_region is not None: + output["secret_region"] = request.secret_region + + return output + + +def marshal_CheckPEMChainRequest( + request: CheckPEMChainRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("secret", request.secret), + OneOfPossibility("raw", request.raw), + ] + ), + ) + + if request.fqdn is not None: + output["fqdn"] = request.fqdn + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + return output + + +def marshal_ScalewayLbBackendConfig( + request: ScalewayLbBackendConfig, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.lbs is not None: + output["lbs"] = [marshal_ScalewayLb(item, defaults) for item in request.lbs] + + return output + + +def marshal_ScalewayS3BackendConfig( + request: ScalewayS3BackendConfig, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.bucket_name is not None: + output["bucket_name"] = request.bucket_name + + if request.bucket_region is not None: + output["bucket_region"] = request.bucket_region + + if request.is_website is not None: + output["is_website"] = request.is_website + + return output + + +def marshal_CreateBackendStageRequest( + request: CreateBackendStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("scaleway_s3", request.scaleway_s3), + OneOfPossibility("scaleway_lb", request.scaleway_lb), + ] + ), + ) + + return output + + +def marshal_CreateCacheStageRequest( + request: CreateCacheStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("backend_stage_id", request.backend_stage_id), + OneOfPossibility("waf_stage_id", request.waf_stage_id), + OneOfPossibility("route_stage_id", request.route_stage_id), + ] + ), + ) + + if request.fallback_ttl is not None: + output["fallback_ttl"] = request.fallback_ttl + + return output + + +def marshal_CreateDNSStageRequest( + request: CreateDNSStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("tls_stage_id", request.tls_stage_id), + OneOfPossibility("cache_stage_id", request.cache_stage_id), + OneOfPossibility("backend_stage_id", request.backend_stage_id), + ] + ), + ) + + if request.fqdns is not None: + output["fqdns"] = request.fqdns + + return output + + +def marshal_CreatePipelineRequest( + request: CreatePipelineRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.description is not None: + output["description"] = request.description + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + return output + + +def marshal_CreatePurgeRequestRequest( + request: CreatePurgeRequestRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("assets", request.assets), + OneOfPossibility("all", request.all), + ] + ), + ) + + if request.pipeline_id is not None: + output["pipeline_id"] = request.pipeline_id + + return output + + +def marshal_CreateRouteStageRequest( + request: CreateRouteStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("waf_stage_id", request.waf_stage_id), + ] + ), + ) + + return output + + +def marshal_TLSSecret( + request: TLSSecret, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.secret_id is not None: + output["secret_id"] = request.secret_id + + if request.region is not None: + output["region"] = request.region or defaults.default_region + + return output + + +def marshal_CreateTLSStageRequest( + request: CreateTLSStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("cache_stage_id", request.cache_stage_id), + OneOfPossibility("backend_stage_id", request.backend_stage_id), + OneOfPossibility("route_stage_id", request.route_stage_id), + OneOfPossibility("waf_stage_id", request.waf_stage_id), + ] + ), + ) + + if request.secrets is not None: + output["secrets"] = [ + marshal_TLSSecret(item, defaults) for item in request.secrets + ] + + if request.managed_certificate is not None: + output["managed_certificate"] = request.managed_certificate + + return output + + +def marshal_CreateWafStageRequest( + request: CreateWafStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("backend_stage_id", request.backend_stage_id), + ] + ), + ) + + if request.paranoia_level is not None: + output["paranoia_level"] = request.paranoia_level + + if request.mode is not None: + output["mode"] = str(request.mode) + + return output + + +def marshal_SelectPlanRequest( + request: SelectPlanRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.plan_name is not None: + output["plan_name"] = str(request.plan_name) + + return output + + +def marshal_SetHeadStageRequestAddNewHeadStage( + request: SetHeadStageRequestAddNewHeadStage, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.new_stage_id is not None: + output["new_stage_id"] = request.new_stage_id + + return output + + +def marshal_SetHeadStageRequestRemoveHeadStage( + request: SetHeadStageRequestRemoveHeadStage, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.remove_stage_id is not None: + output["remove_stage_id"] = request.remove_stage_id + + return output + + +def marshal_SetHeadStageRequestSwapHeadStage( + request: SetHeadStageRequestSwapHeadStage, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.new_stage_id is not None: + output["new_stage_id"] = request.new_stage_id + + if request.current_stage_id is not None: + output["current_stage_id"] = request.current_stage_id + + return output + + +def marshal_SetHeadStageRequest( + request: SetHeadStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("add_new_head_stage", request.add_new_head_stage), + OneOfPossibility("remove_head_stage", request.remove_head_stage), + OneOfPossibility("swap_head_stage", request.swap_head_stage), + ] + ), + ) + + return output + + +def marshal_SetRouteRulesRequest( + request: SetRouteRulesRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.route_rules is not None: + output["route_rules"] = [ + marshal_SetRouteRulesRequestRouteRule(item, defaults) + for item in request.route_rules + ] + + return output + + +def marshal_UpdateBackendStageRequest( + request: UpdateBackendStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("scaleway_s3", request.scaleway_s3), + OneOfPossibility("scaleway_lb", request.scaleway_lb), + ] + ), + ) + + if request.pipeline_id is not None: + output["pipeline_id"] = request.pipeline_id + + return output + + +def marshal_UpdateCacheStageRequest( + request: UpdateCacheStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("backend_stage_id", request.backend_stage_id), + OneOfPossibility("waf_stage_id", request.waf_stage_id), + OneOfPossibility("route_stage_id", request.route_stage_id), + ] + ), + ) + + if request.fallback_ttl is not None: + output["fallback_ttl"] = request.fallback_ttl + + return output + + +def marshal_UpdateDNSStageRequest( + request: UpdateDNSStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("tls_stage_id", request.tls_stage_id), + OneOfPossibility("cache_stage_id", request.cache_stage_id), + OneOfPossibility("backend_stage_id", request.backend_stage_id), + ] + ), + ) + + if request.fqdns is not None: + output["fqdns"] = request.fqdns + + return output + + +def marshal_UpdatePipelineRequest( + request: UpdatePipelineRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.description is not None: + output["description"] = request.description + + return output + + +def marshal_UpdateRouteStageRequest( + request: UpdateRouteStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("waf_stage_id", request.waf_stage_id), + ] + ), + ) + + return output + + +def marshal_TLSSecretsConfig( + request: TLSSecretsConfig, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.tls_secrets is not None: + output["tls_secrets"] = [ + marshal_TLSSecret(item, defaults) for item in request.tls_secrets + ] + + return output + + +def marshal_UpdateTLSStageRequest( + request: UpdateTLSStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("cache_stage_id", request.cache_stage_id), + OneOfPossibility("backend_stage_id", request.backend_stage_id), + OneOfPossibility("route_stage_id", request.route_stage_id), + OneOfPossibility("waf_stage_id", request.waf_stage_id), + ] + ), + ) + + if request.tls_secrets_config is not None: + output["tls_secrets_config"] = marshal_TLSSecretsConfig( + request.tls_secrets_config, defaults + ) + + if request.managed_certificate is not None: + output["managed_certificate"] = request.managed_certificate + + return output + + +def marshal_UpdateWafStageRequest( + request: UpdateWafStageRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("backend_stage_id", request.backend_stage_id), + ] + ), + ) + + if request.mode is not None: + output["mode"] = str(request.mode) + + if request.paranoia_level is not None: + output["paranoia_level"] = request.paranoia_level + + return output diff --git a/scaleway/scaleway/edge_services/v1beta1/types.py b/scaleway/scaleway/edge_services/v1beta1/types.py new file mode 100644 index 000000000..424d86ece --- /dev/null +++ b/scaleway/scaleway/edge_services/v1beta1/types.py @@ -0,0 +1,1780 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import Dict, List, Optional + +from scaleway_core.bridge import ( + Money, + Region as ScwRegion, + Zone as ScwZone, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class DNSStageType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_TYPE = "unknown_type" + AUTO = "auto" + MANAGED = "managed" + CUSTOM = "custom" + + def __str__(self) -> str: + return str(self.value) + + +class LbOriginError(str, Enum, metaclass=StrEnumMeta): + UNKNOWN = "unknown" + TIMEOUT = "timeout" + CONNECTION_REFUSED = "connection_refused" + TLS_ERROR = "tls_error" + + def __str__(self) -> str: + return str(self.value) + + +class ListBackendStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListCacheStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListDNSStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListPipelinesRequestOrderBy(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 ListPipelinesWithStagesRequestOrderBy(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 ListPurgeRequestsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListRouteStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListTLSStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_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" + + def __str__(self) -> str: + return str(self.value) + + +class PipelineErrorCode(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_CODE = "unknown_code" + DNS_INVALID_FORMAT = "dns_invalid_format" + DNS_INVALID_TLD = "dns_invalid_tld" + DNS_FORBIDDEN_ROOT_DOMAIN = "dns_forbidden_root_domain" + DNS_FORBIDDEN_SCW_CLOUD = "dns_forbidden_scw_cloud" + DNS_DOMAIN_DONT_EXIST = "dns_domain_dont_exist" + DNS_CNAME_DONT_EXIST = "dns_cname_dont_exist" + DNS_CNAME_RESOLVE = "dns_cname_resolve" + DNS_FQDN_ALREADY_EXISTS = "dns_fqdn_already_exists" + DNS_FQDN_ALREADY_IN_USE = "dns_fqdn_already_in_use" + TLS_CERT_DELETED = "tls_cert_deleted" + TLS_CERT_DISABLED = "tls_cert_disabled" + TLS_CERT_EXPIRED = "tls_cert_expired" + TLS_CERT_INVALID_FORMAT = "tls_cert_invalid_format" + TLS_CERT_MISSING = "tls_cert_missing" + TLS_CHAIN_ORDER = "tls_chain_order" + TLS_KEY_INVALID_FORMAT = "tls_key_invalid_format" + TLS_KEY_MISSING = "tls_key_missing" + TLS_KEY_TOO_MANY = "tls_key_too_many" + TLS_MANAGED_DOMAIN_RATE_LIMIT = "tls_managed_domain_rate_limit" + TLS_MANAGED_INTERNAL = "tls_managed_internal" + TLS_PAIR_MISMATCH = "tls_pair_mismatch" + TLS_ROOT_INCONSISTENT = "tls_root_inconsistent" + TLS_ROOT_INCORRECT = "tls_root_incorrect" + TLS_ROOT_MISSING = "tls_root_missing" + TLS_SAN_MISMATCH = "tls_san_mismatch" + TLS_SELF_SIGNED = "tls_self_signed" + PIPELINE_INVALID_WORKFLOW = "pipeline_invalid_workflow" + PIPELINE_MISSING_HEAD_STAGE = "pipeline_missing_head_stage" + + def __str__(self) -> str: + return str(self.value) + + +class PipelineErrorSeverity(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_SEVERITY = "unknown_severity" + WARNING = "warning" + CRITICAL = "critical" + + def __str__(self) -> str: + return str(self.value) + + +class PipelineErrorStage(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STAGE = "unknown_stage" + DNS = "dns" + TLS = "tls" + CACHE = "cache" + BACKEND = "backend" + + def __str__(self) -> str: + return str(self.value) + + +class PipelineErrorType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_TYPE = "unknown_type" + RUNTIME = "runtime" + CONFIG = "config" + + def __str__(self) -> str: + return str(self.value) + + +class PipelineStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + READY = "ready" + ERROR = "error" + PENDING = "pending" + WARNING = "warning" + + def __str__(self) -> str: + return str(self.value) + + +class PlanName(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_NAME = "unknown_name" + STARTER = "starter" + PROFESSIONAL = "professional" + ADVANCED = "advanced" + + def __str__(self) -> str: + return str(self.value) + + +class PurgeRequestStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + DONE = "done" + ERROR = "error" + PENDING = "pending" + + def __str__(self) -> str: + return str(self.value) + + +class RuleHttpMatchMethodFilter(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_METHOD_FILTER = "unknown_method_filter" + GET = "get" + POST = "post" + PUT = "put" + PATCH = "patch" + DELETE = "delete" + HEAD = "head" + OPTIONS = "options" + + def __str__(self) -> str: + return str(self.value) + + +class RuleHttpMatchPathFilterPathFilterType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_PATH_FILTER = "unknown_path_filter" + REGEX = "regex" + + def __str__(self) -> str: + return str(self.value) + + +class SearchBackendStagesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class WafStageMode(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_MODE = "unknown_mode" + DISABLE = "disable" + LOG_ONLY = "log_only" + ENABLE = "enable" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class ScalewayLb: + id: str + """ + ID of the Load Balancer. + """ + + zone: ScwZone + """ + Zone of the Load Balancer. + """ + + frontend_id: str + """ + ID of the frontend linked to the Load Balancer. + """ + + is_ssl: Optional[bool] + """ + Defines whether the Load Balancer's frontend handles SSL connections. + """ + + domain_name: Optional[str] + """ + Fully Qualified Domain Name (in the format subdomain.example.com) to use in HTTP requests sent towards your Load Balancer. + """ + + +@dataclass +class RuleHttpMatchPathFilter: + path_filter_type: RuleHttpMatchPathFilterPathFilterType + """ + Type of filter to match for the HTTP URL path. For now, all path filters must be written in regex and use the `regex` type. + """ + + value: str + """ + Value to be matched for the HTTP URL path. + """ + + +@dataclass +class ScalewayLbBackendConfig: + lbs: List[ScalewayLb] + """ + Load Balancer information. + """ + + +@dataclass +class ScalewayS3BackendConfig: + bucket_name: Optional[str] + """ + Name of the Bucket. + """ + + bucket_region: Optional[str] + """ + Region of the Bucket. + """ + + is_website: Optional[bool] + """ + Defines whether the bucket website feature is enabled. + """ + + +@dataclass +class PipelineError: + stage: PipelineErrorStage + + code: PipelineErrorCode + + severity: PipelineErrorSeverity + + message: str + + type_: PipelineErrorType + + +@dataclass +class TLSSecret: + secret_id: str + """ + ID of the Secret. + """ + + region: ScwRegion + """ + Region of the Secret. + """ + + +@dataclass +class RuleHttpMatch: + method_filters: List[RuleHttpMatchMethodFilter] + """ + HTTP methods to filter for. A request using any of these methods will be considered to match the rule. Possible values are `get`, `post`, `put`, `patch`, `delete`, `head`, `options`. All methods will match if none is provided. + """ + + path_filter: Optional[RuleHttpMatchPathFilter] + """ + HTTP URL path to filter for. A request whose path matches the given filter will be considered to match the rule. All paths will match if none is provided. + """ + + +@dataclass +class BackendStage: + id: str + """ + ID of the backend stage. + """ + + pipeline_id: str + """ + Pipeline ID the backend stage belongs to. + """ + + created_at: Optional[datetime] + """ + Date the backend stage was created. + """ + + updated_at: Optional[datetime] + """ + Date the backend stage was last updated. + """ + + scaleway_s3: Optional[ScalewayS3BackendConfig] + + scaleway_lb: Optional[ScalewayLbBackendConfig] + + +@dataclass +class CacheStage: + id: str + """ + ID of the cache stage. + """ + + pipeline_id: str + """ + Pipeline ID the cache stage belongs to. + """ + + fallback_ttl: Optional[str] + """ + Time To Live (TTL) in seconds. Defines how long content is cached. + """ + + created_at: Optional[datetime] + """ + Date the cache stage was created. + """ + + updated_at: Optional[datetime] + """ + Date the cache stage was last updated. + """ + + backend_stage_id: Optional[str] + + waf_stage_id: Optional[str] + + route_stage_id: Optional[str] + + +@dataclass +class DNSStage: + id: str + """ + ID of the DNS stage. + """ + + fqdns: List[str] + """ + List of Fully Qualified Domain Names attached to the stage. + """ + + type_: DNSStageType + """ + Type of the stage. + """ + + pipeline_id: str + """ + Pipeline ID the DNS stage belongs to. + """ + + created_at: Optional[datetime] + """ + Date the DNS stage was created. + """ + + updated_at: Optional[datetime] + """ + Date the DNS stage was last updated. + """ + + tls_stage_id: Optional[str] + + cache_stage_id: Optional[str] + + backend_stage_id: Optional[str] + + +@dataclass +class Pipeline: + id: str + """ + ID of the pipeline. + """ + + name: str + """ + Name of the pipeline. + """ + + description: str + """ + Description of the pipeline. + """ + + status: PipelineStatus + """ + Status of the pipeline. + """ + + errors: List[PipelineError] + """ + Errors of the pipeline. + """ + + project_id: str + """ + Project ID of the pipeline. + """ + + organization_id: str + """ + Organization ID of the pipeline. + """ + + created_at: Optional[datetime] + """ + Date the pipeline was created. + """ + + updated_at: Optional[datetime] + """ + Date the pipeline was last updated. + """ + + +@dataclass +class RouteStage: + id: str + """ + ID of the route stage. + """ + + pipeline_id: str + """ + Pipeline ID the route stage belongs to. + """ + + created_at: Optional[datetime] + """ + Date the route stage was created. + """ + + updated_at: Optional[datetime] + """ + Date the route stage was last updated. + """ + + waf_stage_id: Optional[str] + + +@dataclass +class TLSStage: + id: str + """ + ID of the TLS stage. + """ + + secrets: List[TLSSecret] + """ + Secret (from Scaleway Secret Manager) containing your custom certificate. + """ + + managed_certificate: bool + """ + True when Scaleway generates and manages a Let's Encrypt certificate for the TLS stage/custom endpoint. + """ + + pipeline_id: str + """ + Pipeline ID the TLS stage belongs to. + """ + + certificate_expires_at: Optional[datetime] + """ + Expiration date of the certificate. + """ + + created_at: Optional[datetime] + """ + Date the TLS stage was created. + """ + + updated_at: Optional[datetime] + """ + Date the TLS stage was last updated. + """ + + cache_stage_id: Optional[str] + + backend_stage_id: Optional[str] + + waf_stage_id: Optional[str] + + route_stage_id: Optional[str] + + +@dataclass +class WafStage: + id: str + """ + ID of the WAF stage. + """ + + pipeline_id: str + """ + Pipeline ID the WAF stage belongs to. + """ + + mode: WafStageMode + """ + Mode defining WAF behavior (`disable`/`log_only`/`enable`). + """ + + paranoia_level: int + """ + Sensitivity level (`1`,`2`,`3`,`4`) to use when classifying requests as malicious. With a high level, requests are more likely to be classed as malicious, and false positives are expected. With a lower level, requests are more likely to be classed as benign. + """ + + created_at: Optional[datetime] + """ + Date the WAF stage was created. + """ + + updated_at: Optional[datetime] + """ + Date the WAF stage was last updated. + """ + + backend_stage_id: Optional[str] + + +@dataclass +class SetRouteRulesRequestRouteRule: + rule_http_match: Optional[RuleHttpMatch] + + backend_stage_id: Optional[str] + + +@dataclass +class RouteRule: + position: int + """ + Position of the rule which determines the order of processing within the route stage. + """ + + route_stage_id: str + """ + Route stage ID the route rule belongs to. + """ + + rule_http_match: Optional[RuleHttpMatch] + + backend_stage_id: Optional[str] + + +@dataclass +class CheckPEMChainRequestSecretChain: + secret_id: str + + secret_region: str + + +@dataclass +class PlanDetails: + plan_name: PlanName + """ + Subscription plan name. + """ + + package_gb: int + """ + Amount of egress data from cache included in subscription plan. + """ + + pipeline_limit: int + """ + Number of pipelines included in subscription plan. + """ + + waf_requests: int + """ + Number of WAF requests included in subscription plan. + """ + + +@dataclass +class PlanUsageDetails: + plan_cost: Optional[Money] + """ + Cost to date (this month) for the corresponding Edge Services subscription plan. + """ + + +@dataclass +class HeadStageResponseHeadStage: + dns_stage_id: Optional[str] + + +@dataclass +class ListHeadStagesResponseHeadStage: + dns_stage_id: Optional[str] + + +@dataclass +class PipelineStages: + dns_stages: List[DNSStage] + + tls_stages: List[TLSStage] + + cache_stages: List[CacheStage] + + backend_stages: List[BackendStage] + + waf_stages: List[WafStage] + + route_stages: List[RouteStage] + + pipeline: Optional[Pipeline] + + +@dataclass +class PurgeRequest: + id: str + """ + ID of the purge request. + """ + + pipeline_id: str + """ + Pipeline ID the purge request belongs to. + """ + + status: PurgeRequestStatus + """ + Status of the purge request. + """ + + created_at: Optional[datetime] + """ + Date the purge request was created. + """ + + updated_at: Optional[datetime] + """ + Date the purge request was last updated. + """ + + assets: Optional[List[str]] + + all: Optional[bool] + + +@dataclass +class SetHeadStageRequestAddNewHeadStage: + new_stage_id: str + + +@dataclass +class SetHeadStageRequestRemoveHeadStage: + remove_stage_id: str + + +@dataclass +class SetHeadStageRequestSwapHeadStage: + new_stage_id: str + + current_stage_id: str + + +@dataclass +class TLSSecretsConfig: + tls_secrets: List[TLSSecret] + """ + Secret information (from Secret Manager). + """ + + +@dataclass +class AddRouteRulesRequest: + route_stage_id: str + """ + ID of the route stage to update. + """ + + route_rules: Optional[List[SetRouteRulesRequestRouteRule]] + """ + List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`. + """ + + after_position: Optional[int] + + before_position: Optional[int] + + +@dataclass +class AddRouteRulesResponse: + route_rules: List[RouteRule] + """ + List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`. + """ + + +@dataclass +class CheckDomainRequest: + fqdn: str + + cname: str + + project_id: Optional[str] + + +@dataclass +class CheckDomainResponse: + is_valid: bool + + +@dataclass +class CheckLbOriginRequest: + lb: Optional[ScalewayLb] + + +@dataclass +class CheckLbOriginResponse: + is_valid: bool + + error_type: LbOriginError + + +@dataclass +class CheckPEMChainRequest: + fqdn: str + + project_id: Optional[str] + + secret: Optional[CheckPEMChainRequestSecretChain] + + raw: Optional[str] + + +@dataclass +class CheckPEMChainResponse: + is_valid: bool + + +@dataclass +class CreateBackendStageRequest: + pipeline_id: str + """ + Pipeline ID the Backend stage belongs to. + """ + + scaleway_s3: Optional[ScalewayS3BackendConfig] + + scaleway_lb: Optional[ScalewayLbBackendConfig] + + +@dataclass +class CreateCacheStageRequest: + fallback_ttl: Optional[str] + """ + Time To Live (TTL) in seconds. Defines how long content is cached. + """ + + pipeline_id: str + """ + Pipeline ID the Cache stage belongs to. + """ + + backend_stage_id: Optional[str] + + waf_stage_id: Optional[str] + + route_stage_id: Optional[str] + + +@dataclass +class CreateDNSStageRequest: + fqdns: Optional[List[str]] + """ + Fully Qualified Domain Name (in the format subdomain.example.com) to attach to the stage. + """ + + pipeline_id: str + """ + Pipeline ID the DNS stage belongs to. + """ + + tls_stage_id: Optional[str] + + cache_stage_id: Optional[str] + + backend_stage_id: Optional[str] + + +@dataclass +class CreatePipelineRequest: + name: str + """ + Name of the pipeline. + """ + + description: str + """ + Description of the pipeline. + """ + + project_id: Optional[str] + """ + Project ID in which the pipeline will be created. + """ + + +@dataclass +class CreatePurgeRequestRequest: + pipeline_id: str + """ + Pipeline ID in which the purge request will be created. + """ + + assets: Optional[List[str]] + + all: Optional[bool] + + +@dataclass +class CreateRouteStageRequest: + pipeline_id: str + """ + Pipeline ID the route stage belongs to. + """ + + waf_stage_id: Optional[str] + + +@dataclass +class CreateTLSStageRequest: + secrets: Optional[List[TLSSecret]] + """ + Secret (from Scaleway Secret Manager) containing your custom certificate. + """ + + managed_certificate: Optional[bool] + """ + True when Scaleway generates and manages a Let's Encrypt certificate for the TLS stage/custom endpoint. + """ + + pipeline_id: str + """ + Pipeline ID the TLS stage belongs to. + """ + + cache_stage_id: Optional[str] + + backend_stage_id: Optional[str] + + route_stage_id: Optional[str] + + waf_stage_id: Optional[str] + + +@dataclass +class CreateWafStageRequest: + pipeline_id: str + """ + Pipeline ID the WAF stage belongs to. + """ + + paranoia_level: int + """ + Sensitivity level (`1`,`2`,`3`,`4`) to use when classifying requests as malicious. With a high level, requests are more likely to be classed as malicious, and false positives are expected. With a lower level, requests are more likely to be classed as benign. + """ + + mode: Optional[WafStageMode] + """ + Mode defining WAF behavior (`disable`/`log_only`/`enable`). + """ + + backend_stage_id: Optional[str] + + +@dataclass +class DeleteBackendStageRequest: + backend_stage_id: str + """ + ID of the backend stage to delete. + """ + + +@dataclass +class DeleteCacheStageRequest: + cache_stage_id: str + """ + ID of the cache stage to delete. + """ + + +@dataclass +class DeleteCurrentPlanRequest: + project_id: Optional[str] + + +@dataclass +class DeleteDNSStageRequest: + dns_stage_id: str + """ + ID of the DNS stage to delete. + """ + + +@dataclass +class DeletePipelineRequest: + pipeline_id: str + """ + ID of the pipeline to delete. + """ + + +@dataclass +class DeleteRouteStageRequest: + route_stage_id: str + """ + ID of the route stage to delete. + """ + + +@dataclass +class DeleteTLSStageRequest: + tls_stage_id: str + """ + ID of the TLS stage to delete. + """ + + +@dataclass +class DeleteWafStageRequest: + waf_stage_id: str + """ + ID of the WAF stage to delete. + """ + + +@dataclass +class GetBackendStageRequest: + backend_stage_id: str + """ + ID of the requested backend stage. + """ + + +@dataclass +class GetBillingRequest: + project_id: Optional[str] + + +@dataclass +class GetBillingResponse: + current_plan: Optional[PlanDetails] + """ + Information on the currently-selected, active Edge Services subscription plan. + """ + + pipeline_number: int + """ + Total number of pipelines currently configured. + """ + + current_plan_cache_usage: int + """ + Total amount of data egressed from the cache in gigabytes from the beginning of the month, for the active subscription plan. + """ + + extra_cache_usage: int + """ + Total amount of extra data egressed from cache in gigabytes from the beginning of the month, not included in the subscription plans. + """ + + current_plan_waf_usage: int + """ + Total number of requests processed by the WAF since the beginning of the current month, for the active subscription plan. + """ + + extra_waf_usage: int + """ + Total number of extra requests processed by the WAF from the beginning of the month, not included in the subscription plans. + """ + + plan_cost: Optional[Money] + """ + Cost to date (this month) for Edge Service subscription plans. This comprises the pro-rata cost of the current subscription plan, and any previous subscription plans that were active earlier in the month. + """ + + extra_pipelines_cost: Optional[Money] + """ + Cost to date (this month) of pipelines not included in the subscription plans. + """ + + plans_usage_details: Dict[str, PlanUsageDetails] + """ + Detailed costs and usage for all Edge Services subscription plans that were activated during the month. + """ + + extra_cache_cost: Optional[Money] + """ + Cost to date (this month) of the data egressed from the cache that is not included in the subscription plans. + """ + + extra_waf_cost: Optional[Money] + """ + Cost to date (this month) of the extra requests processed by the WAF that were not included in the subscription plans. + """ + + waf_add_on: Optional[Money] + """ + Cost of activating WAF add-on (where subscription plan does not include WAF). + """ + + total_cost: Optional[Money] + """ + Total cost to date (this month) of all Edge Services resources including active subscription plan, previously active plans, extra pipelines and extra egress cache data. + """ + + +@dataclass +class GetCacheStageRequest: + cache_stage_id: str + """ + ID of the requested cache stage. + """ + + +@dataclass +class GetCurrentPlanRequest: + project_id: Optional[str] + + +@dataclass +class GetDNSStageRequest: + dns_stage_id: str + """ + ID of the requested DNS stage. + """ + + +@dataclass +class GetPipelineRequest: + pipeline_id: str + """ + ID of the requested pipeline. + """ + + +@dataclass +class GetPurgeRequestRequest: + purge_request_id: str + """ + ID of the requested purge request. + """ + + +@dataclass +class GetRouteStageRequest: + route_stage_id: str + """ + ID of the requested route stage. + """ + + +@dataclass +class GetTLSStageRequest: + tls_stage_id: str + """ + ID of the requested TLS stage. + """ + + +@dataclass +class GetWafStageRequest: + waf_stage_id: str + """ + ID of the requested WAF stage. + """ + + +@dataclass +class HeadStageResponse: + head_stage: Optional[HeadStageResponseHeadStage] + """ + Modified or created head stage. + """ + + +@dataclass +class ListBackendStagesRequest: + order_by: Optional[ListBackendStagesRequestOrderBy] + """ + Sort order of backend stages in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of backend stages to return per page. + """ + + pipeline_id: str + """ + Pipeline ID to filter for. Only backend stages from this pipeline will be returned. + """ + + bucket_name: Optional[str] + """ + Bucket name to filter for. Only backend stages from this Bucket will be returned. + """ + + bucket_region: Optional[str] + """ + Bucket region to filter for. Only backend stages with buckets in this region will be returned. + """ + + lb_id: Optional[str] + """ + Load Balancer ID to filter for. Only backend stages with this Load Balancer will be returned. + """ + + +@dataclass +class ListBackendStagesResponse: + stages: List[BackendStage] + """ + Paginated list of backend stages. + """ + + total_count: int + """ + Count of all backend stages matching the requested criteria. + """ + + +@dataclass +class ListCacheStagesRequest: + order_by: Optional[ListCacheStagesRequestOrderBy] + """ + Sort order of cache stages in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of cache stages to return per page. + """ + + pipeline_id: str + """ + Pipeline ID to filter for. Only cache stages from this pipeline will be returned. + """ + + +@dataclass +class ListCacheStagesResponse: + stages: List[CacheStage] + """ + Paginated list of cache stages. + """ + + total_count: int + """ + Count of all cache stages matching the requested criteria. + """ + + +@dataclass +class ListDNSStagesRequest: + order_by: Optional[ListDNSStagesRequestOrderBy] + """ + Sort order of DNS stages in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of DNS stages to return per page. + """ + + pipeline_id: str + """ + Pipeline ID to filter for. Only DNS stages from this pipeline will be returned. + """ + + fqdn: Optional[str] + """ + Fully Qualified Domain Name to filter for (in the format subdomain.example.com). Only DNS stages with this FQDN will be returned. + """ + + +@dataclass +class ListDNSStagesResponse: + stages: List[DNSStage] + """ + Paginated list of DNS stages. + """ + + total_count: int + """ + Count of all DNS stages matching the requested criteria. + """ + + +@dataclass +class ListHeadStagesRequest: + pipeline_id: str + """ + ID of the pipeline to update. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of head stages to return per page. + """ + + +@dataclass +class ListHeadStagesResponse: + head_stages: List[ListHeadStagesResponseHeadStage] + """ + Number of head stages to return per page. + """ + + total_count: int + """ + Count of all head stages matching the requested pipeline_id. + """ + + +@dataclass +class ListPipelinesRequest: + order_by: Optional[ListPipelinesRequestOrderBy] + """ + Sort order of pipelines in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of pipelines to return per page. + """ + + name: Optional[str] + """ + Pipeline name to filter for. Only pipelines with this string within their name will be returned. + """ + + organization_id: Optional[str] + """ + Organization ID to filter for. Only pipelines from this Organization will be returned. + """ + + project_id: Optional[str] + """ + Project ID to filter for. Only pipelines from this Project will be returned. + """ + + has_backend_stage_lb: Optional[bool] + """ + Filter on backend stage. Only pipelines with a Load Balancer origin will be returned. + """ + + +@dataclass +class ListPipelinesResponse: + pipelines: List[Pipeline] + """ + Paginated list of pipelines. + """ + + total_count: int + """ + Count of all pipelines matching the requested criteria. + """ + + +@dataclass +class ListPipelinesWithStagesRequest: + order_by: Optional[ListPipelinesWithStagesRequestOrderBy] + + page: Optional[int] + + page_size: Optional[int] + + name: Optional[str] + + organization_id: Optional[str] + + project_id: Optional[str] + + +@dataclass +class ListPipelinesWithStagesResponse: + pipelines: List[PipelineStages] + + total_count: int + + +@dataclass +class ListPlansResponse: + total_count: int + + plans: List[PlanDetails] + + +@dataclass +class ListPurgeRequestsRequest: + order_by: Optional[ListPurgeRequestsRequestOrderBy] + """ + Sort order of purge requests in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of purge requests to return per page. + """ + + organization_id: Optional[str] + """ + Organization ID to filter for. Only purge requests from this Project will be returned. + """ + + project_id: Optional[str] + """ + Project ID to filter for. Only purge requests from this Project will be returned. + """ + + pipeline_id: Optional[str] + """ + Pipeline ID to filter for. Only purge requests from this pipeline will be returned. + """ + + +@dataclass +class ListPurgeRequestsResponse: + purge_requests: List[PurgeRequest] + """ + Paginated list of purge requests. + """ + + total_count: int + """ + Count of all purge requests matching the requested criteria. + """ + + +@dataclass +class ListRouteRulesRequest: + route_stage_id: str + """ + Route stage ID to filter for. Only route rules from this route stage will be returned. + """ + + +@dataclass +class ListRouteRulesResponse: + route_rules: List[RouteRule] + """ + List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`. + """ + + +@dataclass +class ListRouteStagesRequest: + order_by: Optional[ListRouteStagesRequestOrderBy] + """ + Sort order of route stages in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of route stages to return per page. + """ + + pipeline_id: str + """ + Pipeline ID to filter for. Only route stages from this pipeline will be returned. + """ + + +@dataclass +class ListRouteStagesResponse: + stages: List[RouteStage] + """ + Paginated list of summarized route stages. + """ + + total_count: int + """ + Count of all route stages matching the requested criteria. + """ + + +@dataclass +class ListTLSStagesRequest: + order_by: Optional[ListTLSStagesRequestOrderBy] + """ + Sort order of TLS stages in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of TLS stages to return per page. + """ + + pipeline_id: str + """ + Pipeline ID to filter for. Only TLS stages from this pipeline will be returned. + """ + + secret_id: Optional[str] + """ + Secret ID to filter for. Only TLS stages with this Secret ID will be returned. + """ + + secret_region: Optional[str] + """ + Secret region to filter for. Only TLS stages with a Secret in this region will be returned. + """ + + +@dataclass +class ListTLSStagesResponse: + stages: List[TLSStage] + """ + Paginated list of TLS stages. + """ + + total_count: int + """ + Count of all TLS stages matching the requested criteria. + """ + + +@dataclass +class ListWafStagesRequest: + order_by: Optional[ListWafStagesRequestOrderBy] + """ + Sort order of WAF stages in the response. + """ + + page: Optional[int] + """ + Page number to return, from the paginated results. + """ + + page_size: Optional[int] + """ + Number of WAF stages to return per page. + """ + + pipeline_id: str + """ + Pipeline ID to filter for. Only WAF stages from this pipeline will be returned. + """ + + +@dataclass +class ListWafStagesResponse: + stages: List[WafStage] + """ + Paginated list of WAF stages. + """ + + total_count: int + """ + Count of all WAF stages matching the requested criteria. + """ + + +@dataclass +class Plan: + plan_name: PlanName + + +@dataclass +class SearchBackendStagesRequest: + order_by: Optional[SearchBackendStagesRequestOrderBy] + + page: Optional[int] + + page_size: Optional[int] + + project_id: Optional[str] + + bucket_name: Optional[str] + + bucket_region: Optional[str] + + lb_id: Optional[str] + + +@dataclass +class SelectPlanRequest: + project_id: Optional[str] + + plan_name: Optional[PlanName] + + +@dataclass +class SetHeadStageRequest: + pipeline_id: str + """ + ID of the pipeline to update. + """ + + add_new_head_stage: Optional[SetHeadStageRequestAddNewHeadStage] + + remove_head_stage: Optional[SetHeadStageRequestRemoveHeadStage] + + swap_head_stage: Optional[SetHeadStageRequestSwapHeadStage] + + +@dataclass +class SetRouteRulesRequest: + route_stage_id: str + """ + ID of the route stage to update. + """ + + route_rules: Optional[List[SetRouteRulesRequestRouteRule]] + """ + List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`. + """ + + +@dataclass +class SetRouteRulesResponse: + route_rules: List[RouteRule] + """ + List of rules to be checked against every HTTP request. The first matching rule will forward the request to its specified backend stage. If no rules are matched, the request is forwarded to the WAF stage defined by `waf_stage_id`. + """ + + +@dataclass +class UpdateBackendStageRequest: + backend_stage_id: str + """ + ID of the backend stage to update. + """ + + pipeline_id: str + """ + Pipeline ID the Backend stage belongs to. + """ + + scaleway_s3: Optional[ScalewayS3BackendConfig] + + scaleway_lb: Optional[ScalewayLbBackendConfig] + + +@dataclass +class UpdateCacheStageRequest: + cache_stage_id: str + """ + ID of the cache stage to update. + """ + + fallback_ttl: Optional[str] + """ + Time To Live (TTL) in seconds. Defines how long content is cached. + """ + + backend_stage_id: Optional[str] + + waf_stage_id: Optional[str] + + route_stage_id: Optional[str] + + +@dataclass +class UpdateDNSStageRequest: + dns_stage_id: str + """ + ID of the DNS stage to update. + """ + + fqdns: Optional[List[str]] + """ + Fully Qualified Domain Name (in the format subdomain.example.com) attached to the stage. + """ + + tls_stage_id: Optional[str] + + cache_stage_id: Optional[str] + + backend_stage_id: Optional[str] + + +@dataclass +class UpdatePipelineRequest: + pipeline_id: str + """ + ID of the pipeline to update. + """ + + name: Optional[str] + """ + Name of the pipeline. + """ + + description: Optional[str] + """ + Description of the pipeline. + """ + + +@dataclass +class UpdateRouteStageRequest: + route_stage_id: str + """ + ID of the route stage to update. + """ + + waf_stage_id: Optional[str] + + +@dataclass +class UpdateTLSStageRequest: + tls_stage_id: str + """ + ID of the TLS stage to update. + """ + + tls_secrets_config: Optional[TLSSecretsConfig] + """ + Secret (from Scaleway Secret-Manager) containing your custom certificate. + """ + + managed_certificate: Optional[bool] + """ + True when Scaleway generates and manages a Let's Encrypt certificate for the TLS stage/custom endpoint. + """ + + cache_stage_id: Optional[str] + + backend_stage_id: Optional[str] + + route_stage_id: Optional[str] + + waf_stage_id: Optional[str] + + +@dataclass +class UpdateWafStageRequest: + waf_stage_id: str + """ + ID of the WAF stage to update. + """ + + mode: Optional[WafStageMode] + """ + Mode defining WAF behavior (`disable`/`log_only`/`enable`). + """ + + paranoia_level: Optional[int] + """ + Sensitivity level (`1`,`2`,`3`,`4`) to use when classifying requests as malicious. With a high level, requests are more likely to be classed as malicious, and false positives are expected. With a lower level, requests are more likely to be classed as benign. + """ + + backend_stage_id: Optional[str]