blob: 745d7f4609c0d8cda195d29c23c3ff9442f0b64e [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
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;
David Glantzdfb3ceb2021-10-04 09:10:20 -050020import org.onosproject.core.ApplicationId;
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070021import org.onosproject.event.ListenerService;
Brian O'Connor9476fa12015-06-25 15:17:17 -040022
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070023import java.util.List;
24
Brian O'Connorb876bf12014-10-02 14:59:37 -070025/**
26 * Service for application submitting or withdrawing their intents.
27 */
Brian O'Connor9476fa12015-06-25 15:17:17 -040028@Beta
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070029public interface IntentService
30 extends ListenerService<IntentEvent, IntentListener> {
31
Brian O'Connorb876bf12014-10-02 14:59:37 -070032 /**
33 * Submits an intent into the system.
Thomas Vachuska4b420772014-10-30 16:46:17 -070034 * <p>
Brian O'Connor66630c82014-10-02 21:08:19 -070035 * This is an asynchronous request meaning that any compiling or
36 * installation activities may be done at later time.
Thomas Vachuska4b420772014-10-30 16:46:17 -070037 * </p>
Brian O'Connorb876bf12014-10-02 14:59:37 -070038 * @param intent intent to be submitted
39 */
40 void submit(Intent intent);
41
42 /**
43 * Withdraws an intent from the system.
Thomas Vachuska4b420772014-10-30 16:46:17 -070044 * <p>
Brian O'Connor66630c82014-10-02 21:08:19 -070045 * This is an asynchronous request meaning that the environment may be
46 * affected at later time.
Thomas Vachuska4b420772014-10-30 16:46:17 -070047 * </p>
Brian O'Connorb876bf12014-10-02 14:59:37 -070048 * @param intent intent to be withdrawn
49 */
50 void withdraw(Intent intent);
51
Thomas Vachuska83e090e2014-10-22 14:25:35 -070052 /**
Ray Milkey8c6d00e2015-03-13 14:14:34 -070053 * Purges a specific intent from the system if it is <b>FAILED</b> or
54 * <b>WITHDRAWN</b>. Otherwise, the intent remains in its current state.
55 *
56 * @param intent intent to purge
57 */
58 void purge(Intent intent);
59
60 /**
Ray Milkeyf9af43c2015-02-09 16:45:48 -080061 * Fetches an intent based on its key.
62 *
63 * @param key key of the intent
64 * @return intent object if the key is found, null otherwise
65 */
Brian O'Connorf2114992015-03-17 16:03:14 -070066 Intent getIntent(Key key);
Ray Milkeyf9af43c2015-02-09 16:45:48 -080067
68 /**
Brian O'Connor66630c82014-10-02 21:08:19 -070069 * Returns an iterable of intents currently in the system.
Brian O'Connorb876bf12014-10-02 14:59:37 -070070 *
71 * @return set of intents
72 */
Brian O'Connor66630c82014-10-02 21:08:19 -070073 Iterable<Intent> getIntents();
74
75 /**
David Glantzdfb3ceb2021-10-04 09:10:20 -050076 * Returns an iterable of all intents with this application ID.
77 *
78 * @param id the application ID to look up
79 * @return collection of intents
80 */
81 Iterable<Intent> getIntentsByAppId(ApplicationId id);
82
83 /**
Brian O'Connor38224302016-08-02 22:03:01 -070084 * Adds an intent data object to the pending map for processing.
85 * <p>
86 * This method is intended to only be called by core components, not
87 * applications.
88 * </p>
89 *
90 * @param intentData intent data to be added to pending map
91 */
92 void addPending(IntentData intentData);
93
94 /**
Thomas Vachuskac46af202015-06-03 16:43:27 -070095 * Returns an iterable of intent data objects currently in the system.
96 *
97 * @return set of intent data objects
98 */
99 Iterable<IntentData> getIntentData();
100
101 /**
Brian O'Connor66630c82014-10-02 21:08:19 -0700102 * Returns the number of intents currently in the system.
103 *
104 * @return number of intents
105 */
106 long getIntentCount();
Brian O'Connorb876bf12014-10-02 14:59:37 -0700107
108 /**
Brian O'Connorb876bf12014-10-02 14:59:37 -0700109 * Retrieves the state of an intent by its identifier.
110 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800111 * @param intentKey intent identifier
Brian O'Connor66630c82014-10-02 21:08:19 -0700112 * @return the intent state or null if one with the given identifier is not
toma1d16b62014-10-02 23:45:11 -0700113 * found
Brian O'Connorb876bf12014-10-02 14:59:37 -0700114 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800115 IntentState getIntentState(Key intentKey);
Brian O'Connorb876bf12014-10-02 14:59:37 -0700116
117 /**
Thomas Vachuska10d4abc2014-10-21 12:47:26 -0700118 * Returns the list of the installable events associated with the specified
119 * top-level intent.
120 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800121 * @param intentKey top-level intent identifier
Thomas Vachuska10d4abc2014-10-21 12:47:26 -0700122 * @return compiled installable intents
123 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800124 List<Intent> getInstallableIntents(Key intentKey);
Thomas Vachuska10d4abc2014-10-21 12:47:26 -0700125
Jonathan Hart13d3dd92015-02-25 16:09:42 -0800126 /**
127 * Signifies whether the local node is responsible for processing the given
128 * intent key.
129 *
130 * @param intentKey intent key to check
131 * @return true if the local node is responsible for the intent key,
132 * otherwise false
133 */
134 boolean isLocal(Key intentKey);
Brian O'Connorbe28a872015-02-19 21:44:37 -0800135
Thomas Vachuska10d4abc2014-10-21 12:47:26 -0700136 /**
Jonathan Hart34f1e382015-02-24 16:52:23 -0800137 * Returns the list of intent requests pending processing.
138 *
139 * @return intents pending processing
140 */
Jonathan Hart13d3dd92015-02-25 16:09:42 -0800141 Iterable<Intent> getPending();
Jonathan Hart34f1e382015-02-24 16:52:23 -0800142
Brian O'Connorb876bf12014-10-02 14:59:37 -0700143}