Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backlog and scan-cfg related delivery-service routes #1095

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading