Skip to content

feat(edge_services): add ListPipelinesWithStages #697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .types import ListCacheStagesRequestOrderBy
from .types import ListDNSStagesRequestOrderBy
from .types import ListPipelinesRequestOrderBy
from .types import ListPipelinesWithStagesRequestOrderBy
from .types import ListPurgeRequestsRequestOrderBy
from .types import ListTLSStagesRequestOrderBy
from .types import PipelineErrorCode
Expand All @@ -29,6 +30,7 @@
from .types import TLSStage
from .types import CheckPEMChainRequestSecretChain
from .types import PlanDetails
from .types import PipelineStages
from .types import PurgeRequest
from .types import TLSSecretsConfig
from .types import CheckDomainRequest
Expand Down Expand Up @@ -66,6 +68,8 @@
from .types import ListDNSStagesResponse
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
Expand All @@ -87,6 +91,7 @@
"ListCacheStagesRequestOrderBy",
"ListDNSStagesRequestOrderBy",
"ListPipelinesRequestOrderBy",
"ListPipelinesWithStagesRequestOrderBy",
"ListPurgeRequestsRequestOrderBy",
"ListTLSStagesRequestOrderBy",
"PipelineErrorCode",
Expand All @@ -110,6 +115,7 @@
"TLSStage",
"CheckPEMChainRequestSecretChain",
"PlanDetails",
"PipelineStages",
"PurgeRequest",
"TLSSecretsConfig",
"CheckDomainRequest",
Expand Down Expand Up @@ -147,6 +153,8 @@
"ListDNSStagesResponse",
"ListPipelinesRequest",
"ListPipelinesResponse",
"ListPipelinesWithStagesRequest",
"ListPipelinesWithStagesResponse",
"ListPlansResponse",
"ListPurgeRequestsRequest",
"ListPurgeRequestsResponse",
Expand Down
87 changes: 86 additions & 1 deletion scaleway-async/scaleway_async/edge_services/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
ListCacheStagesRequestOrderBy,
ListDNSStagesRequestOrderBy,
ListPipelinesRequestOrderBy,
ListPipelinesWithStagesRequestOrderBy,
ListPurgeRequestsRequestOrderBy,
ListTLSStagesRequestOrderBy,
PlanName,
Expand All @@ -39,10 +40,12 @@
ListCacheStagesResponse,
ListDNSStagesResponse,
ListPipelinesResponse,
ListPipelinesWithStagesResponse,
ListPlansResponse,
ListPurgeRequestsResponse,
ListTLSStagesResponse,
Pipeline,
PipelineStages,
Plan,
PurgeRequest,
ScalewayLb,
Expand Down Expand Up @@ -77,6 +80,7 @@
unmarshal_ListCacheStagesResponse,
unmarshal_ListDNSStagesResponse,
unmarshal_ListPipelinesResponse,
unmarshal_ListPipelinesWithStagesResponse,
unmarshal_ListPlansResponse,
unmarshal_ListPurgeRequestsResponse,
unmarshal_ListTLSStagesResponse,
Expand Down Expand Up @@ -302,6 +306,87 @@ async def wait_for_pipeline(
},
)

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 <ListPipelinesWithStagesResponse>`

Usage:
::

result = await api.list_pipelines_with_stages()
"""

res = self._request(
"GET",
"/edge-services/v1alpha1/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] <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,
*,
Expand Down Expand Up @@ -1719,7 +1804,7 @@ async def get_billing(
project_id: Optional[str] = None,
) -> GetBillingResponse:
"""
Gives information on current edge-services subscription plan and used resources with associated price.
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 <GetBillingResponse>`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Pipeline,
TLSSecret,
TLSStage,
PipelineStages,
PurgeRequest,
CheckDomainResponse,
CheckLbOriginResponse,
Expand All @@ -33,6 +34,7 @@
ListCacheStagesResponse,
ListDNSStagesResponse,
ListPipelinesResponse,
ListPipelinesWithStagesResponse,
ListPlansResponse,
ListPurgeRequestsResponse,
ListTLSStagesResponse,
Expand Down Expand Up @@ -471,6 +473,47 @@ def unmarshal_TLSStage(data: Any) -> TLSStage:
return TLSStage(**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("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(
Expand Down Expand Up @@ -727,6 +770,29 @@ def unmarshal_ListPipelinesResponse(data: Any) -> ListPipelinesResponse:
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(
Expand Down
61 changes: 53 additions & 8 deletions scaleway-async/scaleway_async/edge_services/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ 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"
Expand Down Expand Up @@ -484,10 +494,23 @@ class PlanDetails:

pipeline_limit: int
"""
Number of pipeline included in subscription plan.
Number of pipelines included in subscription plan.
"""


@dataclass
class PipelineStages:
dns_stages: List[DNSStage]

tls_stages: List[TLSStage]

cache_stages: List[CacheStage]

backend_stages: List[BackendStage]

pipeline: Optional[Pipeline]


@dataclass
class PurgeRequest:
id: str
Expand Down Expand Up @@ -732,22 +755,22 @@ class GetBillingRequest:
class GetBillingResponse:
pipeline_number: int
"""
Total number of pipeline currently configured.
Total number of pipelines currently configured.
"""

current_plan_cache_usage: int
"""
Total amount of data egressed from cache in current subscription plan.
Total amount of data egressed from the cache (this month), included in the active subscription plan.
"""

extra_cache_usage: int
"""
Total amount of data egressed from cache not included in the plans.
Total amount of data egressed from cache (this month), not included in the active subscription plan.
"""

current_plan: Optional[PlanDetails]
"""
Information on the current edge-service subscription plan.
Information on the currently-selected, active Edge Services subscription plan.
"""

plan_cost: Optional[Money]
Expand All @@ -757,17 +780,17 @@ class GetBillingResponse:

extra_pipelines_cost: Optional[Money]
"""
Cost to date of the pipelines not included in the plans.
Cost to date (this month) of pipelines not included in the subscription plan.
"""

extra_cache_cost: Optional[Money]
"""
Cost to date of the data egressed from cache not included in the plans.
Cost to date (this month) of the data egressed from the cache that is not included in the active subscription plan.
"""

total_cost: Optional[Money]
"""
Total cost to date of edge-service product for the month including current plan, previous plans, extra pipelines and extra egress cache data.
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.
"""


Expand Down Expand Up @@ -1010,6 +1033,28 @@ class ListPipelinesResponse:
"""


@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
Expand Down
Loading