Skip to main content

Java client

Izanami Java client aims to help you fetch your features' status from remote Izanami instances.

In addition to perform http requests for you, client offers some nice features :

Importing the client

<dependency>
<groupId>fr.maif</groupId>
<artifactId>izanami-client</artifactId>
<version>2.1.0</version>
</dependency>

Getting started

To instantiate Izanami client, you'll need a remote instance url and an API key.

IzanamiClient client = IzanamiClient.newBuilder(
connectionInformation()
.withUrl(<REMOTE_IZANAMI_BASE_URL>/api)
.withClientId(<YOUR_KEY_CLIENT_ID>)
.withClientSecret(<YOUR_KEY_CLIENT_SECRET>)
).build();

The client can be used to query a single feature...

CompletableFuture<Boolean> res = client.booleanValue(
newSingleFeatureRequest("<YOUR_FEATURE_ID>")
);

// For features that returns a String value
CompletableFuture<String> futureString = client.stringValue(
newSingleFeatureRequest("<YOUR_STRING_FEATURE_ID>")
);

// For features that returns a number (BigDecimal) value
CompletableFuture<BigDecimal> res = client.numberValue(
newSingleFeatureRequest("<YOUR_NUMBER_FEATURE_ID>")
);

... or multiple features at once

// Resulting map associates feature id to its activation
CompletableFuture<IzanamiResult> results = client.featureValues(
newFeatureRequest()
.withFeatures("<BOOLEAN_FEATURE_ID>", "<STRING_FEATURE_ID>")
);
results.join().booleanValue("<BOOLEAN_FEATURE_ID>");
results.join().stringValue("<STRING_FEATURE_ID>");

With these queries, you can specify user, context or payload :

CompletableFuture<IzanamiResult> results = client.checkFeatureActivations(
newFeatureRequest()
.withFeatures("<YOUR_ID_1>", "<YOUR_ID_2>")
.withUser("<YOUR_USER>")
.withContext("prod/mobile")
);