Marc De Leenheer | 57a5af0 | 2016-12-02 20:54:41 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Marc De Leenheer | 57a5af0 | 2016-12-02 20:54:41 -0800 | [diff] [blame] | 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 | package org.onosproject.tl1; |
| 17 | |
| 18 | import com.google.common.annotations.Beta; |
| 19 | |
| 20 | import java.util.Optional; |
| 21 | |
| 22 | /** |
| 23 | * Representation of a TL1 command, which is sent from the controller to a network element. |
| 24 | * |
| 25 | * The following shows the typical TL1 command structure: |
| 26 | * {@literal VERB-MODIFIER:<tid>:<aid>:<ctag>::parameter-list;} |
| 27 | * |
| 28 | * The ctag must be a non-zero decimal number consisting of not more than six characters, |
| 29 | * and is assumed to be a unique message identifier per device. |
| 30 | */ |
| 31 | @Beta |
| 32 | public interface Tl1Command { |
| 33 | |
| 34 | /** |
| 35 | * Minimum CTAG value. |
| 36 | */ |
| 37 | int MIN_CTAG = 0; |
| 38 | |
| 39 | /** |
| 40 | * Maximum CTAG value. |
| 41 | */ |
| 42 | int MAX_CTAG = 999999; |
| 43 | |
| 44 | /** |
| 45 | * Returns the verb of the command. |
| 46 | * |
| 47 | * @return the verb |
| 48 | */ |
| 49 | String verb(); |
| 50 | |
| 51 | /** |
| 52 | * Returns the modifier of the command. |
| 53 | * |
| 54 | * @return the modifier |
| 55 | */ |
| 56 | String modifier(); |
| 57 | |
| 58 | /** |
| 59 | * Returns the optional target identifier (tid). |
| 60 | * |
| 61 | * @return the tid |
| 62 | */ |
| 63 | Optional<String> tid(); |
| 64 | |
| 65 | /** |
| 66 | * Returns the optional access identifier (aid). |
| 67 | * |
| 68 | * @return the aid |
| 69 | */ |
| 70 | Optional<String> aid(); |
| 71 | |
| 72 | /** |
| 73 | * Returns the correlation tag (ctag). |
| 74 | * |
| 75 | * @return correlation tag |
| 76 | */ |
| 77 | int ctag(); |
| 78 | |
| 79 | /** |
| 80 | * Returns the optional parameters. |
| 81 | * |
| 82 | * @return the parameters |
| 83 | */ |
| 84 | Optional<String> parameters(); |
| 85 | |
| 86 | /** |
| 87 | * TL1 command builder. |
| 88 | * |
| 89 | * @param <T> builder implementation type |
| 90 | */ |
| 91 | interface Builder<T extends Builder<T>> { |
| 92 | /** |
| 93 | * Assigns a verb to this TL1 command. |
| 94 | * |
| 95 | * @param verb a verb |
| 96 | * @return this |
| 97 | */ |
| 98 | T withVerb(String verb); |
| 99 | |
| 100 | /** |
| 101 | * Assigns a modifier to this TL1 command. |
| 102 | * |
| 103 | * @param modifier a modifier |
| 104 | * @return this |
| 105 | */ |
| 106 | T withModifier(String modifier); |
| 107 | |
| 108 | /** |
| 109 | * Assigns a target identifier to this TL1 command. |
| 110 | * |
| 111 | * @param tid a tid |
| 112 | * @return this |
| 113 | */ |
| 114 | T forTid(String tid); |
| 115 | |
| 116 | /** |
| 117 | * Assigns an access identifier to this TL1 command. |
| 118 | * |
| 119 | * @param aid an aid |
| 120 | * @return this |
| 121 | */ |
| 122 | T withAid(String aid); |
| 123 | |
| 124 | /** |
| 125 | * Assigns a correlation tag to this TL1 command. |
| 126 | * |
| 127 | * @param ctag a ctag |
| 128 | * @return this |
| 129 | */ |
| 130 | T withCtag(int ctag); |
| 131 | |
| 132 | /** |
| 133 | * Assigns parameters to this TL1 command. |
| 134 | * |
| 135 | * @param parameters the parameters |
| 136 | * @return this |
| 137 | */ |
| 138 | T withParameters(String parameters); |
| 139 | |
| 140 | /** |
| 141 | * Builds a TL1 command. |
| 142 | * |
| 143 | * @return the TL1 command |
| 144 | */ |
| 145 | Tl1Command build(); |
| 146 | } |
| 147 | } |