xref: /aosp_15_r20/external/grpc-grpc-java/xds/third_party/envoy/src/main/proto/envoy/type/matcher/v3/struct.proto (revision e07d83d3ffcef9ecfc9f7f475418ec639ff0e5fe)
1syntax = "proto3";
2
3package envoy.type.matcher.v3;
4
5import "envoy/type/matcher/v3/value.proto";
6
7import "udpa/annotations/status.proto";
8import "udpa/annotations/versioning.proto";
9import "validate/validate.proto";
10
11option java_package = "io.envoyproxy.envoy.type.matcher.v3";
12option java_outer_classname = "StructProto";
13option java_multiple_files = true;
14option go_package = "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3;matcherv3";
15option (udpa.annotations.file_status).package_version_status = ACTIVE;
16
17// [#protodoc-title: Struct matcher]
18
19// StructMatcher provides a general interface to check if a given value is matched in
20// google.protobuf.Struct. It uses ``path`` to retrieve the value
21// from the struct and then check if it's matched to the specified value.
22//
23// For example, for the following Struct:
24//
25// .. code-block:: yaml
26//
27//        fields:
28//          a:
29//            struct_value:
30//              fields:
31//                b:
32//                  struct_value:
33//                    fields:
34//                      c:
35//                        string_value: pro
36//                t:
37//                  list_value:
38//                    values:
39//                      - string_value: m
40//                      - string_value: n
41//
42// The following MetadataMatcher is matched as the path [a, b, c] will retrieve a string value "pro"
43// from the Metadata which is matched to the specified prefix match.
44//
45// .. code-block:: yaml
46//
47//    path:
48//    - key: a
49//    - key: b
50//    - key: c
51//    value:
52//      string_match:
53//        prefix: pr
54//
55// The following StructMatcher is matched as the code will match one of the string values in the
56// list at the path [a, t].
57//
58// .. code-block:: yaml
59//
60//    path:
61//    - key: a
62//    - key: t
63//    value:
64//      list_match:
65//        one_of:
66//          string_match:
67//            exact: m
68//
69// An example use of StructMatcher is to match metadata in envoy.v*.core.Node.
70message StructMatcher {
71  option (udpa.annotations.versioning).previous_message_type = "envoy.type.matcher.StructMatcher";
72
73  // Specifies the segment in a path to retrieve value from Struct.
74  message PathSegment {
75    option (udpa.annotations.versioning).previous_message_type =
76        "envoy.type.matcher.StructMatcher.PathSegment";
77
78    oneof segment {
79      option (validate.required) = true;
80
81      // If specified, use the key to retrieve the value in a Struct.
82      string key = 1 [(validate.rules).string = {min_len: 1}];
83    }
84  }
85
86  // The path to retrieve the Value from the Struct.
87  repeated PathSegment path = 2 [(validate.rules).repeated = {min_items: 1}];
88
89  // The StructMatcher is matched if the value retrieved by path is matched to this value.
90  ValueMatcher value = 3 [(validate.rules).message = {required: true}];
91}
92