Merge "Add memory usage to integration tests [UPDATED]"
[cps.git] / cps-service / src / main / java / org / onap / cps / api / CpsModuleService.java
index 79d6e03..e8c3e77 100644 (file)
@@ -1,7 +1,8 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2020-2022 Nordix Foundation
+ *  Copyright (C) 2020-2023 Nordix Foundation
  *  Modifications Copyright (C) 2020-2021 Pantheon.tech
+ *  Modifications Copyright (C) 2022 TechMahindra Ltd.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -25,6 +26,7 @@ import java.util.Collection;
 import java.util.Map;
 import org.onap.cps.spi.CascadeDeleteAllowed;
 import org.onap.cps.spi.exceptions.DataInUseException;
+import org.onap.cps.spi.model.ModuleDefinition;
 import org.onap.cps.spi.model.ModuleReference;
 import org.onap.cps.spi.model.SchemaSet;
 
@@ -45,15 +47,15 @@ public interface CpsModuleService {
                          Map<String, String> yangResourcesNameToContentMap);
 
     /**
-     * Create a schema set from new modules and existing modules.
+     * Create or upgrade a schema set from new modules and existing modules or only existing modules.
      * @param dataspaceName             Dataspace name
      * @param schemaSetName             schema set name
      * @param newModuleNameToContentMap YANG resources map where key is a module name and value is content
-     * @param moduleReferences          List of YANG resources module references of the modules
+     * @param allModuleReferences       All YANG resource module references
      */
-    void createSchemaSetFromModules(String dataspaceName, String schemaSetName,
+    void createOrUpgradeSchemaSetFromModules(String dataspaceName, String schemaSetName,
                                     Map<String, String> newModuleNameToContentMap,
-                                    Collection<ModuleReference> moduleReferences);
+                                    Collection<ModuleReference> allModuleReferences);
 
     /**
      * Read schema set in the given dataspace.
@@ -64,18 +66,34 @@ public interface CpsModuleService {
      */
     SchemaSet getSchemaSet(String dataspaceName, String schemaSetName);
 
+    /**
+     * Retrieve all schema sets in the given dataspace.
+     *
+     * @param dataspaceName dataspace name
+     * @return all SchemaSets
+     */
+    Collection<SchemaSet> getSchemaSets(String dataspaceName);
+
     /**
      * Deletes Schema Set.
      *
      * @param dataspaceName        dataspace name
      * @param schemaSetName        schema set name
      * @param cascadeDeleteAllowed indicates the allowance to remove associated anchors and data if exist
-     * @throws DataInUseException if cascadeDeleteAllowed is set to CASCADE_DELETE_PROHIBITED and there
-     *                           is associated anchor record exists in database
+     * @throws DataInUseException  if cascadeDeleteAllowed is set to CASCADE_DELETE_PROHIBITED and there
+     *                             is associated anchor record exists in database
      */
     void deleteSchemaSet(String dataspaceName, String schemaSetName,
                          CascadeDeleteAllowed cascadeDeleteAllowed);
 
+    /**
+     * Deletes Schema Sets with cascade.
+     *
+     * @param dataspaceName        dataspace name
+     * @param schemaSetNames       schema set names
+     */
+    void deleteSchemaSetsWithCascade(String dataspaceName, Collection<String> schemaSetNames);
+
     /**
      * Retrieve module references for the given dataspace name.
      *
@@ -93,6 +111,15 @@ public interface CpsModuleService {
      */
     Collection<ModuleReference> getYangResourcesModuleReferences(String dataspaceName, String anchorName);
 
+    /**
+     * Retrieve module definitions for the given dataspace name and anchor name.
+     *
+     * @param dataspaceName dataspace name
+     * @param anchorName    anchor name
+     * @return a collection of module definitions (moduleName, revision, yang resource content)
+     */
+    Collection<ModuleDefinition> getModuleDefinitionsByAnchorName(String dataspaceName, String anchorName);
+
     /**
      * Identify previously unknown Yang Resource module references.
      * The system will ignore the namespace of all module references.