Document ncmp-inventory error code in openapi
[cps.git] / cps-ncmp-rest / docs / openapi / components.yaml
1 #  ============LICENSE_START=======================================================
2 #  Copyright (C) 2021-2022 Nordix Foundation
3 #  Modifications Copyright (C) 2021 Pantheon.tech
4 #  Modifications Copyright (C) 2022 Bell Canada
5 #  ================================================================================
6 #  Licensed under the Apache License, Version 2.0 (the "License");
7 #  you may not use this file except in compliance with the License.
8 #  You may obtain a copy of the License at
9 #
10 #        http://www.apache.org/licenses/LICENSE-2.0
11 #
12 #  Unless required by applicable law or agreed to in writing, software
13 #  distributed under the License is distributed on an "AS IS" BASIS,
14 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 #  See the License for the specific language governing permissions and
16 #  limitations under the License.
17 #
18 #  SPDX-License-Identifier: Apache-2.0
19 #  ============LICENSE_END=========================================================
20
21 components:
22   schemas:
23     # Common Schemas
24     ErrorMessage:
25       type: object
26       title: Error
27       properties:
28         status:
29           type: string
30         message:
31           type: string
32         details:
33           type: string
34     # DMI Server Exception Schema
35     DmiErrorMessage:
36       title: DMI Error Message
37       type: object
38       properties:
39         message:
40           type: string
41           example: "Bad Gateway Error Message NCMP"
42         dmi-response:
43           type: object
44           properties:
45             http-code:
46               type: integer
47               example: 400
48             body:
49               type: string
50               example: Bad Request
51     # Request Schemas
52     RestDmiPluginRegistration:
53       type: object
54       properties:
55         dmiPlugin:
56           type: string
57           example: my-dmi-plugin
58           default: ""
59         dmiDataPlugin:
60           type: string
61           example: my-dmi-data-plugin
62           default: ""
63         dmiModelPlugin:
64           type: string
65           example: my-dmi-model-plugin
66           default: ""
67         createdCmHandles:
68           type: array
69           items:
70             $ref: '#/components/schemas/RestInputCmHandle'
71         updatedCmHandles:
72           type: array
73           items:
74             $ref: '#/components/schemas/RestInputCmHandle'
75             example:
76               cmHandle: my-cm-handle
77               cmHandleProperties:
78                 add-my-property: add-property
79                 update-my-property: updated-property
80                 delete-my-property: '~'
81               publicCmHandleProperties:
82                 add-my-property: add-property
83                 update-my-property: updated-property
84                 delete-my-property: '~'
85         removedCmHandles:
86           type: array
87           items:
88             type: string
89           example: [my-cm-handle1, my-cm-handle2, my-cm-handle3]
90     DmiPluginRegistrationErrorResponse:
91       type: object
92       properties:
93         failedCreatedCmHandles:
94           type: array
95           items:
96             $ref: '#/components/schemas/CmHandlerRegistrationErrorResponse'
97         failedUpdatedCmHandles:
98           type: array
99           items:
100             $ref: '#/components/schemas/CmHandlerRegistrationErrorResponse'
101         failedRemovedCmHandles:
102           type: array
103           items:
104             $ref: '#/components/schemas/CmHandlerRegistrationErrorResponse'
105     CmHandlerRegistrationErrorResponse:
106       type: object
107       properties:
108         cmHandle:
109           type: string
110           example: my-cm-handle
111         errorCode:
112           type: string
113           example: '00'
114         errorText:
115           type: string
116           example: 'Unknown error. <error-details>'
117
118     RestInputCmHandle:
119       required:
120         - cmHandle
121       type: object
122       properties:
123         cmHandle:
124           type: string
125           example: my-cm-handle
126         cmHandleProperties:
127             $ref: '#/components/schemas/RestCmHandleProperties'
128         publicCmHandleProperties:
129             $ref: '#/components/schemas/RestCmHandleProperties'
130     RestCmHandleProperties:
131         type: object
132         additionalProperties:
133             type: string
134             example: my-property
135
136     Conditions:
137       type: object
138       properties:
139         conditions:
140           $ref: '#/components/schemas/ConditionsData'
141     ConditionsData:
142       type: array
143       items:
144         type: object
145         $ref: '#/components/schemas/ConditionProperties'
146     ConditionProperties:
147       properties:
148         name:
149           type: string
150           example: hasAllModules
151         conditionParameters:
152           $ref: '#/components/schemas/ModuleNamesAsJsonArray'
153     ModuleNamesAsJsonArray:
154       type: array
155       items:
156         type: object
157         $ref: '#/components/schemas/ModuleNameAsJsonObject'
158         example: [my-module-1, my-module-2, my-module-3]
159     ModuleNameAsJsonObject:
160         properties:
161           moduleName:
162             type: string
163             example: my-module
164
165     #Response Schemas
166     CmHandles:
167       type: object
168       properties:
169         cmHandles:
170           $ref: '#/components/schemas/CmHandleProperties'
171     CmHandleProperties:
172       type: array
173       items:
174         type: object
175         $ref: '#/components/schemas/CmHandleProperty'
176     CmHandleProperty:
177       properties:
178         cmHandleId:
179           type: string
180           example: my-cm-handle-id
181
182     RestModuleReference:
183       type: object
184       title: Module reference details
185       properties:
186         moduleName:
187           type: string
188           example: my-module-name
189         revision:
190           type: string
191           example: my-module-revision
192
193     CmHandleQueryRestParameters:
194       type: object
195       title: Cm Handle query parameters for executing cm handle search
196       properties:
197         publicCmHandleProperties:
198           type: object
199           additionalProperties:
200             type: string
201             example: Book Type
202
203     RestOutputCmHandle:
204       type: object
205       title: CM handle Details
206       properties:
207         cmHandle:
208           type: string
209           example: my-cm-handle1
210         publicCmHandleProperties:
211           $ref: '#/components/schemas/CmHandlePublicProperties'
212     CmHandlePublicProperties:
213       type: array
214       items:
215         type: object
216         additionalProperties:
217           type: string
218           example: Book Type
219
220   examples:
221     dataSampleRequest:
222         summary: Sample request
223         description: Sample request body
224         value:
225           test:bookstore:
226             bookstore-name: Chapters
227             categories:
228               - code: '01'
229                 name: SciFi
230                 books:
231                 - authors:
232                     - Iain M. Banks
233                     - Ursula K. Le Guin
234               - code: '02'
235                 name: kids
236                 books:
237                 - authors:
238                     - Philip Pullman
239
240     dataSamplePatchRequest:
241       summary: Sample patch request
242       description: Sample patch request body
243       value:
244         ietf-restconf:yang-patch:
245           patch-id: patch-1
246           edit:
247             - edit-id: edit1
248               operation: merge
249               target: /
250               value:
251                 test:bookstore:
252                   bookstore-name: Chapters
253                   categories:
254                     - code: '01'
255                       name: Science
256                       books:
257                         - authors:
258                             - Author1
259                             - Author2
260                     - code: '02'
261                       name: Arts
262                       books:
263                         - authors:
264                             - Author3
265             - edit-id: edit2
266               operation: merge
267               target: /
268               value:
269                 test:bookstore:
270                   bookstore-name: Novels
271                   categories:
272                     - code: '03'
273                       name: History
274                       books:
275                         - authors:
276                             - Iain M. Banks
277                             - Ursula K. Le Guin
278                     - code: '04'
279                       name: Fiction
280                       books:
281                         - authors:
282                             - Philip Pullman
283
284     dataSampleResponse:
285         summary: Sample response
286         description: Sample response for selecting 'sample 1'.
287         value:
288           bookstore:
289             categories:
290               - code: '01'
291                 books:
292                   - authors:
293                       - Iain M. Banks
294                       - Ursula K. Le Guin
295                 name: SciFi
296               - code: '02'
297                 books:
298                   - authors:
299                       - Philip Pullman
300                 name: kids
301
302   parameters:
303     cmHandleInPath:
304       name: cm-handle
305       in: path
306       description: The identifier for a network function, network element, subnetwork or any other cm object by managed Network CM Proxy
307       required: true
308       schema:
309         type: string
310         example: my-cm-handle
311     xpathInQuery:
312       name: xpath
313       in: query
314       description: xpath
315       required: false
316       schema:
317         type: string
318         default: /
319     requiredXpathInQuery:
320       name: xpath
321       in: query
322       description: xpath
323       required: true
324       schema:
325         type: string
326     includeDescendantsOptionInQuery:
327       name: include-descendants
328       in: query
329       description: include-descendants
330       required: false
331       schema:
332         type: boolean
333         default: false
334     cpsPathInQuery:
335       name: cps-path
336       in: query
337       description: cps-path
338       required: false
339       schema:
340         type: string
341         default: /
342     resourceIdentifierInQuery:
343       name: resourceIdentifier
344       in: query
345       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.
346       required: true
347       allowReserved: true
348       schema:
349         type: string
350       examples:
351         sample 1:
352           value:
353             resourceIdentifier: \shops\bookstore
354         sample 2:
355           value:
356             resourceIdentifier: \shops\bookstore\categories[@code=1]
357         sample 3:
358           value:
359             resourceIdentifier: parent=shops,child=bookstore
360     optionsParamInQuery:
361       name: options
362       in: query
363       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.
364       required: false
365       schema:
366         type: string
367       allowReserved: true
368       examples:
369         sample 1:
370           value:
371             options: (depth=3)
372         sample 2:
373           value:
374             options: (fields=book)
375         sample 3:
376           value:
377             options: (depth=2,fields=book/authors)
378     topicParamInQuery:
379       name: topic
380       in: query
381       description: topic parameter in query.
382       required: false
383       schema:
384         type: string
385       allowReserved: true
386       examples:
387         sample 1:
388           value:
389             topic: my-topic-name
390     contentParamInHeader:
391       name: Content-Type
392       in: header
393       required: false
394       description: Content parameter for request, if content parameter is null, default value is application/json.
395       schema:
396         type: string
397         default: application/json
398         example: application/yang-data+json
399
400   responses:
401     NotFound:
402       description: The specified resource was not found
403       content:
404         application/json:
405           schema:
406             $ref: '#/components/schemas/ErrorMessage'
407           example:
408             status: 400
409             message: Not found error message
410             details: Not found error details
411     Unauthorized:
412       description: Unauthorized
413       content:
414         application/json:
415           schema:
416             $ref: '#/components/schemas/ErrorMessage'
417           example:
418             status: 401
419             message: Unauthorized error message
420             details: Unauthorized error details
421     Forbidden:
422       description: Forbidden
423       content:
424         application/json:
425           schema:
426             $ref: '#/components/schemas/ErrorMessage'
427           example:
428            status: 403
429            message: Forbidden error message
430            details: Forbidden error details
431     BadRequest:
432       description: Bad Request
433       content:
434         application/json:
435           schema:
436             $ref: '#/components/schemas/ErrorMessage'
437           example:
438            status: 400 BAD_REQUEST
439            message: Bad request error message
440            details: Bad request error details
441     Conflict:
442       description: Conflict
443       content:
444         application/json:
445           schema:
446             $ref: '#/components/schemas/ErrorMessage'
447           example:
448            status: 409 CONFLICT
449            message: Conflict error message
450            details: Conflict error details
451     NotImplemented:
452       description: The given path has not been implemented
453       content:
454         application/json:
455           schema:
456             $ref: '#/components/schemas/ErrorMessage'
457           example:
458            status: 501
459            message: Not implemented error message
460            details: Not implemented error details
461     Ok:
462       description: OK
463       content:
464         application/json:
465           schema:
466             type: object
467     Created:
468       description: Created
469       content: {}
470     NoContent:
471       description: No Content
472       content: {}
473     InternalServerError:
474       description: Internal Server Error
475       content:
476         application/json:
477           schema:
478             $ref: "#/components/schemas/ErrorMessage"
479           example:
480             status: 500
481             message: Internal Server Error
482             details: Internal Server Error occurred
483     BadGateway:
484       description: Bad Gateway
485       content:
486         application/json:
487           schema:
488             $ref: "#/components/schemas/DmiErrorMessage"
489           example:
490             message: "Bad Gateway Error Message NCMP"
491             dmi-response:
492               http-code: 400
493               body: "Bad Request"