Table of Contents
Description
This is an example of a wrapper Java library for our API functionality, it provide an easy way to interact with Split from within your application.
The Java client is instantiated using an admin API key, for more information on how to generate API Key, please click here
Get Started
- Download the Java Library from the following
Link - Once the library is downloaded, use the splitapi.jar in your project
- Instantiate the Wrapper and Create a New Split API Client
import java.io.IOException;
import java.util.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.split.api.SplitApiClient;
import io.split.api.client.exceptions.SplitException;
import io.split.api.dtos.*;
public class NewAdmin {
public static void main(String[] args) throws SplitException, JsonProcessingException, IOException {
SplitApiClient client = SplitApiClient.client("ADMIN API KEY");
}
}
Workspaces
- Structure
"id": "string", // Server populated identifier
"name": "string", // Display name
- Methods
list
Return list of existing Workspaces in the Organization as workspace object
List<Workspace> result = client.workspaces().list();
System.out.println(result+"\n");
Environments
- Structure
"id": "string", // Server populated identifier
"name": "string", // Display name
"production": "boolean" // Production environment or not
"workspace":"string" // workspace id
- Methods
list
Return list of existing Environments for given Workspace
Params: Workspace ID
List<Environment> result2 = client.environments().list(workspaceId);
System.out.println(result2+"\n");
TrafficTypes
- Structure
"id": "string", // Server populated identifier
"name": "string", // Display name
"workspace":"string" // workspace id
"displayAttributeId": "string" // (Optional) Attribute used for display name in UI
- Methods
list
Return list of all existing TestTypes in the organization
List<TrafficType> result3 = client.trafficTypes().list(workspaceId);
System.out.println(result3+"\n");
Attributes
- Structure
"id": "string", // Attribute identifier, same as used in identity value map
"workspace":"string" // workspace id
"trafficTypeId": "string", // Traffic type this attribute is associated with
"displayName": "string", // (Optional) How the attribute will be displayed in the UI, defaults to the id
"description": "string", // (Optional) A description of the attribute
"dataType": "string", // (Optional) The data type of the attribute used for display formatting, defaults to displaying the raw string. Must be one of: null, "string", "datetime", "number", "set"
"isSearchable": boolean // (Optional) Deprecated, included for backward compatibility
- Methods
list
Return list of all existing Attributes for a given Workspace and TestType Ids
Params: Workspace Id, TestType Id
List<Attribute> result4 = client.attributes().list(testTypeId, workspaceId);
System.out.println(result4+"\n");
save
Save an attribute for a traffic type ID. The attribute is created if it does not exist and is overwritten completely if it does.
Params: workspace Id, trafficType Id, display name, description, data type, isSearchable
Attribute rs = client.attributes().create(
Attribute.builder()
.id("attrib777")
.trafficTypeId(testTypeId)
.dataType("string")
.displayName("Province")
.build(),
workspaceId
);
Customer Identities
- Structure
key: "string", // Key used for getTreatment() calls
trafficTypeId: "string", // Traffic Type Identifier
environmentId: "string", // Environment Identifier
values: { // Attribute Values (key: Attribute Id, value: value)
key: "string",...
- Methods
save
Create or overwrite a single customer ID for a given traffic type and environment.
Params: environment Id, trafficType Id, key, values OR Collection
Identity id = client.identities().save(
Identity.builder()
.key(userId)
.trafficTypeId(testTypeId)
.environmentId(environmentId)
.addValue("attrib911","Canada")
.build()
);
update
Update a single customer ID for a given traffic type and environment. Any provided attribute values will be overwritten, but existing values will otherwise remain.
Params: environment Id, trafficType Id, key, values
Identity id = client.identities().update(
Identity.builder()
.key(userId)
.trafficTypeId(testTypeId)
.environmentId(environmentId)
.addValue("attrib911","Canada")
.build()
);
Comments
0 comments
Please sign in to leave a comment.