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' |
| 55 | '403': |
| 56 | $ref: '#/components/responses/Forbidden' |
| 57 | '500': |
| 58 | $ref: '#/components/responses/InternalServerError' |
| 59 | |
| 60 | components: |
| 61 | securitySchemes: |
| 62 | bearerAuth: |
| 63 | type: http |
| 64 | description: "Bearer token (from client that called CPS-NCMP),used by policies to identify the client" |
| 65 | scheme: bearer |
| 66 | schemas: |
| 67 | ErrorMessage: |
| 68 | type: object |
| 69 | title: Error |
| 70 | properties: |
| 71 | status: |
| 72 | type: string |
| 73 | message: |
| 74 | type: string |
| 75 | details: |
| 76 | type: string |
| 77 | |
| 78 | Payload: |
| 79 | type: object |
| 80 | properties: |
| 81 | targetFdn: |
| 82 | type: string |
| 83 | description: "The complete FDN (Fully Distinguished Name) for the element to be changed" |
| 84 | example: "/Subnetwork=Ireland/MeContext=Athlone/ManagedElement=Athlone/SomeFunction=1/Cell=12" |
| 85 | cmHandleId: |
| 86 | type: string |
| 87 | description: "The CM handle ID (optional)" |
| 88 | example: "F811AF64F5146DFC545EC60B73DE948E" |
| 89 | resourceIdentifier: |
| 90 | type: string |
| 91 | description: "The resource identifier (optional)" |
| 92 | example: "ManagedElement=Athlone/SomeFunction=1/Cell=12" |
| 93 | cmChangeRequest: |
| 94 | type: object |
| 95 | description: "The content of the change to be made" |
| 96 | example: '{"Cell":[{"id":"Cell-id","attributes":{"administrativeState":"UNLOCKED"}}]}' |
| 97 | required: |
| 98 | - targetFdn |
| 99 | - cmChangeRequest |
| 100 | |
| 101 | PolicyExecutionRequest: |
| 102 | type: object |
| 103 | properties: |
| 104 | payloadType: |
| 105 | type: string |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 106 | description: "The type of payload. Currently supported options: 'cm_write'" |
| 107 | example: "cm_write" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 108 | decisionType: |
| 109 | type: string |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 110 | description: "The type of decision. Currently supported options: 'permit'" |
| 111 | example: "permit" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 112 | payload: |
| 113 | type: array |
| 114 | items: |
| 115 | $ref: '#/components/schemas/Payload' |
| 116 | required: |
| 117 | - payloadType |
| 118 | - decisionType |
| 119 | - payload |
| 120 | |
| 121 | PolicyExecutionResponse: |
| 122 | type: object |
| 123 | properties: |
| 124 | decisionId: |
| 125 | type: string |
| 126 | description: "Unique ID for the decision (for auditing purposes)" |
| 127 | example: "550e8400-e29b-41d4-a716-446655440000" |
| 128 | decision: |
| 129 | type: string |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 130 | description: "The decision outcome. Currently supported values: 'permit','deny'" |
| 131 | example: "deny" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 132 | message: |
| 133 | type: string |
| 134 | description: "Additional information regarding the decision outcome" |
| 135 | example: "Object locked due to recent change" |
| 136 | required: |
| 137 | - decisionId |
| 138 | - decision |
| 139 | - message |
| 140 | |
| 141 | responses: |
| 142 | NotFound: |
| 143 | description: "The specified resource was not found" |
| 144 | content: |
| 145 | application/json: |
| 146 | schema: |
| 147 | $ref: '#/components/schemas/ErrorMessage' |
| 148 | example: |
| 149 | status: 404 |
| 150 | message: "Resource Not Found" |
| 151 | details: "The requested resource is not found" |
| 152 | Unauthorized: |
| 153 | description: "Unauthorized request" |
| 154 | content: |
| 155 | application/json: |
| 156 | schema: |
| 157 | $ref: '#/components/schemas/ErrorMessage' |
| 158 | example: |
| 159 | status: 401 |
| 160 | message: "Unauthorized request" |
| 161 | details: "This request is unauthorized" |
| 162 | Forbidden: |
| 163 | description: "Request forbidden" |
| 164 | content: |
| 165 | application/json: |
| 166 | schema: |
| 167 | $ref: '#/components/schemas/ErrorMessage' |
| 168 | example: |
| 169 | status: 403 |
| 170 | message: "Request Forbidden" |
| 171 | details: "This request is forbidden" |
| 172 | BadRequest: |
| 173 | description: "Bad request" |
| 174 | content: |
| 175 | application/json: |
| 176 | schema: |
| 177 | $ref: '#/components/schemas/ErrorMessage' |
| 178 | example: |
| 179 | status: 400 |
| 180 | message: "Bad Request" |
| 181 | details: "The provided request is not valid" |
| 182 | |
| 183 | InternalServerError: |
| 184 | description: "Internal server error" |
| 185 | content: |
| 186 | application/json: |
| 187 | schema: |
| 188 | $ref: '#/components/schemas/ErrorMessage' |
| 189 | example: |
| 190 | status: 500 |
| 191 | message: "Internal Server Error" |
| 192 | details: "Internal server error occurred" |
| 193 | |
| 194 | NotImplemented: |
| 195 | description: "Method not (yet) implemented" |
| 196 | content: |
| 197 | application/json: |
| 198 | schema: |
| 199 | $ref: '#/components/schemas/ErrorMessage' |
| 200 | example: |
| 201 | status: 501 |
| 202 | message: "Not Implemented" |
| 203 | details: "Method not implemented" |
| 204 | |
| 205 | parameters: |
| 206 | actionInPath: |
| 207 | name: action |
| 208 | in: path |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 209 | description: "The policy action. Currently supported options: 'execute'" |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 210 | required: true |
| 211 | schema: |
| 212 | type: string |
ToineSiebelink | d7914bc | 2024-07-04 15:15:36 +0100 | [diff] [blame] | 213 | example: "execute" |
| 214 | authorizationInHeader: |
| 215 | name: Authorization |
| 216 | in: header |
ToineSiebelink | 4962922 | 2024-07-10 09:24:22 +0100 | [diff] [blame] | 217 | 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] | 218 | schema: |
| 219 | type: string |
| 220 | |
ToineSiebelink | 8593bae | 2024-07-01 17:50:54 +0100 | [diff] [blame] | 221 | security: |
| 222 | - bearerAuth: [] |