Skip to content

Commit

Permalink
feat(iam): return localized quota (#841)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored Jan 30, 2025
1 parent c12529a commit a0ad435
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scaleway-async/scaleway_async/iam/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
from .types import ListQuotaRequestOrderBy
from .types import ListSSHKeysRequestOrderBy
from .types import ListUsersRequestOrderBy
from .types import LocalityType
from .types import LogAction
from .types import LogResourceType
from .types import PermissionSetScopeType
from .types import UserStatus
from .types import UserType
from .types import QuotumLimit
from .types import JWT
from .types import RuleSpecs
from .types import CreateUserRequestMember
Expand Down Expand Up @@ -119,11 +121,13 @@
"ListQuotaRequestOrderBy",
"ListSSHKeysRequestOrderBy",
"ListUsersRequestOrderBy",
"LocalityType",
"LogAction",
"LogResourceType",
"PermissionSetScopeType",
"UserStatus",
"UserType",
"QuotumLimit",
"JWT",
"RuleSpecs",
"CreateUserRequestMember",
Expand Down
52 changes: 52 additions & 0 deletions scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Group,
Log,
Policy,
QuotumLimit,
Quotum,
SSHKey,
User,
Expand Down Expand Up @@ -452,6 +453,47 @@ def unmarshal_Policy(data: Any) -> Policy:
return Policy(**args)


def unmarshal_QuotumLimit(data: Any) -> QuotumLimit:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'QuotumLimit' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("global", None)
if field is not None:
args["global_"] = field
else:
args["global_"] = None

field = data.get("region", None)
if field is not None:
args["region"] = field
else:
args["region"] = None

field = data.get("zone", None)
if field is not None:
args["zone"] = field
else:
args["zone"] = None

field = data.get("limit", None)
if field is not None:
args["limit"] = field
else:
args["limit"] = None

field = data.get("unlimited", None)
if field is not None:
args["unlimited"] = field
else:
args["unlimited"] = None

return QuotumLimit(**args)


def unmarshal_Quotum(data: Any) -> Quotum:
if not isinstance(data, dict):
raise TypeError(
Expand All @@ -476,6 +518,16 @@ def unmarshal_Quotum(data: Any) -> Quotum:
if field is not None:
args["description"] = field

field = data.get("locality_type", None)
if field is not None:
args["locality_type"] = field

field = data.get("limits", None)
if field is not None:
args["limits"] = (
[unmarshal_QuotumLimit(v) for v in field] if field is not None else None
)

field = data.get("limit", None)
if field is not None:
args["limit"] = field
Expand Down
36 changes: 36 additions & 0 deletions scaleway-async/scaleway_async/iam/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
from enum import Enum
from typing import List, Optional

from scaleway_core.bridge import (
Region as ScwRegion,
Zone as ScwZone,
)
from scaleway_core.utils import (
StrEnumMeta,
)
Expand Down Expand Up @@ -142,6 +146,15 @@ def __str__(self) -> str:
return str(self.value)


class LocalityType(str, Enum, metaclass=StrEnumMeta):
GLOBAL = "global"
REGION = "region"
ZONE = "zone"

def __str__(self) -> str:
return str(self.value)


class LogAction(str, Enum, metaclass=StrEnumMeta):
UNKNOWN_ACTION = "unknown_action"
CREATED = "created"
Expand Down Expand Up @@ -193,6 +206,19 @@ def __str__(self) -> str:
return str(self.value)


@dataclass
class QuotumLimit:
global_: Optional[bool]

region: Optional[ScwRegion]

zone: Optional[ScwZone]

limit: Optional[int]

unlimited: Optional[bool]


@dataclass
class JWT:
jti: str
Expand Down Expand Up @@ -656,6 +682,16 @@ class Quotum:
Details about the quota.
"""

locality_type: LocalityType
"""
Whether this quotum is applied on at the zone level, region level, or globally.
"""

limits: List[QuotumLimit]
"""
Limits per locality.
"""

limit: Optional[int]

unlimited: Optional[bool]
Expand Down
4 changes: 4 additions & 0 deletions scaleway/scaleway/iam/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
from .types import ListQuotaRequestOrderBy
from .types import ListSSHKeysRequestOrderBy
from .types import ListUsersRequestOrderBy
from .types import LocalityType
from .types import LogAction
from .types import LogResourceType
from .types import PermissionSetScopeType
from .types import UserStatus
from .types import UserType
from .types import QuotumLimit
from .types import JWT
from .types import RuleSpecs
from .types import CreateUserRequestMember
Expand Down Expand Up @@ -119,11 +121,13 @@
"ListQuotaRequestOrderBy",
"ListSSHKeysRequestOrderBy",
"ListUsersRequestOrderBy",
"LocalityType",
"LogAction",
"LogResourceType",
"PermissionSetScopeType",
"UserStatus",
"UserType",
"QuotumLimit",
"JWT",
"RuleSpecs",
"CreateUserRequestMember",
Expand Down
52 changes: 52 additions & 0 deletions scaleway/scaleway/iam/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Group,
Log,
Policy,
QuotumLimit,
Quotum,
SSHKey,
User,
Expand Down Expand Up @@ -452,6 +453,47 @@ def unmarshal_Policy(data: Any) -> Policy:
return Policy(**args)


def unmarshal_QuotumLimit(data: Any) -> QuotumLimit:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'QuotumLimit' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("global", None)
if field is not None:
args["global_"] = field
else:
args["global_"] = None

field = data.get("region", None)
if field is not None:
args["region"] = field
else:
args["region"] = None

field = data.get("zone", None)
if field is not None:
args["zone"] = field
else:
args["zone"] = None

field = data.get("limit", None)
if field is not None:
args["limit"] = field
else:
args["limit"] = None

field = data.get("unlimited", None)
if field is not None:
args["unlimited"] = field
else:
args["unlimited"] = None

return QuotumLimit(**args)


def unmarshal_Quotum(data: Any) -> Quotum:
if not isinstance(data, dict):
raise TypeError(
Expand All @@ -476,6 +518,16 @@ def unmarshal_Quotum(data: Any) -> Quotum:
if field is not None:
args["description"] = field

field = data.get("locality_type", None)
if field is not None:
args["locality_type"] = field

field = data.get("limits", None)
if field is not None:
args["limits"] = (
[unmarshal_QuotumLimit(v) for v in field] if field is not None else None
)

field = data.get("limit", None)
if field is not None:
args["limit"] = field
Expand Down
36 changes: 36 additions & 0 deletions scaleway/scaleway/iam/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
from enum import Enum
from typing import List, Optional

from scaleway_core.bridge import (
Region as ScwRegion,
Zone as ScwZone,
)
from scaleway_core.utils import (
StrEnumMeta,
)
Expand Down Expand Up @@ -142,6 +146,15 @@ def __str__(self) -> str:
return str(self.value)


class LocalityType(str, Enum, metaclass=StrEnumMeta):
GLOBAL = "global"
REGION = "region"
ZONE = "zone"

def __str__(self) -> str:
return str(self.value)


class LogAction(str, Enum, metaclass=StrEnumMeta):
UNKNOWN_ACTION = "unknown_action"
CREATED = "created"
Expand Down Expand Up @@ -193,6 +206,19 @@ def __str__(self) -> str:
return str(self.value)


@dataclass
class QuotumLimit:
global_: Optional[bool]

region: Optional[ScwRegion]

zone: Optional[ScwZone]

limit: Optional[int]

unlimited: Optional[bool]


@dataclass
class JWT:
jti: str
Expand Down Expand Up @@ -656,6 +682,16 @@ class Quotum:
Details about the quota.
"""

locality_type: LocalityType
"""
Whether this quotum is applied on at the zone level, region level, or globally.
"""

limits: List[QuotumLimit]
"""
Limits per locality.
"""

limit: Optional[int]

unlimited: Optional[bool]
Expand Down

0 comments on commit a0ad435

Please sign in to comment.