summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions
diff options
context:
space:
mode:
authorSerge Simard <serge@agilitae.com>2020-08-11 09:47:23 -0400
committerSerge Simard <serge@agilitae.com>2020-08-11 09:50:04 -0400
commit6d7efebd9cd77169b1c99adea56a557a12162a4e (patch)
treeaf566565d03c97327f593871d01842385e52f0c4 /ms/blueprintsprocessor/functions
parent26fe74dd5776276f432e5159e5f7f70a3a106292 (diff)
Add functions/endpoints to fetch all config snapshots for a given resource type or Id - configs-snapshot rest API
Issue-ID: CCSDK-2641 Signed-off-by: Serge Simard <serge@agilitae.com> Change-Id: I392fa72bcbe39fd5306d4d2fdf7f49d62ec441b5
Diffstat (limited to 'ms/blueprintsprocessor/functions')
-rw-r--r--ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt56
-rw-r--r--ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt30
2 files changed, 86 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt
index e1806438b..6806ad665 100644
--- a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt
+++ b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotRepository.kt
@@ -40,4 +40,60 @@ interface ResourceConfigSnapshotRepository : JpaRepository<ResourceConfigSnapsho
resourceType: String,
status: ResourceConfigSnapshot.Status
)
+
+ /**
+ * Finds all ResourceConfigSnapshot for a given resourceId and status as search criterias,
+ * ordering the resulting list in reverse chronological order.
+ *
+ * @param resourceId a resource identifier, e.g. CLLI1234555
+ * @param status RUNNING or CANDIDATE
+ *
+ * @return A list of entries are found returns a list of ConfigSnapshot.
+ * If no entries are found, this method returns an empty list.
+ */
+ fun findByResourceIdAndStatusOrderByCreatedDateDesc(
+ resourceId: String,
+ status: ResourceConfigSnapshot.Status
+ ): List<ResourceConfigSnapshot>?
+
+ /**
+ * Finds all ResourceConfigSnapshot for a given resourceId,
+ * ordering the resulting list in reverse chronological order.
+ *
+ * @param resourceId a resource identifier, e.g. CLLI1234555
+ *
+ * @return A list of entries are found returns a list of ConfigSnapshot.
+ * If no entries are found, this method returns an empty list.
+ */
+ fun findByResourceIdOrderByCreatedDateDesc(
+ resourceId: String
+ ): List<ResourceConfigSnapshot>?
+
+ /**
+ * Finds all ResourceConfigSnapshot for a given resourceType and status as search criterias,
+ * ordering the resulting list in reverse chronological order.
+ *
+ * @param resourceType a resource type name, e.g full_config
+ * @param status RUNNING or CANDIDATE
+ *
+ * @return A list of entries are found returns a list of ConfigSnapshot.
+ * If no entries are found, this method returns an empty list.
+ */
+ fun findByResourceTypeAndStatusOrderByCreatedDateDesc(
+ resourceType: String,
+ status: ResourceConfigSnapshot.Status
+ ): List<ResourceConfigSnapshot>?
+
+ /**
+ * Finds all ResourceConfigSnapshot for a given resourceType,
+ * ordering the resulting list in reverse chronological order.
+ *
+ * @param resourceType a resource type name, e.g full_config
+ *
+ * @return A list of entries are found returns a list of ConfigSnapshot.
+ * If no entries are found, this method returns an empty list.
+ */
+ fun findByResourceTypeOrderByCreatedDateDesc(
+ resourceType: String
+ ): List<ResourceConfigSnapshot>?
}
diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt
index 9260b79e8..2383f2c64 100644
--- a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt
+++ b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt
@@ -36,6 +36,36 @@ open class ResourceConfigSnapshotService(private val resourceConfigSnapshotRepos
private val log = LoggerFactory.getLogger(ResourceConfigSnapshotService::class.toString())
+ suspend fun findAllByResourceIdForStatus(
+ resourceId: String,
+ status: ResourceConfigSnapshot.Status
+ ): List<ResourceConfigSnapshot>? =
+ withContext(Dispatchers.IO) {
+ resourceConfigSnapshotRepository.findByResourceIdAndStatusOrderByCreatedDateDesc(resourceId, status)
+ }
+
+ suspend fun findAllByResourceId(
+ resourceId: String
+ ): List<ResourceConfigSnapshot>? =
+ withContext(Dispatchers.IO) {
+ resourceConfigSnapshotRepository.findByResourceIdOrderByCreatedDateDesc(resourceId)
+ }
+
+ suspend fun findAllByResourceTypeForStatus(
+ resourceType: String,
+ status: ResourceConfigSnapshot.Status
+ ): List<ResourceConfigSnapshot>? =
+ withContext(Dispatchers.IO) {
+ resourceConfigSnapshotRepository.findByResourceTypeAndStatusOrderByCreatedDateDesc(resourceType, status)
+ }
+
+ suspend fun findAllByResourceType(
+ resourceType: String
+ ): List<ResourceConfigSnapshot>? =
+ withContext(Dispatchers.IO) {
+ resourceConfigSnapshotRepository.findByResourceTypeOrderByCreatedDateDesc(resourceType)
+ }
+
suspend fun findByResourceIdAndResourceTypeAndStatus(
resourceId: String,
resourceType: String,