blob: 58ca5acfc5adf54b3e009c36349139523853d9fd [file] [log] [blame]
ToineSiebelink8593bae2024-07-01 17:50:54 +01001# ============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
19openapi: 3.0.3
20info:
21 title: Policy Executor
ToineSiebelinkd7914bc2024-07-04 15:15:36 +010022 description: "Allows NCMP to execute a policy defined by a third party implementation before proceeding with a CM operation"
ToineSiebelink8593bae2024-07-01 17:50:54 +010023 version: 1.0.0
24servers:
ToineSiebelinkd7914bc2024-07-04 15:15:36 +010025 - url: /policy-executor/api
ToineSiebelink8593bae2024-07-01 17:50:54 +010026tags:
27 - name: policy-executor
28 description: "Execute all your policies"
29paths:
ToineSiebelinkd7914bc2024-07-04 15:15:36 +010030 /v1/{action}:
ToineSiebelink8593bae2024-07-01 17:50:54 +010031 post:
32 description: "Fire a Policy action"
33 operationId: executePolicyAction
34 parameters:
ToineSiebelinkd7914bc2024-07-04 15:15:36 +010035 - $ref: '#/components/parameters/authorizationInHeader'
ToineSiebelink8593bae2024-07-01 17:50:54 +010036 - $ref: '#/components/parameters/actionInPath'
37 requestBody:
38 required: true
39 description: "The action request body"
40 content:
ToineSiebelinkd7914bc2024-07-04 15:15:36 +010041 application/json:
ToineSiebelink8593bae2024-07-01 17:50:54 +010042 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'
ToineSiebelink53375822024-07-29 17:45:52 +010055 '401':
56 $ref: '#/components/responses/Unauthorized'
ToineSiebelink8593bae2024-07-01 17:50:54 +010057 '403':
58 $ref: '#/components/responses/Forbidden'
ToineSiebelink53375822024-07-29 17:45:52 +010059 '409':
60 $ref: '#/components/responses/Conflict'
ToineSiebelink8593bae2024-07-01 17:50:54 +010061 '500':
62 $ref: '#/components/responses/InternalServerError'
63
64components:
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
ToineSiebelink53375822024-07-29 17:45:52 +010082 Request:
ToineSiebelink8593bae2024-07-01 17:50:54 +010083 type: object
84 properties:
ToineSiebelink53375822024-07-29 17:45:52 +010085 schema:
ToineSiebelink8593bae2024-07-01 17:50:54 +010086 type: string
ToineSiebelink53375822024-07-29 17:45:52 +010087 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:
ToineSiebelink8593bae2024-07-01 17:50:54 +010090 type: object
ToineSiebelink53375822024-07-29 17:45:52 +010091 description: "The data related to the request. The format of the object is determined by the schema"
ToineSiebelink8593bae2024-07-01 17:50:54 +010092 required:
ToineSiebelink53375822024-07-29 17:45:52 +010093 - schema
94 - data
ToineSiebelink8593bae2024-07-01 17:50:54 +010095
96 PolicyExecutionRequest:
97 type: object
98 properties:
ToineSiebelink8593bae2024-07-01 17:50:54 +010099 decisionType:
100 type: string
ToineSiebelink53375822024-07-29 17:45:52 +0100101 description: "The type of decision. Currently supported options: 'allow'"
102 example: "allow"
103 requests:
ToineSiebelink8593bae2024-07-01 17:50:54 +0100104 type: array
105 items:
ToineSiebelink53375822024-07-29 17:45:52 +0100106 $ref: '#/components/schemas/Request'
ToineSiebelink8593bae2024-07-01 17:50:54 +0100107 required:
ToineSiebelink8593bae2024-07-01 17:50:54 +0100108 - decisionType
ToineSiebelink53375822024-07-29 17:45:52 +0100109 - requests
ToineSiebelink8593bae2024-07-01 17:50:54 +0100110
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
ToineSiebelink53375822024-07-29 17:45:52 +0100120 description: "The decision outcome. Currently supported values: 'allow','deny'"
ToineSiebelinkd7914bc2024-07-04 15:15:36 +0100121 example: "deny"
ToineSiebelink8593bae2024-07-01 17:50:54 +0100122 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:
ToineSiebelink53375822024-07-29 17:45:52 +0100132 BadRequest:
133 description: "Bad request"
ToineSiebelink8593bae2024-07-01 17:50:54 +0100134 content:
135 application/json:
136 schema:
137 $ref: '#/components/schemas/ErrorMessage'
138 example:
ToineSiebelink53375822024-07-29 17:45:52 +0100139 status: 400
140 message: "Bad Request"
141 details: "The provided request is not valid"
ToineSiebelink8593bae2024-07-01 17:50:54 +0100142 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"
ToineSiebelink53375822024-07-29 17:45:52 +0100162 Conflict:
163 description: "Conflict"
ToineSiebelink8593bae2024-07-01 17:50:54 +0100164 content:
165 application/json:
166 schema:
167 $ref: '#/components/schemas/ErrorMessage'
168 example:
ToineSiebelink53375822024-07-29 17:45:52 +0100169 status: 409
170 message: "Conflict"
171 details: "The provided request violates a policy rule"
ToineSiebelink8593bae2024-07-01 17:50:54 +0100172
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
ToineSiebelinkd7914bc2024-07-04 15:15:36 +0100199 description: "The policy action. Currently supported options: 'execute'"
ToineSiebelink8593bae2024-07-01 17:50:54 +0100200 required: true
201 schema:
202 type: string
ToineSiebelinkd7914bc2024-07-04 15:15:36 +0100203 example: "execute"
204 authorizationInHeader:
205 name: Authorization
206 in: header
ToineSiebelink49629222024-07-10 09:24:22 +0100207 description: "Bearer token may be used to identify client as part of a policy"
ToineSiebelinkd7914bc2024-07-04 15:15:36 +0100208 schema:
209 type: string
210
ToineSiebelink8593bae2024-07-01 17:50:54 +0100211security:
212 - bearerAuth: []