Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.intent; |
| 2 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 3 | |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 4 | import java.util.List; |
Thomas Vachuska | 1fb982f | 2014-10-22 14:09:17 -0700 | [diff] [blame^] | 5 | import java.util.concurrent.Future; |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 6 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 7 | /** |
| 8 | * Service for application submitting or withdrawing their intents. |
| 9 | */ |
| 10 | public interface IntentService { |
| 11 | /** |
| 12 | * Submits an intent into the system. |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 13 | * <p/> |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 14 | * This is an asynchronous request meaning that any compiling or |
| 15 | * installation activities may be done at later time. |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 16 | * |
| 17 | * @param intent intent to be submitted |
| 18 | */ |
| 19 | void submit(Intent intent); |
| 20 | |
| 21 | /** |
| 22 | * Withdraws an intent from the system. |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 23 | * <p/> |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 24 | * This is an asynchronous request meaning that the environment may be |
| 25 | * affected at later time. |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 26 | * |
| 27 | * @param intent intent to be withdrawn |
| 28 | */ |
| 29 | void withdraw(Intent intent); |
| 30 | |
Thomas Vachuska | 1fb982f | 2014-10-22 14:09:17 -0700 | [diff] [blame^] | 31 | // void replace(IntentId oldIntentId, Intent newIntent); |
| 32 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 33 | /** |
| 34 | * Submits a batch of submit & withdraw operations. Such a batch is |
| 35 | * assumed to be processed together. |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 36 | * <p/> |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 37 | * This is an asynchronous request meaning that the environment may be |
| 38 | * affected at later time. |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 39 | * |
| 40 | * @param operations batch of intent operations |
| 41 | */ |
Thomas Vachuska | 1fb982f | 2014-10-22 14:09:17 -0700 | [diff] [blame^] | 42 | Future<IntentOperations> execute(IntentOperations operations); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 45 | * Returns an iterable of intents currently in the system. |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 46 | * |
| 47 | * @return set of intents |
| 48 | */ |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 49 | Iterable<Intent> getIntents(); |
| 50 | |
| 51 | /** |
| 52 | * Returns the number of intents currently in the system. |
| 53 | * |
| 54 | * @return number of intents |
| 55 | */ |
| 56 | long getIntentCount(); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | * Retrieves the intent specified by its identifier. |
| 60 | * |
| 61 | * @param id intent identifier |
| 62 | * @return the intent or null if one with the given identifier is not found |
| 63 | */ |
| 64 | Intent getIntent(IntentId id); |
| 65 | |
| 66 | /** |
| 67 | * Retrieves the state of an intent by its identifier. |
| 68 | * |
| 69 | * @param id intent identifier |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 70 | * @return the intent state or null if one with the given identifier is not |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 71 | * found |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 72 | */ |
| 73 | IntentState getIntentState(IntentId id); |
| 74 | |
| 75 | /** |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 76 | * Returns the list of the installable events associated with the specified |
| 77 | * top-level intent. |
| 78 | * |
| 79 | * @param intentId top-level intent identifier |
| 80 | * @return compiled installable intents |
| 81 | */ |
| 82 | List<Intent> getInstallableIntents(IntentId intentId); |
| 83 | |
| 84 | /** |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 85 | * Adds the specified listener for intent events. |
| 86 | * |
| 87 | * @param listener listener to be added |
| 88 | */ |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 89 | void addListener(IntentListener listener); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * Removes the specified listener for intent events. |
| 93 | * |
| 94 | * @param listener listener to be removed |
| 95 | */ |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 96 | void removeListener(IntentListener listener); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 97 | } |