5fbd621b6ece55752062a39affa95a70cdb26642
[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   import rw-vnfd {
57     prefix "rwvnfd";
58   }
59   import rw-nsd {
60     prefix "rwnsd";
61   }
62
63   revision 2016-06-01 {
64     description
65       "Initial revision.";
66   }
67
68   typedef task-status {
69     type enumeration {
70       enum QUEUED;
71       enum IN_PROGRESS;
72       enum DOWNLOADING;
73       enum CANCELLED;
74       enum COMPLETED;
75       enum FAILED;
76     }
77   }
78
79   typedef export-schema {
80     type enumeration {
81       enum RIFT;
82       enum MANO;
83     }
84   }
85
86   typedef export-grammar {
87     type enumeration {
88       enum OSM;
89       enum TOSCA;
90     }
91   }
92
93   typedef export-format {
94     type enumeration {
95       enum YAML;
96       enum JSON;
97     }
98   }
99
100   grouping external-url-data {
101     leaf external-url {
102       description "Url to download";
103       type string;
104     }
105
106     leaf username {
107       description "username if the url uses authentication";
108       type string;
109     }
110
111     leaf password {
112       description "password if the url uses authentication";
113       type string;
114     }
115   }
116
117   grouping package-identifer {
118     leaf package-type {
119       description "Type of the package";
120       type manotypes:package-type;
121     }
122
123     leaf package-id {
124       description "Id of the package";
125       type string;
126     }
127   }
128
129   grouping package-file-identifer {
130     uses package-identifer;
131
132     leaf package-path {
133       description "Relative path in the package";
134       type string;
135     }
136   }
137
138   grouping download-task-status {
139     leaf status {
140       description "The status of the download task";
141       type task-status;
142       default QUEUED;
143     }
144
145     leaf detail {
146       description "Detailed download status message";
147       type string;
148     }
149
150     leaf progress-percent {
151       description "The download progress percentage (0-100)";
152       type uint8;
153       default 0;
154     }
155
156     leaf bytes_downloaded {
157       description "The number of bytes downloaded";
158       type uint64;
159       default 0;
160     }
161
162     leaf bytes_total {
163       description "The total number of bytes to write";
164       type uint64;
165       default 0;
166     }
167
168     leaf bytes_per_second {
169       description "The total number of bytes written per second";
170       type uint32;
171       default 0;
172     }
173
174     leaf start-time {
175       description "start time (unix epoch)";
176       type uint32;
177     }
178
179     leaf stop-time {
180       description "stop time (unix epoch)";
181       type uint32;
182     }
183   }
184
185   grouping copy-task-status {
186     leaf status {
187       description "The status of the copy task";
188       type task-status;
189       default QUEUED;
190     }
191   }
192
193   container download-jobs {
194     rwpb:msg-new DownloadJobs;
195     description "Download jobs";
196     config false;
197
198     list job {
199       rwpb:msg-new DownloadJob;
200       key "download-id";
201
202       leaf download-id {
203         description "Unique UUID";
204         type string;
205       }
206
207       leaf url {
208         description "URL of the download";
209         type string;
210       }
211
212       uses package-file-identifer;
213       uses download-task-status;
214     }
215   }
216
217   container copy-jobs {
218     rwpb:msg-new CopyJobs;
219     description "Copy jobs";
220     config false;
221
222     list job {
223       rwpb:msg-new CopyJob;
224       key "transaction-id";
225
226       leaf transaction-id {
227         description "Unique UUID";
228         type string;
229       }
230
231       uses copy-task-status;
232     }
233   }
234
235   rpc get-package-endpoint {
236     description "Retrieves the endpoint for the descriptor";
237
238     input {
239       uses package-identifer;
240     }
241
242     output {
243      leaf endpoint {
244         description "Endpoint that contains all the package-related data";
245         type string;
246       }
247     }
248   }
249
250   rpc package-copy {
251     description "Copies the package specified in input and returns the copied package id";
252
253     input {
254       uses package-identifer;
255
256       leaf package-name {
257         description "Name of destination package";
258         type string;
259       }
260     }
261
262     output {
263      leaf transaction-id {
264         description "Valid ID to track the status of the task";
265         type string;
266       }
267
268      uses package-identifer;
269     }
270   }
271
272   rpc get-package-schema {
273     description "Retrieves the schema for the package type";
274
275     input {
276       leaf package-type {
277         description "Type of the package";
278         type manotypes:package-type;
279       }
280     }
281
282     output {
283       leaf-list schema {
284         description "List of all top level directories for the package.";
285         type string;
286       }
287     }
288   }
289
290   rpc package-create {
291     description "Creates a new package";
292
293     input {
294       uses package-identifer;
295       uses external-url-data;
296     }
297
298     output {
299      leaf transaction-id {
300         description "Valid ID to track the status of the task";
301         type string;
302       }
303     }
304   }
305
306   rpc package-update {
307     description "Creates a new package";
308
309     input {
310       uses package-identifer;
311       uses external-url-data;
312     }
313
314     output {
315      leaf transaction-id {
316         description "Valid ID to track the status of the task";
317         type string;
318       }
319     }
320   }
321
322   rpc package-export {
323     description "Export a package";
324
325     input {
326       uses package-identifer;
327
328       leaf export-schema {
329         description "Schema to export";
330         type export-schema;
331         default RIFT;
332       }
333
334       leaf export-grammar {
335         description "Schema to export";
336         type export-grammar;
337         default OSM;
338       }
339
340       leaf export-format {
341         description "Format to export";
342         type export-format;
343         default YAML;
344       }
345
346     }
347
348     output {
349      leaf transaction-id {
350         description "Valid ID to track the status of the task";
351         type string;
352       }
353
354      leaf filename {
355         description "Valid ID to track the status of the task";
356         type string;
357       }
358     }
359   }
360
361   rpc package-file-add {
362     description "Retrieves the file from the URL and store it in the package";
363
364     input {
365       uses package-file-identifer;
366       uses external-url-data;
367     }
368
369     output {
370      leaf task-id {
371         description "Valid ID to track the status of the task";
372         type string;
373       }
374     }
375   }
376
377   rpc package-file-delete {
378     description "Retrieves the file from the URL and store it in the package";
379
380     input {
381       uses package-file-identifer;
382     }
383
384     output {
385      leaf status {
386         description "Status of the delte operation";
387         type string;
388       }
389
390       leaf error-trace {
391         description "Trace in case of a failure";
392         type string;
393       }
394
395     }
396   }
397
398 }