diff options
author | Joseph Keenan <joseph.keenan@est.tech> | 2022-08-02 12:59:07 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2022-08-02 12:59:07 +0000 |
commit | 7dfc3a01f327654d64451865ac05b819c5583b27 (patch) | |
tree | 6cf32bf6e0d61055ba26ecad5e3a1a74621d937d /cps-ncmp-rest | |
parent | e79e48d75c0a84e7f1b3cef53d29ac89321184ea (diff) | |
parent | 6ddbe4af2b73a306dec89e55b8350c09b8c5766b (diff) |
Merge "Enable/Disable Data Sync for Cm Handle"
Diffstat (limited to 'cps-ncmp-rest')
5 files changed, 64 insertions, 1 deletions
diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml index 14fd4d24d3..c1e05876ca 100644 --- a/cps-ncmp-rest/docs/openapi/components.yaml +++ b/cps-ncmp-rest/docs/openapi/components.yaml @@ -423,6 +423,14 @@ components: schema: type: string example: my-cm-handle + dataSyncEnabled: + name: dataSyncEnabled + in: query + description: Is used to enable or disable the data synchronization flag + required: true + schema: + type: boolean + example: true xpathInQuery: name: xpath in: query diff --git a/cps-ncmp-rest/docs/openapi/ncmp.yml b/cps-ncmp-rest/docs/openapi/ncmp.yml index d7b383705f..f394e85751 100755 --- a/cps-ncmp-rest/docs/openapi/ncmp.yml +++ b/cps-ncmp-rest/docs/openapi/ncmp.yml @@ -430,4 +430,28 @@ searchCmHandleIds: 404: $ref: 'components.yaml#/components/responses/NotFound' 500: - $ref: 'components.yaml#/components/responses/InternalServerError'
\ No newline at end of file + $ref: 'components.yaml#/components/responses/InternalServerError' + +setDataSyncEnabledFlag: + put: + tags: + - network-cm-proxy + summary: Set the Data Sync Enabled Flag + description: Set the data sync enabled flag to true or false for a specified Cm-Handle. This will in turn set the data sync state to UNSYNCHRONIZED and NONE_REQUESTED respectfully. + operationId: setDataSyncEnabledFlagForCmHandle + parameters: + - $ref: 'components.yaml#/components/parameters/cmHandleInPath' + - $ref: 'components.yaml#/components/parameters/dataSyncEnabled' + responses: + 200: + $ref: 'components.yaml#/components/responses/Ok' + 400: + $ref: 'components.yaml#/components/responses/BadRequest' + 401: + $ref: 'components.yaml#/components/responses/Unauthorized' + 403: + $ref: 'components.yaml#/components/responses/Forbidden' + 500: + $ref: 'components.yaml#/components/responses/InternalServerError' + 502: + $ref: 'components.yaml#/components/responses/BadGateway'
\ No newline at end of file diff --git a/cps-ncmp-rest/docs/openapi/openapi.yml b/cps-ncmp-rest/docs/openapi/openapi.yml index 35be59a38c..8e020668a0 100755 --- a/cps-ncmp-rest/docs/openapi/openapi.yml +++ b/cps-ncmp-rest/docs/openapi/openapi.yml @@ -52,3 +52,6 @@ paths: /v1/ch/{cm-handle}/state: $ref: 'ncmp.yml#/getCmHandleStateById' + + /v1/ch/{cm-handle}/data-sync: + $ref: 'ncmp.yml#/setDataSyncEnabledFlag' diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java index b20487119b..d2ed393794 100755 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java @@ -320,6 +320,20 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { return new ResponseEntity<>(restModuleReferences, HttpStatus.OK); } + /** + * Set the data sync enabled flag, along with the data sync state for the specified cm handle. + * + * @param cmHandleId cm handle id + * @param dataSyncEnabledFlag data sync enabled flag + * @return response entity ok if request is successful + */ + @Override + public ResponseEntity<Object> setDataSyncEnabledFlagForCmHandle(final String cmHandleId, + final Boolean dataSyncEnabledFlag) { + networkCmProxyDataService.setDataSyncEnabled(cmHandleId, dataSyncEnabledFlag); + return new ResponseEntity<>(HttpStatus.OK); + } + private RestOutputCmHandle toRestOutputCmHandle(final NcmpServiceCmHandle ncmpServiceCmHandle) { final RestOutputCmHandle restOutputCmHandle = new RestOutputCmHandle(); final CmHandlePublicProperties cmHandlePublicProperties = new CmHandlePublicProperties(); diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy index 06a7759be9..d568a5a925 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy @@ -423,6 +423,20 @@ class NetworkCmProxyControllerSpec extends Specification { response.status == HttpStatus.OK.value() } + def 'Set the data sync enabled based on the cm handle id and the data sync flag is #scenario' () { + when: 'the set data sync enabled request is invoked' + def response = mvc.perform(put("$ncmpBasePathV1/ch/some-cm-handle-id/data-sync?dataSyncEnabled=" + dataSyncEnabledFlag)) + .andReturn().response + then: 'method to set data sync enabled is called' + 1 * mockNetworkCmProxyDataService.setDataSyncEnabled('some-cm-handle-id', dataSyncEnabledFlag) + and: 'the response returns an OK http code' + response.status == HttpStatus.OK.value() + where: 'the following parameters are used' + scenario | dataSyncEnabledFlag + 'enabled' | true + 'disabled' | false + } + def dataStores() { DataStores.builder() .operationalDataStore(Operational.builder() |