summaryrefslogtreecommitdiffstats
path: root/cps-rest
diff options
context:
space:
mode:
Diffstat (limited to 'cps-rest')
-rw-r--r--cps-rest/docs/openapi/cpsAdmin.yml25
-rw-r--r--cps-rest/docs/openapi/openapi.yml2
-rwxr-xr-xcps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java14
-rwxr-xr-xcps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy15
4 files changed, 55 insertions, 1 deletions
diff --git a/cps-rest/docs/openapi/cpsAdmin.yml b/cps-rest/docs/openapi/cpsAdmin.yml
index e887ef2c07..595f6d7ec1 100644
--- a/cps-rest/docs/openapi/cpsAdmin.yml
+++ b/cps-rest/docs/openapi/cpsAdmin.yml
@@ -91,6 +91,31 @@ schemaSet:
$ref: 'components.yml#/components/responses/Conflict'
'500':
$ref: 'components.yml#/components/responses/InternalServerError'
+ get:
+ description: Read all schema sets, given a dataspace
+ tags:
+ - cps-admin
+ summary: Get schema sets
+ operationId: getSchemaSets
+ parameters:
+ - $ref: 'components.yml#/components/parameters/dataspaceNameInPath'
+ responses:
+ '200':
+ description: OK
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: 'components.yml#/components/schemas/SchemaSetDetails'
+ '400':
+ $ref: 'components.yml#/components/responses/BadRequest'
+ '401':
+ $ref: 'components.yml#/components/responses/Unauthorized'
+ '403':
+ $ref: 'components.yml#/components/responses/Forbidden'
+ '500':
+ $ref: 'components.yml#/components/responses/InternalServerError'
schemaSetBySchemaSetName:
get:
diff --git a/cps-rest/docs/openapi/openapi.yml b/cps-rest/docs/openapi/openapi.yml
index e170295504..e02d6a6715 100644
--- a/cps-rest/docs/openapi/openapi.yml
+++ b/cps-rest/docs/openapi/openapi.yml
@@ -84,4 +84,4 @@ paths:
$ref: 'cpsQuery.yml#/nodesByDataspaceAndAnchorAndCpsPath'
security:
- - basicAuth: [] \ No newline at end of file
+ - basicAuth: []
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
index a29f8d2969..285a15c6a3 100755
--- a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
@@ -110,6 +110,20 @@ public class AdminRestController implements CpsAdminApi {
}
/**
+ * Get list of schema sets for a given dataspace name.
+ *
+ * @param dataspaceName dataspace name
+ * @return a {@Link ResponseEntity} of schema sets & {@link HttpStatus} OK
+ */
+ @Override
+ public ResponseEntity<List<SchemaSetDetails>> getSchemaSets(final String dataspaceName) {
+ final Collection<SchemaSet> schemaSets = cpsModuleService.getSchemaSets(dataspaceName);
+ final List<SchemaSetDetails> schemaSetDetails = schemaSets.stream().map(cpsRestInputMapper::toSchemaSetDetails)
+ .collect(Collectors.toList());
+ return new ResponseEntity<>(schemaSetDetails, HttpStatus.OK);
+ }
+
+ /**
* Delete a {@link SchemaSet} based on given dataspace name & schemaset name.
*
* @param dataspaceName dataspace name
diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
index e9612fc395..7120ce49f3 100755
--- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
+++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
@@ -278,6 +278,21 @@ class AdminRestControllerSpec extends Specification {
response.getContentAsString().contains(schemaSetName)
}
+ def 'Get all schema sets for a given dataspace name.'() {
+ given: 'service method returns all schema sets for a dataspace'
+ mockCpsModuleService.getSchemaSets(dataspaceName) >>
+ [new SchemaSet(name: schemaSetName, dataspaceName: dataspaceName),
+ new SchemaSet(name: "test-schemaset", dataspaceName: dataspaceName)]
+ and: 'an endpoint'
+ def schemaSetEndpoint = "$basePath/v1/dataspaces/$dataspaceName/schema-sets"
+ when: 'get schema sets API is invoked'
+ def response = mvc.perform(get(schemaSetEndpoint)).andReturn().response
+ then: 'the correct schema sets is returned'
+ assert response.status == HttpStatus.OK.value()
+ assert response.getContentAsString() == '[{"dataspaceName":"my_dataspace","moduleReferences":[],"name":' +
+ '"my_schema_set"},{"dataspaceName":"my_dataspace","moduleReferences":[],"name":"test-schemaset"}]'
+ }
+
def 'Create Anchor.'() {
given: 'request parameters'
def requestParams = new LinkedMultiValueMap<>()