[AAI-604] Documenting response.
[aai/gizmo.git] / ASYNC.md
index 7dfc35c..97167f3 100644 (file)
--- a/ASYNC.md
+++ b/ASYNC.md
@@ -9,6 +9,10 @@ response for that particular event on a different event stream. Once it recieves
 response, gizmo will send a response back to the client which made the
 original request.
 
+Note: In the examples below, there is a database-transaction-id and a
+transaction-id. A database-transaction-id is only present in the
+payload when it's part of bulk operation.
+
 ## Here are a few examples of the events published by Gizmo
 
 ### Vertex
@@ -150,3 +154,198 @@ original request.
       "transaction-id": "b4583bc9-dd96-483f-ab2d-20c1c6e5622f",
       "database-transaction-id": "b3e2853e-f643-47a3-a0c3-cb54cc997ad3"
     }
+
+
+## Gizmo expects a response event in the following formats
+
+### Vertex
+
+#### Adding Vertex Response
+
+    {
+      "timestamp": 1519832579046,
+      "operation": "CREATE",
+      "vertex": {
+        "properties": {
+          "last-mod-source-of-truth": "champ-response",
+          "resource-version": "1477013499",
+          "aai-uuid": "12a0ca27-25b1-41c2-b9ff-4bf54a3caa8a",
+          "in-maint": false,
+          "equip-model": "DELL380p-nd",
+          "hostname": "updated-myhost",
+          "source-of-truth": "champ-response",
+          "ipv4-oam-address": "1.2.3.4",
+          "aai-created-ts": 1519832577709,
+          "purpose": "my-purpose",
+          "fqdn": "updated.myhost.onap.net",
+          "equip-vendor": "DELL",
+          "equip-type": "updated-server",
+          "aai-last-mod-ts": 1519832577709,
+          "ptnii-equip-name": "testing"
+        },
+        "key": "12a0ca27-25b1-41c2-b9ff-4bf54a3caa8a",
+        "type": "pserver",
+        "schema-version": "v11"
+      },
+      "transaction-id": "d5c15dd3-2492-4ab9-86a3-e1cd39221e4a",
+      "result": "SUCCESS"
+    }
+
+#### Updating Vertex Response
+
+    {
+      "timestamp": 1519833774425,
+      "operation": "UPDATE",
+      "vertex": {
+        "properties": {
+          "last-mod-source-of-truth": "shwetank-updating",
+          "resource-version": "shwetank-resource",
+          "aai-uuid": "12a0ca27-25b1-41c2-b9ff-4bf54a3caa8a",
+          "in-maint": false,
+          "equip-model": "testing-update",
+          "hostname": "sdave",
+          "source-of-truth": "champ-response",
+          "ipv4-oam-address": "1.2.3.4",
+          "aai-created-ts": 1519832577709,
+          "purpose": "my-purpose-testing-update",
+          "fqdn": "created.myhost.onap.net",
+          "equip-vendor": "testing-update",
+          "equip-type": "shwetank",
+          "aai-last-mod-ts": 1519833774407,
+          "ptnii-equip-name": "testing-update"
+        },
+        "key": "12a0ca27-25b1-41c2-b9ff-4bf54a3caa8a",
+        "type": "pserver",
+        "schema-version": "v11"
+      },
+      "transaction-id": "2981a1b0-30d6-4323-8b36-c80636a1639f",
+      "result": "SUCCESS"
+    }
+
+
+#### Deleting Vertex Response
+
+    {
+      "timestamp": 1519839126416,
+      "operation": "DELETE",
+      "vertex": {
+        "key": "12a0ca27-25b1-41c2-b9ff-4bf54a3caa8a",
+        "type": "pserver",
+        "schema-version": "v11"
+      },
+      "transaction-id": "78650070-a500-47bb-98e5-e46aba77612a",
+      "result": "SUCCESS"
+    }
+
+
+### Edge
+
+#### Adding Edge Response
+
+    {
+      "timestamp": 1519835679492,
+      "operation": "CREATE",
+      "edge": {
+        "target": {
+          "key": "2674b073-2eb5-484b-a21c-7e36983b7cd4",
+          "type": "pserver"
+        },
+        "properties": {
+          "contains-other-v": "NONE",
+          "delete-other-v": "NONE",
+          "aai-created-ts": 1519835679447,
+          "prevent-delete": "IN",
+          "SVC-INFRA": "OUT",
+          "aai-uuid": "149620ae-2382-41a2-b626-1dd321fad4bb",
+          "aai-last-mod-ts": 1519835679447
+        },
+        "key": "149620ae-2382-41a2-b626-1dd321fad4bb",
+        "type": "tosca.relationships.HostedOn",
+        "schema-version": "v11",
+        "source": {
+          "key": "b945d923-b596-4339-a80f-f72ca9a4fe1f",
+          "type": "vserver"
+        }
+      },
+      "transaction-id": "83c7776d-88c9-4fbe-b129-11f40d20348b",
+      "result": "SUCCESS"
+    }
+
+#### Update Edge Response
+
+    {
+      "timestamp": 1519838804681,
+      "operation": "UPDATE",
+      "edge": {
+        "target": {
+          "key": "2674b073-2eb5-484b-a21c-7e36983b7cd4",
+          "type": "pserver"
+        },
+        "properties": {
+          "contains-other-v": "NONE",
+          "delete-other-v": "NONE",
+          "aai-created-ts": 1519835679447,
+          "SVC-INFRA": "OUT",
+          "prevent-delete": "TRUE",
+          "aai-uuid": "149620ae-2382-41a2-b626-1dd321fad4bb",
+          "aai-last-mod-ts": 1519838804671
+        },
+        "key": "149620ae-2382-41a2-b626-1dd321fad4bb",
+        "type": "tosca.relationships.HostedOn",
+        "schema-version": "v11",
+        "source": {
+          "key": "b945d923-b596-4339-a80f-f72ca9a4fe1f",
+          "type": "vserver"
+        }
+      },
+      "transaction-id": "644839f0-bb6d-490f-8f79-bb8227198ed2",
+      "result": "SUCCESS"
+    }
+
+#### Delete Edge Response
+
+    {
+      "timestamp": 1519838964576,
+      "operation": "DELETE",
+      "edge": {
+        "key": "149620ae-2382-41a2-b626-1dd321fad4bb",
+        "type": "tosca.relationships.HostedOn",
+        "schema-version": "v11"
+      },
+      "transaction-id": "db3e67ae-28e3-4c1d-bf63-ec398cf28d98",
+      "result": "SUCCESS"
+    }
+
+
+### Misc
+
+#### Failed Operation Response
+
+
+    {
+      "timestamp": 1519843867529,
+      "operation": "UPDATE",
+      "httpErrorStatus": "BAD_REQUEST",
+      "error-message": "aai-created-ts can't be updated",
+      "vertex": {
+        "properties": {
+          "last-mod-source-of-truth": "shwetank-creating-for-update",
+          "ipv4-oam-address": "1.2.3.4",
+          "aai-created-ts": 123456789,
+          "resource-version": "shwetank-resource",
+          "purpose": "my-purpose-creating-for-patching",
+          "fqdn": "created.myhost.onap.net",
+          "in-maint": false,
+          "equip-model": "creating-for-patching",
+          "equip-vendor": "creating-for-patching",
+          "equip-type": "testing-2",
+          "hostname": "sdave",
+          "ptnii-equip-name": "creating-for-patching"
+        },
+        "key": "10572385-3211-4c80-a7c5-cea648513271",
+        "type": "pserver",
+        "schema-version": "v11"
+      },
+      "transaction-id": "25d4c3e9-d4ab-41ec-b2a9-832286a726db",
+      "result": "FAILURE"
+    }