Bug 7603: ACTION support in Binding spec v2 16/50716/4
authorMartin Ciglan <mciglan@cisco.com>
Fri, 20 Jan 2017 13:36:10 +0000 (14:36 +0100)
committerRobert Varga <nite@hq.sk>
Tue, 24 Jan 2017 12:59:33 +0000 (12:59 +0000)
- API changes necessary
- RPC & Action interface differ as defined here
- ListAction needed for actions in YANG list

Change-Id: Ibf3c7b95d7fc35eb5b6a95a95d61741c41aace8e
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/Action.java
binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/ListAction.java [new file with mode: 0644]
binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/Rpc.java [new file with mode: 0644]

index 9270e78d38b7037bfbcbacbe6d825de5bd6f1e74..bbda46ed2b93d2a500138fc1f0037d4251a825dd 100644 (file)
@@ -9,13 +9,27 @@
 package org.opendaylight.mdsal.binding.javav2.spec.base;
 
 /**
- *  The "action" statement is used to define an operation connected to a
- *  specific container or list data node. The "action" statement defines
- *  an action node in the schema tree. Under the action node, a schema node
- *  with the name "input" and a schema node with the name "output" are also
- *  defined. The nodes "input" and "output" are defined in the module’s namespace.
+ *
+ * The "action" statement is used to define an operation connected to a
+ * specific container or list data node. The "action" statement defines
+ * an action node in the schema tree. Under the action node, a schema node
+ * with the name "input" and a schema node with the name "output" are also
+ * defined. The nodes "input" and "output" are defined in the module’s namespace.
+ *
+ * The difference between an action and an rpc is that an action is tied
+ * to a node in the datastore, whereas an rpc is not.
+ *
+ * Action replaces concept of routed RPC and comes up with implicit InstanceIdentifier
+ * context, whereas routed RPC defines explicit leaf for this purpose.
+ *
  */
-public interface Action<I extends Input<I> & Instantiable<I>, O extends Output<O> & Instantiable<O>> {
+@FunctionalInterface
+public interface Action<P extends TreeNode, I extends Input<I> & Instantiable<I>, O extends Output<O> & Instantiable<O>> {
 
-    void invoke(I input, RpcCallback<O> callback);
+    /**
+     * @param input Action input schema node
+     * @param ii implicit InstanceIdentifier connected to action, according to https://tools.ietf.org/html/rfc7950
+     * @param callback on success/failure callback
+     */
+    void invoke(I input, InstanceIdentifier<P> ii, RpcCallback<O> callback);
 }
diff --git a/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/ListAction.java b/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/ListAction.java
new file mode 100644 (file)
index 0000000..5ff26e1
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.mdsal.binding.javav2.spec.base;
+
+/**
+ *
+ * ListAction provides support for YANG actions defined under List statement.
+ *
+ * The "action" statement is used to define an operation connected to a
+ * specific container or list data node. The "action" statement defines
+ * an action node in the schema tree. Under the action node, a schema node
+ * with the name "input" and a schema node with the name "output" are also
+ * defined. The nodes "input" and "output" are defined in the module’s namespace.
+ *
+ * The difference between an action and an rpc is that an action is tied
+ * to a node in the datastore, whereas an rpc is not.
+ *
+ * Action replaces concept of routed RPC and comes up with implicit InstanceIdentifier
+ * context, whereas routed RPC defines explicit leaf for this purpose.
+ *
+ */
+@FunctionalInterface
+public interface ListAction<P extends TreeNode, I extends Input<I> & Instantiable<I>, O extends Output<O> & Instantiable<O>> {
+
+    /**
+     * @param input Action input schema node
+     * @param kii implicit KeyedInstanceIdentifier connected to action, according to https://tools.ietf.org/html/rfc7950
+     * @param callback on success/failure callback
+     * @param <K> target key type
+     */
+    <K> void invoke(I input, KeyedInstanceIdentifier<P, K> kii, RpcCallback<O> callback);
+}
diff --git a/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/Rpc.java b/binding2/mdsal-binding2-spec/src/main/java/org/opendaylight/mdsal/binding/javav2/spec/base/Rpc.java
new file mode 100644 (file)
index 0000000..f489842
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.mdsal.binding.javav2.spec.base;
+
+/**
+ *
+ * The "rpc" statement is used to define an RPC operation. The "rpc" statement
+ * defines an rpc node in the schema tree. Under the rpc node, a schema node
+ * with the name "input" and a schema node with the name "output" are also defined.
+ * The nodes "input" and "output" are defined in the module’s namespace.
+ *
+ */
+@FunctionalInterface
+public interface Rpc<I extends Input<I> & Instantiable<I>, O extends Output<O> & Instantiable<O>> {
+
+    /**
+     * @param input Rpc input schema node
+     * @param callback on success/failure callback
+     */
+    void invoke(I input, RpcCallback<O> callback);
+}