Skip to content

Commit 3d425c1

Browse files
authored
feat(edge_services): add GetCurrentBilling endpoint (scaleway#2242)
1 parent db8df6f commit 3d425c1

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

api/edge_services/v1alpha1/edge_services_sdk.go

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,11 +924,14 @@ type CheckPEMChainRequestSecretChain struct {
924924

925925
// PlanDetails: plan details.
926926
type PlanDetails struct {
927-
// PlanName: default value: unknown_name
927+
// PlanName: subscription plan name.
928+
// Default value: unknown_name
928929
PlanName PlanName `json:"plan_name"`
929930

931+
// PackageGb: amount of egress data from cache included in subscription plan.
930932
PackageGb uint64 `json:"package_gb"`
931933

934+
// PipelineLimit: number of pipeline included in subscription plan.
932935
PipelineLimit uint32 `json:"pipeline_limit"`
933936
}
934937

@@ -1149,6 +1152,38 @@ type GetBackendStageRequest struct {
11491152
BackendStageID string `json:"-"`
11501153
}
11511154

1155+
// GetBillingRequest: get billing request.
1156+
type GetBillingRequest struct {
1157+
ProjectID string `json:"-"`
1158+
}
1159+
1160+
// GetBillingResponse: get billing response.
1161+
type GetBillingResponse struct {
1162+
// CurrentPlan: information on the current edge-service subscription plan.
1163+
CurrentPlan *PlanDetails `json:"current_plan"`
1164+
1165+
// PlanCost: price of the current subscription plan.
1166+
PlanCost *scw.Money `json:"plan_cost"`
1167+
1168+
// PipelineNumber: total number of pipeline currently configured.
1169+
PipelineNumber uint32 `json:"pipeline_number"`
1170+
1171+
// ExtraPipelinesCost: cost to date of the pipelines not included in the plans.
1172+
ExtraPipelinesCost *scw.Money `json:"extra_pipelines_cost"`
1173+
1174+
// CurrentPlanCacheUsage: total amount of data egressed from cache in current subscription plan.
1175+
CurrentPlanCacheUsage uint64 `json:"current_plan_cache_usage"`
1176+
1177+
// ExtraCacheUsage: total amount of data egressed from cache not included in the plans.
1178+
ExtraCacheUsage uint64 `json:"extra_cache_usage"`
1179+
1180+
// ExtraCacheCost: cost to date of the data egressed from cache not included in the plans.
1181+
ExtraCacheCost *scw.Money `json:"extra_cache_cost"`
1182+
1183+
// TotalCost: total cost to date of edge-service product for the month including current plan, previous plans, extra pipelines and extra egress cache data.
1184+
TotalCost *scw.Money `json:"total_cost"`
1185+
}
1186+
11521187
// GetCacheStageRequest: get cache stage request.
11531188
type GetCacheStageRequest struct {
11541189
// CacheStageID: ID of the requested cache stage.
@@ -2529,3 +2564,30 @@ func (s *API) DeleteCurrentPlan(req *DeleteCurrentPlanRequest, opts ...scw.Reque
25292564
}
25302565
return nil
25312566
}
2567+
2568+
// GetBilling: Gives information on current edge-services subscription plan and used resources with associated price.
2569+
func (s *API) GetBilling(req *GetBillingRequest, opts ...scw.RequestOption) (*GetBillingResponse, error) {
2570+
var err error
2571+
2572+
if req.ProjectID == "" {
2573+
defaultProjectID, _ := s.client.GetDefaultProjectID()
2574+
req.ProjectID = defaultProjectID
2575+
}
2576+
2577+
if fmt.Sprint(req.ProjectID) == "" {
2578+
return nil, errors.New("field ProjectID cannot be empty in request")
2579+
}
2580+
2581+
scwReq := &scw.ScalewayRequest{
2582+
Method: "GET",
2583+
Path: "/edge-services/v1alpha1/billing/" + fmt.Sprint(req.ProjectID) + "",
2584+
}
2585+
2586+
var resp GetBillingResponse
2587+
2588+
err = s.client.Do(scwReq, &resp, opts...)
2589+
if err != nil {
2590+
return nil, err
2591+
}
2592+
return &resp, nil
2593+
}

0 commit comments

Comments
 (0)