NonRT-RIC A1 Northbound API

Initial SEED CODE
Issue-ID: NONRTRIC-36
Change-Id: I72c537297c3440f49af0160b0029488959f5556b
Signed-off-by: Lathish <lathishbabu.ganesan@est.tech>
diff --git a/sdnc-a1-controller/northbound/nonrt-ric-api/model/pom.xml b/sdnc-a1-controller/northbound/nonrt-ric-api/model/pom.xml
new file mode 100644
index 0000000..8bef79e
--- /dev/null
+++ b/sdnc-a1-controller/northbound/nonrt-ric-api/model/pom.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ============LICENSE_START=======================================================
+   Copyright (C) 2019-2020 Nordix Foundation.
+  ================================================================================
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+  SPDX-License-Identifier: Apache-2.0
+  ============LICENSE_END=========================================================
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onap.ccsdk.parent</groupId>
+        <artifactId>binding-parent</artifactId>
+        <version>1.4.3</version>
+        <relativePath/>
+    </parent>
+
+    <groupId>org.onap.sdnc.northbound</groupId>
+    <artifactId>nonrt-ric-api-model</artifactId>
+    <version>1.7.3-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <name>sdnc-northbound :: nonrt-ric-api :: ${project.artifactId}</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+            <artifactId>rfc6991</artifactId>
+        </dependency>
+
+        
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <version>1.2.1</version>
+                <executions>
+                    <execution>
+                        <configuration>
+                            <executable>python</executable>
+                            <arguments>
+                                <argument>scripts/python/yang2props.py</argument>
+                                <argument>src/main/yang/NONRT-RIC-API.yang</argument>
+                                <argument>target/nonrt-ric-api.properties</argument>
+                            </arguments>
+                        </configuration>
+                        <id>generation</id>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/sdnc-a1-controller/northbound/nonrt-ric-api/model/scripts/python/yang2props.py b/sdnc-a1-controller/northbound/nonrt-ric-api/model/scripts/python/yang2props.py
new file mode 100755
index 0000000..559d31b
--- /dev/null
+++ b/sdnc-a1-controller/northbound/nonrt-ric-api/model/scripts/python/yang2props.py
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+
+import re
+import sys
+
+
+# Convert word from foo-bar to FooBar
+# words begining with a digit will be converted to _digit
+def to_enum(s):
+    if s[0].isdigit():
+        s = "_" + s
+    else:
+        s = s[0].upper() + s[1:]
+    return re.sub(r'(?!^)-([a-zA-Z])', lambda m: m.group(1).upper(), s)
+
+leaf = ""
+val = ""
+li = []
+
+if len(sys.argv) < 3:
+     print 'yang2props.py <input yang> <output properties>'
+     sys.exit(2)
+
+with open(sys.argv[1], "r") as ins:
+    for line in ins:
+        # if we see a leaf save the name for later
+        if "leaf " in line:
+	    match = re.search(r'leaf (\S+)', line)
+	    if match:
+                 leaf = match.group(1)
+      
+        # if we see enum convert the value to enum format and see if it changed
+        # if the value is different write a property entry
+        if "enum " in line:
+	    match = re.search(r'enum "(\S+)";', line)
+	    if match:
+                val = match.group(1)
+            	enum = to_enum(val)
+
+                # see if converting to enum changed the string
+		if val != enum:
+                    property = "yang."+leaf+"."+enum+"="+val
+		    if property not in li:
+		        li.append( property)
+
+
+# Open output file
+fo = open(sys.argv[2], "wb")
+fo.write("# yang conversion properties \n")
+fo.write("# used to convert Enum back to the original yang value \n")
+fo.write("\n".join(li))
+fo.write("\n")
+
+# Close opend file
+fo.close()
+
+   
diff --git a/sdnc-a1-controller/northbound/nonrt-ric-api/model/src/main/yang/NONRT-RIC-API.yang b/sdnc-a1-controller/northbound/nonrt-ric-api/model/src/main/yang/NONRT-RIC-API.yang
new file mode 100644
index 0000000..b6a2869
--- /dev/null
+++ b/sdnc-a1-controller/northbound/nonrt-ric-api/model/src/main/yang/NONRT-RIC-API.yang
@@ -0,0 +1,214 @@
+module A1-ADAPTER-API {

+

+    namespace "org:onap:sdnc:northbound:a1-adapter";

+

+    prefix a1-adapter-api;

+

+    import ietf-inet-types { prefix "inet"; revision-date "2013-07-15"; }

+

+    import ietf-yang-types { prefix yang; }

+

+    revision "2019-10-02" {

+        description

+        "A1 adapter for Frankfurt";

+    }

+

+///Flattend interface using RPC

+

+    //Get a comma separated list of near-rt rics, e.g. domain-name1:port1,domainname2:port2

+    //Each item in the returned list will be regarded as one near-rt-ric-id.

+    rpc getNearRT-RICs {

+        output {

+            leaf-list near-rt-ric-id-list {

+                type string;

+            }

+        }

+    }

+

+    //Get health status for a Near-RT-RIC. true - health ok, false - health is not ok.

+    rpc getHealthCheck {

+         input {

+            leaf near-rt-ric-id {

+                type string;

+            }

+        }

+

+        output {

+            leaf health-status {

+                type boolean;

+            }

+        }   

+    }

+

+    //Get a comma separated list of integer policy type ids

+    //Each item in the returned list will be regarded as one policy-type-id.

+    rpc getPolicyTypes {

+        input {

+            leaf near-rt-ric-id {

+                type string;

+            }

+        }

+

+        output {

+            leaf-list policy-type-id-list {

+                type uint32;

+            }

+        }

+    }

+

+    //Create a policy type

+    rpc createPolicyType {

+        input {

+            leaf near-rt-ric-id {

+                type string;

+            }

+            leaf policy-type-id {

+                type uint32;

+            }

+            leaf description {

+                type string;

+            }

+            leaf name {

+                type string;

+            }

+            leaf policy-type {

+                type string;

+            }

+        }

+       output {

+            leaf status {

+                type string;

+            }

+            leaf code {

+                type string;

+            }

+        }

+    }

+

+    //Get a policy type

+    rpc getPolicyType {

+        input {

+            leaf near-rt-ric-id {

+                type string;

+            }

+            leaf policy-type-id {

+                type uint32;

+            }

+        }

+        output {

+            leaf description {

+                type string;

+            }

+            leaf name {

+                type string;

+            }

+            leaf policy-type {

+                type string;

+            }

+        }

+    }

+

+    //Delete a policy type

+    rpc deletePolicyType {

+        input {

+            leaf near-rt-ric-id {

+                type string;

+            }

+            leaf policy-type-id {

+                type uint32;

+            }

+        }

+    }

+

+    //Get a comma separeated list of string policy instance ids

+    //Each item in the returned list will be regarded as one policy-instance-id.

+    rpc getPolicyInstances {

+        input {

+            leaf near-rt-ric-id {

+                type string;

+            }

+            leaf policy-type-id {

+                type uint32;

+            }

+        }

+

+        output {

+            leaf-list policy-instance-id-list {

+                type string;

+            }

+        }

+    }

+

+    //Create a policy instance

+    rpc createPolicyInstance {

+        input {

+            leaf near-rt-ric-id {

+                type string;

+            }

+            leaf policy-type-id {

+                type uint32;

+            }

+            leaf policy-instance-id {

+                type string;

+            }

+            leaf policy-instance {

+                type string;

+            }

+        }

+    }

+    

+    ///Get a policy instance

+    rpc getPolicyInstance {

+        input {

+            leaf near-rt-ric-id {

+                type string;

+            }

+            leaf policy-type-id {

+                type uint32;

+            }

+            leaf policy-instance-id {

+                type string;

+            }

+        }

+        output {

+            leaf policy-instance {

+                type string;

+            }

+        }

+    }

+    

+    //Delete a policy instance

+    rpc deletePolicyInstance {

+        input {

+            leaf near-rt-ric-id {

+                type string;

+            }

+            leaf policy-type-id {

+                type uint32;

+            }

+            leaf policy-instance-id {

+                type string;

+            }

+        }

+    }

+

+    //Get the status for a policy instance

+    rpc getStatus {

+        input {

+            leaf near-rt-ric-id {

+                type string;

+            }

+            leaf policy-type-id {

+                type uint32;

+            }

+            leaf policy-instance-id {

+                type string;

+            }

+        }

+        output {

+            leaf status {

+                type string;

+            }

+        }

+    }

+}
\ No newline at end of file