Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(iam): return localized quota #841

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions scaleway-async/scaleway_async/iam/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
@@ -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
@@ -119,11 +121,13 @@
"ListQuotaRequestOrderBy",
"ListSSHKeysRequestOrderBy",
"ListUsersRequestOrderBy",
"LocalityType",
"LogAction",
"LogResourceType",
"PermissionSetScopeType",
"UserStatus",
"UserType",
"QuotumLimit",
"JWT",
"RuleSpecs",
"CreateUserRequestMember",
52 changes: 52 additions & 0 deletions scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
Group,
Log,
Policy,
QuotumLimit,
Quotum,
SSHKey,
User,
@@ -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(
@@ -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
36 changes: 36 additions & 0 deletions scaleway-async/scaleway_async/iam/v1alpha1/types.py
Original file line number Diff line number Diff line change
@@ -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,
)
@@ -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"
@@ -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
@@ -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]
4 changes: 4 additions & 0 deletions scaleway/scaleway/iam/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
@@ -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
@@ -119,11 +121,13 @@
"ListQuotaRequestOrderBy",
"ListSSHKeysRequestOrderBy",
"ListUsersRequestOrderBy",
"LocalityType",
"LogAction",
"LogResourceType",
"PermissionSetScopeType",
"UserStatus",
"UserType",
"QuotumLimit",
"JWT",
"RuleSpecs",
"CreateUserRequestMember",
52 changes: 52 additions & 0 deletions scaleway/scaleway/iam/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
Group,
Log,
Policy,
QuotumLimit,
Quotum,
SSHKey,
User,
@@ -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(
@@ -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
36 changes: 36 additions & 0 deletions scaleway/scaleway/iam/v1alpha1/types.py
Original file line number Diff line number Diff line change
@@ -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,
)
@@ -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"
@@ -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
@@ -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]