diff options
author | 2018-02-22 14:43:42 -0500 | |
---|---|---|
committer | 2018-02-22 14:46:57 -0500 | |
commit | e023325d3e76a71ac795ebbdb74f5a89756040a7 (patch) | |
tree | 63b2816a829c785f3c0329c3ea57ebd3c4f2937d /src/chameleon/aai_processor.clj | |
parent | 2610df2fc29a9d16bb869f652d4d21caeae4c154 (diff) |
Initial Commit of Chameleon
Commit the initial set of code for the Chameleon offering to ONAP
Change-Id: Ia58bd49eafc0a3702c17c9cab34d666ed1627ba5
Issue-ID: AAI-797
Signed-off-by: Adrian Batos-Parac <adrian.batos-parac@amdocs.com>
Diffstat (limited to 'src/chameleon/aai_processor.clj')
-rw-r--r-- | src/chameleon/aai_processor.clj | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/chameleon/aai_processor.clj b/src/chameleon/aai_processor.clj new file mode 100644 index 0000000..c709ed1 --- /dev/null +++ b/src/chameleon/aai_processor.clj @@ -0,0 +1,26 @@ +(ns chameleon.aai-processor + (:require [chameleon.txform :refer :all] + [chameleon.route :refer :all] + [cheshire.core :refer :all])) + +(defn from-gallifrey + "Transforms Gallifrey response payloads into a format consumable by AAI-centric clients" + [body] + (->> body + (map (fn [[k v]] [(clojure.string/split k #"\.") v])) + ((fn [x] (reduce #(assoc-in %1 (first %2) (second %2) ) {} x))))) + +(defn from-spike + "Transforms Spike-based event payloads to a format accepted by Gallifrey for vertices and relationships" + [gallifrey-host payload] + (let [txpayload (map-keywords (parse-string payload)) + operation (:operation txpayload) + entity-type (if (contains? txpayload :vertex) + :vertex + :relationship) + entity (map-keywords (entity-type txpayload)) + key (:key entity) + properties (assoc (:properties entity) :type (:type entity))] + (assert-gallifrey gallifrey-host "aai" (if (= entity-type :vertex) + {:meta {:key key :operation operation} :body (generate-string properties)} + {:meta {:key key :operation operation} :body (generate-string (conj properties (flatten-entry entity :source) (flatten-entry entity :target)))})))) |