On trying to run JAVA DK of AWS clouddirectory and creating an object ... i always get this ERROR:
Unable to determine if node is one of LeafNode, Node, Policy, Index (Service: CloudDirectory, Status Code: 400, Request ID: 3448687c-d30f-434e-a4e6-76fbb057f5f1)
I tried to create a specific node, of type index, but it didn't work well! I had same output errors on aws cli, but then it just worked ... still not working with JAVA☕
TestAWSCloudDirectory.java code snippet:
package com.pontusvision.graphutils;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.services.clouddirectory.CloudDirectoryClient;
import software.amazon.awssdk.services.clouddirectory.model.*;
import java.util.ArrayList;
import java.util.Collection;
public class TestAWSCloudDirectory {
public static void main(String[] args) throws Exception {
DefaultCredentialsProvider credentials = null;
try {
credentials = DefaultCredentialsProvider.create(); // where is the file ?!
} catch (Exception e) {
throw new Exception(
"Cannot load the credentials from the credential profiles file. " +
"Please make sure that your credentials file is at the correct " +
"location, and is in valid format.",
e);
}
CloudDirectoryClient client = CloudDirectoryClient.builder()
.credentialsProvider(credentials).build();
AttributeKey attributeKey = AttributeKey.builder().schemaArn("***********************************************************")
.facetName("DynamicObjectFacet")
.name("Person_Natural").build();
TypedAttributeValue attributeValue = TypedAttributeValue.fromStringValue("Leo");
AttributeKeyAndValue attrib = AttributeKeyAndValue.builder().key(attributeKey).value(attributeValue).build();
SchemaFacet schemaFacet = SchemaFacet.builder().facetName("DynamicObjectFacet").schemaArn("***********************************************************").build();
Collection<AttributeKeyAndValue> objectAttributeList = new ArrayList<>();
objectAttributeList.add(attrib);
ObjectReference objectReference = ObjectReference.builder().selector("/").build();
client.createObject(CreateObjectRequest.builder().directoryArn("***********************************************************")
.objectAttributeList(objectAttributeList)
.schemaFacets(schemaFacet)
.build());
client.close();
}
}
pom.xml aws and cloud-directory dependencies:
(...)
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>clouddirectory</artifactId>
<version>2.20.26</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>auth</artifactId>
<version>2.20.26</version>
</dependency>
(...)