Java client for the Flagent API (feature flags, evaluation, health). Generated from the OpenAPI spec; uses Java 11+ HttpClient and Jackson.
Version: see root VERSION or Releases.
For a single entry point with caching and evaluate / isEnabled / evaluateBatch, use the Kotlin Enhanced SDK from Java. It runs on the JVM and exposes a blocking API:
// Add dependency: com.flagent:kotlin-enhanced (same version as other Flagent libs)
import com.flagent.enhanced.entry.Flagent;
import com.flagent.enhanced.entry.FlagentClientBlocking;
import com.flagent.client.models.EvalResult;
FlagentClientBlocking client = Flagent.INSTANCE.builder()
.baseUrl("https://api.example.com/api/v1")
.cache(true, 300_000L)
.buildBlocking();
EvalResult result = client.evaluate("new_feature", null, "user123", "user", null, false);
boolean on = client.isEnabled("new_feature", "user123", null, null);Gradle:
implementation("com.flagent:kotlin-enhanced:0.1.7")Maven:
<dependency>
<groupId>com.flagent</groupId>
<artifactId>kotlin-enhanced</artifactId>
<version>0.1.7</version>
</dependency>For Spring Boot, use the Flagent Spring Boot Starter (auto-configuration and FlagentEvaluationFacade). For standalone Java without Spring, use kotlin-enhanced with buildBlocking() as above.
This artifact (flagent-java-client) is the generated OpenAPI client. Use it when you need direct access to EvaluationApi, FlagApi, etc.
- Java 17+
- Run
./generate.shonce (or when API changes) to generate code fromdocs/api/openapi.yaml. Requires OpenAPI Generator (e.g.npx @openapitools/openapi-generator-cli).
Unit tests for models run by default. API tests (*ApiTest.java) are disabled by default because they require a live Flagent server. They are intended for integration runs only.
To run API tests as integration tests:
- Start a Flagent server (e.g.
./gradlew :backend:runor your deployment). - Remove or comment out
@Disabled("Integration test: requires live Flagent server")on the API test classes (or run with a JUnit tag that includes them). - Configure the test to use the server base URL (e.g. set
ApiClientbase path tohttp://localhost:18000/api/v1in test setup). - Run:
./gradlew :java-client:test.
CI runs unit tests only; API tests are not executed unless explicitly enabled and the server URL is provided.
From the Flagent repo root:
./gradlew :java-client:buildFrom this directory (after generation):
cd ../.. && ./gradlew :java-client:buildAdd dependency (when published):
<dependency>
<groupId>com.flagent</groupId>
<artifactId>flagent-java-client</artifactId>
<version>0.1.7</version>
</dependency>Or with Gradle:
implementation("com.flagent:flagent-java-client:0.1.7")Example:
var client = new ApiClient();
client.setBasePath("http://localhost:18000/api/v1");
var evaluationApi = new EvaluationApi(client);
var context = new EvalContext().entityID("user-1").flagKey("my_flag");
EvalResult result = evaluationApi.postEvaluation(context).getBody();Use the Flagent Spring Boot Starter for auto-configuration and beans.