diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py b/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py index edb257bad..385a286af 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py @@ -18,10 +18,13 @@ from .types import PermissionSetScopeType from .types import UserStatus from .types import UserType +from .types import GetUserConnectionsResponseConnectionConnectedOrganization +from .types import GetUserConnectionsResponseConnectionConnectedUser from .types import QuotumLimit from .types import JWT from .types import RuleSpecs from .types import CreateUserRequestMember +from .types import GetUserConnectionsResponseConnection from .types import APIKey from .types import Application from .types import GracePeriod @@ -62,6 +65,8 @@ from .types import GetPolicyRequest from .types import GetQuotumRequest from .types import GetSSHKeyRequest +from .types import GetUserConnectionsRequest +from .types import GetUserConnectionsResponse from .types import GetUserRequest from .types import ListAPIKeysRequest from .types import ListAPIKeysResponse @@ -127,10 +132,13 @@ "PermissionSetScopeType", "UserStatus", "UserType", + "GetUserConnectionsResponseConnectionConnectedOrganization", + "GetUserConnectionsResponseConnectionConnectedUser", "QuotumLimit", "JWT", "RuleSpecs", "CreateUserRequestMember", + "GetUserConnectionsResponseConnection", "APIKey", "Application", "GracePeriod", @@ -171,6 +179,8 @@ "GetPolicyRequest", "GetQuotumRequest", "GetSSHKeyRequest", + "GetUserConnectionsRequest", + "GetUserConnectionsResponse", "GetUserRequest", "ListAPIKeysRequest", "ListAPIKeysResponse", diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/api.py b/scaleway-async/scaleway_async/iam/v1alpha1/api.py index 24fc6a492..b09424baf 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/api.py @@ -39,6 +39,7 @@ CreateUserRequest, CreateUserRequestMember, EncodedJWT, + GetUserConnectionsResponse, Group, JWT, ListAPIKeysResponse, @@ -90,6 +91,7 @@ unmarshal_SSHKey, unmarshal_User, unmarshal_EncodedJWT, + unmarshal_GetUserConnectionsResponse, unmarshal_ListAPIKeysResponse, unmarshal_ListApplicationsResponse, unmarshal_ListGracePeriodsResponse, @@ -851,6 +853,33 @@ async def list_grace_periods( self._throw_on_error(res) return unmarshal_ListGracePeriodsResponse(res.json()) + async def get_user_connections( + self, + *, + user_id: str, + ) -> GetUserConnectionsResponse: + """ + :param user_id: ID of the user to list connections for. + :return: :class:`GetUserConnectionsResponse ` + + Usage: + :: + + result = await api.get_user_connections( + user_id="example", + ) + """ + + param_user_id = validate_path_param("user_id", user_id) + + res = self._request( + "GET", + f"/iam/v1alpha1/users/{param_user_id}/connections", + ) + + self._throw_on_error(res) + return unmarshal_GetUserConnectionsResponse(res.json()) + async def list_applications( self, *, diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py index c6a9ef1eb..4b35ea99c 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py @@ -21,6 +21,10 @@ SSHKey, User, EncodedJWT, + GetUserConnectionsResponseConnectionConnectedOrganization, + GetUserConnectionsResponseConnectionConnectedUser, + GetUserConnectionsResponseConnection, + GetUserConnectionsResponse, ListAPIKeysResponse, ListApplicationsResponse, GracePeriod, @@ -700,6 +704,104 @@ def unmarshal_EncodedJWT(data: Any) -> EncodedJWT: return EncodedJWT(**args) +def unmarshal_GetUserConnectionsResponseConnectionConnectedOrganization( + data: Any, +) -> GetUserConnectionsResponseConnectionConnectedOrganization: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetUserConnectionsResponseConnectionConnectedOrganization' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("locked", None) + if field is not None: + args["locked"] = field + + return GetUserConnectionsResponseConnectionConnectedOrganization(**args) + + +def unmarshal_GetUserConnectionsResponseConnectionConnectedUser( + data: Any, +) -> GetUserConnectionsResponseConnectionConnectedUser: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetUserConnectionsResponseConnectionConnectedUser' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("username", None) + if field is not None: + args["username"] = field + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + return GetUserConnectionsResponseConnectionConnectedUser(**args) + + +def unmarshal_GetUserConnectionsResponseConnection( + data: Any, +) -> GetUserConnectionsResponseConnection: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetUserConnectionsResponseConnection' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("organization", None) + if field is not None: + args["organization"] = ( + unmarshal_GetUserConnectionsResponseConnectionConnectedOrganization(field) + ) + else: + args["organization"] = None + + field = data.get("user", None) + if field is not None: + args["user"] = unmarshal_GetUserConnectionsResponseConnectionConnectedUser( + field + ) + else: + args["user"] = None + + return GetUserConnectionsResponseConnection(**args) + + +def unmarshal_GetUserConnectionsResponse(data: Any) -> GetUserConnectionsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetUserConnectionsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("connections", None) + if field is not None: + args["connections"] = ( + [unmarshal_GetUserConnectionsResponseConnection(v) for v in field] + if field is not None + else None + ) + + return GetUserConnectionsResponse(**args) + + def unmarshal_ListAPIKeysResponse(data: Any) -> ListAPIKeysResponse: if not isinstance(data, dict): raise TypeError( diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/types.py b/scaleway-async/scaleway_async/iam/v1alpha1/types.py index 571ee9ac8..3d5b67aa2 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/types.py @@ -206,6 +206,24 @@ def __str__(self) -> str: return str(self.value) +@dataclass +class GetUserConnectionsResponseConnectionConnectedOrganization: + id: str + + name: str + + locked: bool + + +@dataclass +class GetUserConnectionsResponseConnectionConnectedUser: + id: str + + username: str + + type_: UserType + + @dataclass class QuotumLimit: global_: Optional[bool] @@ -307,6 +325,19 @@ class CreateUserRequestMember: """ +@dataclass +class GetUserConnectionsResponseConnection: + organization: Optional[GetUserConnectionsResponseConnectionConnectedOrganization] + """ + Information about the connected organization. + """ + + user: Optional[GetUserConnectionsResponseConnectionConnectedUser] + """ + Information about the connected user. + """ + + @dataclass class APIKey: access_key: str @@ -1203,6 +1234,22 @@ class GetSSHKeyRequest: """ +@dataclass +class GetUserConnectionsRequest: + user_id: str + """ + ID of the user to list connections for. + """ + + +@dataclass +class GetUserConnectionsResponse: + connections: List[GetUserConnectionsResponseConnection] + """ + List of connections. + """ + + @dataclass class GetUserRequest: user_id: str diff --git a/scaleway/scaleway/iam/v1alpha1/__init__.py b/scaleway/scaleway/iam/v1alpha1/__init__.py index edb257bad..385a286af 100644 --- a/scaleway/scaleway/iam/v1alpha1/__init__.py +++ b/scaleway/scaleway/iam/v1alpha1/__init__.py @@ -18,10 +18,13 @@ from .types import PermissionSetScopeType from .types import UserStatus from .types import UserType +from .types import GetUserConnectionsResponseConnectionConnectedOrganization +from .types import GetUserConnectionsResponseConnectionConnectedUser from .types import QuotumLimit from .types import JWT from .types import RuleSpecs from .types import CreateUserRequestMember +from .types import GetUserConnectionsResponseConnection from .types import APIKey from .types import Application from .types import GracePeriod @@ -62,6 +65,8 @@ from .types import GetPolicyRequest from .types import GetQuotumRequest from .types import GetSSHKeyRequest +from .types import GetUserConnectionsRequest +from .types import GetUserConnectionsResponse from .types import GetUserRequest from .types import ListAPIKeysRequest from .types import ListAPIKeysResponse @@ -127,10 +132,13 @@ "PermissionSetScopeType", "UserStatus", "UserType", + "GetUserConnectionsResponseConnectionConnectedOrganization", + "GetUserConnectionsResponseConnectionConnectedUser", "QuotumLimit", "JWT", "RuleSpecs", "CreateUserRequestMember", + "GetUserConnectionsResponseConnection", "APIKey", "Application", "GracePeriod", @@ -171,6 +179,8 @@ "GetPolicyRequest", "GetQuotumRequest", "GetSSHKeyRequest", + "GetUserConnectionsRequest", + "GetUserConnectionsResponse", "GetUserRequest", "ListAPIKeysRequest", "ListAPIKeysResponse", diff --git a/scaleway/scaleway/iam/v1alpha1/api.py b/scaleway/scaleway/iam/v1alpha1/api.py index 11364cf41..fdb229a5a 100644 --- a/scaleway/scaleway/iam/v1alpha1/api.py +++ b/scaleway/scaleway/iam/v1alpha1/api.py @@ -39,6 +39,7 @@ CreateUserRequest, CreateUserRequestMember, EncodedJWT, + GetUserConnectionsResponse, Group, JWT, ListAPIKeysResponse, @@ -90,6 +91,7 @@ unmarshal_SSHKey, unmarshal_User, unmarshal_EncodedJWT, + unmarshal_GetUserConnectionsResponse, unmarshal_ListAPIKeysResponse, unmarshal_ListApplicationsResponse, unmarshal_ListGracePeriodsResponse, @@ -851,6 +853,33 @@ def list_grace_periods( self._throw_on_error(res) return unmarshal_ListGracePeriodsResponse(res.json()) + def get_user_connections( + self, + *, + user_id: str, + ) -> GetUserConnectionsResponse: + """ + :param user_id: ID of the user to list connections for. + :return: :class:`GetUserConnectionsResponse ` + + Usage: + :: + + result = api.get_user_connections( + user_id="example", + ) + """ + + param_user_id = validate_path_param("user_id", user_id) + + res = self._request( + "GET", + f"/iam/v1alpha1/users/{param_user_id}/connections", + ) + + self._throw_on_error(res) + return unmarshal_GetUserConnectionsResponse(res.json()) + def list_applications( self, *, diff --git a/scaleway/scaleway/iam/v1alpha1/marshalling.py b/scaleway/scaleway/iam/v1alpha1/marshalling.py index c6a9ef1eb..4b35ea99c 100644 --- a/scaleway/scaleway/iam/v1alpha1/marshalling.py +++ b/scaleway/scaleway/iam/v1alpha1/marshalling.py @@ -21,6 +21,10 @@ SSHKey, User, EncodedJWT, + GetUserConnectionsResponseConnectionConnectedOrganization, + GetUserConnectionsResponseConnectionConnectedUser, + GetUserConnectionsResponseConnection, + GetUserConnectionsResponse, ListAPIKeysResponse, ListApplicationsResponse, GracePeriod, @@ -700,6 +704,104 @@ def unmarshal_EncodedJWT(data: Any) -> EncodedJWT: return EncodedJWT(**args) +def unmarshal_GetUserConnectionsResponseConnectionConnectedOrganization( + data: Any, +) -> GetUserConnectionsResponseConnectionConnectedOrganization: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetUserConnectionsResponseConnectionConnectedOrganization' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("locked", None) + if field is not None: + args["locked"] = field + + return GetUserConnectionsResponseConnectionConnectedOrganization(**args) + + +def unmarshal_GetUserConnectionsResponseConnectionConnectedUser( + data: Any, +) -> GetUserConnectionsResponseConnectionConnectedUser: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetUserConnectionsResponseConnectionConnectedUser' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("username", None) + if field is not None: + args["username"] = field + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + return GetUserConnectionsResponseConnectionConnectedUser(**args) + + +def unmarshal_GetUserConnectionsResponseConnection( + data: Any, +) -> GetUserConnectionsResponseConnection: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetUserConnectionsResponseConnection' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("organization", None) + if field is not None: + args["organization"] = ( + unmarshal_GetUserConnectionsResponseConnectionConnectedOrganization(field) + ) + else: + args["organization"] = None + + field = data.get("user", None) + if field is not None: + args["user"] = unmarshal_GetUserConnectionsResponseConnectionConnectedUser( + field + ) + else: + args["user"] = None + + return GetUserConnectionsResponseConnection(**args) + + +def unmarshal_GetUserConnectionsResponse(data: Any) -> GetUserConnectionsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetUserConnectionsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("connections", None) + if field is not None: + args["connections"] = ( + [unmarshal_GetUserConnectionsResponseConnection(v) for v in field] + if field is not None + else None + ) + + return GetUserConnectionsResponse(**args) + + def unmarshal_ListAPIKeysResponse(data: Any) -> ListAPIKeysResponse: if not isinstance(data, dict): raise TypeError( diff --git a/scaleway/scaleway/iam/v1alpha1/types.py b/scaleway/scaleway/iam/v1alpha1/types.py index 571ee9ac8..3d5b67aa2 100644 --- a/scaleway/scaleway/iam/v1alpha1/types.py +++ b/scaleway/scaleway/iam/v1alpha1/types.py @@ -206,6 +206,24 @@ def __str__(self) -> str: return str(self.value) +@dataclass +class GetUserConnectionsResponseConnectionConnectedOrganization: + id: str + + name: str + + locked: bool + + +@dataclass +class GetUserConnectionsResponseConnectionConnectedUser: + id: str + + username: str + + type_: UserType + + @dataclass class QuotumLimit: global_: Optional[bool] @@ -307,6 +325,19 @@ class CreateUserRequestMember: """ +@dataclass +class GetUserConnectionsResponseConnection: + organization: Optional[GetUserConnectionsResponseConnectionConnectedOrganization] + """ + Information about the connected organization. + """ + + user: Optional[GetUserConnectionsResponseConnectionConnectedUser] + """ + Information about the connected user. + """ + + @dataclass class APIKey: access_key: str @@ -1203,6 +1234,22 @@ class GetSSHKeyRequest: """ +@dataclass +class GetUserConnectionsRequest: + user_id: str + """ + ID of the user to list connections for. + """ + + +@dataclass +class GetUserConnectionsResponse: + connections: List[GetUserConnectionsResponseConnection] + """ + List of connections. + """ + + @dataclass class GetUserRequest: user_id: str