Skip to content

Commit 422331c

Browse files
authored
feat(iam): add support for QuotumLimit and LocalityType (scaleway#2401)
1 parent 90f7893 commit 422331c

File tree

1 file changed

+71
-2
lines changed

1 file changed

+71
-2
lines changed

api/iam/v1alpha1/iam_sdk.go

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,45 @@ func (enum *ListUsersRequestOrderBy) UnmarshalJSON(data []byte) error {
609609
return nil
610610
}
611611

612+
type LocalityType string
613+
614+
const (
615+
LocalityTypeGlobal = LocalityType("global")
616+
LocalityTypeRegion = LocalityType("region")
617+
LocalityTypeZone = LocalityType("zone")
618+
)
619+
620+
func (enum LocalityType) String() string {
621+
if enum == "" {
622+
// return default value if empty
623+
return "global"
624+
}
625+
return string(enum)
626+
}
627+
628+
func (enum LocalityType) Values() []LocalityType {
629+
return []LocalityType{
630+
"global",
631+
"region",
632+
"zone",
633+
}
634+
}
635+
636+
func (enum LocalityType) MarshalJSON() ([]byte, error) {
637+
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
638+
}
639+
640+
func (enum *LocalityType) UnmarshalJSON(data []byte) error {
641+
tmp := ""
642+
643+
if err := json.Unmarshal(data, &tmp); err != nil {
644+
return err
645+
}
646+
647+
*enum = LocalityType(LocalityType(tmp).String())
648+
return nil
649+
}
650+
612651
type LogAction string
613652

614653
const (
@@ -836,6 +875,29 @@ func (enum *UserType) UnmarshalJSON(data []byte) error {
836875
return nil
837876
}
838877

878+
// QuotumLimit: quotum limit.
879+
type QuotumLimit struct {
880+
// Global: whether or not the limit is applied globally.
881+
// Precisely one of Global, Region, Zone must be set.
882+
Global *bool `json:"global,omitempty"`
883+
884+
// Region: the region on which the limit is applied.
885+
// Precisely one of Global, Region, Zone must be set.
886+
Region *scw.Region `json:"region,omitempty"`
887+
888+
// Zone: the zone on which the limit is applied.
889+
// Precisely one of Global, Region, Zone must be set.
890+
Zone *scw.Zone `json:"zone,omitempty"`
891+
892+
// Limit: maximum locality limit.
893+
// Precisely one of Limit, Unlimited must be set.
894+
Limit *uint64 `json:"limit,omitempty"`
895+
896+
// Unlimited: whether or not the quota per locality is unlimited.
897+
// Precisely one of Limit, Unlimited must be set.
898+
Unlimited *bool `json:"unlimited,omitempty"`
899+
}
900+
839901
// JWT: jwt.
840902
type JWT struct {
841903
// Jti: jWT ID.
@@ -1144,11 +1206,11 @@ type Quotum struct {
11441206
// Name: name of the quota.
11451207
Name string `json:"name"`
11461208

1147-
// Limit: maximum limit of the quota.
1209+
// Deprecated: Limit: maximum limit of the quota.
11481210
// Precisely one of Limit, Unlimited must be set.
11491211
Limit *uint64 `json:"limit,omitempty"`
11501212

1151-
// Unlimited: defines whether or not the quota is unlimited.
1213+
// Deprecated: Unlimited: defines whether or not the quota is unlimited.
11521214
// Precisely one of Limit, Unlimited must be set.
11531215
Unlimited *bool `json:"unlimited,omitempty"`
11541216

@@ -1160,6 +1222,13 @@ type Quotum struct {
11601222

11611223
// Description: details about the quota.
11621224
Description string `json:"description"`
1225+
1226+
// LocalityType: whether this quotum is applied on at the zone level, region level, or globally.
1227+
// Default value: global
1228+
LocalityType LocalityType `json:"locality_type"`
1229+
1230+
// Limits: limits per locality.
1231+
Limits []*QuotumLimit `json:"limits"`
11631232
}
11641233

11651234
// Rule: rule.

0 commit comments

Comments
 (0)