3939 _ = namegenerator .GetRandomName
4040)
4141
42+ type DiscountDiscountMode string
43+
44+ const (
45+ // Unknown discount mode.
46+ DiscountDiscountModeUnknownDiscountMode = DiscountDiscountMode ("unknown_discount_mode" )
47+ // A rate discount that reduces each customer bill by the discount value percentage.
48+ DiscountDiscountModeDiscountModeRate = DiscountDiscountMode ("discount_mode_rate" )
49+ // A value discount that reduces the amount of the customer bill by the discount value.
50+ DiscountDiscountModeDiscountModeValue = DiscountDiscountMode ("discount_mode_value" )
51+ // A fixed sum to be deducted from the user's bills.
52+ DiscountDiscountModeDiscountModeSplittable = DiscountDiscountMode ("discount_mode_splittable" )
53+ )
54+
55+ func (enum DiscountDiscountMode ) String () string {
56+ if enum == "" {
57+ // return default value if empty
58+ return "unknown_discount_mode"
59+ }
60+ return string (enum )
61+ }
62+
63+ func (enum DiscountDiscountMode ) MarshalJSON () ([]byte , error ) {
64+ return []byte (fmt .Sprintf (`"%s"` , enum )), nil
65+ }
66+
67+ func (enum * DiscountDiscountMode ) UnmarshalJSON (data []byte ) error {
68+ tmp := ""
69+
70+ if err := json .Unmarshal (data , & tmp ); err != nil {
71+ return err
72+ }
73+
74+ * enum = DiscountDiscountMode (DiscountDiscountMode (tmp ).String ())
75+ return nil
76+ }
77+
78+ type DiscountFilterType string
79+
80+ const (
81+ // Unknown filter type.
82+ DiscountFilterTypeUnknownType = DiscountFilterType ("unknown_type" )
83+ // Product category, such as Compute, Network, Observability.
84+ DiscountFilterTypeCategoryName = DiscountFilterType ("category_name" )
85+ // Products within the Product category. For example, VPC, Private Networks, and Public Gateways are products in the Network category.
86+ DiscountFilterTypeProductName = DiscountFilterType ("product_name" )
87+ // The range of a product. For example, `Production Optimized` or `Cost Optimized` for an `instance` product of the `compute` category.
88+ DiscountFilterTypeProductRange = DiscountFilterType ("product_range" )
89+ // Identifies the reference based on category, product, range, size, region, and zone. It can sometimes include different product options, such as licenses and monthly payments.
90+ DiscountFilterTypeResourceName = DiscountFilterType ("resource_name" )
91+ // Region name like "FR-PAR", "NL-AMS", "PL-WAW".
92+ DiscountFilterTypeRegion = DiscountFilterType ("region" )
93+ // Zone name like "FR-PAR-1", "FR-PAR-2", "FR-PAR-3".
94+ DiscountFilterTypeZone = DiscountFilterType ("zone" )
95+ )
96+
97+ func (enum DiscountFilterType ) String () string {
98+ if enum == "" {
99+ // return default value if empty
100+ return "unknown_type"
101+ }
102+ return string (enum )
103+ }
104+
105+ func (enum DiscountFilterType ) MarshalJSON () ([]byte , error ) {
106+ return []byte (fmt .Sprintf (`"%s"` , enum )), nil
107+ }
108+
109+ func (enum * DiscountFilterType ) UnmarshalJSON (data []byte ) error {
110+ tmp := ""
111+
112+ if err := json .Unmarshal (data , & tmp ); err != nil {
113+ return err
114+ }
115+
116+ * enum = DiscountFilterType (DiscountFilterType (tmp ).String ())
117+ return nil
118+ }
119+
42120type DownloadInvoiceRequestFileType string
43121
44122const (
@@ -174,9 +252,9 @@ type ListConsumptionsRequestOrderBy string
174252
175253const (
176254 // Order consumptions by update date (descending chronological order).
177- ListConsumptionsRequestOrderByUpdatedAtDateDesc = ListConsumptionsRequestOrderBy ("updated_at_date_desc " )
255+ ListConsumptionsRequestOrderByUpdatedAtDesc = ListConsumptionsRequestOrderBy ("updated_at_desc " )
178256 // Order consumptions by update date (ascending chronological order).
179- ListConsumptionsRequestOrderByUpdatedAtDateAsc = ListConsumptionsRequestOrderBy ("updated_at_date_asc " )
257+ ListConsumptionsRequestOrderByUpdatedAtAsc = ListConsumptionsRequestOrderBy ("updated_at_asc " )
180258 // Order consumptions by category name (descending alphabetical order).
181259 ListConsumptionsRequestOrderByCategoryNameDesc = ListConsumptionsRequestOrderBy ("category_name_desc" )
182260 // Order consumptions by category name (ascending alphabetical order).
@@ -186,7 +264,7 @@ const (
186264func (enum ListConsumptionsRequestOrderBy ) String () string {
187265 if enum == "" {
188266 // return default value if empty
189- return "updated_at_date_desc "
267+ return "updated_at_desc "
190268 }
191269 return string (enum )
192270}
@@ -206,6 +284,38 @@ func (enum *ListConsumptionsRequestOrderBy) UnmarshalJSON(data []byte) error {
206284 return nil
207285}
208286
287+ type ListDiscountsRequestOrderBy string
288+
289+ const (
290+ // Order discounts by creation date (descending chronological order).
291+ ListDiscountsRequestOrderByCreationDateDesc = ListDiscountsRequestOrderBy ("creation_date_desc" )
292+ // Order discounts by creation date (ascending chronological order).
293+ ListDiscountsRequestOrderByCreationDateAsc = ListDiscountsRequestOrderBy ("creation_date_asc" )
294+ )
295+
296+ func (enum ListDiscountsRequestOrderBy ) String () string {
297+ if enum == "" {
298+ // return default value if empty
299+ return "creation_date_desc"
300+ }
301+ return string (enum )
302+ }
303+
304+ func (enum ListDiscountsRequestOrderBy ) MarshalJSON () ([]byte , error ) {
305+ return []byte (fmt .Sprintf (`"%s"` , enum )), nil
306+ }
307+
308+ func (enum * ListDiscountsRequestOrderBy ) UnmarshalJSON (data []byte ) error {
309+ tmp := ""
310+
311+ if err := json .Unmarshal (data , & tmp ); err != nil {
312+ return err
313+ }
314+
315+ * enum = ListDiscountsRequestOrderBy (ListDiscountsRequestOrderBy (tmp ).String ())
316+ return nil
317+ }
318+
209319type ListInvoicesRequestOrderBy string
210320
211321const (
@@ -252,9 +362,9 @@ type ListTaxesRequestOrderBy string
252362
253363const (
254364 // Order consumptions by update date (descending chronological order).
255- ListTaxesRequestOrderByUpdatedAtDateDesc = ListTaxesRequestOrderBy ("updated_at_date_desc " )
365+ ListTaxesRequestOrderByUpdatedAtDesc = ListTaxesRequestOrderBy ("updated_at_desc " )
256366 // Order consumptions by update date (ascending chronological order).
257- ListTaxesRequestOrderByUpdatedAtDateAsc = ListTaxesRequestOrderBy ("updated_at_date_asc " )
367+ ListTaxesRequestOrderByUpdatedAtAsc = ListTaxesRequestOrderBy ("updated_at_asc " )
258368 // Order consumptions by category name (descending alphabetical order).
259369 ListTaxesRequestOrderByCategoryNameDesc = ListTaxesRequestOrderBy ("category_name_desc" )
260370 // Order consumptions by category name (ascending alphabetical order).
@@ -264,7 +374,7 @@ const (
264374func (enum ListTaxesRequestOrderBy ) String () string {
265375 if enum == "" {
266376 // return default value if empty
267- return "updated_at_date_desc "
377+ return "updated_at_desc "
268378 }
269379 return string (enum )
270380}
@@ -284,6 +394,22 @@ func (enum *ListTaxesRequestOrderBy) UnmarshalJSON(data []byte) error {
284394 return nil
285395}
286396
397+ // DiscountCoupon: discount coupon.
398+ type DiscountCoupon struct {
399+ // Description: the description of the coupon.
400+ Description * string `json:"description"`
401+ }
402+
403+ // DiscountFilter: discount filter.
404+ type DiscountFilter struct {
405+ // Type: type of the filter (category name, product name, product range, resource name, region or zone).
406+ // Default value: unknown_type
407+ Type DiscountFilterType `json:"type"`
408+
409+ // Value: value of filter.
410+ Value string `json:"value"`
411+ }
412+
287413// ListConsumptionsResponseConsumption: list consumptions response consumption.
288414type ListConsumptionsResponseConsumption struct {
289415 // Value: monetary value of the consumption.
@@ -303,6 +429,52 @@ type ListConsumptionsResponseConsumption struct {
303429
304430 // CategoryName: name of consumption category.
305431 CategoryName string `json:"category_name"`
432+
433+ // Unit: unit of consumed quantity.
434+ Unit string `json:"unit"`
435+
436+ // BilledQuantity: consumed quantity.
437+ BilledQuantity string `json:"billed_quantity"`
438+ }
439+
440+ // Discount: discount.
441+ type Discount struct {
442+ // ID: the ID of the discount.
443+ ID string `json:"id"`
444+
445+ // CreationDate: the creation date of the discount.
446+ CreationDate * time.Time `json:"creation_date"`
447+
448+ // OrganizationID: the organization ID of the discount.
449+ OrganizationID string `json:"organization_id"`
450+
451+ // Description: the description of the discount.
452+ Description string `json:"description"`
453+
454+ // Value: the initial value of the discount.
455+ Value float64 `json:"value"`
456+
457+ // ValueUsed: the value indicating how much of the discount has been used.
458+ ValueUsed float64 `json:"value_used"`
459+
460+ // ValueRemaining: the remaining value of the discount.
461+ ValueRemaining float64 `json:"value_remaining"`
462+
463+ // Mode: the mode of the discount.
464+ // Default value: unknown_discount_mode
465+ Mode DiscountDiscountMode `json:"mode"`
466+
467+ // StartDate: the start date of the discount.
468+ StartDate * time.Time `json:"start_date"`
469+
470+ // StopDate: the stop date of the discount.
471+ StopDate * time.Time `json:"stop_date"`
472+
473+ // Coupon: the description of the coupon.
474+ Coupon * DiscountCoupon `json:"coupon"`
475+
476+ // Filters: list of the discount scopes.
477+ Filters []* DiscountFilter `json:"filters"`
306478}
307479
308480// Invoice: invoice.
@@ -353,10 +525,8 @@ type Invoice struct {
353525 // Number: invoice number.
354526 Number int32 `json:"number"`
355527
528+ // SellerName: the name of the seller (Scaleway).
356529 SellerName string `json:"seller_name"`
357-
358- // CustomerName: customer name associated to this organization.
359- CustomerName string `json:"customer_name"`
360530}
361531
362532// ListTaxesResponseTax: list taxes response tax.
@@ -423,7 +593,7 @@ type GetInvoiceRequest struct {
423593// ListConsumptionsRequest: list consumptions request.
424594type ListConsumptionsRequest struct {
425595 // OrderBy: order consumptions list in the response by their update date.
426- // Default value: updated_at_date_desc
596+ // Default value: updated_at_desc
427597 OrderBy ListConsumptionsRequestOrderBy `json:"-"`
428598
429599 // Page: positive integer to choose the page to return.
@@ -481,6 +651,50 @@ func (r *ListConsumptionsResponse) UnsafeAppend(res interface{}) (uint64, error)
481651 return uint64 (len (results .Consumptions )), nil
482652}
483653
654+ // ListDiscountsRequest: list discounts request.
655+ type ListDiscountsRequest struct {
656+ // OrderBy: order discounts in the response by their description.
657+ // Default value: creation_date_desc
658+ OrderBy ListDiscountsRequestOrderBy `json:"-"`
659+
660+ // Page: positive integer to choose the page to return.
661+ Page * int32 `json:"-"`
662+
663+ // PageSize: positive integer lower or equal to 100 to select the number of items to return.
664+ PageSize * uint32 `json:"-"`
665+
666+ // OrganizationID: ID of the organization.
667+ OrganizationID * string `json:"-"`
668+ }
669+
670+ // ListDiscountsResponse: list discounts response.
671+ type ListDiscountsResponse struct {
672+ // TotalCount: total number of discounts.
673+ TotalCount uint64 `json:"total_count"`
674+
675+ // Discounts: paginated returned discounts.
676+ Discounts []* Discount `json:"discounts"`
677+ }
678+
679+ // UnsafeGetTotalCount should not be used
680+ // Internal usage only
681+ func (r * ListDiscountsResponse ) UnsafeGetTotalCount () uint64 {
682+ return r .TotalCount
683+ }
684+
685+ // UnsafeAppend should not be used
686+ // Internal usage only
687+ func (r * ListDiscountsResponse ) UnsafeAppend (res interface {}) (uint64 , error ) {
688+ results , ok := res .(* ListDiscountsResponse )
689+ if ! ok {
690+ return 0 , errors .New ("%T type cannot be appended to type %T" , res , r )
691+ }
692+
693+ r .Discounts = append (r .Discounts , results .Discounts ... )
694+ r .TotalCount += uint64 (len (results .Discounts ))
695+ return uint64 (len (results .Discounts )), nil
696+ }
697+
484698// ListInvoicesRequest: list invoices request.
485699type ListInvoicesRequest struct {
486700 // OrganizationID: organization ID. If specified, only invoices from this Organization will be returned.
@@ -538,7 +752,7 @@ func (r *ListInvoicesResponse) UnsafeAppend(res interface{}) (uint64, error) {
538752// ListTaxesRequest: list taxes request.
539753type ListTaxesRequest struct {
540754 // OrderBy: order consumed taxes list in the response by their update date.
541- // Default value: updated_at_date_desc
755+ // Default value: updated_at_desc
542756 OrderBy ListTaxesRequestOrderBy `json:"-"`
543757
544758 // Page: page number.
@@ -790,3 +1004,33 @@ func (s *API) DownloadInvoice(req *DownloadInvoiceRequest, opts ...scw.RequestOp
7901004 }
7911005 return & resp , nil
7921006}
1007+
1008+ // ListDiscounts:
1009+ func (s * API ) ListDiscounts (req * ListDiscountsRequest , opts ... scw.RequestOption ) (* ListDiscountsResponse , error ) {
1010+ var err error
1011+
1012+ defaultPageSize , exist := s .client .GetDefaultPageSize ()
1013+ if (req .PageSize == nil || * req .PageSize == 0 ) && exist {
1014+ req .PageSize = & defaultPageSize
1015+ }
1016+
1017+ query := url.Values {}
1018+ parameter .AddToQuery (query , "order_by" , req .OrderBy )
1019+ parameter .AddToQuery (query , "page" , req .Page )
1020+ parameter .AddToQuery (query , "page_size" , req .PageSize )
1021+ parameter .AddToQuery (query , "organization_id" , req .OrganizationID )
1022+
1023+ scwReq := & scw.ScalewayRequest {
1024+ Method : "GET" ,
1025+ Path : "/billing/v2beta1/discounts" ,
1026+ Query : query ,
1027+ }
1028+
1029+ var resp ListDiscountsResponse
1030+
1031+ err = s .client .Do (scwReq , & resp , opts ... )
1032+ if err != nil {
1033+ return nil , err
1034+ }
1035+ return & resp , nil
1036+ }
0 commit comments