Config APIs
Data Client Configuration APIs
The configuration APIs mirror the Config REST APIs.
These classes provide basic catalog management operations and manages all platform resources needed for different kinds of catalogs and operations on these resources. It also offers layer subscriptions.
For both API classes the per-request configuration and metrics apply.
ConfigApi
It provides a way to manage catalogs.
For the full ConfigApi specification, see ConfigApi.
Example
val client = BaseClient()
val configApi = client.of[ConfigApi]
val result = configApi.getCatalogs().executeToEntity()
result
.andThen {
case Success(response: CatalogsSummaryListResult) =>
// do something with the list of catalogs
response.results.map(_.items.map(_.foreach(cat => println(cat.hrn))))
case Failure(ex) =>
ex.printStackTrace()
}
Await.result(result, Duration.Inf)BaseClient client = BaseClientJava.instance();
ConfigApi configApi = new ConfigApi(client);
CatalogsSummaryListResult listResult =
(CatalogsSummaryListResult)
configApi.getCatalogs().build().executeToEntity().toCompletableFuture().join();
// do something with the list of catalogs
listResult
.getResults()
.ifPresent(
summary ->
summary
.getItems()
.ifPresent(
items -> items.forEach(cat -> System.out.println(cat.getHrn().get()))));SubscriptionApi
It provides a way to subscribe to changes in layers.
For the full SubscriptionApi specification, see SubscriptionApi.
Example
val client = BaseClient()
val subscriptionApi = client.of[SubscriptionApi]
val xIdempotencyKey = "abc-123"
// TODO: example will be completed with one of the next releases
/*
val catalogHrn = "this needs to be a valid HRN" // note: in this example both layers belong to the same catalog
val subscribedLayer = "myInteractiveMapLayerWhichIWantToSubscribeTo"
val notificationLayer = "myStreamLayerWhichReceivesTheMessageAboutChanges"
val subscriptionRequestBody = CreateSubscriptionRequestBody(
subscriptionName = "someNameWhichCanBeUsedForHRN",
description = "some descriptive free text",
sourceCatalog = catalogHrn,
sourceLayer = subscribedLayer,
destinationCatalog = catalogHrn,
destinationLayer = notificationLayer,
interactiveMapSubscription = SubscriptionInteractiveMapLayerAllOfInteractiveMapSubscription.Type.PerFeature
)
*/
val subscriptionStatusToken = subscriptionApi
.createSubscription(
xIdempotencyKey,
subscriptionRequestBody
)
.toEntity()
// wait some time or check status in a loop
val subscriptionStatus = subscriptionApi
.getSubscriptionStatus(subscriptionStatusToken.statusToken)
.toEntity()
if (subscriptionStatus.status.value != SubscriptionStatus.Status.Active.value)
throw new RuntimeException("subscription is not active")
val subscription = subscriptionApi
.getSubscription(subscriptionStatus.subscriptionHrn.get)
.toEntity()
println(
s"subscription ${subscription.subscriptionHrn.get} with name ${subscription.subscriptionName}")
subscriptionApi
.listSubscriptions()
.toEntity()
.items
.foreach(s => println(s.subscriptionHrn.get))
subscriptionApi
.deleteSubscription(
subscription.subscriptionHrn.get,
xIdempotencyKey
)
.toEntity()BaseClient client = BaseClientJava.instance();
SubscriptionApi subscriptionApi = new SubscriptionApi(client);
// note: in this example both layers belong to the same catalog
String catalogHrn = "this needs to be a valid HRN";
String subscribedLayer = "myInteractiveMapLayerWhichIWantToSubscribeTo";
String notificationLayer = "myStreamLayerWhichReceivesTheMessageAboutChanges";
String xIdempotencyKey = "abc-123";
// TODO: example will be completed with one of the next releasesUpdated 21 days ago