Skip to content

Commit

Permalink
Check API key and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessOne91 committed Oct 15, 2024
1 parent 59c7e88 commit 70bbe33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jenkins_pipelines/scripts/bsc_list_generator/bsc_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def parse_cli_args() -> argparse.Namespace:
def get_bugzilla_product(product_version: str, cloud: bool) -> str:
return f"SUSE Manager {product_version}{' in Public Clouds' if cloud else ''}"

# return a txt file formatted according to .md syntax, so that it can be used in GitHub cards and the likes
def bugs_to_links_list(products_bugs: dict[str, list[dict]], bugzilla_url: str) -> list[str]:
lines: list[str] = []

Expand Down Expand Up @@ -78,6 +79,7 @@ def main():

if args.all:
for version in _PRODUCT_VERSIONS:
# get both "standard" and cloud product versions
bugzilla_products.append(get_bugzilla_product(version, False))
bugzilla_products.append(get_bugzilla_product(version, True))
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

class BugzillaClient:

# api_key is needed for actual API calls
def __init__(self, api_key: str, base_url: str = _SUSE_BUGZILLA_BASE_URL, api_type: str = "rest"):
if not api_key:
raise ValueError("api_key is None or empty")
# private
self._api_key: str = api_key
self._base_url: str = base_url
Expand All @@ -16,6 +19,7 @@ def __init__(self, api_key: str, base_url: str = _SUSE_BUGZILLA_BASE_URL, api_ty
self.show_bug_url: str = f"{base_url}/show_bug.cgi"

def get_bugs(self, **kwargs) -> list[dict[str, Any]]:
# drops CLI args that have not beend used and have no default
additional_params: dict[str, Any] = { k: v for k, v in kwargs.items() if v is not None }
response: requests.Response = requests.get(self._bugs_endpoint, params={**self._params, **additional_params})
if not response.ok:
Expand Down

0 comments on commit 70bbe33

Please sign in to comment.