go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/common/proto/structmask/structmask.proto (about)

     1  // Copyright 2021 The LUCI Authors.
     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  package structmask;
    18  
    19  option go_package = "go.chromium.org/luci/common/proto/structmask";
    20  
    21  // StructMask selects a subset of a google.protobuf.Struct.
    22  //
    23  // Usually used as a repeated field, to allow specifying a union of different
    24  // subsets.
    25  message StructMask {
    26    // A field path inside the struct to select.
    27    //
    28    // Each item can be:
    29    //   * `some_value` - a concrete dict key to follow (unless it is a number or
    30    //     includes `*`, use quotes in this case).
    31    //   * `"some_value"` - same, but quoted. Useful for selecting `*` or numbers
    32    //     literally. See https://pkg.go.dev/strconv#Unquote for syntax.
    33    //   * `<number>` (e.g. `0`) - a zero-based list index to follow.
    34    //     **Not implemented**.
    35    //   *  `*` - follow all dict keys and all list elements. Applies **only** to
    36    //     dicts and lists. Trying to recurse into a number or a string results
    37    //     in an empty match.
    38    //
    39    // When examining a value the following exceptional conditions result in
    40    // an empty match, which is represented by `null` for list elements or
    41    // omissions of the field for dicts:
    42    //   * Trying to follow a dict key while examining a list.
    43    //   * Trying to follow a key which is not present in the dict.
    44    //   * Trying to use `*` mask with values that aren't dicts or lists.
    45    //
    46    // When using `*`, the result is always a subset of the input. In particular
    47    // this is important when filtering lists: if a list of size N is selected by
    48    // the mask, then the filtered result will also always be a list of size N,
    49    // with elements filtered further according to the rest of the mask (perhaps
    50    // resulting in `null` elements on type mismatches, as explained above).
    51    repeated string path = 1;
    52  }