Gkb client#
- class geonemo.client.GkbClient(
- base_url=None,
- *,
- transport=None,
- project_id=None,
- token=None,
- timeout=10.0,
- client=None,
- headers=None,
Publish and read canonical artifacts through the
/v1/gkbAPI.- activity(project_id)#
List a project’s recent artifacts (
GET /v1/gkb/projects/{project_id}/activity).- Parameters:
project_id – Project identifier.
- Returns:
The
GkbActivityResponse.- Raises:
ValueError – If
project_idis not a safe identifier.ServicesClientError – On transport or HTTP failure, or an invalid response.
- catalog_page(query)#
Browse compact artifact rows (
POST /v1/gkb/catalog-page).- Parameters:
query – Filters, page size and cursor.
- Returns:
A
GkbBrowsePage.- Raises:
ServicesClientError – On transport or HTTP failure, or an invalid response.
- contribute(draft, *, idempotency_key=None)#
Render a draft and publish it (
POST /v1/gkb/artifacts).- Parameters:
draft – The draft to publish.
idempotency_key – Replay key; defaults to one derived from the content hash.
- Returns:
The
ContributionReceipt.- Raises:
ValueError – If the draft is invalid or the key is malformed.
ServicesConflictError – If the key was used for different content.
ServicesClientError – On transport or HTTP failure, or an invalid response.
- contribute_artifact(artifact, *, idempotency_key=None)#
Publish a validated artifact (
POST /v1/gkb/artifacts).- Parameters:
artifact – The artifact to publish.
idempotency_key – Replay key (1-256 visible ASCII characters); defaults to one derived from the content hash, so republishing identical content is a safe replay.
- Returns:
The
ContributionReceipt.- Raises:
TypeError – If
artifactis not aKnowledgeArtifact.ValueError – If the key is malformed.
ServicesConflictError – If the key was used for different content.
ServicesProtocolError – If the receipt names a different artifact ID or content hash.
ServicesClientError – On other transport or HTTP failures.
- get(artifact_id)#
Read one artifact (
GET /v1/gkb/artifacts/{artifact_id}).- Parameters:
artifact_id – Artifact identifier.
- Returns:
The
KnowledgeArtifact, orNoneif it does not exist.- Raises:
UnsafeArtifactIdentifierError – If
artifact_idis not a safe identifier.ServicesProtocolError – If the response is not valid canonical Markdown for that ID.
ServicesClientError – On other transport or HTTP failures.
- list_projects()#
List projects (
GET /v1/gkb/projects).- Returns:
The
GkbProjectInfoentries.- Raises:
ServicesClientError – On transport or HTTP failure, or an invalid response.
- map_page(query)#
Browse compact rows inside a map viewport (
POST /v1/gkb/map-page).- Parameters:
query – Filters, viewport boxes, page size and cursor.
- Returns:
A
GkbBrowsePage.- Raises:
ServicesClientError – On transport or HTTP failure, or an invalid response.
- project_summaries()#
Summarize every project (
GET /v1/gkb/project-summaries).- Returns:
The
GkbProjectSummaries.- Raises:
ServicesClientError – On transport or HTTP failure, or an invalid response.
- query(query)#
Query artifacts (
POST /v1/gkb/query).- Parameters:
query – The query.
- Returns:
An
ArtifactQueryResponse; every hit is checked to be valid canonical Markdown for its ID.- Raises:
TypeError – If
queryis not anArtifactQuery.ServicesProtocolError – If a hit is invalid or mismatched.
ServicesClientError – On other transport or HTTP failures.
- relationships(query)#
Read the explicit relations of some artifacts (
POST /v1/gkb/relationships).- Parameters:
query – Artifact IDs and optional project.
- Returns:
The
GkbRelationships.- Raises:
ServicesClientError – On transport or HTTP failure, or an invalid response.
- search(query)#
Query artifacts and return only the hits (
POST /v1/gkb/query).- Parameters:
query – The query.
- Returns:
The list of
KnowledgeHit.- Raises:
TypeError – If
queryis not anArtifactQuery.ServicesProtocolError – If a hit is invalid or mismatched.
ServicesClientError – On other transport or HTTP failures.
- structured_search(query)#
Search artifacts with a structured query (
POST /v1/gkb/search).- Parameters:
query – Search filters, limit and cursor.
- Returns:
A
GkbSearchResponse.- Raises:
ServicesClientError – On transport or HTTP failure, or an invalid response.
- structured_search_page(query)#
Search artifacts with paging cursors in both directions (
POST /v1/gkb/search-page).- Parameters:
query – Search filters, limit and cursor.
- Returns:
A
GkbSearchPageResponse.- Raises:
ServicesClientError – On transport or HTTP failure, or an invalid response.
- timeline_overview(query)#
Count matching artifacts per time bucket (
POST /v1/gkb/timeline-overview).- Parameters:
query – Filters, time range and bucket count.
- Returns:
A
GkbTimelineOverview.- Raises:
ServicesClientError – On transport or HTTP failure, or an invalid response.
- validate(artifact)#
Validate artifact Markdown without storing it (
POST /v1/gkb/artifacts/validate).- Parameters:
artifact – A
KnowledgeArtifactor Markdown text.- Returns:
The
ArtifactValidation; invalid Markdown is reported in it, not raised.- Raises:
TypeError – If
artifactis neither aKnowledgeArtifactnor a string.ServicesClientError – On transport or HTTP failure, or an invalid response.
- visualization(project_id)#
Get a project’s artifact graph (
GET /v1/gkb/projects/{project_id}/visualization).- Parameters:
project_id – Project identifier.
- Returns:
The
GkbVisualizationResponse.- Raises:
ValueError – If
project_idis not a safe identifier.ServicesClientError – On transport or HTTP failure, or an invalid response.