Define response objects(schemas) in cps-ncmp
[cps.git] / cps-ncmp-rest / docs / openapi / components.yaml
1 #  ============LICENSE_START=======================================================
2 #  Copyright (C) 2021 Nordix Foundation
3 #  Modifications Copyright (C) 2021 Pantheon.tech
4 #  ================================================================================
5 #  Licensed under the Apache License, Version 2.0 (the "License");
6 #  you may not use this file except in compliance with the License.
7 #  You may obtain a copy of the License at
8 #
9 #        http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #  Unless required by applicable law or agreed to in writing, software
12 #  distributed under the License is distributed on an "AS IS" BASIS,
13 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #  See the License for the specific language governing permissions and
15 #  limitations under the License.
16 #
17 #  SPDX-License-Identifier: Apache-2.0
18 #  ============LICENSE_END=========================================================
19
20 components:
21   schemas:
22     # Common Schemas
23     ErrorMessage:
24       type: object
25       title: Error
26       properties:
27         status:
28           type: string
29         message:
30           type: string
31         details:
32           type: string
33
34     # Request Schemas
35     RestDmiPluginRegistration:
36       type: object
37       properties:
38         dmiPlugin:
39           type: string
40           example: my-dmi-plugin
41         dmiDataPlugin:
42           type: string
43           example: my-dmi-data-plugin
44         dmiModelPlugin:
45           type: string
46           example: my-dmi-model-plugin
47         createdCmHandles:
48           type: array
49           items:
50             $ref: '#/components/schemas/RestCmHandle'
51         updatedCmHandles:
52           type: array
53           items:
54             $ref: '#/components/schemas/RestCmHandle'
55         removedCmHandles:
56           type: array
57           items:
58             type: string
59             example: [my-cm-handle1, my-cm-handle2, my-cm-handle3]
60
61     RestCmHandle:
62       required:
63         - cmHandle
64       type: object
65       properties:
66         cmHandle:
67           type: string
68           example: my-cm-handle
69         cmHandleProperties:
70             $ref: '#/components/schemas/RestCmHandleAdditionalProperties'
71     RestCmHandleAdditionalProperties:
72         type: object
73         additionalProperties:
74             type: string
75             example: my-additional-property
76
77     Conditions:
78       type: object
79       properties:
80         conditions:
81           $ref: '#/components/schemas/ConditionsData'
82     ConditionsData:
83       type: array
84       items:
85         type: object
86         $ref: '#/components/schemas/ConditionProperties'
87     ConditionProperties:
88       properties:
89         name:
90           type: string
91           example: hasAllModules
92         conditionParameters:
93           $ref: '#/components/schemas/ModuleNamesAsJsonArray'
94     ModuleNamesAsJsonArray:
95       type: array
96       items:
97         type: object
98         $ref: '#/components/schemas/ModuleNameAsJsonObject'
99         example: [my-module-1, my-module-2, my-module-3]
100     ModuleNameAsJsonObject:
101         properties:
102           moduleName:
103             type: string
104             example: my-module
105
106     #Response Schemas
107     CmHandles:
108       type: object
109       properties:
110         cmHandles:
111           $ref: '#/components/schemas/CmHandleProperties'
112     CmHandleProperties:
113       type: array
114       items:
115         type: object
116         $ref: '#/components/schemas/CmHandleProperty'
117     CmHandleProperty:
118       properties:
119         cmHandleId:
120           type: string
121           example: my-cm-handle-id
122
123     ModuleReference:
124       type: object
125       title: Module reference details
126       properties:
127         moduleName:
128           type: string
129           example: my-module-name
130         revision:
131           type: string
132           example: my-module-revision
133
134   examples:
135     dataSampleRequest:
136         summary: Sample request
137         description: Sample request body
138         value:
139           test:bookstore:
140             bookstore-name: Chapters
141             categories:
142               - code: '01'
143                 name: SciFi
144                 books:
145                 - authors:
146                     - Iain M. Banks
147                     - Ursula K. Le Guin
148               - code: '02'
149                 name: kids
150                 books:
151                 - authors:
152                     - Philip Pullman
153
154     dataSampleResponse:
155         summary: Sample response
156         description: Sample response for selecting 'sample 1'.
157         value:
158           bookstore:
159             categories:
160               - code: '01'
161                 books:
162                   - authors:
163                       - Iain M. Banks
164                       - Ursula K. Le Guin
165                 name: SciFi
166               - code: '02'
167                 books:
168                   - authors:
169                       - Philip Pullman
170                 name: kids
171
172   parameters:
173     cmHandleInPath:
174       name: cm-handle
175       in: path
176       description: The identifier for a network function, network element, subnetwork or any other cm object by managed Network CM Proxy
177       required: true
178       schema:
179         type: string
180         example: my-cm-handle
181     xpathInQuery:
182       name: xpath
183       in: query
184       description: xpath
185       required: false
186       schema:
187         type: string
188         default: /
189     requiredXpathInQuery:
190       name: xpath
191       in: query
192       description: xpath
193       required: true
194       schema:
195         type: string
196     includeDescendantsOptionInQuery:
197       name: include-descendants
198       in: query
199       description: include-descendants
200       required: false
201       schema:
202         type: boolean
203         default: false
204     cpsPathInQuery:
205       name: cps-path
206       in: query
207       description: cps-path
208       required: false
209       schema:
210         type: string
211         default: /
212     resourceIdentifierInQuery:
213       name: resourceIdentifier
214       in: query
215       description: The format of resource identifier depend on the associated DMI Plugin implementation. For ONAP DMI Plugin it will be RESTConf paths but it can really be anything.
216       required: true
217       allowReserved: true
218       schema:
219         type: string
220       examples:
221         sample 1:
222           value:
223             resourceIdentifier: \shops\bookstore
224         sample 2:
225           value:
226             resourceIdentifier: \shops\bookstore\categories[@code=1]
227         sample 3:
228           value:
229             resourceIdentifier: parent=shops,child=bookstore
230     acceptParamInHeader:
231       name: Accept
232       in: header
233       required: false
234       description: Accept parameter for response, if accept parameter is null, that means client can accept any format.
235       schema:
236         type: string
237         enum: [ application/json, application/yang-data+json ]
238     optionsParamInQuery:
239       name: options
240       in: query
241       description: options parameter in query, it is mandatory to wrap key(s)=value(s) in parenthesis'()'. The format of options parameter depend on the associated DMI Plugin implementation.
242       required: false
243       schema:
244         type: string
245       allowReserved: true
246       examples:
247         sample 1:
248           value:
249             options: (depth=3)
250         sample 2:
251           value:
252             options: (fields=book)
253         sample 3:
254           value:
255             options: (depth=2,fields=book/authors)
256     contentParamInHeader:
257       name: Content-Type
258       in: header
259       required: false
260       description: Content parameter for request, if content parameter is null, default value is application/json.
261       schema:
262         type: string
263         default: application/json
264         example: application/yang-data+json
265
266   responses:
267     NotFound:
268       description: The specified resource was not found
269       content:
270         application/json:
271           schema:
272             $ref: '#/components/schemas/ErrorMessage'
273           example:
274             status: 400
275             message: Not found error message
276             details: Not found error details
277     Unauthorized:
278       description: Unauthorized
279       content:
280         application/json:
281           schema:
282             $ref: '#/components/schemas/ErrorMessage'
283           example:
284             status: 401
285             message: Unauthorized error message
286             details: Unauthorized error details
287     Forbidden:
288       description: Forbidden
289       content:
290         application/json:
291           schema:
292             $ref: '#/components/schemas/ErrorMessage'
293           example:
294            status: 403
295            message: Forbidden error message
296            details: Forbidden error details
297     BadRequest:
298       description: Bad Request
299       content:
300         application/json:
301           schema:
302             $ref: '#/components/schemas/ErrorMessage'
303           example:
304            status: 400 BAD_REQUEST
305            message: Bad request error message
306            details: Bad request error details
307     Conflict:
308       description: Conflict
309       content:
310         application/json:
311           schema:
312             $ref: '#/components/schemas/ErrorMessage'
313           example:
314            status: 409 CONFLICT
315            message: Conflict error message
316            details: Conflict error details
317     NotImplemented:
318       description: The given path has not been implemented
319       content:
320         application/json:
321           schema:
322             $ref: '#/components/schemas/ErrorMessage'
323           example:
324            status: 501
325            message: Not implemented error message
326            details: Not implemented error details
327     Ok:
328       description: OK
329       content:
330         application/json:
331           schema:
332             type: object
333     Created:
334       description: Created
335       content: {}
336     NoContent:
337       description: No Content
338       content: {}