Skip to content

Repository files navigation

RDP SDK for Java/Kotlin

The RDP SDK for Java/Kotlin is part of the unified SDK family for client applications interacting with Raft Data Platform (RDP). It provides Kotlin-first APIs, Java-friendly blocking support, and generated service clients for the RDP API surface.

For platform concepts, API guides, and integration details, see https://developer.teamraft.com.

Installation

Add the SDK as a Gradle dependency:

repositories {
mavenCentral()
maven {
name ="buf"
url = uri("https://buf.build/gen/maven")
}
}
dependencies {
implementation("com.teamraft:rdp-sdk-java:<version>")
}

The Buf Maven repository provides the public Java and Kotlin packages generated from the raft/wdm module. The generated packages use the build.buf.gen.raft.wdm.v1 namespace shown below.

Quick Start

export RDP_SERVER_URL=https://rdp.example.com
export RDP_API_KEY=your-api-key

Kotlin:

importcom.raft.rdp.loadConfigimportbuild.buf.gen.raft.wdm.v1.service.SearchObjectsRequestimportcom.raft.rdp.toOptionsimportcom.raft.rdp.v1.RdpClientsuspendfunmain() {
// Load RDP_SERVER_URL and authentication from the environment.val cfg = loadConfig()
// Create a client from the loaded config.RdpClient.create(cfg.toOptions()).use { client ->// Request the first 10 WDM objects.val response = client.objectService.searchObjects(
SearchObjectsRequest.newBuilder()
.setPageSize(10)
.build(),
)
response.success { result ->val objects = result.message.objectsList
if (objects.isEmpty()) {
println("No WDM objects found.")
return@success
}
objects.forEach { obj ->println("${obj.id}\t${obj.name}")
}
}
response.failure { err ->
error("SearchObjects failed: ${err.cause.message}")
}
}
}

Java:

importstaticcom.connectrpc.ResponseMessageKt.getOrThrow;
importcom.raft.rdp.Rdp;
importbuild.buf.gen.raft.wdm.v1.service.SearchObjectsRequest;
importcom.raft.rdp.v1.RdpClient;
importjava.util.Collections;
publicfinalclassMain {
publicstaticvoidmain(String[] args) {
// Load RDP_SERVER_URL and authentication from the environment.varcfg = Rdp.loadConfig();
// Create a client from the loaded config.try (varclient = RdpClient.create(Rdp.toOptions(cfg))) {
// Request the first 10 WDM objects.varresponse =
client.getObjectService()
.searchObjectsBlocking(
SearchObjectsRequest.newBuilder().setPageSize(10).build(),
Collections.emptyMap())
.execute();
varobjects = getOrThrow(response).getObjectsList();
if (objects.isEmpty()) {
System.out.println("No WDM objects found.");
return;
}
for (varobject : objects) {
System.out.printf("%s\t%s%n", object.getId(), object.getName());
}
}
}
}

For more examples, see examples.

Configuration

loadConfig() reads connection settings from environment variables and returns a validated RdpConfig. Process environment values take precedence over values loaded from .env.local or a custom dotenv path.

VariableRequiredDescription
RDP_SERVER_URLNoBase RDP endpoint. Defaults to https://rdp.local; use scheme and host only.
RDP_SERVER_PORTNoOptional port override for the endpoint.
TLS_SKIP_VERIFYNoSet to true only for development or test endpoints with self-signed certificates.

Authentication

API key authentication is the preferred method for client applications. Use OAuth2 client credentials or a static Bearer token only when your deployment requires it.

MethodVariablesRequest behavior
API keyRDP_API_KEYSends the value on each request as an API key header.
OAuth2 client credentialsRDP_CLIENT_ID, RDP_CLIENT_SECRETFetches a token from {RDP_SERVER_URL}/api/v1/auth/token and sends it as a bearer token.
BearerRDP_BEARER_TOKENSends Authorization: Bearer <token>.

Providing multiple auth methods is an error. If no method is configured, requests are sent without auth and the SDK logs a warning.

Functional Configuration

Use RdpOptions in Kotlin, or RdpOptions.Builder in Java, to configure the client directly. cfg.toOptions() converts a loaded RdpConfig into client options before calling RdpClient.create(...).

Kotlin callers can use named parameters:

val logger =LoggerFactory.getLogger("rdp")
val options =RdpOptions(
endpoint ="https://rdp.example.com",
apiKey ="your-api-key",
timeout =Duration.ofSeconds(10),
logger = logger,
)
RdpClient.create(options).use { client ->// call generated service clients
}

Static Authorization header auth can be configured directly as well:

val bearerOptions =RdpOptions(
endpoint ="https://rdp.example.com",
bearerToken ="token",
)

Kotlin callers can also start from environment configuration and override only what needs to be programmatic:

val cfg = loadConfig(envPath =".env.local", logger = logger)
val options = cfg.toOptions().copy(timeout =Duration.ofSeconds(10))
RdpClient.create(options).use { client ->// call generated service clients
}

Java callers can use the builder:

varlogger = LoggerFactory.getLogger("rdp");
varoptions = newRdpOptions.Builder()
.endpoint("https://rdp.example.com")
.apiKey("your-api-key")
.timeout(Duration.ofSeconds(10))
.logger(logger)
.build();
try (varclient = RdpClient.create(options)) {
// call generated service clients
}

Java callers can configure Bearer auth through the builder:

varbearerOptions = newRdpOptions.Builder()
.endpoint("https://rdp.example.com")
.bearerToken("token")
.build();

Use clientCredentials(...) only when your deployment requires OAuth2 client credentials. Use tlsSkipVerify(true) only for development or test endpoints with self-signed certificates.

About

RDP SDK for Java/Kotlin

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages