ONOS-2692: Implement methods to unregister resources
Change-Id: Iae88207c5edecf6645aeff3c15875178b5266634
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java b/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java
index 1a13c32..e94ee45 100644
--- a/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java
+++ b/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java
@@ -48,4 +48,28 @@
* succeeds when each resource is not registered or unallocated.
*/
<T> boolean registerResources(ResourcePath parent, List<T> children);
+
+ /**
+ * Unregister resources as the children of the parent resource path.
+ *
+ * @param parent parent resource path under which the resource are unregistered
+ * @param children resources to be unregistered as the children of the parent
+ * @param <T> type of resources
+ * @return true if unregistration is successfully done, false otherwise. Unregistration
+ * succeeds when each resource is not registered or unallocated.
+ */
+ default <T> boolean unregisterResources(ResourcePath parent, T... children) {
+ return unregisterResources(parent, Arrays.asList(children));
+ }
+
+ /**
+ * Unregister resources as the children of the parent resource path.
+ *
+ * @param parent parent resource path under which the resource are unregistered
+ * @param children resources to be unregistered as the children of the parent
+ * @param <T> type of resources
+ * @return true if unregistration is successfully done, false otherwise. Unregistration
+ * succeeds when each resource is not registered or unallocated.
+ */
+ <T> boolean unregisterResources(ResourcePath parent, List<T> children);
}
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java b/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java
index b711f39..0189a57 100644
--- a/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java
+++ b/core/api/src/main/java/org/onosproject/net/newresource/ResourceStore.java
@@ -25,6 +25,18 @@
boolean register(ResourcePath parent, List<ResourcePath> children);
/**
+ * Unregisters the resources as children of the parent resource in transactional way.
+ * The state after completion of this method is all the resources are unregistered,
+ * or no resource is unregistered. The whole unregistration fails when any one of the
+ * resource can't be unregistered.
+ *
+ * @param parent resource which is the parent of the resource to be unregistered
+ * @param children resources to be unregistered
+ * @return true if the registration succeeds, false otherwise
+ */
+ boolean unregister(ResourcePath parent, List<ResourcePath> children);
+
+ /**
* Allocates the specified resources to the specified consumer in transactional way.
* The state after completion of this method is all the resources are allocated to the consumer,
* or no resource is allocated to the consumer. The whole allocation fails when any one of