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' |
| 59 | '500': |
| 60 | $ref: '#/components/responses/InternalServerError' |
| 61 | |
| 62 | components: |
| 63 | securitySchemes: |
| 64 | bearerAuth: |
| 65 | type: http |
| 66 | description: "Bearer token (from client that called CPS-NCMP),used by policies to identify the client" |
| 67 | scheme: bearer |
| 68 | schemas: |
| 69 | ErrorMessage: |
| 70 | type: object |
| 71 | title: Error |
| 72 | properties: |
| 73 | status: |
| 74 | type: string |
| 75 | message: |
| 76 | type: string |
| 77 | details: |
| 78 | type: string |
| 79 | |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 80 | Request: |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 81 | type: object |
| 82 | properties: |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 83 | schema: |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 84 | type: string |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 85 | description: "The schema for the data in this request. The schema name should include the type of operation" |
| 86 | example: "org.onap.cps.ncmp.policy-executor:ncmp-create-schema:1.0.0" |
| 87 | data: |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 88 | type: object |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 89 | 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] | 90 | required: |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 91 | - schema |
| 92 | - data |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 93 | |
| 94 | PolicyExecutionRequest: |
| 95 | type: object |
| 96 | properties: |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 97 | decisionType: |
| 98 | type: string |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 99 | description: "The type of decision. Currently supported options: 'allow'" |
| 100 | example: "allow" |
| 101 | requests: |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 102 | type: array |
| 103 | items: |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 104 | $ref: '#/components/schemas/Request' |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 105 | required: |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 106 | - decisionType |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 107 | - requests |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 108 | |
| 109 | PolicyExecutionResponse: |
| 110 | type: object |
| 111 | properties: |
| 112 | decisionId: |
| 113 | type: string |
| 114 | description: "Unique ID for the decision (for auditing purposes)" |
| 115 | example: "550e8400-e29b-41d4-a716-446655440000" |
| 116 | decision: |
| 117 | type: string |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 118 | description: "The decision outcome. Currently supported values: 'allow','deny'" |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 119 | example: "deny" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 120 | message: |
| 121 | type: string |
| 122 | description: "Additional information regarding the decision outcome" |
| 123 | example: "Object locked due to recent change" |
| 124 | required: |
| 125 | - decisionId |
| 126 | - decision |
| 127 | - message |
| 128 | |
| 129 | responses: |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 130 | BadRequest: |
| 131 | description: "Bad request" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 132 | content: |
| 133 | application/json: |
| 134 | schema: |
| 135 | $ref: '#/components/schemas/ErrorMessage' |
| 136 | example: |
ToineSiebelink | 5337582 | 2024-07-29 17:45:52 +0100 | [diff] [blame] | 137 | status: 400 |
| 138 | message: "Bad Request" |
| 139 | details: "The provided request is not valid" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 140 | Unauthorized: |
| 141 | description: "Unauthorized request" |
| 142 | content: |
| 143 | application/json: |
| 144 | schema: |
| 145 | $ref: '#/components/schemas/ErrorMessage' |
| 146 | example: |
| 147 | status: 401 |
| 148 | message: "Unauthorized request" |
| 149 | details: "This request is unauthorized" |
| 150 | Forbidden: |
| 151 | description: "Request forbidden" |
| 152 | content: |
| 153 | application/json: |
| 154 | schema: |
| 155 | $ref: '#/components/schemas/ErrorMessage' |
| 156 | example: |
| 157 | status: 403 |
| 158 | message: "Request Forbidden" |
| 159 | details: "This request is forbidden" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 160 | |
| 161 | InternalServerError: |
| 162 | description: "Internal server error" |
| 163 | content: |
| 164 | application/json: |
| 165 | schema: |
| 166 | $ref: '#/components/schemas/ErrorMessage' |
| 167 | example: |
| 168 | status: 500 |
| 169 | message: "Internal Server Error" |
| 170 | details: "Internal server error occurred" |
| 171 | |
| 172 | NotImplemented: |
| 173 | description: "Method not (yet) implemented" |
| 174 | content: |
| 175 | application/json: |
| 176 | schema: |
| 177 | $ref: '#/components/schemas/ErrorMessage' |
| 178 | example: |
| 179 | status: 501 |
| 180 | message: "Not Implemented" |
| 181 | details: "Method not implemented" |
| 182 | |
| 183 | parameters: |
| 184 | actionInPath: |
| 185 | name: action |
| 186 | in: path |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 187 | description: "The policy action. Currently supported options: 'execute'" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 188 | required: true |
| 189 | schema: |
| 190 | type: string |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 191 | example: "execute" |
| 192 | authorizationInHeader: |
| 193 | name: Authorization |
| 194 | in: header |
ToineSiebelink | 4962922 | 2024-07-10 09:24:22 +0100 | [diff] [blame] | 195 | 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] | 196 | schema: |
| 197 | type: string |
| 198 | |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 199 | security: |
| 200 | - bearerAuth: [] |