HONEYCOMB-58 - Routing Api
[honeycomb.git] / v3po / v3po2vpp / src / main / java / io / fd / honeycomb / translate / v3po / vppclassifier / VppClassifierContextManager.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
4  * 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:
7  *
8  *     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.
15  */
16
17 package io.fd.honeycomb.translate.v3po.vppclassifier;
18
19 import com.google.common.base.Optional;
20 import io.fd.honeycomb.translate.MappingContext;
21 import javax.annotation.Nonnull;
22 import javax.annotation.Nullable;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.VppNodeName;
24
25 /**
26  * Manages metadata for vpp-classifier
27  */
28 public interface VppClassifierContextManager {
29
30     /**
31      * Creates metadata for classify table.
32      *
33      * @param id             classify table index
34      * @param name           classify table name
35      * @param classifierNode name of VPP node the table is defined for
36      * @param ctx            mapping context providing context data for current transaction
37      */
38     void addTable(final int id, @Nonnull final String name, @Nullable final VppNodeName classifierNode,
39                   @Nonnull final MappingContext ctx);
40
41     /**
42      * Check whether metadata for given classify table metadata is present.
43      *
44      * @param name classify table name
45      * @param ctx  mapping context providing context data for current transaction
46      * @return true if present, false otherwise
47      */
48     boolean containsTable(@Nonnull String name, @Nonnull final MappingContext ctx);
49
50     /**
51      * Returns classify table index associated with the given name.
52      *
53      * @param name classify table name
54      * @param ctx  mapping context providing context data for current transaction
55      * @return integer index value matching supplied classify table name
56      * @throws IllegalArgumentException if classify table was not found
57      */
58     int getTableIndex(@Nonnull final String name, @Nonnull final MappingContext ctx);
59
60     /**
61      * Retrieves classify table name for given id. If not present, artificial name will be generated.
62      *
63      * @param id  classify table index
64      * @param ctx mapping context providing context data for current transaction
65      * @return classify table name matching supplied index
66      */
67     String getTableName(final int id, @Nonnull final MappingContext ctx);
68
69     /**
70      * Returns name of the base vpp node associated with the classify table.
71      *
72      * @param name classify table name
73      * @param ctx  mapping context providing context data for current transaction
74      * @return name of VPP node the table is defined for
75      */
76     Optional<String> getTableBaseNode(final String name, @Nonnull final MappingContext ctx);
77
78     /**
79      * Removes classify table metadata from current context.
80      *
81      * @param name classify table name
82      * @param ctx  mapping context providing context data for current transaction
83      */
84     void removeTable(@Nonnull final String name, @Nonnull final MappingContext ctx);
85
86     /**
87      * Adds relative node index to node name mapping for given classify table.
88      *
89      * @param tableName classify table name
90      * @param nodeIndex index of a vpp node, relative to table's base node
91      * @param nodeName  name of a vpp node
92      * @param ctx       mapping context providing context data for current transaction
93      */
94     void addNodeName(@Nonnull String tableName, final int nodeIndex, @Nonnull final String nodeName,
95                      @Nonnull final MappingContext ctx);
96
97     /**
98      * Retrieves node name associated with the given classify table and node index.
99      *
100      * @param tableIndex classify table index
101      * @param nodeIndex  relative index of a vpp node
102      * @param ctx        mapping context providing context data for current transaction
103      * @return name of vpp node
104      */
105     Optional<String> getNodeName(final int tableIndex, final int nodeIndex, @Nonnull final MappingContext ctx);
106 }