Skip to content

Commit 49f49fb

Browse files
authored
Merge branch 'main' into v1.5561.0
2 parents e3427aa + 666c9dc commit 49f49fb

File tree

3 files changed

+92
-15
lines changed

3 files changed

+92
-15
lines changed

packages/clients/src/api/edge_services/v1alpha1/api.gen.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
unmarshalCheckLbOriginResponse,
3535
unmarshalCheckPEMChainResponse,
3636
unmarshalDNSStage,
37+
unmarshalGetBillingResponse,
3738
unmarshalListBackendStagesResponse,
3839
unmarshalListCacheStagesResponse,
3940
unmarshalListDNSStagesResponse,
@@ -69,6 +70,8 @@ import type {
6970
DeletePipelineRequest,
7071
DeleteTLSStageRequest,
7172
GetBackendStageRequest,
73+
GetBillingRequest,
74+
GetBillingResponse,
7275
GetCacheStageRequest,
7376
GetCurrentPlanRequest,
7477
GetDNSStageRequest,
@@ -826,4 +829,20 @@ export class API extends ParentAPI {
826829
method: 'DELETE',
827830
path: `/edge-services/v1alpha1/current-plan/${validatePathParam('projectId', request.projectId ?? this.client.settings.defaultProjectId)}`,
828831
})
832+
833+
/**
834+
* Gives information on current edge-services subscription plan and used
835+
* resources with associated price.
836+
*
837+
* @param request - The request {@link GetBillingRequest}
838+
* @returns A Promise of GetBillingResponse
839+
*/
840+
getBilling = (request: Readonly<GetBillingRequest> = {}) =>
841+
this.client.fetch<GetBillingResponse>(
842+
{
843+
method: 'GET',
844+
path: `/edge-services/v1alpha1/billing/${validatePathParam('projectId', request.projectId ?? this.client.settings.defaultProjectId)}`,
845+
},
846+
unmarshalGetBillingResponse,
847+
)
829848
}

packages/clients/src/api/edge_services/v1alpha1/marshalling.gen.ts

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
resolveOneOf,
66
unmarshalArrayOfObject,
77
unmarshalDate,
8+
unmarshalMoney,
89
} from '../../../bridge'
910
import type { DefaultValues } from '../../../bridge'
1011
import type {
@@ -24,6 +25,7 @@ import type {
2425
CreatePurgeRequestRequest,
2526
CreateTLSStageRequest,
2627
DNSStage,
28+
GetBillingResponse,
2729
ListBackendStagesResponse,
2830
ListCacheStagesResponse,
2931
ListDNSStagesResponse,
@@ -288,6 +290,47 @@ export const unmarshalCheckPEMChainResponse = (
288290
} as CheckPEMChainResponse
289291
}
290292

293+
const unmarshalPlanDetails = (data: unknown): PlanDetails => {
294+
if (!isJSONObject(data)) {
295+
throw new TypeError(
296+
`Unmarshalling the type 'PlanDetails' failed as data isn't a dictionary.`,
297+
)
298+
}
299+
300+
return {
301+
packageGb: data.package_gb,
302+
pipelineLimit: data.pipeline_limit,
303+
planName: data.plan_name,
304+
} as PlanDetails
305+
}
306+
307+
export const unmarshalGetBillingResponse = (
308+
data: unknown,
309+
): GetBillingResponse => {
310+
if (!isJSONObject(data)) {
311+
throw new TypeError(
312+
`Unmarshalling the type 'GetBillingResponse' failed as data isn't a dictionary.`,
313+
)
314+
}
315+
316+
return {
317+
currentPlan: data.current_plan
318+
? unmarshalPlanDetails(data.current_plan)
319+
: undefined,
320+
currentPlanCacheUsage: data.current_plan_cache_usage,
321+
extraCacheCost: data.extra_cache_cost
322+
? unmarshalMoney(data.extra_cache_cost)
323+
: undefined,
324+
extraCacheUsage: data.extra_cache_usage,
325+
extraPipelinesCost: data.extra_pipelines_cost
326+
? unmarshalMoney(data.extra_pipelines_cost)
327+
: undefined,
328+
pipelineNumber: data.pipeline_number,
329+
planCost: data.plan_cost ? unmarshalMoney(data.plan_cost) : undefined,
330+
totalCost: data.total_cost ? unmarshalMoney(data.total_cost) : undefined,
331+
} as GetBillingResponse
332+
}
333+
291334
export const unmarshalListBackendStagesResponse = (
292335
data: unknown,
293336
): ListBackendStagesResponse => {
@@ -348,20 +391,6 @@ export const unmarshalListPipelinesResponse = (
348391
} as ListPipelinesResponse
349392
}
350393

351-
const unmarshalPlanDetails = (data: unknown): PlanDetails => {
352-
if (!isJSONObject(data)) {
353-
throw new TypeError(
354-
`Unmarshalling the type 'PlanDetails' failed as data isn't a dictionary.`,
355-
)
356-
}
357-
358-
return {
359-
packageGb: data.package_gb,
360-
pipelineLimit: data.pipeline_limit,
361-
planName: data.plan_name,
362-
} as PlanDetails
363-
}
364-
365394
export const unmarshalListPlansResponse = (
366395
data: unknown,
367396
): ListPlansResponse => {

packages/clients/src/api/edge_services/v1alpha1/types.gen.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file was automatically generated. DO NOT EDIT.
22
// If you have any remark or suggestion do not hesitate to open an issue.
3-
import type { Region, Zone } from '../../../bridge'
3+
import type { Money, Region, Zone } from '../../../bridge'
44

55
export type DNSStageType = 'unknown_type' | 'auto' | 'managed' | 'custom'
66

@@ -279,8 +279,11 @@ export interface CheckPEMChainRequestSecretChain {
279279
}
280280

281281
export interface PlanDetails {
282+
/** Subscription plan name. */
282283
planName: PlanName
284+
/** Amount of egress data from cache included in subscription plan. */
283285
packageGb: number
286+
/** Number of pipeline included in subscription plan. */
284287
pipelineLimit: number
285288
}
286289

@@ -501,6 +504,32 @@ export type GetBackendStageRequest = {
501504
backendStageId: string
502505
}
503506

507+
export type GetBillingRequest = {
508+
projectId?: string
509+
}
510+
511+
export interface GetBillingResponse {
512+
/** Information on the current edge-service subscription plan. */
513+
currentPlan?: PlanDetails
514+
/** Price of the current subscription plan. */
515+
planCost?: Money
516+
/** Total number of pipeline currently configured. */
517+
pipelineNumber: number
518+
/** Cost to date of the pipelines not included in the plans. */
519+
extraPipelinesCost?: Money
520+
/** Total amount of data egressed from cache in current subscription plan. */
521+
currentPlanCacheUsage: number
522+
/** Total amount of data egressed from cache not included in the plans. */
523+
extraCacheUsage: number
524+
/** Cost to date of the data egressed from cache not included in the plans. */
525+
extraCacheCost?: Money
526+
/**
527+
* Total cost to date of edge-service product for the month including current
528+
* plan, previous plans, extra pipelines and extra egress cache data.
529+
*/
530+
totalCost?: Money
531+
}
532+
504533
export type GetCacheStageRequest = {
505534
/** ID of the requested cache stage. */
506535
cacheStageId: string

0 commit comments

Comments
 (0)