diff options
author | KAPIL SINGAL <ks220y@att.com> | 2020-08-12 18:24:13 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-08-12 18:24:13 +0000 |
commit | 677ebdb403784a420c3ad45da0850abbb1754a56 (patch) | |
tree | 35e0e27ef075ca591c54fd38913447a4b435fe83 /ms/blueprintsprocessor/functions | |
parent | 8652382567ec5bb8e0527469f2c6334d44584df6 (diff) | |
parent | 6d7efebd9cd77169b1c99adea56a557a12162a4e (diff) |
Merge "Add functions/endpoints to fetch all config snapshots for a given resource type or Id - configs-snapshot rest API"
Diffstat (limited to 'ms/blueprintsprocessor/functions')
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, |