blob: 354db6f3dc669c230d9f92c6f33a722700d33703 [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
Jonathan Hart34f1e382015-02-24 16:52:23 -080019import java.util.Collections;
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070020import java.util.List;
21
Brian O'Connorb876bf12014-10-02 14:59:37 -070022/**
23 * Service for application submitting or withdrawing their intents.
24 */
25public interface IntentService {
26 /**
27 * Submits an intent into the system.
Thomas Vachuska4b420772014-10-30 16:46:17 -070028 * <p>
Brian O'Connor66630c82014-10-02 21:08:19 -070029 * This is an asynchronous request meaning that any compiling or
30 * installation activities may be done at later time.
Thomas Vachuska4b420772014-10-30 16:46:17 -070031 * </p>
Brian O'Connorb876bf12014-10-02 14:59:37 -070032 * @param intent intent to be submitted
33 */
34 void submit(Intent intent);
35
36 /**
37 * Withdraws an intent from the system.
Thomas Vachuska4b420772014-10-30 16:46:17 -070038 * <p>
Brian O'Connor66630c82014-10-02 21:08:19 -070039 * This is an asynchronous request meaning that the environment may be
40 * affected at later time.
Thomas Vachuska4b420772014-10-30 16:46:17 -070041 * </p>
Brian O'Connorb876bf12014-10-02 14:59:37 -070042 * @param intent intent to be withdrawn
43 */
44 void withdraw(Intent intent);
45
Thomas Vachuska83e090e2014-10-22 14:25:35 -070046 /**
Ray Milkeyf9af43c2015-02-09 16:45:48 -080047 * Fetches an intent based on its key.
48 *
49 * @param key key of the intent
50 * @return intent object if the key is found, null otherwise
51 */
52 public Intent getIntent(Key key);
53
54 /**
Brian O'Connor66630c82014-10-02 21:08:19 -070055 * Returns an iterable of intents currently in the system.
Brian O'Connorb876bf12014-10-02 14:59:37 -070056 *
57 * @return set of intents
58 */
Brian O'Connor66630c82014-10-02 21:08:19 -070059 Iterable<Intent> getIntents();
60
61 /**
62 * Returns the number of intents currently in the system.
63 *
64 * @return number of intents
65 */
66 long getIntentCount();
Brian O'Connorb876bf12014-10-02 14:59:37 -070067
68 /**
Brian O'Connorb876bf12014-10-02 14:59:37 -070069 * Retrieves the state of an intent by its identifier.
70 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080071 * @param intentKey intent identifier
Brian O'Connor66630c82014-10-02 21:08:19 -070072 * @return the intent state or null if one with the given identifier is not
toma1d16b62014-10-02 23:45:11 -070073 * found
Brian O'Connorb876bf12014-10-02 14:59:37 -070074 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -080075 IntentState getIntentState(Key intentKey);
Brian O'Connorb876bf12014-10-02 14:59:37 -070076
77 /**
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070078 * Returns the list of the installable events associated with the specified
79 * top-level intent.
80 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080081 * @param intentKey top-level intent identifier
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070082 * @return compiled installable intents
83 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -080084 List<Intent> getInstallableIntents(Key intentKey);
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070085
Jonathan Hart34f1e382015-02-24 16:52:23 -080086 // TODO remove defaults
Brian O'Connorbe28a872015-02-19 21:44:37 -080087 default boolean isLocal(Key intentKey) {
88 return true;
89 }
90
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070091 /**
Jonathan Hart34f1e382015-02-24 16:52:23 -080092 * Returns the list of intent requests pending processing.
93 *
94 * @return intents pending processing
95 */
96 default Iterable<Intent> getPending() {
97 return Collections.emptyList();
98 }
99
100 /**
Brian O'Connorb876bf12014-10-02 14:59:37 -0700101 * Adds the specified listener for intent events.
102 *
103 * @param listener listener to be added
104 */
Brian O'Connor66630c82014-10-02 21:08:19 -0700105 void addListener(IntentListener listener);
Brian O'Connorb876bf12014-10-02 14:59:37 -0700106
107 /**
108 * Removes the specified listener for intent events.
109 *
110 * @param listener listener to be removed
111 */
Brian O'Connor66630c82014-10-02 21:08:19 -0700112 void removeListener(IntentListener listener);
Brian O'Connorb876bf12014-10-02 14:59:37 -0700113}