Data Client Ingestion APIs

The ingestion APIs mirror the Ingest REST APIs.

These classes provide the way to submit data to stream layers and manage cross-origin resource sharing.

For both API classes the per-request configuration and metrics apply.

IngestApi

It provides a way to send any kind of data to stream layers.

For the full IngestApi specification, see IngestApi.

Example

Scala
Java
val client = BaseClient()
val ingestApi = client.of[IngestionApi]

val someHrn = "hrn:here:data::olp-here-test:whatever"
val someLayer = "whateverLayer"
val someData = Array.fill(1000)((scala.util.Random.nextInt(256) - 128).toByte)
val result =
  ingestApi.ingestData(someHrn, someLayer, someData).executeToStatusCode()

result
  .andThen {
    case Success(responseCode) =>
      // check response code
      if (responseCode == 200) {
        // ingestion was successful
        println("ingestion was successful")
      } else {
        // should not happen as in case of error below Failure will match
      }
    case Failure(ex) =>
      ex.printStackTrace()
  }

Await.result(result, Duration.Inf)
BaseClient client = BaseClientJava.instance();
IngestionApi ingestApi = new IngestionApi(client);

String someHrn = "hrn:here:data::olp-here-test:whatever";
String someLayer = "whateverLayer";
byte[] someData = new byte[1000];
new java.util.Random().nextBytes(someData);

ingestApi
    .ingestData()
    .withHrn(someHrn)
    .withLayerId(someLayer)
    .withByteArray(someData)
    .build()
    .executeToEntity()
    .toCompletableFuture()
    .join();

CORSApi

It provides a way to manage cross-origin resource sharing (CORS).

For the full CORSApi specification, see CORSApi.

Example

Scala
Java
val client = BaseClient()
val corsApi = client.of[CORSApi]

val result = corsApi.ingestDataCors("whateverLayer").executeToStatusCode()

result
  .andThen {
    case Success(responseCode) =>
      // check response code
      if (responseCode == 200) {
        // enable ingestion was successful
        println("enable ingestion was successful")
      } else {
        // should not happen as in case of error below Failure will match
      }
    case Failure(ex) =>
      ex.printStackTrace()
  }

Await.result(result, Duration.Inf)
BaseClient client = BaseClientJava.instance();
CORSApi corsApi = new CORSApi(client);

corsApi
    .ingestDataCors()
    .withLayerId("whateverLayer")
    .build()
    .executeToEntity()
    .toCompletableFuture()
    .join();

results matching ""

    No results matching ""