Skip to content

feat(edge_services): add WAF billing #855

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 2 commits into from
Feb 13, 2025
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 @@ -30,6 +30,7 @@
from .types import TLSStage
from .types import CheckPEMChainRequestSecretChain
from .types import PlanDetails
from .types import PlanUsageDetails
from .types import PipelineStages
from .types import PurgeRequest
from .types import TLSSecretsConfig
Expand Down Expand Up @@ -115,6 +116,7 @@
"TLSStage",
"CheckPEMChainRequestSecretChain",
"PlanDetails",
"PlanUsageDetails",
"PipelineStages",
"PurgeRequest",
"TLSSecretsConfig",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
CheckLbOriginResponse,
CheckPEMChainResponse,
PlanDetails,
PlanUsageDetails,
GetBillingResponse,
ListBackendStagesResponse,
ListCacheStagesResponse,
Expand Down Expand Up @@ -634,9 +635,30 @@ def unmarshal_PlanDetails(data: Any) -> PlanDetails:
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(
Expand All @@ -645,6 +667,12 @@ def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse:

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
Expand All @@ -657,11 +685,13 @@ def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse:
if field is not None:
args["extra_cache_usage"] = field

field = data.get("current_plan", None)
field = data.get("current_plan_waf_usage", None)
if field is not None:
args["current_plan"] = unmarshal_PlanDetails(field)
else:
args["current_plan"] = 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:
Expand All @@ -675,12 +705,32 @@ def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse:
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)
Expand Down
44 changes: 41 additions & 3 deletions scaleway-async/scaleway_async/edge_services/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass
from datetime import datetime
from enum import Enum
from typing import List, Optional
from typing import Dict, List, Optional

from scaleway_core.bridge import (
Money,
Expand Down Expand Up @@ -502,6 +502,19 @@ class PlanDetails:
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 PipelineStages:
Expand Down Expand Up @@ -758,6 +771,11 @@ class GetBillingRequest:

@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.
Expand All @@ -773,9 +791,14 @@ class GetBillingResponse:
Total amount of extra data egressed from cache in gigabytes from the beginning of the month, not included in the subscription plans.
"""

current_plan: Optional[PlanDetails]
current_plan_waf_usage: int
"""
Information on the currently-selected, active Edge Services subscription plan.
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]
Expand All @@ -788,11 +811,26 @@ class GetBillingResponse:
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.
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/edge_services/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from .types import TLSStage
from .types import CheckPEMChainRequestSecretChain
from .types import PlanDetails
from .types import PlanUsageDetails
from .types import PipelineStages
from .types import PurgeRequest
from .types import TLSSecretsConfig
Expand Down Expand Up @@ -115,6 +116,7 @@
"TLSStage",
"CheckPEMChainRequestSecretChain",
"PlanDetails",
"PlanUsageDetails",
"PipelineStages",
"PurgeRequest",
"TLSSecretsConfig",
Expand Down
58 changes: 54 additions & 4 deletions scaleway/scaleway/edge_services/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
CheckLbOriginResponse,
CheckPEMChainResponse,
PlanDetails,
PlanUsageDetails,
GetBillingResponse,
ListBackendStagesResponse,
ListCacheStagesResponse,
Expand Down Expand Up @@ -634,9 +635,30 @@ def unmarshal_PlanDetails(data: Any) -> PlanDetails:
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(
Expand All @@ -645,6 +667,12 @@ def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse:

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
Expand All @@ -657,11 +685,13 @@ def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse:
if field is not None:
args["extra_cache_usage"] = field

field = data.get("current_plan", None)
field = data.get("current_plan_waf_usage", None)
if field is not None:
args["current_plan"] = unmarshal_PlanDetails(field)
else:
args["current_plan"] = 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:
Expand All @@ -675,12 +705,32 @@ def unmarshal_GetBillingResponse(data: Any) -> GetBillingResponse:
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)
Expand Down
Loading