diff options
15 files changed, 2760 insertions, 1152 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java index 471f1758c..3dbd578c7 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021 Pantheon.tech - * Modifications Copyright (C) 2021 Nordix Foundation + * Modifications Copyright (C) 2021-2023 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,9 @@ import org.onap.cps.spi.exceptions.AnchorNotFoundException; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +@Repository public interface AnchorRepository extends JpaRepository<AnchorEntity, Integer> { Optional<AnchorEntity> findByDataspaceAndName(@NotNull DataspaceEntity dataspaceEntity, @NotNull String name); diff --git a/docs/api/swagger/cps/openapi.yaml b/docs/api/swagger/cps/openapi.yaml index 80766cc07..53c72f559 100644 --- a/docs/api/swagger/cps/openapi.yaml +++ b/docs/api/swagger/cps/openapi.yaml @@ -15,29 +15,30 @@ info: x-logo: url: cps_logo.png servers: -- url: /cps/api + - url: /cps/api +security: + - basicAuth: [] tags: -- name: cps-admin - description: cps Admin -- name: cps-data - description: cps Data + - name: cps-admin + description: cps Admin + - name: cps-data + description: cps Data paths: /v1/dataspaces: post: tags: - - cps-admin + - cps-admin summary: Create a dataspace description: Create a new dataspace operationId: createDataspace - deprecated: true parameters: - - name: dataspace-name - in: query - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace + - name: dataspace-name + in: query + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace responses: "201": description: Created @@ -96,24 +97,36 @@ paths: status: 500 message: Internal Server Error details: Internal Server Error occurred - /v2/dataspaces: - post: + deprecated: true + /{apiVersion}/dataspaces: + delete: tags: - - cps-admin - summary: Create a dataspace - description: Create a new dataspace - operationId: createDataspaceV2 + - cps-admin + summary: Delete a dataspace + description: Delete a dataspace + operationId: deleteDataspace parameters: - - name: dataspace-name - in: query - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 + - name: dataspace-name + in: query + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace responses: - "201": - description: Created + "204": + description: No Content + content: {} "400": description: Bad Request content: @@ -164,26 +177,24 @@ paths: status: 500 message: Internal Server Error details: Internal Server Error occurred - /{apiVersion}/dataspaces: - delete: + /v2/dataspaces: + post: tags: - - cps-admin - summary: Delete a dataspace - description: Delete a dataspace - operationId: deleteDataspace + - cps-admin + summary: Create a dataspace + description: Create a new dataspace + operationId: createDataspaceV2 parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: query - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace + - name: dataspace-name + in: query + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace responses: - "204": - description: No Content - content: {} + "201": + description: Created without response body "400": description: Bad Request content: @@ -237,12 +248,21 @@ paths: /{apiVersion}/admin/dataspaces: get: tags: - - cps-admin - summary: Get dataspaces - description: "Read all dataspaces" + - cps-admin + summary: Get all dataspaces + description: Read all dataspaces operationId: getAllDataspaces parameters: - - $ref: '#/components/parameters/apiVersionInPath' + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 responses: "200": description: OK @@ -295,19 +315,28 @@ paths: /{apiVersion}/admin/dataspaces/{dataspace-name}: get: tags: - - cps-admin + - cps-admin summary: Get a dataspace - description: Read an dataspace given a dataspace name + description: Read a dataspace given a dataspace name operationId: getDataspace parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace responses: "200": description: OK @@ -355,31 +384,43 @@ paths: status: 500 message: Internal Server Error details: Internal Server Error occurred - /{apiVersion}/dataspaces/{dataspace-name}/anchors: - get: + /v1/dataspaces/{dataspace-name}/anchors: + post: tags: - - cps-admin - summary: Get anchors - description: "Read all anchors, given a dataspace" - operationId: getAnchors + - cps-admin + summary: Create an anchor + description: Create a new anchor in the given dataspace + operationId: createAnchor parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: schema-set-name + in: query + description: schema-set-name + required: true + schema: + type: string + example: my-schema-set + - name: anchor-name + in: query + description: anchor-name + required: true + schema: + type: string + example: my-anchor responses: - "200": - description: OK + "201": + description: Created content: - application/json: + text/plain: schema: - type: array - items: - $ref: '#/components/schemas/AnchorDetails' + type: string + example: my-resource "400": description: Bad Request content: @@ -410,6 +451,16 @@ paths: status: 403 message: Request Forbidden details: This request is forbidden + "409": + 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. "500": description: Internal Server Error content: @@ -420,44 +471,39 @@ paths: status: 500 message: Internal Server Error details: Internal Server Error occurred - /v1/dataspaces/{dataspace-name}/anchors: + deprecated: true + /v2/dataspaces/{dataspace-name}/anchors: post: tags: - - cps-admin + - cps-admin summary: Create an anchor - deprecated: true description: Create a new anchor in the given dataspace - operationId: createAnchor + operationId: createAnchorV2 parameters: - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: schema-set-name - in: query - description: schema-set-name - required: true - schema: - type: string - example: my-schema-set - - name: anchor-name - in: query - description: anchor-name - required: true - schema: - type: string - example: my-anchor + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: schema-set-name + in: query + description: schema-set-name + required: true + schema: + type: string + example: my-schema-set + - name: anchor-name + in: query + description: anchor-name + required: true + schema: + type: string + example: my-anchor responses: "201": - description: Created - content: - text/plain: - schema: - type: string - example: my-resource + description: Created without response body "400": description: Bad Request content: @@ -508,38 +554,40 @@ paths: status: 500 message: Internal Server Error details: Internal Server Error occurred - /v2/dataspaces/{dataspace-name}/anchors: - post: + /{apiVersion}/dataspaces/{dataspace-name}/anchors: + get: tags: - - cps-admin - summary: Create an anchor - description: Create a new anchor in the given dataspace - operationId: createAnchorV2 + - cps-admin + summary: Get anchors + description: "Read all anchors, given a dataspace" + operationId: getAnchors parameters: - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: schema-set-name - in: query - description: schema-set-name - required: true - schema: - type: string - example: my-schema-set - - name: anchor-name - in: query - description: anchor-name - required: true - schema: - type: string - example: my-anchor + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace responses: - "201": - description: Created + "200": + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/AnchorDetails' "400": description: Bad Request content: @@ -570,16 +618,6 @@ paths: status: 403 message: Request Forbidden details: This request is forbidden - "409": - 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. "500": description: Internal Server Error content: @@ -593,26 +631,35 @@ paths: /{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}: get: tags: - - cps-admin + - cps-admin summary: Get an anchor description: Read an anchor given an anchor name and a dataspace operationId: getAnchor parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: anchor-name - in: path - description: anchor-name - required: true - schema: - type: string - example: my-anchor + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: anchor-name + in: path + description: anchor-name + required: true + schema: + type: string + example: my-anchor responses: "200": description: OK @@ -662,26 +709,35 @@ paths: details: Internal Server Error occurred delete: tags: - - cps-admin + - cps-admin summary: Delete an anchor description: Delete an anchor given an anchor name and a dataspace operationId: deleteAnchor parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: anchor-name - in: path - description: anchor-name - required: true - schema: - type: string - example: my-anchor + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: anchor-name + in: path + description: anchor-name + required: true + schema: + type: string + example: my-anchor responses: "204": description: No Content @@ -729,25 +785,25 @@ paths: /v1/dataspaces/{dataspace-name}/schema-sets: post: tags: - - cps-admin + - cps-admin summary: Create a schema set description: Create a new schema set in the given dataspace operationId: createSchemaSet parameters: - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: schema-set-name - in: query - description: schema-set-name - required: true - schema: - type: string - example: my-schema-set + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: schema-set-name + in: query + description: schema-set-name + required: true + schema: + type: string + example: my-schema-set requestBody: content: multipart/form-data: @@ -812,28 +868,29 @@ paths: status: 500 message: Internal Server Error details: Internal Server Error occurred + deprecated: true /v2/dataspaces/{dataspace-name}/schema-sets: post: tags: - - cps-admin + - cps-admin summary: Create a schema set description: Create a new schema set in the given dataspace operationId: createSchemaSetV2 parameters: - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: schema-set-name - in: query - description: schema-set-name - required: true - schema: - type: string - example: my-schema-set + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: schema-set-name + in: query + description: schema-set-name + required: true + schema: + type: string + example: my-schema-set requestBody: content: multipart/form-data: @@ -842,7 +899,7 @@ paths: required: true responses: "201": - description: Created + description: Created without response body "400": description: Bad Request content: @@ -896,19 +953,28 @@ paths: /{apiVersion}/dataspaces/{dataspace-name}/schema-sets: get: tags: - - cps-admin - summary: Get schema sets for a given dataspace - description: "Read schema sets for a given dataspace" + - cps-admin + summary: Get schema sets + description: "Read all schema sets, given a dataspace" operationId: getSchemaSets parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace responses: "200": description: OK @@ -961,26 +1027,35 @@ paths: /{apiVersion}/dataspaces/{dataspace-name}/schema-sets/{schema-set-name}: get: tags: - - cps-admin + - cps-admin summary: Get a schema set description: Read a schema set given a schema set name and a dataspace operationId: getSchemaSet parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: schema-set-name - in: path - description: schema-set-name - required: true - schema: - type: string - example: my-schema-set + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: schema-set-name + in: path + description: schema-set-name + required: true + schema: + type: string + example: my-schema-set responses: "200": description: OK @@ -1030,26 +1105,35 @@ paths: details: Internal Server Error occurred delete: tags: - - cps-admin + - cps-admin summary: Delete a schema set description: Delete a schema set given a schema set name and a dataspace operationId: deleteSchemaSet parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: schema-set-name - in: path - description: schema-set-name - required: true - schema: - type: string - example: my-schema-set + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: schema-set-name + in: path + description: schema-set-name + required: true + schema: + type: string + example: my-schema-set responses: "204": description: No Content @@ -1107,47 +1191,46 @@ paths: /v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/node: get: tags: - - cps-data + - cps-data summary: Get a node description: Get a node with an option to retrieve all the children for a given anchor and dataspace - deprecated: true operationId: getNodeByDataspaceAndAnchor parameters: - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: anchor-name - in: path - description: anchor-name - required: true - schema: - type: string - example: my-anchor - - name: xpath - in: query - description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" - required: false - schema: - type: string - default: / - examples: - container xpath: - value: /shops/bookstore - list attributes xpath: - value: "/shops/bookstore/categories[@code=1]" - - name: include-descendants - in: query - description: include-descendants - required: false - schema: - type: boolean - example: false - default: false + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: anchor-name + in: path + description: anchor-name + required: true + schema: + type: string + example: my-anchor + - name: xpath + in: query + description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" + required: false + schema: + type: string + default: / + examples: + container xpath: + value: /shops/bookstore + list attributes xpath: + value: "/shops/bookstore/categories[@code=1]" + - name: include-descendants + in: query + description: include-descendants + required: false + schema: + type: boolean + example: false + default: false responses: "200": description: OK @@ -1198,51 +1281,52 @@ paths: status: 500 message: Internal Server Error details: Internal Server Error occurred + deprecated: true x-codegen-request-body-name: xpath /v2/dataspaces/{dataspace-name}/anchors/{anchor-name}/node: get: tags: - - cps-data + - cps-data summary: Get a node description: Get a node with an option to retrieve all the children for a given anchor and dataspace operationId: getNodeByDataspaceAndAnchorV2 parameters: - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: anchor-name - in: path - description: anchor-name - required: true - schema: - type: string - example: my-anchor - - name: xpath - in: query - description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" - required: false - schema: - type: string - default: / - examples: - container xpath: - value: /shops/bookstore - list attributes xpath: - value: "/shops/bookstore/categories[@code=1]" - - name: descendants - in: query - description: descendants - required: false - schema: - type: string - example: 3 - default: none - pattern: '^all$|^none$|^[0-9]+$|^-1$' + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: anchor-name + in: path + description: anchor-name + required: true + schema: + type: string + example: my-anchor + - name: xpath + in: query + description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" + required: false + schema: + type: string + default: / + examples: + container xpath: + value: /shops/bookstore + list attributes xpath: + value: "/shops/bookstore/categories[@code=1]" + - name: descendants + in: query + description: "descendents to query depth of children. allowed values are none,\ + \ all, any number starting from -1" + required: false + schema: + type: string + example: "3" + default: none responses: "200": description: OK @@ -1297,46 +1381,55 @@ paths: /{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes: put: tags: - - cps-data + - cps-data summary: Replace a node with descendants description: "Replace a node with descendants for a given dataspace, anchor\ \ and a parent node xpath" operationId: replaceNode parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: anchor-name - in: path - description: anchor-name - required: true - schema: - type: string - example: my-anchor - - name: xpath - in: query - description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" - required: false - schema: - type: string - default: / - examples: - container xpath: - value: /shops/bookstore - list attributes xpath: - value: "/shops/bookstore/categories[@code=1]" - - name: observed-timestamp - in: query - description: observed-timestamp - required: false - schema: - type: string - example: 2021-03-21T00:10:34.030-0100 + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: anchor-name + in: path + description: anchor-name + required: true + schema: + type: string + example: my-anchor + - name: xpath + in: query + description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" + required: false + schema: + type: string + default: / + examples: + container xpath: + value: /shops/bookstore + list attributes xpath: + value: "/shops/bookstore/categories[@code=1]" + - name: observed-timestamp + in: query + description: observed-timestamp + required: false + schema: + type: string + example: 2021-03-21T00:10:34.030-0100 requestBody: content: application/json: @@ -1398,53 +1491,77 @@ paths: details: Internal Server Error occurred post: tags: - - cps-data + - cps-data summary: Create a node description: Create a node for a given anchor and dataspace operationId: createNode parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: anchor-name - in: path - description: anchor-name - required: true - schema: - type: string - example: my-anchor - - name: xpath - in: query - description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" - required: false - schema: - type: string - default: / - examples: - container xpath: - value: /shops/bookstore - list attributes xpath: - value: "/shops/bookstore/categories[@code=1]" - - name: observed-timestamp - in: query - description: observed-timestamp - required: false - schema: - type: string - example: 2021-03-21T00:10:34.030-0100 + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: anchor-name + in: path + description: anchor-name + required: true + schema: + type: string + example: my-anchor + - name: xpath + in: query + description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" + required: false + schema: + type: string + default: / + examples: + container xpath: + value: /shops/bookstore + list attributes xpath: + value: "/shops/bookstore/categories[@code=1]" + - name: observed-timestamp + in: query + description: observed-timestamp + required: false + schema: + type: string + example: 2021-03-21T00:10:34.030-0100 + - name: Content-Type + in: header + description: Content type header + required: true + schema: + type: string + example: application/json requestBody: content: application/json: schema: - type: object + type: string examples: dataSample: $ref: '#/components/examples/dataSample' + application/xml: + schema: + type: object + xml: + name: stores + examples: + dataSample: + $ref: '#/components/examples/dataSampleXml' required: true responses: "201": @@ -1506,46 +1623,55 @@ paths: details: Internal Server Error occurred delete: tags: - - cps-data + - cps-data summary: Delete a data node description: Delete a datanode for a given dataspace and anchor given a node xpath. operationId: deleteDataNode parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: anchor-name - in: path - description: anchor-name - required: true - schema: - type: string - example: my-anchor - - name: xpath - in: query - description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" - required: false - schema: - type: string - default: / - examples: - container xpath: - value: /shops/bookstore - list attributes xpath: - value: "/shops/bookstore/categories[@code=1]" - - name: observed-timestamp - in: query - description: observed-timestamp - required: false - schema: - type: string - example: 2021-03-21T00:10:34.030-0100 + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: anchor-name + in: path + description: anchor-name + required: true + schema: + type: string + example: my-anchor + - name: xpath + in: query + description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" + required: false + schema: + type: string + default: / + examples: + container xpath: + value: /shops/bookstore + list attributes xpath: + value: "/shops/bookstore/categories[@code=1]" + - name: observed-timestamp + in: query + description: observed-timestamp + required: false + schema: + type: string + example: 2021-03-21T00:10:34.030-0100 responses: "204": description: No Content @@ -1592,46 +1718,55 @@ paths: details: Internal Server Error occurred patch: tags: - - cps-data + - cps-data summary: Update node leaves description: Update a data node leaves for a given dataspace and anchor and a parent node xpath operationId: updateNodeLeaves parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: anchor-name - in: path - description: anchor-name - required: true - schema: - type: string - example: my-anchor - - name: xpath - in: query - description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" - required: false - schema: - type: string - default: / - examples: - container xpath: - value: /shops/bookstore - list attributes xpath: - value: "/shops/bookstore/categories[@code=1]" - - name: observed-timestamp - in: query - description: observed-timestamp - required: false - schema: - type: string - example: 2021-03-21T00:10:34.030-0100 + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: anchor-name + in: path + description: anchor-name + required: true + schema: + type: string + example: my-anchor + - name: xpath + in: query + description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" + required: false + schema: + type: string + default: / + examples: + container xpath: + value: /shops/bookstore + list attributes xpath: + value: "/shops/bookstore/categories[@code=1]" + - name: observed-timestamp + in: query + description: observed-timestamp + required: false + schema: + type: string + example: 2021-03-21T00:10:34.030-0100 requestBody: content: application/json: @@ -1691,66 +1826,50 @@ paths: status: 500 message: Internal Server Error details: Internal Server Error occurred - /{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/list-nodes: - put: + /v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/list-nodes: + delete: tags: - - cps-data - summary: Replace list content - description: "Replace list content under a given parent, anchor and dataspace" - operationId: replaceListContent + - cps-data + summary: Delete one or all list element(s) + description: Delete one or all list element(s) for a given anchor and dataspace + operationId: deleteListOrListElement parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: anchor-name - in: path - description: anchor-name - required: true - schema: - type: string - example: my-anchor - - name: xpath - in: query - description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" - required: true - schema: - type: string - examples: - container xpath: - value: /shops/bookstore - list attributes xpath: - value: "/shops/bookstore/categories[@code=1]" - - name: observed-timestamp - in: query - description: observed-timestamp - required: false - schema: - type: string - example: 2021-03-21T00:10:34.030-0100 - requestBody: - content: - application/json: - schema: - type: object - examples: - dataSample: - $ref: '#/components/examples/dataSample' - required: true + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: anchor-name + in: path + description: anchor-name + required: true + schema: + type: string + example: my-anchor + - name: xpath + in: query + description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" + required: true + schema: + type: string + examples: + container xpath: + value: /shops/bookstore + list attributes xpath: + value: "/shops/bookstore/categories[@code=1]" + - name: observed-timestamp + in: query + description: observed-timestamp + required: false + schema: + type: string + example: 2021-03-21T00:10:34.030-0100 responses: - "200": - description: OK - content: - application/json: - schema: - type: object - examples: - dataSample: - value: "" + "204": + description: No Content + content: {} "400": description: Bad Request content: @@ -1791,46 +1910,57 @@ paths: status: 500 message: Internal Server Error details: Internal Server Error occurred - post: + deprecated: true + /{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/list-nodes: + put: tags: - - cps-data - summary: Add list element(s) - description: Add list element(s) to a list for a given anchor and dataspace - operationId: addListElements + - cps-data + summary: Replace list content + description: "Replace list content under a given parent, anchor and dataspace" + operationId: replaceListContent parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: anchor-name - in: path - description: anchor-name - required: true - schema: - type: string - example: my-anchor - - name: xpath - in: query - description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" - required: true - schema: - type: string - examples: - container xpath: - value: /shops/bookstore - list attributes xpath: - value: "/shops/bookstore/categories[@code=1]" - - name: observed-timestamp - in: query - description: observed-timestamp - required: false - schema: - type: string - example: 2021-03-21T00:10:34.030-0100 + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: anchor-name + in: path + description: anchor-name + required: true + schema: + type: string + example: my-anchor + - name: xpath + in: query + description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" + required: true + schema: + type: string + examples: + container xpath: + value: /shops/bookstore + list attributes xpath: + value: "/shops/bookstore/categories[@code=1]" + - name: observed-timestamp + in: query + description: observed-timestamp + required: false + schema: + type: string + example: 2021-03-21T00:10:34.030-0100 requestBody: content: application/json: @@ -1841,13 +1971,15 @@ paths: $ref: '#/components/examples/dataSample' required: true responses: - "201": - description: Created + "200": + description: OK content: - text/plain: + application/json: schema: - type: string - example: my-resource + type: object + examples: + dataSample: + value: "" "400": description: Bad Request content: @@ -1888,50 +2020,72 @@ paths: status: 500 message: Internal Server Error details: Internal Server Error occurred - delete: + post: tags: - - cps-data - summary: Delete one or all list element(s) - description: Delete one or all list element(s) for a given anchor and dataspace - operationId: deleteListOrListElement + - cps-data + summary: Add list element(s) + description: Add list element(s) to a list for a given anchor and dataspace + operationId: addListElements parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: anchor-name - in: path - description: anchor-name - required: true - schema: - type: string - example: my-anchor - - name: xpath - in: query - description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" + - name: apiVersion + in: path + description: apiVersion + required: true + schema: + type: string + default: v2 + enum: + - v1 + - v2 + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: anchor-name + in: path + description: anchor-name + required: true + schema: + type: string + example: my-anchor + - name: xpath + in: query + description: "For more details on xpath, please refer https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html" + required: true + schema: + type: string + examples: + container xpath: + value: /shops/bookstore + list attributes xpath: + value: "/shops/bookstore/categories[@code=1]" + - name: observed-timestamp + in: query + description: observed-timestamp + required: false + schema: + type: string + example: 2021-03-21T00:10:34.030-0100 + requestBody: + content: + application/json: + schema: + type: object + examples: + dataSample: + $ref: '#/components/examples/dataSample' required: true - schema: - type: string - examples: - container xpath: - value: /shops/bookstore - list attributes xpath: - value: "/shops/bookstore/categories[@code=1]" - - name: observed-timestamp - in: query - description: observed-timestamp - required: false - schema: - type: string - example: 2021-03-21T00:10:34.030-0100 responses: - "204": - description: No Content - content: {} + "201": + description: Created + content: + text/plain: + schema: + type: string + example: my-resource "400": description: Bad Request content: @@ -1972,50 +2126,48 @@ paths: status: 500 message: Internal Server Error details: Internal Server Error occurred - deprecated: true - /{apiVersion}/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes/query: + /v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes/query: get: tags: - - cps-query + - cps-query summary: Query data nodes description: Query data nodes for the given dataspace and anchor using CPS path operationId: getNodesByDataspaceAndAnchorAndCpsPath parameters: - - $ref: '#/components/parameters/apiVersionInPath' - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: anchor-name - in: path - description: anchor-name - required: true - schema: - type: string - example: my-anchor - - 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]" - - name: include-descendants - in: query - description: include-descendants - required: false - schema: - type: boolean - example: false - default: false + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: anchor-name + in: path + description: anchor-name + required: true + schema: + type: string + example: my-anchor + - 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]" + - name: include-descendants + in: query + description: include-descendants + required: false + schema: + type: boolean + example: false + default: false responses: "200": description: OK @@ -2066,51 +2218,51 @@ paths: status: 500 message: Internal Server Error details: Internal Server Error occurred + deprecated: true x-codegen-request-body-name: xpath /v2/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes/query: get: tags: - - cps-query + - cps-query summary: Query data nodes description: Query data nodes for the given dataspace and anchor using CPS path operationId: getNodesByDataspaceAndAnchorAndCpsPathV2 parameters: - - name: dataspace-name - in: path - description: dataspace-name - required: true - schema: - type: string - example: my-dataspace - - name: anchor-name - in: path - description: anchor-name - required: true - schema: - type: string - example: my-anchor - - 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]" - - name: descendants - in: query - description: descendants - required: false - schema: - type: string - pattern: '^all$|^none$|^[0-9]+$|^-1$' - example: false - default: none - example: 3 + - name: dataspace-name + in: path + description: dataspace-name + required: true + schema: + type: string + example: my-dataspace + - name: anchor-name + in: path + description: anchor-name + required: true + schema: + type: string + example: my-anchor + - 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]" + - name: descendants + in: query + description: "descendents to query depth of children. allowed values are none,\ + \ all, any number starting from -1" + required: false + schema: + type: string + example: "3" + default: none responses: "200": description: OK @@ -2163,20 +2315,6 @@ paths: details: Internal Server Error occurred x-codegen-request-body-name: xpath components: - parameters: - apiVersionInPath: - name: apiVersion - in: path - description: apiVersion - required: true - schema: - type: string - enum: [v1, v2] - default: v2 - securitySchemes: - basicAuth: - type: http - scheme: basic schemas: ErrorMessage: title: Error @@ -2188,6 +2326,13 @@ components: type: string details: type: string + DataspaceDetails: + title: Dataspace details by dataspace Name + type: object + properties: + name: + type: string + example: my-dataspace AnchorDetails: title: Anchor details by anchor Name type: object @@ -2201,16 +2346,9 @@ components: schemaSetName: type: string example: my-schema-set - DataspaceDetails: - title: Dataspace details by dataspace Name - type: object - properties: - name: - type: string - example: my-dataspace MultipartFile: required: - - file + - file type: object properties: file: @@ -2220,7 +2358,7 @@ components: SchemaSetDetails: title: Schema set details by dataspace and schemasetName required: - - moduleReferences + - moduleReferences type: object properties: dataspaceName: @@ -2252,10 +2390,15 @@ components: test:bookstore: bookstore-name: Chapters categories: - - code: 1 - name: SciFi - - code: 2 - name: kids - -security: - - basicAuth: [] + - code: 1 + name: SciFi + - code: 2 + 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> + </categories> </bookstore> </stores> + securitySchemes: + basicAuth: + type: http + scheme: basic diff --git a/docs/api/swagger/ncmp/openapi-inventory.yaml b/docs/api/swagger/ncmp/openapi-inventory.yaml index 9e84f3a19..3bf93a1e5 100644 --- a/docs/api/swagger/ncmp/openapi-inventory.yaml +++ b/docs/api/swagger/ncmp/openapi-inventory.yaml @@ -4,12 +4,14 @@ info: description: NCMP Inventory API version: "1.0" servers: -- url: /ncmpInventory + - url: /ncmpInventory +security: + - basicAuth: [] paths: /v1/ch: post: tags: - - network-cm-proxy-inventory + - network-cm-proxy-inventory summary: DMI notifies NCMP of new CM Handles description: "Register a DMI Plugin with any new, updated or removed CM Handles." operationId: updateDmiPluginRegistration @@ -63,51 +65,104 @@ paths: $ref: '#/components/schemas/DmiPluginRegistrationErrorResponse' example: failedCreatedCmHandles: - - cmHandle: my-cm-handle-01 - errorCode: "00" - errorText: Unknown error. <error-details> - - cmHandle: my-cm-handle-02 - errorCode: "01" - errorText: cm-handle already exists - - cmHandle: my-cm-handle-03 - errorCode: "03" - errorText: cm-handle has an invalid character(s) in id + - cmHandle: my-cm-handle-01 + errorCode: "00" + errorText: Unknown error. <error-details> + - cmHandle: my-cm-handle-02 + errorCode: "01" + errorText: cm-handle already exists + - cmHandle: my-cm-handle-03 + errorCode: "03" + errorText: cm-handle has an invalid character(s) in id failedUpdatedCmHandles: - - cmHandle: my-cm-handle-01 - errorCode: "00" - errorText: Unknown error. <error-details> - - cmHandle: my-cm-handle-02 - errorCode: "02" - errorText: cm-handle does not exist - - cmHandle: my-cm-handle-03 - errorCode: "03" - errorText: cm-handle has an invalid character(s) in id + - cmHandle: my-cm-handle-01 + errorCode: "00" + errorText: Unknown error. <error-details> + - cmHandle: my-cm-handle-02 + errorCode: "02" + errorText: cm-handle does not exist + - cmHandle: my-cm-handle-03 + errorCode: "03" + errorText: cm-handle has an invalid character(s) in id failedRemovedCmHandles: - - cmHandle: my-cm-handle-01 - errorCode: "00" - errorText: Unknown error. <error-details> - - cmHandle: my-cm-handle-02 - errorCode: "02" - errorText: cm-handle does not exists - - cmHandle: my-cm-handle-03 - errorCode: "03" - errorText: cm-handle has an invalid character(s) in id + - cmHandle: my-cm-handle-01 + errorCode: "00" + errorText: Unknown error. <error-details> + - cmHandle: my-cm-handle-02 + errorCode: "02" + errorText: cm-handle does not exists + - cmHandle: my-cm-handle-03 + errorCode: "03" + errorText: cm-handle has an invalid character(s) in id /v1/ch/cmHandles: get: tags: - - network-cm-proxy-inventory + - network-cm-proxy-inventory summary: "Get all cm handle IDs for a registered DMI plugin (DMI plugin, DMI\ \ data plugin, DMI model plugin)" description: Get all cm handle IDs for a registered DMI plugin operationId: getAllCmHandleIdsForRegisteredDmi parameters: - - name: dmi-plugin-identifier - in: query - description: dmi-plugin-identifier + - name: dmi-plugin-identifier + in: query + description: dmi-plugin-identifier + required: true + schema: + type: string + example: my-dmi-plugin + responses: + "200": + description: OK + content: + application/json: + schema: + type: array + items: + type: string + "401": + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMessage' + example: + status: 401 + message: Unauthorized error message + details: Unauthorized error details + "403": + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMessage' + example: + status: 403 + message: Forbidden error message + details: Forbidden error details + "500": + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMessage' + example: + status: 500 + message: Internal Server Error + details: Internal Server Error occurred + /v1/ch/searches: + post: + tags: + - network-cm-proxy-inventory + summary: Query for CM Handle IDs + description: "Query and get CMHandleIds for additional properties, public properties\ + \ and registered DMI plugin (DMI plugin, DMI data plugin, DMI model plugin)." + operationId: searchCmHandleIds + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CmHandleQueryParameters' required: true - schema: - type: string - example: my-dmi-plugin responses: "200": description: OK @@ -148,10 +203,6 @@ paths: message: Internal Server Error details: Internal Server Error occurred components: - securitySchemes: - basicAuth: - type: http - scheme: basic schemas: RestDmiPluginRegistration: type: object @@ -179,14 +230,14 @@ components: removedCmHandles: type: array example: - - my-cm-handle1 - - my-cm-handle2 - - my-cm-handle3 + - my-cm-handle1 + - my-cm-handle2 + - my-cm-handle3 items: type: string RestInputCmHandle: required: - - cmHandle + - cmHandle type: object properties: cmHandle: @@ -238,6 +289,45 @@ components: errorText: type: string example: Unknown error. <error-details> - -security: - - basicAuth: []
\ No newline at end of file + CmHandleQueryParameters: + title: Cm Handle query parameters for executing cm handle search + type: object + properties: + cmHandleQueryParameters: + type: array + items: + $ref: '#/components/schemas/ConditionProperties' + conditions: + type: array + description: "not necessary, it is just for backward compatibility" + deprecated: true + items: + $ref: '#/components/schemas/OldConditionProperties' + ConditionProperties: + properties: + conditionName: + type: string + conditionParameters: + type: array + items: + type: object + additionalProperties: + type: string + OldConditionProperties: + properties: + name: + type: string + conditionParameters: + type: array + items: + $ref: '#/components/schemas/ModuleNameAsJsonObject' + deprecated: true + ModuleNameAsJsonObject: + properties: + moduleName: + type: string + example: my-module + securitySchemes: + basicAuth: + type: http + scheme: basic diff --git a/docs/api/swagger/ncmp/openapi.yaml b/docs/api/swagger/ncmp/openapi.yaml index 44c4788cf..18839664a 100644 --- a/docs/api/swagger/ncmp/openapi.yaml +++ b/docs/api/swagger/ncmp/openapi.yaml @@ -4,87 +4,89 @@ info: description: NCMP to CPS Proxy API version: "1.0" servers: -- url: /ncmp + - url: /ncmp +security: + - basicAuth: [] paths: /v1/ch/{cm-handle}/data/ds/{datastore-name}: get: tags: - - network-cm-proxy + - network-cm-proxy summary: Get resource data for cm handle description: Get resource data for given cm handle operationId: getResourceDataForCmHandle parameters: - - name: datastore-name - in: path - description: The type of the requested data - required: true - schema: - type: string - example: ncmp-datastore:operational - - name: cm-handle - in: path - description: "The identifier for a network function, network element, subnetwork\ + - name: datastore-name + in: path + description: The type of the requested data + required: true + schema: + type: string + example: ncmp-datastore:operational + - name: cm-handle + in: path + description: "The identifier for a network function, network element, subnetwork\ \ or any other cm object by managed Network CM Proxy" - required: true - schema: - type: string - example: my-cm-handle - - name: resourceIdentifier - in: query - description: The format of resource identifier depend on the associated DMI - Plugin implementation. For ONAP DMI Plugin it will be RESTConf paths but - it can really be anything. - required: true - allowReserved: true - schema: - type: string - examples: - sample 1: - value: - resourceIdentifier: \shops\bookstore - sample 2: - value: - resourceIdentifier: "\\shops\\bookstore\\categories[@code=1]" - sample 3: - value: - resourceIdentifier: "parent=shops,child=bookstore" - - name: options - in: query - description: "options parameter in query, it is mandatory to wrap key(s)=value(s)\ + required: true + schema: + type: string + example: my-cm-handle + - name: resourceIdentifier + in: query + description: The format of resource identifier depend on the associated DMI + Plugin implementation. For ONAP DMI Plugin it will be RESTConf paths but + it can really be anything. + required: true + allowReserved: true + schema: + type: string + examples: + sample 1: + value: + resourceIdentifier: \shops\bookstore + sample 2: + value: + resourceIdentifier: "\\shops\\bookstore\\categories[@code=1]" + sample 3: + value: + resourceIdentifier: "parent=shops,child=bookstore" + - name: options + in: query + description: "options parameter in query, it is mandatory to wrap key(s)=value(s)\ \ in parenthesis'()'. The format of options parameter depend on the associated\ \ DMI Plugin implementation." - required: false - allowReserved: true - schema: - type: string - examples: - sample 1: - value: - options: (depth=3) - sample 2: - value: - options: (fields=book) - sample 3: - value: - options: "(depth=2,fields=book/authors)" - - name: topic - in: query - description: topic parameter in query. - required: false - allowReserved: true - schema: - type: string - examples: - sample 1: - value: - topic: my-topic-name - - name: include-descendants - in: query - description: Determines if descendants are included in response - required: false - schema: - type: boolean - default: false + required: false + allowReserved: true + schema: + type: string + examples: + sample 1: + value: + options: (depth=3) + sample 2: + value: + options: (fields=book) + sample 3: + value: + options: "(depth=2,fields=book/authors)" + - name: topic + in: query + description: topic parameter in query. + required: false + allowReserved: true + schema: + type: string + examples: + sample 1: + value: + topic: my-topic-name + - name: include-descendants + in: query + description: Determines if descendants are included in response + required: false + schema: + type: boolean + default: false responses: "200": description: OK @@ -148,55 +150,55 @@ paths: body: Bad Request put: tags: - - network-cm-proxy + - network-cm-proxy summary: Update resource data from pass-through running for a cm handle description: Update resource data from pass-through running for the given cm handle operationId: updateResourceDataRunningForCmHandle parameters: - - name: datastore-name - in: path - description: The type of the requested data - required: true - schema: - type: string - example: ncmp-datastore:operational - - name: cm-handle - in: path - description: "The identifier for a network function, network element, subnetwork\ + - name: datastore-name + in: path + description: The type of the requested data + required: true + schema: + type: string + example: ncmp-datastore:operational + - name: cm-handle + in: path + description: "The identifier for a network function, network element, subnetwork\ \ or any other cm object by managed Network CM Proxy" - required: true - schema: - type: string - example: my-cm-handle - - name: resourceIdentifier - in: query - description: The format of resource identifier depend on the associated DMI - Plugin implementation. For ONAP DMI Plugin it will be RESTConf paths but - it can really be anything. - required: true - allowReserved: true - schema: - type: string - examples: - sample 1: - value: - resourceIdentifier: \shops\bookstore - sample 2: - value: - resourceIdentifier: "\\shops\\bookstore\\categories[@code=1]" - sample 3: - value: - resourceIdentifier: "parent=shops,child=bookstore" - - name: Content-Type - in: header - description: "Content parameter for request, if content parameter is null,\ + required: true + schema: + type: string + example: my-cm-handle + - name: resourceIdentifier + in: query + description: The format of resource identifier depend on the associated DMI + Plugin implementation. For ONAP DMI Plugin it will be RESTConf paths but + it can really be anything. + required: true + allowReserved: true + schema: + type: string + examples: + sample 1: + value: + resourceIdentifier: \shops\bookstore + sample 2: + value: + resourceIdentifier: "\\shops\\bookstore\\categories[@code=1]" + sample 3: + value: + resourceIdentifier: "parent=shops,child=bookstore" + - name: Content-Type + in: header + description: "Content parameter for request, if content parameter is null,\ \ default value is application/json." - required: false - schema: - type: string - example: application/yang-data+json - default: application/json + required: false + schema: + type: string + example: application/yang-data+json + default: application/json requestBody: content: application/json: @@ -272,54 +274,54 @@ paths: body: Bad Request post: tags: - - network-cm-proxy + - network-cm-proxy summary: create resource data from pass-through running for cm handle description: create resource data from pass-through running for given cm handle operationId: createResourceDataRunningForCmHandle parameters: - - name: datastore-name - in: path - description: The type of the requested data - required: true - schema: - type: string - example: ncmp-datastore:operational - - name: cm-handle - in: path - description: "The identifier for a network function, network element, subnetwork\ + - name: datastore-name + in: path + description: The type of the requested data + required: true + schema: + type: string + example: ncmp-datastore:operational + - name: cm-handle + in: path + description: "The identifier for a network function, network element, subnetwork\ \ or any other cm object by managed Network CM Proxy" - required: true - schema: - type: string - example: my-cm-handle - - name: resourceIdentifier - in: query - description: The format of resource identifier depend on the associated DMI - Plugin implementation. For ONAP DMI Plugin it will be RESTConf paths but - it can really be anything. - required: true - allowReserved: true - schema: - type: string - examples: - sample 1: - value: - resourceIdentifier: \shops\bookstore - sample 2: - value: - resourceIdentifier: "\\shops\\bookstore\\categories[@code=1]" - sample 3: - value: - resourceIdentifier: "parent=shops,child=bookstore" - - name: Content-Type - in: header - description: "Content parameter for request, if content parameter is null,\ + required: true + schema: + type: string + example: my-cm-handle + - name: resourceIdentifier + in: query + description: The format of resource identifier depend on the associated DMI + Plugin implementation. For ONAP DMI Plugin it will be RESTConf paths but + it can really be anything. + required: true + allowReserved: true + schema: + type: string + examples: + sample 1: + value: + resourceIdentifier: \shops\bookstore + sample 2: + value: + resourceIdentifier: "\\shops\\bookstore\\categories[@code=1]" + sample 3: + value: + resourceIdentifier: "parent=shops,child=bookstore" + - name: Content-Type + in: header + description: "Content parameter for request, if content parameter is null,\ \ default value is application/json." - required: false - schema: - type: string - example: application/yang-data+json - default: application/json + required: false + schema: + type: string + example: application/yang-data+json + default: application/json requestBody: content: application/json: @@ -392,54 +394,54 @@ paths: body: Bad Request delete: tags: - - network-cm-proxy + - network-cm-proxy summary: Delete resource data description: Delete resource data from pass-through running for a given cm handle operationId: deleteResourceDataRunningForCmHandle parameters: - - name: datastore-name - in: path - description: The type of the requested data - required: true - schema: - type: string - example: ncmp-datastore:operational - - name: cm-handle - in: path - description: "The identifier for a network function, network element, subnetwork\ + - name: datastore-name + in: path + description: The type of the requested data + required: true + schema: + type: string + example: ncmp-datastore:operational + - name: cm-handle + in: path + description: "The identifier for a network function, network element, subnetwork\ \ or any other cm object by managed Network CM Proxy" - required: true - schema: - type: string - example: my-cm-handle - - name: resourceIdentifier - in: query - description: The format of resource identifier depend on the associated DMI - Plugin implementation. For ONAP DMI Plugin it will be RESTConf paths but - it can really be anything. - required: true - allowReserved: true - schema: - type: string - examples: - sample 1: - value: - resourceIdentifier: \shops\bookstore - sample 2: - value: - resourceIdentifier: "\\shops\\bookstore\\categories[@code=1]" - sample 3: - value: - resourceIdentifier: "parent=shops,child=bookstore" - - name: Content-Type - in: header - description: "Content parameter for request, if content parameter is null,\ + required: true + schema: + type: string + example: my-cm-handle + - name: resourceIdentifier + in: query + description: The format of resource identifier depend on the associated DMI + Plugin implementation. For ONAP DMI Plugin it will be RESTConf paths but + it can really be anything. + required: true + allowReserved: true + schema: + type: string + examples: + sample 1: + value: + resourceIdentifier: \shops\bookstore + sample 2: + value: + resourceIdentifier: "\\shops\\bookstore\\categories[@code=1]" + sample 3: + value: + resourceIdentifier: "parent=shops,child=bookstore" + - name: Content-Type + in: header + description: "Content parameter for request, if content parameter is null,\ \ default value is application/json." - required: false - schema: - type: string - example: application/yang-data+json - default: application/json + required: false + schema: + type: string + example: application/yang-data+json + default: application/json responses: "204": description: No Content @@ -507,55 +509,55 @@ paths: body: Bad Request patch: tags: - - network-cm-proxy + - network-cm-proxy summary: Patch resource data from pass-through running description: Patch resource data from pass-through running for the given cm handle operationId: patchResourceDataRunningForCmHandle parameters: - - name: datastore-name - in: path - description: The type of the requested data - required: true - schema: - type: string - example: ncmp-datastore:operational - - name: cm-handle - in: path - description: "The identifier for a network function, network element, subnetwork\ + - name: datastore-name + in: path + description: The type of the requested data + required: true + schema: + type: string + example: ncmp-datastore:operational + - name: cm-handle + in: path + description: "The identifier for a network function, network element, subnetwork\ \ or any other cm object by managed Network CM Proxy" - required: true - schema: - type: string - example: my-cm-handle - - name: resourceIdentifier - in: query - description: The format of resource identifier depend on the associated DMI - Plugin implementation. For ONAP DMI Plugin it will be RESTConf paths but - it can really be anything. - required: true - allowReserved: true - schema: - type: string - examples: - sample 1: - value: - resourceIdentifier: \shops\bookstore - sample 2: - value: - resourceIdentifier: "\\shops\\bookstore\\categories[@code=1]" - sample 3: - value: - resourceIdentifier: "parent=shops,child=bookstore" - - name: Content-Type - in: header - description: "Content parameter for request, if content parameter is null,\ + required: true + schema: + type: string + example: my-cm-handle + - name: resourceIdentifier + in: query + description: The format of resource identifier depend on the associated DMI + Plugin implementation. For ONAP DMI Plugin it will be RESTConf paths but + it can really be anything. + required: true + allowReserved: true + schema: + type: string + examples: + sample 1: + value: + resourceIdentifier: \shops\bookstore + sample 2: + value: + resourceIdentifier: "\\shops\\bookstore\\categories[@code=1]" + sample 3: + value: + resourceIdentifier: "parent=shops,child=bookstore" + - name: Content-Type + in: header + description: "Content parameter for request, if content parameter is null,\ \ default value is application/json." - required: false - schema: - type: string - example: application/yang-data+json - default: application/json + required: false + schema: + type: string + example: application/yang-data+json + default: application/json requestBody: content: '*/*': @@ -623,23 +625,156 @@ paths: dmi-response: http-code: 400 body: Bad Request + /v1/ch/{cm-handle}/data/ds/{datastore-name}/query: + get: + tags: + - network-cm-proxy + summary: Query resource data for a given cm handle + description: Query resource data for a given cm handle + operationId: queryResourceDataForCmHandle + parameters: + - name: datastore-name + in: path + description: The type of the requested data + required: true + schema: + type: string + example: ncmp-datastore:operational + - name: cm-handle + in: path + description: "The identifier for a network function, network element, subnetwork\ + \ or any other cm object by managed Network CM Proxy" + required: true + schema: + type: string + example: my-cm-handle + - 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]" + - name: options + in: query + description: "options parameter in query, it is mandatory to wrap key(s)=value(s)\ + \ in parenthesis'()'. The format of options parameter depend on the associated\ + \ DMI Plugin implementation." + required: false + allowReserved: true + schema: + type: string + examples: + sample 1: + value: + options: (depth=3) + sample 2: + value: + options: (fields=book) + sample 3: + value: + options: "(depth=2,fields=book/authors)" + - name: topic + in: query + description: topic parameter in query. + required: false + allowReserved: true + schema: + type: string + examples: + sample 1: + value: + topic: my-topic-name + - name: include-descendants + in: query + description: Determines if descendants are included in response + required: false + schema: + type: boolean + default: false + responses: + "200": + description: OK + content: + application/json: + schema: + type: object + examples: + dataSampleResponse: + $ref: '#/components/examples/dataSampleResponse' + "400": + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMessage' + example: + status: 400 BAD_REQUEST + message: Bad request error message + details: Bad request error details + "401": + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMessage' + example: + status: 401 + message: Unauthorized error message + details: Unauthorized error details + "403": + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMessage' + example: + status: 403 + message: Forbidden error message + details: Forbidden error details + "500": + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMessage' + example: + status: 500 + message: Internal Server Error + details: Internal Server Error occurred + "502": + description: Bad Gateway + content: + application/json: + schema: + $ref: '#/components/schemas/DmiErrorMessage' + example: + message: Bad Gateway Error Message NCMP + dmi-response: + http-code: 400 + body: Bad Request /v1/ch/{cm-handle}/modules: get: tags: - - network-cm-proxy + - network-cm-proxy summary: Fetch all module references (name and revision) for a given cm handle description: fetch all module references (name and revision) for a given cm handle operationId: getModuleReferencesByCmHandle parameters: - - name: cm-handle - in: path - description: "The identifier for a network function, network element, subnetwork\ + - name: cm-handle + in: path + description: "The identifier for a network function, network element, subnetwork\ \ or any other cm object by managed Network CM Proxy" - required: true - schema: - type: string - example: my-cm-handle + required: true + schema: + type: string + example: my-cm-handle responses: "200": description: OK @@ -692,21 +827,21 @@ paths: /v1/ch/{cm-handle}/modules/definitions: get: tags: - - network-cm-proxy + - network-cm-proxy summary: "Fetch all module definitions (name, revision, yang resource) for a\ \ given cm handle" description: "Fetch all module definitions (name, revision, yang resource) for\ \ a given cm handle" operationId: getModuleDefinitionsByCmHandleId parameters: - - name: cm-handle - in: path - description: "The identifier for a network function, network element, subnetwork\ + - name: cm-handle + in: path + description: "The identifier for a network function, network element, subnetwork\ \ or any other cm object by managed Network CM Proxy" - required: true - schema: - type: string - example: my-cm-handle + required: true + schema: + type: string + example: my-cm-handle responses: "200": description: OK @@ -749,7 +884,7 @@ paths: /v1/ch/searches: post: tags: - - network-cm-proxy + - network-cm-proxy summary: Execute cm handle search using the available conditions description: Execute cm handle query search and return a list of cm handle details. Any number of conditions can be applied. To be included in the result a cm-handle @@ -831,19 +966,19 @@ paths: /v1/ch/{cm-handle}: get: tags: - - network-cm-proxy + - network-cm-proxy summary: Retrieve CM handle details description: Retrieve CM handle details and properties by cm handle id operationId: retrieveCmHandleDetailsById parameters: - - name: cm-handle - in: path - description: "The identifier for a network function, network element, subnetwork\ + - name: cm-handle + in: path + description: "The identifier for a network function, network element, subnetwork\ \ or any other cm object by managed Network CM Proxy" - required: true - schema: - type: string - example: my-cm-handle + required: true + schema: + type: string + example: my-cm-handle responses: "200": description: OK @@ -894,19 +1029,19 @@ paths: /v1/ch/{cm-handle}/properties: get: tags: - - network-cm-proxy + - network-cm-proxy summary: Get CM handle properties description: Get CM handle properties by cm handle id operationId: getCmHandlePublicPropertiesByCmHandleId parameters: - - name: cm-handle - in: path - description: "The identifier for a network function, network element, subnetwork\ + - name: cm-handle + in: path + description: "The identifier for a network function, network element, subnetwork\ \ or any other cm object by managed Network CM Proxy" - required: true - schema: - type: string - example: my-cm-handle + required: true + schema: + type: string + example: my-cm-handle responses: "200": description: OK @@ -957,7 +1092,7 @@ paths: /v1/ch/id-searches: post: tags: - - network-cm-proxy + - network-cm-proxy summary: Execute cm handle query upon a given set of query parameters description: Execute cm handle query search and return a list of cm handle ids. Any number of conditions can be applied. To be included in the result a cm-handle @@ -1049,19 +1184,19 @@ paths: /v1/ch/{cm-handle}/state: get: tags: - - network-cm-proxy + - network-cm-proxy summary: Get CM handle state description: Get CM handle state by cm handle id operationId: getCmHandleStateByCmHandleId parameters: - - name: cm-handle - in: path - description: "The identifier for a network function, network element, subnetwork\ + - name: cm-handle + in: path + description: "The identifier for a network function, network element, subnetwork\ \ or any other cm object by managed Network CM Proxy" - required: true - schema: - type: string - example: my-cm-handle + required: true + schema: + type: string + example: my-cm-handle responses: "200": description: OK @@ -1112,28 +1247,28 @@ paths: /v1/ch/{cm-handle}/data-sync: put: tags: - - network-cm-proxy + - 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: - - name: cm-handle - in: path - description: "The identifier for a network function, network element, subnetwork\ + - name: cm-handle + in: path + description: "The identifier for a network function, network element, subnetwork\ \ or any other cm object by managed Network CM Proxy" - required: true - schema: - type: string - example: my-cm-handle - - name: dataSyncEnabled - in: query - description: Is used to enable or disable the data synchronization flag - required: true - schema: - type: boolean - example: true + required: true + schema: + type: string + example: my-cm-handle + - name: dataSyncEnabled + in: query + description: Is used to enable or disable the data synchronization flag + required: true + schema: + type: boolean + example: true responses: "200": description: OK @@ -1193,10 +1328,6 @@ paths: http-code: 400 body: Bad Request components: - securitySchemes: - basicAuth: - type: http - scheme: basic schemas: ErrorMessage: title: Error @@ -1365,17 +1496,17 @@ components: value: bookstore: categories: - - code: "01" - books: - - authors: - - Iain M. Banks - - Ursula K. Le Guin - name: SciFi - - code: "02" - books: - - authors: - - Philip Pullman - name: kids + - code: "01" + books: + - authors: + - Iain M. Banks + - Ursula K. Le Guin + name: SciFi + - code: "02" + books: + - authors: + - Philip Pullman + name: kids dataSampleRequest: summary: Sample request description: Sample request body @@ -1383,17 +1514,17 @@ components: test:bookstore: bookstore-name: Chapters categories: - - code: "01" - name: SciFi - books: - - authors: - - Iain M. Banks - - Ursula K. Le Guin - - code: "02" - name: kids - books: - - authors: - - Philip Pullman + - code: "01" + name: SciFi + books: + - authors: + - Iain M. Banks + - Ursula K. Le Guin + - code: "02" + name: kids + books: + - authors: + - Philip Pullman dataSamplePatchRequest: summary: Sample patch request description: Sample patch request body @@ -1401,86 +1532,87 @@ components: ietf-restconf:yang-patch: patch-id: patch-1 edit: - - edit-id: edit1 - operation: merge - target: / - value: - test:bookstore: - bookstore-name: Chapters - categories: - - code: "01" - name: Science - books: - - authors: - - Author1 - - Author2 - - code: "02" - name: Arts - books: - - authors: - - Author3 - - edit-id: edit2 - operation: merge - target: / - value: - test:bookstore: - bookstore-name: Novels - categories: - - code: "03" - name: History - books: - - authors: - - Iain M. Banks - - Ursula K. Le Guin - - code: "04" - name: Fiction - books: - - authors: - - Philip Pullman + - edit-id: edit1 + operation: merge + target: / + value: + test:bookstore: + bookstore-name: Chapters + categories: + - code: "01" + name: Science + books: + - authors: + - Author1 + - Author2 + - code: "02" + name: Arts + books: + - authors: + - Author3 + - edit-id: edit2 + operation: merge + target: / + value: + test:bookstore: + bookstore-name: Novels + categories: + - code: "03" + name: History + books: + - authors: + - Iain M. Banks + - Ursula K. Le Guin + - code: "04" + name: Fiction + books: + - authors: + - Philip Pullman pubPropCmHandleQueryParameters: value: cmHandleQueryParameters: - - conditionName: hasAllProperties - conditionParameters: - - Color: yellow - - Shape: circle - - Size: small + - conditionName: hasAllProperties + conditionParameters: + - Color: yellow + - Shape: circle + - Size: small modulesCmHandleQueryParameters: value: cmHandleQueryParameters: - - conditionName: hasAllModules - conditionParameters: - - moduleName: my-module-1 - - moduleName: my-module-2 - - moduleName: my-module-3 + - conditionName: hasAllModules + conditionParameters: + - moduleName: my-module-1 + - moduleName: my-module-2 + - moduleName: my-module-3 allCmHandleQueryParameters: value: cmHandleQueryParameters: - - conditionName: hasAllModules - conditionParameters: - - moduleName: my-module-1 - - moduleName: my-module-2 - - moduleName: my-module-3 - - conditionName: hasAllProperties - conditionParameters: - - Color: yellow - - Shape: circle - - Size: small - - conditionName: cmHandleWithCpsPath - conditionParameters: - - cpsPath: "//state[@cm-handle-state='ADVISED']" + - conditionName: hasAllModules + conditionParameters: + - moduleName: my-module-1 + - moduleName: my-module-2 + - moduleName: my-module-3 + - conditionName: hasAllProperties + conditionParameters: + - Color: yellow + - Shape: circle + - Size: small + - conditionName: cmHandleWithCpsPath + conditionParameters: + - cpsPath: "//state[@cm-handle-state='ADVISED']" cpsPathCmHandleStateQueryParameters: value: cmHandleQueryParameters: - - conditionName: cmHandleWithCpsPath - conditionParameters: - - cpsPath: "//state[@cm-handle-state='LOCKED']" + - conditionName: cmHandleWithCpsPath + conditionParameters: + - cpsPath: "//state[@cm-handle-state='LOCKED']" cpsPathCmHandleDataSyncQueryParameters: value: cmHandleQueryParameters: - - conditionName: cmHandleWithCpsPath - conditionParameters: - - cpsPath: "//state[@data-sync-enabled='true']" - -security: - - basicAuth: [] + - conditionName: cmHandleWithCpsPath + conditionParameters: + - cpsPath: "//state[@data-sync-enabled='true']" + securitySchemes: + basicAuth: + type: http + scheme: basic diff --git a/integration-test/pom.xml b/integration-test/pom.xml new file mode 100644 index 000000000..40195cafe --- /dev/null +++ b/integration-test/pom.xml @@ -0,0 +1,106 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + Copyright (c) 2023 Nordix Foundation + ================================================================================ + 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. + ============LICENSE_END========================================================= +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.onap.cps</groupId> + <artifactId>cps-parent</artifactId> + <version>3.2.1-SNAPSHOT</version> + <relativePath>../cps-parent/pom.xml</relativePath> + </parent> + + <modelVersion>4.0.0</modelVersion> + + <artifactId>integration-test</artifactId> + + <dependencies> + <dependency> + <groupId>org.onap.cps</groupId> + <artifactId>cps-ri</artifactId> + </dependency> + <dependency> + <groupId>org.onap.cps</groupId> + <artifactId>cps-service</artifactId> + </dependency> + <!-- T E S T D E P E N D E N C I E S --> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.spockframework</groupId> + <artifactId>spock-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.spockframework</groupId> + <artifactId>spock-spring</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>postgresql</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>spock</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.kafka</groupId> + <artifactId>spring-kafka-test</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <profiles> + <profile> + <id>default</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <excludes> + <exclude>%regex[.*Spec.*]</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>include-performance</id> + </profile> + </profiles> + +</project> diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/CpsIntegrationSpecBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/CpsIntegrationSpecBase.groovy new file mode 100644 index 000000000..960483270 --- /dev/null +++ b/integration-test/src/test/groovy/org/onap/cps/integration/CpsIntegrationSpecBase.groovy @@ -0,0 +1,112 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation + * ================================================================================ + * 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========================================================= + */ + +package org.onap.cps.integration + +import org.onap.cps.api.impl.CpsAdminServiceImpl +import org.onap.cps.api.impl.CpsDataServiceImpl +import org.onap.cps.api.impl.CpsModuleServiceImpl +import org.onap.cps.spi.CascadeDeleteAllowed +import org.onap.cps.spi.repository.DataspaceRepository +import org.onap.cps.spi.impl.utils.CpsValidatorImpl +import org.onap.cps.utils.ContentType +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.autoconfigure.EnableAutoConfiguration +import org.springframework.boot.autoconfigure.domain.EntityScan +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.context.annotation.ComponentScan +import org.springframework.context.annotation.Lazy +import org.springframework.data.jpa.repository.config.EnableJpaRepositories +import org.testcontainers.spock.Testcontainers +import spock.lang.Shared +import spock.lang.Specification + +import java.time.OffsetDateTime + +@SpringBootTest(classes = [TestConfig, CpsAdminServiceImpl, CpsValidatorImpl]) +@Testcontainers +@EnableAutoConfiguration +@EnableJpaRepositories(basePackageClasses = [DataspaceRepository]) +@ComponentScan(basePackages = ["org.onap.cps.api", "org.onap.cps.spi.repository"]) +@EntityScan("org.onap.cps.spi.entities") +class CpsIntegrationSpecBase extends Specification { + + @Shared + DatabaseTestContainer databaseTestContainer = DatabaseTestContainer.getInstance() + + @Autowired + @Lazy + CpsAdminServiceImpl cpsAdminService + + @Autowired + @Lazy + CpsDataServiceImpl cpsDataService + + @Autowired + @Lazy + CpsModuleServiceImpl cpsModuleService + + + def static TEST_DATASPACE = 'testDataspace' + def static BOOKSTORE_SCHEMA_SET = 'bookstoreSchemaSet' + def static TEST_ANCHOR = 'testAnchor' + + def createDataspaceSchemaSetAnchor(String dataspaceName, String schemaSetName, String schemaSetFileName, String anchorName) { + cpsAdminService.createDataspace(dataspaceName) + createSchemaSetAnchor(dataspaceName, schemaSetName, schemaSetFileName, anchorName) + } + + def createSchemaSetAnchor(String dataspaceName, String schemaSetName, String schemaSetFileName, String anchorName) { + def bookstoreFileContent = readResourceFile(schemaSetFileName) + cpsModuleService.createSchemaSet(dataspaceName, schemaSetName, [(schemaSetFileName) : bookstoreFileContent]) + cpsAdminService.createAnchor(dataspaceName, schemaSetName, anchorName) + } + + def saveDataNodes(String dataspaceName, String anchorName, String parentNodeXpath, String dataNodesFileName) { + def dataNodesAsJSON = readResourceFile(dataNodesFileName) + if (isRootXpath(parentNodeXpath)) { + cpsDataService.saveData(dataspaceName, anchorName, dataNodesAsJSON, + OffsetDateTime.now(), ContentType.JSON); + } else { + cpsDataService.saveData(dataspaceName, anchorName, parentNodeXpath, + dataNodesAsJSON, OffsetDateTime.now(), ContentType.JSON); + } + } + + def deleteAllFromTestDataspace() { + def anchors = cpsAdminService.getAnchors(TEST_DATASPACE) + for(anchor in anchors) { + cpsDataService.deleteDataNodes(TEST_DATASPACE, anchor.getName(), OffsetDateTime.now()) + cpsAdminService.deleteAnchor(TEST_DATASPACE, anchor.getName()) + } + def schemaSets = cpsModuleService.getSchemaSets(TEST_DATASPACE) + for(schemaSet in schemaSets) { + cpsModuleService.deleteSchemaSet(TEST_DATASPACE, schemaSet.getName(), CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED) + } + } + + def static readResourceFile(String filename) { + return new File('src/test/resources/data/' + filename).text + } + + def static isRootXpath(final String xpath) { + return "/".equals(xpath); + } +} diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/CpsPersistenceSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/CpsPersistenceSpec.groovy new file mode 100644 index 000000000..94bcb0a6f --- /dev/null +++ b/integration-test/src/test/groovy/org/onap/cps/integration/CpsPersistenceSpec.groovy @@ -0,0 +1,61 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation + * ================================================================================ + * 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========================================================= + */ + +package org.onap.cps.integration + +import org.onap.cps.spi.FetchDescendantsOption + +class CpsPersistenceSpec extends CpsIntegrationSpecBase{ + + def 'Test creation of test data'() { + when: 'A dataspace, schema set and anchor are persisted' + createDataspaceSchemaSetAnchor(TEST_DATASPACE, BOOKSTORE_SCHEMA_SET, 'bookstore.yang', TEST_ANCHOR) + and: 'data nodes are persisted under the created anchor' + saveDataNodes(TEST_DATASPACE, TEST_ANCHOR, '/', 'BookstoreDataNodes.json') + then: 'The dataspace has been persisted successfully' + cpsAdminService.getDataspace(TEST_DATASPACE).getName() == TEST_DATASPACE + and: 'The schema set has been persisted successfully' + cpsModuleService.getSchemaSet(TEST_DATASPACE, BOOKSTORE_SCHEMA_SET).getName() == BOOKSTORE_SCHEMA_SET + and: 'The anchor has been persisted successfully' + cpsAdminService.getAnchor(TEST_DATASPACE, TEST_ANCHOR).getName() == TEST_ANCHOR + and: 'The data nodes have been persisted successfully' + cpsDataService.getDataNode(TEST_DATASPACE, TEST_ANCHOR, '/bookstore', FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS).xpath == '/bookstore' + } + + def 'Test deletion of all test data'() { + when: 'delete all from test dataspace method is called' + deleteAllFromTestDataspace() + and: 'the test dataspace is deleted' + cpsAdminService.deleteDataspace(TEST_DATASPACE) + then: 'there is no test dataspace' + !cpsAdminService.getAllDataspaces().contains(TEST_DATASPACE) + } + + def 'Read test for persisted data nodes'() { + given:'There is a test dataspace created' + cpsAdminService.createDataspace(TEST_DATASPACE) + and: 'There is a schema set and anchor for the test dataspace' + createSchemaSetAnchor(TEST_DATASPACE, 'bookstoreSchemaSet', 'bookstore.yang', TEST_ANCHOR) + when: 'data is persisted to the database' + saveDataNodes(TEST_DATASPACE, TEST_ANCHOR, "/", "BookstoreDataNodes.json") + then: 'the correct data is saved' + cpsDataService.getDataNode(TEST_DATASPACE, TEST_ANCHOR, '/bookstore', FetchDescendantsOption.OMIT_DESCENDANTS).leaves['bookstore-name'] == 'Easons' + } +} diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/TestConfig.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/TestConfig.groovy new file mode 100644 index 000000000..273d7bb55 --- /dev/null +++ b/integration-test/src/test/groovy/org/onap/cps/integration/TestConfig.groovy @@ -0,0 +1,111 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation + * ================================================================================ + * 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========================================================= + */ + +package org.onap.cps.integration + +import com.fasterxml.jackson.databind.ObjectMapper +import org.onap.cps.notification.NotificationService +import org.onap.cps.spi.CpsDataPersistenceService +import org.onap.cps.spi.CpsModulePersistenceService +import org.onap.cps.spi.impl.CpsAdminPersistenceServiceImpl +import org.onap.cps.spi.impl.CpsDataPersistenceServiceImpl +import org.onap.cps.spi.impl.CpsModulePersistenceServiceImpl +import org.onap.cps.spi.repository.AnchorRepository +import org.onap.cps.spi.repository.DataspaceRepository +import org.onap.cps.spi.repository.FragmentRepository +import org.onap.cps.spi.repository.ModuleReferenceRepository +import org.onap.cps.spi.repository.SchemaSetRepository +import org.onap.cps.spi.repository.YangResourceRepository +import org.onap.cps.spi.utils.SessionManager +import org.onap.cps.utils.JsonObjectMapper +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Lazy +import spock.lang.Specification + +@Configuration +class TestConfig extends Specification{ + @Autowired + @Lazy + DataspaceRepository dataspaceRepository + + @Autowired + @Lazy + AnchorRepository anchorRepository + + @Autowired + @Lazy + SchemaSetRepository schemaSetRepository + + @Autowired + @Lazy + YangResourceRepository yangResourceRepository + + @Autowired + @Lazy + FragmentRepository fragmentRepository + + @Autowired + @Lazy + ModuleReferenceRepository moduleReferenceRepository + + @Autowired + @Lazy + JsonObjectMapper jsonObjectMapper + + @Autowired + @Lazy + NotificationService stubbedNotificationService + + @Autowired + @Lazy + SessionManager stubbedSessionManager + + @Bean + CpsAdminPersistenceServiceImpl cpsAdminPersistenceService() { + new CpsAdminPersistenceServiceImpl(dataspaceRepository, anchorRepository, schemaSetRepository, yangResourceRepository) + } + + @Bean + CpsDataPersistenceService cpsDataPersistenceService() { + return (CpsDataPersistenceService) new CpsDataPersistenceServiceImpl(dataspaceRepository, anchorRepository, fragmentRepository, jsonObjectMapper, stubbedSessionManager) + } + + @Bean + CpsModulePersistenceService cpsModulePersistenceService() { + return (CpsModulePersistenceService) new CpsModulePersistenceServiceImpl(yangResourceRepository, schemaSetRepository, dataspaceRepository, cpsAdminPersistenceService(), moduleReferenceRepository) + } + + @Bean + JsonObjectMapper jsonObjectMapper() { + return new JsonObjectMapper(new ObjectMapper()) + } + + @Bean + NotificationService notificationService() { + return Stub(NotificationService) + } + + @Bean + SessionManager sessionManager() { + return Stub(SessionManager) + } +}
\ No newline at end of file diff --git a/integration-test/src/test/java/org/onap/cps/integration/DatabaseTestContainer.java b/integration-test/src/test/java/org/onap/cps/integration/DatabaseTestContainer.java new file mode 100644 index 000000000..acf94b74b --- /dev/null +++ b/integration-test/src/test/java/org/onap/cps/integration/DatabaseTestContainer.java @@ -0,0 +1,71 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation. + * ================================================================================ + * 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========================================================= + */ + +package org.onap.cps.integration; + +import org.testcontainers.containers.PostgreSQLContainer; +import org.testcontainers.utility.DockerImageName; + +/** + * The Postgresql database test container wrapper. + * Singleton implementation allows saving time on database initialization which otherwise would occur on each test. + * for debugging/developing purposes you can suspend any test and connect to this database: + * docker exec -it {container-id} sh + * psql -d test -U test + */ +public class DatabaseTestContainer extends PostgreSQLContainer<DatabaseTestContainer> { + private static final String IMAGE_VERSION = "registry.nordix.org/onaptest/postgres:14.1"; + private static DatabaseTestContainer databaseTestContainer; + + private DatabaseTestContainer() { + super(DockerImageName.parse(IMAGE_VERSION).asCompatibleSubstituteFor("postgres")); + } + + /** + * Provides an instance of test container wrapper. + * The returned value expected to be assigned to static variable annotated with @ClassRule. + * This will allow to initialize DB connection env variables before DataSource object + * is initialized by Spring framework. + * + */ + public static DatabaseTestContainer getInstance() { + if (databaseTestContainer == null) { + databaseTestContainer = new DatabaseTestContainer(); + Runtime.getRuntime().addShutdownHook(new Thread(databaseTestContainer::terminate)); + } + return databaseTestContainer; + } + + @Override + public void start() { + super.start(); + System.setProperty("DB_URL", databaseTestContainer.getJdbcUrl()); + System.setProperty("DB_USERNAME", databaseTestContainer.getUsername()); + System.setProperty("DB_PASSWORD", databaseTestContainer.getPassword()); + } + + @Override + public void stop() { + // do nothing on test completion, image removal will be performed via terminate() on JVM shutdown + } + + private void terminate() { + super.stop(); + } +} diff --git a/integration-test/src/test/resources/application.yml b/integration-test/src/test/resources/application.yml new file mode 100644 index 000000000..0aefac83f --- /dev/null +++ b/integration-test/src/test/resources/application.yml @@ -0,0 +1,37 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2023 Nordix Foundation. +# ================================================================================ +# 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========================================================= + +spring: + jpa: + ddl-auto: create + show-sql: false + properties: + hibernate: + enable_lazy_load_no_trans: true + dialect: org.hibernate.dialect.PostgreSQLDialect + format_sql: true + show_sql: false + + datasource: + url: ${DB_URL} + username: ${DB_USERNAME} + password: ${DB_PASSWORD} + driverClassName: org.postgresql.Driver + initialization-mode: always + + liquibase: + change-log: classpath:liquibase/test-changelog.yaml diff --git a/integration-test/src/test/resources/data/BookstoreDataNodes.json b/integration-test/src/test/resources/data/BookstoreDataNodes.json new file mode 100644 index 000000000..1c6cb88f9 --- /dev/null +++ b/integration-test/src/test/resources/data/BookstoreDataNodes.json @@ -0,0 +1,54 @@ +{ + "bookstore": { + "bookstore-name": "Easons", + "categories": [ + { + "code": 1, + "name": "Children", + "books" : [ + { + "title": "Matilda", + "lang": "English", + "authors": ["Roald Dahl"], + "pub_year": 1988, + "price": 10 + }, + { + "title": "The Gruffalo", + "lang": "English", + "authors": ["Julia Donaldson"], + "pub_year": 1999, + "price": 15 + } + ] + }, + { + "code": 2, + "name": "Thriller", + "books" : [ + { + "title": "Annihilation", + "lang": "English", + "authors": ["Jeff VanderMeer"], + "pub_year": 2014, + "price": 15 + } + ] + }, + { + "code": 3, + "name": "Comedy", + "books" : [ + { + "title": "Good Omens", + "lang": "English", + "authors": ["Neil Gaiman", "Terry Pratchett"], + "pub_year": 2006, + "price": 13 + } + ] + } + + ] + } +}
\ No newline at end of file diff --git a/integration-test/src/test/resources/data/bookstore.yang b/integration-test/src/test/resources/data/bookstore.yang new file mode 100644 index 000000000..2179fb93d --- /dev/null +++ b/integration-test/src/test/resources/data/bookstore.yang @@ -0,0 +1,57 @@ +module stores { + yang-version 1.1; + namespace "org:onap:ccsdk:sample"; + + prefix book-store; + + revision "2020-09-15" { + description + "Sample Model"; + } + + typedef year { + type uint16 { + range "1000..9999"; + } + } + + container bookstore { + + leaf bookstore-name { + type string; + } + + list categories { + + key "code"; + + leaf code { + type string; + } + + leaf name { + type string; + } + + list books { + key title; + + leaf title { + type string; + } + leaf lang { + type string; + } + leaf-list authors { + type string; + } + leaf pub_year { + type year; + } + leaf price { + type uint64; + } + } + } + } +} diff --git a/integration-test/src/test/resources/hibernate.cfg.xml b/integration-test/src/test/resources/hibernate.cfg.xml new file mode 100644 index 000000000..513c00ad2 --- /dev/null +++ b/integration-test/src/test/resources/hibernate.cfg.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-configuration PUBLIC + "-//Hibernate/Hibernate Configuration DTD 3.0//EN" + "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> + +<hibernate-configuration> + <session-factory> + <property name="hibernate.connection.driver_class">org.postgresql.Driver</property> + <property name="hibernate.connection.url">${DB_URL}</property> + <property name="hibernate.connection.username">${DB_USERNAME}</property> + <property name="hibernate.connection.password">${DB_PASSWORD}</property> + <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL82Dialect</property> + <property name="show_sql">true</property> + <property name="hibernate.hbm2ddl.auto">none</property> + </session-factory> +</hibernate-configuration>
\ No newline at end of file diff --git a/integration-test/src/test/resources/liquibase/test-changelog.yaml b/integration-test/src/test/resources/liquibase/test-changelog.yaml new file mode 100644 index 000000000..0c881b802 --- /dev/null +++ b/integration-test/src/test/resources/liquibase/test-changelog.yaml @@ -0,0 +1,615 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2023 Nordix Foundation. +# ================================================================================ +# 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. +# ============LICENSE_END========================================================= + +databaseChangeLog: + - changeSet: + id: 1-1 + author: cps + changes: + - createTable: + columns: + - column: + autoIncrement: true + constraints: + nullable: false + primaryKey: true + primaryKeyName: anchor_pkey + name: id + type: BIGINT + - column: + name: name + type: TEXT + - column: + name: schema_set_id + type: INTEGER + - column: + constraints: + nullable: false + name: dataspace_id + type: INTEGER + tableName: anchor + - changeSet: + id: 1-2 + author: cps + changes: + - createTable: + columns: + - column: + constraints: + nullable: false + name: from_fragment_id + type: BIGINT + - column: + constraints: + nullable: false + name: to_fragment_id + type: BIGINT + - column: + constraints: + nullable: false + name: relation_type_id + type: INTEGER + - column: + constraints: + nullable: false + name: from_rel_xpath + type: TEXT + - column: + constraints: + nullable: false + name: to_rel_xpath + type: TEXT + tableName: relation + - changeSet: + id: 1-3 + author: cps + changes: + - createTable: + columns: + - column: + constraints: + nullable: false + name: relation_type + type: TEXT + - column: + autoIncrement: true + constraints: + nullable: false + primaryKey: true + primaryKeyName: relation_type_pkey + name: id + type: INTEGER + tableName: relation_type + - changeSet: + id: 1-4 + author: cps + changes: + - createTable: + columns: + - column: + autoIncrement: true + constraints: + nullable: false + primaryKey: true + primaryKeyName: fragment_pkey + name: id + type: BIGINT + - column: + constraints: + nullable: false + name: xpath + type: TEXT + - column: + name: attributes + type: JSONB + - column: + name: anchor_id + type: BIGINT + - column: + name: parent_id + type: BIGINT + - column: + constraints: + nullable: false + name: dataspace_id + type: INTEGER + - column: + name: schema_node_id + type: INTEGER + tableName: fragment + - changeSet: + id: 1-5 + author: cps + changes: + - createTable: + columns: + - column: + autoIncrement: true + constraints: + nullable: false + primaryKey: true + primaryKeyName: schema_set_pkey + name: id + type: INTEGER + - column: + constraints: + nullable: false + name: name + type: TEXT + - column: + constraints: + nullable: false + name: dataspace_id + type: BIGINT + tableName: schema_set + - changeSet: + id: 1-6 + author: cps + changes: + - createTable: + columns: + - column: + autoIncrement: true + constraints: + nullable: false + primaryKey: true + primaryKeyName: yang_resource_pkey + name: id + type: INTEGER + - column: + constraints: + nullable: false + name: name + type: TEXT + - column: + constraints: + nullable: false + name: content + type: TEXT + - column: + constraints: + nullable: false + name: checksum + type: TEXT + tableName: yang_resource + - changeSet: + id: 1-7 + author: cps + changes: + - createTable: + columns: + - column: + autoIncrement: true + constraints: + nullable: false + primaryKey: true + primaryKeyName: dataspace_pkey + name: id + type: INTEGER + - column: + constraints: + nullable: false + name: name + type: TEXT + tableName: dataspace + - changeSet: + id: 1-8 + author: cps + changes: + - createTable: + columns: + - column: + constraints: + nullable: false + name: schema_node_identifier + type: TEXT + - column: + autoIncrement: true + constraints: + nullable: false + primaryKey: true + primaryKeyName: schema_node_pkey + name: id + type: INTEGER + tableName: schema_node + - changeSet: + id: 1-9 + author: cps + changes: + - createTable: + columns: + - column: + constraints: + nullable: false + name: schema_set_id + type: BIGINT + - column: + constraints: + nullable: false + name: yang_resource_id + type: BIGINT + tableName: schema_set_yang_resources + - changeSet: + id: 1-10 + author: cps + changes: + - createIndex: + columns: + - column: + name: schema_set_id + indexName: FKI_ANCHOR_SCHEMA_SET_ID_FK + tableName: anchor + - changeSet: + id: 1-11 + author: cps + changes: + - addUniqueConstraint: + columnNames: dataspace_id, name + constraintName: anchor_dataspace_id_name_key + tableName: anchor + - changeSet: + id: 1-12 + author: cps + changes: + - addForeignKeyConstraint: + baseColumnNames: anchor_id + baseTableName: fragment + constraintName: fragment_anchor_id_fkey + deferrable: false + initiallyDeferred: false + onDelete: NO ACTION + onUpdate: NO ACTION + referencedColumnNames: id + referencedTableName: anchor + validate: true + - changeSet: + id: 1-13 + author: cps + changes: + - createIndex: + columns: + - column: + name: from_fragment_id + indexName: FKI_RELATIONS_FROM_ID_FK + tableName: relation + - changeSet: + id: 1-14 + author: cps + changes: + - createIndex: + columns: + - column: + name: to_fragment_id + indexName: FKI_RELATIONS_TO_ID_FK + tableName: relation + - changeSet: + id: 1-15 + author: cps + changes: + - createIndex: + columns: + - column: + name: relation_type_id + indexName: FKI_RELATION_TYPE_ID_FK + tableName: relation + - changeSet: + id: 1-16 + author: cps + changes: + - addPrimaryKey: + columnNames: to_fragment_id, from_fragment_id, relation_type_id + constraintName: relation_pkey + tableName: relation + - changeSet: + id: 1-17 + author: cps + changes: + - createIndex: + columns: + - column: + name: anchor_id + indexName: FKI_FRAGMENT_ANCHOR_ID_FK + tableName: fragment + - changeSet: + id: 1-18 + author: cps + changes: + - createIndex: + columns: + - column: + name: dataspace_id + indexName: FKI_FRAGMENT_DATASPACE_ID_FK + tableName: fragment + - changeSet: + id: 1-19 + author: cps + changes: + - createIndex: + columns: + - column: + name: parent_id + indexName: FKI_FRAGMENT_PARENT_ID_FK + tableName: fragment + - changeSet: + id: 1-20 + author: cps + changes: + - createIndex: + columns: + - column: + name: schema_node_id + indexName: FKI_SCHEMA_NODE_ID_TO_ID + tableName: fragment + - changeSet: + id: 1-21 + author: cps + changes: + - createIndex: + columns: + - column: + name: xpath + - column: + name: dataspace_id + indexName: UQ_FRAGMENT_XPATH + tableName: fragment + unique: true + - changeSet: + id: 1-22 + author: cps + changes: + - addUniqueConstraint: + columnNames: dataspace_id, anchor_id, xpath + constraintName: fragment_dataspace_id_anchor_id_xpath_key + tableName: fragment + - changeSet: + id: 1-23 + author: cps + changes: + - addForeignKeyConstraint: + baseColumnNames: from_fragment_id + baseTableName: relation + constraintName: relation_from_fragment_id_fkey + deferrable: false + initiallyDeferred: false + onDelete: NO ACTION + onUpdate: NO ACTION + referencedColumnNames: id + referencedTableName: fragment + validate: true + - changeSet: + id: 1-24 + author: cps + changes: + - addForeignKeyConstraint: + baseColumnNames: to_fragment_id + baseTableName: relation + constraintName: relation_to_fragment_id_fkey + deferrable: false + initiallyDeferred: false + onDelete: NO ACTION + onUpdate: NO ACTION + referencedColumnNames: id + referencedTableName: fragment + validate: true + - changeSet: + id: 1-25 + author: cps + changes: + - addUniqueConstraint: + columnNames: name, dataspace_id + constraintName: schema_set_name_dataspace_id_key + tableName: schema_set + - changeSet: + id: 1-26 + author: cps + changes: + - addForeignKeyConstraint: + baseColumnNames: schema_set_id + baseTableName: schema_set_yang_resources + constraintName: schema_set_resource + deferrable: false + initiallyDeferred: false + onDelete: CASCADE + onUpdate: NO ACTION + referencedColumnNames: id + referencedTableName: schema_set + validate: true + - changeSet: + id: 1-27 + author: cps + changes: + - addUniqueConstraint: + columnNames: checksum + constraintName: yang_resource_checksum_key + tableName: yang_resource + - changeSet: + id: 1-28 + author: cps + changes: + - addUniqueConstraint: + columnNames: name + constraintName: UQ_NAME + tableName: dataspace + - changeSet: + id: 1-29 + author: cps + changes: + - addForeignKeyConstraint: + baseColumnNames: dataspace_id + baseTableName: fragment + constraintName: fragment_dataspace_id_fkey + deferrable: false + initiallyDeferred: false + onDelete: NO ACTION + onUpdate: NO ACTION + referencedColumnNames: id + referencedTableName: dataspace + validate: true + - changeSet: + id: 1-30 + author: cps + changes: + - addForeignKeyConstraint: + baseColumnNames: dataspace_id + baseTableName: schema_set + constraintName: schema_set_dataspace + deferrable: false + initiallyDeferred: false + onDelete: CASCADE + onUpdate: CASCADE + referencedColumnNames: id + referencedTableName: dataspace + validate: true + - changeSet: + id: 1-31 + author: cps + changes: + - createIndex: + columns: + - column: + name: schema_node_identifier + indexName: PERF_SCHEMA_NODE_SCHEMA_NODE_ID + tableName: schema_node + - changeSet: + id: 1-32 + author: cps + changes: + - addForeignKeyConstraint: + baseColumnNames: yang_resource_id + baseTableName: schema_set_yang_resources + constraintName: schema_set_yang_resources_yang_resource_id_fkey + deferrable: false + initiallyDeferred: false + onDelete: NO ACTION + onUpdate: NO ACTION + referencedColumnNames: id + referencedTableName: yang_resource + validate: true + - changeSet: + id: 1-33 + author: cps + changes: + - addForeignKeyConstraint: + baseColumnNames: dataspace_id + baseTableName: anchor + constraintName: anchor_dataspace_id_fkey + deferrable: false + initiallyDeferred: false + onDelete: NO ACTION + onUpdate: NO ACTION + referencedColumnNames: id + referencedTableName: dataspace + validate: true + - changeSet: + id: 1-34 + author: cps + changes: + - addForeignKeyConstraint: + baseColumnNames: schema_set_id + baseTableName: anchor + constraintName: anchor_schema_set_id_fkey + deferrable: false + initiallyDeferred: false + onDelete: NO ACTION + onUpdate: NO ACTION + referencedColumnNames: id + referencedTableName: schema_set + validate: true + - changeSet: + id: 1-35 + author: cps + changes: + - addForeignKeyConstraint: + baseColumnNames: relation_type_id + baseTableName: relation + constraintName: relation_relation_type_id_fkey + deferrable: false + initiallyDeferred: false + onDelete: NO ACTION + onUpdate: NO ACTION + referencedColumnNames: id + referencedTableName: relation_type + validate: true + - changeSet: + id: 1-36 + author: cps + changes: + - addForeignKeyConstraint: + baseColumnNames: parent_id + baseTableName: fragment + constraintName: fragment_parent_id_fkey + deferrable: false + initiallyDeferred: false + onDelete: NO ACTION + onUpdate: NO ACTION + referencedColumnNames: id + referencedTableName: fragment + validate: true + - changeSet: + id: 1-37 + author: cps + changes: + - addForeignKeyConstraint: + baseColumnNames: schema_node_id + baseTableName: fragment + constraintName: fragment_schema_node_id_fkey + deferrable: false + initiallyDeferred: false + onDelete: NO ACTION + onUpdate: NO ACTION + referencedColumnNames: id + referencedTableName: schema_node + validate: true + + + - changeSet: + id: 1-38 + label: add-module-name-and-revision-column + author: cps + changes: + - addColumn: + tableName: yang_resource + columns: + - column: + name: module_name + type: TEXT + - column: + name: revision + type: TEXT + + - changeSet: + id: 1-39 + label: update-previous-data-module-name-and-revision + author: cps + changes: + - sql: + sql: update yang_resource set module_name = 'dummy_module_name', revision = '2021-08-04' where module_name is null and revision is null + rollback: + sql: update yang_resource set module_name = null, revision = null where module_name = 'dummy_module_name' and revision = '2021-08-04' + + - changeSet: + author: cps + label: yang-resource-rename-column + id: 1-40 + changes: + - renameColumn: + tableName: yang_resource + columnDataType: TEXT + oldColumnName: name + newColumnName: file_name + rollback: + - sql: + sql: alter table yang_resource rename column file_name to name @@ -2,7 +2,7 @@ <!--
============LICENSE_START=======================================================
Copyright (c) 2020 Linux Foundation.
- Modifications Copyright (C) 2020-2021 Nordix Foundation
+ Modifications Copyright (C) 2020-2023 Nordix Foundation
Modifications Copyright (C) 2020-2021 Pantheon.tech
Modifications Copyright (C) 2021-2022 Bell Canada.
================================================================================
@@ -61,6 +61,7 @@ <module>cps-ncmp-rest-stub</module>
<module>cps-path-parser</module>
<module>cps-ri</module>
+ <module>integration-test</module>
<module>checkstyle</module>
<module>spotbugs</module>
<module>cps-application</module>
|