Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 19 | package org.onlab.onos.net.intent; |
| 20 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 21 | |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 22 | import java.util.List; |
Thomas Vachuska | 1fb982f | 2014-10-22 14:09:17 -0700 | [diff] [blame] | 23 | import java.util.concurrent.Future; |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 24 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 25 | /** |
| 26 | * Service for application submitting or withdrawing their intents. |
| 27 | */ |
| 28 | public interface IntentService { |
| 29 | /** |
| 30 | * Submits an intent into the system. |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 31 | * <p/> |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 32 | * This is an asynchronous request meaning that any compiling or |
| 33 | * installation activities may be done at later time. |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 34 | * |
| 35 | * @param intent intent to be submitted |
| 36 | */ |
| 37 | void submit(Intent intent); |
| 38 | |
| 39 | /** |
| 40 | * Withdraws an intent from the system. |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 41 | * <p/> |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 42 | * This is an asynchronous request meaning that the environment may be |
| 43 | * affected at later time. |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 44 | * |
| 45 | * @param intent intent to be withdrawn |
| 46 | */ |
| 47 | void withdraw(Intent intent); |
| 48 | |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame^] | 49 | /** |
| 50 | * Replaces the specified intent with a new one. |
| 51 | * |
| 52 | * @param oldIntentId identifier of the old intent being replaced |
| 53 | * @param newIntent new intent replacing the old one |
| 54 | */ |
| 55 | void replace(IntentId oldIntentId, Intent newIntent); |
Thomas Vachuska | 1fb982f | 2014-10-22 14:09:17 -0700 | [diff] [blame] | 56 | |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 57 | /** |
| 58 | * Submits a batch of submit & withdraw operations. Such a batch is |
| 59 | * assumed to be processed together. |
tom | a1d16b6 | 2014-10-02 23:45:11 -0700 | [diff] [blame] | 60 | * <p/> |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 61 | * This is an asynchronous request meaning that the environment may be |
| 62 | * affected at later time. |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 63 | * |
| 64 | * @param operations batch of intent operations |
| 65 | */ |
Thomas Vachuska | 1fb982f | 2014-10-22 14:09:17 -0700 | [diff] [blame] | 66 | Future<IntentOperations> execute(IntentOperations operations); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 67 | |
| 68 | /** |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 69 | * Returns an iterable of intents currently in the system. |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 70 | * |
| 71 | * @return set of intents |
| 72 | */ |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 73 | Iterable<Intent> getIntents(); |
| 74 | |
| 75 | /** |
| 76 | * Returns the number of intents currently in the system. |
| 77 | * |
| 78 | * @return number of intents |
| 79 | */ |
| 80 | long getIntentCount(); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 81 | |
| 82 | /** |
| 83 | * Retrieves the intent specified by its identifier. |
| 84 | * |
| 85 | * @param id intent identifier |
| 86 | * @return the intent or null if one with the given identifier is not found |
| 87 | */ |
| 88 | Intent getIntent(IntentId id); |
| 89 | |
| 90 | /** |
| 91 | * Retrieves the state of an intent by its identifier. |
| 92 | * |
| 93 | * @param id intent identifier |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 94 | * @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] | 95 | * found |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 96 | */ |
| 97 | IntentState getIntentState(IntentId id); |
| 98 | |
| 99 | /** |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 100 | * Returns the list of the installable events associated with the specified |
| 101 | * top-level intent. |
| 102 | * |
| 103 | * @param intentId top-level intent identifier |
| 104 | * @return compiled installable intents |
| 105 | */ |
| 106 | List<Intent> getInstallableIntents(IntentId intentId); |
| 107 | |
| 108 | /** |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 109 | * Adds the specified listener for intent events. |
| 110 | * |
| 111 | * @param listener listener to be added |
| 112 | */ |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 113 | void addListener(IntentListener listener); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 114 | |
| 115 | /** |
| 116 | * Removes the specified listener for intent events. |
| 117 | * |
| 118 | * @param listener listener to be removed |
| 119 | */ |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 120 | void removeListener(IntentListener listener); |
Brian O'Connor | b876bf1 | 2014-10-02 14:59:37 -0700 | [diff] [blame] | 121 | } |