@@ -32,16 +32,20 @@ def prepare_query() -> dict:
3232 TOKEN = os .getenv ("COVERITY_TOKEN" , default = None )
3333 PROJECT_NAME = os .getenv ("COVERITY_PROJECT_NAME" , default = None )
3434 USER = os .getenv ("COVERITY_USER" , default = None )
35+ OUTSTANDING_VIEW_ID = os .getenv ("COVERITY_OUTSTANDING_VIEW_ID" , default = None )
36+ PROJECT_ID = os .getenv ("COVERITY_PROJECT_ID" , default = None )
3537
36- if None in [BASE_URL , TOKEN , PROJECT_NAME , USER ]:
38+ if None in [BASE_URL , TOKEN , PROJECT_NAME , USER , OUTSTANDING_VIEW_ID , PROJECT_ID ]:
3739 log .error ("Environment variables not set" )
3840 log .error (
39- "Please set the following environment variables: COVERITY_BASE_URL, COVERITY_TOKEN, COVERITY_PROJECT_NAME, COVERITY_USER"
41+ "Please set the following environment variables: COVERITY_BASE_URL, COVERITY_TOKEN, COVERITY_PROJECT_NAME, COVERITY_USER, OUTSTANDING_VIEW_ID, COVERITY_PROJECT_ID "
4042 )
4143 return {}
4244 return {
4345 "base_url" : BASE_URL ,
4446 "project_name" : PROJECT_NAME ,
47+ "project_id" : PROJECT_ID ,
48+ "outstanding_view_id" : OUTSTANDING_VIEW_ID ,
4549 "password" : TOKEN ,
4650 "user" : USER ,
4751 "stream" : PROJECT_NAME ,
@@ -59,6 +63,38 @@ def prepare_query() -> dict:
5963 }
6064
6165
66+ def fetch_outstanding_view_issues (config : dict ) -> dict :
67+ """
68+ Fetch issues from a specific view based on the provided view ID.
69+
70+ Args:
71+ config (dict): Configuration dictionary containing 'base_url', 'view_id, 'user', and 'password'.
72+ view_id (int): The ID of the view to fetch issues from.
73+
74+ Returns:
75+ dict: A dictionary containing the list of issues for the view.
76+ """
77+ endpoint = (
78+ f"{ config ['base_url' ]} /api/v2/views/viewContents/{ config ['outstanding_view_id' ]} "
79+ )
80+ issues = {}
81+ try :
82+ response = requests .get (
83+ endpoint ,
84+ params = {"projectId" : config ["project_id" ]},
85+ auth = HTTPBasicAuth (config ["user" ], config ["password" ]),
86+ )
87+ response .raise_for_status ()
88+ issues = response .json ()
89+
90+ except requests .exceptions .HTTPError as http_err :
91+ logging .error (f"HTTP error occurred: { http_err } " )
92+ except Exception as err :
93+ logging .error (f"An error occurred: { err } " )
94+ finally :
95+ return issues
96+
97+
6298def get_snapshot (config : dict , description : str , version : str ) -> int :
6399 """
64100 Retrieve a snapshot ID based on the provided description and version.
@@ -75,7 +111,7 @@ def get_snapshot(config: dict, description: str, version: str) -> int:
75111 raw = get_snapshots_list (config )
76112 ids = list (map (lambda s : s ["id" ], raw ["snapshotsForStream" ]))
77113 snapshot_id = 0
78- #TODO: replace with threads
114+ # TODO: replace with threads
79115 for id in ids :
80116 res = requests .get (
81117 f"{ search_query_url } /{ id } " ,
0 commit comments