syntax = "proto3";

package exschemapath;

option go_package = "github.com/openconfig/ygot/protomap/testdata/exschemapath";

import "github.com/openconfig/ygot/proto/ywrapper/ywrapper.proto";
import "github.com/openconfig/ygot/proto/yext/yext.proto";

message Root {
    System system = 1 [(yext.schemapath) = "/system"];
    message InterfaceKey {
        string name = 1 [(yext.schemapath) = "/interfaces/interface/config/name|/interfaces/interface/name"];
        Interface interface = 2;
    }
    repeated InterfaceKey interface = 422482938 [(yext.schemapath) = "/interfaces/interface"];
}

message Interface {
    ywrapper.StringValue description = 1 [(yext.schemapath) = "/interfaces/interface/config/description"];
    message SubinterfaceKey {
      uint64 index = 1 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/config/index|/interfaces/interface/subinterfaces/subinterface/index"];
      Subinterface subinterface = 2;
    }
    repeated SubinterfaceKey subinterface = 42 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface"];
}

message System {
    ywrapper.StringValue hostname = 1 [(yext.schemapath) = "/system/config/hostname"];
}

message Subinterface {
  ywrapper.StringValue description = 1 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/config/description"];
}

message ExampleMessage {
    ywrapper.BoolValue bo = 1 [(yext.schemapath) = "/bool"];
    ywrapper.BytesValue by = 2 [(yext.schemapath) = "/bytes"];
    ywrapper.Decimal64Value de = 3 [(yext.schemapath) = "/decimal"];
    ywrapper.IntValue in = 4 [(yext.schemapath) = "/int"];
    ywrapper.StringValue str = 5 [(yext.schemapath) = "/string"];
    ywrapper.UintValue ui = 6 [(yext.schemapath) = "/uint"];
    ExampleMessageChild ex = 7 [(yext.schemapath) = "/message"];
    repeated ExampleMessageKey em = 8 [(yext.schemapath) = "/list-name"];
    repeated ExampleMessageMultiKey multi = 9 [(yext.schemapath) = "/multi-list"];
    ExampleEnum en = 10 [(yext.schemapath) = "/enum"];
    ywrapper.StringValue compress =  11 [(yext.schemapath) = "/state/compress"];
    oneof oneof_field {
        string oneof_one = 12 [(yext.schemapath) = "/oneof"];
        uint64 oneof_two = 13 [(yext.schemapath) = "/oneof"];
    }
    repeated ywrapper.StringValue leaflist_string = 14 [(yext.schemapath) = "/leaflist-string", (yext.leaflist) = true];
    repeated ywrapper.BoolValue leaflist_bool = 16 [(yext.schemapath) = "/leaflist-bool", (yext.leaflist) = true];
    repeated ywrapper.IntValue leaflist_int = 17 [(yext.schemapath) = "/leaflist-int", (yext.leaflist) = true];
    repeated ywrapper.UintValue leaflist_uint = 18 [(yext.schemapath) = "/leaflist-uint", (yext.leaflist) = true];
    repeated ywrapper.BytesValue leaflist_bytes = 19 [(yext.schemapath) = "/leaflist-bytes", (yext.leaflist) = true];
    repeated ywrapper.Decimal64Value leaflist_decimal64 = 20 [(yext.schemapath) = "/leaflist-decimal64", (yext.leaflist) = true];
    repeated ExampleUnion leaflist_union = 15 [(yext.schemapath) = "/leaflist-union", (yext.leaflistunion) = true];
    ExampleNestedMessage nested = 21 [(yext.schemapath) = "/nested"];
    // TODO(robjs): support union fields, this needs a new annotation.
    BasicUnion union = 22 [(yext.schemapath) = "/union"];
    repeated ExampleUnionUnambiguous leaflist_union_b = 23 [(yext.schemapath) = "/leaflist-union-b", (yext.leaflistunion) = true];
    repeated ExampleUnionTwo leaflist_union_c = 24 [(yext.schemapath) = "/leaflist-union-c", (yext.leaflistunion) = true];
}

message ExampleNestedMessage {
  ywrapper.StringValue one = 1 [(yext.schemapath) = "/nested/one"];
  ywrapper.StringValue two = 2 [(yext.schemapath) = "/nested/two"];
  ExampleNestedGrandchild child = 3 [(yext.schemapath) = "/nested/child"];
}

message ExampleNestedGrandchild {
  ywrapper.StringValue one = 1 [(yext.schemapath) = "/nested/child/one"];
  ywrapper.StringValue two = 2 [(yext.schemapath) = "/nested/child/two"];
}

message BasicUnion {
    string str = 1 [(yext.schemapath) = "/union"];
}

message ExampleUnion {
    string str = 1 [(yext.schemapath) = "/leaflist-union"];
    uint64 uint = 2 [(yext.schemapath) = "/leaflist-union"];
    ExampleEnum enum = 3 [(yext.schemapath) = "/leaflist-union"];
}

message ExampleUnionTwo {
    bool b = 1 [(yext.schemapath) = "/leaflist-union-c"];
    float f = 2 [(yext.schemapath) = "/leaflist-union-c"];
}

message ExampleUnionUnambiguous {
    uint64 uint = 1 [(yext.schemapath) = "/leaflist-union-b"];
    ExampleEnum enum = 2 [(yext.schemapath) = "/leaflist-union-b"];
}

enum ExampleEnum {
    ENUM_UNSET = 0;
    ENUM_VALONE = 1 [(yext.yang_name) = "VAL_ONE"];
    ENUM_VALTWO = 2 [(yext.yang_name) = "VAL_TWO"];
    ENUM_VALFORTYTWO = 42 [(yext.yang_name) = "VAL_FORTYTWO"];
}

message ExampleMessageChild {
    ywrapper.StringValue str = 1 [(yext.schemapath) = "/message/str"];
}

message ExampleMessageKey {
    string single_key = 1 [(yext.schemapath) = "/list-name/single-key|/list-name/config/single-key"];
    ExampleMessageListMember member = 2;
}

message ExampleMessageListMember {
    ywrapper.StringValue str = 1 [(yext.schemapath) = "/list-name/another-field"];
    repeated NestedListKey child_list = 2 [(yext.schemapath) = "/list-name/child-list"];
}

message NestedListKey {
    string key_one = 1 [(yext.schemapath) = "/list-name/child-list/key-one"];
    NestedListMember field = 2;
}

message NestedListMember {
    ywrapper.StringValue str = 1 [(yext.schemapath) = "/list-name/child-list/str"];
}

message ExampleMessageMultiKey {
    uint32 index = 1 [(yext.schemapath) = "/multi-list/index|/multi-list/config/index"];
    string name = 2 [(yext.schemapath) = "/multi-list/name|/multi-list/config/name"];
    MultiKeyListMember member = 3;
}

message MultiKeyListMember {
    ywrapper.StringValue child = 1 [(yext.schemapath) = "/multi-list/config/child"];
}

message InvalidMessage {
    map<string, string> map_field = 1 [(yext.schemapath) = "/an/invalid/field"];
    string no_annotation = 2;
    repeated ExampleMessageKey km = 3 [(yext.schemapath) = "/one|/two"];
    repeated string ke = 4 [(yext.schemapath) = "/three"];
    repeated BadMessageKey bk = 5 [(yext.schemapath) = "/four"];
    repeated BadMessageMember bm = 6 [(yext.schemapath) = "/five"];
    ywrapper.StringValue invalid_annotated_path = 7 [(yext.schemapath) = "/one[two]"];
    repeated BadMessageKeyTwo bk_two = 8 [(yext.schemapath) = "/six"];
    InvalidMessage multiple_annotations_for_container = 9 [(yext.schemapath) = "/six|/seven"];
    repeated BadKeyPathMessage bkpm = 10 [(yext.schemapath) = "/eight"];
    repeated InvalidKeyPathKey ikpk = 11 [(yext.schemapath) = "/nine"];
}

message InvalidAnnotationMessage {
  string no_annotation = 1;
}

message BadMessageKeyTwo {
    string key = 1 [(yext.schemapath) = "/one|/one/two"];
}

message BadMessageKey {
    float bad_key_type = 1 [(yext.schemapath) = "/four/key"];
}

message BadMessageMember {
    string key = 1 [(yext.schemapath) = "/ok-key"];
    repeated string bad_type = 2 [(yext.schemapath) = "/bad-key"];
}

message BadKeyPathMessage {
    string key = 1 [(yext.schemapath) = "/"];
}

message InvalidKeyPathKey {
    string key = 1 [(yext.schemapath) = "/one[two]"];
}
