github.com/Psiphon-Labs/goarista@v0.0.0-20160825065156-d002785f4c67/openconfig/openconfig.proto (about) 1 // Copyright 2015 Google, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 syntax = "proto3"; 16 17 import "google/protobuf/any.proto"; 18 19 // Package openconfig defines the gRPC service for getting and setting the 20 // OpenConfig configuration and state of a network device. 21 // 22 // This package and its contents have not been ratified by OpenConfig. It is 23 // a working proposal by Google. 24 package openconfig; 25 26 // A Type describes what format a Value's data is encoded in. 27 enum Type { 28 JSON = 0; 29 BYTES = 1; 30 } 31 32 // A Path represents an open config path as a list of strings, one element 33 // per string. 34 message Path { 35 repeated string element = 1; 36 } 37 38 // A Value is either raw data or a JSON encoded value. An enumerated value is 39 // of type JSON, with the numeric value in the value field and the name of the 40 // enumerated value in the name field. 41 message Value { 42 bytes value = 1; 43 Type type = 2; 44 string name = 3; 45 } 46 47 // An Update maps a path to a value. 48 // 49 // In a Notification, an Update represents a new or updated value for path. The 50 // absolute path name is the concatenation of the Notification prefix and the 51 // Update path. Updates are only sent by the target. Path must always specify 52 // a leaf node. Value should be a scalar value (e.g., if Value is JSON encoded 53 // then the value 123 is acceptable, but {"x":123} is not). 54 // 55 // In a SetRequest, an Update contains a path to a read-write node and an 56 // optional value. The absolute path name is the concatenation of the 57 // SetRequest prefix and the Update path The path may reference either a 58 // directory or leaf node. If value is not present then path, and all its 59 // subelements, should be removed. If value set and path references a directory 60 // node, the value is the JSON encoded tree of values below that node, 61 // otherwise, if the value is a scalar and may be encoded in JSON are as raw 62 // BYTES. the value 63 // 64 // For an example of updating a directory node, consider a tree that has the 65 // following values: 66 // 67 // /a/b/c: 1 68 // /a/b/d: 2 69 // /a/b/e: 3 70 // 71 // And an Update of 72 // 73 // Path: /a/b 74 // Value: "{c: 4, f: 5}" 75 // 76 // The result is that /a/b/d and /a/b/e are removed, /a/b/c now has the value of 77 // 4, and /a/b/f is added with the value of 5. 78 message Update { 79 Path path = 1; 80 Value value = 2; 81 } 82 83 // A Notification is a list of updates to apply. Deletes are a list of paths to 84 // delete as long as their data is older than timestamp. Deleting nodes deletes 85 // all values below the node that are older than timestamp. Deletes are 86 // performed after updates are applied. Delete paths are created by 87 // concatenating the prefix, if present, with the individual paths. 88 // 89 // Update paths are created by concatenating the prefix, if present, with the 90 // paths contained in the Updates. 91 // 92 // It is valid to have a path be both in an update and match a delete. The 93 // deletion will only delete values that are older than this update. 94 // 95 // Each notification should contain at most a single update for a given path. 96 // If a nonconforming implementation does send multiple updates for a given path 97 // in a single notification, all but the final update should be ignored. 98 // 99 // The prefix should normally be the longest common prefix to all the individual 100 // update and delete path. This reduces the repetition of the common prefix in 101 // each update and/or delete. The individual updates and deletes also are a 102 // Path (repeated list of elements), allowing a notification such as: 103 // 104 // prefix: /a/b/c 105 // update: { 106 // path: d 107 // value: x 108 // } 109 // update: { 110 // path: e/f 111 // value: y 112 // } 113 // update: { 114 // path: e/g 115 // value: z 116 // } 117 // 118 // The prefix may begin with an alias. An alias is a Path with 1 or more 119 // elements, which maps to another Path. Aliases may be defined by either the 120 // target or the client. Target defined aliases are limited to a single 121 // element. Aliases are client specific (though a target may define the same 122 // alias for multiple clients). 123 // 124 // The target defines an alias by sending a Notification that has alias set and 125 // a non-empty prefix. When alias is set, a Notification need not provide 126 // updates or deletes. If the alias was previously defined, it is over ridden 127 // with the new definition. Once defined, the target may send the value of 128 // alias as the first element of a prefix. A target must not send target 129 // defined aliases to clients that do not specify the use_aliases option in the 130 // initial SubscriptionList message. A target does not need to define aliases 131 // even if the client does specify the use_aliases option in the initial 132 // SubscriptionLlist message. 133 // 134 // Clients define aliases by sending a SubscriptionRequest with aliases set. 135 // 136 // A target should use a define alias when possible, but is not required to. A 137 // target may ignore client defined aliases. 138 // 139 // Clients should not define aliases that valid paths in the data tree. The 140 // target must not define aliases that valid paths in the dat tree. 141 // 142 // If a target sends a notification with alias set, but not prefix, then it is 143 // indicating it will no longer use this alias. The client may delete this 144 // alias from its list of aliases. A target may not delete an alias defined by 145 // the client. It is implementation dependent on what happens if the client 146 // defines an alias that is also defined by the target. 147 // 148 // Aliases must not be used in UDP packets. 149 // 150 // If a client sets the use_aliases option, or defines aliases, in the initial 151 // SubscriptionList message, then it must always check the initial elements of a 152 // prefix against the list of known aliases, expanding the prefix as needed. 153 // Aliases must always be defined as fully expanded prefixes. Only single alias 154 // lookup is needed per Notification. 155 // 156 // Target defined aliases may be any unique string. A target may choose to use 157 // a unique prefix for aliases to make them visually distinct. For example, a 158 // target might construct all aliases as an @ character followed by a decimal or 159 // hexadecimal number (perhaps a hashed address in memory). 160 // 161 // Example: 162 // 163 // Define @42 as an alias: 164 // 165 // timestamp: 1439416376123456789 166 // prefix: "this_is" 167 // prefix: "a_long" 168 // prefix: "prefix" 169 // alias: "@42 170 // 171 // Use @42 as an alias to set /this_is/a_long/prefix/Ethernet0/0/1/in-octets to 172 // 17: 173 // 174 // timestamp: 1439416376456456456 175 // prefix: "@42" 176 // prefix: "Ethernet0/0/1" 177 // update: { 178 // path: { 179 // element: "in-octets" 180 // } 181 // value: 17 182 // } 183 // 184 // Delete the alias @42: 185 // 186 // timestamp: 1439416376987654321 187 // alias: @42 188 message Notification { 189 int64 timestamp = 1; 190 Path prefix = 2; 191 string alias = 3; 192 repeated Update update = 4; 193 repeated Path delete = 5; 194 } 195 196 // UDPWrapper adds metadata necessary for encapsulating a list of notifications 197 // into a UDP packet. It adds the ability to identify the agent that originated 198 // the Notifications, detect packet loss, and identify latency introduced by 199 // the target wrapping notifications. 200 // 201 // The target should keep the total size of a serialized UDPWrapper message 202 // small enough to not cause IP packet fragmentation. 203 message UDPWrapper { 204 // ID Identifies the device (e.g., Loopback IP address, linecard, ...) 205 // TODO(borman): Add examples. Perhaps Agent/module/submodule for juniper. 206 Path id = 1; 207 208 // Optional Epoch time of when the message is queued for transmit. 209 // Useful to quantify delay between message generation and transmission. 210 uint64 transmit_timestamp = 2; 211 212 // The sequence_number must start at 1 and increment by 1 for each new packet 213 // sent. A client may use this to determine if a packet was lost. 214 uint64 sequence_number = 3; 215 216 repeated Notification notification = 4; 217 } 218 219 service OpenConfig { 220 // Subscribe subscribes for streaming updates. Streaming updates are provided 221 // as a series of Notifications, each of which update a portion of the tree. 222 // The target must send the current values of all subscribed paths at the 223 // start of the stream, followed by a sync_response of 0. 224 // 225 // A Subscription operates in one of three modes. 226 // 227 // Streaming: This is the default mode. The target sends continual updates 228 // of each value as specified by each subscription's coalesce_interval. The 229 // client may request the target to resend the current value of a set of paths 230 // by sending a SyncRequest. 231 // 232 // Once: This mode is specified by setting once to true in the 233 // SubscriptionRequest. The target must close the stream after sending 234 // the sync_response of 0. The target should only send each value once. 235 // 236 // Poll: This mode is the equivalent of periodic Once requests but sent over a 237 // single stream. Polling is specified by setting poll_interval in the 238 // SubscriptionRequest to the expected number of nanoseconds between polls. 239 // The target stops sending updates after sending the sync_response of 0. 240 // After the polling interval, the client sends a new SubscriptionRequest with 241 // only the poll_interval set. The target must respond by sending the current 242 // values of all subscribed paths, once again followed with a sync_response of 243 // 0. This process then repeats until the client closes the request stream. 244 rpc Subscribe(stream SubscribeRequest) returns (stream SubscribeResponse); 245 246 // Get requests a single snapshot of the requested data. A Get request may 247 // contain a hint that the request will be repeated (i.e., polling). A Get is 248 // the equivalent of a Subscribe with once set, with the exception that all 249 // the key value pairs will be returned in a single response. 250 rpc Get(GetRequest) returns (GetResponse); 251 252 // Set sets the paths contained in the SetRequest to the values If a path does 253 // not exist, or is read-only the SetResponse will return an error. All paths 254 // in the SetRequest must be valid or the entire request must be rejected. If 255 // a path specifies a node, rather than the leaf, then the value must be the 256 // values of the node's children encoded in JSON. Binary data in the tree 257 // must be base64 encoded. 258 rpc Set(stream SetRequest) returns (stream SetResponse); 259 } 260 261 // An Error contains information about why a particular request failed. 262 // 263 // The canonical error codes are defined for each language. 264 // 265 // Go: import "google.golang.org/grpc/codes" 266 // C++: #include <grpc++/status_code_enum.h> 267 // Java: import static io.grpc.Status.Code; 268 // C: #include <grpc/status.h> 269 // C#: using Grpc.Core; 270 message Error { 271 uint32 code = 1; // Canonical grpc error code 272 string message = 2; // Human readable error 273 google.protobuf.Any data = 3; // optional additional information 274 } 275 276 // A SubscribeRequest is either a subscription request, a change to the 277 // heartbeat rate, or a request for resynchronization of data. It is always 278 // sent from the client to the target. 279 // 280 // Proxy is a list of proxies to use to get to the target. The first proxy 281 // listed is the address of the next hop. Targets ignore the proxy field (it 282 // should not be set). 283 message SubscribeRequest { 284 oneof request { 285 SubscriptionList subscribe = 1; 286 Heartbeat heartbeat = 2; // See description for Heartbeat 287 SyncRequest sync = 3; // See description for SyncRequest 288 AliasList aliases = 4; 289 } 290 repeated string proxy = 5; 291 } 292 293 // A SubscribeResponse is always sent from the target to the client. 294 message SubscribeResponse { 295 oneof response { 296 Notification update = 1; 297 Heartbeat heartbeat = 2; // See description for Heartbeat 298 uint64 sync_response = 3; // See description for SyncRequest 299 } 300 } 301 302 // SubscriptionList contains the list of individual subscriptions. A 303 // SubscriptionList is only valid if all of the contained subscriptions are 304 // valid. Setting once to false or poll_interval to 0 is the equivalent of the 305 // mode not being set (i.e., streaming). 306 // 307 // If prefix is set then all subscriptions in the list and all notifications 308 // generated are relative to prefix. 309 // 310 // If poll_interval is not set, then a SubscriptionList must only be sent once. 311 // If poll_interval is set, the SubscriptionLists following the initial 312 // SubscriptionList must only contain a poll_interval. 313 message SubscriptionList { 314 oneof mode { 315 bool once = 10; 316 uint64 poll_interval = 11; 317 } 318 repeated Subscription subscription = 1; 319 Path prefix = 2; 320 message Options { 321 bool use_aliases = 1; // client accepts target defined aliases. 322 } 323 Options options = 3; 324 } 325 326 // Subscription contains a path as well as the target side coalesce_interval for 327 // aggregating values, typically counters. If the target cannot support the 328 // interval the subscription must be rejected. The coalesce_interval is only 329 // used for subscriptions in streaming mode. If the coalesce_interval is 0 then 330 // the coalesce_interval is target specified. 331 message Subscription { 332 Path path = 1; 333 uint64 coalesce_interval = 2; // nanoseconds between updates 334 } 335 336 // An AliasList represents a list of aliases. 337 message AliasList { 338 repeated Alias alias = 1; 339 } 340 341 // An Alias specifies a preferred client defined alias for a specified path. An 342 // Alias is only sent from the client to the target. An alias is typically one 343 // element and is much shorter than the provided path. A target should 344 // substitute alias for path in Notifications. Targets may ignore Alias 345 // messages. 346 // 347 // The path must be fully expanded and not use an alias. 348 // 349 // If alias is set and path is not then the alias must no longer be used by the 350 // target, once received. A client may still see Notifications using the alias 351 // that were generated prior to the target receiving the request to stop using 352 // the alias. 353 message Alias { 354 Path path = 1; 355 Path alias = 2; 356 } 357 358 // A Heartbeat requests a (possibly repeated) response from the remote side. 359 message Heartbeat { 360 // interval is the maximum amount of time, in nanoseconds, between subsequent 361 // messages from the remote side. An empty message may be sent if no other 362 // messages are pending. If interval is 0 then the remote must immediately 363 // respond with a (possibly empty) message. 364 uint64 interval = 1; 365 } 366 367 // A SyncRequest requests that all values identified by path be resent. The 368 // target should respond with a series of updates and then a sync_response with 369 // the provided id, which should not be zero. 370 // 371 // A target is suggested to keep a timestamp of when the SyncRequest starts, 372 // followed by notifications, all of which are past the starting timestamp. 373 // Before sending the sync_response, a delete for each of the paths should be 374 // made with the starting timestamp. This will assure the client removes all 375 // stale data that was not part of the update. 376 // 377 // If prefix is set, each path is relative to prefix. 378 message SyncRequest { 379 uint64 id = 1; 380 Path prefix = 2; 381 repeated Path path = 3; 382 } 383 384 message GetRequest { 385 Path prefix = 1; // If set, each path is realitve to prefix 386 repeated Path path = 2; // List of paths to return information for 387 388 // If cache_interval is provided and is non-zero number of nanoseconds, it is 389 // a hint of when this get request will be repeated in the future. 390 int64 cache_interval = 3; 391 } 392 393 message GetResponse { 394 repeated Notification notification = 1; 395 } 396 397 // A SetRequest contains an optional prefix, a list of zero or more Paths to 398 // delete and a list of zero or more Updates. The delete and update paths are 399 // relative to prefix. Deletes should appear to happen prior to updates being 400 // applied. This supports delete, update, and replace: 401 // 402 // delete - a path is listed in the delete field 403 // update - a path is listed in the update field 404 // replace - a path is listed in both the delete field and the update field. 405 // 406 // The target must either apply all the deletes and updates or return an error. 407 // The deletes and updates should appear to be atomically applied. 408 message SetRequest { 409 Path prefix = 1; 410 repeated Path delete = 2; 411 repeated Update update = 3; 412 } 413 414 // A SetResponse contains responses to a SetRequest. The optional prefix is 415 // applied to all paths in response. Each path provided by a SetRequest needs a 416 // response, but there need not be a 1:1 correspondence between SetRequests and 417 // SetResponses (e.g., the target may issue a single response to multiple 418 // requests, or multiple responses to a single request). 419 message SetResponse { 420 Path prefix = 1; 421 repeated UpdateResponse response = 2; 422 } 423 424 // An UpdateResponse contains the response for a single path Update. 425 message UpdateResponse { 426 Path path = 1; // path provided in SetRequest. 427 Error error = 2; // optional error, if set, timestamp is optional 428 // The timestamp is the time, in nanoseconds since the epoch, that a Set was 429 // accepted (i.e., the request was valid). It does not imply the value was 430 // actually propagated to an underlying datastore. 431 int64 timestamp = 3; 432 }