CheckmarxPythonSDK 1.7.9__py3-none-any.whl → 1.8.0__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/CxOne/KeycloakAPI/ClientsApi.py +3 -3
- CheckmarxPythonSDK/CxOne/KeycloakAPI/GroupsApi.py +2 -2
- CheckmarxPythonSDK/CxOne/KeycloakAPI/UsersApi.py +1 -1
- CheckmarxPythonSDK/CxOne/accessControlAPI.py +143 -48
- CheckmarxPythonSDK/CxOne/accessManagementAPI.py +1229 -463
- CheckmarxPythonSDK/CxOne/apisecAPI.py +429 -5
- CheckmarxPythonSDK/CxOne/config.py +7 -1
- CheckmarxPythonSDK/CxOne/dto/EntityRolesRequest.py +4 -2
- CheckmarxPythonSDK/CxOne/dto/MultipleAssignmentInput.py +7 -4
- CheckmarxPythonSDK/CxOne/projectsAPI.py +527 -174
- CheckmarxPythonSDK/CxOne/repoManagerAPI.py +267 -19
- CheckmarxPythonSDK/__version__.py +1 -1
- CheckmarxPythonSDK/api_client.py +85 -10
- CheckmarxPythonSDK/configuration.py +3 -0
- CheckmarxPythonSDK/rate_limiter.py +95 -0
- {checkmarxpythonsdk-1.7.9.dist-info → checkmarxpythonsdk-1.8.0.dist-info}/METADATA +1 -1
- {checkmarxpythonsdk-1.7.9.dist-info → checkmarxpythonsdk-1.8.0.dist-info}/RECORD +20 -19
- {checkmarxpythonsdk-1.7.9.dist-info → checkmarxpythonsdk-1.8.0.dist-info}/WHEEL +0 -0
- {checkmarxpythonsdk-1.7.9.dist-info → checkmarxpythonsdk-1.8.0.dist-info}/licenses/LICENSE +0 -0
- {checkmarxpythonsdk-1.7.9.dist-info → checkmarxpythonsdk-1.8.0.dist-info}/top_level.txt +0 -0
|
@@ -2,7 +2,7 @@ import logging
|
|
|
2
2
|
|
|
3
3
|
from CheckmarxPythonSDK.api_client import ApiClient
|
|
4
4
|
from CheckmarxPythonSDK.CxOne.config import construct_configuration
|
|
5
|
-
from typing import Dict, List, Any, Optional
|
|
5
|
+
from typing import Dict, List, Any, Optional, Union
|
|
6
6
|
from .dto.AccessToken import AccessToken
|
|
7
7
|
from .dto.ClientRepresentation import ClientRepresentation
|
|
8
8
|
from .dto.ClientScopeRepresentation import ClientScopeRepresentation
|
|
@@ -16,11 +16,11 @@ from .dto.UserRepresentation import UserRepresentation
|
|
|
16
16
|
from .dto.UserSessionRepresentation import UserSessionRepresentation
|
|
17
17
|
from .api_url import api_url
|
|
18
18
|
|
|
19
|
-
logger = logging.getLogger(
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
class ClientsApi:
|
|
23
|
-
def __init__(self, api_client: ApiClient = None):
|
|
23
|
+
def __init__(self, api_client: Optional[ApiClient] = None):
|
|
24
24
|
if api_client is None:
|
|
25
25
|
configuration = construct_configuration()
|
|
26
26
|
api_client = ApiClient(configuration=configuration)
|
|
@@ -17,7 +17,7 @@ class GroupsApi:
|
|
|
17
17
|
def get_groups_by_realm(
|
|
18
18
|
self,
|
|
19
19
|
realm: str,
|
|
20
|
-
brief_representation:
|
|
20
|
+
brief_representation: bool = False,
|
|
21
21
|
exact: str = None,
|
|
22
22
|
first: int = 0,
|
|
23
23
|
max: int = 100,
|
|
@@ -30,7 +30,7 @@ class GroupsApi:
|
|
|
30
30
|
|
|
31
31
|
Args:
|
|
32
32
|
realm (str): [required]
|
|
33
|
-
brief_representation (
|
|
33
|
+
brief_representation (bool):
|
|
34
34
|
exact (str):
|
|
35
35
|
first (int):
|
|
36
36
|
max (int):
|
|
@@ -11,7 +11,7 @@ from .dto.UserRepresentation import UserRepresentation
|
|
|
11
11
|
from .dto.UserSessionRepresentation import UserSessionRepresentation
|
|
12
12
|
from .api_url import api_url
|
|
13
13
|
|
|
14
|
-
logger = logging.getLogger(
|
|
14
|
+
logger = logging.getLogger(__name__)
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class UsersApi:
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
from CheckmarxPythonSDK.api_client import ApiClient
|
|
2
2
|
from CheckmarxPythonSDK.CxOne.config import construct_configuration
|
|
3
|
-
from typing import List
|
|
3
|
+
from typing import List, Optional
|
|
4
4
|
from CheckmarxPythonSDK.CxOne.dto import (
|
|
5
|
-
AstIdWithName,
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
AstIdWithName,
|
|
6
|
+
construct_ast_id_with_name,
|
|
7
|
+
AstUser,
|
|
8
|
+
construct_ast_user,
|
|
9
|
+
Role,
|
|
10
|
+
construct_role,
|
|
8
11
|
)
|
|
9
12
|
|
|
10
|
-
api_url = f"/auth/realms"
|
|
11
|
-
|
|
12
13
|
|
|
13
14
|
class AccessControlAPI(object):
|
|
14
15
|
def __init__(self, api_client: ApiClient = None):
|
|
@@ -16,10 +17,15 @@ class AccessControlAPI(object):
|
|
|
16
17
|
configuration = construct_configuration()
|
|
17
18
|
api_client = ApiClient(configuration=configuration)
|
|
18
19
|
self.api_client = api_client
|
|
20
|
+
self.base_url = (
|
|
21
|
+
f"{self.api_client.configuration.iam_base_url}"
|
|
22
|
+
f"/auth/realms"
|
|
23
|
+
)
|
|
24
|
+
self.realm = self.api_client.configuration.tenant_name
|
|
19
25
|
|
|
20
26
|
def get_groups(
|
|
21
27
|
self,
|
|
22
|
-
realm: str,
|
|
28
|
+
realm: str = None,
|
|
23
29
|
group_name: str = None,
|
|
24
30
|
limit: int = 10,
|
|
25
31
|
first: int = 0,
|
|
@@ -30,16 +36,23 @@ class AccessControlAPI(object):
|
|
|
30
36
|
|
|
31
37
|
Args:
|
|
32
38
|
realm (str):
|
|
33
|
-
group_name (str): Used for searching the groups by name
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
group_name (str): Used for searching the groups by name
|
|
40
|
+
or by part of name.
|
|
41
|
+
limit (int): Max amount of returned record. Applied if
|
|
42
|
+
groupName param defined. Default value : 10
|
|
43
|
+
first (int): Element to start from. Always applied.
|
|
44
|
+
Default value : 0
|
|
45
|
+
max_result_size (int): Max number of items. Always applied.
|
|
46
|
+
Default value : 10000
|
|
47
|
+
ids (List[str]): Ids of groups separated with comma. Has
|
|
48
|
+
priority over the groupName parameter
|
|
38
49
|
|
|
39
50
|
Returns:
|
|
40
51
|
List[AstIdWithName]
|
|
41
52
|
"""
|
|
42
|
-
|
|
53
|
+
if realm is None:
|
|
54
|
+
realm = self.realm
|
|
55
|
+
url = f"{self.base_url}/{realm}/pip/groups"
|
|
43
56
|
params = {
|
|
44
57
|
"groupName": group_name,
|
|
45
58
|
"limit": limit,
|
|
@@ -47,11 +60,21 @@ class AccessControlAPI(object):
|
|
|
47
60
|
"max": max_result_size,
|
|
48
61
|
"ids": ids if ids is None else ",".join(ids),
|
|
49
62
|
}
|
|
50
|
-
response = self.api_client.
|
|
63
|
+
response = self.api_client.call_api(
|
|
64
|
+
method="GET",
|
|
65
|
+
url=url,
|
|
66
|
+
params=params,
|
|
67
|
+
)
|
|
51
68
|
item_list = response.json()
|
|
52
|
-
return [
|
|
53
|
-
|
|
54
|
-
|
|
69
|
+
return [
|
|
70
|
+
construct_ast_id_with_name(item) for item in item_list
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
def get_group_by_name(
|
|
74
|
+
self,
|
|
75
|
+
group_name: str,
|
|
76
|
+
realm: str = None,
|
|
77
|
+
) -> Optional[AstIdWithName]:
|
|
55
78
|
"""
|
|
56
79
|
|
|
57
80
|
Args:
|
|
@@ -59,18 +82,25 @@ class AccessControlAPI(object):
|
|
|
59
82
|
group_name (str):
|
|
60
83
|
|
|
61
84
|
Returns:
|
|
62
|
-
|
|
85
|
+
Optional[AstIdWithName]
|
|
63
86
|
"""
|
|
64
87
|
result = None
|
|
65
|
-
|
|
66
|
-
|
|
88
|
+
if realm is None:
|
|
89
|
+
realm = self.realm
|
|
90
|
+
groups = self.get_groups(
|
|
91
|
+
realm=realm,
|
|
92
|
+
group_name=group_name
|
|
93
|
+
)
|
|
94
|
+
one_group = list(filter(
|
|
95
|
+
lambda g: g.name == group_name, groups
|
|
96
|
+
))
|
|
67
97
|
if len(one_group) == 1:
|
|
68
98
|
result = one_group[0]
|
|
69
99
|
return result
|
|
70
100
|
|
|
71
101
|
def get_users(
|
|
72
102
|
self,
|
|
73
|
-
realm: str,
|
|
103
|
+
realm: str = None,
|
|
74
104
|
first: int = 0,
|
|
75
105
|
max_result_size: int = 100,
|
|
76
106
|
search: str = None,
|
|
@@ -92,7 +122,9 @@ class AccessControlAPI(object):
|
|
|
92
122
|
Returns:
|
|
93
123
|
List[AstUser]
|
|
94
124
|
"""
|
|
95
|
-
|
|
125
|
+
if realm is None:
|
|
126
|
+
realm = self.realm
|
|
127
|
+
url = f"{self.base_url}/{realm}/users"
|
|
96
128
|
params = {
|
|
97
129
|
"first": first,
|
|
98
130
|
"max": max_result_size,
|
|
@@ -101,11 +133,21 @@ class AccessControlAPI(object):
|
|
|
101
133
|
"order": order,
|
|
102
134
|
"withoutGroups": without_groups,
|
|
103
135
|
}
|
|
104
|
-
response = self.api_client.
|
|
136
|
+
response = self.api_client.call_api(
|
|
137
|
+
method="GET",
|
|
138
|
+
url=url,
|
|
139
|
+
params=params,
|
|
140
|
+
)
|
|
105
141
|
item_list = response.json()
|
|
106
|
-
return [
|
|
107
|
-
|
|
108
|
-
|
|
142
|
+
return [
|
|
143
|
+
construct_ast_user(item) for item in item_list
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
def get_users_by_groups(
|
|
147
|
+
self,
|
|
148
|
+
group_id: str,
|
|
149
|
+
realm: str = None,
|
|
150
|
+
) -> List[AstUser]:
|
|
109
151
|
"""
|
|
110
152
|
|
|
111
153
|
Args:
|
|
@@ -115,12 +157,22 @@ class AccessControlAPI(object):
|
|
|
115
157
|
Returns:
|
|
116
158
|
List[AstUser]
|
|
117
159
|
"""
|
|
118
|
-
|
|
119
|
-
|
|
160
|
+
if realm is None:
|
|
161
|
+
realm = self.realm
|
|
162
|
+
url = f"{self.base_url}/{realm}/pip/users/group/{group_id}"
|
|
163
|
+
response = self.api_client.call_api(
|
|
164
|
+
method="GET",
|
|
165
|
+
url=url,
|
|
166
|
+
)
|
|
120
167
|
item_list = response.json()
|
|
121
|
-
return [
|
|
122
|
-
|
|
123
|
-
|
|
168
|
+
return [
|
|
169
|
+
construct_ast_user(item) for item in item_list
|
|
170
|
+
]
|
|
171
|
+
|
|
172
|
+
def get_users_count(
|
|
173
|
+
self,
|
|
174
|
+
realm: str = None,
|
|
175
|
+
) -> int:
|
|
124
176
|
"""
|
|
125
177
|
Args:
|
|
126
178
|
realm (str):
|
|
@@ -128,12 +180,20 @@ class AccessControlAPI(object):
|
|
|
128
180
|
Returns:
|
|
129
181
|
int
|
|
130
182
|
"""
|
|
131
|
-
|
|
132
|
-
|
|
183
|
+
if realm is None:
|
|
184
|
+
realm = self.realm
|
|
185
|
+
url = f"{self.base_url}/{realm}/users/count"
|
|
186
|
+
response = self.api_client.call_api(
|
|
187
|
+
method="GET",
|
|
188
|
+
url=url,
|
|
189
|
+
)
|
|
133
190
|
item = response.json()
|
|
134
191
|
return item.get("count")
|
|
135
192
|
|
|
136
|
-
def get_logged_in_user_roles(
|
|
193
|
+
def get_logged_in_user_roles(
|
|
194
|
+
self,
|
|
195
|
+
realm: str = None,
|
|
196
|
+
) -> List[Role]:
|
|
137
197
|
"""
|
|
138
198
|
|
|
139
199
|
Args:
|
|
@@ -142,20 +202,41 @@ class AccessControlAPI(object):
|
|
|
142
202
|
Returns:
|
|
143
203
|
List[Role]
|
|
144
204
|
"""
|
|
145
|
-
|
|
146
|
-
|
|
205
|
+
if realm is None:
|
|
206
|
+
realm = self.realm
|
|
207
|
+
url = f"{self.base_url}/{realm}/user-roles"
|
|
208
|
+
response = self.api_client.call_api(
|
|
209
|
+
method="GET",
|
|
210
|
+
url=url,
|
|
211
|
+
)
|
|
147
212
|
item_list = response.json()
|
|
148
|
-
return [
|
|
213
|
+
return [
|
|
214
|
+
construct_role(item) for item in item_list
|
|
215
|
+
]
|
|
149
216
|
|
|
150
217
|
|
|
151
|
-
def get_groups(
|
|
218
|
+
def get_groups(
|
|
219
|
+
realm: str,
|
|
220
|
+
group_name: str = None,
|
|
221
|
+
limit: int = None,
|
|
222
|
+
ids: str = None
|
|
223
|
+
) -> List[AstIdWithName]:
|
|
152
224
|
return AccessControlAPI().get_groups(
|
|
153
|
-
realm=realm,
|
|
225
|
+
realm=realm,
|
|
226
|
+
group_name=group_name,
|
|
227
|
+
limit=limit,
|
|
228
|
+
ids=ids
|
|
154
229
|
)
|
|
155
230
|
|
|
156
231
|
|
|
157
|
-
def get_group_by_name(
|
|
158
|
-
|
|
232
|
+
def get_group_by_name(
|
|
233
|
+
realm: str,
|
|
234
|
+
group_name: str
|
|
235
|
+
) -> AstIdWithName:
|
|
236
|
+
return AccessControlAPI().get_group_by_name(
|
|
237
|
+
realm=realm,
|
|
238
|
+
group_name=group_name
|
|
239
|
+
)
|
|
159
240
|
|
|
160
241
|
|
|
161
242
|
def get_users(
|
|
@@ -166,7 +247,7 @@ def get_users(
|
|
|
166
247
|
sort: str = None,
|
|
167
248
|
order: str = None,
|
|
168
249
|
without_groups: bool = False
|
|
169
|
-
) -> List[AstUser]:
|
|
250
|
+
) -> List[AstUser]:
|
|
170
251
|
return AccessControlAPI().get_users(
|
|
171
252
|
realm=realm,
|
|
172
253
|
first=first,
|
|
@@ -178,13 +259,27 @@ def get_users(
|
|
|
178
259
|
)
|
|
179
260
|
|
|
180
261
|
|
|
181
|
-
def get_users_by_groups(
|
|
182
|
-
|
|
262
|
+
def get_users_by_groups(
|
|
263
|
+
realm: str,
|
|
264
|
+
group_id: str
|
|
265
|
+
) -> List[AstUser]:
|
|
266
|
+
return AccessControlAPI().get_users_by_groups(
|
|
267
|
+
realm=realm,
|
|
268
|
+
group_id=group_id
|
|
269
|
+
)
|
|
183
270
|
|
|
184
271
|
|
|
185
|
-
def get_users_count(
|
|
186
|
-
|
|
272
|
+
def get_users_count(
|
|
273
|
+
realm: str
|
|
274
|
+
) -> int:
|
|
275
|
+
return AccessControlAPI().get_users_count(
|
|
276
|
+
realm=realm
|
|
277
|
+
)
|
|
187
278
|
|
|
188
279
|
|
|
189
|
-
def get_logged_in_user_roles(
|
|
190
|
-
|
|
280
|
+
def get_logged_in_user_roles(
|
|
281
|
+
realm: str
|
|
282
|
+
) -> List[Role]:
|
|
283
|
+
return AccessControlAPI().get_logged_in_user_roles(
|
|
284
|
+
realm=realm
|
|
285
|
+
)
|