Develop an Intake Agent
An Intake Agent is a standalone service that connects an external data source, such as a database or a file system, to the Data Context Hub. It retrieves the data and hands it over to GBS, which imports it into the knowledge graph.
Ready-to-use Intake Agents exist for common data sources. For any other source you can write your own, in any language and framework, as long as it implements the Intake Agent API. The quickest way is a .NET application that references the DCH.IntakeAgentCore NuGet package: it implements the API, Keycloak sign-in and the shared admin screens.
Security
GBS calls the agent with a Keycloak access token (JWT) of the DCH instance. The agent must accept and validate these tokens on every endpoint except GET /api/v1/core/info, which GBS calls without a token.
When the agent sends data back to GBS, it authenticates with the job's API key instead (see Send data to GBS).
Registration
A user registers an Intake Agent in DCH with its URL. GBS then:
If the handshake fails, GBS removes the agent again. Store the dataSourceRefId if the agent creates Data Import Configurations in GBS itself.
Custom Intake Agents must leave licenseModuleKey empty in the GET /api/v1/core/info response. If it is set, it must be part of the instance's license, or the registration fails.
Data import configuration
The agent describes the data it offers with GET /api/v1/core/data-source-configurations: its data source configurations, their source entities and the properties of each. Users map these onto Target Entities in Data Import Configurations. GET /api/v1/core/data-source-configurations/{slug}/data-preview returns sample rows for the preview in DCH.
Data import
When data needs to be imported, for example from a Build or a Workflow, GBS calls POST /api/v1/core/data-jobs. The request names the data source configuration, the source entities and the properties to import, and carries a unique jobId and jobApiKey.
Sometimes source entities must arrive in a certain order. GBS then marks them for a manual trigger, and the agent holds them back until GBS calls POST /api/v1/core/data-jobs/{jobId}/trigger.
The request does not contain the GBS URL, so the agent must know it from its own configuration.
Send data to GBS
The agent sends the data in batches to POST {gbsUrl}/api/v2/data-import-jobs/batch, with the job's jobApiKey in the X-API-Key header:
{
"jobId": "the job's id",
"batchId": "a unique id for this batch",
"sourceEntity": "orders",
"data": [{ "order_id": "10248", "customer_id": "42" }],
"isLatest": false,
"totalBatchesCount": null
}
dataholds the rows. Every value must be a string ornull.- Mark the last batch of each source entity with
isLatest: true, and set itstotalBatchesCountto the number of batches of that source entity, including the last one. GBS considers the source entity complete once all of them have arrived.
If a requested source entity has no data, the agent must still send one batch with data: [], isLatest: true and totalBatchesCount: 1. Otherwise the job never completes.
Errors and cancellation
If the agent cannot process a job, it reports it to POST {gbsUrl}/api/v2/data-import-jobs/failure-report with { "jobId": "…", "errorMessage": "…" } and the X-API-Key header.
If the job fails or is cancelled on the GBS side, GBS calls POST /api/v1/core/data-jobs/{jobId}/cancel. The agent should then stop sending data.
Intake job completion
An import job ending does not mean the intake job is over. GBS runs an intake job's import jobs one after another, so there is always a gap in which an agent has no running job for an intake job that is still going. An agent that releases state scoped to the intake job at that point throws away work the next import job needs.
Only GBS knows when the whole intake job has finished, so it says so. It calls POST /api/v1/core/data-jobs/intake-jobs/{intakeJobId}/complete once every import job of the intake job has run and the graph processing that follows them has settled. The body carries the outcome (Completed, Failed or Cancelled), an errorMessage when the job failed or was cancelled, and finishedAt. GBS calls it on every outcome, at most once per agent and intake job, however many of that job's import jobs the agent ran.
Use it to release anything you scoped to the intake job, such as a cache of parsed source data or a record of an upload batch.
The call is not retried, and a GBS older than 4.0.0 never makes it. Anything you release here needs an independent fallback, such as a time to live, so that the state is freed even when the call does not arrive.
With DCH.IntakeAgentCore, implement IJobLifecycleListener and register it with configurator.AddJobLifecycleListener<T>(). The package serves the endpoint for you and invokes every registered listener. A listener that throws is logged and otherwise ignored, so it never fails the job. Both members have a default implementation, so you override only the event you need:
OnIntakeJobFinished, for the whole intake job as described above.OnImportJobFinished, when one of this agent's own data jobs reaches a terminal state.