generated from coulomb/repo-seed
Add registry feed and library inventory
This commit is contained in:
@@ -16,6 +16,7 @@ from .registry import (
|
||||
blast_radius,
|
||||
consumers,
|
||||
dependency_path_lines,
|
||||
library_xregistry_projection,
|
||||
providers,
|
||||
unresolved_dependencies,
|
||||
xregistry_projection,
|
||||
@@ -72,6 +73,19 @@ class RegistryHandler(BaseHTTPRequestHandler):
|
||||
)
|
||||
if len(parts) == 2 and parts[0] == "artifacts":
|
||||
return HTTPStatus.OK, self.store.get_artifact(_int_id(parts[1], "artifact_id"))
|
||||
if parts == ["libraries"]:
|
||||
return HTTPStatus.OK, self.store.list_libraries(
|
||||
repo_slug=_query_optional(query, "repo_slug"),
|
||||
name=_query_optional(query, "name"),
|
||||
purl=_query_optional(query, "purl"),
|
||||
component_type=_query_optional(query, "component_type") or _query_optional(query, "type"),
|
||||
)
|
||||
if len(parts) == 2 and parts[0] == "libraries":
|
||||
return HTTPStatus.OK, self.store.get_library(_int_id(parts[1], "library_id"))
|
||||
if len(parts) == 3 and parts[0] == "repositories" and parts[2] == "libraries":
|
||||
return HTTPStatus.OK, self.store.list_libraries(repo_slug=parts[1])
|
||||
if parts == ["exports", "libraries", "xregistry"]:
|
||||
return HTTPStatus.OK, library_xregistry_projection(self.store.list_libraries())
|
||||
raise RegistryError(f"route not found: {path}", 404)
|
||||
|
||||
def _post(self, path: str, _query: dict[str, list[str]]) -> tuple[int, Any]:
|
||||
@@ -81,6 +95,8 @@ class RegistryHandler(BaseHTTPRequestHandler):
|
||||
return HTTPStatus.CREATED, self.store.upsert_repository(body)
|
||||
if len(parts) == 3 and parts[0] == "repositories" and parts[2] == "snapshots":
|
||||
return HTTPStatus.CREATED, self.store.add_snapshot(parts[1], body)
|
||||
if len(parts) == 4 and parts[0] == "repositories" and parts[2] == "libraries" and parts[3] == "cyclonedx":
|
||||
return HTTPStatus.CREATED, self.store.ingest_cyclonedx(parts[1], body)
|
||||
if parts == ["artifacts"]:
|
||||
return HTTPStatus.CREATED, self.store.add_artifact(body)
|
||||
raise RegistryError(f"route not found: {path}", 404)
|
||||
|
||||
Reference in New Issue
Block a user