ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 1 | # ============LICENSE_START======================================================= |
| 2 | # Copyright (C) 2024 Nordix Foundation |
| 3 | # ================================================================================ |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | # SPDX-License-Identifier: Apache-2.0 |
| 17 | # ============LICENSE_END========================================================= |
| 18 | |
| 19 | openapi: 3.0.3 |
| 20 | info: |
| 21 | title: Policy Executor |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 22 | description: "Allows NCMP to execute a policy defined by a third party implementation before proceeding with a CM operation" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 23 | version: 1.0.0 |
| 24 | servers: |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 25 | - url: /policy-executor/api |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 26 | tags: |
| 27 | - name: policy-executor |
| 28 | description: "Execute all your policies" |
| 29 | paths: |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 30 | /v1/{action}: |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 31 | post: |
| 32 | description: "Fire a Policy action" |
| 33 | operationId: executePolicyAction |
| 34 | parameters: |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 35 | - $ref: '#/components/parameters/authorizationInHeader' |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 36 | - $ref: '#/components/parameters/actionInPath' |
| 37 | requestBody: |
| 38 | required: true |
| 39 | description: "The action request body" |
| 40 | content: |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 41 | application/json: |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 42 | schema: |
| 43 | $ref: '#/components/schemas/PolicyExecutionRequest' |
| 44 | tags: |
| 45 | - policy-executor |
| 46 | responses: |
| 47 | '200': |
| 48 | description: "Successful policy execution" |
| 49 | content: |
| 50 | application/json: |
| 51 | schema: |
| 52 | $ref: '#/components/schemas/PolicyExecutionResponse' |
| 53 | '400': |
| 54 | $ref: '#/components/responses/BadRequest' |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 55 | '401': |
| 56 | $ref: '#/components/responses/Unauthorized' |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 57 | '403': |
| 58 | $ref: '#/components/responses/Forbidden' |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 59 | '409': |
| 60 | $ref: '#/components/responses/Conflict' |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 61 | '500': |
| 62 | $ref: '#/components/responses/InternalServerError' |
| 63 | |
| 64 | components: |
| 65 | securitySchemes: |
| 66 | bearerAuth: |
| 67 | type: http |
| 68 | description: "Bearer token (from client that called CPS-NCMP),used by policies to identify the client" |
| 69 | scheme: bearer |
| 70 | schemas: |
| 71 | ErrorMessage: |
| 72 | type: object |
| 73 | title: Error |
| 74 | properties: |
| 75 | status: |
| 76 | type: string |
| 77 | message: |
| 78 | type: string |
| 79 | details: |
| 80 | type: string |
| 81 | |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 82 | Request: |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 83 | type: object |
| 84 | properties: |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 85 | schema: |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 86 | type: string |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 87 | description: "The schema for the data in this request. The schema name should include the type of operation" |
| 88 | example: "org.onap.cps.ncmp.policy-executor:ncmp-create-schema:1.0.0" |
| 89 | data: |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 90 | type: object |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 91 | description: "The data related to the request. The format of the object is determined by the schema" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 92 | required: |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 93 | - schema |
| 94 | - data |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 95 | |
| 96 | PolicyExecutionRequest: |
| 97 | type: object |
| 98 | properties: |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 99 | decisionType: |
| 100 | type: string |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 101 | description: "The type of decision. Currently supported options: 'allow'" |
| 102 | example: "allow" |
| 103 | requests: |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 104 | type: array |
| 105 | items: |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 106 | $ref: '#/components/schemas/Request' |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 107 | required: |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 108 | - decisionType |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 109 | - requests |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 110 | |
| 111 | PolicyExecutionResponse: |
| 112 | type: object |
| 113 | properties: |
| 114 | decisionId: |
| 115 | type: string |
| 116 | description: "Unique ID for the decision (for auditing purposes)" |
| 117 | example: "550e8400-e29b-41d4-a716-446655440000" |
| 118 | decision: |
| 119 | type: string |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 120 | description: "The decision outcome. Currently supported values: 'allow','deny'" |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 121 | example: "deny" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 122 | message: |
| 123 | type: string |
| 124 | description: "Additional information regarding the decision outcome" |
| 125 | example: "Object locked due to recent change" |
| 126 | required: |
| 127 | - decisionId |
| 128 | - decision |
| 129 | - message |
| 130 | |
| 131 | responses: |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 132 | BadRequest: |
| 133 | description: "Bad request" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 134 | content: |
| 135 | application/json: |
| 136 | schema: |
| 137 | $ref: '#/components/schemas/ErrorMessage' |
| 138 | example: |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 139 | status: 400 |
| 140 | message: "Bad Request" |
| 141 | details: "The provided request is not valid" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 142 | Unauthorized: |
| 143 | description: "Unauthorized request" |
| 144 | content: |
| 145 | application/json: |
| 146 | schema: |
| 147 | $ref: '#/components/schemas/ErrorMessage' |
| 148 | example: |
| 149 | status: 401 |
| 150 | message: "Unauthorized request" |
| 151 | details: "This request is unauthorized" |
| 152 | Forbidden: |
| 153 | description: "Request forbidden" |
| 154 | content: |
| 155 | application/json: |
| 156 | schema: |
| 157 | $ref: '#/components/schemas/ErrorMessage' |
| 158 | example: |
| 159 | status: 403 |
| 160 | message: "Request Forbidden" |
| 161 | details: "This request is forbidden" |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 162 | Conflict: |
| 163 | description: "Conflict" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 164 | content: |
| 165 | application/json: |
| 166 | schema: |
| 167 | $ref: '#/components/schemas/ErrorMessage' |
| 168 | example: |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 169 | status: 409 |
| 170 | message: "Conflict" |
| 171 | details: "The provided request violates a policy rule" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 172 | |
| 173 | InternalServerError: |
| 174 | description: "Internal server error" |
| 175 | content: |
| 176 | application/json: |
| 177 | schema: |
| 178 | $ref: '#/components/schemas/ErrorMessage' |
| 179 | example: |
| 180 | status: 500 |
| 181 | message: "Internal Server Error" |
| 182 | details: "Internal server error occurred" |
| 183 | |
| 184 | NotImplemented: |
| 185 | description: "Method not (yet) implemented" |
| 186 | content: |
| 187 | application/json: |
| 188 | schema: |
| 189 | $ref: '#/components/schemas/ErrorMessage' |
| 190 | example: |
| 191 | status: 501 |
| 192 | message: "Not Implemented" |
| 193 | details: "Method not implemented" |
| 194 | |
| 195 | parameters: |
| 196 | actionInPath: |
| 197 | name: action |
| 198 | in: path |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 199 | description: "The policy action. Currently supported options: 'execute'" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 200 | required: true |
| 201 | schema: |
| 202 | type: string |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 203 | example: "execute" |
| 204 | authorizationInHeader: |
| 205 | name: Authorization |
| 206 | in: header |
ToineSiebelink | 4962922 | 2024-07-10 09:24:22 +0100 | [diff] [blame] | 207 | description: "Bearer token may be used to identify client as part of a policy" |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 208 | schema: |
| 209 | type: string |
| 210 | |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 211 | security: |
| 212 | - bearerAuth: [] |