Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions scaleway-async/scaleway_async/iam/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
from .types import GetGroupRequest
from .types import GetJWTRequest
from .types import GetLogRequest
from .types import GetOrganizationSecuritySettingsRequest
from .types import GetPolicyRequest
from .types import GetQuotumRequest
from .types import GetSSHKeyRequest
Expand Down Expand Up @@ -83,6 +84,7 @@
from .types import ListUsersRequest
from .types import ListUsersResponse
from .types import LockUserRequest
from .types import OrganizationSecuritySettings
from .types import RemoveGroupMemberRequest
from .types import SetGroupMembersRequest
from .types import SetRulesRequest
Expand All @@ -91,6 +93,7 @@
from .types import UpdateAPIKeyRequest
from .types import UpdateApplicationRequest
from .types import UpdateGroupRequest
from .types import UpdateOrganizationSecuritySettingsRequest
from .types import UpdatePolicyRequest
from .types import UpdateSSHKeyRequest
from .types import UpdateUserPasswordRequest
Expand Down Expand Up @@ -152,6 +155,7 @@
"GetGroupRequest",
"GetJWTRequest",
"GetLogRequest",
"GetOrganizationSecuritySettingsRequest",
"GetPolicyRequest",
"GetQuotumRequest",
"GetSSHKeyRequest",
Expand Down Expand Up @@ -181,6 +185,7 @@
"ListUsersRequest",
"ListUsersResponse",
"LockUserRequest",
"OrganizationSecuritySettings",
"RemoveGroupMemberRequest",
"SetGroupMembersRequest",
"SetRulesRequest",
Expand All @@ -189,6 +194,7 @@
"UpdateAPIKeyRequest",
"UpdateApplicationRequest",
"UpdateGroupRequest",
"UpdateOrganizationSecuritySettingsRequest",
"UpdatePolicyRequest",
"UpdateSSHKeyRequest",
"UpdateUserPasswordRequest",
Expand Down
76 changes: 76 additions & 0 deletions scaleway-async/scaleway_async/iam/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
ListSSHKeysResponse,
ListUsersResponse,
Log,
OrganizationSecuritySettings,
PermissionSet,
Policy,
Quotum,
Expand All @@ -67,6 +68,7 @@
UpdateAPIKeyRequest,
UpdateApplicationRequest,
UpdateGroupRequest,
UpdateOrganizationSecuritySettingsRequest,
UpdatePolicyRequest,
UpdateSSHKeyRequest,
UpdateUserPasswordRequest,
Expand Down Expand Up @@ -96,6 +98,7 @@
unmarshal_ListRulesResponse,
unmarshal_ListSSHKeysResponse,
unmarshal_ListUsersResponse,
unmarshal_OrganizationSecuritySettings,
unmarshal_SetRulesResponse,
marshal_AddGroupMemberRequest,
marshal_AddGroupMembersRequest,
Expand All @@ -112,6 +115,7 @@
marshal_UpdateAPIKeyRequest,
marshal_UpdateApplicationRequest,
marshal_UpdateGroupRequest,
marshal_UpdateOrganizationSecuritySettingsRequest,
marshal_UpdatePolicyRequest,
marshal_UpdateSSHKeyRequest,
marshal_UpdateUserPasswordRequest,
Expand Down Expand Up @@ -2563,3 +2567,75 @@ async def get_log(

self._throw_on_error(res)
return unmarshal_Log(res.json())

async def get_organization_security_settings(
self,
*,
organization_id: Optional[str] = None,
) -> OrganizationSecuritySettings:
"""
Get security settings of an Organization.
Retrieve information about the security settings of an Organization, specified by the `organization_id` parameter.
:param organization_id: ID of the Organization.
:return: :class:`OrganizationSecuritySettings <OrganizationSecuritySettings>`

Usage:
::

result = await api.get_organization_security_settings()
"""

param_organization_id = validate_path_param(
"organization_id", organization_id or self.client.default_organization_id
)

res = self._request(
"GET",
f"/iam/v1alpha1/organizations/{param_organization_id}/security-settings",
)

self._throw_on_error(res)
return unmarshal_OrganizationSecuritySettings(res.json())

async def update_organization_security_settings(
self,
*,
organization_id: Optional[str] = None,
enforce_password_renewal: Optional[bool] = None,
grace_period_duration: Optional[str] = None,
login_attempts_before_locked: Optional[int] = None,
) -> OrganizationSecuritySettings:
"""
Update the security settings of an Organization.
:param organization_id: ID of the Organization.
:param enforce_password_renewal: Defines whether password renewal is enforced during first login.
:param grace_period_duration: Duration of the grace period to renew password or enable MFA.
:param login_attempts_before_locked: Number of login attempts before the account is locked.
:return: :class:`OrganizationSecuritySettings <OrganizationSecuritySettings>`

Usage:
::

result = await api.update_organization_security_settings()
"""

param_organization_id = validate_path_param(
"organization_id", organization_id or self.client.default_organization_id
)

res = self._request(
"PATCH",
f"/iam/v1alpha1/organizations/{param_organization_id}/security-settings",
body=marshal_UpdateOrganizationSecuritySettingsRequest(
UpdateOrganizationSecuritySettingsRequest(
organization_id=organization_id,
enforce_password_renewal=enforce_password_renewal,
grace_period_duration=grace_period_duration,
login_attempts_before_locked=login_attempts_before_locked,
),
self.client,
),
)

self._throw_on_error(res)
return unmarshal_OrganizationSecuritySettings(res.json())
45 changes: 45 additions & 0 deletions scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
ListRulesResponse,
ListSSHKeysResponse,
ListUsersResponse,
OrganizationSecuritySettings,
SetRulesResponse,
AddGroupMemberRequest,
AddGroupMembersRequest,
Expand All @@ -53,6 +54,7 @@
UpdateAPIKeyRequest,
UpdateApplicationRequest,
UpdateGroupRequest,
UpdateOrganizationSecuritySettingsRequest,
UpdatePolicyRequest,
UpdateSSHKeyRequest,
UpdateUserPasswordRequest,
Expand Down Expand Up @@ -993,6 +995,31 @@ def unmarshal_ListUsersResponse(data: Any) -> ListUsersResponse:
return ListUsersResponse(**args)


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

args: Dict[str, Any] = {}

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

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

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

return OrganizationSecuritySettings(**args)


def unmarshal_SetRulesResponse(data: Any) -> SetRulesResponse:
if not isinstance(data, dict):
raise TypeError(
Expand Down Expand Up @@ -1357,6 +1384,24 @@ def marshal_UpdateGroupRequest(
return output


def marshal_UpdateOrganizationSecuritySettingsRequest(
request: UpdateOrganizationSecuritySettingsRequest,
defaults: ProfileDefaults,
) -> Dict[str, Any]:
output: Dict[str, Any] = {}

if request.enforce_password_renewal is not None:
output["enforce_password_renewal"] = request.enforce_password_renewal

if request.grace_period_duration is not None:
output["grace_period_duration"] = request.grace_period_duration

if request.login_attempts_before_locked is not None:
output["login_attempts_before_locked"] = request.login_attempts_before_locked

return output


def marshal_UpdatePolicyRequest(
request: UpdatePolicyRequest,
defaults: ProfileDefaults,
Expand Down
49 changes: 49 additions & 0 deletions scaleway-async/scaleway_async/iam/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,14 @@ class GetLogRequest:
"""


@dataclass
class GetOrganizationSecuritySettingsRequest:
organization_id: Optional[str]
"""
ID of the Organization.
"""


@dataclass
class GetPolicyRequest:
policy_id: str
Expand Down Expand Up @@ -1747,6 +1755,24 @@ class LockUserRequest:
"""


@dataclass
class OrganizationSecuritySettings:
enforce_password_renewal: bool
"""
Defines whether password renewal is enforced during first login.
"""

login_attempts_before_locked: int
"""
Number of login attempts before the account is locked.
"""

grace_period_duration: Optional[str]
"""
Duration of the grace period to renew password or enable MFA.
"""


@dataclass
class RemoveGroupMemberRequest:
group_id: str
Expand Down Expand Up @@ -1861,6 +1887,29 @@ class UpdateGroupRequest:
"""


@dataclass
class UpdateOrganizationSecuritySettingsRequest:
organization_id: Optional[str]
"""
ID of the Organization.
"""

enforce_password_renewal: Optional[bool]
"""
Defines whether password renewal is enforced during first login.
"""

grace_period_duration: Optional[str]
"""
Duration of the grace period to renew password or enable MFA.
"""

login_attempts_before_locked: Optional[int]
"""
Number of login attempts before the account is locked.
"""


@dataclass
class UpdatePolicyRequest:
policy_id: str
Expand Down
6 changes: 6 additions & 0 deletions scaleway/scaleway/iam/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
from .types import GetGroupRequest
from .types import GetJWTRequest
from .types import GetLogRequest
from .types import GetOrganizationSecuritySettingsRequest
from .types import GetPolicyRequest
from .types import GetQuotumRequest
from .types import GetSSHKeyRequest
Expand Down Expand Up @@ -83,6 +84,7 @@
from .types import ListUsersRequest
from .types import ListUsersResponse
from .types import LockUserRequest
from .types import OrganizationSecuritySettings
from .types import RemoveGroupMemberRequest
from .types import SetGroupMembersRequest
from .types import SetRulesRequest
Expand All @@ -91,6 +93,7 @@
from .types import UpdateAPIKeyRequest
from .types import UpdateApplicationRequest
from .types import UpdateGroupRequest
from .types import UpdateOrganizationSecuritySettingsRequest
from .types import UpdatePolicyRequest
from .types import UpdateSSHKeyRequest
from .types import UpdateUserPasswordRequest
Expand Down Expand Up @@ -152,6 +155,7 @@
"GetGroupRequest",
"GetJWTRequest",
"GetLogRequest",
"GetOrganizationSecuritySettingsRequest",
"GetPolicyRequest",
"GetQuotumRequest",
"GetSSHKeyRequest",
Expand Down Expand Up @@ -181,6 +185,7 @@
"ListUsersRequest",
"ListUsersResponse",
"LockUserRequest",
"OrganizationSecuritySettings",
"RemoveGroupMemberRequest",
"SetGroupMembersRequest",
"SetRulesRequest",
Expand All @@ -189,6 +194,7 @@
"UpdateAPIKeyRequest",
"UpdateApplicationRequest",
"UpdateGroupRequest",
"UpdateOrganizationSecuritySettingsRequest",
"UpdatePolicyRequest",
"UpdateSSHKeyRequest",
"UpdateUserPasswordRequest",
Expand Down
Loading
Loading