Skip to content

Commit 2c203db

Browse files
committed
feat: new method update_project_release_relationship()
1 parent e54db3c commit 2c203db

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

sw360/sw360_api.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -------------------------------------------------------------------------------
2-
# (c) 2019-2021 Siemens AG
2+
# (c) 2019-2022 Siemens AG
33
# All Rights Reserved.
44
# Authors: thomas.graf@siemens.com, gernot.hillier@siemens.com
55
#
@@ -608,6 +608,45 @@ def duplicate_project(self, project_id: str, new_version: str):
608608

609609
raise SW360Error(response, url)
610610

611+
def update_project_release_relationship(self, project_id: str, release_id: str, new_state: str,
612+
new_relation: str, comment: str):
613+
"""Update the relationship for a specific release of a project
614+
615+
API endpoint PATCH /projects/{pid}/release{rid}
616+
617+
:param project_id: the id of the exisiting project
618+
:type project_id: string
619+
:param release_id: the id of the release to be requested
620+
:type release_id: string
621+
:param new_state: the new mainline state of the release, one of
622+
(OPEN, MAINLINE, SPECIFIC, PHASEOUT, DENIED)
623+
:type new_state: string
624+
:param new_relation: the new relation of the release, one of
625+
(CONTAINED, REFERRED, UNKNOWN, DYNAMICALLY_LINKED, STATICALLY_LINKED, SIDE_BY_SIDE, STANDALONE,
626+
INTERNAL_USE, OPTIONAL, TO_BE_REPLACED, CODE_SNIPPET)
627+
:type new_relation: string
628+
:param comment: a comment
629+
:type comment: string
630+
"""
631+
if not project_id:
632+
raise SW360Error(message="No project id provided!")
633+
634+
if not release_id:
635+
raise SW360Error(message="No release id provided!")
636+
637+
relation = {}
638+
relation["releaseRelation"] = new_relation
639+
relation["mainlineState"] = new_state
640+
relation["comment"] = comment
641+
642+
url = self.url + "resource/api/projects/" + project_id + "/release/" + release_id
643+
response = requests.patch(url, json=relation, headers=self.api_headers)
644+
645+
if response.ok:
646+
return response.json()
647+
648+
raise SW360Error(response, url)
649+
611650
# ----- Releases ---------------------------------------------------------
612651

613652
def get_release(self, release_id):

0 commit comments

Comments
 (0)