From 53375821fa2d156785a92ef57ef7948389260cc1 Mon Sep 17 00:00:00 2001 From: ToineSiebelink Date: Mon, 29 Jul 2024 17:45:52 +0100 Subject: Refactor OpenAPI Policy Executor - replace payload with request(s) - replace payloadType with schema (one schema for each operation) - include conflict error response in OpenAPI - introduce 4 schemas in NCMP (doc module) for create, update, patch & delete - udpate stub & test to follow new API and use one schema for testign purposes Issue-ID: CPS-2335 Change-Id: Ifc40062ae83429a9ffba350ec3bcc28cb7147293 Signed-off-by: ToineSiebelink --- docs/api/swagger/policy-executor/openapi.yaml | 66 +++++++++------------- .../policy-executor/ncmp-create-schema-1.0.0.json | 29 ++++++++++ .../policy-executor/ncmp-delete-schema-1.0.0.json | 25 ++++++++ .../policy-executor/ncmp-patch-schema-1.0.0.json | 29 ++++++++++ .../policy-executor/ncmp-update-schema-1.0.0.json | 29 ++++++++++ 5 files changed, 140 insertions(+), 38 deletions(-) create mode 100644 docs/schemas/policy-executor/ncmp-create-schema-1.0.0.json create mode 100644 docs/schemas/policy-executor/ncmp-delete-schema-1.0.0.json create mode 100644 docs/schemas/policy-executor/ncmp-patch-schema-1.0.0.json create mode 100644 docs/schemas/policy-executor/ncmp-update-schema-1.0.0.json (limited to 'docs') diff --git a/docs/api/swagger/policy-executor/openapi.yaml b/docs/api/swagger/policy-executor/openapi.yaml index 98c5b1e79a..58ca5acfc5 100644 --- a/docs/api/swagger/policy-executor/openapi.yaml +++ b/docs/api/swagger/policy-executor/openapi.yaml @@ -52,8 +52,12 @@ paths: $ref: '#/components/schemas/PolicyExecutionResponse' '400': $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' + '409': + $ref: '#/components/responses/Conflict' '500': $ref: '#/components/responses/InternalServerError' @@ -75,48 +79,34 @@ components: details: type: string - Payload: + Request: type: object properties: - targetFdn: + schema: type: string - description: "The complete FDN (Fully Distinguished Name) for the element to be changed" - example: "/Subnetwork=Ireland/MeContext=Athlone/ManagedElement=Athlone/SomeFunction=1/Cell=12" - cmHandleId: - type: string - description: "The CM handle ID (optional)" - example: "F811AF64F5146DFC545EC60B73DE948E" - resourceIdentifier: - type: string - description: "The resource identifier (optional)" - example: "ManagedElement=Athlone/SomeFunction=1/Cell=12" - cmChangeRequest: + description: "The schema for the data in this request. The schema name should include the type of operation" + example: "org.onap.cps.ncmp.policy-executor:ncmp-create-schema:1.0.0" + data: type: object - description: "The content of the change to be made" - example: '{"Cell":[{"id":"Cell-id","attributes":{"administrativeState":"UNLOCKED"}}]}' + description: "The data related to the request. The format of the object is determined by the schema" required: - - targetFdn - - cmChangeRequest + - schema + - data PolicyExecutionRequest: type: object properties: - payloadType: - type: string - description: "The type of payload. Currently supported options: 'cm_write'" - example: "cm_write" decisionType: type: string - description: "The type of decision. Currently supported options: 'permit'" - example: "permit" - payload: + description: "The type of decision. Currently supported options: 'allow'" + example: "allow" + requests: type: array items: - $ref: '#/components/schemas/Payload' + $ref: '#/components/schemas/Request' required: - - payloadType - decisionType - - payload + - requests PolicyExecutionResponse: type: object @@ -127,7 +117,7 @@ components: example: "550e8400-e29b-41d4-a716-446655440000" decision: type: string - description: "The decision outcome. Currently supported values: 'permit','deny'" + description: "The decision outcome. Currently supported values: 'allow','deny'" example: "deny" message: type: string @@ -139,16 +129,16 @@ components: - message responses: - NotFound: - description: "The specified resource was not found" + BadRequest: + description: "Bad request" content: application/json: schema: $ref: '#/components/schemas/ErrorMessage' example: - status: 404 - message: "Resource Not Found" - details: "The requested resource is not found" + status: 400 + message: "Bad Request" + details: "The provided request is not valid" Unauthorized: description: "Unauthorized request" content: @@ -169,16 +159,16 @@ components: status: 403 message: "Request Forbidden" details: "This request is forbidden" - BadRequest: - description: "Bad request" + Conflict: + description: "Conflict" content: application/json: schema: $ref: '#/components/schemas/ErrorMessage' example: - status: 400 - message: "Bad Request" - details: "The provided request is not valid" + status: 409 + message: "Conflict" + details: "The provided request violates a policy rule" InternalServerError: description: "Internal server error" diff --git a/docs/schemas/policy-executor/ncmp-create-schema-1.0.0.json b/docs/schemas/policy-executor/ncmp-create-schema-1.0.0.json new file mode 100644 index 0000000000..2ec9daf949 --- /dev/null +++ b/docs/schemas/policy-executor/ncmp-create-schema-1.0.0.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "urn:cps:org.onap.cps.ncmp.policy-executor:ncmp-create-schema:1.0.0", + "$ref": "#/definitions/NcmpCreate", + "definitions": { + "NcmpCreate": { + "type": "object", + "additionalProperties": false, + "properties": { + "cmHandleId": { + "type": "string" + }, + "resourceIdentifier": { + "type": "string" + }, + "targetIdentifier": { + "type": "string" + }, + "cmChangeRequest": { + "type": "object" + } + }, + "required": [ + "targetIdentifier", + "cmChangeRequest" + ] + } + } +} diff --git a/docs/schemas/policy-executor/ncmp-delete-schema-1.0.0.json b/docs/schemas/policy-executor/ncmp-delete-schema-1.0.0.json new file mode 100644 index 0000000000..5df0325e39 --- /dev/null +++ b/docs/schemas/policy-executor/ncmp-delete-schema-1.0.0.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "urn:cps:org.onap.cps.ncmp.policy-executor:ncmp-delete-schema:1.0.0", + "$ref": "#/definitions/NcmpDelete", + "definitions": { + "NcmpDelete": { + "type": "object", + "additionalProperties": false, + "properties": { + "cmHandleId": { + "type": "string" + }, + "resourceIdentifier": { + "type": "string" + }, + "targetIdentifier": { + "type": "string" + } + }, + "required": [ + "targetIdentifier" + ] + } + } +} diff --git a/docs/schemas/policy-executor/ncmp-patch-schema-1.0.0.json b/docs/schemas/policy-executor/ncmp-patch-schema-1.0.0.json new file mode 100644 index 0000000000..e26c244c94 --- /dev/null +++ b/docs/schemas/policy-executor/ncmp-patch-schema-1.0.0.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "urn:cps:org.onap.cps.ncmp.policy-executor:ncmp-patch-schema:1.0.0", + "$ref": "#/definitions/NcmpPatch", + "definitions": { + "NcmpPatch": { + "type": "object", + "additionalProperties": false, + "properties": { + "cmHandleId": { + "type": "string" + }, + "resourceIdentifier": { + "type": "string" + }, + "targetIdentifier": { + "type": "string" + }, + "cmChangeRequest": { + "type": "object" + } + }, + "required": [ + "targetIdentifier", + "cmChangeRequest" + ] + } + } +} diff --git a/docs/schemas/policy-executor/ncmp-update-schema-1.0.0.json b/docs/schemas/policy-executor/ncmp-update-schema-1.0.0.json new file mode 100644 index 0000000000..0a497e38c5 --- /dev/null +++ b/docs/schemas/policy-executor/ncmp-update-schema-1.0.0.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "urn:cps:org.onap.cps.ncmp.policy-executor:ncmp-update-schema:1.0.0", + "$ref": "#/definitions/NcmpUpdate", + "definitions": { + "NcmpUpdate": { + "type": "object", + "additionalProperties": false, + "properties": { + "cmHandleId": { + "type": "string" + }, + "resourceIdentifier": { + "type": "string" + }, + "targetIdentifier": { + "type": "string" + }, + "cmChangeRequest": { + "type": "object" + } + }, + "required": [ + "targetIdentifier", + "cmChangeRequest" + ] + } + } +} -- cgit 1.2.3-korg