diff options
Diffstat (limited to 'cps-rest')
-rw-r--r-- | cps-rest/docs/openapi/components.yml | 397 | ||||
-rw-r--r-- | cps-rest/docs/openapi/cpsAdmin.yml | 232 | ||||
-rw-r--r-- | cps-rest/docs/openapi/cpsAdminV1Deprecated.yml | 92 | ||||
-rw-r--r-- | cps-rest/docs/openapi/cpsAdminV2.yml | 89 | ||||
-rw-r--r-- | cps-rest/docs/openapi/cpsData.yml | 217 | ||||
-rw-r--r-- | cps-rest/docs/openapi/cpsDataV1Deprecated.yml | 71 | ||||
-rw-r--r-- | cps-rest/docs/openapi/cpsDataV2.yml | 129 | ||||
-rw-r--r-- | cps-rest/docs/openapi/cpsQueryV1Deprecated.yml | 50 | ||||
-rw-r--r-- | cps-rest/docs/openapi/cpsQueryV2.yml | 78 | ||||
-rw-r--r-- | cps-rest/docs/openapi/openapi.yml | 123 | ||||
-rw-r--r-- | cps-rest/pom.xml | 30 | ||||
-rwxr-xr-x | cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java | 45 | ||||
-rw-r--r-- | cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java | 21 | ||||
-rwxr-xr-x | cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy | 77 | ||||
-rw-r--r-- | cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy | 23 |
15 files changed, 101 insertions, 1573 deletions
diff --git a/cps-rest/docs/openapi/components.yml b/cps-rest/docs/openapi/components.yml deleted file mode 100644 index 01375f503d..0000000000 --- a/cps-rest/docs/openapi/components.yml +++ /dev/null @@ -1,397 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2021-2022 Bell Canada. -# Modifications Copyright (C) 2021-2023 Nordix Foundation -# Modifications Copyright (C) 2022-2024 TechMahindra Ltd. -# Modifications Copyright (C) 2022 Deutsche Telekom AG -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -components: - schemas: - - AnchorDetails: - type: object - title: Anchor details by anchor Name - properties: - name: - type: string - example: my-anchor - dataspaceName: - type: string - example: my-dataspace - schemaSetName: - type: string - example: my-schema-set - - DataspaceDetails: - type: object - title: Dataspace details by dataspace Name - properties: - name: - type: string - example: my-dataspace - - ErrorMessage: - type: object - title: Error - properties: - status: - type: string - message: - type: string - details: - type: string - - MultipartFile: - type: object - required: - - file - properties: - file: - type: string - description: multipartFile - format: binary - - ModuleReferences: - type: object - title: Module reference object - properties: - name: - type: string - example: my-module-reference-name - namespace: - type: string - example: my-module-reference-namespace - revision: - type: string - example: my-module-reference-revision - - SchemaSetDetails: - type: object - title: Schema set details by dataspace and schemasetName - required: - - "moduleReferences" - properties: - dataspaceName: - type: string - example: my-dataspace - moduleReferences: - type: array - items: - $ref: '#/components/schemas/ModuleReferences' - name: - type: string - example: my-schema-set - - examples: - dataSample: - value: - test:bookstore: - bookstore-name: Chapters - categories: - - code: 01 - name: SciFi - - code: 02 - name: kids - dataSampleXml: - value: - <stores xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> - <bookstore xmlns="org:onap:ccsdk:sample"> - <bookstore-name>Chapters</bookstore-name> - <categories> - <code>1</code> - <name>SciFi</name> - <code>2</code> - <name>kids</name> - </categories> - </bookstore> - </stores> - dataSampleAcrossAnchors: - value: - - anchorName: bookstore1 - dataNode: - test:bookstore: - bookstore-name: Chapters - categories: - - code: 01 - name: SciFi - - code: 02 - name: kids - - anchorName: bookstore2 - dataNode: - test:bookstore: - bookstore-name: Chapters - categories: - - code: 01 - name: SciFi - - code: 02 - name: kids - deltaReportSample: - value: - - action: "ADD" - xpath: "/bookstore/categories/[@code=3]" - target-data: - code: 3, - name: "kidz" - - action: "REMOVE" - xpath: "/bookstore/categories/[@code=1]" - source-data: - code: 1, - name: "Fiction" - - action: "UPDATE" - xpath: "/bookstore/categories/[@code=2]" - source-data: - name: "Funny" - target-data: - name: "Comic" - - parameters: - dataspaceNameInQuery: - name: dataspace-name - in: query - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - dataspaceNameInPath: - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - anchorNameInPath: - name: anchor-name - in: path - description: anchor-name - required: true - schema: - type: string - example: my-anchor - schemaSetNameInQuery: - name: schema-set-name - in: query - description: schema-set-name - required: true - schema: - type: string - example: my-schema-set - schemaSetNameInPath: - name: schema-set-name - in: path - description: schema-set-name - required: true - schema: - type: string - example: my-schema-set - anchorNameInQuery: - name: anchor-name - in: query - description: anchor-name - required: true - schema: - type: string - example: my-anchor - targetAnchorNameInQuery: - name: target-anchor-name - in: query - description: target-anchor-name - required: true - schema: - type: string - example: my-anchor - xpathInQuery: - name: xpath - in: query - description: For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/xpath.html - required: false - schema: - type: string - default: / - examples: - container xpath: - value: /shops/bookstore - list attributes xpath: - value: /shops/bookstore/categories[@code=1] - requiredXpathInQuery: - name: xpath - in: query - description: For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/xpath.html - required: true - schema: - type: string - examples: - container xpath: - value: /shops/bookstore - list attributes xpath: - value: /shops/bookstore/categories[@code=1] - cpsPathInQuery: - name: cps-path - in: query - description: For more details on cps path, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html - required: false - schema: - type: string - default: / - examples: - container cps path: - value: //bookstore - list attributes cps path: - value: //categories[@code=1] - includeDescendantsOptionInQuery: - name: include-descendants - in: query - description: include-descendants - required: false - schema: - type: boolean - default: false - example: false - observedTimestampInQuery: - name: observed-timestamp - in: query - description: observed-timestamp - required: false - schema: - type: string - example: '2021-03-21T00:10:34.030-0100' - apiVersionInPath: - name: apiVersion - in: path - description: apiVersion - required: true - schema: - type: string - enum: [v1, v2] - default: v2 - contentTypeHeader: - name: Content-Type - in: header - description: Content type header - schema: - type: string - example: 'application/json' - required: true - descendantsInQuery: - name: descendants - in: query - description: Number of descendants to query. Allowed values are 'none', 'all', 'direct', 1 (for direct), -1 (for all), 0 (for none) and any positive number. - required: false - schema: - type: string - default: none - example: 3 - pageIndexInQuery: - name: pageIndex - in: query - description: page index for pagination over anchors. It must be greater then zero if provided. - required: false - schema: - type: integer - example: 1 - pageSizeInQuery: - name: pageSize - in: query - description: number of records (anchors) per page. It must be greater then zero if provided. - required: false - schema: - type: integer - example: 10 - - responses: - NotFound: - description: The specified resource was not found - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorMessage' - example: - status: 404 - message: Resource Not Found - details: The requested resource is not found - Unauthorized: - description: Unauthorized - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorMessage' - example: - status: 401 - message: Unauthorized request - details: This request is unauthorized - Forbidden: - description: Forbidden - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorMessage' - example: - status: 403 - message: Request Forbidden - details: This request is forbidden - BadRequest: - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorMessage' - example: - status: 400 - message: Bad Request - details: The provided request is not valid - Conflict: - description: Conflict - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorMessage' - example: - status: 409 - message: Conflicting request - details: The request cannot be processed as the resource is in use. - Ok: - description: OK - content: - application/json: - schema: - type: object - examples: - dataSample: - value: "" - Created: - description: Created - content: - text/plain: - schema: - type: string - example: my-resource - CreatedV2: - description: Created without response body - InternalServerError: - description: Internal Server Error - content: - application/json: - schema: - $ref: "#/components/schemas/ErrorMessage" - example: - status: 500 - message: Internal Server Error - details: Internal Server Error occurred - NoContent: - description: No Content - content: {} diff --git a/cps-rest/docs/openapi/cpsAdmin.yml b/cps-rest/docs/openapi/cpsAdmin.yml deleted file mode 100644 index f394270dd5..0000000000 --- a/cps-rest/docs/openapi/cpsAdmin.yml +++ /dev/null @@ -1,232 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2021 Bell Canada. -# Modifications Copyright (C) 2021-2022 Nordix Foundation -# Modifications Copyright (C) 2022 TechMahindra Ltd. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -dataspaces: - delete: - description: Delete a dataspace - tags: - - cps-admin - summary: Delete a dataspace - operationId: deleteDataspace - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - - $ref: 'components.yml#/components/parameters/dataspaceNameInQuery' - responses: - '204': - $ref: 'components.yml#/components/responses/NoContent' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '409': - $ref: 'components.yml#/components/responses/Conflict' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - -schemaSet: - get: - description: Read all schema sets, given a dataspace - tags: - - cps-admin - summary: Get schema sets - operationId: getSchemaSets - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - - $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' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - -schemaSetBySchemaSetName: - get: - description: Read a schema set given a schema set name and a dataspace - tags: - - cps-admin - summary: Get a schema set - operationId: getSchemaSet - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/schemaSetNameInPath' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: 'components.yml#/components/schemas/SchemaSetDetails' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - delete: - description: Delete a schema set given a schema set name and a dataspace - tags: - - cps-admin - summary: Delete a schema set - operationId: deleteSchemaSet - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/schemaSetNameInPath' - responses: - '204': - $ref: 'components.yml#/components/responses/NoContent' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '409': - $ref: 'components.yml#/components/responses/Conflict' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - -anchorsByDataspace: - get: - description: Read all anchors, given a dataspace - tags: - - cps-admin - summary: Get anchors - operationId: getAnchors - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - $ref: 'components.yml#/components/schemas/AnchorDetails' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - -anchorByDataspaceAndAnchorName: - get: - description: Read an anchor given an anchor name and a dataspace - tags: - - cps-admin - summary: Get an anchor - operationId: getAnchor - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: 'components.yml#/components/schemas/AnchorDetails' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - delete: - description: Delete an anchor given an anchor name and a dataspace - tags: - - cps-admin - summary: Delete an anchor - operationId: deleteAnchor - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - responses: - '204': - $ref: 'components.yml#/components/responses/NoContent' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - -adminDataspaces: - get: - description: Read all dataspaces - tags: - - cps-admin - summary: Get all dataspaces - operationId: getAllDataspaces - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - $ref: 'components.yml#/components/schemas/DataspaceDetails' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - -adminDataspace: - get: - description: Read a dataspace given a dataspace name - tags: - - cps-admin - summary: Get a dataspace - operationId: getDataspace - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: 'components.yml#/components/schemas/DataspaceDetails' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' diff --git a/cps-rest/docs/openapi/cpsAdminV1Deprecated.yml b/cps-rest/docs/openapi/cpsAdminV1Deprecated.yml deleted file mode 100644 index c92f773c30..0000000000 --- a/cps-rest/docs/openapi/cpsAdminV1Deprecated.yml +++ /dev/null @@ -1,92 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2022 TechMahindra Ltd. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -dataspaces: - post: - deprecated: true - description: Create a new dataspace - tags: - - cps-admin - summary: Create a dataspace - operationId: createDataspace - parameters: - - $ref: 'components.yml#/components/parameters/dataspaceNameInQuery' - responses: - '201': - $ref: 'components.yml#/components/responses/Created' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '409': - $ref: 'components.yml#/components/responses/Conflict' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - -anchorsByDataspace: - post: - deprecated: true - description: Create a new anchor in the given dataspace - tags: - - cps-admin - summary: Create an anchor - operationId: createAnchor - parameters: - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/schemaSetNameInQuery' - - $ref: 'components.yml#/components/parameters/anchorNameInQuery' - responses: - '201': - $ref: 'components.yml#/components/responses/Created' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '409': - $ref: 'components.yml#/components/responses/Conflict' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - -schemaSet: - post: - deprecated: true - description: Create a new schema set in the given dataspace - tags: - - cps-admin - summary: Create a schema set - operationId: createSchemaSet - parameters: - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/schemaSetNameInQuery' - requestBody: - required: true - content: - multipart/form-data: - schema: - $ref: 'components.yml#/components/schemas/MultipartFile' - responses: - '201': - $ref: 'components.yml#/components/responses/Created' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '409': - $ref: 'components.yml#/components/responses/Conflict' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' diff --git a/cps-rest/docs/openapi/cpsAdminV2.yml b/cps-rest/docs/openapi/cpsAdminV2.yml deleted file mode 100644 index e501ad8b15..0000000000 --- a/cps-rest/docs/openapi/cpsAdminV2.yml +++ /dev/null @@ -1,89 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2022 TechMahindra Ltd. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -dataspaces: - post: - description: Create a new dataspace - tags: - - cps-admin - summary: Create a dataspace - operationId: createDataspaceV2 - parameters: - - $ref: 'components.yml#/components/parameters/dataspaceNameInQuery' - responses: - '201': - $ref: 'components.yml#/components/responses/CreatedV2' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '409': - $ref: 'components.yml#/components/responses/Conflict' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - -anchorsByDataspace: - post: - description: Create a new anchor in the given dataspace - tags: - - cps-admin - summary: Create an anchor - operationId: createAnchorV2 - parameters: - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/schemaSetNameInQuery' - - $ref: 'components.yml#/components/parameters/anchorNameInQuery' - responses: - '201': - $ref: 'components.yml#/components/responses/CreatedV2' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '409': - $ref: 'components.yml#/components/responses/Conflict' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - -schemaSet: - post: - description: Create a new schema set in the given dataspace - tags: - - cps-admin - summary: Create a schema set - operationId: createSchemaSetV2 - parameters: - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/schemaSetNameInQuery' - requestBody: - required: true - content: - multipart/form-data: - schema: - $ref: 'components.yml#/components/schemas/MultipartFile' - responses: - '201': - $ref: 'components.yml#/components/responses/CreatedV2' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '409': - $ref: 'components.yml#/components/responses/Conflict' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' diff --git a/cps-rest/docs/openapi/cpsData.yml b/cps-rest/docs/openapi/cpsData.yml deleted file mode 100644 index d13c285817..0000000000 --- a/cps-rest/docs/openapi/cpsData.yml +++ /dev/null @@ -1,217 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2021-2022 Bell Canada. -# Modifications Copyright (C) 2021-2022 Nordix Foundation -# Modifications Copyright (C) 2022-2024 TechMahindra Ltd. -# Modifications Copyright (C) 2022 Deutsche Telekom AG -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -listElementByDataspaceAndAnchor: - post: - description: Add list element(s) to a list for a given anchor and dataspace - tags: - - cps-data - summary: Add list element(s) - operationId: addListElements - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - - $ref: 'components.yml#/components/parameters/requiredXpathInQuery' - - $ref: 'components.yml#/components/parameters/observedTimestampInQuery' - requestBody: - required: true - content: - application/json: - schema: - type: object - examples: - dataSample: - $ref: 'components.yml#/components/examples/dataSample' - responses: - '201': - $ref: 'components.yml#/components/responses/Created' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - put: - description: Replace list content under a given parent, anchor and dataspace - tags: - - cps-data - summary: Replace list content - operationId: replaceListContent - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - - $ref: 'components.yml#/components/parameters/requiredXpathInQuery' - - $ref: 'components.yml#/components/parameters/observedTimestampInQuery' - requestBody: - required: true - content: - application/json: - schema: - type: object - examples: - dataSample: - $ref: 'components.yml#/components/examples/dataSample' - responses: - '200': - $ref: 'components.yml#/components/responses/Ok' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - -nodesByDataspaceAndAnchor: - post: - description: Create a node for a given anchor and dataspace - tags: - - cps-data - summary: Create a node - operationId: createNode - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - - $ref: 'components.yml#/components/parameters/xpathInQuery' - - $ref: 'components.yml#/components/parameters/observedTimestampInQuery' - - $ref: 'components.yml#/components/parameters/contentTypeHeader' - requestBody: - required: true - content: - application/json: - schema: - type: string - examples: - dataSample: - $ref: 'components.yml#/components/examples/dataSample' - application/xml: - schema: - type: object # Workaround to show example - xml: - name: stores - examples: - dataSample: - $ref: 'components.yml#/components/examples/dataSampleXml' - - responses: - '201': - $ref: 'components.yml#/components/responses/Created' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '409': - $ref: 'components.yml#/components/responses/Conflict' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - patch: - description: Update a data node leaves for a given dataspace and anchor and a parent node xpath. This operation - is currently supported for one top level data node only. - tags: - - cps-data - summary: Update node leaves - operationId: updateNodeLeaves - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - - $ref: 'components.yml#/components/parameters/xpathInQuery' - - $ref: 'components.yml#/components/parameters/observedTimestampInQuery' - - $ref: 'components.yml#/components/parameters/contentTypeHeader' - requestBody: - required: true - content: - application/json: - schema: - type: string - examples: - dataSample: - $ref: 'components.yml#/components/examples/dataSample' - application/xml: - schema: - type: object - xml: - name: stores - examples: - dataSample: - $ref: 'components.yml#/components/examples/dataSampleXml' - responses: - '200': - $ref: 'components.yml#/components/responses/Ok' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - delete: - description: Delete a datanode for a given dataspace and anchor given a node xpath. - tags: - - cps-data - summary: Delete a data node - operationId: deleteDataNode - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - - $ref: 'components.yml#/components/parameters/xpathInQuery' - - $ref: 'components.yml#/components/parameters/observedTimestampInQuery' - responses: - '204': - $ref: 'components.yml#/components/responses/NoContent' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - put: - description: Replace a node with descendants for a given dataspace, anchor and a parent node xpath - tags: - - cps-data - summary: Replace a node with descendants - operationId: replaceNode - parameters: - - $ref: 'components.yml#/components/parameters/apiVersionInPath' - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - - $ref: 'components.yml#/components/parameters/xpathInQuery' - - $ref: 'components.yml#/components/parameters/observedTimestampInQuery' - requestBody: - required: true - content: - application/json: - schema: - type: object - examples: - dataSample: - $ref: 'components.yml#/components/examples/dataSample' - responses: - '200': - $ref: 'components.yml#/components/responses/Ok' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' diff --git a/cps-rest/docs/openapi/cpsDataV1Deprecated.yml b/cps-rest/docs/openapi/cpsDataV1Deprecated.yml deleted file mode 100644 index 3941856422..0000000000 --- a/cps-rest/docs/openapi/cpsDataV1Deprecated.yml +++ /dev/null @@ -1,71 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2022-2023 TechMahindra Ltd. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -nodeByDataspaceAndAnchor: - get: - description: Get a node with an option to retrieve all the children for a given anchor and dataspace - deprecated: true - tags: - - cps-data - summary: Get a node - operationId: getNodeByDataspaceAndAnchor - parameters: - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - - $ref: 'components.yml#/components/parameters/xpathInQuery' - - $ref: 'components.yml#/components/parameters/includeDescendantsOptionInQuery' - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - examples: - dataSample: - $ref: 'components.yml#/components/examples/dataSample' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - x-codegen-request-body-name: xpath - -listElementByDataspaceAndAnchor: - delete: - description: Delete one or all list element(s) for a given anchor and dataspace - deprecated: true - tags: - - cps-data - summary: Delete one or all list element(s) - operationId: deleteListOrListElement - parameters: - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - - $ref: 'components.yml#/components/parameters/requiredXpathInQuery' - - $ref: 'components.yml#/components/parameters/observedTimestampInQuery' - responses: - '204': - $ref: 'components.yml#/components/responses/NoContent' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' diff --git a/cps-rest/docs/openapi/cpsDataV2.yml b/cps-rest/docs/openapi/cpsDataV2.yml deleted file mode 100644 index a1433badf6..0000000000 --- a/cps-rest/docs/openapi/cpsDataV2.yml +++ /dev/null @@ -1,129 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2022-2024 TechMahindra Ltd. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -nodeByDataspaceAndAnchor: - get: - description: Get a node with an option to retrieve all the children for a given anchor and dataspace - tags: - - cps-data - summary: Get a node - operationId: getNodeByDataspaceAndAnchorV2 - parameters: - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - - $ref: 'components.yml#/components/parameters/xpathInQuery' - - $ref: 'components.yml#/components/parameters/descendantsInQuery' - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - examples: - dataSample: - $ref: 'components.yml#/components/examples/dataSample' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - x-codegen-request-body-name: xpath - -deltaByDataspaceAndAnchors: - get: - description: Get delta between two anchors within a given dataspace - tags: - - cps-data - summary: Get delta between anchors in the same dataspace - operationId: getDeltaByDataspaceAndAnchors - parameters: - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - - $ref: 'components.yml#/components/parameters/targetAnchorNameInQuery' - - $ref: 'components.yml#/components/parameters/xpathInQuery' - - $ref: 'components.yml#/components/parameters/descendantsInQuery' - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - examples: - dataSample: - $ref: 'components.yml#/components/examples/deltaReportSample' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - x-codegen-request-body-name: xpath - -deltaByDataspaceAnchorAndPayload: - post: - description: Get delta between an anchor in a dataspace and JSON payload - tags: - - cps-data - summary: Get delta between an anchor and JSON payload - operationId: getDeltaByDataspaceAnchorAndPayload - parameters: - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - - $ref: 'components.yml#/components/parameters/xpathInQuery' - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - json: - type: object - example: - test:bookstore: - bookstore-name: Chapters - categories: - - code: 01 - name: SciFi - - code: 02 - name: kids - file: - type: string - format: binary - required: - - json - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - examples: - dataSample: - $ref: 'components.yml#/components/examples/deltaReportSample' - '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'
\ No newline at end of file diff --git a/cps-rest/docs/openapi/cpsQueryV1Deprecated.yml b/cps-rest/docs/openapi/cpsQueryV1Deprecated.yml deleted file mode 100644 index 9db2823994..0000000000 --- a/cps-rest/docs/openapi/cpsQueryV1Deprecated.yml +++ /dev/null @@ -1,50 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation -# Modifications Copyright (c) 2022 Bell Canada. -# Modifications Copyright (c) 2023 TechMahindra Ltd. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -nodesByDataspaceAndAnchorAndCpsPath: - get: - description: Query data nodes for the given dataspace and anchor using CPS path - tags: - - cps-query - summary: Query data nodes - deprecated: true - operationId: getNodesByDataspaceAndAnchorAndCpsPath - parameters: - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - - $ref: 'components.yml#/components/parameters/cpsPathInQuery' - - $ref: 'components.yml#/components/parameters/includeDescendantsOptionInQuery' - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - examples: - dataSample: - $ref: 'components.yml#/components/examples/dataSample' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - x-codegen-request-body-name: xpath diff --git a/cps-rest/docs/openapi/cpsQueryV2.yml b/cps-rest/docs/openapi/cpsQueryV2.yml deleted file mode 100644 index 7f0ceff768..0000000000 --- a/cps-rest/docs/openapi/cpsQueryV2.yml +++ /dev/null @@ -1,78 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2023 TechMahindra Ltd. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -nodesByDataspaceAndAnchorAndCpsPath: - get: - description: Query data nodes for the given dataspace and anchor using CPS path - tags: - - cps-query - summary: Query data nodes - operationId: getNodesByDataspaceAndAnchorAndCpsPathV2 - parameters: - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/anchorNameInPath' - - $ref: 'components.yml#/components/parameters/cpsPathInQuery' - - $ref: 'components.yml#/components/parameters/descendantsInQuery' - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - examples: - dataSample: - $ref: 'components.yml#/components/examples/dataSample' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - x-codegen-request-body-name: xpath - -nodesByDataspaceAndCpsPath: - get: - description: Query data nodes for the given dataspace across anchors using CPS path - tags: - - cps-query - summary: Query data nodes across anchors - operationId: getNodesByDataspaceAndCpsPath - parameters: - - $ref: 'components.yml#/components/parameters/dataspaceNameInPath' - - $ref: 'components.yml#/components/parameters/cpsPathInQuery' - - $ref: 'components.yml#/components/parameters/descendantsInQuery' - - $ref: 'components.yml#/components/parameters/pageIndexInQuery' - - $ref: 'components.yml#/components/parameters/pageSizeInQuery' - responses: - '200': - description: OK - content: - application/json: - schema: - type: object - examples: - dataSample: - $ref: 'components.yml#/components/examples/dataSampleAcrossAnchors' - '400': - $ref: 'components.yml#/components/responses/BadRequest' - '403': - $ref: 'components.yml#/components/responses/Forbidden' - '500': - $ref: 'components.yml#/components/responses/InternalServerError' - x-codegen-request-body-name: xpath diff --git a/cps-rest/docs/openapi/openapi.yml b/cps-rest/docs/openapi/openapi.yml deleted file mode 100644 index b4e0b70408..0000000000 --- a/cps-rest/docs/openapi/openapi.yml +++ /dev/null @@ -1,123 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2021-2023 Nordix Foundation -# Modifications Copyright (C) 2021 Pantheon.tech -# Modifications Copyright (C) 2021 Bell Canada. -# Modifications Copyright (C) 2022-2024 TechMahindra Ltd. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# ============LICENSE_END========================================================= - -openapi: 3.0.3 -info: - title: ONAP Open API v3 Configuration Persistence Service - description: Configuration Persistence Service is a Model Driven Generic Database - version: "1.0.0" - contact: - name: ONAP - url: "https://onap.readthedocs.io" - email: "onap-discuss@lists.onap.org" - license: - name: "Apache 2.0" - url: "http://www.apache.org/licenses/LICENSE-2.0" - x-planned-retirement-date: "202212" - x-component: "Modeling" - x-logo: - url: "cps_logo.png" - -servers: - - url: /cps/api -components: - securitySchemes: - basicAuth: - type: http - scheme: basic -tags: - - name: cps-admin - description: cps Admin - - name: cps-data - description: cps Data -paths: - - /v1/dataspaces: - $ref: 'cpsAdminV1Deprecated.yml#/dataspaces' - - /{apiVersion}/dataspaces: - $ref: 'cpsAdmin.yml#/dataspaces' - - /v2/dataspaces: - $ref: 'cpsAdminV2.yml#/dataspaces' - - /{apiVersion}/admin/dataspaces: - $ref: 'cpsAdmin.yml#/adminDataspaces' - - /{apiVersion}/admin/dataspaces/{dataspace-name}: - $ref: 'cpsAdmin.yml#/adminDataspace' - - /v1/dataspaces/{dataspace-name}/anchors: - $ref: 'cpsAdminV1Deprecated.yml#/anchorsByDataspace' - - /v2/dataspaces/{dataspace-name}/anchors: - $ref: 'cpsAdminV2.yml#/anchorsByDataspace' - - /{apiVersion}/dataspaces/{dataspace-name}/anchors: - $ref: 'cpsAdmin.yml#/anchorsByDataspace' - - /{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}: - $ref: 'cpsAdmin.yml#/anchorByDataspaceAndAnchorName' - - /v1/dataspaces/{dataspace-name}/schema-sets: - $ref: 'cpsAdminV1Deprecated.yml#/schemaSet' - - /v2/dataspaces/{dataspace-name}/schema-sets: - $ref: 'cpsAdminV2.yml#/schemaSet' - - /{apiVersion}/dataspaces/{dataspace-name}/schema-sets: - $ref: 'cpsAdmin.yml#/schemaSet' - - /{apiVersion}/dataspaces/{dataspace-name}/schema-sets/{schema-set-name}: - $ref: 'cpsAdmin.yml#/schemaSetBySchemaSetName' - - /v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/node: - $ref: 'cpsDataV1Deprecated.yml#/nodeByDataspaceAndAnchor' - - /v2/dataspaces/{dataspace-name}/anchors/{anchor-name}/node: - $ref: 'cpsDataV2.yml#/nodeByDataspaceAndAnchor' - - /{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes: - $ref: 'cpsData.yml#/nodesByDataspaceAndAnchor' - - /v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/list-nodes: - $ref: 'cpsDataV1Deprecated.yml#/listElementByDataspaceAndAnchor' - - /{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/list-nodes: - $ref: 'cpsData.yml#/listElementByDataspaceAndAnchor' - - /v2/dataspaces/{dataspace-name}/anchors/{anchor-name}/deltaAnchors: - $ref: 'cpsDataV2.yml#/deltaByDataspaceAndAnchors' - - /v2/dataspaces/{dataspace-name}/anchors/{anchor-name}/deltaPayload: - $ref: 'cpsDataV2.yml#/deltaByDataspaceAnchorAndPayload' - - /v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes/query: - $ref: 'cpsQueryV1Deprecated.yml#/nodesByDataspaceAndAnchorAndCpsPath' - - /v2/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes/query: - $ref: 'cpsQueryV2.yml#/nodesByDataspaceAndAnchorAndCpsPath' - - /v2/dataspaces/{dataspace-name}/nodes/query: - $ref: 'cpsQueryV2.yml#/nodesByDataspaceAndCpsPath' - -security: - - basicAuth: [] diff --git a/cps-rest/pom.xml b/cps-rest/pom.xml index f7ddd6c382..f115fdfd52 100644 --- a/cps-rest/pom.xml +++ b/cps-rest/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.5.1-SNAPSHOT</version> + <version>3.5.3-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> @@ -141,7 +141,7 @@ <goal>generate</goal> </goals> <configuration> - <inputSpec>${project.basedir}/docs/openapi/openapi.yml</inputSpec> + <inputSpec>${project.basedir}/../docs/api/swagger/cps/openapi.yaml</inputSpec> <invokerPackage>org.onap.cps.rest.controller</invokerPackage> <modelPackage>org.onap.cps.rest.model</modelPackage> <apiPackage>org.onap.cps.rest.api</apiPackage> @@ -165,7 +165,7 @@ </goals> <phase>compile</phase> <configuration> - <inputSpec>${project.basedir}/docs/openapi/openapi.yml</inputSpec> + <inputSpec>${project.basedir}/../docs/api/swagger/cps/openapi.yaml</inputSpec> <generatorName>openapi-yaml</generatorName> <configOptions> <outputFile>openapi.yaml</outputFile> @@ -174,30 +174,6 @@ </execution> </executions> </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-resources-plugin</artifactId> - <executions> - <execution> - <id>copy-resources</id> - <phase>compile</phase> - <goals> - <goal>copy-resources</goal> - </goals> - <configuration> - <outputDirectory>${project.basedir}/target/classes/static/api-docs/cps-core</outputDirectory> - <resources> - <resource> - <directory>${project.basedir}/target/generated-sources/openapi/</directory> - <includes> - <include>openapi.yaml</include> - </includes> - </resource> - </resources> - </configuration> - </execution> - </executions> - </plugin> </plugins> </build> </project> diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java index f579c82d25..f86073fb06 100755 --- a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2020-2022 Bell Canada. * Modifications Copyright (C) 2021 Pantheon.tech - * Modifications Copyright (C) 2021-2023 Nordix Foundation + * Modifications Copyright (C) 2021-2024 Nordix Foundation * Modifications Copyright (C) 2022-2024 TechMahindra Ltd. * Modifications Copyright (C) 2022 Deutsche Telekom AG * ================================================================================ @@ -37,9 +37,11 @@ import java.util.List; import java.util.Map; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; +import org.onap.cps.api.CpsAnchorService; import org.onap.cps.api.CpsDataService; import org.onap.cps.rest.api.CpsDataApi; import org.onap.cps.spi.FetchDescendantsOption; +import org.onap.cps.spi.model.Anchor; import org.onap.cps.spi.model.DataNode; import org.onap.cps.spi.model.DeltaReport; import org.onap.cps.utils.ContentType; @@ -49,7 +51,6 @@ import org.onap.cps.utils.PrefixResolver; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -64,17 +65,17 @@ public class DataRestController implements CpsDataApi { private static final DateTimeFormatter ISO_TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern(ISO_TIMESTAMP_FORMAT); private final CpsDataService cpsDataService; + private final CpsAnchorService cpsAnchorService; private final JsonObjectMapper jsonObjectMapper; private final PrefixResolver prefixResolver; @Override public ResponseEntity<String> createNode(final String apiVersion, final String dataspaceName, final String anchorName, - @RequestHeader(value = "Content-Type") final String contentTypeHeader, + final String contentTypeInHeader, final String nodeData, final String parentNodeXpath, final String observedTimestamp) { - final ContentType contentType = contentTypeHeader.contains(MediaType.APPLICATION_XML_VALUE) ? ContentType.XML - : ContentType.JSON; + final ContentType contentType = getContentTypeFromHeader(contentTypeInHeader); if (isRootXpath(parentNodeXpath)) { cpsDataService.saveData(dataspaceName, anchorName, nodeData, toOffsetDateTime(observedTimestamp), contentType); @@ -97,9 +98,11 @@ public class DataRestController implements CpsDataApi { @Override public ResponseEntity<String> addListElements(final String apiVersion, final String dataspaceName, final String anchorName, final String parentNodeXpath, - final Object jsonData, final String observedTimestamp) { + final String contentTypeInHeader, final String nodeData, + final String observedTimestamp) { + final ContentType contentType = getContentTypeFromHeader(contentTypeInHeader); cpsDataService.saveListElements(dataspaceName, anchorName, parentNodeXpath, - jsonObjectMapper.asJsonString(jsonData), toOffsetDateTime(observedTimestamp)); + nodeData, toOffsetDateTime(observedTimestamp), contentType); return new ResponseEntity<>(HttpStatus.CREATED); } @@ -112,7 +115,8 @@ public class DataRestController implements CpsDataApi { ? FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS : FetchDescendantsOption.OMIT_DESCENDANTS; final DataNode dataNode = cpsDataService.getDataNodes(dataspaceName, anchorName, xpath, fetchDescendantsOption).iterator().next(); - final String prefix = prefixResolver.getPrefix(dataspaceName, anchorName, dataNode.getXpath()); + final Anchor anchor = cpsAnchorService.getAnchor(dataspaceName, anchorName); + final String prefix = prefixResolver.getPrefix(anchor, dataNode.getXpath()); return new ResponseEntity<>(DataMapUtils.toDataMapWithIdentifier(dataNode, prefix), HttpStatus.OK); } @@ -127,8 +131,9 @@ public class DataRestController implements CpsDataApi { final Collection<DataNode> dataNodes = cpsDataService.getDataNodes(dataspaceName, anchorName, xpath, fetchDescendantsOption); final List<Map<String, Object>> dataMaps = new ArrayList<>(dataNodes.size()); + final Anchor anchor = cpsAnchorService.getAnchor(dataspaceName, anchorName); for (final DataNode dataNode: dataNodes) { - final String prefix = prefixResolver.getPrefix(dataspaceName, anchorName, dataNode.getXpath()); + final String prefix = prefixResolver.getPrefix(anchor, dataNode.getXpath()); final Map<String, Object> dataMap = DataMapUtils.toDataMapWithIdentifier(dataNode, prefix); dataMaps.add(dataMap); } @@ -137,23 +142,23 @@ public class DataRestController implements CpsDataApi { @Override public ResponseEntity<Object> updateNodeLeaves(final String apiVersion, final String dataspaceName, - final String anchorName, final String contentTypeHeader, + final String anchorName, final String contentTypeInHeader, final String nodeData, final String parentNodeXpath, final String observedTimestamp) { - final ContentType contentType = contentTypeHeader.contains(MediaType.APPLICATION_XML_VALUE) ? ContentType.XML - : ContentType.JSON; + final ContentType contentType = getContentTypeFromHeader(contentTypeInHeader); cpsDataService.updateNodeLeaves(dataspaceName, anchorName, parentNodeXpath, nodeData, toOffsetDateTime(observedTimestamp), contentType); return new ResponseEntity<>(HttpStatus.OK); } @Override - public ResponseEntity<Object> replaceNode(final String apiVersion, - final String dataspaceName, final String anchorName, - final Object jsonData, final String parentNodeXpath, final String observedTimestamp) { - cpsDataService - .updateDataNodeAndDescendants(dataspaceName, anchorName, parentNodeXpath, - jsonObjectMapper.asJsonString(jsonData), toOffsetDateTime(observedTimestamp)); + public ResponseEntity<Object> replaceNode(final String apiVersion, final String dataspaceName, + final String anchorName, final String contentTypeInHeader, + final String nodeData, final String parentNodeXpath, + final String observedTimestamp) { + final ContentType contentType = getContentTypeFromHeader(contentTypeInHeader); + cpsDataService.updateDataNodeAndDescendants(dataspaceName, anchorName, parentNodeXpath, + nodeData, toOffsetDateTime(observedTimestamp), contentType); return new ResponseEntity<>(HttpStatus.OK); } @@ -213,6 +218,10 @@ public class DataRestController implements CpsDataApi { return new ResponseEntity<>(jsonObjectMapper.asJsonString(deltaBetweenAnchors), HttpStatus.OK); } + private static ContentType getContentTypeFromHeader(final String contentTypeInHeader) { + return contentTypeInHeader.contains(MediaType.APPLICATION_XML_VALUE) ? ContentType.XML : ContentType.JSON; + } + private static boolean isRootXpath(final String xpath) { return ROOT_XPATH.equals(xpath); } diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java index 5334b48143..547be669ae 100644 --- a/cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation + * Copyright (C) 2021-2024 Nordix Foundation * Modifications Copyright (C) 2022 Bell Canada. * Modifications Copyright (C) 2022-2023 TechMahindra Ltd. * ================================================================================ @@ -29,10 +29,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import lombok.RequiredArgsConstructor; +import org.onap.cps.api.CpsAnchorService; import org.onap.cps.api.CpsQueryService; import org.onap.cps.rest.api.CpsQueryApi; import org.onap.cps.spi.FetchDescendantsOption; import org.onap.cps.spi.PaginationOption; +import org.onap.cps.spi.model.Anchor; import org.onap.cps.spi.model.DataNode; import org.onap.cps.utils.DataMapUtils; import org.onap.cps.utils.JsonObjectMapper; @@ -48,6 +50,7 @@ import org.springframework.web.bind.annotation.RestController; public class QueryRestController implements CpsQueryApi { private final CpsQueryService cpsQueryService; + private final CpsAnchorService cpsAnchorService; private final JsonObjectMapper jsonObjectMapper; private final PrefixResolver prefixResolver; @@ -87,14 +90,15 @@ public class QueryRestController implements CpsQueryApi { cpsPath, fetchDescendantsOption, paginationOption); final List<Map<String, Object>> dataNodesAsListOfMaps = new ArrayList<>(dataNodes.size()); String prefix = null; - final Map<String, List<DataNode>> anchorDataNodeListMap = prepareDataNodesForAnchor(dataNodes); - for (final Map.Entry<String, List<DataNode>> anchorDataNodesMapEntry : anchorDataNodeListMap.entrySet()) { + final Map<String, List<DataNode>> dataNodesPerAnchor = groupDataNodesPerAnchor(dataNodes); + for (final Map.Entry<String, List<DataNode>> dataNodesPerAnchorEntry : dataNodesPerAnchor.entrySet()) { + final String anchorName = dataNodesPerAnchorEntry.getKey(); if (prefix == null) { - prefix = prefixResolver.getPrefix(dataspaceName, anchorDataNodesMapEntry.getKey(), - anchorDataNodesMapEntry.getValue().get(0).getXpath()); + final Anchor anchor = cpsAnchorService.getAnchor(dataspaceName, anchorName); + prefix = prefixResolver.getPrefix(anchor, dataNodesPerAnchorEntry.getValue().get(0).getXpath()); } final Map<String, Object> dataMap = DataMapUtils.toDataMapWithIdentifierAndAnchor( - anchorDataNodesMapEntry.getValue(), anchorDataNodesMapEntry.getKey(), prefix); + dataNodesPerAnchorEntry.getValue(), anchorName, prefix); dataNodesAsListOfMaps.add(dataMap); } final Integer totalPages = getTotalPages(dataspaceName, cpsPath, paginationOption); @@ -112,7 +116,7 @@ public class QueryRestController implements CpsQueryApi { : (int) Math.ceil((double) totalAnchors / paginationOption.getPageSize()); } - private Map<String, List<DataNode>> prepareDataNodesForAnchor(final Collection<DataNode> dataNodes) { + private Map<String, List<DataNode>> groupDataNodesPerAnchor(final Collection<DataNode> dataNodes) { final Map<String, List<DataNode>> dataNodesMapForAnchor = new HashMap<>(); for (final DataNode dataNode : dataNodes) { List<DataNode> dataNodesInAnchor = dataNodesMapForAnchor.get(dataNode.getAnchorName()); @@ -130,10 +134,11 @@ public class QueryRestController implements CpsQueryApi { final Collection<DataNode> dataNodes = cpsQueryService.queryDataNodes(dataspaceName, anchorName, cpsPath, fetchDescendantsOption); final List<Map<String, Object>> dataNodesAsListOfMaps = new ArrayList<>(dataNodes.size()); + final Anchor anchor = cpsAnchorService.getAnchor(dataspaceName, anchorName); String prefix = null; for (final DataNode dataNode : dataNodes) { if (prefix == null) { - prefix = prefixResolver.getPrefix(dataspaceName, anchorName, dataNode.getXpath()); + prefix = prefixResolver.getPrefix(anchor, dataNode.getXpath()); } final Map<String, Object> dataMap = DataMapUtils.toDataMapWithIdentifier(dataNode, prefix); dataNodesAsListOfMaps.add(dataMap); diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy index 317b9c5b7c..e101ea6c41 100755 --- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy +++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation + * Copyright (C) 2021-2024 Nordix Foundation * Modifications Copyright (C) 2021 Pantheon.tech * Modifications Copyright (C) 2021-2022 Bell Canada. * Modifications Copyright (C) 2022 Deutsche Telekom AG @@ -26,6 +26,7 @@ package org.onap.cps.rest.controller import com.fasterxml.jackson.databind.ObjectMapper import groovy.json.JsonSlurper +import org.onap.cps.api.CpsAnchorService import org.onap.cps.api.CpsDataService import org.onap.cps.spi.FetchDescendantsOption import org.onap.cps.spi.model.DataNode @@ -63,6 +64,9 @@ class DataRestControllerSpec extends Specification { CpsDataService mockCpsDataService = Mock() @SpringBean + CpsAnchorService mockCpsAnchorService = Mock() + + @SpringBean JsonObjectMapper jsonObjectMapper = new JsonObjectMapper(new ObjectMapper()) @SpringBean @@ -192,22 +196,25 @@ class DataRestControllerSpec extends Specification { def rootNodeXpath = '/' when: 'list-node endpoint is invoked with post (create) operation' def postRequestBuilder = post("$dataNodeBaseEndpointV1/anchors/$anchorName/list-nodes") - .contentType(MediaType.APPLICATION_JSON) + .contentType(contentType) .param('xpath', rootNodeXpath ) - .content(requestBodyJson) + .content(requestBody) if (observedTimestamp != null) postRequestBuilder.param('observed-timestamp', observedTimestamp) def response = mvc.perform(postRequestBuilder).andReturn().response then: 'a created response is returned' response.status == expectedHttpStatus.value() then: 'the java API was called with the correct parameters' - expectedApiCount * mockCpsDataService.saveListElements(dataspaceName, anchorName, rootNodeXpath, expectedJsonData, - { it == DateTimeUtility.toOffsetDateTime(observedTimestamp) }) + expectedApiCount * mockCpsDataService.saveListElements(dataspaceName, anchorName, rootNodeXpath, expectedData, + { it == DateTimeUtility.toOffsetDateTime(observedTimestamp) }, expectedContentType) where: - scenario | observedTimestamp || expectedApiCount | expectedHttpStatus - 'with observed-timestamp' | '2021-03-03T23:59:59.999-0400' || 1 | HttpStatus.CREATED - 'without observed-timestamp' | null || 1 | HttpStatus.CREATED - 'with invalid observed-timestamp' | 'invalid' || 0 | HttpStatus.BAD_REQUEST + scenario | observedTimestamp | contentType | requestBody || expectedApiCount | expectedHttpStatus | expectedData | expectedContentType + 'Content type JSON with observed-timestamp' | '2021-03-03T23:59:59.999-0400' | MediaType.APPLICATION_JSON | requestBodyJson || 1 | HttpStatus.CREATED | expectedJsonData | ContentType.JSON + 'Content type JSON without observed-timestamp' | null | MediaType.APPLICATION_JSON | requestBodyJson || 1 | HttpStatus.CREATED | expectedJsonData | ContentType.JSON + 'Content type JSON with invalid observed-timestamp' | 'invalid' | MediaType.APPLICATION_JSON | requestBodyJson || 0 | HttpStatus.BAD_REQUEST | expectedJsonData | ContentType.JSON + 'Content type XML with observed-timestamp' | '2021-03-03T23:59:59.999-0400' | MediaType.APPLICATION_XML | requestBodyXml || 1 | HttpStatus.CREATED | expectedXmlData | ContentType.XML + 'Content type XML without observed-timestamp' | null | MediaType.APPLICATION_XML | requestBodyXml || 1 | HttpStatus.CREATED | expectedXmlData | ContentType.XML + 'Content type XML with invalid observed-timestamp' | 'invalid' | MediaType.APPLICATION_XML | requestBodyXml || 0 | HttpStatus.BAD_REQUEST | expectedXmlData | ContentType.XML } def 'Save list elements #scenario.'() { @@ -215,22 +222,25 @@ class DataRestControllerSpec extends Specification { def parentNodeXpath = 'parent node xpath' when: 'list-node endpoint is invoked with post (create) operation' def postRequestBuilder = post("$dataNodeBaseEndpointV1/anchors/$anchorName/list-nodes") - .contentType(MediaType.APPLICATION_JSON) + .contentType(contentType) .param('xpath', parentNodeXpath) - .content(requestBodyJson) + .content(requestBody) if (observedTimestamp != null) postRequestBuilder.param('observed-timestamp', observedTimestamp) def response = mvc.perform(postRequestBuilder).andReturn().response then: 'a created response is returned' response.status == expectedHttpStatus.value() then: 'the java API was called with the correct parameters' - expectedApiCount * mockCpsDataService.saveListElements(dataspaceName, anchorName, parentNodeXpath, expectedJsonData, - { it == DateTimeUtility.toOffsetDateTime(observedTimestamp) }) + expectedApiCount * mockCpsDataService.saveListElements(dataspaceName, anchorName, parentNodeXpath, expectedData, + { it == DateTimeUtility.toOffsetDateTime(observedTimestamp) }, expectedContentType) where: - scenario | observedTimestamp || expectedApiCount | expectedHttpStatus - 'with observed-timestamp' | '2021-03-03T23:59:59.999-0400' || 1 | HttpStatus.CREATED - 'without observed-timestamp' | null || 1 | HttpStatus.CREATED - 'with invalid observed-timestamp' | 'invalid' || 0 | HttpStatus.BAD_REQUEST + scenario | observedTimestamp | contentType | requestBody || expectedApiCount | expectedHttpStatus | expectedData | expectedContentType + 'Content type JSON with observed-timestamp' | '2021-03-03T23:59:59.999-0400' | MediaType.APPLICATION_JSON | requestBodyJson || 1 | HttpStatus.CREATED | expectedJsonData | ContentType.JSON + 'Content type JSON without observed-timestamp' | null | MediaType.APPLICATION_JSON | requestBodyJson || 1 | HttpStatus.CREATED | expectedJsonData | ContentType.JSON + 'Content type JSON with invalid observed-timestamp' | 'invalid' | MediaType.APPLICATION_JSON | requestBodyJson || 0 | HttpStatus.BAD_REQUEST | expectedJsonData | ContentType.JSON + 'Content type XML with observed-timestamp' | '2021-03-03T23:59:59.999-0400' | MediaType.APPLICATION_XML | requestBodyXml || 1 | HttpStatus.CREATED | expectedXmlData | ContentType.XML + 'Content type XML without observed-timestamp' | null | MediaType.APPLICATION_XML | requestBodyXml || 1 | HttpStatus.CREATED | expectedXmlData | ContentType.XML + 'Content type XML with invalid observed-timestamp' | 'invalid' | MediaType.APPLICATION_XML | requestBodyXml || 0 | HttpStatus.BAD_REQUEST | expectedXmlData | ContentType.XML } def 'Get data node with leaves'() { @@ -344,9 +354,9 @@ class DataRestControllerSpec extends Specification { def 'Get delta between two anchors'() { given: 'the service returns a list containing delta reports' - def deltaReports = new DeltaReportBuilder().actionUpdate().withXpath('some xpath').withSourceData('some key': 'some value').withTargetData('some key': 'some value').build() + def deltaReports = new DeltaReportBuilder().actionReplace().withXpath('some xpath').withSourceData('some key': 'some value').withTargetData('some key': 'some value').build() def xpath = 'some xpath' - def endpoint = "$dataNodeBaseEndpointV2/anchors/sourceAnchor/deltaAnchors" + def endpoint = "$dataNodeBaseEndpointV2/anchors/sourceAnchor/delta" mockCpsDataService.getDeltaByDataspaceAndAnchors(dataspaceName, 'sourceAnchor', 'targetAnchor', xpath, OMIT_DESCENDANTS) >> [deltaReports] when: 'get delta request is performed using REST API' def response = @@ -357,14 +367,14 @@ class DataRestControllerSpec extends Specification { then: 'expected response code is returned' assert response.status == HttpStatus.OK.value() and: 'the response contains expected value' - assert response.contentAsString.contains("[{\"action\":\"update\",\"xpath\":\"some xpath\",\"sourceData\":{\"some key\":\"some value\"},\"targetData\":{\"some key\":\"some value\"}}]") + assert response.contentAsString.contains("[{\"action\":\"replace\",\"xpath\":\"some xpath\",\"sourceData\":{\"some key\":\"some value\"},\"targetData\":{\"some key\":\"some value\"}}]") } def 'Get delta between anchor and JSON payload with multipart file'() { given: 'sample delta report, xpath, yang model file and json payload' - def deltaReports = new DeltaReportBuilder().actionAdd().withXpath('some xpath').build() + def deltaReports = new DeltaReportBuilder().actionCreate().withXpath('some xpath').build() def xpath = 'some xpath' - def endpoint = "$dataNodeBaseEndpointV2/anchors/$anchorName/deltaPayload" + def endpoint = "$dataNodeBaseEndpointV2/anchors/$anchorName/delta" and: 'the service layer returns a list containing delta reports' mockCpsDataService.getDeltaByDataspaceAnchorAndPayload(dataspaceName, anchorName, xpath, ['filename.yang':'content'], expectedJsonData, INCLUDE_ALL_DESCENDANTS) >> [deltaReports] when: 'get delta request is performed using REST API' @@ -378,14 +388,14 @@ class DataRestControllerSpec extends Specification { then: 'expected response code is returned' assert response.status == HttpStatus.OK.value() and: 'the response contains expected value' - assert response.contentAsString.contains("[{\"action\":\"add\",\"xpath\":\"some xpath\"}]") + assert response.contentAsString.contains("[{\"action\":\"create\",\"xpath\":\"some xpath\"}]") } def 'Get delta between anchor and JSON payload without multipart file'() { given: 'sample delta report, xpath, and json payload' def deltaReports = new DeltaReportBuilder().actionRemove().withXpath('some xpath').build() def xpath = 'some xpath' - def endpoint = "$dataNodeBaseEndpointV2/anchors/$anchorName/deltaPayload" + def endpoint = "$dataNodeBaseEndpointV2/anchors/$anchorName/delta" and: 'the service layer returns a list containing delta reports' mockCpsDataService.getDeltaByDataspaceAnchorAndPayload(dataspaceName, anchorName, xpath, [:], expectedJsonData, INCLUDE_ALL_DESCENDANTS) >> [deltaReports] when: 'get delta request is performed using REST API' @@ -456,19 +466,22 @@ class DataRestControllerSpec extends Specification { def response = mvc.perform( put(endpoint) - .contentType(MediaType.APPLICATION_JSON) - .content(requestBodyJson) + .contentType(contentType) + .content(requestBody) .param('xpath', inputXpath)) .andReturn().response then: 'the service method is invoked with expected parameters' - 1 * mockCpsDataService.updateDataNodeAndDescendants(dataspaceName, anchorName, xpathServiceParameter, expectedJsonData, noTimestamp) + 1 * mockCpsDataService.updateDataNodeAndDescendants(dataspaceName, anchorName, xpathServiceParameter, expectedData, noTimestamp, expectedContentType) and: 'response status indicates success' response.status == HttpStatus.OK.value() where: - scenario | inputXpath || xpathServiceParameter - 'root node by default' | '' || '/' - 'root node by choice' | '/' || '/' - 'some xpath by parent' | '/some/xpath' || '/some/xpath' + scenario | inputXpath | contentType || xpathServiceParameter | requestBody | expectedData | expectedContentType + 'JSON content: root node by default' | '' | MediaType.APPLICATION_JSON || '/' | requestBodyJson | expectedJsonData | ContentType.JSON + 'JSON content: root node by choice' | '/' | MediaType.APPLICATION_JSON || '/' | requestBodyJson | expectedJsonData | ContentType.JSON + 'JSON content: some xpath by parent' | '/some/xpath' | MediaType.APPLICATION_JSON || '/some/xpath' | requestBodyJson | expectedJsonData | ContentType.JSON + 'XML content: root node by default' | '' | MediaType.APPLICATION_XML || '/' | requestBodyXml | expectedXmlData | ContentType.XML + 'XML content: root node by choice' | '/' | MediaType.APPLICATION_XML || '/' | requestBodyXml | expectedXmlData | ContentType.XML + 'XML content: some xpath by parent' | '/some/xpath' | MediaType.APPLICATION_XML || '/some/xpath' | requestBodyXml | expectedXmlData | ContentType.XML } def 'Update data node and descendants with observedTimestamp.'() { @@ -485,7 +498,7 @@ class DataRestControllerSpec extends Specification { .andReturn().response then: 'the service method is invoked with expected parameters' expectedApiCount * mockCpsDataService.updateDataNodeAndDescendants(dataspaceName, anchorName, '/', expectedJsonData, - { it == DateTimeUtility.toOffsetDateTime(observedTimestamp) }) + { it == DateTimeUtility.toOffsetDateTime(observedTimestamp) }, ContentType.JSON) and: 'response status indicates success' response.status == expectedHttpStatus.value() where: diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy index c30a63fd46..80b287cda8 100644 --- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy +++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation + * Copyright (C) 2021-2024 Nordix Foundation * Modifications Copyright (C) 2021-2022 Bell Canada. * Modifications Copyright (C) 2021 Pantheon.tech * Modifications Copyright (C) 2022-2023 TechMahindra Ltd. @@ -23,18 +23,13 @@ package org.onap.cps.rest.controller -import org.onap.cps.spi.PaginationOption -import org.onap.cps.utils.PrefixResolver - -import static org.onap.cps.spi.FetchDescendantsOption.DIRECT_CHILDREN_ONLY -import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS -import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get - import com.fasterxml.jackson.databind.ObjectMapper -import org.onap.cps.utils.JsonObjectMapper +import org.onap.cps.api.CpsAnchorService import org.onap.cps.api.CpsQueryService +import org.onap.cps.spi.PaginationOption import org.onap.cps.spi.model.DataNodeBuilder +import org.onap.cps.utils.JsonObjectMapper +import org.onap.cps.utils.PrefixResolver import org.spockframework.spring.SpringBean import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value @@ -43,6 +38,11 @@ import org.springframework.http.HttpStatus import org.springframework.test.web.servlet.MockMvc import spock.lang.Specification +import static org.onap.cps.spi.FetchDescendantsOption.DIRECT_CHILDREN_ONLY +import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS +import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get + @WebMvcTest(QueryRestController) class QueryRestControllerSpec extends Specification { @@ -50,6 +50,9 @@ class QueryRestControllerSpec extends Specification { CpsQueryService mockCpsQueryService = Mock() @SpringBean + CpsAnchorService mockCpsAnchorService = Mock() + + @SpringBean JsonObjectMapper jsonObjectMapper = new JsonObjectMapper(new ObjectMapper()) @SpringBean |