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