Skip to content

Commit 8364594

Browse files
authored
feat(webhosting): update list offer with hosting id and its available offers (#1574)
1 parent 7b9019d commit 8364594

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

api/webhosting/v1alpha1/webhosting_sdk.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,38 @@ func (enum *NameserverStatus) UnmarshalJSON(data []byte) error {
303303
return nil
304304
}
305305

306+
type OfferQuotaWarning string
307+
308+
const (
309+
OfferQuotaWarningUnknownQuotaWarning = OfferQuotaWarning("unknown_quota_warning")
310+
OfferQuotaWarningEmailCountExceeded = OfferQuotaWarning("email_count_exceeded")
311+
OfferQuotaWarningDatabaseCountExceeded = OfferQuotaWarning("database_count_exceeded")
312+
OfferQuotaWarningDiskUsageExceeded = OfferQuotaWarning("disk_usage_exceeded")
313+
)
314+
315+
func (enum OfferQuotaWarning) String() string {
316+
if enum == "" {
317+
// return default value if empty
318+
return "unknown_quota_warning"
319+
}
320+
return string(enum)
321+
}
322+
323+
func (enum OfferQuotaWarning) MarshalJSON() ([]byte, error) {
324+
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
325+
}
326+
327+
func (enum *OfferQuotaWarning) UnmarshalJSON(data []byte) error {
328+
tmp := ""
329+
330+
if err := json.Unmarshal(data, &tmp); err != nil {
331+
return err
332+
}
333+
334+
*enum = OfferQuotaWarning(OfferQuotaWarning(tmp).String())
335+
return nil
336+
}
337+
306338
// DNSRecord: dns record.
307339
type DNSRecord struct {
308340
// Name: record name.
@@ -421,6 +453,10 @@ type Offer struct {
421453
Product *OfferProduct `json:"product"`
422454
// Price: offer price.
423455
Price *scw.Money `json:"price"`
456+
// Available: if offer is available for a specific hosting.
457+
Available bool `json:"available"`
458+
// QuotaWarnings: if not available, return quota warnings.
459+
QuotaWarnings []OfferQuotaWarning `json:"quota_warnings"`
424460
}
425461

426462
// OfferProduct: offer. product.
@@ -796,6 +832,8 @@ type ListOffersRequest struct {
796832
WithoutOptions bool `json:"-"`
797833
// OnlyOptions: select only options.
798834
OnlyOptions bool `json:"-"`
835+
// HostingID: define a specific hosting id (optional).
836+
HostingID *string `json:"-"`
799837
}
800838

801839
// ListOffers: list all offers.
@@ -811,6 +849,7 @@ func (s *API) ListOffers(req *ListOffersRequest, opts ...scw.RequestOption) (*Li
811849
parameter.AddToQuery(query, "order_by", req.OrderBy)
812850
parameter.AddToQuery(query, "without_options", req.WithoutOptions)
813851
parameter.AddToQuery(query, "only_options", req.OnlyOptions)
852+
parameter.AddToQuery(query, "hosting_id", req.HostingID)
814853

815854
if fmt.Sprint(req.Region) == "" {
816855
return nil, errors.New("field Region cannot be empty in request")

0 commit comments

Comments
 (0)