Skip to content

Commit 065b97b

Browse files
authored
feat(iam): add listing of user connections (#887)
1 parent 6b9c211 commit 065b97b

File tree

8 files changed

+376
-0
lines changed

8 files changed

+376
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from .types import UserStatus
2020
from .types import UserType
2121
from .types import QuotumLimit
22+
from .types import ListUserConnectionsResponseConnectionConnectedOrganization
23+
from .types import ListUserConnectionsResponseConnectionConnectedUser
2224
from .types import JWT
2325
from .types import RuleSpecs
2426
from .types import CreateUserRequestMember
@@ -32,6 +34,7 @@
3234
from .types import Quotum
3335
from .types import Rule
3436
from .types import SSHKey
37+
from .types import ListUserConnectionsResponseConnection
3538
from .types import User
3639
from .types import AddGroupMemberRequest
3740
from .types import AddGroupMembersRequest
@@ -85,6 +88,8 @@
8588
from .types import ListRulesResponse
8689
from .types import ListSSHKeysRequest
8790
from .types import ListSSHKeysResponse
91+
from .types import ListUserConnectionsRequest
92+
from .types import ListUserConnectionsResponse
8893
from .types import ListUsersRequest
8994
from .types import ListUsersResponse
9095
from .types import LockUserRequest
@@ -128,6 +133,8 @@
128133
"UserStatus",
129134
"UserType",
130135
"QuotumLimit",
136+
"ListUserConnectionsResponseConnectionConnectedOrganization",
137+
"ListUserConnectionsResponseConnectionConnectedUser",
131138
"JWT",
132139
"RuleSpecs",
133140
"CreateUserRequestMember",
@@ -141,6 +148,7 @@
141148
"Quotum",
142149
"Rule",
143150
"SSHKey",
151+
"ListUserConnectionsResponseConnection",
144152
"User",
145153
"AddGroupMemberRequest",
146154
"AddGroupMembersRequest",
@@ -194,6 +202,8 @@
194202
"ListRulesResponse",
195203
"ListSSHKeysRequest",
196204
"ListSSHKeysResponse",
205+
"ListUserConnectionsRequest",
206+
"ListUserConnectionsResponse",
197207
"ListUsersRequest",
198208
"ListUsersResponse",
199209
"LockUserRequest",

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
ListQuotaResponse,
5353
ListRulesResponse,
5454
ListSSHKeysResponse,
55+
ListUserConnectionsResponse,
5556
ListUsersResponse,
5657
Log,
5758
MFAOTP,
@@ -101,6 +102,7 @@
101102
unmarshal_ListQuotaResponse,
102103
unmarshal_ListRulesResponse,
103104
unmarshal_ListSSHKeysResponse,
105+
unmarshal_ListUserConnectionsResponse,
104106
unmarshal_ListUsersResponse,
105107
unmarshal_MFAOTP,
106108
unmarshal_OrganizationSecuritySettings,
@@ -851,6 +853,33 @@ async def list_grace_periods(
851853
self._throw_on_error(res)
852854
return unmarshal_ListGracePeriodsResponse(res.json())
853855

856+
async def list_user_connections(
857+
self,
858+
*,
859+
user_id: str,
860+
) -> ListUserConnectionsResponse:
861+
"""
862+
:param user_id: ID of the user to list connections for.
863+
:return: :class:`ListUserConnectionsResponse <ListUserConnectionsResponse>`
864+
865+
Usage:
866+
::
867+
868+
result = await api.list_user_connections(
869+
user_id="example",
870+
)
871+
"""
872+
873+
param_user_id = validate_path_param("user_id", user_id)
874+
875+
res = self._request(
876+
"GET",
877+
f"/iam/v1alpha1/users/{param_user_id}/connections",
878+
)
879+
880+
self._throw_on_error(res)
881+
return unmarshal_ListUserConnectionsResponse(res.json())
882+
854883
async def list_applications(
855884
self,
856885
*,

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

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
Rule,
3636
ListRulesResponse,
3737
ListSSHKeysResponse,
38+
ListUserConnectionsResponseConnectionConnectedOrganization,
39+
ListUserConnectionsResponseConnectionConnectedUser,
40+
ListUserConnectionsResponseConnection,
41+
ListUserConnectionsResponse,
3842
ListUsersResponse,
3943
MFAOTP,
4044
OrganizationSecuritySettings,
@@ -1030,6 +1034,104 @@ def unmarshal_ListSSHKeysResponse(data: Any) -> ListSSHKeysResponse:
10301034
return ListSSHKeysResponse(**args)
10311035

10321036

1037+
def unmarshal_ListUserConnectionsResponseConnectionConnectedOrganization(
1038+
data: Any,
1039+
) -> ListUserConnectionsResponseConnectionConnectedOrganization:
1040+
if not isinstance(data, dict):
1041+
raise TypeError(
1042+
"Unmarshalling the type 'ListUserConnectionsResponseConnectionConnectedOrganization' failed as data isn't a dictionary."
1043+
)
1044+
1045+
args: Dict[str, Any] = {}
1046+
1047+
field = data.get("id", None)
1048+
if field is not None:
1049+
args["id"] = field
1050+
1051+
field = data.get("name", None)
1052+
if field is not None:
1053+
args["name"] = field
1054+
1055+
field = data.get("locked", None)
1056+
if field is not None:
1057+
args["locked"] = field
1058+
1059+
return ListUserConnectionsResponseConnectionConnectedOrganization(**args)
1060+
1061+
1062+
def unmarshal_ListUserConnectionsResponseConnectionConnectedUser(
1063+
data: Any,
1064+
) -> ListUserConnectionsResponseConnectionConnectedUser:
1065+
if not isinstance(data, dict):
1066+
raise TypeError(
1067+
"Unmarshalling the type 'ListUserConnectionsResponseConnectionConnectedUser' failed as data isn't a dictionary."
1068+
)
1069+
1070+
args: Dict[str, Any] = {}
1071+
1072+
field = data.get("id", None)
1073+
if field is not None:
1074+
args["id"] = field
1075+
1076+
field = data.get("username", None)
1077+
if field is not None:
1078+
args["username"] = field
1079+
1080+
field = data.get("type", None)
1081+
if field is not None:
1082+
args["type_"] = field
1083+
1084+
return ListUserConnectionsResponseConnectionConnectedUser(**args)
1085+
1086+
1087+
def unmarshal_ListUserConnectionsResponseConnection(
1088+
data: Any,
1089+
) -> ListUserConnectionsResponseConnection:
1090+
if not isinstance(data, dict):
1091+
raise TypeError(
1092+
"Unmarshalling the type 'ListUserConnectionsResponseConnection' failed as data isn't a dictionary."
1093+
)
1094+
1095+
args: Dict[str, Any] = {}
1096+
1097+
field = data.get("organization", None)
1098+
if field is not None:
1099+
args["organization"] = (
1100+
unmarshal_ListUserConnectionsResponseConnectionConnectedOrganization(field)
1101+
)
1102+
else:
1103+
args["organization"] = None
1104+
1105+
field = data.get("user", None)
1106+
if field is not None:
1107+
args["user"] = unmarshal_ListUserConnectionsResponseConnectionConnectedUser(
1108+
field
1109+
)
1110+
else:
1111+
args["user"] = None
1112+
1113+
return ListUserConnectionsResponseConnection(**args)
1114+
1115+
1116+
def unmarshal_ListUserConnectionsResponse(data: Any) -> ListUserConnectionsResponse:
1117+
if not isinstance(data, dict):
1118+
raise TypeError(
1119+
"Unmarshalling the type 'ListUserConnectionsResponse' failed as data isn't a dictionary."
1120+
)
1121+
1122+
args: Dict[str, Any] = {}
1123+
1124+
field = data.get("connections", None)
1125+
if field is not None:
1126+
args["connections"] = (
1127+
[unmarshal_ListUserConnectionsResponseConnection(v) for v in field]
1128+
if field is not None
1129+
else None
1130+
)
1131+
1132+
return ListUserConnectionsResponse(**args)
1133+
1134+
10331135
def unmarshal_ListUsersResponse(data: Any) -> ListUsersResponse:
10341136
if not isinstance(data, dict):
10351137
raise TypeError(

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,24 @@ class QuotumLimit:
219219
unlimited: Optional[bool]
220220

221221

222+
@dataclass
223+
class ListUserConnectionsResponseConnectionConnectedOrganization:
224+
id: str
225+
226+
name: str
227+
228+
locked: bool
229+
230+
231+
@dataclass
232+
class ListUserConnectionsResponseConnectionConnectedUser:
233+
id: str
234+
235+
username: str
236+
237+
type_: UserType
238+
239+
222240
@dataclass
223241
class JWT:
224242
jti: str
@@ -774,6 +792,19 @@ class SSHKey:
774792
"""
775793

776794

795+
@dataclass
796+
class ListUserConnectionsResponseConnection:
797+
organization: Optional[ListUserConnectionsResponseConnectionConnectedOrganization]
798+
"""
799+
Information about the connected organization.
800+
"""
801+
802+
user: Optional[ListUserConnectionsResponseConnectionConnectedUser]
803+
"""
804+
Information about the connected user.
805+
"""
806+
807+
777808
@dataclass
778809
class User:
779810
id: str
@@ -1750,6 +1781,22 @@ class ListSSHKeysResponse:
17501781
"""
17511782

17521783

1784+
@dataclass
1785+
class ListUserConnectionsRequest:
1786+
user_id: str
1787+
"""
1788+
ID of the user to list connections for.
1789+
"""
1790+
1791+
1792+
@dataclass
1793+
class ListUserConnectionsResponse:
1794+
connections: List[ListUserConnectionsResponseConnection]
1795+
"""
1796+
List of connections.
1797+
"""
1798+
1799+
17531800
@dataclass
17541801
class ListUsersRequest:
17551802
order_by: Optional[ListUsersRequestOrderBy]

scaleway/scaleway/iam/v1alpha1/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from .types import UserStatus
2020
from .types import UserType
2121
from .types import QuotumLimit
22+
from .types import ListUserConnectionsResponseConnectionConnectedOrganization
23+
from .types import ListUserConnectionsResponseConnectionConnectedUser
2224
from .types import JWT
2325
from .types import RuleSpecs
2426
from .types import CreateUserRequestMember
@@ -32,6 +34,7 @@
3234
from .types import Quotum
3335
from .types import Rule
3436
from .types import SSHKey
37+
from .types import ListUserConnectionsResponseConnection
3538
from .types import User
3639
from .types import AddGroupMemberRequest
3740
from .types import AddGroupMembersRequest
@@ -85,6 +88,8 @@
8588
from .types import ListRulesResponse
8689
from .types import ListSSHKeysRequest
8790
from .types import ListSSHKeysResponse
91+
from .types import ListUserConnectionsRequest
92+
from .types import ListUserConnectionsResponse
8893
from .types import ListUsersRequest
8994
from .types import ListUsersResponse
9095
from .types import LockUserRequest
@@ -128,6 +133,8 @@
128133
"UserStatus",
129134
"UserType",
130135
"QuotumLimit",
136+
"ListUserConnectionsResponseConnectionConnectedOrganization",
137+
"ListUserConnectionsResponseConnectionConnectedUser",
131138
"JWT",
132139
"RuleSpecs",
133140
"CreateUserRequestMember",
@@ -141,6 +148,7 @@
141148
"Quotum",
142149
"Rule",
143150
"SSHKey",
151+
"ListUserConnectionsResponseConnection",
144152
"User",
145153
"AddGroupMemberRequest",
146154
"AddGroupMembersRequest",
@@ -194,6 +202,8 @@
194202
"ListRulesResponse",
195203
"ListSSHKeysRequest",
196204
"ListSSHKeysResponse",
205+
"ListUserConnectionsRequest",
206+
"ListUserConnectionsResponse",
197207
"ListUsersRequest",
198208
"ListUsersResponse",
199209
"LockUserRequest",

scaleway/scaleway/iam/v1alpha1/api.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
ListQuotaResponse,
5353
ListRulesResponse,
5454
ListSSHKeysResponse,
55+
ListUserConnectionsResponse,
5556
ListUsersResponse,
5657
Log,
5758
MFAOTP,
@@ -101,6 +102,7 @@
101102
unmarshal_ListQuotaResponse,
102103
unmarshal_ListRulesResponse,
103104
unmarshal_ListSSHKeysResponse,
105+
unmarshal_ListUserConnectionsResponse,
104106
unmarshal_ListUsersResponse,
105107
unmarshal_MFAOTP,
106108
unmarshal_OrganizationSecuritySettings,
@@ -851,6 +853,33 @@ def list_grace_periods(
851853
self._throw_on_error(res)
852854
return unmarshal_ListGracePeriodsResponse(res.json())
853855

856+
def list_user_connections(
857+
self,
858+
*,
859+
user_id: str,
860+
) -> ListUserConnectionsResponse:
861+
"""
862+
:param user_id: ID of the user to list connections for.
863+
:return: :class:`ListUserConnectionsResponse <ListUserConnectionsResponse>`
864+
865+
Usage:
866+
::
867+
868+
result = api.list_user_connections(
869+
user_id="example",
870+
)
871+
"""
872+
873+
param_user_id = validate_path_param("user_id", user_id)
874+
875+
res = self._request(
876+
"GET",
877+
f"/iam/v1alpha1/users/{param_user_id}/connections",
878+
)
879+
880+
self._throw_on_error(res)
881+
return unmarshal_ListUserConnectionsResponse(res.json())
882+
854883
def list_applications(
855884
self,
856885
*,

0 commit comments

Comments
 (0)