-
-In this example we create the relationship:
-
-dog eats dogPellets
-
-```
-ChampRelationship.create()
- .ofType("eats")
- .withoutKey()
- .withSource()
- .ofType("dog")
- .withoutKey()
- .withProperty("name", "champ")
- .build()
- .withTarget()
- .ofType("dogPellets")
- .withoutKey()
- .withProperty("brand", "costco")
- .build()
- .withProperty("at", System.currentTimeMillis())
- .build()
-```
-
-#### Persisting a relationship
-
-```
-final ChampGraph graph = ChampGraph.Factory.newInstance(graphType, "neighborhoodDogsGraph");
-graph.storeRelationship(champEatsCostcoFood); //'champEatsCostcoFood' is a reference to a ChampRelationship
-graph.shutdown(); //The ChampGraph is thread-safe, and only one needs to be created
- //Once your application is finished using it, call shutdown()
- //to cleanup any loose ends
-```
-
-#### Retrieving incident relationships
-
-```
-final ChampGraph graph = ChampGraph.Factory.newInstance(graphType, "neighborhoodDogsGraph");
-final Stream<ChampRelationship> relationships = graph.retrieveRelationships(ChampObject.create().withKey("foo").build());
-
-relationships.close(); //You must close the stream when you are done with it
-graph.shutdown(); //The ChampGraph is thread-safe, and only one needs to be created
-
-```
-
-#### Querying relationship
-
-```
-final ChampGraph graph = ChampGraph.Factory.newInstance(graphType, "neighborhoodDogsGraph");
-final Stream<ChampRelationship> relationships = graph.queryRelationships(Collections.singletonMap("favoriteHydrant", 42);
-
-relationships.close(); //You must close the stream when you are done with it
-graph.shutdown(); //The ChampGraph is thread-safe, and only one needs to be created
-
-```
-
-### Creating partitions
-#### Create a new partition
-
-Champ partitions are subgraphs (i.e. a collection of objects and relationships)
-** Note: We are still in the proces of creating a fluent API for partitions **
-
-
-```
-ChampPartition.create()
- .withObject(
- ChampObject.create()
- .ofType("dog")
- .withoutKey()
- .build()
- )
- .withObject(
- ChampObject.create()
- .ofType("cat")
- .withoutKey()
- .build()
- .withObject(
- ChampObject.create()
- .ofType("bird")
- .withoutKey()
- .build()
- )
- .withRelationship(
- ChampRelationship.create()
- ...
- .build()
- )
- .build()
-```
-
-#### Persisting a partition
-
-```
-final ChampGraph graph = ChampGraph.Factory.newInstance(graphType, "neighborhoodDogsGraph");
-graph.storePartition(dogsOnMyBlock); //'dogsOnMyBlock' is a reference to a ChampPartition
-graph.shutdown(); //The ChampGraph is thread-safe, and only one needs to be created
- //Once your application is finished using it, call shutdown()
- //to cleanup any loose ends
-```
-
-### Creating indices
-#### Create an object index
-
-```
-ChampObjectIndex.create()
- .ofName("dogName")
- .onType("dog")
- .forField("name")
- .build()
-```
-
-#### Create a relationship index
-
-```
-ChampRelationshipIndex.create()
- .ofName("eatsAtTime")
- .onType("eats")
- .forField("at")
- .build()
-```
-
-#### Persisting an object index
-
-```
-final ChampGraph graph = ChampGraph.Factory.newInstance(graphType, "neighborhoodDogsGraph");
-graph.storeObjectIndex(dogName); //'dogName' is a reference to a ChampObjectIndex
-graph.shutdown(); //The ChampGraph is thread-safe, and only one needs to be created
- //Once your application is finished using it, call shutdown()
- //to cleanup any loose ends
-```
-
-#### Persisting a relationship index
-
-```
-final ChampGraph graph = ChampGraph.Factory.newInstance(graphType, "neighborhoodDogsGraph");
-graph.storeRelationshipIndex(eatsAtTime); //'eatsAtTime' is a reference to a ChampObjectIndex
-graph.shutdown(); //The ChampGraph is thread-safe, and only one needs to be created
- //Once your application is finished using it, call shutdown()
- //to cleanup any loose ends
-```
-#### Retrieving an object index
-
-```
-final ChampGraph graph = ChampGraph.Factory.newInstance(graphType, "neighborhoodDogsGraph");
-graph.retrieveObjectIndex("dogName");
-graph.shutdown();
-
-```
-
-#### Retrieving a relationship index
-
-```
-final ChampGraph graph = ChampGraph.Factory.newInstance(graphType, "neighborhoodDogsGraph");
-graph.retrieveRelationshipIndex("eatsAtTime");
-graph.shutdown();
-
-```
-
-### Creating schemas
-#### Create a schema
-
-The following schema restricts objects of type foo to have a required property "property1" as an Integer, and optional property "property2" as a String (Strings are the default type for object properties). It also restricts relationships of type bar to only be allowed to originate from the object type foo.
-
-```
-ChampSchema.create()
- .withObjectConstraint()
- .onType("foo")
- .withPropertyConstraint()
- .onField("property1")
- .ofType(Integer.class)
- .required()
- .build()
- .withPropertyConstraint()
- .onField("property2")
- .optional()
- .build()
- .build()
- .withRelationshipConstraint()
- .onType("bar")
- .withPropertyConstraint()
- .onField("at")
- .ofType(String.class)
- .optional()
- .build()
- .withConnectionConstraint()
- .sourcedFrom("foo")
- .targetToAny()
- .build()
- .build()
- .build();
-```
-
-#### Persisting a schema
-
-```
-final ChampGraph graph = ChampGraph.Factory.newInstance(graphType, "neighborhoodDogsGraph");
-graph.storeSchema(neighborhoodDogsSchema); //'neighborhoodDogsSchema' is a reference to a ChampObjectIndex
-graph.updateSchema(neighborhoodDogConstraint); //'neighborhoosDogConstraint' is a reference to a ChampObjectConstraint
-graph.updateSchema(eatsAtConstraint); //'eatsAtConstraint' is a reference to a ChampRelationshipIndex
-graph.shutdown(); //The ChampGraph is thread-safe, and only one needs to be created
- //Once your application is finished using it, call shutdown()
- //to cleanup any loose ends
-```
-
-#### Retrieving a schema
-
-```
-final ChampGraph graph = ChampGraph.Factory.newInstance(graphType, "neighborhoodDogsGraph");
-
-final ChampSchema schema = graph.retrieveSchema();
-
-graph.shutdown();
-
-```
-
-### Champ Performance Testing
-
-There is a jar-with-dependencies provided in maven that contains a performance test you can move around and get some idea of how well Champ is running on a cluster of your choice. At the moment, the test only runs against a Titan implementation.
-
-#### Example running an in-memory test
-
-```
-
-java -cp champ-0.0.1-SNAPSHOT-jar-with-dependencies.jar org.openecomp.aai.champ.perf.ChampAPIPerformanceTest --champ.graph.type=IN_MEMORY
-
-
-```
-
-#### Example running a Titan test
-
-Note that after the --champ.graph.type=TITAN parameter is provided, you may provide any configuration that is specified by Titan (see link above for the documentation)
-
-```
-
-java -cp champ-0.0.1-SNAPSHOT-jar-with-dependencies.jar org.openecomp.aai.champ.perf.ChampAPIPerformanceTest --champ.graph.type=TITAN --storage.backend=cassandrathrift --storage.hostname=localhost
-
-
-```
+Creates a new relationship with the specified properties. "source" and "target" must be objects that have already been created, specified by their keys. Returns the created relationship with its key and timestamps.
+
+ URL: https://<host>:9522/services/champ-service/v1/relationships
+ Method: POST
+ Content:
+ {
+ "type": "testOnTest2",
+ "properties": {
+ "beep": "boop",
+ "a": "b"
+ },
+ "source": {
+ "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "type": "test",
+ "properties": {
+ "key1": "val3",
+ "key2": "val2",
+ "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "key4": "val4"
+ }
+ },
+ "target": {
+ "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "type": "test2",
+ "properties": {
+ "key1": "val1",
+ "key2": "val2",
+ "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "key4": "val4"
+ }
+ }
+ }
+
+ Response:
+ Code: 201 Created
+ Content:
+ {
+ "key": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1",
+ "type": "testOnTest2",
+ "properties": {
+ "beep": "boop",
+ "a": "b",
+ "aai-uuid": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1"
+ "aai-last-mod-ts": 1516730919213,
+ "aai-created-ts": 1516730919213
+ },
+ "source": {
+ "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "type": "test",
+ "properties": {
+ "key1": "val3",
+ "key2": "val2",
+ "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "key4": "val4"
+ }
+ },
+ "target": {
+ "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "type": "test2",
+ "properties": {
+ "key1": "val1",
+ "key2": "val2",
+ "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "key4": "val4"
+ }
+ }
+ }
+
+#### Retrieving relationships
+Returns the relationship, looked up by key.
+
+ URL: https://<host>:9522/services/champ-service/v1/relationships/<key>
+ Method: GET
+ Response:
+ Code: 200 OK
+ Content:
+ {
+ "key": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1",
+ "type": "testOnTest2",
+ "properties": {
+ "beep": "boop",
+ "a": "b",
+ "aai-uuid": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1"
+ "aai-last-mod-ts": 1516730919213,
+ "aai-created-ts": 1516730919213
+ },
+ "source": {
+ "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "type": "test",
+ "properties": {
+ "key1": "val3",
+ "key2": "val2",
+ "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "key4": "val4"
+ }
+ },
+ "target": {
+ "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "type": "test2",
+ "properties": {
+ "key1": "val1",
+ "key2": "val2",
+ "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "key4": "val4"
+ }
+ }
+ }
+
+ #### Get relationships for an object
+ Given an object, returns all connected relationships.
+
+ URL: https://<host>:9522/services/champ-service/v1/objects/relationships/<object-id>
+ Method: GET
+ Success Response:
+ Code: 200 OK
+ Content:
+ [
+ {
+ "key": "4ba8dcc2-806d-4312-aecb-503435f355e5",
+ "type": "testOnTest2",
+ "properties": {
+ "beep": "fdsa",
+ "a": "c",
+ "aai-uuid": "4ba8dcc2-806d-4312-aecb-503435f355e5"
+ },
+ "source": {
+ "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "type": "test",
+ "properties": {
+ "key1": "val3",
+ "key2": "val2",
+ "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "key4": "val4"
+ }
+ },
+ "target": {
+ "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "type": "test2",
+ "properties": {
+ "key1": "val1",
+ "key2": "val2",
+ "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "key4": "val4"
+ }
+ }
+ },
+ {
+ "key": "a3096bb8-dc66-4a9c-ab33-a1183f784fbb",
+ "type": "testOnTest2",
+ "properties": {
+ "beep": "fdsa",
+ "a": "c",
+ "aai-uuid": "a3096bb8-dc66-4a9c-ab33-a1183f784fbb"
+ },
+ "source": {
+ "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "type": "test",
+ "properties": {
+ "key1": "val3",
+ "key2": "val2",
+ "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "key4": "val4"
+ }
+ },
+ "target": {
+ "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "type": "test2",
+ "properties": {
+ "key1": "val1",
+ "key2": "val2",
+ "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "key4": "val4"
+ }
+ }
+ }
+ ]
+
+#### Updating relationships
+Update the relationship properties. Passing timestamps is optional, but the request will be rejected if they are incorrect.
+
+ URL: https://<host>:9522/services/champ-service/v1/relationships/<key>
+ Method: PUT
+ Content:
+ {
+ "key": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1",
+ "type": "testOnTest2",
+ "properties": {
+ "beep": "borp",
+ "a": "c",
+ "aai-uuid": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1"
+ },
+ "source": {
+ "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "type": "test",
+ "properties": {
+ "key1": "val3",
+ "key2": "val2",
+ "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "key4": "val4"
+ }
+ },
+ "target": {
+ "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "type": "test2",
+ "properties": {
+ "key1": "val1",
+ "key2": "val2",
+ "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "key4": "val4"
+ }
+ }
+ }
+
+ Response:
+ Code: 200 OK
+ Content:
+ {
+ "key": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1",
+ "type": "testOnTest2",
+ "properties": {
+ "beep": "borp",
+ "a": "c",
+ "aai-uuid": "7a3282d0-6904-40f2-ae1e-8246bb1f49c1",
+ "aai-last-mod-ts": 1516734987294,
+ "aai-created-ts": 1516730919213
+ },
+ "source": {
+ "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "type": "test",
+ "properties": {
+ "key1": "val3",
+ "key2": "val2",
+ "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "key4": "val4"
+ }
+ },
+ "target": {
+ "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "type": "test2",
+ "properties": {
+ "key1": "val1",
+ "key2": "val2",
+ "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "key4": "val4"
+ }
+ }
+ }
+
+#### Deleting relationships
+Deletes the relationship specified by key.
+
+ URL: https://<host>:9522/services/champ-service/v1/relationships/<key>
+ Method: Delete
+ Response: 200 OK
+
+#### Filtered Relationship
+Returns a list of relationships that have key/value properties matching the filter
+
+ URL: https://<host>:9522/services/champ-service/v1/objects/filter?<key>=<val>
+ Method: GET
+ Success Response:
+ [
+ {
+ "key": "a4d51cd9-f271-4201-975d-168ec6bde501",
+ "type": "testOnTest2",
+ "properties": {
+ "beep": "yes",
+ "a": "c",
+ "aai-uuid": "a4d51cd9-f271-4201-975d-168ec6bde501"
+ },
+ "source": {
+ "key": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "type": "test",
+ "properties": {
+ "key1": "val3",
+ "key2": "val2",
+ "aai-uuid": "890c8b3f-892f-48e3-85cd-748ebf0426a5",
+ "key4": "val4"
+ }
+ },
+ "target": {
+ "key": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "type": "test2",
+ "properties": {
+ "key1": "val1",
+ "key2": "val2",
+ "aai-uuid": "559855df-62e2-4b06-a1ae-18e0d5ac9826",
+ "key4": "val4"
+ }
+ }
+ }
+ ]
+
+### Transactions
+Transactions allow multiple graph operations to be grouped into a logical, sandboxed context, so that the option exists to either persist ALL of the grouped changes together, or NONE of them.
+
+Explicit use of transactions is entirely optional for the client. Calling the API methods described below without supplying a transaction
+object results in a transaction being implicitly opened for the single operation, and then automatically committed.
+
+However, all of the API calls described above related to persisting, retrieving, and deleting vertices, edges and graph partitions also
+expose a version of the call which optionally accepts a transaction id (acquired by explicitly calling the /transaction API endpoint).
+In this case, the supplied transaction is used for the operation, and no automatic commit occurs. It is the responsibility of
+the client to explicitly commit or rollback the transaction at his or her discretion.
+
+#### Open a new transaction
+To use explicit transaction the client must request a transaction id from the Champ service by making a request to open a new transaction.
+
+ URL: https://<host>:9522/services/champ-service/v1/transaction/
+ Method: POST
+ Response:
+ Code: 200 OK
+ Content: 5d90f5ae-1f1e-4c3e-b20b-2f7c45f822eb
+
+#### Working within a transaction
+Operations can be done within a transaction by putting the transactionId in the query string.
+
+ Query string: transactionId=<id>
+
+Example object creation:
+
+ URL: https://<host>:9522/services/champ-service/v1/objects?transactionId=5d90f5ae-1f1e-4c3e-b20b-2f7c45f822eb
+
+Example relationship update:
+
+ URL: https://<host>:9522/services/champ-service/v1/relationships/<key>?transactionId=5d90f5ae-1f1e-4c3e-b20b-2f7c45f822eb
+
+#### Checking a transaction
+If you wish to check the status of a transaction, you can do a get on it
+
+ URL: https://<host>:9522/services/champ-service/v1/transaction/<transaction-id>
+ Method: GET
+If the transaction is currently open:
+
+ Response:
+ Code: 200 OK
+ Content: "fa0890d9-6ac4-40aa-9838-745a25a61fa6 is OPEN"
+If the transaction is not open:
+
+ Response:
+ Code: 404 Not Found
+ Content: {}
+
+
+#### Committing a transaction
+Operations performed within the context of a transaction are not visible outside of that context
+until the client explicitly commits the transaction. Up until that point, there is always the
+option to just roll back the changes.
+
+ URL: https://<host>:9522/services/champ-service/v1/transaction/<transaction-id>
+ Method: PUT
+ Content: {"method":"commit"}
+
+ Response:
+ Code: 200 OK
+ Content: COMMITED
+
+### Rolling back a transaction.
+In the event that a sequence of graph operations which were performed within the same transactional context need to be aborted (for example one of the operations in the sequence encountered a failure of some kind) the entire transaction can be aborted by rolling back the transaction. This effectively undoes all of the operations which were performed within the open transaction.
+
+Note, once a transaction has been committed, it is no longer possible to rollback the contents of the transaction.
+
+ URL: https://<host>:9522/services/champ-service/v1/transaction/<transaction-id>
+ Method: PUT
+ Content: {"method":"rollback"}
+
+ Response:
+ Code: 200 OK
+ Content: ROLLED BACK