blob: b86d793974d2727e4e5f407f0c56065ec30266b8 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 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
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070019import java.util.List;
20
Brian O'Connorb876bf12014-10-02 14:59:37 -070021/**
22 * Service for application submitting or withdrawing their intents.
23 */
24public interface IntentService {
25 /**
26 * Submits an intent into the system.
Thomas Vachuska4b420772014-10-30 16:46:17 -070027 * <p>
Brian O'Connor66630c82014-10-02 21:08:19 -070028 * This is an asynchronous request meaning that any compiling or
29 * installation activities may be done at later time.
Thomas Vachuska4b420772014-10-30 16:46:17 -070030 * </p>
Brian O'Connorb876bf12014-10-02 14:59:37 -070031 * @param intent intent to be submitted
32 */
33 void submit(Intent intent);
34
35 /**
36 * Withdraws an intent from the system.
Thomas Vachuska4b420772014-10-30 16:46:17 -070037 * <p>
Brian O'Connor66630c82014-10-02 21:08:19 -070038 * This is an asynchronous request meaning that the environment may be
39 * affected at later time.
Thomas Vachuska4b420772014-10-30 16:46:17 -070040 * </p>
Brian O'Connorb876bf12014-10-02 14:59:37 -070041 * @param intent intent to be withdrawn
42 */
43 void withdraw(Intent intent);
44
Thomas Vachuska83e090e2014-10-22 14:25:35 -070045 /**
Ray Milkeyf9af43c2015-02-09 16:45:48 -080046 * Fetches an intent based on its key.
47 *
48 * @param key key of the intent
49 * @return intent object if the key is found, null otherwise
50 */
51 public Intent getIntent(Key key);
52
53 /**
Brian O'Connor66630c82014-10-02 21:08:19 -070054 * Returns an iterable of intents currently in the system.
Brian O'Connorb876bf12014-10-02 14:59:37 -070055 *
56 * @return set of intents
57 */
Brian O'Connor66630c82014-10-02 21:08:19 -070058 Iterable<Intent> getIntents();
59
60 /**
61 * Returns the number of intents currently in the system.
62 *
63 * @return number of intents
64 */
65 long getIntentCount();
Brian O'Connorb876bf12014-10-02 14:59:37 -070066
67 /**
Brian O'Connorb876bf12014-10-02 14:59:37 -070068 * Retrieves the state of an intent by its identifier.
69 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080070 * @param intentKey intent identifier
Brian O'Connor66630c82014-10-02 21:08:19 -070071 * @return the intent state or null if one with the given identifier is not
toma1d16b62014-10-02 23:45:11 -070072 * found
Brian O'Connorb876bf12014-10-02 14:59:37 -070073 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -080074 IntentState getIntentState(Key intentKey);
Brian O'Connorb876bf12014-10-02 14:59:37 -070075
76 /**
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070077 * Returns the list of the installable events associated with the specified
78 * top-level intent.
79 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080080 * @param intentKey top-level intent identifier
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070081 * @return compiled installable intents
82 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -080083 List<Intent> getInstallableIntents(Key intentKey);
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070084
Jonathan Hart13d3dd92015-02-25 16:09:42 -080085 /**
86 * Signifies whether the local node is responsible for processing the given
87 * intent key.
88 *
89 * @param intentKey intent key to check
90 * @return true if the local node is responsible for the intent key,
91 * otherwise false
92 */
93 boolean isLocal(Key intentKey);
Brian O'Connorbe28a872015-02-19 21:44:37 -080094
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070095 /**
Jonathan Hart34f1e382015-02-24 16:52:23 -080096 * Returns the list of intent requests pending processing.
97 *
98 * @return intents pending processing
99 */
Jonathan Hart13d3dd92015-02-25 16:09:42 -0800100 Iterable<Intent> getPending();
Jonathan Hart34f1e382015-02-24 16:52:23 -0800101
102 /**
Brian O'Connorb876bf12014-10-02 14:59:37 -0700103 * Adds the specified listener for intent events.
104 *
105 * @param listener listener to be added
106 */
Brian O'Connor66630c82014-10-02 21:08:19 -0700107 void addListener(IntentListener listener);
Brian O'Connorb876bf12014-10-02 14:59:37 -0700108
109 /**
110 * Removes the specified listener for intent events.
111 *
112 * @param listener listener to be removed
113 */
Brian O'Connor66630c82014-10-02 21:08:19 -0700114 void removeListener(IntentListener listener);
Brian O'Connor8016f342015-02-24 17:00:39 -0800115
116 /**
117 * Purges a specific intent from the system if it is FAILED or WITHDRAWN.
118 *
119 * @param key key of the intent to purge
120 */
121 void purge(Key key);
Brian O'Connorb876bf12014-10-02 14:59:37 -0700122}