Skip to content

Commit

Permalink
Add backlog and scan-cfg related delivery-service routes
Browse files Browse the repository at this point in the history
  • Loading branch information
zkdev committed Dec 9, 2024
1 parent c9c3c7a commit a648ae4
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions delivery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ def cache(self):
'cache',
)

def scan_cfgs(self):
return ci.util.urljoin(
self._base_url,
'service-extensions',
'scan-configurations',
)

def backlog_items(self):
return ci.util.urljoin(
self._base_url,
'service-extensions',
'backlog-items',
)


class DeliveryServiceClient:
def __init__(
Expand Down Expand Up @@ -745,6 +759,50 @@ def mark_cache_for_deletion(

res.raise_for_status()

def create_backlog_item(
self,
service: str,
cfg_name: str,
artefacts: collections.abc.Iterable[dso.model.ComponentArtefactId]=(),
priority: str | None=None, # see delivery-service k8s/backlog for allowed priorities
):
headers = {
'Content-Type': 'application/json',
}

params = dict()

params['service'] = service
params['cfg_name'] = cfg_name

if priority:
params['priority'] = priority

data, headers = http_requests.encode_request(
json={'artefacts': [
dataclasses.asdict(artefact)
for artefact in artefacts
]},
headers=headers,
)

res = self.request(
url=self._routes.backlog_items(),
method='POST',
headers=headers,
data=data,
params=params,
)
res.raise_for_status()

def scan_cfgs(self) -> list:
res = self.request(
url=self._routes.scan_cfgs(),
method='GET',
)
res.raise_for_status()
return res.json()


def _normalise_github_hostname(github_url: str):
# hack: for github.com, we might get a different subdomain (api.github.com)
Expand Down

0 comments on commit a648ae4

Please sign in to comment.