Skip to content

Commit a0ad435

Browse files
authored
feat(iam): return localized quota (#841)
1 parent c12529a commit a0ad435

File tree

6 files changed

+184
-0
lines changed

6 files changed

+184
-0
lines changed

scaleway-async/scaleway_async/iam/v1alpha1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
from .types import ListQuotaRequestOrderBy
1313
from .types import ListSSHKeysRequestOrderBy
1414
from .types import ListUsersRequestOrderBy
15+
from .types import LocalityType
1516
from .types import LogAction
1617
from .types import LogResourceType
1718
from .types import PermissionSetScopeType
1819
from .types import UserStatus
1920
from .types import UserType
21+
from .types import QuotumLimit
2022
from .types import JWT
2123
from .types import RuleSpecs
2224
from .types import CreateUserRequestMember
@@ -119,11 +121,13 @@
119121
"ListQuotaRequestOrderBy",
120122
"ListSSHKeysRequestOrderBy",
121123
"ListUsersRequestOrderBy",
124+
"LocalityType",
122125
"LogAction",
123126
"LogResourceType",
124127
"PermissionSetScopeType",
125128
"UserStatus",
126129
"UserType",
130+
"QuotumLimit",
127131
"JWT",
128132
"RuleSpecs",
129133
"CreateUserRequestMember",

scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Group,
1717
Log,
1818
Policy,
19+
QuotumLimit,
1920
Quotum,
2021
SSHKey,
2122
User,
@@ -452,6 +453,47 @@ def unmarshal_Policy(data: Any) -> Policy:
452453
return Policy(**args)
453454

454455

456+
def unmarshal_QuotumLimit(data: Any) -> QuotumLimit:
457+
if not isinstance(data, dict):
458+
raise TypeError(
459+
"Unmarshalling the type 'QuotumLimit' failed as data isn't a dictionary."
460+
)
461+
462+
args: Dict[str, Any] = {}
463+
464+
field = data.get("global", None)
465+
if field is not None:
466+
args["global_"] = field
467+
else:
468+
args["global_"] = None
469+
470+
field = data.get("region", None)
471+
if field is not None:
472+
args["region"] = field
473+
else:
474+
args["region"] = None
475+
476+
field = data.get("zone", None)
477+
if field is not None:
478+
args["zone"] = field
479+
else:
480+
args["zone"] = None
481+
482+
field = data.get("limit", None)
483+
if field is not None:
484+
args["limit"] = field
485+
else:
486+
args["limit"] = None
487+
488+
field = data.get("unlimited", None)
489+
if field is not None:
490+
args["unlimited"] = field
491+
else:
492+
args["unlimited"] = None
493+
494+
return QuotumLimit(**args)
495+
496+
455497
def unmarshal_Quotum(data: Any) -> Quotum:
456498
if not isinstance(data, dict):
457499
raise TypeError(
@@ -476,6 +518,16 @@ def unmarshal_Quotum(data: Any) -> Quotum:
476518
if field is not None:
477519
args["description"] = field
478520

521+
field = data.get("locality_type", None)
522+
if field is not None:
523+
args["locality_type"] = field
524+
525+
field = data.get("limits", None)
526+
if field is not None:
527+
args["limits"] = (
528+
[unmarshal_QuotumLimit(v) for v in field] if field is not None else None
529+
)
530+
479531
field = data.get("limit", None)
480532
if field is not None:
481533
args["limit"] = field

scaleway-async/scaleway_async/iam/v1alpha1/types.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
from enum import Enum
88
from typing import List, Optional
99

10+
from scaleway_core.bridge import (
11+
Region as ScwRegion,
12+
Zone as ScwZone,
13+
)
1014
from scaleway_core.utils import (
1115
StrEnumMeta,
1216
)
@@ -142,6 +146,15 @@ def __str__(self) -> str:
142146
return str(self.value)
143147

144148

149+
class LocalityType(str, Enum, metaclass=StrEnumMeta):
150+
GLOBAL = "global"
151+
REGION = "region"
152+
ZONE = "zone"
153+
154+
def __str__(self) -> str:
155+
return str(self.value)
156+
157+
145158
class LogAction(str, Enum, metaclass=StrEnumMeta):
146159
UNKNOWN_ACTION = "unknown_action"
147160
CREATED = "created"
@@ -193,6 +206,19 @@ def __str__(self) -> str:
193206
return str(self.value)
194207

195208

209+
@dataclass
210+
class QuotumLimit:
211+
global_: Optional[bool]
212+
213+
region: Optional[ScwRegion]
214+
215+
zone: Optional[ScwZone]
216+
217+
limit: Optional[int]
218+
219+
unlimited: Optional[bool]
220+
221+
196222
@dataclass
197223
class JWT:
198224
jti: str
@@ -656,6 +682,16 @@ class Quotum:
656682
Details about the quota.
657683
"""
658684

685+
locality_type: LocalityType
686+
"""
687+
Whether this quotum is applied on at the zone level, region level, or globally.
688+
"""
689+
690+
limits: List[QuotumLimit]
691+
"""
692+
Limits per locality.
693+
"""
694+
659695
limit: Optional[int]
660696

661697
unlimited: Optional[bool]

scaleway/scaleway/iam/v1alpha1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
from .types import ListQuotaRequestOrderBy
1313
from .types import ListSSHKeysRequestOrderBy
1414
from .types import ListUsersRequestOrderBy
15+
from .types import LocalityType
1516
from .types import LogAction
1617
from .types import LogResourceType
1718
from .types import PermissionSetScopeType
1819
from .types import UserStatus
1920
from .types import UserType
21+
from .types import QuotumLimit
2022
from .types import JWT
2123
from .types import RuleSpecs
2224
from .types import CreateUserRequestMember
@@ -119,11 +121,13 @@
119121
"ListQuotaRequestOrderBy",
120122
"ListSSHKeysRequestOrderBy",
121123
"ListUsersRequestOrderBy",
124+
"LocalityType",
122125
"LogAction",
123126
"LogResourceType",
124127
"PermissionSetScopeType",
125128
"UserStatus",
126129
"UserType",
130+
"QuotumLimit",
127131
"JWT",
128132
"RuleSpecs",
129133
"CreateUserRequestMember",

scaleway/scaleway/iam/v1alpha1/marshalling.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Group,
1717
Log,
1818
Policy,
19+
QuotumLimit,
1920
Quotum,
2021
SSHKey,
2122
User,
@@ -452,6 +453,47 @@ def unmarshal_Policy(data: Any) -> Policy:
452453
return Policy(**args)
453454

454455

456+
def unmarshal_QuotumLimit(data: Any) -> QuotumLimit:
457+
if not isinstance(data, dict):
458+
raise TypeError(
459+
"Unmarshalling the type 'QuotumLimit' failed as data isn't a dictionary."
460+
)
461+
462+
args: Dict[str, Any] = {}
463+
464+
field = data.get("global", None)
465+
if field is not None:
466+
args["global_"] = field
467+
else:
468+
args["global_"] = None
469+
470+
field = data.get("region", None)
471+
if field is not None:
472+
args["region"] = field
473+
else:
474+
args["region"] = None
475+
476+
field = data.get("zone", None)
477+
if field is not None:
478+
args["zone"] = field
479+
else:
480+
args["zone"] = None
481+
482+
field = data.get("limit", None)
483+
if field is not None:
484+
args["limit"] = field
485+
else:
486+
args["limit"] = None
487+
488+
field = data.get("unlimited", None)
489+
if field is not None:
490+
args["unlimited"] = field
491+
else:
492+
args["unlimited"] = None
493+
494+
return QuotumLimit(**args)
495+
496+
455497
def unmarshal_Quotum(data: Any) -> Quotum:
456498
if not isinstance(data, dict):
457499
raise TypeError(
@@ -476,6 +518,16 @@ def unmarshal_Quotum(data: Any) -> Quotum:
476518
if field is not None:
477519
args["description"] = field
478520

521+
field = data.get("locality_type", None)
522+
if field is not None:
523+
args["locality_type"] = field
524+
525+
field = data.get("limits", None)
526+
if field is not None:
527+
args["limits"] = (
528+
[unmarshal_QuotumLimit(v) for v in field] if field is not None else None
529+
)
530+
479531
field = data.get("limit", None)
480532
if field is not None:
481533
args["limit"] = field

scaleway/scaleway/iam/v1alpha1/types.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
from enum import Enum
88
from typing import List, Optional
99

10+
from scaleway_core.bridge import (
11+
Region as ScwRegion,
12+
Zone as ScwZone,
13+
)
1014
from scaleway_core.utils import (
1115
StrEnumMeta,
1216
)
@@ -142,6 +146,15 @@ def __str__(self) -> str:
142146
return str(self.value)
143147

144148

149+
class LocalityType(str, Enum, metaclass=StrEnumMeta):
150+
GLOBAL = "global"
151+
REGION = "region"
152+
ZONE = "zone"
153+
154+
def __str__(self) -> str:
155+
return str(self.value)
156+
157+
145158
class LogAction(str, Enum, metaclass=StrEnumMeta):
146159
UNKNOWN_ACTION = "unknown_action"
147160
CREATED = "created"
@@ -193,6 +206,19 @@ def __str__(self) -> str:
193206
return str(self.value)
194207

195208

209+
@dataclass
210+
class QuotumLimit:
211+
global_: Optional[bool]
212+
213+
region: Optional[ScwRegion]
214+
215+
zone: Optional[ScwZone]
216+
217+
limit: Optional[int]
218+
219+
unlimited: Optional[bool]
220+
221+
196222
@dataclass
197223
class JWT:
198224
jti: str
@@ -656,6 +682,16 @@ class Quotum:
656682
Details about the quota.
657683
"""
658684

685+
locality_type: LocalityType
686+
"""
687+
Whether this quotum is applied on at the zone level, region level, or globally.
688+
"""
689+
690+
limits: List[QuotumLimit]
691+
"""
692+
Limits per locality.
693+
"""
694+
659695
limit: Optional[int]
660696

661697
unlimited: Optional[bool]

0 commit comments

Comments
 (0)