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