4d64b01b859ceb1c18592e1c71251e8a8256c779
[cps.git] / docs / api / swagger / openapi.yml
1 #  ============LICENSE_START=======================================================
2 #  Copyright (C) 2021 Nordix Foundation
3 #  Modifications Copyright (C) 2021 Bell Canada.
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 openapi: 3.0.1
21 info:
22   title: ONAP Open API v3 Configuration Persistence Service
23   description: Configuration Persistence Service is a Model Driven Generic Database
24   version: 1.0.0
25   contact:
26     name: ONAP
27     url: 'https://onap.readthedocs.io'
28     email: onap-discuss@lists.onap.org
29   license:
30     name: Apache 2.0
31     url: 'http://www.apache.org/licenses/LICENSE-2.0'
32   x-planned-retirement-date: '202212'
33   x-component: Modeling
34   x-logo:
35     url: cps_logo.png
36 servers:
37   - url: '//localhost:8088'
38 tags:
39   - name: cps-admin
40     description: cps Admin
41   - name: cps-data
42     description: cps Data
43 paths:
44   /v1/dataspaces:
45     post:
46       description: Create a new dataspace
47       tags:
48         - cps-admin
49       summary: Create a dataspace
50       operationId: createDataspace
51       parameters:
52         - name: dataspace-name
53           in: query
54           description: dataspace-name
55           required: true
56           schema:
57             type: string
58       responses:
59         '201':
60           description: Created
61           content:
62             text/plain:
63               schema:
64                 type: string
65         '400':
66           description: Bad Request
67           content:
68             application/json:
69               schema:
70                 $ref: '#/components/schemas/ErrorMessage'
71         '401':
72           description: Unauthorized
73           content:
74             application/json:
75               schema:
76                 $ref: '#/components/schemas/ErrorMessage'
77         '403':
78           description: Forbidden
79           content:
80             application/json:
81               schema:
82                 $ref: '#/components/schemas/ErrorMessage'
83   '/v1/dataspaces/{dataspace-name}':
84     delete:
85       description: Delete the given dataspace - DRAFT
86       tags:
87         - cps-admin
88       summary: Delete a dataspace
89       operationId: deleteDataspace
90       parameters:
91         - name: dataspace-name
92           in: path
93           description: dataspace-name
94           required: true
95           schema:
96             type: string
97       responses:
98         '200':
99           description: OK
100           content:
101             application/json:
102               schema:
103                 type: object
104         '204':
105           description: No Content
106           content: {}
107         '400':
108           description: Bad Request
109           content:
110             application/json:
111               schema:
112                 $ref: '#/components/schemas/ErrorMessage'
113         '401':
114           description: Unauthorized
115           content:
116             application/json:
117               schema:
118                 $ref: '#/components/schemas/ErrorMessage'
119         '403':
120           description: Forbidden
121           content:
122             application/json:
123               schema:
124                 $ref: '#/components/schemas/ErrorMessage'
125   '/v1/dataspaces/{dataspace-name}/anchors':
126     get:
127       description: 'Read all anchors, given a dataspace'
128       tags:
129         - cps-admin
130       summary: Get anchors
131       operationId: getAnchors
132       parameters:
133         - name: dataspace-name
134           in: path
135           description: dataspace-name
136           required: true
137           schema:
138             type: string
139       responses:
140         '200':
141           description: OK
142           content:
143             application/json:
144               schema:
145                 type: object
146         '400':
147           description: Bad Request
148           content:
149             application/json:
150               schema:
151                 $ref: '#/components/schemas/ErrorMessage'
152         '401':
153           description: Unauthorized
154           content:
155             application/json:
156               schema:
157                 $ref: '#/components/schemas/ErrorMessage'
158         '403':
159           description: Forbidden
160           content:
161             application/json:
162               schema:
163                 $ref: '#/components/schemas/ErrorMessage'
164         '404':
165           description: The specified resource was not found
166           content:
167             application/json:
168               schema:
169                 $ref: '#/components/schemas/ErrorMessage'
170     post:
171       description: Create a new anchor in the given dataspace
172       tags:
173         - cps-admin
174       summary: Create an anchor
175       operationId: createAnchor
176       parameters:
177         - name: dataspace-name
178           in: path
179           description: dataspace-name
180           required: true
181           schema:
182             type: string
183         - name: schema-set-name
184           in: query
185           description: schema-set-name
186           required: true
187           schema:
188             type: string
189         - name: anchor-name
190           in: query
191           description: anchor-name
192           required: true
193           schema:
194             type: string
195       responses:
196         '201':
197           description: Created
198           content:
199             text/plain:
200               schema:
201                 type: string
202         '400':
203           description: Bad Request
204           content:
205             application/json:
206               schema:
207                 $ref: '#/components/schemas/ErrorMessage'
208         '401':
209           description: Unauthorized
210           content:
211             application/json:
212               schema:
213                 $ref: '#/components/schemas/ErrorMessage'
214         '403':
215           description: Forbidden
216           content:
217             application/json:
218               schema:
219                 $ref: '#/components/schemas/ErrorMessage'
220   '/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}':
221     get:
222       description: Read an anchor given an anchor name and a dataspace
223       tags:
224         - cps-admin
225       summary: Get an anchor
226       operationId: getAnchor
227       parameters:
228         - name: dataspace-name
229           in: path
230           description: dataspace-name
231           required: true
232           schema:
233             type: string
234         - name: anchor-name
235           in: path
236           description: anchor-name
237           required: true
238           schema:
239             type: string
240       responses:
241         '200':
242           description: OK
243           content:
244             application/json:
245               schema:
246                 type: object
247         '400':
248           description: Bad Request
249           content:
250             application/json:
251               schema:
252                 $ref: '#/components/schemas/ErrorMessage'
253         '401':
254           description: Unauthorized
255           content:
256             application/json:
257               schema:
258                 $ref: '#/components/schemas/ErrorMessage'
259         '403':
260           description: Forbidden
261           content:
262             application/json:
263               schema:
264                 $ref: '#/components/schemas/ErrorMessage'
265         '404':
266           description: The specified resource was not found
267           content:
268             application/json:
269               schema:
270                 $ref: '#/components/schemas/ErrorMessage'
271     delete:
272       description: Delete an anchor given an anchor name and a dataspace - DRAFT
273       tags:
274         - cps-admin
275       summary: Delete an anchor
276       operationId: deleteAnchor
277       parameters:
278         - name: dataspace-name
279           in: path
280           description: dataspace-name
281           required: true
282           schema:
283             type: string
284         - name: anchor-name
285           in: path
286           description: anchor-name
287           required: true
288           schema:
289             type: string
290       responses:
291         '200':
292           description: OK
293           content:
294             application/json:
295               schema:
296                 type: object
297         '204':
298           description: No Content
299           content: {}
300         '400':
301           description: Bad Request
302           content:
303             application/json:
304               schema:
305                 $ref: '#/components/schemas/ErrorMessage'
306         '401':
307           description: Unauthorized
308           content:
309             application/json:
310               schema:
311                 $ref: '#/components/schemas/ErrorMessage'
312         '403':
313           description: Forbidden
314           content:
315             application/json:
316               schema:
317                 $ref: '#/components/schemas/ErrorMessage'
318   '/v1/dataspaces/{dataspace-name}/schema-sets':
319     post:
320       description: Create a new schema set in the given dataspace
321       tags:
322         - cps-admin
323       summary: Create a schema set
324       operationId: createSchemaSet
325       parameters:
326         - name: dataspace-name
327           in: path
328           description: dataspace-name
329           required: true
330           schema:
331             type: string
332         - name: schema-set-name
333           in: query
334           description: schema-set-name
335           required: true
336           schema:
337             type: string
338       requestBody:
339         required: true
340         content:
341           multipart/form-data:
342             schema:
343               type: object
344               required:
345                 - file
346               properties:
347                 file:
348                   type: string
349                   description: multipartFile
350                   format: binary
351                   example: 'http://example.com/examples/example.yang'
352       responses:
353         '201':
354           description: Created
355           content:
356             text/plain:
357               schema:
358                 type: string
359         '400':
360           description: Bad Request
361           content:
362             application/json:
363               schema:
364                 $ref: '#/components/schemas/ErrorMessage'
365         '401':
366           description: Unauthorized
367           content:
368             application/json:
369               schema:
370                 $ref: '#/components/schemas/ErrorMessage'
371         '403':
372           description: Forbidden
373           content:
374             application/json:
375               schema:
376                 $ref: '#/components/schemas/ErrorMessage'
377   '/v1/dataspaces/{dataspace-name}/schema-sets/{schema-set-name}':
378     get:
379       description: Read a schema set given a schema set name and a dataspace
380       tags:
381         - cps-admin
382       summary: Get a schema set
383       operationId: getSchemaSet
384       parameters:
385         - name: dataspace-name
386           in: path
387           description: dataspace-name
388           required: true
389           schema:
390             type: string
391         - name: schema-set-name
392           in: path
393           description: schema-set-name
394           required: true
395           schema:
396             type: string
397       responses:
398         '200':
399           description: OK
400           content:
401             application/json:
402               schema:
403                 type: object
404         '400':
405           description: Bad Request
406           content:
407             application/json:
408               schema:
409                 $ref: '#/components/schemas/ErrorMessage'
410         '401':
411           description: Unauthorized
412           content:
413             application/json:
414               schema:
415                 $ref: '#/components/schemas/ErrorMessage'
416         '403':
417           description: Forbidden
418           content:
419             application/json:
420               schema:
421                 $ref: '#/components/schemas/ErrorMessage'
422         '404':
423           description: The specified resource was not found
424           content:
425             application/json:
426               schema:
427                 $ref: '#/components/schemas/ErrorMessage'
428     delete:
429       description: Delete a schema set given a schema set name and a dataspace
430       tags:
431         - cps-admin
432       summary: Delete a schema set
433       operationId: deleteSchemaSet
434       parameters:
435         - name: dataspace-name
436           in: path
437           description: dataspace-name
438           required: true
439           schema:
440             type: string
441         - name: schema-set-name
442           in: path
443           description: schema-set-name
444           required: true
445           schema:
446             type: string
447       responses:
448         '204':
449           description: No Content
450           content: {}
451         '400':
452           description: Bad Request
453           content:
454             application/json:
455               schema:
456                 $ref: '#/components/schemas/ErrorMessage'
457         '401':
458           description: Unauthorized
459           content:
460             application/json:
461               schema:
462                 $ref: '#/components/schemas/ErrorMessage'
463         '403':
464           description: Forbidden
465           content:
466             application/json:
467               schema:
468                 $ref: '#/components/schemas/ErrorMessage'
469         '409':
470           description: Conflict
471           content:
472             application/json:
473               schema:
474                 $ref: '#/components/schemas/ErrorMessage'
475   '/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/node':
476     get:
477       description: >-
478         Get a node with an option to retrieve all the children for a given
479         anchor and dataspace
480       tags:
481         - cps-data
482       summary: Get a node
483       operationId: getNodeByDataspaceAndAnchor
484       parameters:
485         - name: dataspace-name
486           in: path
487           description: dataspace-name
488           required: true
489           schema:
490             type: string
491         - name: anchor-name
492           in: path
493           description: anchor-name
494           required: true
495           schema:
496             type: string
497         - name: xpath
498           in: query
499           description: xpath
500           required: false
501           schema:
502             type: string
503             default: /
504         - name: include-descendants
505           in: query
506           description: include-descendants
507           required: false
508           schema:
509             type: boolean
510             default: false
511       responses:
512         '200':
513           description: OK
514           content:
515             application/json:
516               schema:
517                 type: object
518         '400':
519           description: Bad Request
520           content:
521             application/json:
522               schema:
523                 $ref: '#/components/schemas/ErrorMessage'
524         '401':
525           description: Unauthorized
526           content:
527             application/json:
528               schema:
529                 $ref: '#/components/schemas/ErrorMessage'
530         '403':
531           description: Forbidden
532           content:
533             application/json:
534               schema:
535                 $ref: '#/components/schemas/ErrorMessage'
536         '404':
537           description: The specified resource was not found
538           content:
539             application/json:
540               schema:
541                 $ref: '#/components/schemas/ErrorMessage'
542       x-codegen-request-body-name: xpath
543   '/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes':
544     post:
545       description: Create a node for a given anchor and dataspace
546       tags:
547         - cps-data
548       summary: Create a node
549       operationId: createNode
550       parameters:
551         - name: dataspace-name
552           in: path
553           description: dataspace-name
554           required: true
555           schema:
556             type: string
557         - name: anchor-name
558           in: path
559           description: anchor-name
560           required: true
561           schema:
562             type: string
563       requestBody:
564         required: true
565         content:
566           application/json:
567             schema:
568               type: string
569       responses:
570         '201':
571           description: Created
572           content:
573             text/plain:
574               schema:
575                 type: string
576         '400':
577           description: Bad Request
578           content:
579             application/json:
580               schema:
581                 $ref: '#/components/schemas/ErrorMessage'
582         '401':
583           description: Unauthorized
584           content:
585             application/json:
586               schema:
587                 $ref: '#/components/schemas/ErrorMessage'
588         '403':
589           description: Forbidden
590           content:
591             application/json:
592               schema:
593                 $ref: '#/components/schemas/ErrorMessage'
594     patch:
595       description: >-
596         Update a data node leaves for a given dataspace and anchor and a parent
597         node xpath
598       tags:
599         - cps-data
600       summary: Update node leaves
601       operationId: updateNodeLeaves
602       parameters:
603         - name: dataspace-name
604           in: path
605           description: dataspace-name
606           required: true
607           schema:
608             type: string
609         - name: anchor-name
610           in: path
611           description: anchor-name
612           required: true
613           schema:
614             type: string
615         - name: xpath
616           in: query
617           description: xpath
618           required: false
619           schema:
620             type: string
621             default: /
622       requestBody:
623         required: true
624         content:
625           application/json:
626             schema:
627               type: string
628       responses:
629         '200':
630           description: OK
631           content:
632             application/json:
633               schema:
634                 type: object
635         '400':
636           description: Bad Request
637           content:
638             application/json:
639               schema:
640                 $ref: '#/components/schemas/ErrorMessage'
641         '401':
642           description: Unauthorized
643           content:
644             application/json:
645               schema:
646                 $ref: '#/components/schemas/ErrorMessage'
647         '403':
648           description: Forbidden
649           content:
650             application/json:
651               schema:
652                 $ref: '#/components/schemas/ErrorMessage'
653     put:
654       description: >-
655         Replace a node with descendants for a given dataspace, anchor and a
656         parent node xpath
657       tags:
658         - cps-data
659       summary: Replace a node with descendants
660       operationId: replaceNode
661       parameters:
662         - name: dataspace-name
663           in: path
664           description: dataspace-name
665           required: true
666           schema:
667             type: string
668         - name: anchor-name
669           in: path
670           description: anchor-name
671           required: true
672           schema:
673             type: string
674         - name: xpath
675           in: query
676           description: xpath
677           required: false
678           schema:
679             type: string
680             default: /
681       requestBody:
682         required: true
683         content:
684           application/json:
685             schema:
686               type: string
687       responses:
688         '200':
689           description: OK
690           content:
691             application/json:
692               schema:
693                 type: object
694         '400':
695           description: Bad Request
696           content:
697             application/json:
698               schema:
699                 $ref: '#/components/schemas/ErrorMessage'
700         '401':
701           description: Unauthorized
702           content:
703             application/json:
704               schema:
705                 $ref: '#/components/schemas/ErrorMessage'
706         '403':
707           description: Forbidden
708           content:
709             application/json:
710               schema:
711                 $ref: '#/components/schemas/ErrorMessage'
712   '/v1/dataspaces/{dataspace-name}/nodes':
713     get:
714       description: >-
715         Get all nodes for a given dataspace using an xpath or schema node
716         identifier - DRAFT
717       tags:
718         - cps-data
719       summary: Get nodes
720       operationId: getNodesByDataspace
721       parameters:
722         - name: dataspace-name
723           in: path
724           description: dataspace-name
725           required: true
726           schema:
727             type: string
728       responses:
729         '200':
730           description: OK
731           content:
732             application/json:
733               schema:
734                 type: object
735         '400':
736           description: Bad Request
737           content:
738             application/json:
739               schema:
740                 $ref: '#/components/schemas/ErrorMessage'
741         '401':
742           description: Unauthorized
743           content:
744             application/json:
745               schema:
746                 $ref: '#/components/schemas/ErrorMessage'
747         '403':
748           description: Forbidden
749           content:
750             application/json:
751               schema:
752                 $ref: '#/components/schemas/ErrorMessage'
753         '404':
754           description: The specified resource was not found
755           content:
756             application/json:
757               schema:
758                 $ref: '#/components/schemas/ErrorMessage'
759       x-codegen-request-body-name: requestBody
760   '/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes/query':
761     get:
762       description: Query data nodes for the given dataspace and anchor using CPS path
763       tags:
764         - cps-query
765       summary: Query data nodes
766       operationId: getNodesByDataspaceAndAnchorAndCpsPath
767       parameters:
768         - name: dataspace-name
769           in: path
770           description: dataspace-name
771           required: true
772           schema:
773             type: string
774         - name: anchor-name
775           in: path
776           description: anchor-name
777           required: true
778           schema:
779             type: string
780         - name: cps-path
781           in: query
782           description: cps-path
783           required: false
784           schema:
785             type: string
786             default: /
787         - name: include-descendants
788           in: query
789           description: include-descendants
790           required: false
791           schema:
792             type: boolean
793             default: false
794       responses:
795         '200':
796           description: OK
797           content:
798             application/json:
799               schema:
800                 type: object
801         '400':
802           description: Bad Request
803           content:
804             application/json:
805               schema:
806                 $ref: '#/components/schemas/ErrorMessage'
807         '401':
808           description: Unauthorized
809           content:
810             application/json:
811               schema:
812                 $ref: '#/components/schemas/ErrorMessage'
813         '403':
814           description: Forbidden
815           content:
816             application/json:
817               schema:
818                 $ref: '#/components/schemas/ErrorMessage'
819         '404':
820           description: The specified resource was not found
821           content:
822             application/json:
823               schema:
824                 $ref: '#/components/schemas/ErrorMessage'
825       x-codegen-request-body-name: xpath
826 components:
827   schemas:
828     ErrorMessage:
829       type: object
830       title: Error
831       properties:
832         status:
833           type: string
834           example: 400
835         message:
836           type: string
837           example: Dataspace not found
838         details:
839           type: string
840           example: Dataspace with name D1 does not exist.