From 04280e2f93bbf30e8654c411bb1e107d275c22bb Mon Sep 17 00:00:00 2001 From: "halil.cakal" Date: Tue, 23 Jan 2024 10:05:36 +0000 Subject: Extend API: Get Module Definitions - add query parameters: module-name and revision to OpenAPI - extend the controller method to hande the new parameters - add the new method stack to the service layer - extend the SQL query to support the new parameters - add unit and integration testwares Issue-ID: CPS-1135 Change-Id: I089ad2ad71effb58ac0ba809e9f441d6cdb59c4f Signed-off-by: halil.cakal --- .../src/main/java/org/onap/cps/api/CpsModuleService.java | 14 +++++++++++++- .../java/org/onap/cps/api/impl/CpsModuleServiceImpl.java | 11 ++++++++++- .../java/org/onap/cps/spi/CpsModulePersistenceService.java | 14 +++++++++++++- 3 files changed, 36 insertions(+), 3 deletions(-) (limited to 'cps-service/src/main/java/org') diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java b/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java index 2928464461..bdd361458e 100644 --- a/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java +++ b/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2023 Nordix Foundation + * Copyright (C) 2020-2024 Nordix Foundation * Modifications Copyright (C) 2020-2021 Pantheon.tech * Modifications Copyright (C) 2022 TechMahindra Ltd. * ================================================================================ @@ -133,6 +133,18 @@ public interface CpsModuleService { */ Collection getModuleDefinitionsByAnchorName(String dataspaceName, String anchorName); + /** + * Retrieve module definitions for the given parameters. + * + * @param dataspaceName dataspace name + * @param anchorName anchor name + * @param moduleName module name + * @param moduleRevision the revision of the module + * @return a collection of module definitions (moduleName, revision, yang resource content) + */ + Collection getModuleDefinitionsByAnchorAndModule(String dataspaceName, String anchorName, + String moduleName, String moduleRevision); + /** * Identify previously unknown Yang Resource module references. * The system will ignore the namespace of all module references. diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java index 61a4e623af..0f9eb3c64f 100644 --- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2023 Nordix Foundation + * Copyright (C) 2020-2024 Nordix Foundation * Modifications Copyright (C) 2020-2021 Pantheon.tech * Modifications Copyright (C) 2022 Bell Canada * Modifications Copyright (C) 2022 TechMahindra Ltd @@ -155,6 +155,15 @@ public class CpsModuleServiceImpl implements CpsModuleService { return cpsModulePersistenceService.getYangResourceDefinitions(dataspaceName, anchorName); } + @Override + public Collection getModuleDefinitionsByAnchorAndModule(final String dataspaceName, + final String anchorName, + final String moduleName, + final String moduleRevision) { + return cpsModulePersistenceService.getYangResourceDefinitionsByAnchorAndModule(dataspaceName, anchorName, + moduleName, moduleRevision); + } + @Override public Collection identifyNewModuleReferences( final Collection moduleReferencesToCheck) { diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java index aaca2ee5b5..eeaaa47991 100755 --- a/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java +++ b/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2023 Nordix Foundation + * Copyright (C) 2020-2024 Nordix Foundation * Modifications Copyright (C) 2020-2022 Bell Canada. * Modifications Copyright (C) 2022 TechMahindra Ltd. * ================================================================================ @@ -125,6 +125,18 @@ public interface CpsModulePersistenceService { */ Collection getYangResourceDefinitions(String dataspaceName, String anchorName); + /** + * Get YANG resource definitions for the given parameters. + * + * @param dataspaceName dataspace name + * @param anchorName anchor name + * @param moduleName module name + * @param moduleRevision the revision of the module + * @return a collection of module definitions (moduleName, revision and yang resource content) + */ + Collection getYangResourceDefinitionsByAnchorAndModule(String dataspaceName, String anchorName, + String moduleName, String moduleRevision); + /** * Remove unused Yang Resource Modules. */ -- cgit 1.2.3-korg