Revert "Create folder structure in backend for onboarded descriptor - RIFT 15317"
[osm/SO.git] / rwlaunchpad / plugins / yang / rw-pkg-mgmt.yang
1 /*
2  *
3  *   Copyright 2016 RIFT.IO Inc
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  *
18  */
19
20 /**
21  * @file rw-pkg-mgmt.yang
22  * @author Varun Prasad
23  * @date 2016/09/21
24  * @brief Pacakage Management Yang
25  */
26
27 module rw-pkg-mgmt
28 {
29   namespace "http://riftio.com/ns/riftware-1.0/rw-pkg-mgmt";
30   prefix "rw-pkg-mgmt";
31
32   import ietf-yang-types {
33     prefix "yang";
34   }
35
36   import rw-pb-ext {
37     prefix "rwpb";
38   }
39
40   import rw-cli-ext {
41     prefix "rwcli";
42   }
43
44   import rw-cloud {
45     prefix "rwcloud";
46   }
47
48   import rwcal {
49     prefix "rwcal";
50   }
51
52   import mano-types {
53     prefix "manotypes";
54   }
55
56   revision 2016-06-01 {
57     description
58       "Initial revision.";
59   }
60
61   typedef task-status {
62     type enumeration {
63       enum QUEUED;
64       enum IN_PROGRESS;
65       enum DOWNLOADING;
66       enum CANCELLED;
67       enum COMPLETED;
68       enum FAILED;
69     }
70   }
71
72   typedef export-schema {
73     type enumeration {
74       enum RIFT;
75       enum MANO;
76     }
77   }
78
79   typedef export-grammar {
80     type enumeration {
81       enum OSM;
82       enum TOSCA;
83     }
84   }
85
86   typedef export-format {
87     type enumeration {
88       enum YAML;
89       enum JSON;
90     }
91   }
92
93   grouping external-url-data {
94     leaf external-url {
95       description "Url to download";
96       type string;
97     }
98
99     leaf username {
100       description "username if the url uses authentication";
101       type string;
102     }
103
104     leaf password {
105       description "password if the url uses authentication";
106       type string;
107     }
108   }
109
110   grouping package-identifer {
111     leaf package-type {
112       description "Type of the package";
113       type manotypes:package-type;
114     }
115
116     leaf package-id {
117       description "Id of the package";
118       type string;
119     }
120   }
121
122   grouping package-file-identifer {
123     uses package-identifer;
124
125     leaf package-path {
126       description "Relative path in the package";
127       type string;
128     }
129   }
130
131   grouping download-task-status {
132     leaf status {
133       description "The status of the download task";
134       type task-status;
135       default QUEUED;
136     }
137
138     leaf detail {
139       description "Detailed download status message";
140       type string;
141     }
142
143     leaf progress-percent {
144       description "The download progress percentage (0-100)";
145       type uint8;
146       default 0;
147     }
148
149     leaf bytes_downloaded {
150       description "The number of bytes downloaded";
151       type uint64;
152       default 0;
153     }
154
155     leaf bytes_total {
156       description "The total number of bytes to write";
157       type uint64;
158       default 0;
159     }
160
161     leaf bytes_per_second {
162       description "The total number of bytes written per second";
163       type uint32;
164       default 0;
165     }
166
167     leaf start-time {
168       description "start time (unix epoch)";
169       type uint32;
170     }
171
172     leaf stop-time {
173       description "stop time (unix epoch)";
174       type uint32;
175     }
176   }
177
178   container download-jobs {
179     rwpb:msg-new DownloadJobs;
180     description "Download jobs";
181     config false;
182
183     list job {
184       rwpb:msg-new DownloadJob;
185       key "download-id";
186
187       leaf download-id {
188         description "Unique UUID";
189         type string;
190       }
191
192       leaf url {
193         description "URL of the download";
194         type string;
195       }
196
197       uses package-file-identifer;
198       uses download-task-status;
199     }
200   }
201
202   rpc get-package-endpoint {
203     description "Retrieves the endpoint for the descriptor";
204
205     input {
206       uses package-identifer;
207     }
208
209     output {
210      leaf endpoint {
211         description "Endpoint that contains all the package-related data";
212         type string;
213       }
214     }
215   }
216
217   rpc get-package-schema {
218     description "Retrieves the schema for the package type";
219
220     input {
221       leaf package-type {
222         description "Type of the package";
223         type manotypes:package-type;
224       }
225     }
226
227     output {
228       leaf-list schema {
229         description "List of all top level directories for the package.";
230         type string;
231       }
232     }
233   }
234
235   rpc package-create {
236     description "Creates a new package";
237
238     input {
239       uses package-identifer;
240       uses external-url-data;
241     }
242
243     output {
244      leaf transaction-id {
245         description "Valid ID to track the status of the task";
246         type string;
247       }
248     }
249   }
250
251   rpc package-update {
252     description "Creates a new package";
253
254     input {
255       uses package-identifer;
256       uses external-url-data;
257     }
258
259     output {
260      leaf transaction-id {
261         description "Valid ID to track the status of the task";
262         type string;
263       }
264     }
265   }
266
267   rpc package-export {
268     description "Export a package";
269
270     input {
271       uses package-identifer;
272
273       leaf export-schema {
274         description "Schema to export";
275         type export-schema;
276         default RIFT;
277       }
278
279       leaf export-grammar {
280         description "Schema to export";
281         type export-grammar;
282         default OSM;
283       }
284
285       leaf export-format {
286         description "Format to export";
287         type export-format;
288         default YAML;
289       }
290
291     }
292
293     output {
294      leaf transaction-id {
295         description "Valid ID to track the status of the task";
296         type string;
297       }
298
299      leaf filename {
300         description "Valid ID to track the status of the task";
301         type string;
302       }
303     }
304   }
305
306   rpc package-file-add {
307     description "Retrieves the file from the URL and store it in the package";
308
309     input {
310       uses package-file-identifer;
311       uses external-url-data;
312     }
313
314     output {
315      leaf task-id {
316         description "Valid ID to track the status of the task";
317         type string;
318       }
319     }
320   }
321
322   rpc package-file-delete {
323     description "Retrieves the file from the URL and store it in the package";
324
325     input {
326       uses package-file-identifer;
327     }
328
329     output {
330      leaf status {
331         description "Status of the delte operation";
332         type string;
333       }
334
335       leaf error-trace {
336         description "Trace in case of a failure";
337         type string;
338       }
339
340     }
341   }
342
343 }