Rest and Java Sample Codes
Applies to: Kyvos Enterprise Kyvos Cloud (SaaS on AWS) Kyvos AWS Marketplace
Kyvos Azure Marketplace  Kyvos GCP Marketplace Kyvos Single Node Installation (Kyvos SNI)
Here are some sample codes to help you use REST and Java APIs for working with Kyvos entities.Â
Adding new user group in KyvosÂ
/**Method to add new group in Kyvos*/
public static void addGroup(String groupName) throws UnsupportedEncodingException {
UserGroup group = new UserGroup();
group.setGroupName(groupName);
group.setUserGroupId(groupName);
group.setDescription("test Group");
group.setRole("0");
group.setGroupType(UserAuthType.NATIVE);
group.setUserIds(new String[]{""});
System.out.println(group.getXML());
String params = "groupXML="+URLEncoder.encode(group.getXML(), java.nio.charset.StandardCharsets.UTF_8.toString());
RESTClient.sendRequest("group", params, "POST");
Updating user group in KyvosÂ
/**Method to update a group in Kyvos*/
public static void updateGroup(String groupName) throws UnsupportedEncodingException {
String groupXML = RESTClient.sendRequest("group/"+groupName+"?addResponseTag=false", null, "GET");
System.out.println(groupXML);
UserGroup group = new UserGroup(groupXML);
System.out.println(group.getXML());
group.setUserIds(new String[]{"", ""});
String params = "groupXML="+URLEncoder.encode(group.getXML(), java.nio.charset.StandardCharsets.UTF_8.toString());
RESTClient.sendRequest("group/"+group.getGroupName(), params, "PUT");
Creating new relationship design
/**Method to create a fresh DRD*/
public static void createDRD() throws Exception {
String RF_1_ID = "";
String RF_2_ID = "";
DRDObject drdObject = new DRDObject();
drdObject.setViewType(Enums.DRDViewType.TABULAR);
drdObject.setName("");
drdObject.setId(Utility.getGUID());
drdObject.setFolderName("");
drdObject.setFolderId("");
// Creating DRD Node using registered file id
DRDObject.DRDDatasetDetails node1 = new DRDObject.DRDDatasetDetails();
node1.setId(RF_1_ID);
node1.setAliasName("NODE_NAME_1");
drdObject.addNode("NODE_ID_1", node1);
DRDObject.DRDDatasetDetails node2 = new DRDObject.DRDDatasetDetails();
node2.setId(RF_2_ID);
node2.setAliasName("NODE_NAME_2");
drdObject.addNode("NODE_ID_2", node2);
DRDRelation drdRelation = new DRDRelation();
drdRelation.setSourceID("NODE_ID_1");
drdRelation.setFirstDSID("NODE_ID_1");
drdRelation.setSecondDSID("NODE_ID_2");
drdRelation.setRelationType("ONE_TO_MANY");
drdRelation.addJoin("ID", "Product_ID");
drdRelation.setRelationName("test");
ArrayList<DRDRelation> drdRelationList = new ArrayList<>();
drdRelationList.add(drdRelation);
drdObject.getDrdRelationsMap().put(Utility.getClientGuid(""), drdRelationList);
System.out.println(drdObject.getXML());
String params = "drdXML="+URLEncoder.encode(drdObject.getXML(), java.nio.charset.StandardCharsets.UTF_8.toString());
System.out.println(RESTClient.sendRequest("datasetrelationship", params, "POST"));
}
Updating relationship design
Adding single data security rule to semantic model
Updating single data security rule
Getting data security rule
Deleting data security rule from semantic model of given semantic model ID
Adding data security rules mapping for user
Adding data security rules mapping for a group
Creating a Registered fileÂ
Creating semantic model
Updating a semantic model
Adding a connectionÂ
Updating a connectionÂ
Copyright Kyvos, Inc. All rights reserved.