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