CheckmarxPythonSDK 1.7.8__py3-none-any.whl → 1.7.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CheckmarxPythonSDK/CxODataApiSDK/Utilities.py +1 -1
- CheckmarxPythonSDK/CxODataApiSDK/config.py +7 -2
- CheckmarxPythonSDK/CxOne/KeycloakAPI/ClientRoleMappingsApi.py +8 -5
- CheckmarxPythonSDK/CxOne/KeycloakAPI/ClientRolesApi.py +17 -18
- CheckmarxPythonSDK/CxOne/KeycloakAPI/ClientScopesApi.py +3 -1
- CheckmarxPythonSDK/CxOne/KeycloakAPI/ClientsApi.py +33 -14
- CheckmarxPythonSDK/CxOne/KeycloakAPI/ComponentApi.py +2 -2
- CheckmarxPythonSDK/CxOne/KeycloakAPI/GroupsApi.py +8 -8
- CheckmarxPythonSDK/CxOne/KeycloakAPI/RoleMapperApi.py +118 -40
- CheckmarxPythonSDK/CxOne/KeycloakAPI/RolesApi.py +266 -134
- CheckmarxPythonSDK/CxOne/KeycloakAPI/RolesByIdApi.py +103 -43
- CheckmarxPythonSDK/CxOne/KeycloakAPI/ScopeMappingsApi.py +328 -114
- CheckmarxPythonSDK/CxOne/KeycloakAPI/UsersApi.py +299 -97
- CheckmarxPythonSDK/CxOne/config.py +9 -2
- CheckmarxPythonSDK/CxRestAPISDK/config.py +7 -2
- CheckmarxPythonSDK/__init__.py +3 -17
- CheckmarxPythonSDK/__version__.py +1 -1
- CheckmarxPythonSDK/configuration.py +1 -1
- CheckmarxPythonSDK/logger_setup.py +64 -0
- {checkmarxpythonsdk-1.7.8.dist-info → checkmarxpythonsdk-1.7.9.dist-info}/METADATA +1 -1
- {checkmarxpythonsdk-1.7.8.dist-info → checkmarxpythonsdk-1.7.9.dist-info}/RECORD +24 -23
- {checkmarxpythonsdk-1.7.8.dist-info → checkmarxpythonsdk-1.7.9.dist-info}/WHEEL +1 -1
- {checkmarxpythonsdk-1.7.8.dist-info → checkmarxpythonsdk-1.7.9.dist-info}/licenses/LICENSE +0 -0
- {checkmarxpythonsdk-1.7.8.dist-info → checkmarxpythonsdk-1.7.9.dist-info}/top_level.txt +0 -0
|
@@ -206,7 +206,7 @@ def get_result(project, filter_false_positive=False, threshold=0):
|
|
|
206
206
|
"ScanId": last_scan_id,
|
|
207
207
|
"DirectLink": f"{ResultsODataAPI().api_client.configuration.server_base_url}/cxwebclient"
|
|
208
208
|
f"/ViewerMain.aspx?scanid={last_scan_id}&projectid={project_id}"
|
|
209
|
-
f"&pathid={result.get(
|
|
209
|
+
f"&pathid={result.get('PathId')}"
|
|
210
210
|
}
|
|
211
211
|
)
|
|
212
212
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from CheckmarxPythonSDK.configuration import Configuration
|
|
2
2
|
from CheckmarxPythonSDK.utilities.configUtility import get_config
|
|
3
|
+
from CheckmarxPythonSDK.logger_setup import set_module_logger_level
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
def construct_configuration() -> Configuration:
|
|
@@ -20,13 +21,14 @@ def construct_configuration() -> Configuration:
|
|
|
20
21
|
"verify": True,
|
|
21
22
|
"cert": None,
|
|
22
23
|
"proxy": None,
|
|
24
|
+
"logging_level": "ERROR",
|
|
23
25
|
}
|
|
24
26
|
old_config = get_config(config_default=config_default, section="checkmarx", prefix="cxsast_")
|
|
25
27
|
new_config = get_config(config_default=config_default, section="CxSAST", prefix="cxsast_")
|
|
26
28
|
config = old_config
|
|
27
29
|
if new_config.get("base_url"):
|
|
28
30
|
config = new_config
|
|
29
|
-
|
|
31
|
+
configuration = Configuration(
|
|
30
32
|
server_base_url=config.get("base_url"),
|
|
31
33
|
token_url=f"{config.get('base_url')}/cxrestapi/auth/identity/connect/token",
|
|
32
34
|
username=config.get("username"),
|
|
@@ -41,5 +43,8 @@ def construct_configuration() -> Configuration:
|
|
|
41
43
|
proxies={
|
|
42
44
|
"http": config.get("proxy"),
|
|
43
45
|
"https": config.get("proxy"),
|
|
44
|
-
}
|
|
46
|
+
},
|
|
47
|
+
logging_level=config.get("logging_level"),
|
|
45
48
|
)
|
|
49
|
+
set_module_logger_level("CxODataApiSDK", configuration.logging_level)
|
|
50
|
+
return configuration
|
|
@@ -197,7 +197,7 @@ class ClientRoleMappingsApi:
|
|
|
197
197
|
realm: str,
|
|
198
198
|
id: str,
|
|
199
199
|
client: str,
|
|
200
|
-
|
|
200
|
+
role_representations: List[RoleRepresentation]
|
|
201
201
|
) -> bool:
|
|
202
202
|
"""
|
|
203
203
|
Add client-level roles to the user role mapping
|
|
@@ -206,7 +206,7 @@ class ClientRoleMappingsApi:
|
|
|
206
206
|
realm (str): [required]
|
|
207
207
|
id (str): [required]
|
|
208
208
|
client (str): [required]
|
|
209
|
-
|
|
209
|
+
role_representations (List[RoleRepresentation]): Request body data [required]
|
|
210
210
|
|
|
211
211
|
Returns:
|
|
212
212
|
bool
|
|
@@ -217,16 +217,17 @@ class ClientRoleMappingsApi:
|
|
|
217
217
|
relative_url = f"{api_url}/{realm}/users/{id}/role-mappings/clients/{client}"
|
|
218
218
|
response = self.api_client.post_request(
|
|
219
219
|
relative_url=relative_url,
|
|
220
|
-
json=role_representation.to_dict(),
|
|
220
|
+
json=[role_representation.to_dict() for role_representation in role_representations],
|
|
221
221
|
is_iam=True
|
|
222
222
|
)
|
|
223
|
-
return response.status_code ==
|
|
223
|
+
return response.status_code == 204
|
|
224
224
|
|
|
225
225
|
def delete_user_role_mappings_client(
|
|
226
226
|
self,
|
|
227
227
|
realm: str,
|
|
228
228
|
id: str,
|
|
229
|
-
client: str
|
|
229
|
+
client: str,
|
|
230
|
+
role_representations: List[RoleRepresentation]
|
|
230
231
|
) -> bool:
|
|
231
232
|
"""
|
|
232
233
|
Delete client-level roles from user role mapping
|
|
@@ -235,6 +236,7 @@ class ClientRoleMappingsApi:
|
|
|
235
236
|
realm (str): [required]
|
|
236
237
|
id (str): [required]
|
|
237
238
|
client (str): [required]
|
|
239
|
+
role_representations (List[RoleRepresentation]): Request body data [required]
|
|
238
240
|
|
|
239
241
|
Returns:
|
|
240
242
|
bool
|
|
@@ -245,6 +247,7 @@ class ClientRoleMappingsApi:
|
|
|
245
247
|
relative_url = f"{api_url}/{realm}/users/{id}/role-mappings/clients/{client}"
|
|
246
248
|
response = self.api_client.delete_request(
|
|
247
249
|
relative_url=relative_url,
|
|
250
|
+
json=[role_representation.to_dict() for role_representation in role_representations],
|
|
248
251
|
is_iam=True
|
|
249
252
|
)
|
|
250
253
|
return response.status_code == 204
|
|
@@ -19,9 +19,9 @@ class ClientRolesApi:
|
|
|
19
19
|
self,
|
|
20
20
|
realm: str,
|
|
21
21
|
id: str,
|
|
22
|
-
brief_representation:
|
|
23
|
-
first: int =
|
|
24
|
-
max: int =
|
|
22
|
+
brief_representation: bool = False,
|
|
23
|
+
first: int = 0,
|
|
24
|
+
max: int = 100,
|
|
25
25
|
search: str = None
|
|
26
26
|
) -> List[RoleRepresentation]:
|
|
27
27
|
"""
|
|
@@ -30,10 +30,10 @@ class ClientRolesApi:
|
|
|
30
30
|
Args:
|
|
31
31
|
realm (str): [required]
|
|
32
32
|
id (str): [required]
|
|
33
|
-
brief_representation (
|
|
34
|
-
first (int):
|
|
35
|
-
max (int):
|
|
36
|
-
search (str):
|
|
33
|
+
brief_representation (bool): [optional]
|
|
34
|
+
first (int): [optional]
|
|
35
|
+
max (int): [optional]
|
|
36
|
+
search (str): [optional]
|
|
37
37
|
|
|
38
38
|
Returns:
|
|
39
39
|
List[RoleRepresentation]
|
|
@@ -48,7 +48,6 @@ class ClientRolesApi:
|
|
|
48
48
|
"search": search
|
|
49
49
|
}
|
|
50
50
|
relative_url = f"{api_url}/{realm}/clients/{id}/roles"
|
|
51
|
-
|
|
52
51
|
response = self.api_client.get_request(
|
|
53
52
|
relative_url=relative_url,
|
|
54
53
|
params=params
|
|
@@ -336,8 +335,8 @@ class ClientRolesApi:
|
|
|
336
335
|
id: str,
|
|
337
336
|
role_name: str,
|
|
338
337
|
brief_representation: bool = None,
|
|
339
|
-
first: int =
|
|
340
|
-
max: int =
|
|
338
|
+
first: int = 0,
|
|
339
|
+
max: int = 100
|
|
341
340
|
) -> List[GroupRepresentation]:
|
|
342
341
|
"""
|
|
343
342
|
Returns a stream of groups that have the specified role name
|
|
@@ -434,8 +433,8 @@ class ClientRolesApi:
|
|
|
434
433
|
realm: str,
|
|
435
434
|
id: str,
|
|
436
435
|
role_name: str,
|
|
437
|
-
first: int =
|
|
438
|
-
max: int =
|
|
436
|
+
first: int = 0,
|
|
437
|
+
max: int = 100
|
|
439
438
|
) -> List[UserRepresentation]:
|
|
440
439
|
"""
|
|
441
440
|
Returns a stream of users that have the specified role name.
|
|
@@ -468,8 +467,8 @@ class ClientRolesApi:
|
|
|
468
467
|
self,
|
|
469
468
|
realm: str,
|
|
470
469
|
brief_representation: str = None,
|
|
471
|
-
first: int =
|
|
472
|
-
max: int =
|
|
470
|
+
first: int = 0,
|
|
471
|
+
max: int = 100,
|
|
473
472
|
search: str = None
|
|
474
473
|
) -> List[RoleRepresentation]:
|
|
475
474
|
"""
|
|
@@ -767,8 +766,8 @@ class ClientRolesApi:
|
|
|
767
766
|
realm: str,
|
|
768
767
|
role_name: str,
|
|
769
768
|
brief_representation: bool = None,
|
|
770
|
-
first: int =
|
|
771
|
-
max: int =
|
|
769
|
+
first: int = 0,
|
|
770
|
+
max: int = 100
|
|
772
771
|
) -> List[GroupRepresentation]:
|
|
773
772
|
"""
|
|
774
773
|
Returns a stream of groups that have the specified role name
|
|
@@ -862,8 +861,8 @@ class ClientRolesApi:
|
|
|
862
861
|
self,
|
|
863
862
|
realm: str,
|
|
864
863
|
role_name: str,
|
|
865
|
-
first: int =
|
|
866
|
-
max: int =
|
|
864
|
+
first: int = 0,
|
|
865
|
+
max: int = 100
|
|
867
866
|
) -> List[UserRepresentation]:
|
|
868
867
|
"""
|
|
869
868
|
Returns a stream of users that have the specified role name.
|
|
@@ -33,7 +33,9 @@ class ClientScopesApi:
|
|
|
33
33
|
relative_url=relative_url,
|
|
34
34
|
is_iam=True
|
|
35
35
|
)
|
|
36
|
-
return [
|
|
36
|
+
return [
|
|
37
|
+
ClientScopeRepresentation.from_dict(item) for item in response.json()
|
|
38
|
+
]
|
|
37
39
|
|
|
38
40
|
def post_client_scopes(
|
|
39
41
|
self,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
1
3
|
from CheckmarxPythonSDK.api_client import ApiClient
|
|
2
4
|
from CheckmarxPythonSDK.CxOne.config import construct_configuration
|
|
3
5
|
from typing import Dict, List, Any, Optional
|
|
@@ -14,6 +16,8 @@ from .dto.UserRepresentation import UserRepresentation
|
|
|
14
16
|
from .dto.UserSessionRepresentation import UserSessionRepresentation
|
|
15
17
|
from .api_url import api_url
|
|
16
18
|
|
|
19
|
+
logger = logging.getLogger("CheckmarxPythonSDK.CxOne.KeycloakAPI.ClientsApi")
|
|
20
|
+
|
|
17
21
|
|
|
18
22
|
class ClientsApi:
|
|
19
23
|
def __init__(self, api_client: ApiClient = None):
|
|
@@ -26,8 +30,8 @@ class ClientsApi:
|
|
|
26
30
|
self,
|
|
27
31
|
realm: str,
|
|
28
32
|
client_id: str = None,
|
|
29
|
-
first:
|
|
30
|
-
max:
|
|
33
|
+
first: int = 0,
|
|
34
|
+
max: int = 100,
|
|
31
35
|
q: str = None,
|
|
32
36
|
search: bool = None,
|
|
33
37
|
viewable_only: str = None
|
|
@@ -38,8 +42,8 @@ class ClientsApi:
|
|
|
38
42
|
Args:
|
|
39
43
|
realm (str): [required]
|
|
40
44
|
client_id (str): filter by clientId
|
|
41
|
-
first (
|
|
42
|
-
max (
|
|
45
|
+
first (int): the first result
|
|
46
|
+
max (int): the max results to return
|
|
43
47
|
q (str):
|
|
44
48
|
search (bool): whether this is a search query or a getClientById query
|
|
45
49
|
viewable_only (str): filter clients that cannot be viewed in full by admin
|
|
@@ -87,12 +91,14 @@ class ClientsApi:
|
|
|
87
91
|
Relative path: /{realm}/clients
|
|
88
92
|
"""
|
|
89
93
|
relative_url = f"{api_url}/{realm}/clients"
|
|
94
|
+
print(f"Post request to {relative_url}")
|
|
95
|
+
print(f"Request body: {client_representation.to_dict()}")
|
|
90
96
|
response = self.api_client.post_request(
|
|
91
97
|
relative_url=relative_url,
|
|
92
98
|
json=client_representation.to_dict(),
|
|
93
99
|
is_iam=True
|
|
94
100
|
)
|
|
95
|
-
return response.status_code ==
|
|
101
|
+
return response.status_code == 201
|
|
96
102
|
|
|
97
103
|
def get_client_by_realm_by_id(
|
|
98
104
|
self,
|
|
@@ -145,7 +151,7 @@ class ClientsApi:
|
|
|
145
151
|
json=client_representation.to_dict(),
|
|
146
152
|
is_iam=True
|
|
147
153
|
)
|
|
148
|
-
return response.status_code ==
|
|
154
|
+
return response.status_code == 204
|
|
149
155
|
|
|
150
156
|
def delete_client_by_realm_by_id(
|
|
151
157
|
self,
|
|
@@ -165,11 +171,24 @@ class ClientsApi:
|
|
|
165
171
|
URL:
|
|
166
172
|
Relative path: /{realm}/clients/{id}
|
|
167
173
|
"""
|
|
174
|
+
if id in ['ast-app', 'cb-app', 'realm-management', 'superset-kpi']:
|
|
175
|
+
logger.error(
|
|
176
|
+
"Forbid to delete builtin-in clients ast-app, cb-app, "
|
|
177
|
+
"realm-management, superset-kpi which are system clients"
|
|
178
|
+
)
|
|
179
|
+
return False
|
|
180
|
+
if id.startswith(tuple(['saml-helper-'])):
|
|
181
|
+
logger.error(
|
|
182
|
+
"Forbid to delete clients with saml-helper- prefix, "
|
|
183
|
+
"which are intended for internal use"
|
|
184
|
+
)
|
|
185
|
+
return False
|
|
168
186
|
relative_url = f"{api_url}/{realm}/clients/{id}"
|
|
169
187
|
response = self.api_client.delete_request(
|
|
170
188
|
relative_url=relative_url,
|
|
171
189
|
is_iam=True
|
|
172
190
|
)
|
|
191
|
+
logger.info(f"Delete client {id} successful in realm {realm}")
|
|
173
192
|
return response.status_code == 204
|
|
174
193
|
|
|
175
194
|
def get_client_secret(
|
|
@@ -700,8 +719,8 @@ class ClientsApi:
|
|
|
700
719
|
self,
|
|
701
720
|
realm: str,
|
|
702
721
|
id: str,
|
|
703
|
-
first:
|
|
704
|
-
max:
|
|
722
|
+
first: int = 0,
|
|
723
|
+
max: int = 100
|
|
705
724
|
) -> List[UserSessionRepresentation]:
|
|
706
725
|
"""
|
|
707
726
|
Get offline sessions for client Returns a list of offline user sessions
|
|
@@ -710,8 +729,8 @@ class ClientsApi:
|
|
|
710
729
|
Args:
|
|
711
730
|
realm (str): [required]
|
|
712
731
|
id (str): [required]
|
|
713
|
-
first (
|
|
714
|
-
max (
|
|
732
|
+
first (int): Paging offset
|
|
733
|
+
max (int): Maximum results size (defaults to 100)
|
|
715
734
|
|
|
716
735
|
Returns:
|
|
717
736
|
List[UserSessionRepresentation]
|
|
@@ -930,8 +949,8 @@ class ClientsApi:
|
|
|
930
949
|
def get_client_user_sessions(self,
|
|
931
950
|
realm: str,
|
|
932
951
|
id: str,
|
|
933
|
-
first:
|
|
934
|
-
max:
|
|
952
|
+
first: int = 0,
|
|
953
|
+
max: int = 100
|
|
935
954
|
) -> List[UserSessionRepresentation]:
|
|
936
955
|
"""
|
|
937
956
|
Get user sessions for client Returns a list of user sessions
|
|
@@ -940,8 +959,8 @@ class ClientsApi:
|
|
|
940
959
|
Args:
|
|
941
960
|
realm (str): [required]
|
|
942
961
|
id (str): [required]
|
|
943
|
-
first (
|
|
944
|
-
max (
|
|
962
|
+
first (int): Paging offset
|
|
963
|
+
max (int): Maximum results size (defaults to 100)
|
|
945
964
|
|
|
946
965
|
Returns:
|
|
947
966
|
List[UserSessionRepresentation]
|
|
@@ -68,7 +68,7 @@ class ComponentApi:
|
|
|
68
68
|
json=component_representation.to_dict(),
|
|
69
69
|
is_iam=True
|
|
70
70
|
)
|
|
71
|
-
return response.status_code ==
|
|
71
|
+
return response.status_code == 204
|
|
72
72
|
|
|
73
73
|
def get_component(self,
|
|
74
74
|
realm: str,
|
|
@@ -114,7 +114,7 @@ class ComponentApi:
|
|
|
114
114
|
json=component_representation.to_dict(),
|
|
115
115
|
is_iam=True
|
|
116
116
|
)
|
|
117
|
-
return response.status_code ==
|
|
117
|
+
return response.status_code == 204
|
|
118
118
|
|
|
119
119
|
def delete_component(self,
|
|
120
120
|
realm: str,
|
|
@@ -19,8 +19,8 @@ class GroupsApi:
|
|
|
19
19
|
realm: str,
|
|
20
20
|
brief_representation: str = None,
|
|
21
21
|
exact: str = None,
|
|
22
|
-
first:
|
|
23
|
-
max:
|
|
22
|
+
first: int = 0,
|
|
23
|
+
max: int = 100,
|
|
24
24
|
populate_hierarchy: str = None,
|
|
25
25
|
q: str = None,
|
|
26
26
|
search: str = None
|
|
@@ -32,8 +32,8 @@ class GroupsApi:
|
|
|
32
32
|
realm (str): [required]
|
|
33
33
|
brief_representation (str):
|
|
34
34
|
exact (str):
|
|
35
|
-
first (
|
|
36
|
-
max (
|
|
35
|
+
first (int):
|
|
36
|
+
max (int):
|
|
37
37
|
populate_hierarchy (str):
|
|
38
38
|
q (str):
|
|
39
39
|
search (str):
|
|
@@ -201,8 +201,8 @@ class GroupsApi:
|
|
|
201
201
|
realm: str,
|
|
202
202
|
id: str,
|
|
203
203
|
brief_representation: str = None,
|
|
204
|
-
first:
|
|
205
|
-
max:
|
|
204
|
+
first: int = 0,
|
|
205
|
+
max: int = 100
|
|
206
206
|
) -> List[GroupRepresentation]:
|
|
207
207
|
"""
|
|
208
208
|
Return a paginated list of subgroups that have a parent group
|
|
@@ -212,8 +212,8 @@ class GroupsApi:
|
|
|
212
212
|
realm (str): [required]
|
|
213
213
|
id (str): [required]
|
|
214
214
|
brief_representation (str):
|
|
215
|
-
first (
|
|
216
|
-
max (
|
|
215
|
+
first (int):
|
|
216
|
+
max (int):
|
|
217
217
|
|
|
218
218
|
Returns:
|
|
219
219
|
List[GroupRepresentation]
|
|
@@ -13,7 +13,11 @@ class RoleMapperApi:
|
|
|
13
13
|
api_client = ApiClient(configuration=configuration)
|
|
14
14
|
self.api_client = api_client
|
|
15
15
|
|
|
16
|
-
def get_group_role_mappings(
|
|
16
|
+
def get_group_role_mappings(
|
|
17
|
+
self,
|
|
18
|
+
realm: str,
|
|
19
|
+
id: str
|
|
20
|
+
) -> MappingsRepresentation:
|
|
17
21
|
"""
|
|
18
22
|
Get role mappings
|
|
19
23
|
|
|
@@ -28,11 +32,16 @@ class RoleMapperApi:
|
|
|
28
32
|
Relative path: /{realm}/groups/{id}/role-mappings
|
|
29
33
|
"""
|
|
30
34
|
relative_url = f"{api_url}/{realm}/groups/{id}/role-mappings"
|
|
31
|
-
response = self.api_client.get_request(
|
|
35
|
+
response = self.api_client.get_request(
|
|
36
|
+
relative_url=relative_url,
|
|
37
|
+
is_iam=True
|
|
38
|
+
)
|
|
32
39
|
return MappingsRepresentation.from_dict(response.json())
|
|
33
40
|
|
|
34
41
|
def get_group_role_mappings_realm(
|
|
35
|
-
|
|
42
|
+
self,
|
|
43
|
+
realm: str,
|
|
44
|
+
id: str
|
|
36
45
|
) -> List[RoleRepresentation]:
|
|
37
46
|
"""
|
|
38
47
|
Get realm-level role mappings
|
|
@@ -48,19 +57,27 @@ class RoleMapperApi:
|
|
|
48
57
|
Relative path: /{realm}/groups/{id}/role-mappings/realm
|
|
49
58
|
"""
|
|
50
59
|
relative_url = f"{api_url}/{realm}/groups/{id}/role-mappings/realm"
|
|
51
|
-
response = self.api_client.get_request(
|
|
52
|
-
|
|
60
|
+
response = self.api_client.get_request(
|
|
61
|
+
relative_url=relative_url,
|
|
62
|
+
is_iam=True
|
|
63
|
+
)
|
|
64
|
+
return [
|
|
65
|
+
RoleRepresentation.from_dict(item) for item in response.json()
|
|
66
|
+
]
|
|
53
67
|
|
|
54
68
|
def post_group_role_mappings_realm(
|
|
55
|
-
|
|
56
|
-
|
|
69
|
+
self,
|
|
70
|
+
realm: str,
|
|
71
|
+
id: str,
|
|
72
|
+
role_representations: List[RoleRepresentation]
|
|
73
|
+
) -> bool:
|
|
57
74
|
"""
|
|
58
75
|
Add realm-level role mappings to the user
|
|
59
76
|
|
|
60
77
|
Args:
|
|
61
78
|
realm (str): [required]
|
|
62
79
|
id (str): [required]
|
|
63
|
-
|
|
80
|
+
role_representations (List[RoleRepresentation]): Request body data [required]
|
|
64
81
|
|
|
65
82
|
Returns:
|
|
66
83
|
bool
|
|
@@ -70,11 +87,18 @@ class RoleMapperApi:
|
|
|
70
87
|
"""
|
|
71
88
|
relative_url = f"{api_url}/{realm}/groups/{id}/role-mappings/realm"
|
|
72
89
|
response = self.api_client.post_request(
|
|
73
|
-
relative_url=relative_url,
|
|
90
|
+
relative_url=relative_url,
|
|
91
|
+
json=[role_representation.to_dict() for role_representation in role_representations],
|
|
92
|
+
is_iam=True
|
|
74
93
|
)
|
|
75
|
-
return response.status_code ==
|
|
94
|
+
return response.status_code == 204
|
|
76
95
|
|
|
77
|
-
def delete_group_role_mappings_realm(
|
|
96
|
+
def delete_group_role_mappings_realm(
|
|
97
|
+
self,
|
|
98
|
+
realm: str,
|
|
99
|
+
id: str,
|
|
100
|
+
role_representations: List[RoleRepresentation]
|
|
101
|
+
) -> bool:
|
|
78
102
|
"""
|
|
79
103
|
Delete realm-level role mappings
|
|
80
104
|
|
|
@@ -90,13 +114,19 @@ class RoleMapperApi:
|
|
|
90
114
|
"""
|
|
91
115
|
relative_url = f"{api_url}/{realm}/groups/{id}/role-mappings/realm"
|
|
92
116
|
response = self.api_client.delete_request(
|
|
93
|
-
relative_url=relative_url,
|
|
117
|
+
relative_url=relative_url,
|
|
118
|
+
json=[
|
|
119
|
+
role_representation.to_dict() for role_representation in role_representations
|
|
120
|
+
],
|
|
121
|
+
is_iam=True
|
|
94
122
|
)
|
|
95
123
|
return response.status_code == 204
|
|
96
124
|
|
|
97
125
|
def get_group_role_mappings_realm_available(
|
|
98
|
-
|
|
99
|
-
|
|
126
|
+
self,
|
|
127
|
+
realm: str,
|
|
128
|
+
id: str
|
|
129
|
+
) -> List[RoleRepresentation]:
|
|
100
130
|
"""
|
|
101
131
|
Get realm-level roles that can be mapped
|
|
102
132
|
|
|
@@ -115,8 +145,11 @@ class RoleMapperApi:
|
|
|
115
145
|
return [RoleRepresentation.from_dict(item) for item in response.json()]
|
|
116
146
|
|
|
117
147
|
def get_group_role_mappings_realm_composite(
|
|
118
|
-
|
|
119
|
-
|
|
148
|
+
self,
|
|
149
|
+
realm: str,
|
|
150
|
+
id: str,
|
|
151
|
+
brief_representation: bool = None
|
|
152
|
+
) -> List[RoleRepresentation]:
|
|
120
153
|
"""
|
|
121
154
|
Get effective realm-level role mappings This will recurse all composite roles to get the result.
|
|
122
155
|
|
|
@@ -136,9 +169,15 @@ class RoleMapperApi:
|
|
|
136
169
|
response = self.api_client.get_request(
|
|
137
170
|
relative_url=relative_url, params=params, is_iam=True
|
|
138
171
|
)
|
|
139
|
-
return [
|
|
140
|
-
|
|
141
|
-
|
|
172
|
+
return [
|
|
173
|
+
RoleRepresentation.from_dict(item) for item in response.json()
|
|
174
|
+
]
|
|
175
|
+
|
|
176
|
+
def get_user_role_mappings(
|
|
177
|
+
self,
|
|
178
|
+
realm: str,
|
|
179
|
+
id: str
|
|
180
|
+
) -> MappingsRepresentation:
|
|
142
181
|
"""
|
|
143
182
|
Get role mappings
|
|
144
183
|
|
|
@@ -153,12 +192,17 @@ class RoleMapperApi:
|
|
|
153
192
|
Relative path: /{realm}/users/{id}/role-mappings
|
|
154
193
|
"""
|
|
155
194
|
relative_url = f"{api_url}/{realm}/users/{id}/role-mappings"
|
|
156
|
-
response = self.api_client.get_request(
|
|
195
|
+
response = self.api_client.get_request(
|
|
196
|
+
relative_url=relative_url,
|
|
197
|
+
is_iam=True
|
|
198
|
+
)
|
|
157
199
|
return MappingsRepresentation.from_dict(response.json())
|
|
158
200
|
|
|
159
201
|
def get_user_role_mappings_realm(
|
|
160
|
-
|
|
161
|
-
|
|
202
|
+
self,
|
|
203
|
+
realm: str,
|
|
204
|
+
id: str
|
|
205
|
+
) -> List[RoleRepresentation]:
|
|
162
206
|
"""
|
|
163
207
|
Get realm-level role mappings
|
|
164
208
|
|
|
@@ -173,19 +217,27 @@ class RoleMapperApi:
|
|
|
173
217
|
Relative path: /{realm}/users/{id}/role-mappings/realm
|
|
174
218
|
"""
|
|
175
219
|
relative_url = f"{api_url}/{realm}/users/{id}/role-mappings/realm"
|
|
176
|
-
response = self.api_client.get_request(
|
|
177
|
-
|
|
220
|
+
response = self.api_client.get_request(
|
|
221
|
+
relative_url=relative_url,
|
|
222
|
+
is_iam=True
|
|
223
|
+
)
|
|
224
|
+
return [
|
|
225
|
+
RoleRepresentation.from_dict(item) for item in response.json()
|
|
226
|
+
]
|
|
178
227
|
|
|
179
228
|
def post_user_role_mappings_realm(
|
|
180
|
-
|
|
181
|
-
|
|
229
|
+
self,
|
|
230
|
+
realm: str,
|
|
231
|
+
id: str,
|
|
232
|
+
role_representations: List[RoleRepresentation]
|
|
233
|
+
) -> bool:
|
|
182
234
|
"""
|
|
183
235
|
Add realm-level role mappings to the user
|
|
184
236
|
|
|
185
237
|
Args:
|
|
186
238
|
realm (str): [required]
|
|
187
239
|
id (str): [required]
|
|
188
|
-
|
|
240
|
+
role_representations (List[RoleRepresentation]): Request body data [required]
|
|
189
241
|
|
|
190
242
|
Returns:
|
|
191
243
|
bool
|
|
@@ -195,17 +247,25 @@ class RoleMapperApi:
|
|
|
195
247
|
"""
|
|
196
248
|
relative_url = f"{api_url}/{realm}/users/{id}/role-mappings/realm"
|
|
197
249
|
response = self.api_client.post_request(
|
|
198
|
-
relative_url=relative_url,
|
|
250
|
+
relative_url=relative_url,
|
|
251
|
+
json=[item.to_dict() for item in role_representations],
|
|
252
|
+
is_iam=True
|
|
199
253
|
)
|
|
200
|
-
return response.status_code ==
|
|
254
|
+
return response.status_code == 204
|
|
201
255
|
|
|
202
|
-
def delete_user_role_mappings_realm(
|
|
256
|
+
def delete_user_role_mappings_realm(
|
|
257
|
+
self,
|
|
258
|
+
realm: str,
|
|
259
|
+
id: str,
|
|
260
|
+
role_representations: List[RoleRepresentation]
|
|
261
|
+
) -> bool:
|
|
203
262
|
"""
|
|
204
263
|
Delete realm-level role mappings
|
|
205
264
|
|
|
206
265
|
Args:
|
|
207
266
|
realm (str): [required]
|
|
208
267
|
id (str): [required]
|
|
268
|
+
role_representations (List[RoleRepresentation]): Request body data [required]
|
|
209
269
|
|
|
210
270
|
Returns:
|
|
211
271
|
bool
|
|
@@ -215,13 +275,17 @@ class RoleMapperApi:
|
|
|
215
275
|
"""
|
|
216
276
|
relative_url = f"{api_url}/{realm}/users/{id}/role-mappings/realm"
|
|
217
277
|
response = self.api_client.delete_request(
|
|
218
|
-
relative_url=relative_url,
|
|
278
|
+
relative_url=relative_url,
|
|
279
|
+
json=[item.to_dict() for item in role_representations],
|
|
280
|
+
is_iam=True
|
|
219
281
|
)
|
|
220
282
|
return response.status_code == 204
|
|
221
283
|
|
|
222
284
|
def get_user_role_mappings_realm_available(
|
|
223
|
-
|
|
224
|
-
|
|
285
|
+
self,
|
|
286
|
+
realm: str,
|
|
287
|
+
id: str
|
|
288
|
+
) -> List[RoleRepresentation]:
|
|
225
289
|
"""
|
|
226
290
|
Get realm-level roles that can be mapped
|
|
227
291
|
|
|
@@ -236,12 +300,20 @@ class RoleMapperApi:
|
|
|
236
300
|
Relative path: /{realm}/users/{id}/role-mappings/realm/available
|
|
237
301
|
"""
|
|
238
302
|
relative_url = f"{api_url}/{realm}/users/{id}/role-mappings/realm/available"
|
|
239
|
-
response = self.api_client.get_request(
|
|
240
|
-
|
|
303
|
+
response = self.api_client.get_request(
|
|
304
|
+
relative_url=relative_url,
|
|
305
|
+
is_iam=True
|
|
306
|
+
)
|
|
307
|
+
return [
|
|
308
|
+
RoleRepresentation.from_dict(item) for item in response.json()
|
|
309
|
+
]
|
|
241
310
|
|
|
242
311
|
def get_user_role_mappings_realm_composite(
|
|
243
|
-
|
|
244
|
-
|
|
312
|
+
self,
|
|
313
|
+
realm: str,
|
|
314
|
+
id: str,
|
|
315
|
+
brief_representation: bool = False
|
|
316
|
+
) -> List[RoleRepresentation]:
|
|
245
317
|
"""
|
|
246
318
|
Get effective realm-level role mappings This will recurse all composite roles to get the result.
|
|
247
319
|
|
|
@@ -256,9 +328,15 @@ class RoleMapperApi:
|
|
|
256
328
|
URL:
|
|
257
329
|
Relative path: /{realm}/users/{id}/role-mappings/realm/composite
|
|
258
330
|
"""
|
|
259
|
-
params = {
|
|
331
|
+
params = {
|
|
332
|
+
"briefRepresentation": brief_representation
|
|
333
|
+
}
|
|
260
334
|
relative_url = f"{api_url}/{realm}/users/{id}/role-mappings/realm/composite"
|
|
261
335
|
response = self.api_client.get_request(
|
|
262
|
-
relative_url=relative_url,
|
|
336
|
+
relative_url=relative_url,
|
|
337
|
+
params=params,
|
|
338
|
+
is_iam=True
|
|
263
339
|
)
|
|
264
|
-
return [
|
|
340
|
+
return [
|
|
341
|
+
RoleRepresentation.from_dict(item) for item in response.json()
|
|
342
|
+
]
|