From 09ea98929f7bd43f4cba69e5d925b2ea9f988f55 Mon Sep 17 00:00:00 2001 From: Karim Radhouani Date: Wed, 31 Jul 2024 18:10:22 -0700 Subject: [PATCH 1/2] add gNMI "Where" extension --- proto/gnmi/gnmi.proto | 1 + proto/gnmi_ext/gnmi_ext.proto | 96 +++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) diff --git a/proto/gnmi/gnmi.proto b/proto/gnmi/gnmi.proto index da0fed3f..be4c7b34 100644 --- a/proto/gnmi/gnmi.proto +++ b/proto/gnmi/gnmi.proto @@ -155,6 +155,7 @@ message Path { message PathElem { string name = 1; // The name of the element in the path. map key = 2; // Map of key (attribute) name to value. + repeated gnmi_ext.Extension extension = 3; } // Value encodes a data tree node's value - along with the way in which diff --git a/proto/gnmi_ext/gnmi_ext.proto b/proto/gnmi_ext/gnmi_ext.proto index ada5e39a..48d1b809 100644 --- a/proto/gnmi_ext/gnmi_ext.proto +++ b/proto/gnmi_ext/gnmi_ext.proto @@ -34,6 +34,7 @@ message Extension { History history = 3; // History extension. Commit commit = 4; // Commit confirmed extension. Depth depth = 5; // Depth extension. + Where where = 7; // Where extension. } } @@ -159,3 +160,98 @@ message Depth { // returned. uint32 level = 1; } + +// Where allows clients to specify a condition on a path. +// the condition must evaluate to true for its children to be included in +// the response. +// The Where extension can be included in a PathElem part of: +// - Path or Prefix in a GetRequest message or +// - Prefix in a SubscriptionList message or +// - Path in a Subscription message. +message Where { + oneof op { + // Expression defines the condition that needs to be evaluated. + // It is composed of an operation (one of WhereOp) and 2 operands + // (left and right). + Expression expr = 1; + // Path is a relative path that begins from the Path element to which the + // 'where' message was appended. + Path path = 2; + // Value is a list of values to be evaluated against a path. + Value value = 3; + } +} + +// Expression defines a message for an operator node in a binary expression +// tree. +// It defines the condition that needs to be evaluated. +// It is composed of an operation (one of WhereOp) and 2 operands +// (left and right). +message Expression { + WhereOp op = 1; + Where left = 2; + Where right = 3; +} + +// Path defines a message for a path node in the binary expression tree. +// It is a relative path that begins at the Path element to which the +// 'Where' message was appended. +message Path { + repeated string path = 1; +} + +// Value defines a message for a value node in the binary expression tree. +// one or multiple values can be specified based on the WhereOp value. +message Value { + oneof value_type { + int64 int_val = 1; + uint64 uint_val = 2; + string string_val = 3; + bool bool_val = 4; + float float_val = 5; + ValueList list_val = 6; // List of values of any type + } +} + +message ValueList { + repeated Value values = 1; +} + +// WhereOp defines the list of supported operations. +enum WhereOp { + // Must be treated as an error + UNSPECIFIED = 0; + // The AND operation returns true only if both operands are true, + // otherwise it returns false. + AND = 1; + // The OR operation returns true if at least one of the operands is true, + // otherwise it returns false. + OR = 2; + // The NOT operation returns true if the operand is false, + // and false if the operand is true. It inverts the boolean value. + NOT = 3; + // The EQUAL operation returns true if both operands are equal, + // otherwise it returns false. + EQUAL = 4; + // The NotEqual operation returns true if the operands are not equal, + // otherwise it returns false. + NOT_EQUAL = 5; + // The LessThan operation returns true if the left operand is less than + // the right operand, otherwise it returns false. + LESS_THAN = 6; + // The GreaterThan operation returns true if the left operand is greater + // than the right operand, otherwise it returns false. + GREATER_THAN = 7; + // The LessThanOrEqual operation returns true if the left operand is less + // than or equal to the right operand, otherwise it returns false. + LESS_THAN_OR_EQUAL = 8; + // The GreaterThanOrEqual operation returns true if the left operand is + // greater than or equal to the right operand, otherwise it returns false. + GREATER_THAN_OR_EQUAL = 9; + // The IN operation returns true if the left operand is found within the + // collection specified by the right operand, otherwise it returns false. + IN = 10; + // The NOT_IN operation returns true if the left operand is not found within + // the collection specified by the right operand, otherwise it returns false. + NOT_IN = 11; +} \ No newline at end of file From 5d37874394479201a53e80902449652e74038964 Mon Sep 17 00:00:00 2001 From: Karim Radhouani Date: Thu, 1 Aug 2024 07:41:26 -0700 Subject: [PATCH 2/2] change float to double --- proto/gnmi_ext/gnmi_ext.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proto/gnmi_ext/gnmi_ext.proto b/proto/gnmi_ext/gnmi_ext.proto index 48d1b809..9889dc94 100644 --- a/proto/gnmi_ext/gnmi_ext.proto +++ b/proto/gnmi_ext/gnmi_ext.proto @@ -208,8 +208,8 @@ message Value { uint64 uint_val = 2; string string_val = 3; bool bool_val = 4; - float float_val = 5; - ValueList list_val = 6; // List of values of any type + double double_val = 5; + ValueList list_val = 6; } }