sw360 1.12.0.dev2__tar.gz → 1.12.0.dev3__tar.gz
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.
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/PKG-INFO +1 -1
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/pyproject.toml +1 -1
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/__init__.py +1 -1
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/components.py +21 -11
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/packages.py +21 -10
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/project.py +24 -5
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/releases.py +14 -9
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/LICENSES/MIT.txt +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/License.md +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/Readme.md +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/attachments.py +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/base.py +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/clearing.py +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/license.py +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/moderationrequests.py +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/py.typed +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/reports.py +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/sorting.py +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/sw360_api.py +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/sw360error.py +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/sw360keycloak.py +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/sw360oauth2.py +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/vendor.py +0 -0
- {sw360-1.12.0.dev2 → sw360-1.12.0.dev3}/sw360/vulnerabilities.py +0 -0
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
# SPDX-License-Identifier: MIT
|
|
8
8
|
# -------------------------------------------------------------------------------
|
|
9
9
|
|
|
10
|
-
__version__ = (1, 12, 0, "
|
|
10
|
+
__version__ = (1, 12, 0, "dev3")
|
|
11
11
|
|
|
12
12
|
from .base import SW360Response
|
|
13
13
|
from .sorting import (BaseSortMixin, ProjectSortColumn, ReleaseSortColumn,
|
|
@@ -37,7 +37,7 @@ class ComponentsMixin(BaseMixin):
|
|
|
37
37
|
:type page_size: int
|
|
38
38
|
:param sort: sort order for the components (Sort by name if `None`)
|
|
39
39
|
:type sort: SortParam
|
|
40
|
-
:return:
|
|
40
|
+
:return: response from API
|
|
41
41
|
:rtype: list of JSON component objects
|
|
42
42
|
:raises SW360Error: if there is a negative HTTP response
|
|
43
43
|
"""
|
|
@@ -55,12 +55,7 @@ class ComponentsMixin(BaseMixin):
|
|
|
55
55
|
else:
|
|
56
56
|
resp = self.api_get(full_url)
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
"_embedded" in resp and
|
|
60
|
-
"sw360:components" in resp["_embedded"]):
|
|
61
|
-
return resp["_embedded"]["sw360:components"]
|
|
62
|
-
|
|
63
|
-
return []
|
|
58
|
+
return resp
|
|
64
59
|
|
|
65
60
|
def get_all_components(
|
|
66
61
|
self, fields: str = "", page: int = -1, page_size: int = -1,
|
|
@@ -99,8 +94,16 @@ class ComponentsMixin(BaseMixin):
|
|
|
99
94
|
if sort is None:
|
|
100
95
|
sort = ComponentSortColumn.NAME.asc()
|
|
101
96
|
|
|
102
|
-
|
|
97
|
+
resp = self.__get_components_filtered(url_with_param, page, page_size,
|
|
103
98
|
sort)
|
|
99
|
+
if (resp and
|
|
100
|
+
"_embedded" in resp and
|
|
101
|
+
"sw360:components" in resp["_embedded"]):
|
|
102
|
+
if page == -1:
|
|
103
|
+
return resp["_embedded"]["sw360:components"]
|
|
104
|
+
return resp
|
|
105
|
+
|
|
106
|
+
return []
|
|
104
107
|
|
|
105
108
|
def get_components_by_type(
|
|
106
109
|
self, component_type: str, page: int = -1, page_size: int = -1,
|
|
@@ -135,9 +138,14 @@ class ComponentsMixin(BaseMixin):
|
|
|
135
138
|
if sort is None:
|
|
136
139
|
sort = ComponentSortColumn.NAME.asc()
|
|
137
140
|
|
|
138
|
-
|
|
141
|
+
resp = self.__get_components_filtered(url_with_param, page, page_size,
|
|
139
142
|
sort)
|
|
140
143
|
|
|
144
|
+
if resp and ("_embedded" in resp) and ("sw360:components" in resp["_embedded"]):
|
|
145
|
+
return resp["_embedded"]["sw360:components"]
|
|
146
|
+
|
|
147
|
+
return []
|
|
148
|
+
|
|
141
149
|
def get_component(self, component_id: str) -> Optional[Dict[str, Any]]:
|
|
142
150
|
"""Get information of about a component
|
|
143
151
|
|
|
@@ -175,7 +183,7 @@ class ComponentsMixin(BaseMixin):
|
|
|
175
183
|
def get_component_by_name(
|
|
176
184
|
self, component_name: str, page: int = -1, page_size: int = -1,
|
|
177
185
|
sort: Optional[SortParam] = None
|
|
178
|
-
) -> Dict[str, Any]:
|
|
186
|
+
) -> Optional[Dict[str, Any]]:
|
|
179
187
|
"""Get information of about a component
|
|
180
188
|
|
|
181
189
|
API endpoint: GET /components?name=
|
|
@@ -206,9 +214,11 @@ class ComponentsMixin(BaseMixin):
|
|
|
206
214
|
else:
|
|
207
215
|
sort = ComponentSortColumn.NAME.asc()
|
|
208
216
|
|
|
209
|
-
|
|
217
|
+
resp = self.__get_components_filtered(url_with_param, page, page_size,
|
|
210
218
|
sort)
|
|
211
219
|
|
|
220
|
+
return resp
|
|
221
|
+
|
|
212
222
|
def get_components_by_external_id(self, ext_id_name: str, ext_id_value: str = "") -> List[Dict[str, Any]]:
|
|
213
223
|
"""Get components by external id. `ext_id_value` can be left blank to
|
|
214
224
|
search for all components with `ext_id_name`.
|
|
@@ -33,7 +33,7 @@ class PackagesMixin(BaseMixin):
|
|
|
33
33
|
:type page_size: int
|
|
34
34
|
:param sort: sort order for the package
|
|
35
35
|
:type sort: SortParam
|
|
36
|
-
:return:
|
|
36
|
+
:return: response from API
|
|
37
37
|
:rtype: list of JSON package objects
|
|
38
38
|
:raises SW360Error: if there is a negative HTTP response
|
|
39
39
|
"""
|
|
@@ -51,12 +51,7 @@ class PackagesMixin(BaseMixin):
|
|
|
51
51
|
else:
|
|
52
52
|
resp = self.api_get(full_url)
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
"_embedded" in resp and
|
|
56
|
-
"sw360:packages" in resp["_embedded"]):
|
|
57
|
-
return resp["_embedded"]["sw360:packages"]
|
|
58
|
-
|
|
59
|
-
return []
|
|
54
|
+
return resp
|
|
60
55
|
|
|
61
56
|
def get_package(self, package_id: str) -> Optional[Dict[str, Any]]:
|
|
62
57
|
"""Get information of about a package
|
|
@@ -109,7 +104,13 @@ class PackagesMixin(BaseMixin):
|
|
|
109
104
|
else:
|
|
110
105
|
sort = PackageSortColumn.NAME.asc()
|
|
111
106
|
|
|
112
|
-
|
|
107
|
+
resp = self.__get_packages_filtered(url_with_param, page, page_size,
|
|
108
|
+
sort)
|
|
109
|
+
|
|
110
|
+
if resp and ("_embedded" in resp) and ("sw360:packages" in resp["_embedded"]):
|
|
111
|
+
return resp["_embedded"]["sw360:packages"]
|
|
112
|
+
|
|
113
|
+
return []
|
|
113
114
|
|
|
114
115
|
def get_all_packages(
|
|
115
116
|
self, name: str = "", version: str = "", purl: str = "",
|
|
@@ -167,9 +168,14 @@ class PackagesMixin(BaseMixin):
|
|
|
167
168
|
else:
|
|
168
169
|
sort = PackageSortColumn.NAME.asc()
|
|
169
170
|
|
|
170
|
-
|
|
171
|
+
resp = self.__get_packages_filtered(url_with_param, page, page_size,
|
|
171
172
|
sort)
|
|
172
173
|
|
|
174
|
+
if page == -1 and resp and ("_embedded" in resp) and ("sw360:packages" in resp["_embedded"]):
|
|
175
|
+
return resp["_embedded"]["sw360:packages"]
|
|
176
|
+
|
|
177
|
+
return resp
|
|
178
|
+
|
|
173
179
|
def get_packages_by_packagemanager(
|
|
174
180
|
self, manager: str, page: int = -1, page_size: int = -1,
|
|
175
181
|
sort: Optional[SortParam] = None
|
|
@@ -204,9 +210,14 @@ class PackagesMixin(BaseMixin):
|
|
|
204
210
|
else:
|
|
205
211
|
sort = PackageSortColumn.NAME.asc()
|
|
206
212
|
|
|
207
|
-
|
|
213
|
+
resp = self.__get_packages_filtered(url_with_param, page, page_size,
|
|
208
214
|
sort)
|
|
209
215
|
|
|
216
|
+
if page == -1 and resp and ("_embedded" in resp) and ("sw360:packages" in resp["_embedded"]):
|
|
217
|
+
return resp["_embedded"]["sw360:packages"]
|
|
218
|
+
|
|
219
|
+
return resp
|
|
220
|
+
|
|
210
221
|
def create_new_package(self, name: str, version: str, purl: str,
|
|
211
222
|
package_type: str, package_details: Dict[str, Any] = {}) -> Optional[Dict[str, Any]]:
|
|
212
223
|
"""Create a new package
|
|
@@ -127,7 +127,7 @@ class ProjectMixin(BaseMixin):
|
|
|
127
127
|
def get_projects(
|
|
128
128
|
self, all_details: bool = False, page: int = -1, page_size: int = -1,
|
|
129
129
|
sort: Optional[SortParam] = None
|
|
130
|
-
) ->
|
|
130
|
+
) -> Optional[Dict[str, Any]]:
|
|
131
131
|
"""Get all projects
|
|
132
132
|
|
|
133
133
|
API endpoint: GET /projects
|
|
@@ -150,13 +150,25 @@ class ProjectMixin(BaseMixin):
|
|
|
150
150
|
|
|
151
151
|
if all_details:
|
|
152
152
|
params["allDetails"] = "true"
|
|
153
|
-
url_with_param = self._add_params(fullbase_url, params)
|
|
154
153
|
|
|
155
154
|
if sort is None:
|
|
156
155
|
sort = ProjectSortColumn.NAME.asc()
|
|
157
156
|
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
if self.is_above_version_18():
|
|
158
|
+
params["luceneSearch"] = "true"
|
|
159
|
+
|
|
160
|
+
url_with_param = self._add_params(fullbase_url, params)
|
|
161
|
+
|
|
162
|
+
if page > -1 and page_size > -1:
|
|
163
|
+
url_with_param = self._add_pagination(url_with_param, page,
|
|
164
|
+
page_size, sort)
|
|
165
|
+
|
|
166
|
+
if self.is_above_version_18() and page_size == -1:
|
|
167
|
+
resp = self.api_get_all(url_with_param, sort)
|
|
168
|
+
else:
|
|
169
|
+
resp = self.api_get(url_with_param)
|
|
170
|
+
|
|
171
|
+
return resp
|
|
160
172
|
|
|
161
173
|
def get_projects_by_type(
|
|
162
174
|
self, project_type: str, page: int = -1, page_size: int = -1,
|
|
@@ -206,7 +218,14 @@ class ProjectMixin(BaseMixin):
|
|
|
206
218
|
if not all_projects:
|
|
207
219
|
return resp
|
|
208
220
|
|
|
209
|
-
|
|
221
|
+
if "_embedded" not in all_projects:
|
|
222
|
+
return resp
|
|
223
|
+
|
|
224
|
+
if "sw360:projects" not in all_projects["_embedded"]:
|
|
225
|
+
return resp
|
|
226
|
+
|
|
227
|
+
projects: List[Dict[str, Any]] = all_projects["_embedded"]["sw360:projects"]
|
|
228
|
+
|
|
210
229
|
if not projects:
|
|
211
230
|
return resp
|
|
212
231
|
|
|
@@ -35,7 +35,7 @@ class ReleasesMixin(BaseMixin):
|
|
|
35
35
|
:type page_size: int
|
|
36
36
|
:param sort: sort order for the releases
|
|
37
37
|
:type sort: SortParam
|
|
38
|
-
:return:
|
|
38
|
+
:return: response from API
|
|
39
39
|
:rtype: list of JSON release objects
|
|
40
40
|
:raises SW360Error: if there is a negative HTTP response
|
|
41
41
|
"""
|
|
@@ -53,12 +53,7 @@ class ReleasesMixin(BaseMixin):
|
|
|
53
53
|
else:
|
|
54
54
|
resp = self.api_get(full_url)
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
"_embedded" in resp and
|
|
58
|
-
"sw360:releases" in resp["_embedded"]):
|
|
59
|
-
return resp["_embedded"]["sw360:releases"]
|
|
60
|
-
|
|
61
|
-
return []
|
|
56
|
+
return resp
|
|
62
57
|
|
|
63
58
|
def get_release(self, release_id: str) -> Optional[Dict[str, Any]]:
|
|
64
59
|
"""Get information of about a release
|
|
@@ -128,9 +123,14 @@ class ReleasesMixin(BaseMixin):
|
|
|
128
123
|
else:
|
|
129
124
|
sort = ReleaseSortColumn.VERSION.desc()
|
|
130
125
|
|
|
131
|
-
|
|
126
|
+
resp = self.__get_releases_filtered(url_with_param, page, page_size,
|
|
132
127
|
sort)
|
|
133
128
|
|
|
129
|
+
if resp and ("_embedded" in resp) and ("sw360:releases" in resp["_embedded"]):
|
|
130
|
+
return resp["_embedded"]["sw360:releases"]
|
|
131
|
+
|
|
132
|
+
return []
|
|
133
|
+
|
|
134
134
|
# return type List[Dict[str, Any]] | Optional[Dict[str, Any]] for Python 3.11 is good,
|
|
135
135
|
# Union[List[Dict[str, Any]], Optional[Dict[str, Any]]] for lower Python versions is not good
|
|
136
136
|
def get_all_releases(
|
|
@@ -175,9 +175,14 @@ class ReleasesMixin(BaseMixin):
|
|
|
175
175
|
if sort is None:
|
|
176
176
|
sort = ReleaseSortColumn.NAME.asc()
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
resp = self.__get_releases_filtered(url_with_param, page, page_size,
|
|
179
179
|
sort)
|
|
180
180
|
|
|
181
|
+
if page == -1 and resp and ("_embedded" in resp) and ("sw360:releases" in resp["_embedded"]):
|
|
182
|
+
return resp["_embedded"]["sw360:releases"]
|
|
183
|
+
|
|
184
|
+
return resp
|
|
185
|
+
|
|
181
186
|
def get_releases_by_external_id(self, ext_id_name: str, ext_id_value: str = "") -> List[Dict[str, Any]]:
|
|
182
187
|
"""Get releases by external id. `ext_id_value` can be left blank to
|
|
183
188
|
search for all releases with `ext_id_name`.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|