gnmi.proto 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. //
  2. // Copyright 2016 Google Inc. All Rights Reserved.
  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. syntax = "proto3";
  17. import "google/protobuf/any.proto";
  18. import "google/protobuf/descriptor.proto";
  19. import "github.com/openconfig/gnmi/proto/gnmi_ext/gnmi_ext.proto";
  20. // Package gNMI defines a service specification for the gRPC Network Management
  21. // Interface. This interface is defined to be a standard interface via which
  22. // a network management system ("client") can subscribe to state values,
  23. // retrieve snapshots of state information, and manipulate the state of a data
  24. // tree supported by a device ("target").
  25. //
  26. // This document references the gNMI Specification which can be found at
  27. // http://github.com/openconfig/reference/blob/master/rpc/gnmi
  28. package gnmi;
  29. // Define a protobuf FileOption that defines the gNMI service version.
  30. extend google.protobuf.FileOptions {
  31. // The gNMI service semantic version.
  32. string gnmi_service = 1001;
  33. }
  34. // gNMI_service is the current version of the gNMI service, returned through
  35. // the Capabilities RPC.
  36. option (gnmi_service) = "0.6.0";
  37. service gNMI {
  38. // Capabilities allows the client to retrieve the set of capabilities that
  39. // is supported by the target. This allows the target to validate the
  40. // service version that is implemented and retrieve the set of models that
  41. // the target supports. The models can then be specified in subsequent RPCs
  42. // to restrict the set of data that is utilized.
  43. // Reference: gNMI Specification Section 3.2
  44. rpc Capabilities(CapabilityRequest) returns (CapabilityResponse);
  45. // Retrieve a snapshot of data from the target. A Get RPC requests that the
  46. // target snapshots a subset of the data tree as specified by the paths
  47. // included in the message and serializes this to be returned to the
  48. // client using the specified encoding.
  49. // Reference: gNMI Specification Section 3.3
  50. rpc Get(GetRequest) returns (GetResponse);
  51. // Set allows the client to modify the state of data on the target. The
  52. // paths to modified along with the new values that the client wishes
  53. // to set the value to.
  54. // Reference: gNMI Specification Section 3.4
  55. rpc Set(SetRequest) returns (SetResponse);
  56. // Subscribe allows a client to request the target to send it values
  57. // of particular paths within the data tree. These values may be streamed
  58. // at a particular cadence (STREAM), sent one off on a long-lived channel
  59. // (POLL), or sent as a one-off retrieval (ONCE).
  60. // Reference: gNMI Specification Section 3.5
  61. rpc Subscribe(stream SubscribeRequest) returns (stream SubscribeResponse);
  62. }
  63. // Notification is a re-usable message that is used to encode data from the
  64. // target to the client. A Notification carries two types of changes to the data
  65. // tree:
  66. // - Deleted values (delete) - a set of paths that have been removed from the
  67. // data tree.
  68. // - Updated values (update) - a set of path-value pairs indicating the path
  69. // whose value has changed in the data tree.
  70. // Reference: gNMI Specification Section 2.1
  71. message Notification {
  72. int64 timestamp = 1; // Timestamp in nanoseconds since Epoch.
  73. Path prefix = 2; // Prefix used for paths in the message.
  74. // An alias for the path specified in the prefix field.
  75. // Reference: gNMI Specification Section 2.4.2
  76. string alias = 3;
  77. repeated Update update = 4; // Data elements that have changed values.
  78. repeated Path delete = 5; // Data elements that have been deleted.
  79. }
  80. // Update is a re-usable message that is used to store a particular Path,
  81. // Value pair.
  82. // Reference: gNMI Specification Section 2.1
  83. message Update {
  84. Path path = 1; // The path (key) for the update.
  85. Value value = 2 [deprecated=true]; // The value (value) for the update.
  86. TypedValue val = 3; // The explicitly typed update value.
  87. uint32 duplicates = 4; // Number of coalesced duplicates.
  88. }
  89. // TypedValue is used to encode a value being sent between the client and
  90. // target (originated by either entity).
  91. message TypedValue {
  92. // One of the fields within the val oneof is populated with the value
  93. // of the update. The type of the value being included in the Update
  94. // determines which field should be populated. In the case that the
  95. // encoding is a particular form of the base protobuf type, a specific
  96. // field is used to store the value (e.g., json_val).
  97. oneof value {
  98. string string_val = 1; // String value.
  99. int64 int_val = 2; // Integer value.
  100. uint64 uint_val = 3; // Unsigned integer value.
  101. bool bool_val = 4; // Bool value.
  102. bytes bytes_val = 5; // Arbitrary byte sequence value.
  103. float float_val = 6; // Floating point value.
  104. Decimal64 decimal_val = 7; // Decimal64 encoded value.
  105. ScalarArray leaflist_val = 8; // Mixed type scalar array value.
  106. google.protobuf.Any any_val = 9; // protobuf.Any encoded bytes.
  107. bytes json_val = 10; // JSON-encoded text.
  108. bytes json_ietf_val = 11; // JSON-encoded text per RFC7951.
  109. string ascii_val = 12; // Arbitrary ASCII text.
  110. }
  111. }
  112. // Path encodes a data tree path as a series of repeated strings, with
  113. // each element of the path representing a data tree node name and the
  114. // associated attributes.
  115. // Reference: gNMI Specification Section 2.2.2.
  116. message Path {
  117. // Elements of the path are no longer encoded as a string, but rather within
  118. // the elem field as a PathElem message.
  119. repeated string element = 1 [deprecated=true];
  120. string origin = 2; // Label to disambiguate path.
  121. repeated PathElem elem = 3; // Elements of the path.
  122. string target = 4; // The name of the target
  123. // (Sec. 2.2.2.1)
  124. }
  125. // PathElem encodes an element of a gNMI path, along ith any attributes (keys)
  126. // that may be associated with it.
  127. // Reference: gNMI Specification Section 2.2.2.
  128. message PathElem {
  129. string name = 1; // The name of the element in the path.
  130. map<string, string> key = 2; // Map of key (attribute) name to value.
  131. }
  132. // Value encodes a data tree node's value - along with the way in which
  133. // the value is encoded. This message is deprecated by gNMI 0.3.0.
  134. // Reference: gNMI Specification Section 2.2.3.
  135. message Value {
  136. option deprecated = true;
  137. bytes value = 1; // Value of the variable being transmitted.
  138. Encoding type = 2; // Encoding used for the value field.
  139. }
  140. // Encoding defines the value encoding formats that are supported by the gNMI
  141. // protocol. These encodings are used by both the client (when sending Set
  142. // messages to modify the state of the target) and the target when serializing
  143. // data to be returned to the client (in both Subscribe and Get RPCs).
  144. // Reference: gNMI Specification Section 2.3
  145. enum Encoding {
  146. JSON = 0; // JSON encoded text.
  147. BYTES = 1; // Arbitrarily encoded bytes.
  148. PROTO = 2; // Encoded according to out-of-band agreed Protobuf.
  149. ASCII = 3; // ASCII text of an out-of-band agreed format.
  150. JSON_IETF = 4; // JSON encoded text as per RFC7951.
  151. }
  152. // Error message previously utilised to return errors to the client. Deprecated
  153. // in favour of using the google.golang.org/genproto/googleapis/rpc/status
  154. // message in the RPC response.
  155. // Reference: gNMI Specification Section 2.5
  156. message Error {
  157. option deprecated = true;
  158. uint32 code = 1; // Canonical gRPC error code.
  159. string message = 2; // Human readable error.
  160. google.protobuf.Any data = 3; // Optional additional information.
  161. }
  162. // Decimal64 is used to encode a fixed precision decimal number. The value
  163. // is expressed as a set of digits with the precision specifying the
  164. // number of digits following the decimal point in the digit set.
  165. message Decimal64 {
  166. int64 digits = 1; // Set of digits.
  167. uint32 precision = 2; // Number of digits following the decimal point.
  168. }
  169. // ScalarArray is used to encode a mixed-type array of values.
  170. message ScalarArray {
  171. // The set of elements within the array. Each TypedValue message should
  172. // specify only elements that have a field identifier of 1-7 (i.e., the
  173. // values are scalar values).
  174. repeated TypedValue element = 1;
  175. }
  176. // SubscribeRequest is the message sent by the client to the target when
  177. // initiating a subscription to a set of paths within the data tree. The
  178. // request field must be populated and the initial message must specify a
  179. // SubscriptionList to initiate a subscription. The message is subsequently
  180. // used to define aliases or trigger polled data to be sent by the target.
  181. // Reference: gNMI Specification Section 3.5.1.1
  182. message SubscribeRequest {
  183. oneof request {
  184. SubscriptionList subscribe = 1; // Specify the paths within a subscription.
  185. Poll poll = 3; // Trigger a polled update.
  186. AliasList aliases = 4; // Aliases to be created.
  187. }
  188. // Extension messages associated with the SubscribeRequest. See the
  189. // gNMI extension specification for further definition.
  190. repeated gnmi_ext.Extension extension = 5;
  191. }
  192. // Poll is sent within a SubscribeRequest to trigger the device to
  193. // send telemetry updates for the paths that are associated with the
  194. // subscription.
  195. // Reference: gNMI Specification Section Section 3.5.1.4
  196. message Poll {
  197. }
  198. // SubscribeResponse is the message used by the target within a Subscribe RPC.
  199. // The target includes a Notification message which is used to transmit values
  200. // of the path(s) that are associated with the subscription. The same message
  201. // is to indicate that the target has sent all data values once (is
  202. // synchronized).
  203. // Reference: gNMI Specification Section 3.5.1.4
  204. message SubscribeResponse {
  205. oneof response {
  206. Notification update = 1; // Changed or sampled value for a path.
  207. // Indicate target has sent all values associated with the subscription
  208. // at least once.
  209. bool sync_response = 3;
  210. // Deprecated in favour of google.golang.org/genproto/googleapis/rpc/status
  211. Error error = 4 [deprecated=true];
  212. }
  213. // Extension messages associated with the SubscribeResponse. See the
  214. // gNMI extension specification for further definition.
  215. repeated gnmi_ext.Extension extension = 5;
  216. }
  217. // SubscriptionList is used within a Subscribe message to specify the list of
  218. // paths that the client wishes to subscribe to. The message consists of a
  219. // list of (possibly prefixed) paths, and options that relate to the
  220. // subscription.
  221. // Reference: gNMI Specification Section 3.5.1.2
  222. message SubscriptionList {
  223. Path prefix = 1; // Prefix used for paths.
  224. repeated Subscription subscription = 2; // Set of subscriptions to create.
  225. // Whether target defined aliases are allowed within the subscription.
  226. bool use_aliases = 3;
  227. QOSMarking qos = 4; // DSCP marking to be used.
  228. // Mode of the subscription.
  229. enum Mode {
  230. STREAM = 0; // Values streamed by the target (Sec. 3.5.1.5.2).
  231. ONCE = 1; // Values sent once-off by the target (Sec. 3.5.1.5.1).
  232. POLL = 2; // Values sent in response to a poll request (Sec. 3.5.1.5.3).
  233. }
  234. Mode mode = 5;
  235. // Whether elements of the schema that are marked as eligible for aggregation
  236. // should be aggregated or not.
  237. bool allow_aggregation = 6;
  238. // The set of schemas that define the elements of the data tree that should
  239. // be sent by the target.
  240. repeated ModelData use_models = 7;
  241. // The encoding that the target should use within the Notifications generated
  242. // corresponding to the SubscriptionList.
  243. Encoding encoding = 8;
  244. // An optional field to specify that only updates to current state should be
  245. // sent to a client. If set, the initial state is not sent to the client but
  246. // rather only the sync message followed by any subsequent updates to the
  247. // current state. For ONCE and POLL modes, this causes the server to send only
  248. // the sync message (Sec. 3.5.2.3).
  249. bool updates_only = 9;
  250. }
  251. // Subscription is a single request within a SubscriptionList. The path
  252. // specified is interpreted (along with the prefix) as the elements of the data
  253. // tree that the client is subscribing to. The mode determines how the target
  254. // should trigger updates to be sent.
  255. // Reference: gNMI Specification Section 3.5.1.3
  256. message Subscription {
  257. Path path = 1; // The data tree path.
  258. SubscriptionMode mode = 2; // Subscription mode to be used.
  259. uint64 sample_interval = 3; // ns between samples in SAMPLE mode.
  260. // Indicates whether values that not changed should be sent in a SAMPLE
  261. // subscription.
  262. bool suppress_redundant = 4;
  263. // Specifies the maximum allowable silent period in nanoseconds when
  264. // suppress_redundant is in use. The target should send a value at least once
  265. // in the period specified.
  266. uint64 heartbeat_interval = 5;
  267. }
  268. // SubscriptionMode is the mode of the subscription, specifying how the
  269. // target must return values in a subscription.
  270. // Reference: gNMI Specification Section 3.5.1.3
  271. enum SubscriptionMode {
  272. TARGET_DEFINED = 0; // The target selects the relevant mode for each element.
  273. ON_CHANGE = 1; // The target sends an update on element value change.
  274. SAMPLE = 2; // The target samples values according to the interval.
  275. }
  276. // QOSMarking specifies the DSCP value to be set on transmitted telemetry
  277. // updates from the target.
  278. // Reference: gNMI Specification Section 3.5.1.2
  279. message QOSMarking {
  280. uint32 marking = 1;
  281. }
  282. // Alias specifies a data tree path, and an associated string which defines an
  283. // alias which is to be used for this path in the context of the RPC. The alias
  284. // is specified as a string which is prefixed with "#" to disambiguate it from
  285. // data tree element paths.
  286. // Reference: gNMI Specification Section 2.4.2
  287. message Alias {
  288. Path path = 1; // The path to be aliased.
  289. string alias = 2; // The alias value, a string prefixed by "#".
  290. }
  291. // AliasList specifies a list of aliases. It is used in a SubscribeRequest for
  292. // a client to create a set of aliases that the target is to utilize.
  293. // Reference: gNMI Specification Section 3.5.1.6
  294. message AliasList {
  295. repeated Alias alias = 1; // The set of aliases to be created.
  296. }
  297. // SetRequest is sent from a client to the target to update values in the data
  298. // tree. Paths are either deleted by the client, or modified by means of being
  299. // updated, or replaced. Where a replace is used, unspecified values are
  300. // considered to be replaced, whereas when update is used the changes are
  301. // considered to be incremental. The set of changes that are specified within
  302. // a single SetRequest are considered to be a transaction.
  303. // Reference: gNMI Specification Section 3.4.1
  304. message SetRequest {
  305. Path prefix = 1; // Prefix used for paths in the message.
  306. repeated Path delete = 2; // Paths to be deleted from the data tree.
  307. repeated Update replace = 3; // Updates specifying elements to be replaced.
  308. repeated Update update = 4; // Updates specifying elements to updated.
  309. // Extension messages associated with the SetRequest. See the
  310. // gNMI extension specification for further definition.
  311. repeated gnmi_ext.Extension extension = 5;
  312. }
  313. // SetResponse is the response to a SetRequest, sent from the target to the
  314. // client. It reports the result of the modifications to the data tree that were
  315. // specified by the client. Errors for this RPC should be reported using the
  316. // https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto
  317. // message in the RPC return. The gnmi.Error message can be used to add additional
  318. // details where required.
  319. // Reference: gNMI Specification Section 3.4.2
  320. message SetResponse {
  321. Path prefix = 1; // Prefix used for paths.
  322. // A set of responses specifying the result of the operations specified in
  323. // the SetRequest.
  324. repeated UpdateResult response = 2;
  325. Error message = 3 [deprecated=true]; // The overall status of the transaction.
  326. int64 timestamp = 4; // Timestamp of transaction (ns since epoch).
  327. // Extension messages associated with the SetResponse. See the
  328. // gNMI extension specification for further definition.
  329. repeated gnmi_ext.Extension extension = 5;
  330. }
  331. // UpdateResult is used within the SetResponse message to communicate the
  332. // result of an operation specified within a SetRequest message.
  333. // Reference: gNMI Specification Section 3.4.2
  334. message UpdateResult {
  335. // The operation that was associated with the Path specified.
  336. enum Operation {
  337. INVALID = 0;
  338. DELETE = 1; // The result relates to a delete of Path.
  339. REPLACE = 2; // The result relates to a replace of Path.
  340. UPDATE = 3; // The result relates to an update of Path.
  341. }
  342. // Deprecated timestamp for the UpdateResult, this field has been
  343. // replaced by the timestamp within the SetResponse message, since
  344. // all mutations effected by a set should be applied as a single
  345. // transaction.
  346. int64 timestamp = 1 [deprecated=true];
  347. Path path = 2; // Path associated with the update.
  348. Error message = 3 [deprecated=true]; // Status of the update operation.
  349. Operation op = 4; // Update operation type.
  350. }
  351. // GetRequest is sent when a client initiates a Get RPC. It is used to specify
  352. // the set of data elements for which the target should return a snapshot of
  353. // data. The use_models field specifies the set of schema modules that are to
  354. // be used by the target - where use_models is not specified then the target
  355. // must use all schema models that it has.
  356. // Reference: gNMI Specification Section 3.3.1
  357. message GetRequest {
  358. Path prefix = 1; // Prefix used for paths.
  359. repeated Path path = 2; // Paths requested by the client.
  360. // Type of elements within the data tree.
  361. enum DataType {
  362. ALL = 0; // All data elements.
  363. CONFIG = 1; // Config (rw) only elements.
  364. STATE = 2; // State (ro) only elements.
  365. // Data elements marked in the schema as operational. This refers to data
  366. // elements whose value relates to the state of processes or interactions
  367. // running on the device.
  368. OPERATIONAL = 3;
  369. }
  370. DataType type = 3; // The type of data being requested.
  371. Encoding encoding = 5; // Encoding to be used.
  372. repeated ModelData use_models = 6; // The schema models to be used.
  373. // Extension messages associated with the GetRequest. See the
  374. // gNMI extension specification for further definition.
  375. repeated gnmi_ext.Extension extension = 7;
  376. }
  377. // GetResponse is used by the target to respond to a GetRequest from a client.
  378. // The set of Notifications corresponds to the data values that are requested
  379. // by the client in the GetRequest.
  380. // Reference: gNMI Specification Section 3.3.2
  381. message GetResponse {
  382. repeated Notification notification = 1; // Data values.
  383. Error error = 2 [deprecated=true]; // Errors that occurred in the Get.
  384. // Extension messages associated with the GetResponse. See the
  385. // gNMI extension specification for further definition.
  386. repeated gnmi_ext.Extension extension = 3;
  387. }
  388. // CapabilityRequest is sent by the client in the Capabilities RPC to request
  389. // that the target reports its capabilities.
  390. // Reference: gNMI Specification Section 3.2.1
  391. message CapabilityRequest {
  392. // Extension messages associated with the CapabilityRequest. See the
  393. // gNMI extension specification for further definition.
  394. repeated gnmi_ext.Extension extension = 1;
  395. }
  396. // CapabilityResponse is used by the target to report its capabilities to the
  397. // client within the Capabilities RPC.
  398. // Reference: gNMI Specification Section 3.2.2
  399. message CapabilityResponse {
  400. repeated ModelData supported_models = 1; // Supported schema models.
  401. repeated Encoding supported_encodings = 2; // Supported encodings.
  402. string gNMI_version = 3; // Supported gNMI version.
  403. // Extension messages associated with the CapabilityResponse. See the
  404. // gNMI extension specification for further definition.
  405. repeated gnmi_ext.Extension extension = 4;
  406. }
  407. // ModelData is used to describe a set of schema modules. It can be used in a
  408. // CapabilityResponse where a target reports the set of modules that it
  409. // supports, and within the SubscribeRequest and GetRequest messages to specify
  410. // the set of models from which data tree elements should be reported.
  411. // Reference: gNMI Specification Section 3.2.3
  412. message ModelData {
  413. string name = 1; // Name of the model.
  414. string organization = 2; // Organization publishing the model.
  415. string version = 3; // Semantic version of the model.
  416. }