Skip to content

Commit edbd519

Browse files
feat(edge_services): add WAF billing (#855)
Co-authored-by: Laure-di <[email protected]>
1 parent 09b66d9 commit edbd519

File tree

6 files changed

+194
-14
lines changed

6 files changed

+194
-14
lines changed

scaleway-async/scaleway_async/edge_services/v1alpha1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from .types import TLSStage
3131
from .types import CheckPEMChainRequestSecretChain
3232
from .types import PlanDetails
33+
from .types import PlanUsageDetails
3334
from .types import PipelineStages
3435
from .types import PurgeRequest
3536
from .types import TLSSecretsConfig
@@ -115,6 +116,7 @@
115116
"TLSStage",
116117
"CheckPEMChainRequestSecretChain",
117118
"PlanDetails",
119+
"PlanUsageDetails",
118120
"PipelineStages",
119121
"PurgeRequest",
120122
"TLSSecretsConfig",

scaleway-async/scaleway_async/edge_services/v1alpha1/marshalling.py

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
CheckLbOriginResponse,
3030
CheckPEMChainResponse,
3131
PlanDetails,
32+
PlanUsageDetails,
3233
GetBillingResponse,
3334
ListBackendStagesResponse,
3435
ListCacheStagesResponse,
@@ -634,9 +635,30 @@ def unmarshal_PlanDetails(data: Any) -> PlanDetails:
634635
if field is not None:
635636
args["pipeline_limit"] = field
636637

638+
field = data.get("waf_requests", None)
639+
if field is not None:
640+
args["waf_requests"] = field
641+
637642
return PlanDetails(**args)
638643

639644

645+
def unmarshal_PlanUsageDetails(data: Any) -> PlanUsageDetails:
646+
if not isinstance(data, dict):
647+
raise TypeError(
648+
"Unmarshalling the type 'PlanUsageDetails' failed as data isn't a dictionary."
649+
)
650+
651+
args: Dict[str, Any] = {}
652+
653+
field = data.get("plan_cost", None)
654+
if field is not None:
655+
args["plan_cost"] = unmarshal_Money(field)
656+
else:
657+
args["plan_cost"] = None
658+
659+
return PlanUsageDetails(**args)
660+
661+
640662
def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse:
641663
if not isinstance(data, dict):
642664
raise TypeError(
@@ -645,6 +667,12 @@ def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse:
645667

646668
args: Dict[str, Any] = {}
647669

670+
field = data.get("current_plan", None)
671+
if field is not None:
672+
args["current_plan"] = unmarshal_PlanDetails(field)
673+
else:
674+
args["current_plan"] = None
675+
648676
field = data.get("pipeline_number", None)
649677
if field is not None:
650678
args["pipeline_number"] = field
@@ -657,11 +685,13 @@ def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse:
657685
if field is not None:
658686
args["extra_cache_usage"] = field
659687

660-
field = data.get("current_plan", None)
688+
field = data.get("current_plan_waf_usage", None)
661689
if field is not None:
662-
args["current_plan"] = unmarshal_PlanDetails(field)
663-
else:
664-
args["current_plan"] = None
690+
args["current_plan_waf_usage"] = field
691+
692+
field = data.get("extra_waf_usage", None)
693+
if field is not None:
694+
args["extra_waf_usage"] = field
665695

666696
field = data.get("plan_cost", None)
667697
if field is not None:
@@ -675,12 +705,32 @@ def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse:
675705
else:
676706
args["extra_pipelines_cost"] = None
677707

708+
field = data.get("plans_usage_details", None)
709+
if field is not None:
710+
args["plans_usage_details"] = (
711+
{key: unmarshal_PlanUsageDetails(value) for key, value in field.items()}
712+
if field is not None
713+
else None
714+
)
715+
678716
field = data.get("extra_cache_cost", None)
679717
if field is not None:
680718
args["extra_cache_cost"] = unmarshal_Money(field)
681719
else:
682720
args["extra_cache_cost"] = None
683721

722+
field = data.get("extra_waf_cost", None)
723+
if field is not None:
724+
args["extra_waf_cost"] = unmarshal_Money(field)
725+
else:
726+
args["extra_waf_cost"] = None
727+
728+
field = data.get("waf_add_on", None)
729+
if field is not None:
730+
args["waf_add_on"] = unmarshal_Money(field)
731+
else:
732+
args["waf_add_on"] = None
733+
684734
field = data.get("total_cost", None)
685735
if field is not None:
686736
args["total_cost"] = unmarshal_Money(field)

scaleway-async/scaleway_async/edge_services/v1alpha1/types.py

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dataclasses import dataclass
66
from datetime import datetime
77
from enum import Enum
8-
from typing import List, Optional
8+
from typing import Dict, List, Optional
99

1010
from scaleway_core.bridge import (
1111
Money,
@@ -502,6 +502,19 @@ class PlanDetails:
502502
Number of pipelines included in subscription plan.
503503
"""
504504

505+
waf_requests: int
506+
"""
507+
Number of WAF requests included in subscription plan.
508+
"""
509+
510+
511+
@dataclass
512+
class PlanUsageDetails:
513+
plan_cost: Optional[Money]
514+
"""
515+
Cost to date (this month) for the corresponding Edge Services subscription plan.
516+
"""
517+
505518

506519
@dataclass
507520
class PipelineStages:
@@ -758,6 +771,11 @@ class GetBillingRequest:
758771

759772
@dataclass
760773
class GetBillingResponse:
774+
current_plan: Optional[PlanDetails]
775+
"""
776+
Information on the currently-selected, active Edge Services subscription plan.
777+
"""
778+
761779
pipeline_number: int
762780
"""
763781
Total number of pipelines currently configured.
@@ -773,9 +791,14 @@ class GetBillingResponse:
773791
Total amount of extra data egressed from cache in gigabytes from the beginning of the month, not included in the subscription plans.
774792
"""
775793

776-
current_plan: Optional[PlanDetails]
794+
current_plan_waf_usage: int
777795
"""
778-
Information on the currently-selected, active Edge Services subscription plan.
796+
Total number of requests processed by the WAF since the beginning of the current month, for the active subscription plan.
797+
"""
798+
799+
extra_waf_usage: int
800+
"""
801+
Total number of extra requests processed by the WAF from the beginning of the month, not included in the subscription plans.
779802
"""
780803

781804
plan_cost: Optional[Money]
@@ -788,11 +811,26 @@ class GetBillingResponse:
788811
Cost to date (this month) of pipelines not included in the subscription plans.
789812
"""
790813

814+
plans_usage_details: Dict[str, PlanUsageDetails]
815+
"""
816+
Detailed costs and usage for all Edge Services subscription plans that were activated during the month.
817+
"""
818+
791819
extra_cache_cost: Optional[Money]
792820
"""
793821
Cost to date (this month) of the data egressed from the cache that is not included in the subscription plans.
794822
"""
795823

824+
extra_waf_cost: Optional[Money]
825+
"""
826+
Cost to date (this month) of the extra requests processed by the WAF that were not included in the subscription plans.
827+
"""
828+
829+
waf_add_on: Optional[Money]
830+
"""
831+
Cost of activating WAF add-on (where subscription plan does not include WAF).
832+
"""
833+
796834
total_cost: Optional[Money]
797835
"""
798836
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.

scaleway/scaleway/edge_services/v1alpha1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from .types import TLSStage
3131
from .types import CheckPEMChainRequestSecretChain
3232
from .types import PlanDetails
33+
from .types import PlanUsageDetails
3334
from .types import PipelineStages
3435
from .types import PurgeRequest
3536
from .types import TLSSecretsConfig
@@ -115,6 +116,7 @@
115116
"TLSStage",
116117
"CheckPEMChainRequestSecretChain",
117118
"PlanDetails",
119+
"PlanUsageDetails",
118120
"PipelineStages",
119121
"PurgeRequest",
120122
"TLSSecretsConfig",

scaleway/scaleway/edge_services/v1alpha1/marshalling.py

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
CheckLbOriginResponse,
3030
CheckPEMChainResponse,
3131
PlanDetails,
32+
PlanUsageDetails,
3233
GetBillingResponse,
3334
ListBackendStagesResponse,
3435
ListCacheStagesResponse,
@@ -634,9 +635,30 @@ def unmarshal_PlanDetails(data: Any) -> PlanDetails:
634635
if field is not None:
635636
args["pipeline_limit"] = field
636637

638+
field = data.get("waf_requests", None)
639+
if field is not None:
640+
args["waf_requests"] = field
641+
637642
return PlanDetails(**args)
638643

639644

645+
def unmarshal_PlanUsageDetails(data: Any) -> PlanUsageDetails:
646+
if not isinstance(data, dict):
647+
raise TypeError(
648+
"Unmarshalling the type 'PlanUsageDetails' failed as data isn't a dictionary."
649+
)
650+
651+
args: Dict[str, Any] = {}
652+
653+
field = data.get("plan_cost", None)
654+
if field is not None:
655+
args["plan_cost"] = unmarshal_Money(field)
656+
else:
657+
args["plan_cost"] = None
658+
659+
return PlanUsageDetails(**args)
660+
661+
640662
def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse:
641663
if not isinstance(data, dict):
642664
raise TypeError(
@@ -645,6 +667,12 @@ def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse:
645667

646668
args: Dict[str, Any] = {}
647669

670+
field = data.get("current_plan", None)
671+
if field is not None:
672+
args["current_plan"] = unmarshal_PlanDetails(field)
673+
else:
674+
args["current_plan"] = None
675+
648676
field = data.get("pipeline_number", None)
649677
if field is not None:
650678
args["pipeline_number"] = field
@@ -657,11 +685,13 @@ def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse:
657685
if field is not None:
658686
args["extra_cache_usage"] = field
659687

660-
field = data.get("current_plan", None)
688+
field = data.get("current_plan_waf_usage", None)
661689
if field is not None:
662-
args["current_plan"] = unmarshal_PlanDetails(field)
663-
else:
664-
args["current_plan"] = None
690+
args["current_plan_waf_usage"] = field
691+
692+
field = data.get("extra_waf_usage", None)
693+
if field is not None:
694+
args["extra_waf_usage"] = field
665695

666696
field = data.get("plan_cost", None)
667697
if field is not None:
@@ -675,12 +705,32 @@ def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse:
675705
else:
676706
args["extra_pipelines_cost"] = None
677707

708+
field = data.get("plans_usage_details", None)
709+
if field is not None:
710+
args["plans_usage_details"] = (
711+
{key: unmarshal_PlanUsageDetails(value) for key, value in field.items()}
712+
if field is not None
713+
else None
714+
)
715+
678716
field = data.get("extra_cache_cost", None)
679717
if field is not None:
680718
args["extra_cache_cost"] = unmarshal_Money(field)
681719
else:
682720
args["extra_cache_cost"] = None
683721

722+
field = data.get("extra_waf_cost", None)
723+
if field is not None:
724+
args["extra_waf_cost"] = unmarshal_Money(field)
725+
else:
726+
args["extra_waf_cost"] = None
727+
728+
field = data.get("waf_add_on", None)
729+
if field is not None:
730+
args["waf_add_on"] = unmarshal_Money(field)
731+
else:
732+
args["waf_add_on"] = None
733+
684734
field = data.get("total_cost", None)
685735
if field is not None:
686736
args["total_cost"] = unmarshal_Money(field)

0 commit comments

Comments
 (0)