From 7dd0e66a8d0c287aba9ec7dbfbfdfb12296c1853 Mon Sep 17 00:00:00 2001 From: nathan-roys <110457649+nathan-roys@users.noreply.github.com> Date: Tue, 15 Aug 2023 14:25:55 +0100 Subject: [PATCH] fix: add remoteRepoUrl from target (#189) --- pyproject.toml | 2 +- snyk/managers.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ace3985..dbb860e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pysnyk" -version = "0.9.9" +version = "0.9.10" description = "A Python client for the Snyk API" authors = [ "Gareth Rushgrove ", diff --git a/snyk/managers.py b/snyk/managers.py index 4a6565e..972b880 100644 --- a/snyk/managers.py +++ b/snyk/managers.py @@ -1,4 +1,5 @@ import abc +import json from typing import Any, Dict, List from deprecation import deprecated # type: ignore @@ -143,7 +144,13 @@ def _rest_to_v1_response_format(self, project): settings = attributes.get("settings", {}) recurring_tests = settings.get("recurring_tests", {}) issue_counts = project.get("meta", {}).get("latest_issue_counts") - + remote_repo_url = ( + project.get("relationships", {}) + .get("target", {}) + .get("data", {}) + .get("attributes", {}) + .get("url") + ) return { "name": attributes.get("name"), "id": project.get("id"), @@ -161,6 +168,7 @@ def _rest_to_v1_response_format(self, project): }, "targetReference": attributes.get("target_reference"), "branch": attributes.get("target_reference"), + "remoteRepoUrl": remote_repo_url, "_tags": attributes.get("tags", []), "importingUserId": project.get("relationships", {}) .get("importer", {}) @@ -189,6 +197,7 @@ def _query(self, tags: List[Dict[str, str]] = [], next_url: str = None): # Append the issue count param to the params if this is the first page if not next_url: params["meta.latest_issue_counts"] = "true" + params["expand"] = "target" # And lastly, make the API call resp = self.client.get(