blob: ccc97d871e845232c1ad73207270275e7966c090 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Thomas Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Thomas Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent;
Brian O'Connorb876bf12014-10-02 14:59:37 -070017
Brian O'Connorb876bf12014-10-02 14:59:37 -070018
Brian O'Connor9476fa12015-06-25 15:17:17 -040019import com.google.common.annotations.Beta;
20
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070021import java.util.List;
22
Brian O'Connorb876bf12014-10-02 14:59:37 -070023/**
24 * Service for application submitting or withdrawing their intents.
25 */
Brian O'Connor9476fa12015-06-25 15:17:17 -040026@Beta
Brian O'Connorb876bf12014-10-02 14:59:37 -070027public interface IntentService {
28 /**
29 * Submits an intent into the system.
Thomas Vachuska4b420772014-10-30 16:46:17 -070030 * <p>
Brian O'Connor66630c82014-10-02 21:08:19 -070031 * This is an asynchronous request meaning that any compiling or
32 * installation activities may be done at later time.
Thomas Vachuska4b420772014-10-30 16:46:17 -070033 * </p>
Brian O'Connorb876bf12014-10-02 14:59:37 -070034 * @param intent intent to be submitted
35 */
36 void submit(Intent intent);
37
38 /**
39 * Withdraws an intent from the system.
Thomas Vachuska4b420772014-10-30 16:46:17 -070040 * <p>
Brian O'Connor66630c82014-10-02 21:08:19 -070041 * This is an asynchronous request meaning that the environment may be
42 * affected at later time.
Thomas Vachuska4b420772014-10-30 16:46:17 -070043 * </p>
Brian O'Connorb876bf12014-10-02 14:59:37 -070044 * @param intent intent to be withdrawn
45 */
46 void withdraw(Intent intent);
47
Thomas Vachuska83e090e2014-10-22 14:25:35 -070048 /**
Ray Milkey8c6d00e2015-03-13 14:14:34 -070049 * Purges a specific intent from the system if it is <b>FAILED</b> or
50 * <b>WITHDRAWN</b>. Otherwise, the intent remains in its current state.
51 *
52 * @param intent intent to purge
53 */
54 void purge(Intent intent);
55
56 /**
Ray Milkeyf9af43c2015-02-09 16:45:48 -080057 * Fetches an intent based on its key.
58 *
59 * @param key key of the intent
60 * @return intent object if the key is found, null otherwise
61 */
Brian O'Connorf2114992015-03-17 16:03:14 -070062 Intent getIntent(Key key);
Ray Milkeyf9af43c2015-02-09 16:45:48 -080063
64 /**
Brian O'Connor66630c82014-10-02 21:08:19 -070065 * Returns an iterable of intents currently in the system.
Brian O'Connorb876bf12014-10-02 14:59:37 -070066 *
67 * @return set of intents
68 */
Brian O'Connor66630c82014-10-02 21:08:19 -070069 Iterable<Intent> getIntents();
70
71 /**
Thomas Vachuskac46af202015-06-03 16:43:27 -070072 * Returns an iterable of intent data objects currently in the system.
73 *
74 * @return set of intent data objects
75 */
76 Iterable<IntentData> getIntentData();
77
78 /**
Brian O'Connor66630c82014-10-02 21:08:19 -070079 * Returns the number of intents currently in the system.
80 *
81 * @return number of intents
82 */
83 long getIntentCount();
Brian O'Connorb876bf12014-10-02 14:59:37 -070084
85 /**
Brian O'Connorb876bf12014-10-02 14:59:37 -070086 * Retrieves the state of an intent by its identifier.
87 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080088 * @param intentKey intent identifier
Brian O'Connor66630c82014-10-02 21:08:19 -070089 * @return the intent state or null if one with the given identifier is not
toma1d16b62014-10-02 23:45:11 -070090 * found
Brian O'Connorb876bf12014-10-02 14:59:37 -070091 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -080092 IntentState getIntentState(Key intentKey);
Brian O'Connorb876bf12014-10-02 14:59:37 -070093
94 /**
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070095 * Returns the list of the installable events associated with the specified
96 * top-level intent.
97 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080098 * @param intentKey top-level intent identifier
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070099 * @return compiled installable intents
100 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800101 List<Intent> getInstallableIntents(Key intentKey);
Thomas Vachuska10d4abc2014-10-21 12:47:26 -0700102
Jonathan Hart13d3dd92015-02-25 16:09:42 -0800103 /**
104 * Signifies whether the local node is responsible for processing the given
105 * intent key.
106 *
107 * @param intentKey intent key to check
108 * @return true if the local node is responsible for the intent key,
109 * otherwise false
110 */
111 boolean isLocal(Key intentKey);
Brian O'Connorbe28a872015-02-19 21:44:37 -0800112
Thomas Vachuska10d4abc2014-10-21 12:47:26 -0700113 /**
Jonathan Hart34f1e382015-02-24 16:52:23 -0800114 * Returns the list of intent requests pending processing.
115 *
116 * @return intents pending processing
117 */
Jonathan Hart13d3dd92015-02-25 16:09:42 -0800118 Iterable<Intent> getPending();
Jonathan Hart34f1e382015-02-24 16:52:23 -0800119
120 /**
Brian O'Connorb876bf12014-10-02 14:59:37 -0700121 * Adds the specified listener for intent events.
122 *
123 * @param listener listener to be added
124 */
Brian O'Connor66630c82014-10-02 21:08:19 -0700125 void addListener(IntentListener listener);
Brian O'Connorb876bf12014-10-02 14:59:37 -0700126
127 /**
128 * Removes the specified listener for intent events.
129 *
130 * @param listener listener to be removed
131 */
Brian O'Connor66630c82014-10-02 21:08:19 -0700132 void removeListener(IntentListener listener);
Brian O'Connorb876bf12014-10-02 14:59:37 -0700133}