Adding nemo engine.
[nemo.git] / nemo-api / src / main / yang / nemo-intent.yang
1 /*\r
2  * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 module nemo-intent {\r
10     yang-version 1;\r
11 \r
12     namespace "urn:opendaylight:params:xml:ns:yang:nemo:intent";\r
13     prefix "nemo-intent";\r
14 \r
15     import nemo-common {prefix nemo-common;}\r
16     import nemo-object {prefix nemo-object;}\r
17     import nemo-operation {prefix nemo-operation;}\r
18     import nemo-user {prefix nemo-user;}\r
19 \r
20     revision "2015-10-10" {\r
21         description\r
22             "Initial revision.";\r
23     }\r
24 \r
25     grouping user-intent {\r
26         description\r
27             "User intent refers to a purpose in getting an ultimate result\r
28              or performing some specific operation on some objects.";\r
29 \r
30         container objects {\r
31             description\r
32                 "The element could be operated and managed by users.\r
33                  It inludes resources to construct users' virtual network,\r
34                  and the services in this network.In NEMO project, it is\r
35                  abstracted into node, connection and flow";\r
36 \r
37             list node {\r
38                 key "node-id";\r
39                 uses nemo-object:node-instance;\r
40             }\r
41 \r
42             list connection {\r
43                 key "connection-id";\r
44                 uses nemo-object:connection-instance;\r
45             }\r
46 \r
47             list flow {\r
48                 key "flow-id";\r
49                 uses nemo-object:flow-instance;\r
50             }\r
51         }\r
52 \r
53         container operations {\r
54             description\r
55                 "The operation is to dynamically adjust the behavior of network,\r
56                  and it is applied on objects, that is, node, connection and flow";\r
57 \r
58             list operation {\r
59                 key "operation-id";\r
60                 uses nemo-operation:operation-instance;\r
61             }\r
62         }\r
63 \r
64         container results {\r
65             // TBD\r
66         }\r
67     }\r
68 \r
69     container users {\r
70         description\r
71             "The list of all known users";\r
72 \r
73         list user {\r
74             description\r
75                 "A user is an administrative domain which is\r
76                  logically separated from other users, and each\r
77                  intent is specified by a particular user.";\r
78 \r
79             key "user-id";\r
80             uses nemo-user:user-instance;\r
81             uses user-intent;\r
82         }\r
83     }\r
84 \r
85     container query-condition-definitions {\r
86         description\r
87             "Contains the definitions for all advanced query, which means\r
88              they are the query with conditions supported by the NEMO engine.\r
89              User will fetch all results which meet the condition.";\r
90 \r
91         list query-condition-definition {\r
92             description\r
93                 "Define the query with condition. For example, user may\r
94                  intent to query all connection's name whose utilization is\r
95                  beyond 80%. That is a query with condition.";\r
96 \r
97             key "query-condition-name query-intent-type";\r
98             leaf query-condition-name {\r
99                 description\r
100                     "A user-visible name for the query condition definition.\r
101                      The query condition name is usually to specify the\r
102                      attribute or property of some kind of intent.\r
103                      For the above example, the query-condition-name is utility.";\r
104                 type nemo-common:query-condition-name;\r
105                 mandatory true;\r
106             }\r
107 \r
108             leaf query-intent-type {\r
109                 description\r
110                     "The target for the query, and its attributes will be checked out\r
111                      if meet the condition. In the above example, connection is the\r
112                      target. So, connection will be the query-intent-type here.";\r
113                 type enumeration {\r
114                     enum node;\r
115                     enum connection;\r
116                     enum flow;\r
117                     enum operation;\r
118                     enum result;\r
119                 }\r
120             }\r
121 \r
122             leaf query-condition-value-type {\r
123                 description\r
124                     "The type of the target value for the query condition.\r
125                      For the above example, the target-value is 80(%),\r
126                      so the query-condition-value-type will be int.";\r
127                 default string;\r
128                 type enumeration {\r
129                     enum string {\r
130                         description\r
131                             "A string-valued target value.";\r
132                     }\r
133                     enum int {\r
134                         description\r
135                             "An integer-valued target value.";\r
136                     }\r
137                     enum range {\r
138                         description\r
139                             "An integer-range target value.";\r
140                     }\r
141                 }\r
142             }\r
143 \r
144             container query-condition-match-patterns {\r
145                 description\r
146                     "The relationship between the value of query-condition-name\r
147                      and query-condition-target-value. If an intent's attribute\r
148                      or property specified by the query condition name matches\r
149                      to the target value by the match pattern, this intent meets\r
150                      the condition. For the above example, the condition's\r
151                      query-condition-match-patterns could be less-than, not-less-than,\r
152                      equal, not-equal, greater-than, not-greater-than, between.";\r
153 \r
154                 leaf-list query-condition-match-pattern {\r
155                     type enumeration {\r
156                         enum less-than;\r
157                         enum not-less-than;\r
158                         enum equal;\r
159                         enum not-equal;\r
160                         enum greater-than;\r
161                         enum not-greater-than;\r
162                         enum between;\r
163                     }\r
164                 }\r
165             }\r
166         }\r
167     }\r
168 \r
169     grouping common-rpc-result {\r
170         description\r
171             "Common return result for all defined RPCs.";\r
172 \r
173         leaf result-code {\r
174             description\r
175                 "Result code which is convenient for processing in a program.";\r
176             type enumeration {\r
177                 enum ok {\r
178                     description\r
179                         "The invoked RPC was executed successfully";\r
180                 }\r
181                 enum error {\r
182                     description\r
183                         "There's an error while executing the RPC";\r
184                 }\r
185             }\r
186         }\r
187 \r
188         leaf message {\r
189             description\r
190                 "A human-readable message for an error or exception";\r
191             type string;\r
192         }\r
193     }\r
194 \r
195     grouping query-condition-instance {\r
196         description\r
197             "A query condition instance generated according to\r
198              a specified query condition definition.";\r
199 \r
200         leaf query-condition-id {\r
201             description\r
202                 "A unique ID for a query condition instance.";\r
203             type nemo-common:query-condition-id;\r
204             mandatory true;\r
205         }\r
206 \r
207         leaf query-condition-name {\r
208             description\r
209                 "The name of the query condition definition.";\r
210             type nemo-common:query-condition-name;\r
211             mandatory true;\r
212         }\r
213 \r
214         leaf query-intent-type {\r
215             description\r
216                 "The type of the intents that the user wants to query from through\r
217                  the condition instance.";\r
218             type enumeration {\r
219                 enum node;\r
220                 enum connection;\r
221                 enum flow;\r
222                 enum operation;\r
223                 enum result;\r
224             }\r
225         }\r
226 \r
227         leaf query-condition-match-pattern {\r
228             description\r
229                 "The match pattern the condition instance will use.";\r
230             type enumeration {\r
231                 enum less-than;\r
232                 enum not-less-than;\r
233                 enum equal;\r
234                 enum not-equal;\r
235                 enum greater-than;\r
236                 enum not-greater-than;\r
237                 enum between;\r
238             }\r
239         }\r
240 \r
241         container query-condition-target-value {\r
242             description\r
243                 "The target value used to compare with the attribute\r
244                  or property of the intents.";\r
245 \r
246             leaf string-value {\r
247                 type string;\r
248             }\r
249 \r
250             leaf int-value {\r
251                 type int64;\r
252             }\r
253 \r
254             container range-value {\r
255                 leaf min {\r
256                     type int64;\r
257                     mandatory true;\r
258                 }\r
259 \r
260                 leaf max {\r
261                     type int64;\r
262                     mandatory true;\r
263                 }\r
264             }\r
265         }\r
266     }\r
267 \r
268     rpc register-user {\r
269         description\r
270             "Register a user to the user repository.";\r
271 \r
272         input {\r
273             uses nemo-user:user-instance;\r
274         }\r
275 \r
276         output {\r
277             uses common-rpc-result;\r
278         }\r
279     }\r
280 \r
281     rpc begin-transaction {\r
282         description\r
283             "Begin a transaction for the user";\r
284 \r
285         input {\r
286             uses nemo-user:user-instance;\r
287         }\r
288 \r
289         output {\r
290             uses common-rpc-result;\r
291         }\r
292     }\r
293 \r
294     rpc end-transaction {\r
295         description\r
296             "Commit the user's current transaction";\r
297 \r
298         input {\r
299             uses nemo-user:user-instance;\r
300         }\r
301 \r
302         output {\r
303             uses common-rpc-result;\r
304         }\r
305     }\r
306 \r
307     rpc language-style-nemo-request {\r
308         description\r
309             "Create, update or delete an intent of a user through an NEMO statement";\r
310 \r
311         input {\r
312             uses nemo-user:user-instance;\r
313 \r
314             leaf nemo-statement {\r
315                 type string;\r
316             }\r
317         }\r
318 \r
319         output {\r
320             uses common-rpc-result;\r
321         }\r
322     }\r
323 \r
324     rpc structure-style-nemo-update {\r
325         description\r
326             "Create or update all or a part of the user's intents,\r
327              which are described as json or xml format.";\r
328 \r
329         input {\r
330             uses nemo-user:user-instance;\r
331             uses user-intent;\r
332         }\r
333 \r
334         output {\r
335             uses common-rpc-result;\r
336         }\r
337     }\r
338 \r
339     rpc structure-style-nemo-delete {\r
340         description\r
341             "Delete some intents of a user from the user repository";\r
342 \r
343         input {\r
344             uses nemo-user:user-instance;\r
345 \r
346             container objects {\r
347                 leaf-list node {\r
348                     type nemo-common:node-id;\r
349                 }\r
350 \r
351                 leaf-list connection {\r
352                     type nemo-common:connection-id;\r
353                 }\r
354 \r
355                 leaf-list flow {\r
356                     type nemo-common:flow-id;\r
357                 }\r
358             }\r
359 \r
360             container operations {\r
361                 leaf-list operation {\r
362                     type nemo-common:operation-id;\r
363                 }\r
364             }\r
365 \r
366             container results {\r
367                 // TBD\r
368             }\r
369         }\r
370 \r
371         output {\r
372             uses common-rpc-result;\r
373         }\r
374     }\r
375 \r
376     rpc advanced-nemo-query {\r
377         description\r
378             "Query some intents of a user from the user repository\r
379              according to several advanced query conditions.";\r
380 \r
381         input {\r
382             uses nemo-user:user-instance;\r
383 \r
384             list query-condition {\r
385                 key "query-condition-id";\r
386                 uses query-condition-instance;\r
387             }\r
388         }\r
389 \r
390         output {\r
391             uses common-rpc-result;\r
392             uses user-intent;\r
393         }\r
394     }\r
395 }\r