Skip to content
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 @@ -69,6 +69,7 @@ export type {
Plan,
PlanDetails,
PlanName,
PlanUsageDetails,
PurgeRequest,
PurgeRequestStatus,
ScalewayLb,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
resolveOneOf,
unmarshalArrayOfObject,
unmarshalDate,
unmarshalMapOfObject,
unmarshalMoney,
} from '../../../bridge'
import type { DefaultValues } from '../../../bridge'
Expand Down Expand Up @@ -39,6 +40,7 @@ import type {
PipelineStages,
Plan,
PlanDetails,
PlanUsageDetails,
PurgeRequest,
ScalewayLb,
ScalewayLbBackendConfig,
Expand Down Expand Up @@ -323,9 +325,22 @@ const unmarshalPlanDetails = (data: unknown): PlanDetails => {
packageGb: data.package_gb,
pipelineLimit: data.pipeline_limit,
planName: data.plan_name,
wafRequests: data.waf_requests,
} as PlanDetails
}

const unmarshalPlanUsageDetails = (data: unknown): PlanUsageDetails => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'PlanUsageDetails' failed as data isn't a dictionary.`,
)
}

return {
planCost: data.plan_cost ? unmarshalMoney(data.plan_cost) : undefined,
} as PlanUsageDetails
}

export const unmarshalGetBillingResponse = (
data: unknown,
): GetBillingResponse => {
Expand All @@ -340,16 +355,26 @@ export const unmarshalGetBillingResponse = (
? unmarshalPlanDetails(data.current_plan)
: undefined,
currentPlanCacheUsage: data.current_plan_cache_usage,
currentPlanWafUsage: data.current_plan_waf_usage,
extraCacheCost: data.extra_cache_cost
? unmarshalMoney(data.extra_cache_cost)
: undefined,
extraCacheUsage: data.extra_cache_usage,
extraPipelinesCost: data.extra_pipelines_cost
? unmarshalMoney(data.extra_pipelines_cost)
: undefined,
extraWafCost: data.extra_waf_cost
? unmarshalMoney(data.extra_waf_cost)
: undefined,
extraWafUsage: data.extra_waf_usage,
pipelineNumber: data.pipeline_number,
planCost: data.plan_cost ? unmarshalMoney(data.plan_cost) : undefined,
plansUsageDetails: unmarshalMapOfObject(
data.plans_usage_details,
unmarshalPlanUsageDetails,
),
totalCost: data.total_cost ? unmarshalMoney(data.total_cost) : undefined,
wafAddOn: data.waf_add_on ? unmarshalMoney(data.waf_add_on) : undefined,
} as GetBillingResponse
}

Expand Down
35 changes: 35 additions & 0 deletions packages/clients/src/api/edge_services/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,16 @@ export interface PlanDetails {
packageGb: number
/** Number of pipelines included in subscription plan. */
pipelineLimit: number
/** Number of WAF requests included in subscription plan. */
wafRequests: number
}

export interface PlanUsageDetails {
/**
* Cost to date (this month) for the corresponding Edge Services subscription
* plan.
*/
planCost?: Money
}

export interface PipelineStages {
Expand Down Expand Up @@ -562,6 +572,31 @@ export interface GetBillingResponse {
* included in the subscription plans.
*/
extraCacheCost?: Money
/**
* Total number of requests processed by the WAF since the beginning of the
* current month, for the active subscription plan.
*/
currentPlanWafUsage: number
/**
* Total number of extra requests processed by the WAF from the beginning of
* the month, not included in the subscription plans.
*/
extraWafUsage: number
/**
* Cost to date (this month) of the extra requests processed by the WAF that
* were not included in the subscription plans.
*/
extraWafCost?: Money
/**
* Cost of activating WAF add-on (where subscription plan does not include
* WAF).
*/
wafAddOn?: Money
/**
* Detailed costs and usage for all Edge Services subscription plans that were
* activated during the month.
*/
plansUsageDetails: Record<string, PlanUsageDetails>
/**
* Total cost to date (this month) of all Edge Services resources including
* active subscription plan, previously active plans, extra pipelines and
Expand Down
Loading