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