diff --git a/app/ygnmi/cmd/generator/generator.go b/app/ygnmi/cmd/generator/generator.go index 5c00688..79f0fd5 100644 --- a/app/ygnmi/cmd/generator/generator.go +++ b/app/ygnmi/cmd/generator/generator.go @@ -65,6 +65,7 @@ func New() *cobra.Command { generator.Flags().String("fakeroot_name", "root", "Change the name of the ygot-generated fake root entity (ygot's default is \"device\").") generator.Flags().Bool("shorten_enum_leaf_names", true, "If also set to true when compress_paths=true, all leaves of type enumeration will by default not be prefixed with the name of its residing module.") generator.Flags().Bool("annotations", false, "If set to true, metadata annotations are added within the ygot-generated structs.") + generator.Flags().Bool("prefer_operational_state", true, "If set to true, state (config false) fields in the YANG schema are preferred over intended config leaves in the generated Go code with compressed schema paths. This flag is only valid for compress_paths=true.") // TODO(wenovus): Delete these hidden flags before or on v1 release. generator.Flags().Bool("typedef_enum_with_defmod", true, "If set to true, all typedefs of type enumeration or identity will be prefixed with the name of its module of definition instead of its residing module.") @@ -110,7 +111,13 @@ func generate(cmd *cobra.Command, args []string) error { } compressBehaviour := genutil.Uncompressed if viper.GetBool("compress_paths") { - compressBehaviour = genutil.PreferOperationalState + if viper.GetBool("prefer_operational_state") { + compressBehaviour = genutil.PreferOperationalState + } else { + compressBehaviour = genutil.PreferIntendedConfig + } + } + if compressBehaviour.CompressEnabled() { extraGenerators = pathgen.ExtraGenerators{ Extras: []pathgen.Generator{pathgen.GNMIGenerator}, } @@ -204,15 +211,10 @@ func generate(cmd *cobra.Command, args []string) error { } } - return generateStructs(args, schemaStructPath, version, fakeRootName) + return generateStructs(args, schemaStructPath, version, fakeRootName, compressBehaviour) } -func generateStructs(modules []string, schemaPath, version, fakeRootName string) error { - cmp := genutil.Uncompressed - if viper.GetBool("compress_paths") { - cmp = genutil.PreferOperationalState - } - +func generateStructs(modules []string, schemaPath, version, fakeRootName string, compressBehaviour genutil.CompressBehaviour) error { // Perform the code generation. cg := gogen.New( version, @@ -228,7 +230,7 @@ func generateStructs(modules []string, schemaPath, version, fakeRootName string) }, }, TransformationOptions: ygen.TransformationOpts{ - CompressBehaviour: cmp, + CompressBehaviour: compressBehaviour, SkipEnumDeduplication: false, GenerateFakeRoot: true, FakeRootName: fakeRootName, diff --git a/exampleoc/a/a-0.go b/exampleoc/a/a-0.go index aa94e2a..e1173b8 100644 --- a/exampleoc/a/a-0.go +++ b/exampleoc/a/a-0.go @@ -57,6 +57,7 @@ func (n *Model_SingleKey_CounterPath) State() ygnmi.SingletonQuery[float32] { return ygnmi.NewSingletonQuery[float32]( "Model_SingleKey", true, + false, true, false, true, @@ -93,6 +94,7 @@ func (n *Model_SingleKey_CounterPathAny) State() ygnmi.WildcardQuery[float32] { return ygnmi.NewWildcardQuery[float32]( "Model_SingleKey", true, + false, true, false, true, @@ -141,6 +143,7 @@ func (n *Model_SingleKey_CountersPath) State() ygnmi.SingletonQuery[[]float32] { return ygnmi.NewSingletonQuery[[]float32]( "Model_SingleKey", true, + false, true, false, true, @@ -177,6 +180,7 @@ func (n *Model_SingleKey_CountersPathAny) State() ygnmi.WildcardQuery[[]float32] return ygnmi.NewWildcardQuery[[]float32]( "Model_SingleKey", true, + false, true, false, true, @@ -225,6 +229,7 @@ func (n *Model_SingleKey_KeyPath) State() ygnmi.SingletonQuery[string] { return ygnmi.NewSingletonQuery[string]( "Model_SingleKey", true, + false, true, true, true, @@ -265,6 +270,7 @@ func (n *Model_SingleKey_KeyPathAny) State() ygnmi.WildcardQuery[string] { return ygnmi.NewWildcardQuery[string]( "Model_SingleKey", true, + false, true, true, true, @@ -308,6 +314,7 @@ func (n *Model_SingleKey_KeyPath) Config() ygnmi.ConfigQuery[string] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key"}, @@ -348,6 +355,7 @@ func (n *Model_SingleKey_KeyPathAny) Config() ygnmi.WildcardQuery[string] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key"}, @@ -397,6 +405,7 @@ func (n *Model_SingleKey_ValuePath) State() ygnmi.SingletonQuery[int64] { return ygnmi.NewSingletonQuery[int64]( "Model_SingleKey", true, + false, true, true, true, @@ -437,6 +446,7 @@ func (n *Model_SingleKey_ValuePathAny) State() ygnmi.WildcardQuery[int64] { return ygnmi.NewWildcardQuery[int64]( "Model_SingleKey", true, + false, true, true, true, @@ -480,6 +490,7 @@ func (n *Model_SingleKey_ValuePath) Config() ygnmi.ConfigQuery[int64] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "value"}, @@ -520,6 +531,7 @@ func (n *Model_SingleKey_ValuePathAny) Config() ygnmi.WildcardQuery[int64] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "value"}, @@ -794,6 +806,7 @@ func (n *Model_SingleKeyPath) State() ygnmi.SingletonQuery[*oc.Model_SingleKey] true, false, false, + false, true, false, n, @@ -818,6 +831,7 @@ func (n *Model_SingleKeyPathAny) State() ygnmi.WildcardQuery[*oc.Model_SingleKey true, false, false, + false, true, false, n, @@ -840,6 +854,7 @@ func (n *Model_SingleKeyPath) Config() ygnmi.ConfigQuery[*oc.Model_SingleKey] { return ygnmi.NewConfigQuery[*oc.Model_SingleKey]( "Model_SingleKey", false, + true, false, false, true, @@ -864,6 +879,7 @@ func (n *Model_SingleKeyPathAny) Config() ygnmi.WildcardQuery[*oc.Model_SingleKe return ygnmi.NewWildcardQuery[*oc.Model_SingleKey]( "Model_SingleKey", false, + true, false, false, true, @@ -890,6 +906,7 @@ func (n *Model_SingleKeyPathMap) State() ygnmi.SingletonQuery[map[string]*oc.Mod true, false, false, + false, true, true, n, @@ -920,6 +937,7 @@ func (n *Model_SingleKeyPathMapAny) State() ygnmi.WildcardQuery[map[string]*oc.M true, false, false, + false, true, true, n, @@ -948,6 +966,7 @@ func (n *Model_SingleKeyPathMap) Config() ygnmi.ConfigQuery[map[string]*oc.Model return ygnmi.NewConfigQuery[map[string]*oc.Model_SingleKey]( "Model", false, + true, false, false, true, @@ -978,6 +997,7 @@ func (n *Model_SingleKeyPathMapAny) Config() ygnmi.WildcardQuery[map[string]*oc. return ygnmi.NewWildcardQuery[map[string]*oc.Model_SingleKey]( "Model", false, + true, false, false, true, @@ -1030,6 +1050,7 @@ func (n *Model_SingleKey_OrderedListPathMap) State() ygnmi.SingletonQuery[*oc.Mo true, false, false, + false, true, true, n, @@ -1060,6 +1081,7 @@ func (n *Model_SingleKey_OrderedListPathMapAny) State() ygnmi.WildcardQuery[*oc. true, false, false, + false, true, true, n, @@ -1088,6 +1110,7 @@ func (n *Model_SingleKey_OrderedListPathMap) Config() ygnmi.ConfigQuery[*oc.Mode return ygnmi.NewConfigQuery[*oc.Model_SingleKey_OrderedList_OrderedMap]( "Model_SingleKey", false, + true, false, false, true, @@ -1118,6 +1141,7 @@ func (n *Model_SingleKey_OrderedListPathMapAny) Config() ygnmi.WildcardQuery[*oc return ygnmi.NewWildcardQuery[*oc.Model_SingleKey_OrderedList_OrderedMap]( "Model_SingleKey", false, + true, false, false, true, @@ -1170,6 +1194,7 @@ func (n *Model_SingleKey_SingleKeyPathMap) State() ygnmi.SingletonQuery[map[stri true, false, false, + false, true, true, n, @@ -1200,6 +1225,7 @@ func (n *Model_SingleKey_SingleKeyPathMapAny) State() ygnmi.WildcardQuery[map[st true, false, false, + false, true, true, n, @@ -1228,6 +1254,7 @@ func (n *Model_SingleKey_SingleKeyPathMap) Config() ygnmi.ConfigQuery[map[string return ygnmi.NewConfigQuery[map[string]*oc.Model_SingleKey_SingleKey]( "Model_SingleKey", false, + true, false, false, true, @@ -1258,6 +1285,7 @@ func (n *Model_SingleKey_SingleKeyPathMapAny) Config() ygnmi.WildcardQuery[map[s return ygnmi.NewWildcardQuery[map[string]*oc.Model_SingleKey_SingleKey]( "Model_SingleKey", false, + true, false, false, true, diff --git a/exampleoc/exampleocpath/exampleocpath.go b/exampleoc/exampleocpath/exampleocpath.go index 520c242..29a6e05 100644 --- a/exampleoc/exampleocpath/exampleocpath.go +++ b/exampleoc/exampleocpath/exampleocpath.go @@ -96,6 +96,7 @@ func (n *APath) State() ygnmi.SingletonQuery[*oc.A] { true, false, false, + false, true, false, n, @@ -120,6 +121,7 @@ func (n *APathAny) State() ygnmi.WildcardQuery[*oc.A] { true, false, false, + false, true, false, n, @@ -142,6 +144,7 @@ func (n *APath) Config() ygnmi.ConfigQuery[*oc.A] { return ygnmi.NewConfigQuery[*oc.A]( "A", false, + true, false, false, true, @@ -166,6 +169,7 @@ func (n *APathAny) Config() ygnmi.WildcardQuery[*oc.A] { return ygnmi.NewWildcardQuery[*oc.A]( "A", false, + true, false, false, true, @@ -236,6 +240,7 @@ func (n *A_BPath) State() ygnmi.SingletonQuery[*oc.A_B] { true, false, false, + false, true, false, n, @@ -260,6 +265,7 @@ func (n *A_BPathAny) State() ygnmi.WildcardQuery[*oc.A_B] { true, false, false, + false, true, false, n, @@ -282,6 +288,7 @@ func (n *A_BPath) Config() ygnmi.ConfigQuery[*oc.A_B] { return ygnmi.NewConfigQuery[*oc.A_B]( "A_B", false, + true, false, false, true, @@ -306,6 +313,7 @@ func (n *A_BPathAny) Config() ygnmi.WildcardQuery[*oc.A_B] { return ygnmi.NewWildcardQuery[*oc.A_B]( "A_B", false, + true, false, false, true, @@ -376,6 +384,7 @@ func (n *A_B_CPath) State() ygnmi.SingletonQuery[*oc.A_B_C] { true, false, false, + false, true, false, n, @@ -400,6 +409,7 @@ func (n *A_B_CPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C] { true, false, false, + false, true, false, n, @@ -422,6 +432,7 @@ func (n *A_B_CPath) Config() ygnmi.ConfigQuery[*oc.A_B_C] { return ygnmi.NewConfigQuery[*oc.A_B_C]( "A_B_C", false, + true, false, false, true, @@ -446,6 +457,7 @@ func (n *A_B_CPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C] { return ygnmi.NewWildcardQuery[*oc.A_B_C]( "A_B_C", false, + true, false, false, true, @@ -516,6 +528,7 @@ func (n *A_B_C_DPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D] { true, false, false, + false, true, false, n, @@ -540,6 +553,7 @@ func (n *A_B_C_DPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D] { true, false, false, + false, true, false, n, @@ -562,6 +576,7 @@ func (n *A_B_C_DPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D] { return ygnmi.NewConfigQuery[*oc.A_B_C_D]( "A_B_C_D", false, + true, false, false, true, @@ -586,6 +601,7 @@ func (n *A_B_C_DPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D] { return ygnmi.NewWildcardQuery[*oc.A_B_C_D]( "A_B_C_D", false, + true, false, false, true, @@ -656,6 +672,7 @@ func (n *A_B_C_D_EPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E] { true, false, false, + false, true, false, n, @@ -680,6 +697,7 @@ func (n *A_B_C_D_EPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E] { true, false, false, + false, true, false, n, @@ -702,6 +720,7 @@ func (n *A_B_C_D_EPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E] { return ygnmi.NewConfigQuery[*oc.A_B_C_D_E]( "A_B_C_D_E", false, + true, false, false, true, @@ -726,6 +745,7 @@ func (n *A_B_C_D_EPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E] { return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E]( "A_B_C_D_E", false, + true, false, false, true, @@ -796,6 +816,7 @@ func (n *A_B_C_D_E_FPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F] { true, false, false, + false, true, false, n, @@ -820,6 +841,7 @@ func (n *A_B_C_D_E_FPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F] { true, false, false, + false, true, false, n, @@ -842,6 +864,7 @@ func (n *A_B_C_D_E_FPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F] { return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F]( "A_B_C_D_E_F", false, + true, false, false, true, @@ -866,6 +889,7 @@ func (n *A_B_C_D_E_FPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F] { return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F]( "A_B_C_D_E_F", false, + true, false, false, true, @@ -936,6 +960,7 @@ func (n *A_B_C_D_E_F_GPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G] { true, false, false, + false, true, false, n, @@ -960,6 +985,7 @@ func (n *A_B_C_D_E_F_GPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G] { true, false, false, + false, true, false, n, @@ -982,6 +1008,7 @@ func (n *A_B_C_D_E_F_GPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G] { return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G]( "A_B_C_D_E_F_G", false, + true, false, false, true, @@ -1006,6 +1033,7 @@ func (n *A_B_C_D_E_F_GPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G] { return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G]( "A_B_C_D_E_F_G", false, + true, false, false, true, @@ -1076,6 +1104,7 @@ func (n *A_B_C_D_E_F_G_HPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G_H] true, false, false, + false, true, false, n, @@ -1100,6 +1129,7 @@ func (n *A_B_C_D_E_F_G_HPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_H true, false, false, + false, true, false, n, @@ -1122,6 +1152,7 @@ func (n *A_B_C_D_E_F_G_HPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G_H] { return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H]( "A_B_C_D_E_F_G_H", false, + true, false, false, true, @@ -1146,6 +1177,7 @@ func (n *A_B_C_D_E_F_G_HPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_ return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H]( "A_B_C_D_E_F_G_H", false, + true, false, false, true, @@ -1216,6 +1248,7 @@ func (n *A_B_C_D_E_F_G_H_IPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G_H true, false, false, + false, true, false, n, @@ -1240,6 +1273,7 @@ func (n *A_B_C_D_E_F_G_H_IPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G true, false, false, + false, true, false, n, @@ -1262,6 +1296,7 @@ func (n *A_B_C_D_E_F_G_H_IPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G_H_I return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I]( "A_B_C_D_E_F_G_H_I", false, + true, false, false, true, @@ -1286,6 +1321,7 @@ func (n *A_B_C_D_E_F_G_H_IPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_ return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I]( "A_B_C_D_E_F_G_H_I", false, + true, false, false, true, @@ -1356,6 +1392,7 @@ func (n *A_B_C_D_E_F_G_H_I_JPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G true, false, false, + false, true, false, n, @@ -1380,6 +1417,7 @@ func (n *A_B_C_D_E_F_G_H_I_JPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F true, false, false, + false, true, false, n, @@ -1402,6 +1440,7 @@ func (n *A_B_C_D_E_F_G_H_I_JPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G_H return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J]( "A_B_C_D_E_F_G_H_I_J", false, + true, false, false, true, @@ -1426,6 +1465,7 @@ func (n *A_B_C_D_E_F_G_H_I_JPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_ return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J]( "A_B_C_D_E_F_G_H_I_J", false, + true, false, false, true, @@ -1496,6 +1536,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_KPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F true, false, false, + false, true, false, n, @@ -1520,6 +1561,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_KPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E true, false, false, + false, true, false, n, @@ -1542,6 +1584,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_KPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J_K]( "A_B_C_D_E_F_G_H_I_J_K", false, + true, false, false, true, @@ -1566,6 +1609,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_KPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_ return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K]( "A_B_C_D_E_F_G_H_I_J_K", false, + true, false, false, true, @@ -1636,6 +1680,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_LPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E true, false, false, + false, true, false, n, @@ -1660,6 +1705,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_LPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D true, false, false, + false, true, false, n, @@ -1682,6 +1728,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_LPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L]( "A_B_C_D_E_F_G_H_I_J_K_L", false, + true, false, false, true, @@ -1706,6 +1753,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_LPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_ return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L]( "A_B_C_D_E_F_G_H_I_J_K_L", false, + true, false, false, true, @@ -1747,6 +1795,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_L_M_FooPath) State() ygnmi.SingletonQuery[string] return ygnmi.NewSingletonQuery[string]( "A_B_C_D_E_F_G_H_I_J_K_L_M", true, + false, true, true, true, @@ -1787,6 +1836,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_L_M_FooPathAny) State() ygnmi.WildcardQuery[strin return ygnmi.NewWildcardQuery[string]( "A_B_C_D_E_F_G_H_I_J_K_L_M", true, + false, true, true, true, @@ -1870,6 +1920,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_L_MPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D true, false, false, + false, true, false, n, @@ -1894,6 +1945,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_L_MPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C true, false, false, + false, true, false, n, @@ -1916,6 +1968,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_L_MPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L_M]( "A_B_C_D_E_F_G_H_I_J_K_L_M", false, + true, false, false, true, @@ -1940,6 +1993,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_L_MPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_ return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L_M]( "A_B_C_D_E_F_G_H_I_J_K_L_M", false, + true, false, false, true, @@ -1976,6 +2030,7 @@ func (n *ContainerPath) State() ygnmi.SingletonQuery[*oc.Container] { true, false, false, + false, true, false, n, @@ -2000,6 +2055,7 @@ func (n *ContainerPathAny) State() ygnmi.WildcardQuery[*oc.Container] { true, false, false, + false, true, false, n, @@ -2022,6 +2078,7 @@ func (n *ContainerPath) Config() ygnmi.ConfigQuery[*oc.Container] { return ygnmi.NewConfigQuery[*oc.Container]( "Container", false, + true, false, false, true, @@ -2046,6 +2103,7 @@ func (n *ContainerPathAny) Config() ygnmi.WildcardQuery[*oc.Container] { return ygnmi.NewWildcardQuery[*oc.Container]( "Container", false, + true, false, false, true, @@ -2330,6 +2388,7 @@ func (n *ModelPath) State() ygnmi.SingletonQuery[*oc.Model] { true, false, false, + false, true, false, n, @@ -2354,6 +2413,7 @@ func (n *ModelPathAny) State() ygnmi.WildcardQuery[*oc.Model] { true, false, false, + false, true, false, n, @@ -2376,6 +2436,7 @@ func (n *ModelPath) Config() ygnmi.ConfigQuery[*oc.Model] { return ygnmi.NewConfigQuery[*oc.Model]( "Model", false, + true, false, false, true, @@ -2400,6 +2461,7 @@ func (n *ModelPathAny) Config() ygnmi.WildcardQuery[*oc.Model] { return ygnmi.NewWildcardQuery[*oc.Model]( "Model", false, + true, false, false, true, @@ -2436,6 +2498,7 @@ func (n *Model_NoKeyPath) State() ygnmi.SingletonQuery[*oc.Model_NoKey] { true, false, false, + false, true, false, n, @@ -2460,6 +2523,7 @@ func (n *Model_NoKeyPathAny) State() ygnmi.WildcardQuery[*oc.Model_NoKey] { true, false, false, + false, true, false, n, @@ -2499,6 +2563,7 @@ func (n *Model_NoKey_Foo_KeyPath) State() ygnmi.SingletonQuery[string] { return ygnmi.NewSingletonQuery[string]( "Model_NoKey_Foo", true, + false, true, true, true, @@ -2539,6 +2604,7 @@ func (n *Model_NoKey_Foo_KeyPathAny) State() ygnmi.WildcardQuery[string] { return ygnmi.NewWildcardQuery[string]( "Model_NoKey_Foo", true, + false, true, true, true, @@ -2591,6 +2657,7 @@ func (n *Model_NoKey_Foo_ValuePath) State() ygnmi.SingletonQuery[int64] { return ygnmi.NewSingletonQuery[int64]( "Model_NoKey_Foo", true, + false, true, true, true, @@ -2631,6 +2698,7 @@ func (n *Model_NoKey_Foo_ValuePathAny) State() ygnmi.WildcardQuery[int64] { return ygnmi.NewWildcardQuery[int64]( "Model_NoKey_Foo", true, + false, true, true, true, @@ -2750,6 +2818,7 @@ func (n *Model_NoKey_FooPath) State() ygnmi.SingletonQuery[*oc.Model_NoKey_Foo] true, false, false, + false, true, false, n, @@ -2774,6 +2843,7 @@ func (n *Model_NoKey_FooPathAny) State() ygnmi.WildcardQuery[*oc.Model_NoKey_Foo true, false, false, + false, true, false, n, @@ -2842,6 +2912,7 @@ func (n *ParentPath) State() ygnmi.SingletonQuery[*oc.Parent] { true, false, false, + false, true, false, n, @@ -2866,6 +2937,7 @@ func (n *ParentPathAny) State() ygnmi.WildcardQuery[*oc.Parent] { true, false, false, + false, true, false, n, @@ -2888,6 +2960,7 @@ func (n *ParentPath) Config() ygnmi.ConfigQuery[*oc.Parent] { return ygnmi.NewConfigQuery[*oc.Parent]( "Parent", false, + true, false, false, true, @@ -2912,6 +2985,7 @@ func (n *ParentPathAny) Config() ygnmi.WildcardQuery[*oc.Parent] { return ygnmi.NewWildcardQuery[*oc.Parent]( "Parent", false, + true, false, false, true, @@ -2953,6 +3027,7 @@ func (n *Parent_Child_FivePath) State() ygnmi.SingletonQuery[float32] { return ygnmi.NewSingletonQuery[float32]( "Parent_Child", true, + false, true, false, true, @@ -2989,6 +3064,7 @@ func (n *Parent_Child_FivePathAny) State() ygnmi.WildcardQuery[float32] { return ygnmi.NewWildcardQuery[float32]( "Parent_Child", true, + false, true, false, true, @@ -3026,6 +3102,7 @@ func (n *Parent_Child_FivePath) Config() ygnmi.ConfigQuery[float32] { "Parent_Child", false, true, + true, false, true, false, @@ -3062,6 +3139,7 @@ func (n *Parent_Child_FivePathAny) Config() ygnmi.WildcardQuery[float32] { "Parent_Child", false, true, + true, false, true, false, @@ -3109,6 +3187,7 @@ func (n *Parent_Child_FourPath) State() ygnmi.SingletonQuery[oc.Binary] { return ygnmi.NewSingletonQuery[oc.Binary]( "Parent_Child", true, + false, true, false, true, @@ -3145,6 +3224,7 @@ func (n *Parent_Child_FourPathAny) State() ygnmi.WildcardQuery[oc.Binary] { return ygnmi.NewWildcardQuery[oc.Binary]( "Parent_Child", true, + false, true, false, true, @@ -3182,6 +3262,7 @@ func (n *Parent_Child_FourPath) Config() ygnmi.ConfigQuery[oc.Binary] { "Parent_Child", false, true, + true, false, true, false, @@ -3218,6 +3299,7 @@ func (n *Parent_Child_FourPathAny) Config() ygnmi.WildcardQuery[oc.Binary] { "Parent_Child", false, true, + true, false, true, false, @@ -3265,6 +3347,7 @@ func (n *Parent_Child_OnePath) State() ygnmi.SingletonQuery[string] { return ygnmi.NewSingletonQuery[string]( "Parent_Child", true, + false, true, true, true, @@ -3305,6 +3388,7 @@ func (n *Parent_Child_OnePathAny) State() ygnmi.WildcardQuery[string] { return ygnmi.NewWildcardQuery[string]( "Parent_Child", true, + false, true, true, true, @@ -3348,6 +3432,7 @@ func (n *Parent_Child_OnePath) Config() ygnmi.ConfigQuery[string] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "one"}, @@ -3388,6 +3473,7 @@ func (n *Parent_Child_OnePathAny) Config() ygnmi.WildcardQuery[string] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "one"}, @@ -3437,6 +3523,7 @@ func (n *Parent_Child_SixPath) State() ygnmi.SingletonQuery[[]float32] { return ygnmi.NewSingletonQuery[[]float32]( "Parent_Child", true, + false, true, false, true, @@ -3473,6 +3560,7 @@ func (n *Parent_Child_SixPathAny) State() ygnmi.WildcardQuery[[]float32] { return ygnmi.NewWildcardQuery[[]float32]( "Parent_Child", true, + false, true, false, true, @@ -3510,6 +3598,7 @@ func (n *Parent_Child_SixPath) Config() ygnmi.ConfigQuery[[]float32] { "Parent_Child", false, true, + true, false, true, false, @@ -3546,6 +3635,7 @@ func (n *Parent_Child_SixPathAny) Config() ygnmi.WildcardQuery[[]float32] { "Parent_Child", false, true, + true, false, true, false, @@ -3593,6 +3683,7 @@ func (n *Parent_Child_ThreePath) State() ygnmi.SingletonQuery[oc.E_Child_Three] return ygnmi.NewSingletonQuery[oc.E_Child_Three]( "Parent_Child", true, + false, true, false, true, @@ -3629,6 +3720,7 @@ func (n *Parent_Child_ThreePathAny) State() ygnmi.WildcardQuery[oc.E_Child_Three return ygnmi.NewWildcardQuery[oc.E_Child_Three]( "Parent_Child", true, + false, true, false, true, @@ -3666,6 +3758,7 @@ func (n *Parent_Child_ThreePath) Config() ygnmi.ConfigQuery[oc.E_Child_Three] { "Parent_Child", false, true, + true, false, true, false, @@ -3702,6 +3795,7 @@ func (n *Parent_Child_ThreePathAny) Config() ygnmi.WildcardQuery[oc.E_Child_Thre "Parent_Child", false, true, + true, false, true, false, @@ -3749,6 +3843,7 @@ func (n *Parent_Child_TwoPath) State() ygnmi.SingletonQuery[string] { return ygnmi.NewSingletonQuery[string]( "Parent_Child", true, + false, true, true, true, @@ -3789,6 +3884,7 @@ func (n *Parent_Child_TwoPathAny) State() ygnmi.WildcardQuery[string] { return ygnmi.NewWildcardQuery[string]( "Parent_Child", true, + false, true, true, true, @@ -4052,6 +4148,7 @@ func (n *Parent_ChildPath) State() ygnmi.SingletonQuery[*oc.Parent_Child] { true, false, false, + false, true, false, n, @@ -4076,6 +4173,7 @@ func (n *Parent_ChildPathAny) State() ygnmi.WildcardQuery[*oc.Parent_Child] { true, false, false, + false, true, false, n, @@ -4098,6 +4196,7 @@ func (n *Parent_ChildPath) Config() ygnmi.ConfigQuery[*oc.Parent_Child] { return ygnmi.NewConfigQuery[*oc.Parent_Child]( "Parent_Child", false, + true, false, false, true, @@ -4122,6 +4221,7 @@ func (n *Parent_ChildPathAny) Config() ygnmi.WildcardQuery[*oc.Parent_Child] { return ygnmi.NewWildcardQuery[*oc.Parent_Child]( "Parent_Child", false, + true, false, false, true, @@ -4163,6 +4263,7 @@ func (n *RemoteContainer_ALeafPath) State() ygnmi.SingletonQuery[string] { return ygnmi.NewSingletonQuery[string]( "RemoteContainer", true, + false, true, true, true, @@ -4203,6 +4304,7 @@ func (n *RemoteContainer_ALeafPathAny) State() ygnmi.WildcardQuery[string] { return ygnmi.NewWildcardQuery[string]( "RemoteContainer", true, + false, true, true, true, @@ -4246,6 +4348,7 @@ func (n *RemoteContainer_ALeafPath) Config() ygnmi.ConfigQuery[string] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "a-leaf"}, @@ -4286,6 +4389,7 @@ func (n *RemoteContainer_ALeafPathAny) Config() ygnmi.WildcardQuery[string] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "a-leaf"}, @@ -4366,6 +4470,7 @@ func (n *RemoteContainerPath) State() ygnmi.SingletonQuery[*oc.RemoteContainer] true, false, false, + false, true, false, n, @@ -4390,6 +4495,7 @@ func (n *RemoteContainerPathAny) State() ygnmi.WildcardQuery[*oc.RemoteContainer true, false, false, + false, true, false, n, @@ -4412,6 +4518,7 @@ func (n *RemoteContainerPath) Config() ygnmi.ConfigQuery[*oc.RemoteContainer] { return ygnmi.NewConfigQuery[*oc.RemoteContainer]( "RemoteContainer", false, + true, false, false, true, @@ -4436,6 +4543,7 @@ func (n *RemoteContainerPathAny) Config() ygnmi.WildcardQuery[*oc.RemoteContaine return ygnmi.NewWildcardQuery[*oc.RemoteContainer]( "RemoteContainer", false, + true, false, false, true, @@ -4573,6 +4681,7 @@ func (b *Batch) State() ygnmi.SingletonQuery[*oc.Root] { true, false, false, + false, true, false, ygnmi.NewDeviceRootBase(), @@ -4598,6 +4707,7 @@ func (b *Batch) Config() ygnmi.SingletonQuery[*oc.Root] { return ygnmi.NewSingletonQuery[*oc.Root]( "Root", false, + true, false, false, true, @@ -4624,6 +4734,7 @@ func (n *RootPath) State() ygnmi.SingletonQuery[*oc.Root] { true, false, false, + false, true, false, n, @@ -4646,6 +4757,7 @@ func (n *RootPath) Config() ygnmi.ConfigQuery[*oc.Root] { return ygnmi.NewConfigQuery[*oc.Root]( "Root", false, + true, false, false, true, diff --git a/exampleoc/modelb/modelb-0.go b/exampleoc/modelb/modelb-0.go index 6ab0e1a..6c62dad 100644 --- a/exampleoc/modelb/modelb-0.go +++ b/exampleoc/modelb/modelb-0.go @@ -69,6 +69,7 @@ func (n *Model_MultiKey_Key1Path) State() ygnmi.SingletonQuery[uint32] { return ygnmi.NewSingletonQuery[uint32]( "Model_MultiKey", true, + false, true, true, true, @@ -109,6 +110,7 @@ func (n *Model_MultiKey_Key1PathAny) State() ygnmi.WildcardQuery[uint32] { return ygnmi.NewWildcardQuery[uint32]( "Model_MultiKey", true, + false, true, true, true, @@ -152,6 +154,7 @@ func (n *Model_MultiKey_Key1Path) Config() ygnmi.ConfigQuery[uint32] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key1"}, @@ -192,6 +195,7 @@ func (n *Model_MultiKey_Key1PathAny) Config() ygnmi.WildcardQuery[uint32] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key1"}, @@ -241,6 +245,7 @@ func (n *Model_MultiKey_Key2Path) State() ygnmi.SingletonQuery[uint64] { return ygnmi.NewSingletonQuery[uint64]( "Model_MultiKey", true, + false, true, true, true, @@ -281,6 +286,7 @@ func (n *Model_MultiKey_Key2PathAny) State() ygnmi.WildcardQuery[uint64] { return ygnmi.NewWildcardQuery[uint64]( "Model_MultiKey", true, + false, true, true, true, @@ -324,6 +330,7 @@ func (n *Model_MultiKey_Key2Path) Config() ygnmi.ConfigQuery[uint64] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key2"}, @@ -364,6 +371,7 @@ func (n *Model_MultiKey_Key2PathAny) Config() ygnmi.WildcardQuery[uint64] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key2"}, @@ -498,6 +506,7 @@ func (n *Model_MultiKeyPath) State() ygnmi.SingletonQuery[*oc.Model_MultiKey] { true, false, false, + false, true, false, n, @@ -522,6 +531,7 @@ func (n *Model_MultiKeyPathAny) State() ygnmi.WildcardQuery[*oc.Model_MultiKey] true, false, false, + false, true, false, n, @@ -544,6 +554,7 @@ func (n *Model_MultiKeyPath) Config() ygnmi.ConfigQuery[*oc.Model_MultiKey] { return ygnmi.NewConfigQuery[*oc.Model_MultiKey]( "Model_MultiKey", false, + true, false, false, true, @@ -568,6 +579,7 @@ func (n *Model_MultiKeyPathAny) Config() ygnmi.WildcardQuery[*oc.Model_MultiKey] return ygnmi.NewWildcardQuery[*oc.Model_MultiKey]( "Model_MultiKey", false, + true, false, false, true, @@ -594,6 +606,7 @@ func (n *Model_MultiKeyPathMap) State() ygnmi.SingletonQuery[map[oc.Model_MultiK true, false, false, + false, true, true, n, @@ -624,6 +637,7 @@ func (n *Model_MultiKeyPathMapAny) State() ygnmi.WildcardQuery[map[oc.Model_Mult true, false, false, + false, true, true, n, @@ -652,6 +666,7 @@ func (n *Model_MultiKeyPathMap) Config() ygnmi.ConfigQuery[map[oc.Model_MultiKey return ygnmi.NewConfigQuery[map[oc.Model_MultiKey_Key]*oc.Model_MultiKey]( "Model", false, + true, false, false, true, @@ -682,6 +697,7 @@ func (n *Model_MultiKeyPathMapAny) Config() ygnmi.WildcardQuery[map[oc.Model_Mul return ygnmi.NewWildcardQuery[map[oc.Model_MultiKey_Key]*oc.Model_MultiKey]( "Model", false, + true, false, false, true, diff --git a/internal/exampleocconfig/README.md b/internal/exampleocconfig/README.md new file mode 100644 index 0000000..703805a --- /dev/null +++ b/internal/exampleocconfig/README.md @@ -0,0 +1 @@ +This package MAY change without warning, and if possible SHOULD NOT be imported into your application. \ No newline at end of file diff --git a/internal/exampleocconfig/a/a-0.go b/internal/exampleocconfig/a/a-0.go new file mode 100644 index 0000000..63b9768 --- /dev/null +++ b/internal/exampleocconfig/a/a-0.go @@ -0,0 +1,1312 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* +Package a is a generated package which contains definitions +of structs which generate gNMI paths for a YANG schema. + +This package was generated by ygnmi version: (devel): (ygot: v0.29.12) +using the following YANG input files: + - ../../pathgen/testdata/yang/openconfig-simple.yang + - ../../pathgen/testdata/yang/openconfig-withlistval.yang + - ../../pathgen/testdata/yang/openconfig-nested.yang + +Imported modules were sourced from: +*/ +package a + +import ( + "reflect" + + oc "github.com/openconfig/ygnmi/internal/exampleocconfig" + "github.com/openconfig/ygnmi/ygnmi" + "github.com/openconfig/ygot/ygot" + "github.com/openconfig/ygot/ytypes" +) + +// Model_SingleKey_CounterPath represents the /openconfig-withlistval/model/a/single-key/state/counter YANG schema element. +type Model_SingleKey_CounterPath struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// Model_SingleKey_CounterPathAny represents the wildcard version of the /openconfig-withlistval/model/a/single-key/state/counter YANG schema element. +type Model_SingleKey_CounterPathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/counter" +// Path from root: "/model/a/single-key/state/counter" +func (n *Model_SingleKey_CounterPath) State() ygnmi.SingletonQuery[float32] { + return ygnmi.NewSingletonQuery[float32]( + "Model_SingleKey", + true, + true, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"state", "counter"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (float32, bool) { + ret := gs.(*oc.Model_SingleKey).Counter + return ygot.BinaryToFloat32(ret), !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/counter" +// Path from root: "/model/a/single-key/state/counter" +func (n *Model_SingleKey_CounterPathAny) State() ygnmi.WildcardQuery[float32] { + return ygnmi.NewWildcardQuery[float32]( + "Model_SingleKey", + true, + true, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"state", "counter"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (float32, bool) { + ret := gs.(*oc.Model_SingleKey).Counter + return ygot.BinaryToFloat32(ret), !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Model_SingleKey_CountersPath represents the /openconfig-withlistval/model/a/single-key/state/counters YANG schema element. +type Model_SingleKey_CountersPath struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// Model_SingleKey_CountersPathAny represents the wildcard version of the /openconfig-withlistval/model/a/single-key/state/counters YANG schema element. +type Model_SingleKey_CountersPathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/counters" +// Path from root: "/model/a/single-key/state/counters" +func (n *Model_SingleKey_CountersPath) State() ygnmi.SingletonQuery[[]float32] { + return ygnmi.NewSingletonQuery[[]float32]( + "Model_SingleKey", + true, + true, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"state", "counters"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) ([]float32, bool) { + ret := gs.(*oc.Model_SingleKey).Counters + return binarySliceToFloatSlice(ret), !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/counters" +// Path from root: "/model/a/single-key/state/counters" +func (n *Model_SingleKey_CountersPathAny) State() ygnmi.WildcardQuery[[]float32] { + return ygnmi.NewWildcardQuery[[]float32]( + "Model_SingleKey", + true, + true, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"state", "counters"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) ([]float32, bool) { + ret := gs.(*oc.Model_SingleKey).Counters + return binarySliceToFloatSlice(ret), !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Model_SingleKey_KeyPath represents the /openconfig-withlistval/model/a/single-key/config/key YANG schema element. +type Model_SingleKey_KeyPath struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// Model_SingleKey_KeyPathAny represents the wildcard version of the /openconfig-withlistval/model/a/single-key/config/key YANG schema element. +type Model_SingleKey_KeyPathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/key" +// Path from root: "/model/a/single-key/state/key" +func (n *Model_SingleKey_KeyPath) State() ygnmi.SingletonQuery[string] { + return ygnmi.NewSingletonQuery[string]( + "Model_SingleKey", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "key"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.Model_SingleKey).Key + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/key" +// Path from root: "/model/a/single-key/state/key" +func (n *Model_SingleKey_KeyPathAny) State() ygnmi.WildcardQuery[string] { + return ygnmi.NewWildcardQuery[string]( + "Model_SingleKey", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "key"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.Model_SingleKey).Key + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "config/key" +// Path from root: "/model/a/single-key/config/key" +func (n *Model_SingleKey_KeyPath) Config() ygnmi.ConfigQuery[string] { + return ygnmi.NewConfigQuery[string]( + "Model_SingleKey", + false, + false, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"config", "key"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.Model_SingleKey).Key + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "config/key" +// Path from root: "/model/a/single-key/config/key" +func (n *Model_SingleKey_KeyPathAny) Config() ygnmi.WildcardQuery[string] { + return ygnmi.NewWildcardQuery[string]( + "Model_SingleKey", + false, + false, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"config", "key"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.Model_SingleKey).Key + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Model_SingleKey_ValuePath represents the /openconfig-withlistval/model/a/single-key/config/value YANG schema element. +type Model_SingleKey_ValuePath struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// Model_SingleKey_ValuePathAny represents the wildcard version of the /openconfig-withlistval/model/a/single-key/config/value YANG schema element. +type Model_SingleKey_ValuePathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/value" +// Path from root: "/model/a/single-key/state/value" +func (n *Model_SingleKey_ValuePath) State() ygnmi.SingletonQuery[int64] { + return ygnmi.NewSingletonQuery[int64]( + "Model_SingleKey", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "value"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (int64, bool) { + ret := gs.(*oc.Model_SingleKey).Value + if ret == nil { + var zero int64 + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/value" +// Path from root: "/model/a/single-key/state/value" +func (n *Model_SingleKey_ValuePathAny) State() ygnmi.WildcardQuery[int64] { + return ygnmi.NewWildcardQuery[int64]( + "Model_SingleKey", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "value"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (int64, bool) { + ret := gs.(*oc.Model_SingleKey).Value + if ret == nil { + var zero int64 + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "config/value" +// Path from root: "/model/a/single-key/config/value" +func (n *Model_SingleKey_ValuePath) Config() ygnmi.ConfigQuery[int64] { + return ygnmi.NewConfigQuery[int64]( + "Model_SingleKey", + false, + false, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"config", "value"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (int64, bool) { + ret := gs.(*oc.Model_SingleKey).Value + if ret == nil { + var zero int64 + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "config/value" +// Path from root: "/model/a/single-key/config/value" +func (n *Model_SingleKey_ValuePathAny) Config() ygnmi.WildcardQuery[int64] { + return ygnmi.NewWildcardQuery[int64]( + "Model_SingleKey", + false, + false, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"config", "value"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (int64, bool) { + ret := gs.(*oc.Model_SingleKey).Value + if ret == nil { + var zero int64 + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Model_SingleKeyPath represents the /openconfig-withlistval/model/a/single-key YANG schema element. +type Model_SingleKeyPath struct { + *ygnmi.NodePath +} + +// Model_SingleKeyPathAny represents the wildcard version of the /openconfig-withlistval/model/a/single-key YANG schema element. +type Model_SingleKeyPathAny struct { + *ygnmi.NodePath +} + +// Model_SingleKeyPathMap represents the /openconfig-withlistval/model/a/single-key YANG schema element. +type Model_SingleKeyPathMap struct { + *ygnmi.NodePath +} + +// Model_SingleKeyPathMapAny represents the wildcard version of the /openconfig-withlistval/model/a/single-key YANG schema element. +type Model_SingleKeyPathMapAny struct { + *ygnmi.NodePath +} + +// Counter (leaf): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/counter" +// Path from root: "/model/a/single-key/state/counter" +func (n *Model_SingleKeyPath) Counter() *Model_SingleKey_CounterPath { + ps := &Model_SingleKey_CounterPath{ + NodePath: ygnmi.NewNodePath( + []string{"state", "counter"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Counter (leaf): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/counter" +// Path from root: "/model/a/single-key/state/counter" +func (n *Model_SingleKeyPathAny) Counter() *Model_SingleKey_CounterPathAny { + ps := &Model_SingleKey_CounterPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"state", "counter"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Counters (leaf-list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/counters" +// Path from root: "/model/a/single-key/state/counters" +func (n *Model_SingleKeyPath) Counters() *Model_SingleKey_CountersPath { + ps := &Model_SingleKey_CountersPath{ + NodePath: ygnmi.NewNodePath( + []string{"state", "counters"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Counters (leaf-list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/counters" +// Path from root: "/model/a/single-key/state/counters" +func (n *Model_SingleKeyPathAny) Counters() *Model_SingleKey_CountersPathAny { + ps := &Model_SingleKey_CountersPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"state", "counters"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Key (leaf): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "*/key" +// Path from root: "/model/a/single-key/*/key" +func (n *Model_SingleKeyPath) Key() *Model_SingleKey_KeyPath { + ps := &Model_SingleKey_KeyPath{ + NodePath: ygnmi.NewNodePath( + []string{"*", "key"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Key (leaf): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "*/key" +// Path from root: "/model/a/single-key/*/key" +func (n *Model_SingleKeyPathAny) Key() *Model_SingleKey_KeyPathAny { + ps := &Model_SingleKey_KeyPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"*", "key"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// OrderedListMap (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "ordered-lists/ordered-list" +// Path from root: "/model/a/single-key/ordered-lists/ordered-list" +func (n *Model_SingleKeyPath) OrderedListMap() *Model_SingleKey_OrderedListPathMap { + ps := &Model_SingleKey_OrderedListPathMap{ + NodePath: ygnmi.NewNodePath( + []string{"ordered-lists"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// OrderedListMap (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "ordered-lists/ordered-list" +// Path from root: "/model/a/single-key/ordered-lists/ordered-list" +func (n *Model_SingleKeyPathAny) OrderedListMap() *Model_SingleKey_OrderedListPathMapAny { + ps := &Model_SingleKey_OrderedListPathMapAny{ + NodePath: ygnmi.NewNodePath( + []string{"ordered-lists"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// SingleKeyMap (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "inner-a/single-key" +// Path from root: "/model/a/single-key/inner-a/single-key" +func (n *Model_SingleKeyPath) SingleKeyMap() *Model_SingleKey_SingleKeyPathMap { + ps := &Model_SingleKey_SingleKeyPathMap{ + NodePath: ygnmi.NewNodePath( + []string{"inner-a"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// SingleKeyMap (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "inner-a/single-key" +// Path from root: "/model/a/single-key/inner-a/single-key" +func (n *Model_SingleKeyPathAny) SingleKeyMap() *Model_SingleKey_SingleKeyPathMapAny { + ps := &Model_SingleKey_SingleKeyPathMapAny{ + NodePath: ygnmi.NewNodePath( + []string{"inner-a"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// Value (leaf): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "*/value" +// Path from root: "/model/a/single-key/*/value" +func (n *Model_SingleKeyPath) Value() *Model_SingleKey_ValuePath { + ps := &Model_SingleKey_ValuePath{ + NodePath: ygnmi.NewNodePath( + []string{"*", "value"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Value (leaf): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "*/value" +// Path from root: "/model/a/single-key/*/value" +func (n *Model_SingleKeyPathAny) Value() *Model_SingleKey_ValuePathAny { + ps := &Model_SingleKey_ValuePathAny{ + NodePath: ygnmi.NewNodePath( + []string{"*", "value"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +func binarySliceToFloatSlice(in []oc.Binary) []float32 { + converted := make([]float32, 0, len(in)) + for _, binary := range in { + converted = append(converted, ygot.BinaryToFloat32(binary)) + } + return converted +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_SingleKeyPath) State() ygnmi.SingletonQuery[*oc.Model_SingleKey] { + return ygnmi.NewSingletonQuery[*oc.Model_SingleKey]( + "Model_SingleKey", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_SingleKeyPathAny) State() ygnmi.WildcardQuery[*oc.Model_SingleKey] { + return ygnmi.NewWildcardQuery[*oc.Model_SingleKey]( + "Model_SingleKey", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *Model_SingleKeyPath) Config() ygnmi.ConfigQuery[*oc.Model_SingleKey] { + return ygnmi.NewConfigQuery[*oc.Model_SingleKey]( + "Model_SingleKey", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *Model_SingleKeyPathAny) Config() ygnmi.WildcardQuery[*oc.Model_SingleKey] { + return ygnmi.NewWildcardQuery[*oc.Model_SingleKey]( + "Model_SingleKey", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_SingleKeyPathMap) State() ygnmi.SingletonQuery[map[string]*oc.Model_SingleKey] { + return ygnmi.NewSingletonQuery[map[string]*oc.Model_SingleKey]( + "Model", + true, + true, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (map[string]*oc.Model_SingleKey, bool) { + ret := gs.(*oc.Model).SingleKey + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:a"}, + PostRelPath: []string{"openconfig-withlistval:single-key"}, + }, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_SingleKeyPathMapAny) State() ygnmi.WildcardQuery[map[string]*oc.Model_SingleKey] { + return ygnmi.NewWildcardQuery[map[string]*oc.Model_SingleKey]( + "Model", + true, + true, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (map[string]*oc.Model_SingleKey, bool) { + ret := gs.(*oc.Model).SingleKey + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:a"}, + PostRelPath: []string{"openconfig-withlistval:single-key"}, + }, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *Model_SingleKeyPathMap) Config() ygnmi.ConfigQuery[map[string]*oc.Model_SingleKey] { + return ygnmi.NewConfigQuery[map[string]*oc.Model_SingleKey]( + "Model", + false, + false, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (map[string]*oc.Model_SingleKey, bool) { + ret := gs.(*oc.Model).SingleKey + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:a"}, + PostRelPath: []string{"openconfig-withlistval:single-key"}, + }, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *Model_SingleKeyPathMapAny) Config() ygnmi.WildcardQuery[map[string]*oc.Model_SingleKey] { + return ygnmi.NewWildcardQuery[map[string]*oc.Model_SingleKey]( + "Model", + false, + false, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (map[string]*oc.Model_SingleKey, bool) { + ret := gs.(*oc.Model).SingleKey + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:a"}, + PostRelPath: []string{"openconfig-withlistval:single-key"}, + }, + ) +} + +// Model_SingleKey_OrderedListPath represents the /openconfig-withlistval/model/a/single-key/ordered-lists/ordered-list YANG schema element. +type Model_SingleKey_OrderedListPath struct { + *ygnmi.NodePath +} + +// Model_SingleKey_OrderedListPathAny represents the wildcard version of the /openconfig-withlistval/model/a/single-key/ordered-lists/ordered-list YANG schema element. +type Model_SingleKey_OrderedListPathAny struct { + *ygnmi.NodePath +} + +// Model_SingleKey_OrderedListPathMap represents the /openconfig-withlistval/model/a/single-key/ordered-lists/ordered-list YANG schema element. +type Model_SingleKey_OrderedListPathMap struct { + *ygnmi.NodePath +} + +// Model_SingleKey_OrderedListPathMapAny represents the wildcard version of the /openconfig-withlistval/model/a/single-key/ordered-lists/ordered-list YANG schema element. +type Model_SingleKey_OrderedListPathMapAny struct { + *ygnmi.NodePath +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_SingleKey_OrderedListPathMap) State() ygnmi.SingletonQuery[*oc.Model_SingleKey_OrderedList_OrderedMap] { + return ygnmi.NewSingletonQuery[*oc.Model_SingleKey_OrderedList_OrderedMap]( + "Model_SingleKey", + true, + true, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (*oc.Model_SingleKey_OrderedList_OrderedMap, bool) { + ret := gs.(*oc.Model_SingleKey).OrderedList + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:ordered-lists"}, + PostRelPath: []string{"openconfig-withlistval:ordered-list"}, + }, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_SingleKey_OrderedListPathMapAny) State() ygnmi.WildcardQuery[*oc.Model_SingleKey_OrderedList_OrderedMap] { + return ygnmi.NewWildcardQuery[*oc.Model_SingleKey_OrderedList_OrderedMap]( + "Model_SingleKey", + true, + true, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (*oc.Model_SingleKey_OrderedList_OrderedMap, bool) { + ret := gs.(*oc.Model_SingleKey).OrderedList + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:ordered-lists"}, + PostRelPath: []string{"openconfig-withlistval:ordered-list"}, + }, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *Model_SingleKey_OrderedListPathMap) Config() ygnmi.ConfigQuery[*oc.Model_SingleKey_OrderedList_OrderedMap] { + return ygnmi.NewConfigQuery[*oc.Model_SingleKey_OrderedList_OrderedMap]( + "Model_SingleKey", + false, + false, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (*oc.Model_SingleKey_OrderedList_OrderedMap, bool) { + ret := gs.(*oc.Model_SingleKey).OrderedList + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:ordered-lists"}, + PostRelPath: []string{"openconfig-withlistval:ordered-list"}, + }, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *Model_SingleKey_OrderedListPathMapAny) Config() ygnmi.WildcardQuery[*oc.Model_SingleKey_OrderedList_OrderedMap] { + return ygnmi.NewWildcardQuery[*oc.Model_SingleKey_OrderedList_OrderedMap]( + "Model_SingleKey", + false, + false, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (*oc.Model_SingleKey_OrderedList_OrderedMap, bool) { + ret := gs.(*oc.Model_SingleKey).OrderedList + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:ordered-lists"}, + PostRelPath: []string{"openconfig-withlistval:ordered-list"}, + }, + ) +} + +// Model_SingleKey_SingleKeyPath represents the /openconfig-withlistval/model/a/single-key/inner-a/single-key YANG schema element. +type Model_SingleKey_SingleKeyPath struct { + *ygnmi.NodePath +} + +// Model_SingleKey_SingleKeyPathAny represents the wildcard version of the /openconfig-withlistval/model/a/single-key/inner-a/single-key YANG schema element. +type Model_SingleKey_SingleKeyPathAny struct { + *ygnmi.NodePath +} + +// Model_SingleKey_SingleKeyPathMap represents the /openconfig-withlistval/model/a/single-key/inner-a/single-key YANG schema element. +type Model_SingleKey_SingleKeyPathMap struct { + *ygnmi.NodePath +} + +// Model_SingleKey_SingleKeyPathMapAny represents the wildcard version of the /openconfig-withlistval/model/a/single-key/inner-a/single-key YANG schema element. +type Model_SingleKey_SingleKeyPathMapAny struct { + *ygnmi.NodePath +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_SingleKey_SingleKeyPathMap) State() ygnmi.SingletonQuery[map[string]*oc.Model_SingleKey_SingleKey] { + return ygnmi.NewSingletonQuery[map[string]*oc.Model_SingleKey_SingleKey]( + "Model_SingleKey", + true, + true, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (map[string]*oc.Model_SingleKey_SingleKey, bool) { + ret := gs.(*oc.Model_SingleKey).SingleKey + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:inner-a"}, + PostRelPath: []string{"openconfig-withlistval:single-key"}, + }, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_SingleKey_SingleKeyPathMapAny) State() ygnmi.WildcardQuery[map[string]*oc.Model_SingleKey_SingleKey] { + return ygnmi.NewWildcardQuery[map[string]*oc.Model_SingleKey_SingleKey]( + "Model_SingleKey", + true, + true, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (map[string]*oc.Model_SingleKey_SingleKey, bool) { + ret := gs.(*oc.Model_SingleKey).SingleKey + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:inner-a"}, + PostRelPath: []string{"openconfig-withlistval:single-key"}, + }, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *Model_SingleKey_SingleKeyPathMap) Config() ygnmi.ConfigQuery[map[string]*oc.Model_SingleKey_SingleKey] { + return ygnmi.NewConfigQuery[map[string]*oc.Model_SingleKey_SingleKey]( + "Model_SingleKey", + false, + false, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (map[string]*oc.Model_SingleKey_SingleKey, bool) { + ret := gs.(*oc.Model_SingleKey).SingleKey + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:inner-a"}, + PostRelPath: []string{"openconfig-withlistval:single-key"}, + }, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *Model_SingleKey_SingleKeyPathMapAny) Config() ygnmi.WildcardQuery[map[string]*oc.Model_SingleKey_SingleKey] { + return ygnmi.NewWildcardQuery[map[string]*oc.Model_SingleKey_SingleKey]( + "Model_SingleKey", + false, + false, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (map[string]*oc.Model_SingleKey_SingleKey, bool) { + ret := gs.(*oc.Model_SingleKey).SingleKey + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_SingleKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:inner-a"}, + PostRelPath: []string{"openconfig-withlistval:single-key"}, + }, + ) +} diff --git a/internal/exampleocconfig/enum.go b/internal/exampleocconfig/enum.go new file mode 100644 index 0000000..007ec24 --- /dev/null +++ b/internal/exampleocconfig/enum.go @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* +Package exampleocconfig is a generated package which contains definitions +of structs which represent a YANG schema. The generated schema can be +compressed by a series of transformations (compression was true +in this case). + +This package was generated by ygnmi version: (devel): (ygot: v0.29.12) +using the following YANG input files: + - ../../pathgen/testdata/yang/openconfig-simple.yang + - ../../pathgen/testdata/yang/openconfig-withlistval.yang + - ../../pathgen/testdata/yang/openconfig-nested.yang + +Imported modules were sourced from: +*/ +package exampleocconfig + +import ( + "github.com/openconfig/ygot/ygot" +) + +// E_Child_Three is a derived int64 type which is used to represent +// the enumerated node Child_Three. An additional value named +// Child_Three_UNSET is added to the enumeration which is used as +// the nil value, indicating that the enumeration was not explicitly set by +// the program importing the generated structures. +type E_Child_Three int64 + +// IsYANGGoEnum ensures that Child_Three implements the yang.GoEnum +// interface. This ensures that Child_Three can be identified as a +// mapped type for a YANG enumeration. +func (E_Child_Three) IsYANGGoEnum() {} + +// ΛMap returns the value lookup map associated with Child_Three. +func (E_Child_Three) ΛMap() map[string]map[int64]ygot.EnumDefinition { return ΛEnum } + +// String returns a logging-friendly string for E_Child_Three. +func (e E_Child_Three) String() string { + return ygot.EnumLogString(e, int64(e), "E_Child_Three") +} + +const ( + // Child_Three_UNSET corresponds to the value UNSET of Child_Three + Child_Three_UNSET E_Child_Three = 0 + // Child_Three_ONE corresponds to the value ONE of Child_Three + Child_Three_ONE E_Child_Three = 1 + // Child_Three_TWO corresponds to the value TWO of Child_Three + Child_Three_TWO E_Child_Three = 2 +) diff --git a/internal/exampleocconfig/enum_map.go b/internal/exampleocconfig/enum_map.go new file mode 100644 index 0000000..74b214f --- /dev/null +++ b/internal/exampleocconfig/enum_map.go @@ -0,0 +1,61 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* +Package exampleocconfig is a generated package which contains definitions +of structs which represent a YANG schema. The generated schema can be +compressed by a series of transformations (compression was true +in this case). + +This package was generated by ygnmi version: (devel): (ygot: v0.29.12) +using the following YANG input files: + - ../../pathgen/testdata/yang/openconfig-simple.yang + - ../../pathgen/testdata/yang/openconfig-withlistval.yang + - ../../pathgen/testdata/yang/openconfig-nested.yang + +Imported modules were sourced from: +*/ +package exampleocconfig + +import ( + "reflect" + + "github.com/openconfig/ygot/ygot" +) + +// ΛEnum is a map, keyed by the name of the type defined for each enum in the +// generated Go code, which provides a mapping between the constant int64 value +// of each value of the enumeration, and the string that is used to represent it +// in the YANG schema. The map is named ΛEnum in order to avoid clash with any +// valid YANG identifier. +var ΛEnum = map[string]map[int64]ygot.EnumDefinition{ + "E_Child_Three": { + 1: {Name: "ONE"}, + 2: {Name: "TWO"}, + }, +} + +// ΛEnumTypes is a map, keyed by a YANG schema path, of the enumerated types that +// correspond with the leaf. The type is represented as a reflect.Type. The naming +// of the map ensures that there are no clashes with valid YANG identifiers. +func initΛEnumTypes() { + ΛEnumTypes = map[string][]reflect.Type{ + "/parent/child/config/three": []reflect.Type{ + reflect.TypeOf((E_Child_Three)(0)), + }, + "/parent/child/state/three": []reflect.Type{ + reflect.TypeOf((E_Child_Three)(0)), + }, + } +} diff --git a/internal/exampleocconfig/exampleocconfigpath/exampleocconfigpath.go b/internal/exampleocconfig/exampleocconfigpath/exampleocconfigpath.go new file mode 100644 index 0000000..781c946 --- /dev/null +++ b/internal/exampleocconfig/exampleocconfigpath/exampleocconfigpath.go @@ -0,0 +1,4778 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* +Package exampleocconfigpath is a generated package which contains definitions +of structs which generate gNMI paths for a YANG schema. + +This package was generated by ygnmi version: (devel): (ygot: v0.29.12) +using the following YANG input files: + - ../../pathgen/testdata/yang/openconfig-simple.yang + - ../../pathgen/testdata/yang/openconfig-withlistval.yang + - ../../pathgen/testdata/yang/openconfig-nested.yang + +Imported modules were sourced from: +*/ +package exampleocconfigpath + +import ( + "reflect" + + oc "github.com/openconfig/ygnmi/internal/exampleocconfig" + "github.com/openconfig/ygnmi/internal/exampleocconfig/a" + "github.com/openconfig/ygnmi/internal/exampleocconfig/modelb" + "github.com/openconfig/ygnmi/ygnmi" + "github.com/openconfig/ygot/ygot" + "github.com/openconfig/ygot/ytypes" +) + +// APath represents the /openconfig-nested/a YANG schema element. +type APath struct { + *ygnmi.NodePath +} + +// APathAny represents the wildcard version of the /openconfig-nested/a YANG schema element. +type APathAny struct { + *ygnmi.NodePath +} + +// B (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "b" +// Path from root: "/a/b" +func (n *APath) B() *A_BPath { + ps := &A_BPath{ + NodePath: ygnmi.NewNodePath( + []string{"b"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// B (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "b" +// Path from root: "/a/b" +func (n *APathAny) B() *A_BPathAny { + ps := &A_BPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"b"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +func binarySliceToFloatSlice(in []oc.Binary) []float32 { + converted := make([]float32, 0, len(in)) + for _, binary := range in { + converted = append(converted, ygot.BinaryToFloat32(binary)) + } + return converted +} + +// State returns a Query that can be used in gNMI operations. +func (n *APath) State() ygnmi.SingletonQuery[*oc.A] { + return ygnmi.NewSingletonQuery[*oc.A]( + "A", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *APathAny) State() ygnmi.WildcardQuery[*oc.A] { + return ygnmi.NewWildcardQuery[*oc.A]( + "A", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *APath) Config() ygnmi.ConfigQuery[*oc.A] { + return ygnmi.NewConfigQuery[*oc.A]( + "A", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *APathAny) Config() ygnmi.WildcardQuery[*oc.A] { + return ygnmi.NewWildcardQuery[*oc.A]( + "A", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// A_BPath represents the /openconfig-nested/a/b YANG schema element. +type A_BPath struct { + *ygnmi.NodePath +} + +// A_BPathAny represents the wildcard version of the /openconfig-nested/a/b YANG schema element. +type A_BPathAny struct { + *ygnmi.NodePath +} + +// C (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "c" +// Path from root: "/a/b/c" +func (n *A_BPath) C() *A_B_CPath { + ps := &A_B_CPath{ + NodePath: ygnmi.NewNodePath( + []string{"c"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// C (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "c" +// Path from root: "/a/b/c" +func (n *A_BPathAny) C() *A_B_CPathAny { + ps := &A_B_CPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"c"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_BPath) State() ygnmi.SingletonQuery[*oc.A_B] { + return ygnmi.NewSingletonQuery[*oc.A_B]( + "A_B", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_BPathAny) State() ygnmi.WildcardQuery[*oc.A_B] { + return ygnmi.NewWildcardQuery[*oc.A_B]( + "A_B", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_BPath) Config() ygnmi.ConfigQuery[*oc.A_B] { + return ygnmi.NewConfigQuery[*oc.A_B]( + "A_B", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_BPathAny) Config() ygnmi.WildcardQuery[*oc.A_B] { + return ygnmi.NewWildcardQuery[*oc.A_B]( + "A_B", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// A_B_CPath represents the /openconfig-nested/a/b/c YANG schema element. +type A_B_CPath struct { + *ygnmi.NodePath +} + +// A_B_CPathAny represents the wildcard version of the /openconfig-nested/a/b/c YANG schema element. +type A_B_CPathAny struct { + *ygnmi.NodePath +} + +// D (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "d" +// Path from root: "/a/b/c/d" +func (n *A_B_CPath) D() *A_B_C_DPath { + ps := &A_B_C_DPath{ + NodePath: ygnmi.NewNodePath( + []string{"d"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// D (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "d" +// Path from root: "/a/b/c/d" +func (n *A_B_CPathAny) D() *A_B_C_DPathAny { + ps := &A_B_C_DPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"d"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_CPath) State() ygnmi.SingletonQuery[*oc.A_B_C] { + return ygnmi.NewSingletonQuery[*oc.A_B_C]( + "A_B_C", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_CPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C] { + return ygnmi.NewWildcardQuery[*oc.A_B_C]( + "A_B_C", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_CPath) Config() ygnmi.ConfigQuery[*oc.A_B_C] { + return ygnmi.NewConfigQuery[*oc.A_B_C]( + "A_B_C", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_CPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C] { + return ygnmi.NewWildcardQuery[*oc.A_B_C]( + "A_B_C", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// A_B_C_DPath represents the /openconfig-nested/a/b/c/d YANG schema element. +type A_B_C_DPath struct { + *ygnmi.NodePath +} + +// A_B_C_DPathAny represents the wildcard version of the /openconfig-nested/a/b/c/d YANG schema element. +type A_B_C_DPathAny struct { + *ygnmi.NodePath +} + +// E (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "e" +// Path from root: "/a/b/c/d/e" +func (n *A_B_C_DPath) E() *A_B_C_D_EPath { + ps := &A_B_C_D_EPath{ + NodePath: ygnmi.NewNodePath( + []string{"e"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// E (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "e" +// Path from root: "/a/b/c/d/e" +func (n *A_B_C_DPathAny) E() *A_B_C_D_EPathAny { + ps := &A_B_C_D_EPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"e"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_DPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D] { + return ygnmi.NewSingletonQuery[*oc.A_B_C_D]( + "A_B_C_D", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_DPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D]( + "A_B_C_D", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_DPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D] { + return ygnmi.NewConfigQuery[*oc.A_B_C_D]( + "A_B_C_D", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_DPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D]( + "A_B_C_D", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// A_B_C_D_EPath represents the /openconfig-nested/a/b/c/d/e YANG schema element. +type A_B_C_D_EPath struct { + *ygnmi.NodePath +} + +// A_B_C_D_EPathAny represents the wildcard version of the /openconfig-nested/a/b/c/d/e YANG schema element. +type A_B_C_D_EPathAny struct { + *ygnmi.NodePath +} + +// F (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "f" +// Path from root: "/a/b/c/d/e/f" +func (n *A_B_C_D_EPath) F() *A_B_C_D_E_FPath { + ps := &A_B_C_D_E_FPath{ + NodePath: ygnmi.NewNodePath( + []string{"f"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// F (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "f" +// Path from root: "/a/b/c/d/e/f" +func (n *A_B_C_D_EPathAny) F() *A_B_C_D_E_FPathAny { + ps := &A_B_C_D_E_FPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"f"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_EPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E] { + return ygnmi.NewSingletonQuery[*oc.A_B_C_D_E]( + "A_B_C_D_E", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_EPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E]( + "A_B_C_D_E", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_EPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E] { + return ygnmi.NewConfigQuery[*oc.A_B_C_D_E]( + "A_B_C_D_E", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_EPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E]( + "A_B_C_D_E", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// A_B_C_D_E_FPath represents the /openconfig-nested/a/b/c/d/e/f YANG schema element. +type A_B_C_D_E_FPath struct { + *ygnmi.NodePath +} + +// A_B_C_D_E_FPathAny represents the wildcard version of the /openconfig-nested/a/b/c/d/e/f YANG schema element. +type A_B_C_D_E_FPathAny struct { + *ygnmi.NodePath +} + +// G (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "g" +// Path from root: "/a/b/c/d/e/f/g" +func (n *A_B_C_D_E_FPath) G() *A_B_C_D_E_F_GPath { + ps := &A_B_C_D_E_F_GPath{ + NodePath: ygnmi.NewNodePath( + []string{"g"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// G (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "g" +// Path from root: "/a/b/c/d/e/f/g" +func (n *A_B_C_D_E_FPathAny) G() *A_B_C_D_E_F_GPathAny { + ps := &A_B_C_D_E_F_GPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"g"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_FPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F] { + return ygnmi.NewSingletonQuery[*oc.A_B_C_D_E_F]( + "A_B_C_D_E_F", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_FPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F]( + "A_B_C_D_E_F", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_FPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F] { + return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F]( + "A_B_C_D_E_F", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_FPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F]( + "A_B_C_D_E_F", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// A_B_C_D_E_F_GPath represents the /openconfig-nested/a/b/c/d/e/f/g YANG schema element. +type A_B_C_D_E_F_GPath struct { + *ygnmi.NodePath +} + +// A_B_C_D_E_F_GPathAny represents the wildcard version of the /openconfig-nested/a/b/c/d/e/f/g YANG schema element. +type A_B_C_D_E_F_GPathAny struct { + *ygnmi.NodePath +} + +// H (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "h" +// Path from root: "/a/b/c/d/e/f/g/h" +func (n *A_B_C_D_E_F_GPath) H() *A_B_C_D_E_F_G_HPath { + ps := &A_B_C_D_E_F_G_HPath{ + NodePath: ygnmi.NewNodePath( + []string{"h"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// H (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "h" +// Path from root: "/a/b/c/d/e/f/g/h" +func (n *A_B_C_D_E_F_GPathAny) H() *A_B_C_D_E_F_G_HPathAny { + ps := &A_B_C_D_E_F_G_HPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"h"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_GPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G] { + return ygnmi.NewSingletonQuery[*oc.A_B_C_D_E_F_G]( + "A_B_C_D_E_F_G", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_GPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G]( + "A_B_C_D_E_F_G", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_GPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G] { + return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G]( + "A_B_C_D_E_F_G", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_GPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G]( + "A_B_C_D_E_F_G", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// A_B_C_D_E_F_G_HPath represents the /openconfig-nested/a/b/c/d/e/f/g/h YANG schema element. +type A_B_C_D_E_F_G_HPath struct { + *ygnmi.NodePath +} + +// A_B_C_D_E_F_G_HPathAny represents the wildcard version of the /openconfig-nested/a/b/c/d/e/f/g/h YANG schema element. +type A_B_C_D_E_F_G_HPathAny struct { + *ygnmi.NodePath +} + +// I (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "i" +// Path from root: "/a/b/c/d/e/f/g/h/i" +func (n *A_B_C_D_E_F_G_HPath) I() *A_B_C_D_E_F_G_H_IPath { + ps := &A_B_C_D_E_F_G_H_IPath{ + NodePath: ygnmi.NewNodePath( + []string{"i"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// I (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "i" +// Path from root: "/a/b/c/d/e/f/g/h/i" +func (n *A_B_C_D_E_F_G_HPathAny) I() *A_B_C_D_E_F_G_H_IPathAny { + ps := &A_B_C_D_E_F_G_H_IPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"i"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_HPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G_H] { + return ygnmi.NewSingletonQuery[*oc.A_B_C_D_E_F_G_H]( + "A_B_C_D_E_F_G_H", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_HPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_H] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H]( + "A_B_C_D_E_F_G_H", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_HPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G_H] { + return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H]( + "A_B_C_D_E_F_G_H", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_HPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_H] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H]( + "A_B_C_D_E_F_G_H", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// A_B_C_D_E_F_G_H_IPath represents the /openconfig-nested/a/b/c/d/e/f/g/h/i YANG schema element. +type A_B_C_D_E_F_G_H_IPath struct { + *ygnmi.NodePath +} + +// A_B_C_D_E_F_G_H_IPathAny represents the wildcard version of the /openconfig-nested/a/b/c/d/e/f/g/h/i YANG schema element. +type A_B_C_D_E_F_G_H_IPathAny struct { + *ygnmi.NodePath +} + +// J (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "j" +// Path from root: "/a/b/c/d/e/f/g/h/i/j" +func (n *A_B_C_D_E_F_G_H_IPath) J() *A_B_C_D_E_F_G_H_I_JPath { + ps := &A_B_C_D_E_F_G_H_I_JPath{ + NodePath: ygnmi.NewNodePath( + []string{"j"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// J (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "j" +// Path from root: "/a/b/c/d/e/f/g/h/i/j" +func (n *A_B_C_D_E_F_G_H_IPathAny) J() *A_B_C_D_E_F_G_H_I_JPathAny { + ps := &A_B_C_D_E_F_G_H_I_JPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"j"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_IPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G_H_I] { + return ygnmi.NewSingletonQuery[*oc.A_B_C_D_E_F_G_H_I]( + "A_B_C_D_E_F_G_H_I", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_IPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_H_I] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I]( + "A_B_C_D_E_F_G_H_I", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_IPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G_H_I] { + return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I]( + "A_B_C_D_E_F_G_H_I", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_IPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_H_I] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I]( + "A_B_C_D_E_F_G_H_I", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// A_B_C_D_E_F_G_H_I_JPath represents the /openconfig-nested/a/b/c/d/e/f/g/h/i/j YANG schema element. +type A_B_C_D_E_F_G_H_I_JPath struct { + *ygnmi.NodePath +} + +// A_B_C_D_E_F_G_H_I_JPathAny represents the wildcard version of the /openconfig-nested/a/b/c/d/e/f/g/h/i/j YANG schema element. +type A_B_C_D_E_F_G_H_I_JPathAny struct { + *ygnmi.NodePath +} + +// K (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "k" +// Path from root: "/a/b/c/d/e/f/g/h/i/j/k" +func (n *A_B_C_D_E_F_G_H_I_JPath) K() *A_B_C_D_E_F_G_H_I_J_KPath { + ps := &A_B_C_D_E_F_G_H_I_J_KPath{ + NodePath: ygnmi.NewNodePath( + []string{"k"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// K (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "k" +// Path from root: "/a/b/c/d/e/f/g/h/i/j/k" +func (n *A_B_C_D_E_F_G_H_I_JPathAny) K() *A_B_C_D_E_F_G_H_I_J_KPathAny { + ps := &A_B_C_D_E_F_G_H_I_J_KPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"k"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_JPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G_H_I_J] { + return ygnmi.NewSingletonQuery[*oc.A_B_C_D_E_F_G_H_I_J]( + "A_B_C_D_E_F_G_H_I_J", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_JPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J]( + "A_B_C_D_E_F_G_H_I_J", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_JPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J] { + return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J]( + "A_B_C_D_E_F_G_H_I_J", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_JPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J]( + "A_B_C_D_E_F_G_H_I_J", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// A_B_C_D_E_F_G_H_I_J_KPath represents the /openconfig-nested/a/b/c/d/e/f/g/h/i/j/k YANG schema element. +type A_B_C_D_E_F_G_H_I_J_KPath struct { + *ygnmi.NodePath +} + +// A_B_C_D_E_F_G_H_I_J_KPathAny represents the wildcard version of the /openconfig-nested/a/b/c/d/e/f/g/h/i/j/k YANG schema element. +type A_B_C_D_E_F_G_H_I_J_KPathAny struct { + *ygnmi.NodePath +} + +// L (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "l" +// Path from root: "/a/b/c/d/e/f/g/h/i/j/k/l" +func (n *A_B_C_D_E_F_G_H_I_J_KPath) L() *A_B_C_D_E_F_G_H_I_J_K_LPath { + ps := &A_B_C_D_E_F_G_H_I_J_K_LPath{ + NodePath: ygnmi.NewNodePath( + []string{"l"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// L (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "l" +// Path from root: "/a/b/c/d/e/f/g/h/i/j/k/l" +func (n *A_B_C_D_E_F_G_H_I_J_KPathAny) L() *A_B_C_D_E_F_G_H_I_J_K_LPathAny { + ps := &A_B_C_D_E_F_G_H_I_J_K_LPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"l"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_J_KPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G_H_I_J_K] { + return ygnmi.NewSingletonQuery[*oc.A_B_C_D_E_F_G_H_I_J_K]( + "A_B_C_D_E_F_G_H_I_J_K", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_J_KPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K]( + "A_B_C_D_E_F_G_H_I_J_K", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_J_KPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J_K] { + return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J_K]( + "A_B_C_D_E_F_G_H_I_J_K", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_J_KPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K]( + "A_B_C_D_E_F_G_H_I_J_K", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// A_B_C_D_E_F_G_H_I_J_K_LPath represents the /openconfig-nested/a/b/c/d/e/f/g/h/i/j/k/l YANG schema element. +type A_B_C_D_E_F_G_H_I_J_K_LPath struct { + *ygnmi.NodePath +} + +// A_B_C_D_E_F_G_H_I_J_K_LPathAny represents the wildcard version of the /openconfig-nested/a/b/c/d/e/f/g/h/i/j/k/l YANG schema element. +type A_B_C_D_E_F_G_H_I_J_K_LPathAny struct { + *ygnmi.NodePath +} + +// M (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "m" +// Path from root: "/a/b/c/d/e/f/g/h/i/j/k/l/m" +func (n *A_B_C_D_E_F_G_H_I_J_K_LPath) M() *A_B_C_D_E_F_G_H_I_J_K_L_MPath { + ps := &A_B_C_D_E_F_G_H_I_J_K_L_MPath{ + NodePath: ygnmi.NewNodePath( + []string{"m"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// M (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "m" +// Path from root: "/a/b/c/d/e/f/g/h/i/j/k/l/m" +func (n *A_B_C_D_E_F_G_H_I_J_K_LPathAny) M() *A_B_C_D_E_F_G_H_I_J_K_L_MPathAny { + ps := &A_B_C_D_E_F_G_H_I_J_K_L_MPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"m"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_J_K_LPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L] { + return ygnmi.NewSingletonQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L]( + "A_B_C_D_E_F_G_H_I_J_K_L", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_J_K_LPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L]( + "A_B_C_D_E_F_G_H_I_J_K_L", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_J_K_LPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L] { + return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L]( + "A_B_C_D_E_F_G_H_I_J_K_L", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_J_K_LPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L]( + "A_B_C_D_E_F_G_H_I_J_K_L", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// A_B_C_D_E_F_G_H_I_J_K_L_M_FooPath represents the /openconfig-nested/a/b/c/d/e/f/g/h/i/j/k/l/m/state/foo YANG schema element. +type A_B_C_D_E_F_G_H_I_J_K_L_M_FooPath struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// A_B_C_D_E_F_G_H_I_J_K_L_M_FooPathAny represents the wildcard version of the /openconfig-nested/a/b/c/d/e/f/g/h/i/j/k/l/m/state/foo YANG schema element. +type A_B_C_D_E_F_G_H_I_J_K_L_M_FooPathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "state/foo" +// Path from root: "/a/b/c/d/e/f/g/h/i/j/k/l/m/state/foo" +func (n *A_B_C_D_E_F_G_H_I_J_K_L_M_FooPath) State() ygnmi.SingletonQuery[string] { + return ygnmi.NewSingletonQuery[string]( + "A_B_C_D_E_F_G_H_I_J_K_L_M", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "foo"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.A_B_C_D_E_F_G_H_I_J_K_L_M).Foo + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.A_B_C_D_E_F_G_H_I_J_K_L_M) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "state/foo" +// Path from root: "/a/b/c/d/e/f/g/h/i/j/k/l/m/state/foo" +func (n *A_B_C_D_E_F_G_H_I_J_K_L_M_FooPathAny) State() ygnmi.WildcardQuery[string] { + return ygnmi.NewWildcardQuery[string]( + "A_B_C_D_E_F_G_H_I_J_K_L_M", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "foo"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.A_B_C_D_E_F_G_H_I_J_K_L_M).Foo + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.A_B_C_D_E_F_G_H_I_J_K_L_M) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// A_B_C_D_E_F_G_H_I_J_K_L_MPath represents the /openconfig-nested/a/b/c/d/e/f/g/h/i/j/k/l/m YANG schema element. +type A_B_C_D_E_F_G_H_I_J_K_L_MPath struct { + *ygnmi.NodePath +} + +// A_B_C_D_E_F_G_H_I_J_K_L_MPathAny represents the wildcard version of the /openconfig-nested/a/b/c/d/e/f/g/h/i/j/k/l/m YANG schema element. +type A_B_C_D_E_F_G_H_I_J_K_L_MPathAny struct { + *ygnmi.NodePath +} + +// Foo (leaf): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "state/foo" +// Path from root: "/a/b/c/d/e/f/g/h/i/j/k/l/m/state/foo" +func (n *A_B_C_D_E_F_G_H_I_J_K_L_MPath) Foo() *A_B_C_D_E_F_G_H_I_J_K_L_M_FooPath { + ps := &A_B_C_D_E_F_G_H_I_J_K_L_M_FooPath{ + NodePath: ygnmi.NewNodePath( + []string{"state", "foo"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Foo (leaf): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "state/foo" +// Path from root: "/a/b/c/d/e/f/g/h/i/j/k/l/m/state/foo" +func (n *A_B_C_D_E_F_G_H_I_J_K_L_MPathAny) Foo() *A_B_C_D_E_F_G_H_I_J_K_L_M_FooPathAny { + ps := &A_B_C_D_E_F_G_H_I_J_K_L_M_FooPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"state", "foo"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_J_K_L_MPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L_M] { + return ygnmi.NewSingletonQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L_M]( + "A_B_C_D_E_F_G_H_I_J_K_L_M", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_J_K_L_MPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L_M] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L_M]( + "A_B_C_D_E_F_G_H_I_J_K_L_M", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_J_K_L_MPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L_M] { + return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L_M]( + "A_B_C_D_E_F_G_H_I_J_K_L_M", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *A_B_C_D_E_F_G_H_I_J_K_L_MPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L_M] { + return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L_M]( + "A_B_C_D_E_F_G_H_I_J_K_L_M", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// ContainerPath represents the /openconfig-nested/container YANG schema element. +type ContainerPath struct { + *ygnmi.NodePath +} + +// ContainerPathAny represents the wildcard version of the /openconfig-nested/container YANG schema element. +type ContainerPathAny struct { + *ygnmi.NodePath +} + +// State returns a Query that can be used in gNMI operations. +func (n *ContainerPath) State() ygnmi.SingletonQuery[*oc.Container] { + return ygnmi.NewSingletonQuery[*oc.Container]( + "Container", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *ContainerPathAny) State() ygnmi.WildcardQuery[*oc.Container] { + return ygnmi.NewWildcardQuery[*oc.Container]( + "Container", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *ContainerPath) Config() ygnmi.ConfigQuery[*oc.Container] { + return ygnmi.NewConfigQuery[*oc.Container]( + "Container", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *ContainerPathAny) Config() ygnmi.WildcardQuery[*oc.Container] { + return ygnmi.NewWildcardQuery[*oc.Container]( + "Container", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// ModelPath represents the /openconfig-withlistval/model YANG schema element. +type ModelPath struct { + *ygnmi.NodePath +} + +// ModelPathAny represents the wildcard version of the /openconfig-withlistval/model YANG schema element. +type ModelPathAny struct { + *ygnmi.NodePath +} + +// MultiKeyAny (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "b/multi-key" +// Path from root: "/model/b/multi-key" +func (n *ModelPath) MultiKeyAny() *modelb.Model_MultiKeyPathAny { + ps := &modelb.Model_MultiKeyPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"b", "multi-key"}, + map[string]interface{}{"key1": "*", "key2": "*"}, + n, + ), + } + return ps +} + +// MultiKeyAny (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "b/multi-key" +// Path from root: "/model/b/multi-key" +func (n *ModelPathAny) MultiKeyAny() *modelb.Model_MultiKeyPathAny { + ps := &modelb.Model_MultiKeyPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"b", "multi-key"}, + map[string]interface{}{"key1": "*", "key2": "*"}, + n, + ), + } + return ps +} + +// MultiKey (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "b/multi-key" +// Path from root: "/model/b/multi-key" +// +// Key1: uint32 +// Key2: uint64 +func (n *ModelPath) MultiKey(Key1 uint32, Key2 uint64) *modelb.Model_MultiKeyPath { + ps := &modelb.Model_MultiKeyPath{ + NodePath: ygnmi.NewNodePath( + []string{"b", "multi-key"}, + map[string]interface{}{"key1": Key1, "key2": Key2}, + n, + ), + } + return ps +} + +// MultiKey (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "b/multi-key" +// Path from root: "/model/b/multi-key" +// +// Key1: uint32 +// Key2: uint64 +func (n *ModelPathAny) MultiKey(Key1 uint32, Key2 uint64) *modelb.Model_MultiKeyPathAny { + ps := &modelb.Model_MultiKeyPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"b", "multi-key"}, + map[string]interface{}{"key1": Key1, "key2": Key2}, + n, + ), + } + return ps +} + +// MultiKeyMap (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "b/multi-key" +// Path from root: "/model/b/multi-key" +func (n *ModelPath) MultiKeyMap() *modelb.Model_MultiKeyPathMap { + ps := &modelb.Model_MultiKeyPathMap{ + NodePath: ygnmi.NewNodePath( + []string{"b"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// MultiKeyMap (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "b/multi-key" +// Path from root: "/model/b/multi-key" +func (n *ModelPathAny) MultiKeyMap() *modelb.Model_MultiKeyPathMapAny { + ps := &modelb.Model_MultiKeyPathMapAny{ + NodePath: ygnmi.NewNodePath( + []string{"b"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// NoKeyAny (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "c/no-key" +// Path from root: "/model/c/no-key" +func (n *ModelPath) NoKeyAny() *Model_NoKeyPathAny { + ps := &Model_NoKeyPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"c", "no-key"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// NoKeyAny (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "c/no-key" +// Path from root: "/model/c/no-key" +func (n *ModelPathAny) NoKeyAny() *Model_NoKeyPathAny { + ps := &Model_NoKeyPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"c", "no-key"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// SingleKeyAny (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "a/single-key" +// Path from root: "/model/a/single-key" +func (n *ModelPath) SingleKeyAny() *a.Model_SingleKeyPathAny { + ps := &a.Model_SingleKeyPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"a", "single-key"}, + map[string]interface{}{"key": "*"}, + n, + ), + } + return ps +} + +// SingleKeyAny (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "a/single-key" +// Path from root: "/model/a/single-key" +func (n *ModelPathAny) SingleKeyAny() *a.Model_SingleKeyPathAny { + ps := &a.Model_SingleKeyPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"a", "single-key"}, + map[string]interface{}{"key": "*"}, + n, + ), + } + return ps +} + +// SingleKey (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "a/single-key" +// Path from root: "/model/a/single-key" +// +// Key: string +func (n *ModelPath) SingleKey(Key string) *a.Model_SingleKeyPath { + ps := &a.Model_SingleKeyPath{ + NodePath: ygnmi.NewNodePath( + []string{"a", "single-key"}, + map[string]interface{}{"key": Key}, + n, + ), + } + return ps +} + +// SingleKey (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "a/single-key" +// Path from root: "/model/a/single-key" +// +// Key: string +func (n *ModelPathAny) SingleKey(Key string) *a.Model_SingleKeyPathAny { + ps := &a.Model_SingleKeyPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"a", "single-key"}, + map[string]interface{}{"key": Key}, + n, + ), + } + return ps +} + +// SingleKeyMap (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "a/single-key" +// Path from root: "/model/a/single-key" +func (n *ModelPath) SingleKeyMap() *a.Model_SingleKeyPathMap { + ps := &a.Model_SingleKeyPathMap{ + NodePath: ygnmi.NewNodePath( + []string{"a"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// SingleKeyMap (list): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "a/single-key" +// Path from root: "/model/a/single-key" +func (n *ModelPathAny) SingleKeyMap() *a.Model_SingleKeyPathMapAny { + ps := &a.Model_SingleKeyPathMapAny{ + NodePath: ygnmi.NewNodePath( + []string{"a"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *ModelPath) State() ygnmi.SingletonQuery[*oc.Model] { + return ygnmi.NewSingletonQuery[*oc.Model]( + "Model", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *ModelPathAny) State() ygnmi.WildcardQuery[*oc.Model] { + return ygnmi.NewWildcardQuery[*oc.Model]( + "Model", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *ModelPath) Config() ygnmi.ConfigQuery[*oc.Model] { + return ygnmi.NewConfigQuery[*oc.Model]( + "Model", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *ModelPathAny) Config() ygnmi.WildcardQuery[*oc.Model] { + return ygnmi.NewWildcardQuery[*oc.Model]( + "Model", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Model_NoKeyPath represents the /openconfig-withlistval/model/c/no-key YANG schema element. +type Model_NoKeyPath struct { + *ygnmi.NodePath +} + +// Model_NoKeyPathAny represents the wildcard version of the /openconfig-withlistval/model/c/no-key YANG schema element. +type Model_NoKeyPathAny struct { + *ygnmi.NodePath +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_NoKeyPath) State() ygnmi.SingletonQuery[*oc.Model_NoKey] { + return ygnmi.NewSingletonQuery[*oc.Model_NoKey]( + "Model_NoKey", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_NoKeyPathAny) State() ygnmi.WildcardQuery[*oc.Model_NoKey] { + return ygnmi.NewWildcardQuery[*oc.Model_NoKey]( + "Model_NoKey", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Model_NoKey_Foo_KeyPath represents the /openconfig-withlistval/model/c/no-key/foo/state/key YANG schema element. +type Model_NoKey_Foo_KeyPath struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// Model_NoKey_Foo_KeyPathAny represents the wildcard version of the /openconfig-withlistval/model/c/no-key/foo/state/key YANG schema element. +type Model_NoKey_Foo_KeyPathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/key" +// Path from root: "/model/c/no-key/foo/state/key" +func (n *Model_NoKey_Foo_KeyPath) State() ygnmi.SingletonQuery[string] { + return ygnmi.NewSingletonQuery[string]( + "Model_NoKey_Foo", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "key"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.Model_NoKey_Foo).Key + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_NoKey_Foo) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/key" +// Path from root: "/model/c/no-key/foo/state/key" +func (n *Model_NoKey_Foo_KeyPathAny) State() ygnmi.WildcardQuery[string] { + return ygnmi.NewWildcardQuery[string]( + "Model_NoKey_Foo", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "key"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.Model_NoKey_Foo).Key + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_NoKey_Foo) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Model_NoKey_Foo_ValuePath represents the /openconfig-withlistval/model/c/no-key/foo/state/value YANG schema element. +type Model_NoKey_Foo_ValuePath struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// Model_NoKey_Foo_ValuePathAny represents the wildcard version of the /openconfig-withlistval/model/c/no-key/foo/state/value YANG schema element. +type Model_NoKey_Foo_ValuePathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/value" +// Path from root: "/model/c/no-key/foo/state/value" +func (n *Model_NoKey_Foo_ValuePath) State() ygnmi.SingletonQuery[int64] { + return ygnmi.NewSingletonQuery[int64]( + "Model_NoKey_Foo", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "value"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (int64, bool) { + ret := gs.(*oc.Model_NoKey_Foo).Value + if ret == nil { + var zero int64 + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_NoKey_Foo) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/value" +// Path from root: "/model/c/no-key/foo/state/value" +func (n *Model_NoKey_Foo_ValuePathAny) State() ygnmi.WildcardQuery[int64] { + return ygnmi.NewWildcardQuery[int64]( + "Model_NoKey_Foo", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "value"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (int64, bool) { + ret := gs.(*oc.Model_NoKey_Foo).Value + if ret == nil { + var zero int64 + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_NoKey_Foo) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Model_NoKey_FooPath represents the /openconfig-withlistval/model/c/no-key/foo YANG schema element. +type Model_NoKey_FooPath struct { + *ygnmi.NodePath +} + +// Model_NoKey_FooPathAny represents the wildcard version of the /openconfig-withlistval/model/c/no-key/foo YANG schema element. +type Model_NoKey_FooPathAny struct { + *ygnmi.NodePath +} + +// Key (leaf): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/key" +// Path from root: "/model/c/no-key/foo/state/key" +func (n *Model_NoKey_FooPath) Key() *Model_NoKey_Foo_KeyPath { + ps := &Model_NoKey_Foo_KeyPath{ + NodePath: ygnmi.NewNodePath( + []string{"state", "key"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Key (leaf): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/key" +// Path from root: "/model/c/no-key/foo/state/key" +func (n *Model_NoKey_FooPathAny) Key() *Model_NoKey_Foo_KeyPathAny { + ps := &Model_NoKey_Foo_KeyPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"state", "key"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Value (leaf): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/value" +// Path from root: "/model/c/no-key/foo/state/value" +func (n *Model_NoKey_FooPath) Value() *Model_NoKey_Foo_ValuePath { + ps := &Model_NoKey_Foo_ValuePath{ + NodePath: ygnmi.NewNodePath( + []string{"state", "value"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Value (leaf): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/value" +// Path from root: "/model/c/no-key/foo/state/value" +func (n *Model_NoKey_FooPathAny) Value() *Model_NoKey_Foo_ValuePathAny { + ps := &Model_NoKey_Foo_ValuePathAny{ + NodePath: ygnmi.NewNodePath( + []string{"state", "value"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_NoKey_FooPath) State() ygnmi.SingletonQuery[*oc.Model_NoKey_Foo] { + return ygnmi.NewSingletonQuery[*oc.Model_NoKey_Foo]( + "Model_NoKey_Foo", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_NoKey_FooPathAny) State() ygnmi.WildcardQuery[*oc.Model_NoKey_Foo] { + return ygnmi.NewWildcardQuery[*oc.Model_NoKey_Foo]( + "Model_NoKey_Foo", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// ParentPath represents the /openconfig-simple/parent YANG schema element. +type ParentPath struct { + *ygnmi.NodePath +} + +// ParentPathAny represents the wildcard version of the /openconfig-simple/parent YANG schema element. +type ParentPathAny struct { + *ygnmi.NodePath +} + +// Child (container): +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "child" +// Path from root: "/parent/child" +func (n *ParentPath) Child() *Parent_ChildPath { + ps := &Parent_ChildPath{ + NodePath: ygnmi.NewNodePath( + []string{"child"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// Child (container): +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "child" +// Path from root: "/parent/child" +func (n *ParentPathAny) Child() *Parent_ChildPathAny { + ps := &Parent_ChildPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"child"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *ParentPath) State() ygnmi.SingletonQuery[*oc.Parent] { + return ygnmi.NewSingletonQuery[*oc.Parent]( + "Parent", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *ParentPathAny) State() ygnmi.WildcardQuery[*oc.Parent] { + return ygnmi.NewWildcardQuery[*oc.Parent]( + "Parent", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *ParentPath) Config() ygnmi.ConfigQuery[*oc.Parent] { + return ygnmi.NewConfigQuery[*oc.Parent]( + "Parent", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *ParentPathAny) Config() ygnmi.WildcardQuery[*oc.Parent] { + return ygnmi.NewWildcardQuery[*oc.Parent]( + "Parent", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Parent_Child_FivePath represents the /openconfig-simple/parent/child/config/five YANG schema element. +type Parent_Child_FivePath struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// Parent_Child_FivePathAny represents the wildcard version of the /openconfig-simple/parent/child/config/five YANG schema element. +type Parent_Child_FivePathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/five" +// Path from root: "/parent/child/state/five" +func (n *Parent_Child_FivePath) State() ygnmi.SingletonQuery[float32] { + return ygnmi.NewSingletonQuery[float32]( + "Parent_Child", + true, + true, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"state", "five"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (float32, bool) { + ret := gs.(*oc.Parent_Child).Five + return ygot.BinaryToFloat32(ret), !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/five" +// Path from root: "/parent/child/state/five" +func (n *Parent_Child_FivePathAny) State() ygnmi.WildcardQuery[float32] { + return ygnmi.NewWildcardQuery[float32]( + "Parent_Child", + true, + true, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"state", "five"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (float32, bool) { + ret := gs.(*oc.Parent_Child).Five + return ygot.BinaryToFloat32(ret), !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "config/five" +// Path from root: "/parent/child/config/five" +func (n *Parent_Child_FivePath) Config() ygnmi.ConfigQuery[float32] { + return ygnmi.NewConfigQuery[float32]( + "Parent_Child", + false, + false, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"config", "five"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (float32, bool) { + ret := gs.(*oc.Parent_Child).Five + return ygot.BinaryToFloat32(ret), !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "config/five" +// Path from root: "/parent/child/config/five" +func (n *Parent_Child_FivePathAny) Config() ygnmi.WildcardQuery[float32] { + return ygnmi.NewWildcardQuery[float32]( + "Parent_Child", + false, + false, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"config", "five"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (float32, bool) { + ret := gs.(*oc.Parent_Child).Five + return ygot.BinaryToFloat32(ret), !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Parent_Child_FourPath represents the /openconfig-simple/parent/child/config/four YANG schema element. +type Parent_Child_FourPath struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// Parent_Child_FourPathAny represents the wildcard version of the /openconfig-simple/parent/child/config/four YANG schema element. +type Parent_Child_FourPathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/four" +// Path from root: "/parent/child/state/four" +func (n *Parent_Child_FourPath) State() ygnmi.SingletonQuery[oc.Binary] { + return ygnmi.NewSingletonQuery[oc.Binary]( + "Parent_Child", + true, + true, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"state", "four"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (oc.Binary, bool) { + ret := gs.(*oc.Parent_Child).Four + return ret, !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/four" +// Path from root: "/parent/child/state/four" +func (n *Parent_Child_FourPathAny) State() ygnmi.WildcardQuery[oc.Binary] { + return ygnmi.NewWildcardQuery[oc.Binary]( + "Parent_Child", + true, + true, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"state", "four"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (oc.Binary, bool) { + ret := gs.(*oc.Parent_Child).Four + return ret, !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "config/four" +// Path from root: "/parent/child/config/four" +func (n *Parent_Child_FourPath) Config() ygnmi.ConfigQuery[oc.Binary] { + return ygnmi.NewConfigQuery[oc.Binary]( + "Parent_Child", + false, + false, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"config", "four"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (oc.Binary, bool) { + ret := gs.(*oc.Parent_Child).Four + return ret, !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "config/four" +// Path from root: "/parent/child/config/four" +func (n *Parent_Child_FourPathAny) Config() ygnmi.WildcardQuery[oc.Binary] { + return ygnmi.NewWildcardQuery[oc.Binary]( + "Parent_Child", + false, + false, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"config", "four"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (oc.Binary, bool) { + ret := gs.(*oc.Parent_Child).Four + return ret, !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Parent_Child_OnePath represents the /openconfig-simple/parent/child/config/one YANG schema element. +type Parent_Child_OnePath struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// Parent_Child_OnePathAny represents the wildcard version of the /openconfig-simple/parent/child/config/one YANG schema element. +type Parent_Child_OnePathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/one" +// Path from root: "/parent/child/state/one" +func (n *Parent_Child_OnePath) State() ygnmi.SingletonQuery[string] { + return ygnmi.NewSingletonQuery[string]( + "Parent_Child", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "one"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.Parent_Child).One + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/one" +// Path from root: "/parent/child/state/one" +func (n *Parent_Child_OnePathAny) State() ygnmi.WildcardQuery[string] { + return ygnmi.NewWildcardQuery[string]( + "Parent_Child", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "one"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.Parent_Child).One + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "config/one" +// Path from root: "/parent/child/config/one" +func (n *Parent_Child_OnePath) Config() ygnmi.ConfigQuery[string] { + return ygnmi.NewConfigQuery[string]( + "Parent_Child", + false, + false, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"config", "one"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.Parent_Child).One + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "config/one" +// Path from root: "/parent/child/config/one" +func (n *Parent_Child_OnePathAny) Config() ygnmi.WildcardQuery[string] { + return ygnmi.NewWildcardQuery[string]( + "Parent_Child", + false, + false, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"config", "one"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.Parent_Child).One + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Parent_Child_SixPath represents the /openconfig-simple/parent/child/config/six YANG schema element. +type Parent_Child_SixPath struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// Parent_Child_SixPathAny represents the wildcard version of the /openconfig-simple/parent/child/config/six YANG schema element. +type Parent_Child_SixPathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/six" +// Path from root: "/parent/child/state/six" +func (n *Parent_Child_SixPath) State() ygnmi.SingletonQuery[[]float32] { + return ygnmi.NewSingletonQuery[[]float32]( + "Parent_Child", + true, + true, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"state", "six"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) ([]float32, bool) { + ret := gs.(*oc.Parent_Child).Six + return binarySliceToFloatSlice(ret), !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/six" +// Path from root: "/parent/child/state/six" +func (n *Parent_Child_SixPathAny) State() ygnmi.WildcardQuery[[]float32] { + return ygnmi.NewWildcardQuery[[]float32]( + "Parent_Child", + true, + true, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"state", "six"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) ([]float32, bool) { + ret := gs.(*oc.Parent_Child).Six + return binarySliceToFloatSlice(ret), !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "config/six" +// Path from root: "/parent/child/config/six" +func (n *Parent_Child_SixPath) Config() ygnmi.ConfigQuery[[]float32] { + return ygnmi.NewConfigQuery[[]float32]( + "Parent_Child", + false, + false, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"config", "six"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) ([]float32, bool) { + ret := gs.(*oc.Parent_Child).Six + return binarySliceToFloatSlice(ret), !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "config/six" +// Path from root: "/parent/child/config/six" +func (n *Parent_Child_SixPathAny) Config() ygnmi.WildcardQuery[[]float32] { + return ygnmi.NewWildcardQuery[[]float32]( + "Parent_Child", + false, + false, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"config", "six"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) ([]float32, bool) { + ret := gs.(*oc.Parent_Child).Six + return binarySliceToFloatSlice(ret), !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Parent_Child_ThreePath represents the /openconfig-simple/parent/child/config/three YANG schema element. +type Parent_Child_ThreePath struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// Parent_Child_ThreePathAny represents the wildcard version of the /openconfig-simple/parent/child/config/three YANG schema element. +type Parent_Child_ThreePathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/three" +// Path from root: "/parent/child/state/three" +func (n *Parent_Child_ThreePath) State() ygnmi.SingletonQuery[oc.E_Child_Three] { + return ygnmi.NewSingletonQuery[oc.E_Child_Three]( + "Parent_Child", + true, + true, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"state", "three"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (oc.E_Child_Three, bool) { + ret := gs.(*oc.Parent_Child).Three + return ret, !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/three" +// Path from root: "/parent/child/state/three" +func (n *Parent_Child_ThreePathAny) State() ygnmi.WildcardQuery[oc.E_Child_Three] { + return ygnmi.NewWildcardQuery[oc.E_Child_Three]( + "Parent_Child", + true, + true, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"state", "three"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (oc.E_Child_Three, bool) { + ret := gs.(*oc.Parent_Child).Three + return ret, !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "config/three" +// Path from root: "/parent/child/config/three" +func (n *Parent_Child_ThreePath) Config() ygnmi.ConfigQuery[oc.E_Child_Three] { + return ygnmi.NewConfigQuery[oc.E_Child_Three]( + "Parent_Child", + false, + false, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"config", "three"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (oc.E_Child_Three, bool) { + ret := gs.(*oc.Parent_Child).Three + return ret, !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "config/three" +// Path from root: "/parent/child/config/three" +func (n *Parent_Child_ThreePathAny) Config() ygnmi.WildcardQuery[oc.E_Child_Three] { + return ygnmi.NewWildcardQuery[oc.E_Child_Three]( + "Parent_Child", + false, + false, + true, + false, + true, + false, + ygnmi.NewNodePath( + []string{"config", "three"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (oc.E_Child_Three, bool) { + ret := gs.(*oc.Parent_Child).Three + return ret, !reflect.ValueOf(ret).IsZero() + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Parent_Child_TwoPath represents the /openconfig-simple/parent/child/state/two YANG schema element. +type Parent_Child_TwoPath struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// Parent_Child_TwoPathAny represents the wildcard version of the /openconfig-simple/parent/child/state/two YANG schema element. +type Parent_Child_TwoPathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/two" +// Path from root: "/parent/child/state/two" +func (n *Parent_Child_TwoPath) State() ygnmi.SingletonQuery[string] { + return ygnmi.NewSingletonQuery[string]( + "Parent_Child", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "two"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.Parent_Child).Two + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/two" +// Path from root: "/parent/child/state/two" +func (n *Parent_Child_TwoPathAny) State() ygnmi.WildcardQuery[string] { + return ygnmi.NewWildcardQuery[string]( + "Parent_Child", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "two"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.Parent_Child).Two + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Parent_Child) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Parent_ChildPath represents the /openconfig-simple/parent/child YANG schema element. +type Parent_ChildPath struct { + *ygnmi.NodePath +} + +// Parent_ChildPathAny represents the wildcard version of the /openconfig-simple/parent/child YANG schema element. +type Parent_ChildPathAny struct { + *ygnmi.NodePath +} + +// Five (leaf): +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "*/five" +// Path from root: "/parent/child/*/five" +func (n *Parent_ChildPath) Five() *Parent_Child_FivePath { + ps := &Parent_Child_FivePath{ + NodePath: ygnmi.NewNodePath( + []string{"*", "five"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Five (leaf): +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "*/five" +// Path from root: "/parent/child/*/five" +func (n *Parent_ChildPathAny) Five() *Parent_Child_FivePathAny { + ps := &Parent_Child_FivePathAny{ + NodePath: ygnmi.NewNodePath( + []string{"*", "five"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Four (leaf): +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "*/four" +// Path from root: "/parent/child/*/four" +func (n *Parent_ChildPath) Four() *Parent_Child_FourPath { + ps := &Parent_Child_FourPath{ + NodePath: ygnmi.NewNodePath( + []string{"*", "four"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Four (leaf): +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "*/four" +// Path from root: "/parent/child/*/four" +func (n *Parent_ChildPathAny) Four() *Parent_Child_FourPathAny { + ps := &Parent_Child_FourPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"*", "four"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// One (leaf): +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "*/one" +// Path from root: "/parent/child/*/one" +func (n *Parent_ChildPath) One() *Parent_Child_OnePath { + ps := &Parent_Child_OnePath{ + NodePath: ygnmi.NewNodePath( + []string{"*", "one"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// One (leaf): +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "*/one" +// Path from root: "/parent/child/*/one" +func (n *Parent_ChildPathAny) One() *Parent_Child_OnePathAny { + ps := &Parent_Child_OnePathAny{ + NodePath: ygnmi.NewNodePath( + []string{"*", "one"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Six (leaf-list): +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "*/six" +// Path from root: "/parent/child/*/six" +func (n *Parent_ChildPath) Six() *Parent_Child_SixPath { + ps := &Parent_Child_SixPath{ + NodePath: ygnmi.NewNodePath( + []string{"*", "six"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Six (leaf-list): +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "*/six" +// Path from root: "/parent/child/*/six" +func (n *Parent_ChildPathAny) Six() *Parent_Child_SixPathAny { + ps := &Parent_Child_SixPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"*", "six"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Three (leaf): +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "*/three" +// Path from root: "/parent/child/*/three" +func (n *Parent_ChildPath) Three() *Parent_Child_ThreePath { + ps := &Parent_Child_ThreePath{ + NodePath: ygnmi.NewNodePath( + []string{"*", "three"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Three (leaf): +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "*/three" +// Path from root: "/parent/child/*/three" +func (n *Parent_ChildPathAny) Three() *Parent_Child_ThreePathAny { + ps := &Parent_Child_ThreePathAny{ + NodePath: ygnmi.NewNodePath( + []string{"*", "three"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Two (leaf): +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/two" +// Path from root: "/parent/child/state/two" +func (n *Parent_ChildPath) Two() *Parent_Child_TwoPath { + ps := &Parent_Child_TwoPath{ + NodePath: ygnmi.NewNodePath( + []string{"state", "two"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Two (leaf): +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/two" +// Path from root: "/parent/child/state/two" +func (n *Parent_ChildPathAny) Two() *Parent_Child_TwoPathAny { + ps := &Parent_Child_TwoPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"state", "two"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *Parent_ChildPath) State() ygnmi.SingletonQuery[*oc.Parent_Child] { + return ygnmi.NewSingletonQuery[*oc.Parent_Child]( + "Parent_Child", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *Parent_ChildPathAny) State() ygnmi.WildcardQuery[*oc.Parent_Child] { + return ygnmi.NewWildcardQuery[*oc.Parent_Child]( + "Parent_Child", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *Parent_ChildPath) Config() ygnmi.ConfigQuery[*oc.Parent_Child] { + return ygnmi.NewConfigQuery[*oc.Parent_Child]( + "Parent_Child", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *Parent_ChildPathAny) Config() ygnmi.WildcardQuery[*oc.Parent_Child] { + return ygnmi.NewWildcardQuery[*oc.Parent_Child]( + "Parent_Child", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// RemoteContainer_ALeafPath represents the /openconfig-simple/remote-container/config/a-leaf YANG schema element. +type RemoteContainer_ALeafPath struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// RemoteContainer_ALeafPathAny represents the wildcard version of the /openconfig-simple/remote-container/config/a-leaf YANG schema element. +type RemoteContainer_ALeafPathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-remote" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/a-leaf" +// Path from root: "/remote-container/state/a-leaf" +func (n *RemoteContainer_ALeafPath) State() ygnmi.SingletonQuery[string] { + return ygnmi.NewSingletonQuery[string]( + "RemoteContainer", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "a-leaf"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.RemoteContainer).ALeaf + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.RemoteContainer) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-remote" +// Instantiating module: "openconfig-simple" +// Path from parent: "state/a-leaf" +// Path from root: "/remote-container/state/a-leaf" +func (n *RemoteContainer_ALeafPathAny) State() ygnmi.WildcardQuery[string] { + return ygnmi.NewWildcardQuery[string]( + "RemoteContainer", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "a-leaf"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.RemoteContainer).ALeaf + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.RemoteContainer) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-remote" +// Instantiating module: "openconfig-simple" +// Path from parent: "config/a-leaf" +// Path from root: "/remote-container/config/a-leaf" +func (n *RemoteContainer_ALeafPath) Config() ygnmi.ConfigQuery[string] { + return ygnmi.NewConfigQuery[string]( + "RemoteContainer", + false, + false, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"config", "a-leaf"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.RemoteContainer).ALeaf + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.RemoteContainer) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-remote" +// Instantiating module: "openconfig-simple" +// Path from parent: "config/a-leaf" +// Path from root: "/remote-container/config/a-leaf" +func (n *RemoteContainer_ALeafPathAny) Config() ygnmi.WildcardQuery[string] { + return ygnmi.NewWildcardQuery[string]( + "RemoteContainer", + false, + false, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"config", "a-leaf"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (string, bool) { + ret := gs.(*oc.RemoteContainer).ALeaf + if ret == nil { + var zero string + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.RemoteContainer) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// RemoteContainerPath represents the /openconfig-simple/remote-container YANG schema element. +type RemoteContainerPath struct { + *ygnmi.NodePath +} + +// RemoteContainerPathAny represents the wildcard version of the /openconfig-simple/remote-container YANG schema element. +type RemoteContainerPathAny struct { + *ygnmi.NodePath +} + +// ALeaf (leaf): +// +// Defining module: "openconfig-remote" +// Instantiating module: "openconfig-simple" +// Path from parent: "*/a-leaf" +// Path from root: "/remote-container/*/a-leaf" +func (n *RemoteContainerPath) ALeaf() *RemoteContainer_ALeafPath { + ps := &RemoteContainer_ALeafPath{ + NodePath: ygnmi.NewNodePath( + []string{"*", "a-leaf"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// ALeaf (leaf): +// +// Defining module: "openconfig-remote" +// Instantiating module: "openconfig-simple" +// Path from parent: "*/a-leaf" +// Path from root: "/remote-container/*/a-leaf" +func (n *RemoteContainerPathAny) ALeaf() *RemoteContainer_ALeafPathAny { + ps := &RemoteContainer_ALeafPathAny{ + NodePath: ygnmi.NewNodePath( + []string{"*", "a-leaf"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// State returns a Query that can be used in gNMI operations. +func (n *RemoteContainerPath) State() ygnmi.SingletonQuery[*oc.RemoteContainer] { + return ygnmi.NewSingletonQuery[*oc.RemoteContainer]( + "RemoteContainer", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *RemoteContainerPathAny) State() ygnmi.WildcardQuery[*oc.RemoteContainer] { + return ygnmi.NewWildcardQuery[*oc.RemoteContainer]( + "RemoteContainer", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *RemoteContainerPath) Config() ygnmi.ConfigQuery[*oc.RemoteContainer] { + return ygnmi.NewConfigQuery[*oc.RemoteContainer]( + "RemoteContainer", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *RemoteContainerPathAny) Config() ygnmi.WildcardQuery[*oc.RemoteContainer] { + return ygnmi.NewWildcardQuery[*oc.RemoteContainer]( + "RemoteContainer", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// RootPath represents the /root YANG schema element. +type RootPath struct { + *ygnmi.DeviceRootBase +} + +// Root returns a root path object from which YANG paths can be constructed. +func Root() *RootPath { + return &RootPath{ygnmi.NewDeviceRootBase()} +} + +// A (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "a" +// Path from root: "/a" +func (n *RootPath) A() *APath { + ps := &APath{ + NodePath: ygnmi.NewNodePath( + []string{"a"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// Container (container): +// +// Defining module: "openconfig-nested" +// Instantiating module: "openconfig-nested" +// Path from parent: "container" +// Path from root: "/container" +func (n *RootPath) Container() *ContainerPath { + ps := &ContainerPath{ + NodePath: ygnmi.NewNodePath( + []string{"container"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// Model (container): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "model" +// Path from root: "/model" +func (n *RootPath) Model() *ModelPath { + ps := &ModelPath{ + NodePath: ygnmi.NewNodePath( + []string{"model"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// Parent (container): I am a parent container +// that has 4 children. +// +// Defining module: "openconfig-simple" +// Instantiating module: "openconfig-simple" +// Path from parent: "parent" +// Path from root: "/parent" +func (n *RootPath) Parent() *ParentPath { + ps := &ParentPath{ + NodePath: ygnmi.NewNodePath( + []string{"parent"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// RemoteContainer (container): +// +// Defining module: "openconfig-remote" +// Instantiating module: "openconfig-simple" +// Path from parent: "remote-container" +// Path from root: "/remote-container" +func (n *RootPath) RemoteContainer() *RemoteContainerPath { + ps := &RemoteContainerPath{ + NodePath: ygnmi.NewNodePath( + []string{"remote-container"}, + map[string]interface{}{}, + n, + ), + } + return ps +} + +// Batch contains a collection of paths. +// Use batch to call Lookup, Watch, etc. on multiple paths at once. +type Batch struct { + paths []ygnmi.PathStruct +} + +// AddPaths adds the paths to the batch. +func (b *Batch) AddPaths(paths ...ygnmi.PathStruct) *Batch { + b.paths = append(b.paths, paths...) + return b +} + +// State returns a Query that can be used in gNMI operations. +// The returned query is immutable, adding paths does not modify existing queries. +func (b *Batch) State() ygnmi.SingletonQuery[*oc.Root] { + queryPaths := make([]ygnmi.PathStruct, len(b.paths)) + copy(queryPaths, b.paths) + return ygnmi.NewSingletonQuery[*oc.Root]( + "Root", + true, + true, + false, + false, + true, + false, + ygnmi.NewDeviceRootBase(), + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + queryPaths, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// The returned query is immutable, adding paths does not modify existing queries. +func (b *Batch) Config() ygnmi.SingletonQuery[*oc.Root] { + queryPaths := make([]ygnmi.PathStruct, len(b.paths)) + copy(queryPaths, b.paths) + return ygnmi.NewSingletonQuery[*oc.Root]( + "Root", + false, + false, + false, + false, + true, + false, + ygnmi.NewDeviceRootBase(), + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + queryPaths, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *RootPath) State() ygnmi.SingletonQuery[*oc.Root] { + return ygnmi.NewSingletonQuery[*oc.Root]( + "Root", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *RootPath) Config() ygnmi.ConfigQuery[*oc.Root] { + return ygnmi.NewConfigQuery[*oc.Root]( + "Root", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} diff --git a/internal/exampleocconfig/gen.go b/internal/exampleocconfig/gen.go new file mode 100644 index 0000000..c2d5a30 --- /dev/null +++ b/internal/exampleocconfig/gen.go @@ -0,0 +1,16 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:generate ./gen.sh +package exampleocconfig diff --git a/internal/exampleocconfig/gen.sh b/internal/exampleocconfig/gen.sh new file mode 100755 index 0000000..d9a097d --- /dev/null +++ b/internal/exampleocconfig/gen.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +set -e + +cd "$(dirname "$0")" + +go run ../../app/ygnmi generator \ + --trim_module_prefix=openconfig \ + --prefer_operational_state=false \ + --base_package_path=github.com/openconfig/ygnmi/internal/exampleocconfig \ + --split_package_paths=/model/a=a,/model/b \ + --split_top_level_packages=false \ + ../../pathgen/testdata/yang/openconfig-simple.yang \ + ../../pathgen/testdata/yang/openconfig-withlistval.yang \ + ../../pathgen/testdata/yang/openconfig-nested.yang + +go install golang.org/x/tools/cmd/goimports@latest +go install github.com/google/addlicense@latest +goimports -w . +addlicense -c "Google LLC" -y "2023" -l apache . diff --git a/internal/exampleocconfig/modelb/modelb-0.go b/internal/exampleocconfig/modelb/modelb-0.go new file mode 100644 index 0000000..e554dc9 --- /dev/null +++ b/internal/exampleocconfig/modelb/modelb-0.go @@ -0,0 +1,724 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* +Package modelb is a generated package which contains definitions +of structs which generate gNMI paths for a YANG schema. + +This package was generated by ygnmi version: (devel): (ygot: v0.29.12) +using the following YANG input files: + - ../../pathgen/testdata/yang/openconfig-simple.yang + - ../../pathgen/testdata/yang/openconfig-withlistval.yang + - ../../pathgen/testdata/yang/openconfig-nested.yang + +Imported modules were sourced from: +*/ +package modelb + +import ( + oc "github.com/openconfig/ygnmi/internal/exampleocconfig" + "github.com/openconfig/ygnmi/ygnmi" + "github.com/openconfig/ygot/ygot" + "github.com/openconfig/ygot/ytypes" +) + +// WithKey1 sets Model_MultiKeyPathAny's key "key1" to the specified value. +// Key1: uint32 +func (n *Model_MultiKeyPathAny) WithKey1(Key1 uint32) *Model_MultiKeyPathAny { + ygnmi.ModifyKey(n.NodePath, "key1", Key1) + return n +} + +// WithKey2 sets Model_MultiKeyPathAny's key "key2" to the specified value. +// Key2: uint64 +func (n *Model_MultiKeyPathAny) WithKey2(Key2 uint64) *Model_MultiKeyPathAny { + ygnmi.ModifyKey(n.NodePath, "key2", Key2) + return n +} + +// Model_MultiKey_Key1Path represents the /openconfig-withlistval/model/b/multi-key/config/key1 YANG schema element. +type Model_MultiKey_Key1Path struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// Model_MultiKey_Key1PathAny represents the wildcard version of the /openconfig-withlistval/model/b/multi-key/config/key1 YANG schema element. +type Model_MultiKey_Key1PathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/key1" +// Path from root: "/model/b/multi-key/state/key1" +func (n *Model_MultiKey_Key1Path) State() ygnmi.SingletonQuery[uint32] { + return ygnmi.NewSingletonQuery[uint32]( + "Model_MultiKey", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "key1"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (uint32, bool) { + ret := gs.(*oc.Model_MultiKey).Key1 + if ret == nil { + var zero uint32 + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_MultiKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/key1" +// Path from root: "/model/b/multi-key/state/key1" +func (n *Model_MultiKey_Key1PathAny) State() ygnmi.WildcardQuery[uint32] { + return ygnmi.NewWildcardQuery[uint32]( + "Model_MultiKey", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "key1"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (uint32, bool) { + ret := gs.(*oc.Model_MultiKey).Key1 + if ret == nil { + var zero uint32 + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_MultiKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "config/key1" +// Path from root: "/model/b/multi-key/config/key1" +func (n *Model_MultiKey_Key1Path) Config() ygnmi.ConfigQuery[uint32] { + return ygnmi.NewConfigQuery[uint32]( + "Model_MultiKey", + false, + false, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"config", "key1"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (uint32, bool) { + ret := gs.(*oc.Model_MultiKey).Key1 + if ret == nil { + var zero uint32 + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_MultiKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "config/key1" +// Path from root: "/model/b/multi-key/config/key1" +func (n *Model_MultiKey_Key1PathAny) Config() ygnmi.WildcardQuery[uint32] { + return ygnmi.NewWildcardQuery[uint32]( + "Model_MultiKey", + false, + false, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"config", "key1"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (uint32, bool) { + ret := gs.(*oc.Model_MultiKey).Key1 + if ret == nil { + var zero uint32 + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_MultiKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Model_MultiKey_Key2Path represents the /openconfig-withlistval/model/b/multi-key/config/key2 YANG schema element. +type Model_MultiKey_Key2Path struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// Model_MultiKey_Key2PathAny represents the wildcard version of the /openconfig-withlistval/model/b/multi-key/config/key2 YANG schema element. +type Model_MultiKey_Key2PathAny struct { + *ygnmi.NodePath + parent ygnmi.PathStruct +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/key2" +// Path from root: "/model/b/multi-key/state/key2" +func (n *Model_MultiKey_Key2Path) State() ygnmi.SingletonQuery[uint64] { + return ygnmi.NewSingletonQuery[uint64]( + "Model_MultiKey", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "key2"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (uint64, bool) { + ret := gs.(*oc.Model_MultiKey).Key2 + if ret == nil { + var zero uint64 + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_MultiKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "state/key2" +// Path from root: "/model/b/multi-key/state/key2" +func (n *Model_MultiKey_Key2PathAny) State() ygnmi.WildcardQuery[uint64] { + return ygnmi.NewWildcardQuery[uint64]( + "Model_MultiKey", + true, + true, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"state", "key2"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (uint64, bool) { + ret := gs.(*oc.Model_MultiKey).Key2 + if ret == nil { + var zero uint64 + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_MultiKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "config/key2" +// Path from root: "/model/b/multi-key/config/key2" +func (n *Model_MultiKey_Key2Path) Config() ygnmi.ConfigQuery[uint64] { + return ygnmi.NewConfigQuery[uint64]( + "Model_MultiKey", + false, + false, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"config", "key2"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (uint64, bool) { + ret := gs.(*oc.Model_MultiKey).Key2 + if ret == nil { + var zero uint64 + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_MultiKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "config/key2" +// Path from root: "/model/b/multi-key/config/key2" +func (n *Model_MultiKey_Key2PathAny) Config() ygnmi.WildcardQuery[uint64] { + return ygnmi.NewWildcardQuery[uint64]( + "Model_MultiKey", + false, + false, + true, + true, + true, + false, + ygnmi.NewNodePath( + []string{"config", "key2"}, + nil, + n.parent, + ), + func(gs ygot.ValidatedGoStruct) (uint64, bool) { + ret := gs.(*oc.Model_MultiKey).Key2 + if ret == nil { + var zero uint64 + return zero, false + } + return *ret, true + }, + func() ygot.ValidatedGoStruct { return new(oc.Model_MultiKey) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Model_MultiKeyPath represents the /openconfig-withlistval/model/b/multi-key YANG schema element. +type Model_MultiKeyPath struct { + *ygnmi.NodePath +} + +// Model_MultiKeyPathAny represents the wildcard version of the /openconfig-withlistval/model/b/multi-key YANG schema element. +type Model_MultiKeyPathAny struct { + *ygnmi.NodePath +} + +// Model_MultiKeyPathMap represents the /openconfig-withlistval/model/b/multi-key YANG schema element. +type Model_MultiKeyPathMap struct { + *ygnmi.NodePath +} + +// Model_MultiKeyPathMapAny represents the wildcard version of the /openconfig-withlistval/model/b/multi-key YANG schema element. +type Model_MultiKeyPathMapAny struct { + *ygnmi.NodePath +} + +// Key1 (leaf): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "*/key1" +// Path from root: "/model/b/multi-key/*/key1" +func (n *Model_MultiKeyPath) Key1() *Model_MultiKey_Key1Path { + ps := &Model_MultiKey_Key1Path{ + NodePath: ygnmi.NewNodePath( + []string{"*", "key1"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Key1 (leaf): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "*/key1" +// Path from root: "/model/b/multi-key/*/key1" +func (n *Model_MultiKeyPathAny) Key1() *Model_MultiKey_Key1PathAny { + ps := &Model_MultiKey_Key1PathAny{ + NodePath: ygnmi.NewNodePath( + []string{"*", "key1"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Key2 (leaf): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "*/key2" +// Path from root: "/model/b/multi-key/*/key2" +func (n *Model_MultiKeyPath) Key2() *Model_MultiKey_Key2Path { + ps := &Model_MultiKey_Key2Path{ + NodePath: ygnmi.NewNodePath( + []string{"*", "key2"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +// Key2 (leaf): +// +// Defining module: "openconfig-withlistval" +// Instantiating module: "openconfig-withlistval" +// Path from parent: "*/key2" +// Path from root: "/model/b/multi-key/*/key2" +func (n *Model_MultiKeyPathAny) Key2() *Model_MultiKey_Key2PathAny { + ps := &Model_MultiKey_Key2PathAny{ + NodePath: ygnmi.NewNodePath( + []string{"*", "key2"}, + map[string]interface{}{}, + n, + ), + parent: n, + } + return ps +} + +func binarySliceToFloatSlice(in []oc.Binary) []float32 { + converted := make([]float32, 0, len(in)) + for _, binary := range in { + converted = append(converted, ygot.BinaryToFloat32(binary)) + } + return converted +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_MultiKeyPath) State() ygnmi.SingletonQuery[*oc.Model_MultiKey] { + return ygnmi.NewSingletonQuery[*oc.Model_MultiKey]( + "Model_MultiKey", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_MultiKeyPathAny) State() ygnmi.WildcardQuery[*oc.Model_MultiKey] { + return ygnmi.NewWildcardQuery[*oc.Model_MultiKey]( + "Model_MultiKey", + true, + true, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *Model_MultiKeyPath) Config() ygnmi.ConfigQuery[*oc.Model_MultiKey] { + return ygnmi.NewConfigQuery[*oc.Model_MultiKey]( + "Model_MultiKey", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *Model_MultiKeyPathAny) Config() ygnmi.WildcardQuery[*oc.Model_MultiKey] { + return ygnmi.NewWildcardQuery[*oc.Model_MultiKey]( + "Model_MultiKey", + false, + false, + false, + false, + true, + false, + n, + nil, + nil, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + nil, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_MultiKeyPathMap) State() ygnmi.SingletonQuery[map[oc.Model_MultiKey_Key]*oc.Model_MultiKey] { + return ygnmi.NewSingletonQuery[map[oc.Model_MultiKey_Key]*oc.Model_MultiKey]( + "Model", + true, + true, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (map[oc.Model_MultiKey_Key]*oc.Model_MultiKey, bool) { + ret := gs.(*oc.Model).MultiKey + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:b"}, + PostRelPath: []string{"openconfig-withlistval:multi-key"}, + }, + ) +} + +// State returns a Query that can be used in gNMI operations. +func (n *Model_MultiKeyPathMapAny) State() ygnmi.WildcardQuery[map[oc.Model_MultiKey_Key]*oc.Model_MultiKey] { + return ygnmi.NewWildcardQuery[map[oc.Model_MultiKey_Key]*oc.Model_MultiKey]( + "Model", + true, + true, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (map[oc.Model_MultiKey_Key]*oc.Model_MultiKey, bool) { + ret := gs.(*oc.Model).MultiKey + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:b"}, + PostRelPath: []string{"openconfig-withlistval:multi-key"}, + }, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *Model_MultiKeyPathMap) Config() ygnmi.ConfigQuery[map[oc.Model_MultiKey_Key]*oc.Model_MultiKey] { + return ygnmi.NewConfigQuery[map[oc.Model_MultiKey_Key]*oc.Model_MultiKey]( + "Model", + false, + false, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (map[oc.Model_MultiKey_Key]*oc.Model_MultiKey, bool) { + ret := gs.(*oc.Model).MultiKey + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:b"}, + PostRelPath: []string{"openconfig-withlistval:multi-key"}, + }, + ) +} + +// Config returns a Query that can be used in gNMI operations. +func (n *Model_MultiKeyPathMapAny) Config() ygnmi.WildcardQuery[map[oc.Model_MultiKey_Key]*oc.Model_MultiKey] { + return ygnmi.NewWildcardQuery[map[oc.Model_MultiKey_Key]*oc.Model_MultiKey]( + "Model", + false, + false, + false, + false, + true, + true, + n, + func(gs ygot.ValidatedGoStruct) (map[oc.Model_MultiKey_Key]*oc.Model_MultiKey, bool) { + ret := gs.(*oc.Model).MultiKey + return ret, ret != nil + }, + func() ygot.ValidatedGoStruct { return new(oc.Model) }, + func() *ytypes.Schema { + return &ytypes.Schema{ + Root: &oc.Root{}, + SchemaTree: oc.SchemaTree, + Unmarshal: oc.Unmarshal, + } + }, + nil, + &ygnmi.CompressionInfo{ + PreRelPath: []string{"openconfig-withlistval:b"}, + PostRelPath: []string{"openconfig-withlistval:multi-key"}, + }, + ) +} diff --git a/internal/exampleocconfig/schema.go b/internal/exampleocconfig/schema.go new file mode 100644 index 0000000..e89547b --- /dev/null +++ b/internal/exampleocconfig/schema.go @@ -0,0 +1,285 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* +Package exampleocconfig is a generated package which contains definitions +of structs which represent a YANG schema. The generated schema can be +compressed by a series of transformations (compression was true +in this case). + +This package was generated by ygnmi version: (devel): (ygot: v0.29.12) +using the following YANG input files: + - ../../pathgen/testdata/yang/openconfig-simple.yang + - ../../pathgen/testdata/yang/openconfig-withlistval.yang + - ../../pathgen/testdata/yang/openconfig-nested.yang + +Imported modules were sourced from: +*/ +package exampleocconfig + +var ( + // ySchema is a byte slice contain a gzip compressed representation of the + // YANG schema from which the Go code was generated. When uncompressed the + // contents of the byte slice is a JSON document containing an object, keyed + // on the name of the generated struct, and containing the JSON marshalled + // contents of a goyang yang.Entry struct, which defines the schema for the + // fields within the struct. + ySchema = []byte{ + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x5d, 0x4b, 0x73, 0xdb, 0x46, + 0x12, 0xbe, 0xeb, 0x57, 0xb0, 0x70, 0x0e, 0x03, 0x91, 0x96, 0xac, 0xc7, 0xcd, 0x51, 0xe4, 0x4d, + 0xd6, 0x91, 0xed, 0xb2, 0xbd, 0xbb, 0x87, 0x8d, 0x8b, 0x05, 0x41, 0x43, 0x0a, 0x36, 0x09, 0xa8, + 0x00, 0xd0, 0x96, 0x6a, 0x8b, 0xff, 0x7d, 0x8b, 0x0f, 0x80, 0x2f, 0x3c, 0x66, 0xba, 0x7b, 0x06, + 0x43, 0xa2, 0x73, 0x8a, 0x45, 0x0e, 0x38, 0x98, 0xe9, 0xfe, 0xfa, 0xdd, 0xfd, 0xbf, 0x93, 0x4e, + 0xa7, 0xd3, 0x71, 0xde, 0x7b, 0x13, 0xe1, 0x5c, 0x77, 0x9c, 0x38, 0x8a, 0x52, 0xe7, 0x97, 0xe5, + 0xdf, 0xde, 0x05, 0xe1, 0x83, 0x73, 0xdd, 0xe9, 0xad, 0xfe, 0x79, 0x13, 0x85, 0xc3, 0x60, 0xe4, + 0x5c, 0x77, 0x4e, 0x57, 0x7f, 0xf8, 0x3d, 0x88, 0x9d, 0xeb, 0xce, 0xf2, 0x01, 0x8b, 0x3f, 0x78, + 0x5b, 0xff, 0xdc, 0x7a, 0xae, 0xb7, 0x7a, 0x68, 0xfe, 0xc1, 0xf6, 0xc3, 0xf3, 0x3f, 0xef, 0xfe, + 0x48, 0xfe, 0xc1, 0xc7, 0x58, 0x0c, 0x83, 0xe7, 0xbd, 0x1f, 0xd8, 0xfa, 0x91, 0xc8, 0x0f, 0x77, + 0x7e, 0x66, 0xf1, 0xf1, 0xe7, 0x68, 0x1a, 0xfb, 0xa2, 0x70, 0xe9, 0x72, 0x2b, 0xe2, 0xe5, 0x67, + 0x14, 0xcf, 0x77, 0xe3, 0x3c, 0x2d, 0x7f, 0xe5, 0x97, 0xe2, 0x2f, 0xfe, 0xe1, 0x25, 0x6f, 0xe2, + 0xd1, 0x74, 0x22, 0xc2, 0xd4, 0xb9, 0xee, 0xa4, 0xf1, 0x54, 0x94, 0x7c, 0x71, 0xe3, 0x5b, 0x8b, + 0x4d, 0xed, 0x7d, 0x6b, 0xb6, 0xf5, 0x97, 0xd9, 0xce, 0xbb, 0xee, 0x1e, 0x6c, 0xfe, 0xc1, 0x7d, + 0xf9, 0x4b, 0x64, 0x67, 0x70, 0x5f, 0xb6, 0xf9, 0xe2, 0x03, 0xaf, 0x3d, 0x78, 0x99, 0x0b, 0x90, + 0xbc, 0x08, 0xd9, 0x0b, 0x51, 0xbe, 0x18, 0xe5, 0x0b, 0x92, 0xbf, 0xa8, 0xe2, 0x0b, 0x2b, 0xb9, + 0xb8, 0xda, 0x0b, 0xcc, 0xbf, 0xe0, 0xd7, 0xbf, 0x7c, 0x76, 0x96, 0x7e, 0xdd, 0x4b, 0x57, 0x5f, + 0xac, 0xf4, 0x05, 0xab, 0x5c, 0xb4, 0xe2, 0x85, 0xab, 0x5e, 0x3c, 0x98, 0x00, 0xc0, 0x84, 0xa0, + 0x4e, 0x10, 0xd5, 0x84, 0x51, 0x43, 0x20, 0xd2, 0x84, 0x92, 0x7f, 0xf1, 0x41, 0xfe, 0xd0, 0xb2, + 0x3b, 0x79, 0x90, 0x3d, 0x2c, 0x39, 0x02, 0x52, 0x26, 0x24, 0x08, 0x41, 0x01, 0x09, 0x0b, 0x4a, + 0x60, 0x68, 0x42, 0x43, 0x13, 0x1c, 0x9c, 0xf0, 0xe4, 0x08, 0x50, 0x92, 0x10, 0x95, 0x09, 0x32, + 0x5f, 0x00, 0x38, 0xec, 0xec, 0x6e, 0x85, 0xea, 0x21, 0xab, 0x11, 0x2a, 0x98, 0x60, 0x31, 0x84, + 0x8b, 0x24, 0x60, 0x2c, 0x21, 0x93, 0x11, 0x34, 0x19, 0x61, 0xe3, 0x09, 0x5c, 0x8d, 0xd0, 0x15, + 0x09, 0x1e, 0x4c, 0xf8, 0xf9, 0xc2, 0x21, 0xfc, 0x92, 0x32, 0x1a, 0x19, 0x42, 0x2f, 0x07, 0xc6, + 0x10, 0x68, 0xc6, 0xa0, 0x60, 0x10, 0x22, 0x46, 0xa1, 0x62, 0x18, 0x72, 0xc6, 0x21, 0x67, 0x20, + 0x3a, 0x46, 0x82, 0x31, 0x14, 0x90, 0xb1, 0xd0, 0x0c, 0x96, 0x3f, 0x60, 0x84, 0xbf, 0xdc, 0x8c, + 0xd6, 0x46, 0xd8, 0x4b, 0xc5, 0x31, 0x1e, 0x19, 0x03, 0x52, 0x32, 0x22, 0x31, 0x43, 0x52, 0x33, + 0xa6, 0x36, 0x06, 0xd5, 0xc6, 0xa8, 0xf4, 0x0c, 0x8b, 0x63, 0x5c, 0x24, 0x03, 0x93, 0x31, 0x72, + 0xfe, 0xa0, 0x47, 0x3a, 0xa2, 0xc8, 0x68, 0xf6, 0x91, 0x8a, 0x18, 0x68, 0x18, 0x9c, 0x9c, 0xd1, + 0x75, 0x30, 0xbc, 0x26, 0xc6, 0xd7, 0x05, 0x00, 0xda, 0x81, 0x40, 0x3b, 0x20, 0xe8, 0x03, 0x06, + 0x1a, 0x80, 0x20, 0x02, 0x0a, 0x72, 0xc0, 0xc8, 0x1f, 0x18, 0xd0, 0x13, 0x53, 0x46, 0xfb, 0x01, + 0x35, 0x11, 0xd1, 0x02, 0x89, 0x36, 0x40, 0xd1, 0x09, 0x2c, 0x9a, 0x01, 0x46, 0x37, 0xd0, 0x18, + 0x03, 0x1c, 0x63, 0xc0, 0xa3, 0x1f, 0x80, 0x68, 0x81, 0x88, 0x18, 0x90, 0xb4, 0x01, 0x53, 0xfe, + 0xe0, 0x6f, 0xfa, 0x88, 0x30, 0xe3, 0xa1, 0x6f, 0xba, 0x88, 0x4f, 0x0f, 0x60, 0x69, 0x07, 0x2e, + 0x13, 0x00, 0x66, 0x08, 0xc8, 0x4c, 0x01, 0x9a, 0x71, 0x60, 0x33, 0x0e, 0x70, 0xe6, 0x80, 0x4e, + 0x0f, 0xe0, 0x69, 0x02, 0x3e, 0xed, 0x00, 0x98, 0xff, 0xc0, 0x77, 0xfd, 0xc4, 0x9b, 0xf1, 0xe2, + 0x77, 0xdd, 0x44, 0xab, 0x17, 0x18, 0x8d, 0x01, 0xa4, 0x49, 0xa0, 0x34, 0x0c, 0x98, 0xa6, 0x81, + 0xb3, 0x31, 0x00, 0x6d, 0x0c, 0x48, 0xcd, 0x03, 0xaa, 0x5e, 0x60, 0xd5, 0x0c, 0xb0, 0xc6, 0x80, + 0x36, 0xff, 0xa1, 0xb1, 0x39, 0xa2, 0xcf, 0x78, 0x7a, 0x6c, 0x8a, 0xd8, 0xcd, 0x00, 0xb0, 0x71, + 0x20, 0x6e, 0x02, 0x90, 0x1b, 0x02, 0xe6, 0xa6, 0x00, 0xba, 0x71, 0xa0, 0x6e, 0x1c, 0xb0, 0x9b, + 0x03, 0x6e, 0x33, 0x00, 0x6e, 0x08, 0xc8, 0x8d, 0x03, 0x7a, 0xfe, 0x83, 0x13, 0xf3, 0xcc, 0x92, + 0x61, 0xc3, 0xc4, 0x34, 0x93, 0x98, 0x05, 0xfa, 0xc6, 0x00, 0xbf, 0x49, 0xe0, 0x6f, 0x58, 0x00, + 0x34, 0x2d, 0x08, 0xac, 0x11, 0x08, 0xd6, 0x08, 0x86, 0xe6, 0x05, 0x84, 0x59, 0x41, 0x61, 0x58, + 0x60, 0x34, 0x26, 0x38, 0xf2, 0x1f, 0x4e, 0x52, 0x2f, 0x6d, 0x90, 0xd1, 0x32, 0x9c, 0x59, 0x6e, + 0xa3, 0x21, 0xda, 0x6e, 0x46, 0xb0, 0xec, 0x0b, 0x98, 0x7e, 0x43, 0x1b, 0x68, 0x50, 0xd0, 0x58, + 0x22, 0x70, 0x6c, 0x11, 0x3c, 0xd6, 0x09, 0x20, 0xeb, 0x04, 0x91, 0x3d, 0x02, 0xa9, 0x19, 0xc1, + 0xd4, 0x90, 0x80, 0x6a, 0x5c, 0x50, 0xe5, 0x1b, 0x18, 0x46, 0x51, 0xf3, 0xec, 0x99, 0xa7, 0x68, + 0x47, 0x51, 0xd3, 0x8c, 0xb9, 0x12, 0x5e, 0xa7, 0x0d, 0x6f, 0xa3, 0x29, 0x2b, 0xc9, 0x46, 0x61, + 0x66, 0x99, 0x50, 0xb3, 0x4d, 0xb8, 0x59, 0x2b, 0xe4, 0xac, 0x15, 0x76, 0xf6, 0x09, 0xbd, 0x66, + 0x85, 0x5f, 0xc3, 0x42, 0x30, 0xbf, 0x8e, 0x2f, 0x2f, 0x4f, 0xc2, 0x2e, 0xa4, 0x49, 0xd2, 0x38, + 0x08, 0x47, 0x36, 0x80, 0x4d, 0x66, 0x54, 0x5d, 0x9e, 0xb4, 0x93, 0x3e, 0xdb, 0xa5, 0x16, 0xbe, + 0x09, 0xc3, 0x28, 0xf5, 0xd2, 0x20, 0x0a, 0x9b, 0xd5, 0x0e, 0x13, 0xff, 0x51, 0x4c, 0xbc, 0x27, + 0x2f, 0x7d, 0x9c, 0x73, 0x83, 0x1b, 0x3d, 0x89, 0xd0, 0x5f, 0x68, 0x26, 0xdd, 0x50, 0x24, 0xa9, + 0x78, 0x70, 0x3d, 0xf7, 0xde, 0xf5, 0xdd, 0x07, 0x57, 0xb8, 0x43, 0x77, 0xe4, 0x3e, 0xba, 0x81, + 0xfb, 0xcd, 0xfd, 0xee, 0x8e, 0xdd, 0x89, 0xbb, 0x74, 0x41, 0x9c, 0xb4, 0x83, 0x56, 0x8e, 0xdb, + 0x9b, 0xd6, 0x30, 0x35, 0x22, 0xa8, 0xb0, 0x09, 0x67, 0x7b, 0x92, 0xc6, 0x53, 0x3f, 0x0d, 0x57, + 0x12, 0xe4, 0xcd, 0xe0, 0xb7, 0xc1, 0xcd, 0xe0, 0xf7, 0xc1, 0xed, 0xe0, 0xed, 0xe0, 0x1f, 0x83, + 0x3f, 0x06, 0x7f, 0x0e, 0xfe, 0x39, 0x78, 0x37, 0xf8, 0x6b, 0x70, 0x67, 0x96, 0x35, 0x66, 0x1c, + 0x81, 0x3c, 0x24, 0xd2, 0x07, 0x93, 0xbc, 0xc9, 0xf4, 0x02, 0x29, 0x42, 0x37, 0x43, 0xe6, 0x33, + 0xce, 0x8c, 0xb2, 0x89, 0x8c, 0x81, 0xe4, 0x6b, 0x22, 0x69, 0x51, 0x82, 0x68, 0xf5, 0x92, 0xec, + 0x8c, 0xb3, 0xa2, 0x4d, 0x92, 0x24, 0x88, 0x14, 0x75, 0x96, 0x1b, 0xd4, 0x12, 0xa0, 0x1e, 0xf2, + 0x9b, 0xb5, 0xac, 0xea, 0x48, 0x33, 0x79, 0x01, 0xc8, 0x4a, 0x47, 0x31, 0x5e, 0x0d, 0x31, 0xd1, + 0x92, 0xd2, 0xec, 0x48, 0x2b, 0x67, 0x35, 0x91, 0x8a, 0x32, 0x89, 0x50, 0x96, 0x83, 0x57, 0x12, + 0x06, 0x0d, 0x59, 0xcc, 0x0e, 0xbc, 0xc3, 0x02, 0xf1, 0xb5, 0x2b, 0x5e, 0x37, 0x45, 0xd3, 0x8f, + 0x8a, 0x4b, 0xc6, 0x5d, 0xf1, 0xec, 0x40, 0xba, 0xdd, 0x10, 0x5d, 0xa1, 0xd2, 0xd5, 0x61, 0xda, + 0x27, 0x95, 0x5e, 0x18, 0xec, 0xba, 0x66, 0x96, 0x75, 0xf7, 0x42, 0x5e, 0x87, 0xc2, 0x35, 0x40, + 0x9a, 0xbd, 0x95, 0x1c, 0xbe, 0xda, 0xd1, 0xcf, 0x1a, 0xea, 0x18, 0x08, 0x3c, 0x5a, 0xe9, 0x23, + 0x55, 0x69, 0xff, 0x58, 0x78, 0x90, 0x72, 0xc7, 0x38, 0xd3, 0xdc, 0xe9, 0x53, 0xf1, 0x98, 0x24, + 0x8f, 0x47, 0xa6, 0xe9, 0x6a, 0xc1, 0xa1, 0x54, 0x1f, 0xc9, 0x8c, 0xa8, 0x0b, 0xae, 0xe4, 0x2b, + 0x4b, 0xbd, 0x6a, 0x55, 0x3b, 0xe1, 0xbd, 0x17, 0x2c, 0x7e, 0xbd, 0x99, 0x62, 0x17, 0xe6, 0x9a, + 0xed, 0x4b, 0x6c, 0xbb, 0xa8, 0x19, 0xf5, 0xce, 0x66, 0xb7, 0xb7, 0xba, 0xde, 0xd0, 0xc6, 0x66, + 0x1c, 0x3f, 0x0a, 0x53, 0x2f, 0x08, 0x45, 0x5c, 0xde, 0x5e, 0x7b, 0xfd, 0x15, 0x6e, 0xb3, 0x2d, + 0x7d, 0xc1, 0xa5, 0x6d, 0xb6, 0x45, 0xe8, 0xdd, 0x8f, 0xc5, 0x43, 0x7d, 0xb3, 0xed, 0xec, 0x8b, + 0xd5, 0x2d, 0xb7, 0x4f, 0xb9, 0xe5, 0xb6, 0xca, 0xa5, 0xc1, 0xc0, 0xa6, 0x36, 0x42, 0xbf, 0xee, + 0x90, 0x1e, 0x45, 0x63, 0xe1, 0x55, 0x9e, 0x56, 0xc6, 0x35, 0x3d, 0x12, 0x20, 0xb9, 0x7d, 0x4e, + 0x13, 0xe7, 0xba, 0xf3, 0xdf, 0xbd, 0x65, 0xf5, 0x8c, 0x12, 0xf9, 0x5d, 0xf1, 0x9c, 0x5e, 0xa7, + 0x62, 0x2c, 0x26, 0x22, 0x8d, 0x5f, 0xba, 0x5e, 0x1a, 0x4d, 0x02, 0x5f, 0x8e, 0x73, 0x86, 0xde, + 0x38, 0x91, 0x61, 0x9d, 0x3a, 0xbe, 0xf9, 0x4a, 0x0d, 0x8c, 0x65, 0x68, 0x55, 0x00, 0x90, 0x37, + 0xf9, 0x57, 0x25, 0x80, 0x72, 0x12, 0x3d, 0x88, 0x71, 0x39, 0x48, 0x2e, 0x3f, 0x36, 0x02, 0x90, + 0x36, 0xe2, 0x23, 0x19, 0x3c, 0x7a, 0xf5, 0xc0, 0xe8, 0xd9, 0x31, 0x85, 0xe0, 0x10, 0x11, 0xd1, + 0xd8, 0x0c, 0x82, 0x24, 0x08, 0x47, 0x63, 0xd1, 0xfd, 0x2e, 0x5e, 0xe4, 0x87, 0x11, 0x6c, 0xac, + 0x39, 0x88, 0xa9, 0x04, 0xc7, 0x38, 0x94, 0xc0, 0x9a, 0x99, 0x04, 0x7e, 0x76, 0x77, 0x8a, 0x83, + 0x09, 0x56, 0xeb, 0x8e, 0x62, 0x3a, 0x41, 0x1b, 0x87, 0x13, 0x1c, 0xcc, 0x6c, 0x02, 0x19, 0x68, + 0x2b, 0xbd, 0xdb, 0x7a, 0x8c, 0x53, 0xd4, 0xf7, 0xc9, 0x48, 0x16, 0x43, 0xba, 0x38, 0x12, 0xc6, + 0x92, 0x32, 0x19, 0x49, 0x93, 0x91, 0x36, 0x9a, 0xc4, 0xcd, 0xf8, 0x2f, 0xc1, 0xf9, 0xc7, 0xf8, + 0x7c, 0x61, 0x60, 0x7e, 0xaf, 0x69, 0x0f, 0xed, 0xcb, 0x28, 0x4a, 0xbb, 0x91, 0xdf, 0xf5, 0xa3, + 0xc9, 0x53, 0x2c, 0x92, 0x44, 0x3c, 0x74, 0xc7, 0xc2, 0x5b, 0x0c, 0x67, 0x98, 0xe9, 0xf2, 0xa3, + 0x2a, 0x60, 0xff, 0x0f, 0x6f, 0x3c, 0x45, 0x8c, 0x4a, 0x59, 0x2e, 0x67, 0x38, 0x62, 0x38, 0x3a, + 0x12, 0x38, 0x0a, 0xc2, 0xf4, 0xf5, 0x19, 0x02, 0x8d, 0xce, 0x00, 0x4b, 0x3f, 0x79, 0xe1, 0x48, + 0x14, 0x3a, 0x62, 0x64, 0xfe, 0x43, 0x04, 0xf1, 0xee, 0x02, 0x7c, 0x20, 0xd7, 0xf9, 0xf7, 0x0a, + 0x41, 0xae, 0xfa, 0xfd, 0x57, 0xaf, 0x2e, 0xfa, 0xa7, 0xaf, 0x5e, 0x5f, 0x9e, 0x9f, 0x5d, 0x5c, + 0x9c, 0x5f, 0x9e, 0x5e, 0x22, 0xc3, 0xcd, 0x6f, 0x63, 0xcf, 0x9f, 0x03, 0xef, 0xef, 0xc1, 0x28, + 0x58, 0x78, 0xaa, 0xb0, 0xd3, 0x28, 0xde, 0x8b, 0x91, 0x97, 0x06, 0x3f, 0xc4, 0x8a, 0x05, 0xe0, + 0x21, 0x5b, 0x44, 0x40, 0xf3, 0xce, 0x7b, 0xd6, 0x79, 0xe6, 0x17, 0x16, 0x9f, 0xf9, 0xc2, 0xef, + 0x67, 0x3a, 0x4e, 0xae, 0xbc, 0xea, 0x2b, 0xab, 0x13, 0x3a, 0x8d, 0x25, 0xfa, 0xb0, 0xec, 0xcf, + 0x20, 0x7d, 0x1c, 0x07, 0x49, 0xfa, 0xc3, 0x1b, 0xbb, 0x0b, 0x57, 0xaa, 0xeb, 0xb9, 0x6b, 0x7f, + 0x90, 0xbb, 0xb2, 0xea, 0xa9, 0x82, 0xad, 0x12, 0x8e, 0x9b, 0x20, 0x0c, 0x45, 0xdc, 0xf5, 0xd4, + 0x1d, 0x10, 0xd9, 0x42, 0xf6, 0x40, 0xb0, 0x07, 0x42, 0xaf, 0x07, 0x42, 0xc1, 0xc7, 0x8a, 0xf7, + 0xb9, 0x22, 0x09, 0x97, 0x0d, 0x00, 0x36, 0x00, 0x64, 0x77, 0x07, 0x9e, 0x96, 0xa8, 0xe8, 0x33, + 0x2e, 0x25, 0x13, 0x25, 0x1f, 0x32, 0x11, 0x63, 0xa0, 0x19, 0x84, 0x82, 0x51, 0x68, 0x18, 0x86, + 0x8a, 0x71, 0xc8, 0x19, 0x88, 0x9c, 0x91, 0xc8, 0x18, 0x0a, 0xa9, 0x1f, 0x37, 0x35, 0x35, 0x11, + 0x22, 0x7a, 0x4a, 0x69, 0x4d, 0x5d, 0x06, 0x11, 0x39, 0xa5, 0xc8, 0x59, 0x90, 0x92, 0x15, 0x69, + 0x59, 0x92, 0x9a, 0x35, 0xb5, 0xb1, 0xa8, 0x36, 0x56, 0x25, 0x67, 0x59, 0x1c, 0xeb, 0x12, 0x78, + 0x23, 0x3a, 0xa4, 0x3d, 0x44, 0xe8, 0x7b, 0x80, 0x10, 0xf5, 0xf0, 0xb0, 0xad, 0xee, 0x81, 0xcc, + 0x88, 0xa7, 0x23, 0x24, 0x8c, 0x4b, 0x0b, 0x16, 0x43, 0x28, 0xa5, 0x1e, 0x48, 0x4c, 0x81, 0xe1, + 0x9c, 0xe1, 0x9c, 0xe1, 0x5c, 0x13, 0x9c, 0x43, 0x63, 0x22, 0x65, 0x4c, 0x79, 0x46, 0xf0, 0x28, + 0x5c, 0xcc, 0x64, 0xf7, 0x3f, 0xc2, 0x12, 0x46, 0x8a, 0x98, 0xca, 0xde, 0x43, 0xb5, 0xc5, 0x58, + 0xf6, 0x7e, 0x89, 0xda, 0xff, 0xbf, 0x4f, 0x54, 0x44, 0x31, 0x18, 0x62, 0xb6, 0xd9, 0xbe, 0x43, + 0xef, 0xd9, 0xe4, 0x1d, 0x5e, 0x1c, 0xf0, 0x1d, 0xe2, 0x62, 0x3a, 0xb4, 0xc8, 0x49, 0xf7, 0x94, + 0xaf, 0xac, 0x6e, 0x6a, 0x56, 0x37, 0x8f, 0xac, 0xe8, 0xb5, 0x26, 0x06, 0xb5, 0x0a, 0xec, 0x40, + 0xc3, 0x52, 0xf8, 0xd3, 0x03, 0x9c, 0x1c, 0xca, 0x43, 0x43, 0xe0, 0x99, 0x41, 0xaa, 0xf0, 0xec, + 0x0c, 0xd5, 0xaf, 0x9a, 0xb3, 0x33, 0x94, 0x48, 0xe5, 0x5e, 0xcf, 0xac, 0x13, 0xde, 0x30, 0x16, + 0xa8, 0x8a, 0xf9, 0xcc, 0x65, 0x82, 0xd0, 0x2a, 0x9c, 0x8f, 0x2b, 0x88, 0xfb, 0xf5, 0xd7, 0x15, + 0x4e, 0xb9, 0x73, 0x3e, 0xb6, 0x18, 0xab, 0x70, 0x43, 0x44, 0x48, 0x86, 0x80, 0x90, 0x05, 0x6f, + 0xfa, 0x8c, 0x57, 0x8c, 0x57, 0x5a, 0xf1, 0x8a, 0x83, 0x37, 0xec, 0xed, 0x63, 0x6f, 0x1f, 0x7b, + 0xfb, 0x4a, 0x64, 0xa0, 0x65, 0xc1, 0x1b, 0x8e, 0x69, 0x30, 0xca, 0x31, 0xca, 0x31, 0xca, 0x71, + 0x4c, 0x43, 0xe9, 0x3f, 0x8e, 0x69, 0x64, 0xbf, 0xc4, 0x31, 0x0d, 0x8e, 0x69, 0xa8, 0xdc, 0x21, + 0xc7, 0x34, 0x48, 0xb5, 0xb0, 0xd6, 0xbb, 0xfa, 0x11, 0x73, 0x5d, 0x6c, 0xeb, 0x57, 0xf9, 0x6e, + 0x61, 0xf8, 0x43, 0x7a, 0x10, 0xfc, 0x15, 0x24, 0xe9, 0x9b, 0x34, 0x05, 0xa6, 0x67, 0xdf, 0x05, + 0xe1, 0xed, 0x58, 0xcc, 0x15, 0x1a, 0x20, 0xef, 0xcf, 0xf1, 0x6f, 0xe3, 0x09, 0xbd, 0xcb, 0xb3, + 0xb3, 0xd7, 0x17, 0x67, 0x67, 0xa7, 0x17, 0xaf, 0x2e, 0x4e, 0xaf, 0xce, 0xcf, 0x7b, 0xaf, 0x7b, + 0xe7, 0x80, 0x87, 0x7e, 0x88, 0x1f, 0x44, 0x2c, 0x1e, 0x7e, 0x9b, 0x1f, 0x4a, 0x38, 0x1d, 0x8f, + 0x31, 0x8f, 0xf8, 0x57, 0xb2, 0x68, 0xa4, 0xa7, 0x0e, 0x3e, 0xf6, 0xf4, 0x1c, 0x55, 0x66, 0x0d, + 0x7c, 0x53, 0xd2, 0xbb, 0xf9, 0xcf, 0x0c, 0x3e, 0x2f, 0x9e, 0xf8, 0x4e, 0xbc, 0xac, 0xff, 0xef, + 0x30, 0x9a, 0x94, 0x96, 0xb6, 0x60, 0xa3, 0xd1, 0xea, 0xe0, 0x2d, 0xdb, 0x24, 0x2d, 0x96, 0x8a, + 0x56, 0x6e, 0x52, 0xa6, 0x09, 0x75, 0xc1, 0xd4, 0x57, 0x5b, 0xab, 0x10, 0xb3, 0xd2, 0x3e, 0x83, + 0x65, 0x88, 0x2a, 0x4e, 0x5a, 0x80, 0x33, 0x56, 0xd1, 0x1d, 0xc1, 0xe5, 0x87, 0x1a, 0xcc, 0x7f, + 0x4b, 0xca, 0x0f, 0x95, 0xcd, 0x73, 0x44, 0xbc, 0x13, 0x12, 0xdf, 0xc4, 0xc4, 0x33, 0x69, 0x78, + 0x31, 0x5a, 0x4a, 0xf9, 0xee, 0x1c, 0x21, 0x12, 0x75, 0xae, 0xdc, 0x5e, 0xce, 0xe5, 0xc1, 0xcc, + 0x9f, 0x4a, 0xfc, 0xa9, 0x5c, 0x1e, 0xbc, 0x49, 0x6f, 0xf0, 0x02, 0xe1, 0xad, 0xa7, 0x70, 0x89, + 0x30, 0x2d, 0x71, 0x93, 0x11, 0x39, 0x19, 0xb1, 0xa3, 0x89, 0xde, 0x8c, 0x09, 0xcb, 0x25, 0xc2, + 0x9c, 0x15, 0xa7, 0x85, 0x81, 0xc8, 0x19, 0x89, 0x8c, 0xa1, 0x9a, 0x71, 0xc5, 0x71, 0x96, 0x89, + 0x1e, 0x16, 0xa4, 0x64, 0x45, 0x5a, 0x96, 0xa4, 0x66, 0x4d, 0x6d, 0x2c, 0xaa, 0x8d, 0x55, 0xc9, + 0x59, 0x16, 0xc7, 0xba, 0x48, 0x16, 0x86, 0x1b, 0x78, 0xb5, 0x74, 0xc6, 0x25, 0xc2, 0xd5, 0xcf, + 0xe3, 0x12, 0xe1, 0x2a, 0xea, 0xe1, 0x74, 0x1a, 0x86, 0x73, 0x86, 0x73, 0x8b, 0xe0, 0x9c, 0xd3, + 0x69, 0x14, 0x36, 0xc6, 0xe9, 0x34, 0x35, 0x44, 0xc5, 0xe9, 0x34, 0x9c, 0x4e, 0xa3, 0x07, 0x39, + 0xe9, 0x9e, 0xc2, 0x25, 0xc2, 0xba, 0xd5, 0xcd, 0x76, 0xe5, 0x0d, 0x6d, 0x85, 0x78, 0xb6, 0xfe, + 0xc5, 0xa5, 0xc2, 0x9a, 0x55, 0x79, 0x76, 0x8a, 0xea, 0x57, 0xd1, 0xd9, 0x29, 0x4a, 0xa4, 0x7a, + 0x73, 0xa9, 0x30, 0x12, 0xab, 0xb8, 0x54, 0x98, 0xf1, 0x8a, 0xf1, 0x4a, 0x76, 0xd7, 0x1c, 0xc4, + 0x61, 0xaf, 0x1f, 0x7b, 0xfd, 0xd8, 0xeb, 0x57, 0x22, 0x03, 0xb9, 0x54, 0x98, 0x63, 0x1b, 0x8c, + 0x72, 0x8c, 0x72, 0xc7, 0x8c, 0x72, 0x1c, 0xdb, 0x50, 0xd8, 0x18, 0xc7, 0x36, 0x6a, 0x88, 0x8a, + 0x63, 0x1b, 0x1c, 0xdb, 0xd0, 0x83, 0x9c, 0x74, 0x4f, 0xe1, 0x52, 0x61, 0x25, 0x87, 0x92, 0x06, + 0x97, 0x3f, 0x97, 0x0c, 0xb7, 0xa1, 0x64, 0x18, 0xe9, 0x82, 0x9c, 0x26, 0x22, 0x86, 0x7a, 0x20, + 0x09, 0xd4, 0xde, 0xad, 0xe2, 0xd2, 0x15, 0xf1, 0xde, 0x63, 0xfc, 0x33, 0xa4, 0x2a, 0xee, 0x96, + 0x5a, 0xbb, 0x38, 0x29, 0x8b, 0x7d, 0xd2, 0xbb, 0x45, 0xe0, 0xca, 0xaa, 0x81, 0x2a, 0x53, 0x8a, + 0xe7, 0x34, 0xf6, 0xba, 0xd3, 0x30, 0x49, 0xbd, 0xfb, 0x31, 0x70, 0x64, 0xf2, 0xc6, 0x9d, 0x37, + 0x30, 0xbb, 0x98, 0x80, 0x09, 0x3a, 0x9a, 0x1c, 0xd0, 0x24, 0xcc, 0xd0, 0xd1, 0xee, 0x84, 0x86, + 0x33, 0x45, 0x87, 0xc7, 0xf1, 0xea, 0x93, 0xfd, 0xf4, 0x3d, 0x11, 0x56, 0xe8, 0x32, 0x17, 0xa7, + 0x0e, 0xcf, 0x08, 0xae, 0xbd, 0x0d, 0x93, 0x75, 0xc1, 0x6a, 0xc1, 0x48, 0x50, 0xf0, 0x11, 0x5c, + 0x07, 0xdc, 0xe7, 0x3a, 0x60, 0x2a, 0x1c, 0x3e, 0xd4, 0x3a, 0x60, 0x3f, 0x9a, 0x86, 0xa9, 0x88, + 0xe1, 0x25, 0xc0, 0xd9, 0x03, 0x60, 0xd5, 0xbf, 0xa7, 0x5c, 0xfd, 0xab, 0x9b, 0xb4, 0xc9, 0x55, + 0x0d, 0xcb, 0xab, 0x7f, 0xc1, 0xee, 0xe1, 0xb5, 0x3b, 0x58, 0x08, 0x31, 0x1c, 0x47, 0x5e, 0xfa, + 0xaa, 0x0f, 0xb9, 0xf0, 0x15, 0x69, 0x5f, 0x01, 0x96, 0xfe, 0x25, 0xc2, 0xd1, 0x42, 0xb4, 0x19, + 0x57, 0xb6, 0x29, 0xbc, 0xba, 0xb9, 0x07, 0x10, 0xe9, 0xff, 0x26, 0xf7, 0xef, 0xd1, 0xf9, 0xf3, + 0x30, 0x51, 0x44, 0x0a, 0xa7, 0x6b, 0x1b, 0x8e, 0xd8, 0x4e, 0xb3, 0xe3, 0x44, 0x03, 0x89, 0x64, + 0xc2, 0x33, 0x41, 0x8b, 0xdf, 0x84, 0xe5, 0x2f, 0xcb, 0x5f, 0x96, 0xbf, 0x2c, 0x7f, 0x59, 0xfe, + 0xb2, 0xfc, 0x3d, 0x4a, 0xf9, 0xcb, 0x91, 0x25, 0x5b, 0x9a, 0xd1, 0x6a, 0xd1, 0x84, 0x20, 0x49, + 0xc4, 0x88, 0xa4, 0x61, 0xd6, 0x7f, 0x58, 0xff, 0xb1, 0x56, 0xff, 0x01, 0x27, 0xdd, 0x02, 0x93, + 0x6c, 0xf5, 0x70, 0x34, 0x2c, 0x69, 0x16, 0x95, 0x24, 0xcb, 0x5c, 0xcd, 0x5c, 0x6d, 0xaf, 0x55, + 0x03, 0x4c, 0x32, 0x45, 0x24, 0x95, 0x22, 0x93, 0x48, 0x6d, 0x31, 0x67, 0xc8, 0x93, 0x42, 0xb5, + 0x6a, 0xdf, 0xa8, 0xa4, 0x4f, 0x6b, 0xec, 0x1b, 0xf2, 0x24, 0x4e, 0xb6, 0x78, 0xf4, 0x79, 0x1c, + 0x0f, 0x3b, 0x34, 0xaf, 0x90, 0x09, 0x29, 0x11, 0x92, 0x3f, 0x41, 0x9c, 0x81, 0x7c, 0x26, 0xa3, + 0x9a, 0x7d, 0xa9, 0x6e, 0x4f, 0x92, 0xd8, 0x8f, 0x00, 0x7b, 0x11, 0x60, 0x1f, 0xd6, 0x9d, 0xa9, + 0x22, 0x3d, 0x81, 0xe9, 0xc8, 0x91, 0x4a, 0xc6, 0xa8, 0xc8, 0xa2, 0xa9, 0x26, 0xc1, 0x72, 0xc2, + 0x2a, 0xfe, 0xa4, 0xe4, 0x58, 0x64, 0x8f, 0x43, 0xed, 0x18, 0x8a, 0xb7, 0xbe, 0xbf, 0xb1, 0x82, + 0x4d, 0x39, 0xf7, 0xa5, 0xfb, 0xc8, 0x55, 0x97, 0xfb, 0x92, 0xb3, 0xad, 0x49, 0x3c, 0xa9, 0xd5, + 0xab, 0x65, 0xf4, 0x67, 0x39, 0x3d, 0x59, 0x56, 0x1f, 0x56, 0xd6, 0x7b, 0x95, 0xf5, 0x5b, 0x69, + 0x3d, 0x56, 0x8d, 0x6c, 0xea, 0x12, 0x3b, 0x9c, 0xc9, 0x74, 0x9c, 0x06, 0x5d, 0x19, 0x37, 0x4a, + 0x7e, 0xa2, 0xeb, 0x25, 0x75, 0xb0, 0x28, 0x95, 0x5f, 0x24, 0x6d, 0x46, 0xa9, 0x98, 0x4d, 0x6a, + 0x66, 0x92, 0xaa, 0x59, 0x04, 0x36, 0x83, 0xc0, 0x66, 0x8f, 0xb2, 0x99, 0x83, 0x13, 0x68, 0xb2, + 0xf9, 0x40, 0xaa, 0xad, 0xcf, 0x61, 0xad, 0xce, 0x79, 0x60, 0x05, 0x27, 0xaa, 0x29, 0x12, 0xe6, + 0xa6, 0x83, 0xb8, 0x87, 0xf2, 0x10, 0xf7, 0xd8, 0x99, 0xc4, 0xce, 0xa4, 0x63, 0x71, 0x26, 0x4d, + 0x83, 0x10, 0x17, 0x1d, 0xbf, 0x68, 0xad, 0x37, 0xe9, 0x94, 0x83, 0xe3, 0xba, 0x9d, 0x47, 0x67, + 0xfd, 0xab, 0xb3, 0xab, 0xd7, 0x17, 0xfd, 0xab, 0x73, 0xf6, 0x19, 0x99, 0xf5, 0x19, 0x19, 0x2e, + 0x8e, 0x21, 0x6b, 0x2a, 0xaa, 0x2d, 0xa8, 0xdc, 0x47, 0xe9, 0x0c, 0x7d, 0xd6, 0x19, 0x58, 0x67, + 0x38, 0x26, 0x9d, 0x01, 0x15, 0x81, 0xba, 0x64, 0x9d, 0x81, 0x75, 0x06, 0x5d, 0x3a, 0x03, 0x4d, + 0x8a, 0x14, 0x6b, 0x0f, 0xac, 0x3d, 0x98, 0x73, 0x62, 0x98, 0x08, 0x95, 0xdd, 0xbb, 0xb9, 0x9b, + 0x56, 0xa9, 0x4d, 0x38, 0xd9, 0x84, 0xe9, 0x1e, 0x68, 0xc4, 0x74, 0x8f, 0x67, 0x4c, 0xb3, 0x4b, + 0x50, 0x8d, 0x9b, 0x0e, 0x73, 0xc6, 0x74, 0xcf, 0x30, 0x3b, 0xf6, 0x41, 0xec, 0xd8, 0x67, 0x76, + 0x64, 0x76, 0x6c, 0x03, 0x3b, 0xf6, 0xb9, 0xb7, 0x03, 0xf7, 0x76, 0x38, 0x4e, 0x86, 0xe4, 0x90, + 0x19, 0xbb, 0xbf, 0xd8, 0xfd, 0x85, 0x72, 0x7f, 0x71, 0xc8, 0x8c, 0xdd, 0x5f, 0x76, 0xba, 0xbf, + 0x38, 0x64, 0xd6, 0x94, 0xd3, 0x8b, 0x23, 0x4f, 0x2c, 0x7a, 0x59, 0xf4, 0x6a, 0x17, 0xbd, 0x1c, + 0x79, 0x62, 0xd1, 0x6b, 0xa7, 0xe8, 0xe5, 0xc8, 0xd3, 0x21, 0x09, 0xe1, 0x83, 0x0e, 0xe0, 0x58, + 0x59, 0xea, 0xd4, 0xfb, 0x3b, 0xfc, 0x3b, 0xec, 0x48, 0xe8, 0x1c, 0x5c, 0xf4, 0x24, 0x7d, 0xba, + 0x3a, 0x8b, 0x9e, 0x36, 0x08, 0x0a, 0x5a, 0xf3, 0x74, 0x37, 0x7f, 0xc0, 0x41, 0x97, 0x3c, 0xdd, + 0x63, 0x4a, 0x9e, 0xfc, 0xfa, 0x92, 0x27, 0x1f, 0x5b, 0xf2, 0xd4, 0xe7, 0x92, 0x27, 0x24, 0xd9, + 0xd4, 0x96, 0x3c, 0x85, 0x91, 0x5a, 0xbd, 0xd3, 0xea, 0xfb, 0x5c, 0xec, 0xd4, 0xf6, 0x62, 0xa7, + 0x61, 0x14, 0xa9, 0x47, 0x6d, 0xe6, 0x8b, 0xb8, 0xcc, 0xc9, 0x90, 0x8d, 0xdd, 0xda, 0x98, 0x0d, + 0x6c, 0x76, 0x35, 0x6a, 0x66, 0x35, 0x70, 0x56, 0x35, 0x78, 0x46, 0x35, 0xbb, 0x8e, 0x5a, 0xe3, + 0x3a, 0x82, 0xce, 0x96, 0x46, 0xcd, 0x94, 0x26, 0x98, 0x25, 0x8d, 0x9c, 0xae, 0x8a, 0x9e, 0xaa, + 0xca, 0xe3, 0xdb, 0xcd, 0xb1, 0x10, 0x19, 0x2b, 0x21, 0x5d, 0x2c, 0x40, 0x4a, 0x41, 0x4f, 0x43, + 0xa5, 0x9b, 0xf5, 0x8c, 0x9c, 0xf1, 0x6c, 0x66, 0x10, 0x17, 0x6e, 0x96, 0x33, 0xc9, 0x0c, 0x67, + 0x46, 0x17, 0x46, 0x97, 0xd6, 0xa1, 0x0b, 0x76, 0xc6, 0x32, 0xc1, 0x6c, 0x65, 0xa2, 0x99, 0xca, + 0x04, 0x83, 0xa7, 0x29, 0x67, 0x28, 0xeb, 0x9f, 0x9d, 0xac, 0x6d, 0xde, 0x2e, 0xf9, 0xac, 0x64, + 0x82, 0x19, 0xc9, 0xa4, 0xb3, 0x91, 0xf5, 0xcf, 0x44, 0x36, 0x72, 0x37, 0x34, 0x33, 0x90, 0x67, + 0x0d, 0xcd, 0x1c, 0xfe, 0x7a, 0x14, 0x43, 0x76, 0x4d, 0xce, 0x31, 0xf4, 0xdd, 0xa5, 0xab, 0xd4, + 0x1d, 0x46, 0x11, 0x64, 0x50, 0xf1, 0x31, 0x87, 0xf3, 0x36, 0xcf, 0x46, 0xc5, 0x93, 0x56, 0x14, + 0x86, 0x79, 0x1f, 0xbd, 0x13, 0x2f, 0x83, 0xb7, 0x51, 0x64, 0x47, 0x48, 0x90, 0xc3, 0x7b, 0xb2, + 0x27, 0xa5, 0x33, 0xbc, 0x97, 0x11, 0x18, 0x34, 0xb6, 0xb7, 0x20, 0xaa, 0xc3, 0x0d, 0xec, 0xf9, + 0xd2, 0x81, 0xbd, 0x93, 0x8a, 0x2d, 0xd6, 0x6d, 0x4d, 0x65, 0x4b, 0x05, 0x17, 0x51, 0x74, 0xf0, + 0xdb, 0xfb, 0x5e, 0xef, 0x6e, 0x63, 0x67, 0xce, 0x93, 0x17, 0x2f, 0x4d, 0x80, 0xed, 0x1d, 0xe5, + 0x4a, 0xf2, 0xea, 0xf3, 0x9d, 0x77, 0x29, 0xf6, 0xcf, 0x96, 0x9a, 0x81, 0x55, 0xe6, 0xdd, 0x86, + 0xd9, 0x56, 0x34, 0x32, 0xaa, 0xce, 0x1e, 0x93, 0xb6, 0xb3, 0xa4, 0xed, 0xa7, 0x1d, 0xbb, 0xa8, + 0x60, 0x34, 0x6b, 0xf5, 0x3d, 0x97, 0x79, 0x18, 0x1d, 0xff, 0x31, 0x18, 0x3f, 0x48, 0xc4, 0x79, + 0x17, 0x5f, 0xb3, 0xa2, 0xbd, 0x65, 0x72, 0x88, 0xc1, 0xde, 0xc4, 0x58, 0xb4, 0x57, 0xb2, 0x43, + 0xa1, 0x5a, 0x67, 0x42, 0x4b, 0xa2, 0xbd, 0xc9, 0x31, 0x86, 0x7b, 0x13, 0x7b, 0xe2, 0xbd, 0x4b, + 0x33, 0x46, 0x35, 0xe0, 0x3b, 0x5f, 0x75, 0x14, 0x65, 0xb3, 0x49, 0x1b, 0x43, 0xbe, 0xc9, 0xe1, + 0x15, 0xce, 0xc2, 0x06, 0xdf, 0x01, 0x06, 0xde, 0x41, 0x07, 0xdd, 0xc1, 0x46, 0x69, 0xc1, 0xbd, + 0xed, 0xc8, 0x69, 0x6b, 0x64, 0xce, 0x11, 0xbc, 0x33, 0x64, 0x06, 0x9b, 0x21, 0xc6, 0x47, 0xa7, + 0xec, 0x57, 0x39, 0xa1, 0xf5, 0x0b, 0xe9, 0xf6, 0x3d, 0xa0, 0x9b, 0xe0, 0xd0, 0x94, 0xb2, 0x0f, + 0xa3, 0x69, 0x0c, 0xc9, 0x89, 0x9a, 0xc6, 0x2c, 0x22, 0x59, 0x44, 0x9a, 0x13, 0x91, 0xf7, 0x41, + 0xe8, 0xc5, 0x2f, 0x10, 0xe9, 0xc8, 0xdc, 0xbe, 0xde, 0x46, 0x14, 0x02, 0xf4, 0xe1, 0xf9, 0x22, + 0xe6, 0x75, 0xe6, 0x75, 0x63, 0xbc, 0xae, 0x9c, 0x90, 0xa2, 0x98, 0x80, 0xd2, 0x12, 0x66, 0x4f, + 0x14, 0x38, 0x65, 0x7d, 0xf6, 0xf2, 0xee, 0x02, 0x66, 0x76, 0x66, 0x76, 0xb6, 0x7d, 0xd9, 0xf6, + 0x65, 0xdb, 0xb7, 0xad, 0xb6, 0x2f, 0x68, 0xd8, 0x3a, 0x7c, 0xc8, 0x3a, 0xe9, 0x70, 0x75, 0xc4, + 0x50, 0x75, 0xc4, 0x30, 0xf5, 0x96, 0xa8, 0x1e, 0xe9, 0x63, 0x2c, 0x00, 0x96, 0xc6, 0x72, 0x19, + 0xab, 0x1f, 0xac, 0x7e, 0x18, 0x53, 0x3f, 0x44, 0x38, 0x9d, 0x88, 0x78, 0xc9, 0x69, 0x00, 0x83, + 0x43, 0x41, 0xd2, 0x38, 0xb7, 0xe1, 0x74, 0xa2, 0x7e, 0xc7, 0x5f, 0xa2, 0xcf, 0x4b, 0x73, 0x08, + 0x94, 0xfd, 0x75, 0x3a, 0x7f, 0xc7, 0x0f, 0xef, 0x6f, 0x21, 0x45, 0x53, 0xbd, 0xf9, 0xda, 0x2f, + 0xff, 0xf9, 0xe0, 0xe8, 0xed, 0x32, 0x13, 0xfd, 0x59, 0x90, 0x19, 0x21, 0x07, 0xc3, 0xef, 0x6f, + 0x61, 0x32, 0x7a, 0xf1, 0x56, 0xd7, 0x9d, 0xde, 0x51, 0x27, 0xb7, 0x99, 0x10, 0x05, 0x96, 0x24, + 0x53, 0x25, 0xc1, 0xe4, 0x69, 0x2c, 0xdc, 0x65, 0x16, 0x8d, 0xbb, 0x48, 0xed, 0x90, 0xea, 0x99, + 0x5e, 0x91, 0x0f, 0x55, 0x91, 0x92, 0x21, 0x57, 0xaa, 0xa9, 0x54, 0x9a, 0xa9, 0x9c, 0x8e, 0xd0, + 0xe7, 0x74, 0x04, 0x42, 0xa1, 0xc4, 0xe9, 0x08, 0xac, 0x13, 0xb1, 0x4e, 0xc4, 0x2e, 0x19, 0x76, + 0xc9, 0xb0, 0x4b, 0xc6, 0x56, 0x97, 0x0c, 0x47, 0xfb, 0x59, 0x02, 0xb5, 0x46, 0x02, 0xe9, 0x8e, + 0xf6, 0x73, 0x30, 0x9d, 0x59, 0xa9, 0x25, 0xac, 0xa4, 0x3d, 0x98, 0xce, 0xb1, 0x6a, 0xe6, 0x25, + 0x36, 0x8c, 0xd8, 0x30, 0x62, 0xc3, 0x88, 0x0d, 0xa3, 0x26, 0x0c, 0x23, 0x8e, 0x55, 0xcb, 0x2d, + 0x55, 0x8f, 0x55, 0x73, 0x28, 0x98, 0xa5, 0x7b, 0x8b, 0xa4, 0x3b, 0x87, 0x82, 0x4b, 0xd7, 0x72, + 0x28, 0x18, 0x28, 0xc3, 0x8c, 0x26, 0xdd, 0xfc, 0x04, 0x74, 0x37, 0x9e, 0x2f, 0x62, 0x94, 0x65, + 0x94, 0x6d, 0x93, 0x3f, 0xc2, 0xe2, 0xac, 0x05, 0x89, 0xa6, 0x4b, 0xf6, 0x34, 0x71, 0x29, 0x78, + 0x01, 0xa7, 0x32, 0x6f, 0x62, 0xb3, 0x77, 0xca, 0xc7, 0xc5, 0xaa, 0xc1, 0xcd, 0x62, 0x55, 0xc3, + 0xad, 0x5f, 0xb6, 0x5e, 0xa4, 0xbe, 0xed, 0xcb, 0x72, 0xeb, 0x32, 0x7d, 0x5f, 0x62, 0x31, 0x89, + 0x52, 0xd1, 0xf5, 0xa3, 0x30, 0xf5, 0x82, 0x50, 0xc4, 0xe5, 0x1d, 0x60, 0xf6, 0xbe, 0x69, 0xa4, + 0x17, 0x4c, 0x6c, 0x63, 0x2f, 0x98, 0x98, 0xae, 0x17, 0x4c, 0x75, 0xeb, 0x10, 0xb9, 0x96, 0x21, + 0x86, 0xbb, 0xc1, 0xc4, 0x87, 0xd8, 0x0d, 0x26, 0x36, 0xd6, 0x0d, 0xc6, 0xcb, 0x93, 0xd8, 0xe4, + 0xb2, 0xaf, 0x56, 0xdf, 0x97, 0x4b, 0xbf, 0x3a, 0x6d, 0xb6, 0x1b, 0x4c, 0x7c, 0x8c, 0xe9, 0x57, + 0xb1, 0xee, 0xf4, 0x2b, 0x69, 0x55, 0x44, 0x5d, 0x05, 0x91, 0x54, 0x3d, 0xa8, 0x55, 0x06, 0x70, + 0xe6, 0xa6, 0x75, 0xaa, 0xc1, 0xae, 0x54, 0xab, 0xcc, 0xca, 0x94, 0x9b, 0xe1, 0x54, 0x9d, 0x7d, + 0x29, 0x95, 0x75, 0x69, 0x78, 0x96, 0x13, 0x23, 0x3a, 0x23, 0x3a, 0x23, 0xfa, 0x61, 0x21, 0xba, + 0xf5, 0x40, 0x5a, 0x61, 0x28, 0x1a, 0xb7, 0x9b, 0x6a, 0x6c, 0x97, 0x02, 0x0b, 0xea, 0xd3, 0x62, + 0xc5, 0x4d, 0xbe, 0xa0, 0xcc, 0x94, 0x3a, 0xd9, 0xd8, 0x6f, 0xd9, 0x3e, 0x9d, 0x20, 0xb9, 0xc9, + 0x05, 0xe5, 0xe7, 0xc5, 0x5e, 0xf7, 0xa8, 0xdb, 0x09, 0x92, 0xb7, 0xde, 0x77, 0xf1, 0x29, 0x8a, + 0xf6, 0x29, 0x7f, 0xf7, 0xfd, 0x9c, 0xcd, 0x8f, 0xb6, 0x77, 0x3d, 0x5f, 0xbe, 0xdc, 0xd2, 0xc9, + 0xec, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x31, 0xd4, 0xfc, 0xe6, + 0xc6, 0xb6, 0x01, 0x00, + } +) diff --git a/internal/exampleocconfig/structs-0.go b/internal/exampleocconfig/structs-0.go new file mode 100644 index 0000000..e958717 --- /dev/null +++ b/internal/exampleocconfig/structs-0.go @@ -0,0 +1,2719 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* +Package exampleocconfig is a generated package which contains definitions +of structs which represent a YANG schema. The generated schema can be +compressed by a series of transformations (compression was true +in this case). + +This package was generated by ygnmi version: (devel): (ygot: v0.29.12) +using the following YANG input files: + - ../../pathgen/testdata/yang/openconfig-simple.yang + - ../../pathgen/testdata/yang/openconfig-withlistval.yang + - ../../pathgen/testdata/yang/openconfig-nested.yang + +Imported modules were sourced from: +*/ +package exampleocconfig + +import ( + "encoding/json" + "fmt" + "reflect" + + "github.com/openconfig/goyang/pkg/yang" + "github.com/openconfig/ygot/ygot" + "github.com/openconfig/ygot/ytypes" +) + +// Binary is a type that is used for fields that have a YANG type of +// binary. It is used such that binary fields can be distinguished from +// leaf-lists of uint8s (which are mapped to []uint8, equivalent to +// []byte in reflection). +type Binary []byte + +// YANGEmpty is a type that is used for fields that have a YANG type of +// empty. It is used such that empty fields can be distinguished from boolean fields +// in the generated code. +type YANGEmpty bool + +// UnionInt8 is an int8 type assignable to unions of which it is a subtype. +type UnionInt8 int8 + +// UnionInt16 is an int16 type assignable to unions of which it is a subtype. +type UnionInt16 int16 + +// UnionInt32 is an int32 type assignable to unions of which it is a subtype. +type UnionInt32 int32 + +// UnionInt64 is an int64 type assignable to unions of which it is a subtype. +type UnionInt64 int64 + +// UnionUint8 is a uint8 type assignable to unions of which it is a subtype. +type UnionUint8 uint8 + +// UnionUint16 is a uint16 type assignable to unions of which it is a subtype. +type UnionUint16 uint16 + +// UnionUint32 is a uint32 type assignable to unions of which it is a subtype. +type UnionUint32 uint32 + +// UnionUint64 is a uint64 type assignable to unions of which it is a subtype. +type UnionUint64 uint64 + +// UnionFloat64 is a float64 type assignable to unions of which it is a subtype. +type UnionFloat64 float64 + +// UnionString is a string type assignable to unions of which it is a subtype. +type UnionString string + +// UnionBool is a bool type assignable to unions of which it is a subtype. +type UnionBool bool + +// UnionUnsupported is an interface{} wrapper type for unsupported types. It is +// assignable to unions of which it is a subtype. +type UnionUnsupported struct { + Value interface{} +} + +var ( + SchemaTree map[string]*yang.Entry + ΛEnumTypes map[string][]reflect.Type +) + +func init() { + var err error + initΛEnumTypes() + if SchemaTree, err = UnzipSchema(); err != nil { + panic("schema error: " + err.Error()) + } +} + +// Schema returns the details of the generated schema. +func Schema() (*ytypes.Schema, error) { + uzp, err := UnzipSchema() + if err != nil { + return nil, fmt.Errorf("cannot unzip schema, %v", err) + } + + return &ytypes.Schema{ + Root: &Root{}, + SchemaTree: uzp, + Unmarshal: Unmarshal, + }, nil +} + +// UnzipSchema unzips the zipped schema and returns a map of yang.Entry nodes, +// keyed by the name of the struct that the yang.Entry describes the schema for. +func UnzipSchema() (map[string]*yang.Entry, error) { + var schemaTree map[string]*yang.Entry + var err error + if schemaTree, err = ygot.GzipToSchema(ySchema); err != nil { + return nil, fmt.Errorf("could not unzip the schema; %v", err) + } + return schemaTree, nil +} + +// Unmarshal unmarshals data, which must be RFC7951 JSON format, into +// destStruct, which must be non-nil and the correct GoStruct type. It returns +// an error if the destStruct is not found in the schema or the data cannot be +// unmarshaled. The supplied options (opts) are used to control the behaviour +// of the unmarshal function - for example, determining whether errors are +// thrown for unknown fields in the input JSON. +func Unmarshal(data []byte, destStruct ygot.GoStruct, opts ...ytypes.UnmarshalOpt) error { + tn := reflect.TypeOf(destStruct).Elem().Name() + schema, ok := SchemaTree[tn] + if !ok { + return fmt.Errorf("could not find schema for type %s", tn) + } + var jsonTree interface{} + if err := json.Unmarshal([]byte(data), &jsonTree); err != nil { + return err + } + return ytypes.Unmarshal(schema, destStruct, jsonTree, opts...) +} + +// A represents the /openconfig-nested/a YANG schema element. +type A struct { + B *A_B `path:"b" module:"openconfig-nested"` +} + +// IsYANGGoStruct ensures that A implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*A) IsYANGGoStruct() {} + +// GetOrCreateB retrieves the value of the B field +// or returns the existing field if it already exists. +func (t *A) GetOrCreateB() *A_B { + if t.B != nil { + return t.B + } + t.B = &A_B{} + return t.B +} + +// GetB returns the value of the B struct pointer +// from A. If the receiver or the field B is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *A) GetB() *A_B { + if t != nil && t.B != nil { + return t.B + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the A +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *A) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.B.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["A"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *A) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of A. +func (*A) ΛBelongingModule() string { + return "openconfig-nested" +} + +// A_B represents the /openconfig-nested/a/b YANG schema element. +type A_B struct { + C *A_B_C `path:"c" module:"openconfig-nested"` +} + +// IsYANGGoStruct ensures that A_B implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*A_B) IsYANGGoStruct() {} + +// GetOrCreateC retrieves the value of the C field +// or returns the existing field if it already exists. +func (t *A_B) GetOrCreateC() *A_B_C { + if t.C != nil { + return t.C + } + t.C = &A_B_C{} + return t.C +} + +// GetC returns the value of the C struct pointer +// from A_B. If the receiver or the field C is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *A_B) GetC() *A_B_C { + if t != nil && t.C != nil { + return t.C + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the A_B +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *A_B) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.C.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["A_B"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *A_B) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of A_B. +func (*A_B) ΛBelongingModule() string { + return "openconfig-nested" +} + +// A_B_C represents the /openconfig-nested/a/b/c YANG schema element. +type A_B_C struct { + D *A_B_C_D `path:"d" module:"openconfig-nested"` +} + +// IsYANGGoStruct ensures that A_B_C implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*A_B_C) IsYANGGoStruct() {} + +// GetOrCreateD retrieves the value of the D field +// or returns the existing field if it already exists. +func (t *A_B_C) GetOrCreateD() *A_B_C_D { + if t.D != nil { + return t.D + } + t.D = &A_B_C_D{} + return t.D +} + +// GetD returns the value of the D struct pointer +// from A_B_C. If the receiver or the field D is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *A_B_C) GetD() *A_B_C_D { + if t != nil && t.D != nil { + return t.D + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the A_B_C +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *A_B_C) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.D.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["A_B_C"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *A_B_C) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of A_B_C. +func (*A_B_C) ΛBelongingModule() string { + return "openconfig-nested" +} + +// A_B_C_D represents the /openconfig-nested/a/b/c/d YANG schema element. +type A_B_C_D struct { + E *A_B_C_D_E `path:"e" module:"openconfig-nested"` +} + +// IsYANGGoStruct ensures that A_B_C_D implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*A_B_C_D) IsYANGGoStruct() {} + +// GetOrCreateE retrieves the value of the E field +// or returns the existing field if it already exists. +func (t *A_B_C_D) GetOrCreateE() *A_B_C_D_E { + if t.E != nil { + return t.E + } + t.E = &A_B_C_D_E{} + return t.E +} + +// GetE returns the value of the E struct pointer +// from A_B_C_D. If the receiver or the field E is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *A_B_C_D) GetE() *A_B_C_D_E { + if t != nil && t.E != nil { + return t.E + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the A_B_C_D +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *A_B_C_D) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.E.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["A_B_C_D"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *A_B_C_D) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of A_B_C_D. +func (*A_B_C_D) ΛBelongingModule() string { + return "openconfig-nested" +} + +// A_B_C_D_E represents the /openconfig-nested/a/b/c/d/e YANG schema element. +type A_B_C_D_E struct { + F *A_B_C_D_E_F `path:"f" module:"openconfig-nested"` +} + +// IsYANGGoStruct ensures that A_B_C_D_E implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*A_B_C_D_E) IsYANGGoStruct() {} + +// GetOrCreateF retrieves the value of the F field +// or returns the existing field if it already exists. +func (t *A_B_C_D_E) GetOrCreateF() *A_B_C_D_E_F { + if t.F != nil { + return t.F + } + t.F = &A_B_C_D_E_F{} + return t.F +} + +// GetF returns the value of the F struct pointer +// from A_B_C_D_E. If the receiver or the field F is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *A_B_C_D_E) GetF() *A_B_C_D_E_F { + if t != nil && t.F != nil { + return t.F + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the A_B_C_D_E +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *A_B_C_D_E) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.F.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["A_B_C_D_E"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *A_B_C_D_E) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of A_B_C_D_E. +func (*A_B_C_D_E) ΛBelongingModule() string { + return "openconfig-nested" +} + +// A_B_C_D_E_F represents the /openconfig-nested/a/b/c/d/e/f YANG schema element. +type A_B_C_D_E_F struct { + G *A_B_C_D_E_F_G `path:"g" module:"openconfig-nested"` +} + +// IsYANGGoStruct ensures that A_B_C_D_E_F implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*A_B_C_D_E_F) IsYANGGoStruct() {} + +// GetOrCreateG retrieves the value of the G field +// or returns the existing field if it already exists. +func (t *A_B_C_D_E_F) GetOrCreateG() *A_B_C_D_E_F_G { + if t.G != nil { + return t.G + } + t.G = &A_B_C_D_E_F_G{} + return t.G +} + +// GetG returns the value of the G struct pointer +// from A_B_C_D_E_F. If the receiver or the field G is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *A_B_C_D_E_F) GetG() *A_B_C_D_E_F_G { + if t != nil && t.G != nil { + return t.G + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the A_B_C_D_E_F +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *A_B_C_D_E_F) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.G.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["A_B_C_D_E_F"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *A_B_C_D_E_F) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of A_B_C_D_E_F. +func (*A_B_C_D_E_F) ΛBelongingModule() string { + return "openconfig-nested" +} + +// A_B_C_D_E_F_G represents the /openconfig-nested/a/b/c/d/e/f/g YANG schema element. +type A_B_C_D_E_F_G struct { + H *A_B_C_D_E_F_G_H `path:"h" module:"openconfig-nested"` +} + +// IsYANGGoStruct ensures that A_B_C_D_E_F_G implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*A_B_C_D_E_F_G) IsYANGGoStruct() {} + +// GetOrCreateH retrieves the value of the H field +// or returns the existing field if it already exists. +func (t *A_B_C_D_E_F_G) GetOrCreateH() *A_B_C_D_E_F_G_H { + if t.H != nil { + return t.H + } + t.H = &A_B_C_D_E_F_G_H{} + return t.H +} + +// GetH returns the value of the H struct pointer +// from A_B_C_D_E_F_G. If the receiver or the field H is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *A_B_C_D_E_F_G) GetH() *A_B_C_D_E_F_G_H { + if t != nil && t.H != nil { + return t.H + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the A_B_C_D_E_F_G +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *A_B_C_D_E_F_G) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.H.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F_G) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["A_B_C_D_E_F_G"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F_G) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *A_B_C_D_E_F_G) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of A_B_C_D_E_F_G. +func (*A_B_C_D_E_F_G) ΛBelongingModule() string { + return "openconfig-nested" +} + +// A_B_C_D_E_F_G_H represents the /openconfig-nested/a/b/c/d/e/f/g/h YANG schema element. +type A_B_C_D_E_F_G_H struct { + I *A_B_C_D_E_F_G_H_I `path:"i" module:"openconfig-nested"` +} + +// IsYANGGoStruct ensures that A_B_C_D_E_F_G_H implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*A_B_C_D_E_F_G_H) IsYANGGoStruct() {} + +// GetOrCreateI retrieves the value of the I field +// or returns the existing field if it already exists. +func (t *A_B_C_D_E_F_G_H) GetOrCreateI() *A_B_C_D_E_F_G_H_I { + if t.I != nil { + return t.I + } + t.I = &A_B_C_D_E_F_G_H_I{} + return t.I +} + +// GetI returns the value of the I struct pointer +// from A_B_C_D_E_F_G_H. If the receiver or the field I is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *A_B_C_D_E_F_G_H) GetI() *A_B_C_D_E_F_G_H_I { + if t != nil && t.I != nil { + return t.I + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the A_B_C_D_E_F_G_H +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *A_B_C_D_E_F_G_H) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.I.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F_G_H) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["A_B_C_D_E_F_G_H"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F_G_H) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *A_B_C_D_E_F_G_H) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of A_B_C_D_E_F_G_H. +func (*A_B_C_D_E_F_G_H) ΛBelongingModule() string { + return "openconfig-nested" +} + +// A_B_C_D_E_F_G_H_I represents the /openconfig-nested/a/b/c/d/e/f/g/h/i YANG schema element. +type A_B_C_D_E_F_G_H_I struct { + J *A_B_C_D_E_F_G_H_I_J `path:"j" module:"openconfig-nested"` +} + +// IsYANGGoStruct ensures that A_B_C_D_E_F_G_H_I implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*A_B_C_D_E_F_G_H_I) IsYANGGoStruct() {} + +// GetOrCreateJ retrieves the value of the J field +// or returns the existing field if it already exists. +func (t *A_B_C_D_E_F_G_H_I) GetOrCreateJ() *A_B_C_D_E_F_G_H_I_J { + if t.J != nil { + return t.J + } + t.J = &A_B_C_D_E_F_G_H_I_J{} + return t.J +} + +// GetJ returns the value of the J struct pointer +// from A_B_C_D_E_F_G_H_I. If the receiver or the field J is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *A_B_C_D_E_F_G_H_I) GetJ() *A_B_C_D_E_F_G_H_I_J { + if t != nil && t.J != nil { + return t.J + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the A_B_C_D_E_F_G_H_I +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *A_B_C_D_E_F_G_H_I) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.J.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F_G_H_I) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["A_B_C_D_E_F_G_H_I"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F_G_H_I) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *A_B_C_D_E_F_G_H_I) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of A_B_C_D_E_F_G_H_I. +func (*A_B_C_D_E_F_G_H_I) ΛBelongingModule() string { + return "openconfig-nested" +} + +// A_B_C_D_E_F_G_H_I_J represents the /openconfig-nested/a/b/c/d/e/f/g/h/i/j YANG schema element. +type A_B_C_D_E_F_G_H_I_J struct { + K *A_B_C_D_E_F_G_H_I_J_K `path:"k" module:"openconfig-nested"` +} + +// IsYANGGoStruct ensures that A_B_C_D_E_F_G_H_I_J implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*A_B_C_D_E_F_G_H_I_J) IsYANGGoStruct() {} + +// GetOrCreateK retrieves the value of the K field +// or returns the existing field if it already exists. +func (t *A_B_C_D_E_F_G_H_I_J) GetOrCreateK() *A_B_C_D_E_F_G_H_I_J_K { + if t.K != nil { + return t.K + } + t.K = &A_B_C_D_E_F_G_H_I_J_K{} + return t.K +} + +// GetK returns the value of the K struct pointer +// from A_B_C_D_E_F_G_H_I_J. If the receiver or the field K is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *A_B_C_D_E_F_G_H_I_J) GetK() *A_B_C_D_E_F_G_H_I_J_K { + if t != nil && t.K != nil { + return t.K + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the A_B_C_D_E_F_G_H_I_J +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *A_B_C_D_E_F_G_H_I_J) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.K.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F_G_H_I_J) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["A_B_C_D_E_F_G_H_I_J"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F_G_H_I_J) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *A_B_C_D_E_F_G_H_I_J) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of A_B_C_D_E_F_G_H_I_J. +func (*A_B_C_D_E_F_G_H_I_J) ΛBelongingModule() string { + return "openconfig-nested" +} + +// A_B_C_D_E_F_G_H_I_J_K represents the /openconfig-nested/a/b/c/d/e/f/g/h/i/j/k YANG schema element. +type A_B_C_D_E_F_G_H_I_J_K struct { + L *A_B_C_D_E_F_G_H_I_J_K_L `path:"l" module:"openconfig-nested"` +} + +// IsYANGGoStruct ensures that A_B_C_D_E_F_G_H_I_J_K implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*A_B_C_D_E_F_G_H_I_J_K) IsYANGGoStruct() {} + +// GetOrCreateL retrieves the value of the L field +// or returns the existing field if it already exists. +func (t *A_B_C_D_E_F_G_H_I_J_K) GetOrCreateL() *A_B_C_D_E_F_G_H_I_J_K_L { + if t.L != nil { + return t.L + } + t.L = &A_B_C_D_E_F_G_H_I_J_K_L{} + return t.L +} + +// GetL returns the value of the L struct pointer +// from A_B_C_D_E_F_G_H_I_J_K. If the receiver or the field L is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *A_B_C_D_E_F_G_H_I_J_K) GetL() *A_B_C_D_E_F_G_H_I_J_K_L { + if t != nil && t.L != nil { + return t.L + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the A_B_C_D_E_F_G_H_I_J_K +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *A_B_C_D_E_F_G_H_I_J_K) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.L.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F_G_H_I_J_K) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["A_B_C_D_E_F_G_H_I_J_K"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F_G_H_I_J_K) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *A_B_C_D_E_F_G_H_I_J_K) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of A_B_C_D_E_F_G_H_I_J_K. +func (*A_B_C_D_E_F_G_H_I_J_K) ΛBelongingModule() string { + return "openconfig-nested" +} + +// A_B_C_D_E_F_G_H_I_J_K_L represents the /openconfig-nested/a/b/c/d/e/f/g/h/i/j/k/l YANG schema element. +type A_B_C_D_E_F_G_H_I_J_K_L struct { + M *A_B_C_D_E_F_G_H_I_J_K_L_M `path:"m" module:"openconfig-nested"` +} + +// IsYANGGoStruct ensures that A_B_C_D_E_F_G_H_I_J_K_L implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*A_B_C_D_E_F_G_H_I_J_K_L) IsYANGGoStruct() {} + +// GetOrCreateM retrieves the value of the M field +// or returns the existing field if it already exists. +func (t *A_B_C_D_E_F_G_H_I_J_K_L) GetOrCreateM() *A_B_C_D_E_F_G_H_I_J_K_L_M { + if t.M != nil { + return t.M + } + t.M = &A_B_C_D_E_F_G_H_I_J_K_L_M{} + return t.M +} + +// GetM returns the value of the M struct pointer +// from A_B_C_D_E_F_G_H_I_J_K_L. If the receiver or the field M is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *A_B_C_D_E_F_G_H_I_J_K_L) GetM() *A_B_C_D_E_F_G_H_I_J_K_L_M { + if t != nil && t.M != nil { + return t.M + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the A_B_C_D_E_F_G_H_I_J_K_L +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *A_B_C_D_E_F_G_H_I_J_K_L) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.M.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F_G_H_I_J_K_L) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["A_B_C_D_E_F_G_H_I_J_K_L"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F_G_H_I_J_K_L) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *A_B_C_D_E_F_G_H_I_J_K_L) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of A_B_C_D_E_F_G_H_I_J_K_L. +func (*A_B_C_D_E_F_G_H_I_J_K_L) ΛBelongingModule() string { + return "openconfig-nested" +} + +// A_B_C_D_E_F_G_H_I_J_K_L_M represents the /openconfig-nested/a/b/c/d/e/f/g/h/i/j/k/l/m YANG schema element. +type A_B_C_D_E_F_G_H_I_J_K_L_M struct { + Foo *string `path:"state/foo" module:"openconfig-nested/openconfig-nested"` +} + +// IsYANGGoStruct ensures that A_B_C_D_E_F_G_H_I_J_K_L_M implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*A_B_C_D_E_F_G_H_I_J_K_L_M) IsYANGGoStruct() {} + +// GetFoo retrieves the value of the leaf Foo from the A_B_C_D_E_F_G_H_I_J_K_L_M +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Foo is set, it can +// safely use t.GetFoo() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Foo == nil' before retrieving the leaf's value. +func (t *A_B_C_D_E_F_G_H_I_J_K_L_M) GetFoo() string { + if t == nil || t.Foo == nil { + return "" + } + return *t.Foo +} + +// SetFoo sets the value of the leaf Foo in the A_B_C_D_E_F_G_H_I_J_K_L_M +// struct. +func (t *A_B_C_D_E_F_G_H_I_J_K_L_M) SetFoo(v string) { + t.Foo = &v +} + +// PopulateDefaults recursively populates unset leaf fields in the A_B_C_D_E_F_G_H_I_J_K_L_M +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *A_B_C_D_E_F_G_H_I_J_K_L_M) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F_G_H_I_J_K_L_M) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["A_B_C_D_E_F_G_H_I_J_K_L_M"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *A_B_C_D_E_F_G_H_I_J_K_L_M) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *A_B_C_D_E_F_G_H_I_J_K_L_M) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of A_B_C_D_E_F_G_H_I_J_K_L_M. +func (*A_B_C_D_E_F_G_H_I_J_K_L_M) ΛBelongingModule() string { + return "openconfig-nested" +} + +// Container represents the /openconfig-nested/container YANG schema element. +type Container struct { + Enabled *bool `path:"enabled" module:"openconfig-nested"` +} + +// IsYANGGoStruct ensures that Container implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Container) IsYANGGoStruct() {} + +// GetEnabled retrieves the value of the leaf Enabled from the Container +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Enabled is set, it can +// safely use t.GetEnabled() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Enabled == nil' before retrieving the leaf's value. +func (t *Container) GetEnabled() bool { + if t == nil || t.Enabled == nil { + return false + } + return *t.Enabled +} + +// SetEnabled sets the value of the leaf Enabled in the Container +// struct. +func (t *Container) SetEnabled(v bool) { + t.Enabled = &v +} + +// PopulateDefaults recursively populates unset leaf fields in the Container +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *Container) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Container) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Container"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Container) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Container) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of Container. +func (*Container) ΛBelongingModule() string { + return "openconfig-nested" +} + +// Model represents the /openconfig-withlistval/model YANG schema element. +type Model struct { + MultiKey map[Model_MultiKey_Key]*Model_MultiKey `path:"b/multi-key" module:"openconfig-withlistval/openconfig-withlistval"` + NoKey []*Model_NoKey `path:"c/no-key" module:"openconfig-withlistval/openconfig-withlistval"` + SingleKey map[string]*Model_SingleKey `path:"a/single-key" module:"openconfig-withlistval/openconfig-withlistval"` +} + +// IsYANGGoStruct ensures that Model implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Model) IsYANGGoStruct() {} + +// Model_MultiKey_Key represents the key for list MultiKey of element /openconfig-withlistval/model. +type Model_MultiKey_Key struct { + Key1 uint32 `path:"key1"` + Key2 uint64 `path:"key2"` +} + +// IsYANGGoKeyStruct ensures that Model_MultiKey_Key partially implements the +// yang.GoKeyStruct interface. This allows functions that need to +// handle this key struct to identify it as being generated by gogen. +func (Model_MultiKey_Key) IsYANGGoKeyStruct() {} + +// ΛListKeyMap returns the values of the Model_MultiKey_Key key struct. +func (t Model_MultiKey_Key) ΛListKeyMap() (map[string]interface{}, error) { + return map[string]interface{}{ + "key1": t.Key1, + "key2": t.Key2, + }, nil +} + +// NewMultiKey creates a new entry in the MultiKey list of the +// Model struct. The keys of the list are populated from the input +// arguments. +func (t *Model) NewMultiKey(Key1 uint32, Key2 uint64) (*Model_MultiKey, error) { + + // Initialise the list within the receiver struct if it has not already been + // created. + if t.MultiKey == nil { + t.MultiKey = make(map[Model_MultiKey_Key]*Model_MultiKey) + } + + key := Model_MultiKey_Key{ + Key1: Key1, + Key2: Key2, + } + + // Ensure that this key has not already been used in the + // list. Keyed YANG lists do not allow duplicate keys to + // be created. + if _, ok := t.MultiKey[key]; ok { + return nil, fmt.Errorf("duplicate key %v for list MultiKey", key) + } + + t.MultiKey[key] = &Model_MultiKey{ + Key1: &Key1, + Key2: &Key2, + } + + return t.MultiKey[key], nil +} + +// RenameMultiKey renames an entry in the list MultiKey within +// the Model struct. The entry with key oldK is renamed to newK updating +// the key within the value. +func (t *Model) RenameMultiKey(oldK, newK Model_MultiKey_Key) error { + if _, ok := t.MultiKey[newK]; ok { + return fmt.Errorf("key %v already exists in MultiKey", newK) + } + + e, ok := t.MultiKey[oldK] + if !ok { + return fmt.Errorf("key %v not found in MultiKey", oldK) + } + e.Key1 = &newK.Key1 + e.Key2 = &newK.Key2 + + t.MultiKey[newK] = e + delete(t.MultiKey, oldK) + return nil +} + +// GetOrCreateMultiKey retrieves the value with the specified keys from +// the receiver Model. If the entry does not exist, then it is created. +// It returns the existing or new list member. +func (t *Model) GetOrCreateMultiKey(Key1 uint32, Key2 uint64) *Model_MultiKey { + + key := Model_MultiKey_Key{ + Key1: Key1, + Key2: Key2, + } + + if v, ok := t.MultiKey[key]; ok { + return v + } + // Panic if we receive an error, since we should have retrieved an existing + // list member. This allows chaining of GetOrCreate methods. + v, err := t.NewMultiKey(Key1, Key2) + if err != nil { + panic(fmt.Sprintf("GetOrCreateMultiKey got unexpected error: %v", err)) + } + return v +} + +// GetMultiKey retrieves the value with the specified key from +// the MultiKey map field of Model. If the receiver is nil, or +// the specified key is not present in the list, nil is returned such that Get* +// methods may be safely chained. +func (t *Model) GetMultiKey(Key1 uint32, Key2 uint64) *Model_MultiKey { + + if t == nil { + return nil + } + + key := Model_MultiKey_Key{ + Key1: Key1, + Key2: Key2, + } + + if lm, ok := t.MultiKey[key]; ok { + return lm + } + return nil +} + +// DeleteMultiKey deletes the value with the specified keys from +// the receiver Model. If there is no such element, the function +// is a no-op. +func (t *Model) DeleteMultiKey(Key1 uint32, Key2 uint64) { + key := Model_MultiKey_Key{ + Key1: Key1, + Key2: Key2, + } + + delete(t.MultiKey, key) +} + +// AppendMultiKey appends the supplied Model_MultiKey struct to the +// list MultiKey of Model. If the key value(s) specified in +// the supplied Model_MultiKey already exist in the list, an error is +// returned. +func (t *Model) AppendMultiKey(v *Model_MultiKey) error { + if v.Key1 == nil { + return fmt.Errorf("invalid nil key for Key1") + } + + if v.Key2 == nil { + return fmt.Errorf("invalid nil key for Key2") + } + + key := Model_MultiKey_Key{ + Key1: *v.Key1, + Key2: *v.Key2, + } + + // Initialise the list within the receiver struct if it has not already been + // created. + if t.MultiKey == nil { + t.MultiKey = make(map[Model_MultiKey_Key]*Model_MultiKey) + } + + if _, ok := t.MultiKey[key]; ok { + return fmt.Errorf("duplicate key for list MultiKey %v", key) + } + + t.MultiKey[key] = v + return nil +} + +// NewSingleKey creates a new entry in the SingleKey list of the +// Model struct. The keys of the list are populated from the input +// arguments. +func (t *Model) NewSingleKey(Key string) (*Model_SingleKey, error) { + + // Initialise the list within the receiver struct if it has not already been + // created. + if t.SingleKey == nil { + t.SingleKey = make(map[string]*Model_SingleKey) + } + + key := Key + + // Ensure that this key has not already been used in the + // list. Keyed YANG lists do not allow duplicate keys to + // be created. + if _, ok := t.SingleKey[key]; ok { + return nil, fmt.Errorf("duplicate key %v for list SingleKey", key) + } + + t.SingleKey[key] = &Model_SingleKey{ + Key: &Key, + } + + return t.SingleKey[key], nil +} + +// RenameSingleKey renames an entry in the list SingleKey within +// the Model struct. The entry with key oldK is renamed to newK updating +// the key within the value. +func (t *Model) RenameSingleKey(oldK, newK string) error { + if _, ok := t.SingleKey[newK]; ok { + return fmt.Errorf("key %v already exists in SingleKey", newK) + } + + e, ok := t.SingleKey[oldK] + if !ok { + return fmt.Errorf("key %v not found in SingleKey", oldK) + } + e.Key = &newK + + t.SingleKey[newK] = e + delete(t.SingleKey, oldK) + return nil +} + +// GetOrCreateSingleKey retrieves the value with the specified keys from +// the receiver Model. If the entry does not exist, then it is created. +// It returns the existing or new list member. +func (t *Model) GetOrCreateSingleKey(Key string) *Model_SingleKey { + + key := Key + + if v, ok := t.SingleKey[key]; ok { + return v + } + // Panic if we receive an error, since we should have retrieved an existing + // list member. This allows chaining of GetOrCreate methods. + v, err := t.NewSingleKey(Key) + if err != nil { + panic(fmt.Sprintf("GetOrCreateSingleKey got unexpected error: %v", err)) + } + return v +} + +// GetSingleKey retrieves the value with the specified key from +// the SingleKey map field of Model. If the receiver is nil, or +// the specified key is not present in the list, nil is returned such that Get* +// methods may be safely chained. +func (t *Model) GetSingleKey(Key string) *Model_SingleKey { + + if t == nil { + return nil + } + + key := Key + + if lm, ok := t.SingleKey[key]; ok { + return lm + } + return nil +} + +// DeleteSingleKey deletes the value with the specified keys from +// the receiver Model. If there is no such element, the function +// is a no-op. +func (t *Model) DeleteSingleKey(Key string) { + key := Key + + delete(t.SingleKey, key) +} + +// AppendSingleKey appends the supplied Model_SingleKey struct to the +// list SingleKey of Model. If the key value(s) specified in +// the supplied Model_SingleKey already exist in the list, an error is +// returned. +func (t *Model) AppendSingleKey(v *Model_SingleKey) error { + if v.Key == nil { + return fmt.Errorf("invalid nil key received for Key") + } + + key := *v.Key + + // Initialise the list within the receiver struct if it has not already been + // created. + if t.SingleKey == nil { + t.SingleKey = make(map[string]*Model_SingleKey) + } + + if _, ok := t.SingleKey[key]; ok { + return fmt.Errorf("duplicate key for list SingleKey %v", key) + } + + t.SingleKey[key] = v + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the Model +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *Model) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + for _, e := range t.MultiKey { + e.PopulateDefaults() + } + for _, e := range t.NoKey { + e.PopulateDefaults() + } + for _, e := range t.SingleKey { + e.PopulateDefaults() + } +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Model) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Model"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Model) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Model) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of Model. +func (*Model) ΛBelongingModule() string { + return "openconfig-withlistval" +} + +// Model_MultiKey represents the /openconfig-withlistval/model/b/multi-key YANG schema element. +type Model_MultiKey struct { + Key1 *uint32 `path:"config/key1|key1" module:"openconfig-withlistval/openconfig-withlistval|openconfig-withlistval" shadow-path:"state/key1|key1" shadow-module:"openconfig-withlistval/openconfig-withlistval|openconfig-withlistval"` + Key2 *uint64 `path:"config/key2|key2" module:"openconfig-withlistval/openconfig-withlistval|openconfig-withlistval" shadow-path:"state/key2|key2" shadow-module:"openconfig-withlistval/openconfig-withlistval|openconfig-withlistval"` +} + +// IsYANGGoStruct ensures that Model_MultiKey implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Model_MultiKey) IsYANGGoStruct() {} + +// GetKey1 retrieves the value of the leaf Key1 from the Model_MultiKey +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Key1 is set, it can +// safely use t.GetKey1() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Key1 == nil' before retrieving the leaf's value. +func (t *Model_MultiKey) GetKey1() uint32 { + if t == nil || t.Key1 == nil { + return 0 + } + return *t.Key1 +} + +// GetKey2 retrieves the value of the leaf Key2 from the Model_MultiKey +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Key2 is set, it can +// safely use t.GetKey2() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Key2 == nil' before retrieving the leaf's value. +func (t *Model_MultiKey) GetKey2() uint64 { + if t == nil || t.Key2 == nil { + return 0 + } + return *t.Key2 +} + +// SetKey1 sets the value of the leaf Key1 in the Model_MultiKey +// struct. +func (t *Model_MultiKey) SetKey1(v uint32) { + t.Key1 = &v +} + +// SetKey2 sets the value of the leaf Key2 in the Model_MultiKey +// struct. +func (t *Model_MultiKey) SetKey2(v uint64) { + t.Key2 = &v +} + +// PopulateDefaults recursively populates unset leaf fields in the Model_MultiKey +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *Model_MultiKey) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) +} + +// ΛListKeyMap returns the keys of the Model_MultiKey struct, which is a YANG list entry. +func (t *Model_MultiKey) ΛListKeyMap() (map[string]interface{}, error) { + if t.Key1 == nil { + return nil, fmt.Errorf("nil value for key Key1") + } + + if t.Key2 == nil { + return nil, fmt.Errorf("nil value for key Key2") + } + + return map[string]interface{}{ + "key1": *t.Key1, + "key2": *t.Key2, + }, nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Model_MultiKey) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Model_MultiKey"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Model_MultiKey) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Model_MultiKey) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of Model_MultiKey. +func (*Model_MultiKey) ΛBelongingModule() string { + return "openconfig-withlistval" +} + +// Model_NoKey represents the /openconfig-withlistval/model/c/no-key YANG schema element. +type Model_NoKey struct { + Foo *Model_NoKey_Foo `path:"foo" module:"openconfig-withlistval"` +} + +// IsYANGGoStruct ensures that Model_NoKey implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Model_NoKey) IsYANGGoStruct() {} + +// GetOrCreateFoo retrieves the value of the Foo field +// or returns the existing field if it already exists. +func (t *Model_NoKey) GetOrCreateFoo() *Model_NoKey_Foo { + if t.Foo != nil { + return t.Foo + } + t.Foo = &Model_NoKey_Foo{} + return t.Foo +} + +// GetFoo returns the value of the Foo struct pointer +// from Model_NoKey. If the receiver or the field Foo is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *Model_NoKey) GetFoo() *Model_NoKey_Foo { + if t != nil && t.Foo != nil { + return t.Foo + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the Model_NoKey +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *Model_NoKey) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.Foo.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Model_NoKey) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Model_NoKey"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Model_NoKey) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Model_NoKey) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of Model_NoKey. +func (*Model_NoKey) ΛBelongingModule() string { + return "openconfig-withlistval" +} + +// Model_NoKey_Foo represents the /openconfig-withlistval/model/c/no-key/foo YANG schema element. +type Model_NoKey_Foo struct { + Key *string `path:"state/key" module:"openconfig-withlistval/openconfig-withlistval"` + Value *int64 `path:"state/value" module:"openconfig-withlistval/openconfig-withlistval"` +} + +// IsYANGGoStruct ensures that Model_NoKey_Foo implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Model_NoKey_Foo) IsYANGGoStruct() {} + +// GetKey retrieves the value of the leaf Key from the Model_NoKey_Foo +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Key is set, it can +// safely use t.GetKey() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Key == nil' before retrieving the leaf's value. +func (t *Model_NoKey_Foo) GetKey() string { + if t == nil || t.Key == nil { + return "" + } + return *t.Key +} + +// GetValue retrieves the value of the leaf Value from the Model_NoKey_Foo +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Value is set, it can +// safely use t.GetValue() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Value == nil' before retrieving the leaf's value. +func (t *Model_NoKey_Foo) GetValue() int64 { + if t == nil || t.Value == nil { + return 0 + } + return *t.Value +} + +// SetKey sets the value of the leaf Key in the Model_NoKey_Foo +// struct. +func (t *Model_NoKey_Foo) SetKey(v string) { + t.Key = &v +} + +// SetValue sets the value of the leaf Value in the Model_NoKey_Foo +// struct. +func (t *Model_NoKey_Foo) SetValue(v int64) { + t.Value = &v +} + +// PopulateDefaults recursively populates unset leaf fields in the Model_NoKey_Foo +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *Model_NoKey_Foo) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Model_NoKey_Foo) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Model_NoKey_Foo"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Model_NoKey_Foo) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Model_NoKey_Foo) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of Model_NoKey_Foo. +func (*Model_NoKey_Foo) ΛBelongingModule() string { + return "openconfig-withlistval" +} + +// Model_SingleKey represents the /openconfig-withlistval/model/a/single-key YANG schema element. +type Model_SingleKey struct { + Counter Binary `path:"state/counter" module:"openconfig-withlistval/openconfig-withlistval"` + Counters []Binary `path:"state/counters" module:"openconfig-withlistval/openconfig-withlistval"` + Key *string `path:"config/key|key" module:"openconfig-withlistval/openconfig-withlistval|openconfig-withlistval" shadow-path:"state/key|key" shadow-module:"openconfig-withlistval/openconfig-withlistval|openconfig-withlistval"` + OrderedList *Model_SingleKey_OrderedList_OrderedMap `path:"ordered-lists/ordered-list" module:"openconfig-withlistval/openconfig-withlistval"` + SingleKey map[string]*Model_SingleKey_SingleKey `path:"inner-a/single-key" module:"openconfig-withlistval/openconfig-withlistval"` + Value *int64 `path:"config/value" module:"openconfig-withlistval/openconfig-withlistval" shadow-path:"state/value" shadow-module:"openconfig-withlistval/openconfig-withlistval"` +} + +// IsYANGGoStruct ensures that Model_SingleKey implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Model_SingleKey) IsYANGGoStruct() {} + +// NewSingleKey creates a new entry in the SingleKey list of the +// Model_SingleKey struct. The keys of the list are populated from the input +// arguments. +func (t *Model_SingleKey) NewSingleKey(Key string) (*Model_SingleKey_SingleKey, error) { + + // Initialise the list within the receiver struct if it has not already been + // created. + if t.SingleKey == nil { + t.SingleKey = make(map[string]*Model_SingleKey_SingleKey) + } + + key := Key + + // Ensure that this key has not already been used in the + // list. Keyed YANG lists do not allow duplicate keys to + // be created. + if _, ok := t.SingleKey[key]; ok { + return nil, fmt.Errorf("duplicate key %v for list SingleKey", key) + } + + t.SingleKey[key] = &Model_SingleKey_SingleKey{ + Key: &Key, + } + + return t.SingleKey[key], nil +} + +// RenameSingleKey renames an entry in the list SingleKey within +// the Model_SingleKey struct. The entry with key oldK is renamed to newK updating +// the key within the value. +func (t *Model_SingleKey) RenameSingleKey(oldK, newK string) error { + if _, ok := t.SingleKey[newK]; ok { + return fmt.Errorf("key %v already exists in SingleKey", newK) + } + + e, ok := t.SingleKey[oldK] + if !ok { + return fmt.Errorf("key %v not found in SingleKey", oldK) + } + e.Key = &newK + + t.SingleKey[newK] = e + delete(t.SingleKey, oldK) + return nil +} + +// GetOrCreateSingleKey retrieves the value with the specified keys from +// the receiver Model_SingleKey. If the entry does not exist, then it is created. +// It returns the existing or new list member. +func (t *Model_SingleKey) GetOrCreateSingleKey(Key string) *Model_SingleKey_SingleKey { + + key := Key + + if v, ok := t.SingleKey[key]; ok { + return v + } + // Panic if we receive an error, since we should have retrieved an existing + // list member. This allows chaining of GetOrCreate methods. + v, err := t.NewSingleKey(Key) + if err != nil { + panic(fmt.Sprintf("GetOrCreateSingleKey got unexpected error: %v", err)) + } + return v +} + +// GetSingleKey retrieves the value with the specified key from +// the SingleKey map field of Model_SingleKey. If the receiver is nil, or +// the specified key is not present in the list, nil is returned such that Get* +// methods may be safely chained. +func (t *Model_SingleKey) GetSingleKey(Key string) *Model_SingleKey_SingleKey { + + if t == nil { + return nil + } + + key := Key + + if lm, ok := t.SingleKey[key]; ok { + return lm + } + return nil +} + +// DeleteSingleKey deletes the value with the specified keys from +// the receiver Model_SingleKey. If there is no such element, the function +// is a no-op. +func (t *Model_SingleKey) DeleteSingleKey(Key string) { + key := Key + + delete(t.SingleKey, key) +} + +// AppendSingleKey appends the supplied Model_SingleKey_SingleKey struct to the +// list SingleKey of Model_SingleKey. If the key value(s) specified in +// the supplied Model_SingleKey_SingleKey already exist in the list, an error is +// returned. +func (t *Model_SingleKey) AppendSingleKey(v *Model_SingleKey_SingleKey) error { + if v.Key == nil { + return fmt.Errorf("invalid nil key received for Key") + } + + key := *v.Key + + // Initialise the list within the receiver struct if it has not already been + // created. + if t.SingleKey == nil { + t.SingleKey = make(map[string]*Model_SingleKey_SingleKey) + } + + if _, ok := t.SingleKey[key]; ok { + return fmt.Errorf("duplicate key for list SingleKey %v", key) + } + + t.SingleKey[key] = v + return nil +} + +// GetCounter retrieves the value of the leaf Counter from the Model_SingleKey +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Counter is set, it can +// safely use t.GetCounter() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Counter == nil' before retrieving the leaf's value. +func (t *Model_SingleKey) GetCounter() Binary { + if t == nil || t.Counter == nil { + return nil + } + return t.Counter +} + +// GetCounters retrieves the value of the leaf Counters from the Model_SingleKey +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Counters is set, it can +// safely use t.GetCounters() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Counters == nil' before retrieving the leaf's value. +func (t *Model_SingleKey) GetCounters() []Binary { + if t == nil || t.Counters == nil { + return nil + } + return t.Counters +} + +// GetKey retrieves the value of the leaf Key from the Model_SingleKey +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Key is set, it can +// safely use t.GetKey() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Key == nil' before retrieving the leaf's value. +func (t *Model_SingleKey) GetKey() string { + if t == nil || t.Key == nil { + return "" + } + return *t.Key +} + +// GetValue retrieves the value of the leaf Value from the Model_SingleKey +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Value is set, it can +// safely use t.GetValue() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Value == nil' before retrieving the leaf's value. +func (t *Model_SingleKey) GetValue() int64 { + if t == nil || t.Value == nil { + return 0 + } + return *t.Value +} + +// SetCounter sets the value of the leaf Counter in the Model_SingleKey +// struct. +func (t *Model_SingleKey) SetCounter(v Binary) { + t.Counter = v +} + +// SetCounters sets the value of the leaf Counters in the Model_SingleKey +// struct. +func (t *Model_SingleKey) SetCounters(v []Binary) { + t.Counters = v +} + +// SetKey sets the value of the leaf Key in the Model_SingleKey +// struct. +func (t *Model_SingleKey) SetKey(v string) { + t.Key = &v +} + +// SetValue sets the value of the leaf Value in the Model_SingleKey +// struct. +func (t *Model_SingleKey) SetValue(v int64) { + t.Value = &v +} + +// AppendNewOrderedList creates a new entry in the OrderedList +// ordered map of the Model_SingleKey struct. The keys of the list are +// populated from the input arguments. +func (s *Model_SingleKey) AppendNewOrderedList(Key string) (*Model_SingleKey_OrderedList, error) { + if s.OrderedList == nil { + s.OrderedList = &Model_SingleKey_OrderedList_OrderedMap{} + } + return s.OrderedList.AppendNew(Key) +} + +// AppendOrderedList appends the supplied Model_SingleKey_OrderedList struct +// to the list OrderedList of Model_SingleKey. If the key value(s) +// specified in the supplied Model_SingleKey_OrderedList already exist in the list, an +// error is returned. +func (s *Model_SingleKey) AppendOrderedList(v *Model_SingleKey_OrderedList) error { + if s.OrderedList == nil { + s.OrderedList = &Model_SingleKey_OrderedList_OrderedMap{} + } + return s.OrderedList.Append(v) +} + +// GetOrderedList retrieves the value with the specified key from the +// OrderedList map field of Model_SingleKey. If the receiver +// is nil, or the specified key is not present in the list, nil is returned +// such that Get* methods may be safely chained. +func (s *Model_SingleKey) GetOrderedList(Key string) *Model_SingleKey_OrderedList { + if s == nil { + return nil + } + key := Key + return s.OrderedList.Get(key) +} + +// DeleteOrderedList deletes the value with the specified keys from +// the receiver Model_SingleKey. If there is no such element, the +// function is a no-op. +func (s *Model_SingleKey) DeleteOrderedList(Key string) bool { + key := Key + return s.OrderedList.Delete(key) +} + +// Model_SingleKey_OrderedList_OrderedMap is an ordered map that represents the "ordered-by user" +// list elements at /openconfig-withlistval/model/a/single-key/ordered-lists/ordered-list. +type Model_SingleKey_OrderedList_OrderedMap struct { + keys []string + valueMap map[string]*Model_SingleKey_OrderedList +} + +// IsYANGOrderedList ensures that Model_SingleKey_OrderedList_OrderedMap implements the +// ygot.GoOrderedMap interface. +func (*Model_SingleKey_OrderedList_OrderedMap) IsYANGOrderedList() {} + +// init initializes any uninitialized values. +func (o *Model_SingleKey_OrderedList_OrderedMap) init() { + if o == nil { + return + } + if o.valueMap == nil { + o.valueMap = map[string]*Model_SingleKey_OrderedList{} + } +} + +// Keys returns a copy of the list's keys. +func (o *Model_SingleKey_OrderedList_OrderedMap) Keys() []string { + if o == nil { + return nil + } + return append([]string{}, o.keys...) +} + +// Values returns the current set of the list's values in order. +func (o *Model_SingleKey_OrderedList_OrderedMap) Values() []*Model_SingleKey_OrderedList { + if o == nil { + return nil + } + var values []*Model_SingleKey_OrderedList + for _, key := range o.keys { + values = append(values, o.valueMap[key]) + } + return values +} + +// Len returns a size of Model_SingleKey_OrderedList_OrderedMap +func (o *Model_SingleKey_OrderedList_OrderedMap) Len() int { + if o == nil { + return 0 + } + return len(o.keys) +} + +// Get returns the value corresponding to the key. If the key is not found, nil +// is returned. +func (o *Model_SingleKey_OrderedList_OrderedMap) Get(key string) *Model_SingleKey_OrderedList { + if o == nil { + return nil + } + val, _ := o.valueMap[key] + return val +} + +// Delete deletes an element. +func (o *Model_SingleKey_OrderedList_OrderedMap) Delete(key string) bool { + if o == nil { + return false + } + if _, ok := o.valueMap[key]; !ok { + return false + } + for i, k := range o.keys { + if k == key { + o.keys = append(o.keys[:i], o.keys[i+1:]...) + delete(o.valueMap, key) + return true + } + } + return false +} + +// Append appends a Model_SingleKey_OrderedList, returning an error if the key +// already exists in the ordered list or if the key is unspecified. +func (o *Model_SingleKey_OrderedList_OrderedMap) Append(v *Model_SingleKey_OrderedList) error { + if o == nil { + return fmt.Errorf("nil ordered map, cannot append Model_SingleKey_OrderedList") + } + if v == nil { + return fmt.Errorf("nil Model_SingleKey_OrderedList") + } + if v.Key == nil { + return fmt.Errorf("invalid nil key received for Key") + } + + key := *v.Key + + if _, ok := o.valueMap[key]; ok { + return fmt.Errorf("duplicate key for list Statement %v", key) + } + o.keys = append(o.keys, key) + o.init() + o.valueMap[key] = v + return nil +} + +// AppendNew creates and appends a new Model_SingleKey_OrderedList, returning the +// newly-initialized v. It returns an error if the v already exists. +func (o *Model_SingleKey_OrderedList_OrderedMap) AppendNew(Key string) (*Model_SingleKey_OrderedList, error) { + if o == nil { + return nil, fmt.Errorf("nil ordered map, cannot append Model_SingleKey_OrderedList") + } + key := Key + + if _, ok := o.valueMap[key]; ok { + return nil, fmt.Errorf("duplicate key for list Statement %v", key) + } + o.keys = append(o.keys, key) + newElement := &Model_SingleKey_OrderedList{ + Key: &Key, + } + o.init() + o.valueMap[key] = newElement + return newElement, nil +} + +// PopulateDefaults recursively populates unset leaf fields in the Model_SingleKey +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *Model_SingleKey) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + for _, e := range t.SingleKey { + e.PopulateDefaults() + } + for _, e := range t.OrderedList.Values() { + e.PopulateDefaults() + } +} + +// ΛListKeyMap returns the keys of the Model_SingleKey struct, which is a YANG list entry. +func (t *Model_SingleKey) ΛListKeyMap() (map[string]interface{}, error) { + if t.Key == nil { + return nil, fmt.Errorf("nil value for key Key") + } + + return map[string]interface{}{ + "key": *t.Key, + }, nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Model_SingleKey) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Model_SingleKey"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Model_SingleKey) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Model_SingleKey) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of Model_SingleKey. +func (*Model_SingleKey) ΛBelongingModule() string { + return "openconfig-withlistval" +} + +// Model_SingleKey_OrderedList represents the /openconfig-withlistval/model/a/single-key/ordered-lists/ordered-list YANG schema element. +type Model_SingleKey_OrderedList struct { + Key *string `path:"config/key|key" module:"openconfig-withlistval/openconfig-withlistval|openconfig-withlistval" shadow-path:"state/key|key" shadow-module:"openconfig-withlistval/openconfig-withlistval|openconfig-withlistval"` + Value *int64 `path:"config/value" module:"openconfig-withlistval/openconfig-withlistval" shadow-path:"state/value" shadow-module:"openconfig-withlistval/openconfig-withlistval"` +} + +// IsYANGGoStruct ensures that Model_SingleKey_OrderedList implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Model_SingleKey_OrderedList) IsYANGGoStruct() {} + +// GetKey retrieves the value of the leaf Key from the Model_SingleKey_OrderedList +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Key is set, it can +// safely use t.GetKey() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Key == nil' before retrieving the leaf's value. +func (t *Model_SingleKey_OrderedList) GetKey() string { + if t == nil || t.Key == nil { + return "" + } + return *t.Key +} + +// GetValue retrieves the value of the leaf Value from the Model_SingleKey_OrderedList +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Value is set, it can +// safely use t.GetValue() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Value == nil' before retrieving the leaf's value. +func (t *Model_SingleKey_OrderedList) GetValue() int64 { + if t == nil || t.Value == nil { + return 0 + } + return *t.Value +} + +// SetKey sets the value of the leaf Key in the Model_SingleKey_OrderedList +// struct. +func (t *Model_SingleKey_OrderedList) SetKey(v string) { + t.Key = &v +} + +// SetValue sets the value of the leaf Value in the Model_SingleKey_OrderedList +// struct. +func (t *Model_SingleKey_OrderedList) SetValue(v int64) { + t.Value = &v +} + +// PopulateDefaults recursively populates unset leaf fields in the Model_SingleKey_OrderedList +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *Model_SingleKey_OrderedList) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) +} + +// ΛListKeyMap returns the keys of the Model_SingleKey_OrderedList struct, which is a YANG list entry. +func (t *Model_SingleKey_OrderedList) ΛListKeyMap() (map[string]interface{}, error) { + if t.Key == nil { + return nil, fmt.Errorf("nil value for key Key") + } + + return map[string]interface{}{ + "key": *t.Key, + }, nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Model_SingleKey_OrderedList) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Model_SingleKey_OrderedList"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Model_SingleKey_OrderedList) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Model_SingleKey_OrderedList) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of Model_SingleKey_OrderedList. +func (*Model_SingleKey_OrderedList) ΛBelongingModule() string { + return "openconfig-withlistval" +} + +// Model_SingleKey_SingleKey represents the /openconfig-withlistval/model/a/single-key/inner-a/single-key YANG schema element. +type Model_SingleKey_SingleKey struct { + Key *string `path:"config/key|key" module:"openconfig-withlistval/openconfig-withlistval|openconfig-withlistval" shadow-path:"state/key|key" shadow-module:"openconfig-withlistval/openconfig-withlistval|openconfig-withlistval"` + Value *int64 `path:"config/value" module:"openconfig-withlistval/openconfig-withlistval" shadow-path:"state/value" shadow-module:"openconfig-withlistval/openconfig-withlistval"` +} + +// IsYANGGoStruct ensures that Model_SingleKey_SingleKey implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Model_SingleKey_SingleKey) IsYANGGoStruct() {} + +// GetKey retrieves the value of the leaf Key from the Model_SingleKey_SingleKey +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Key is set, it can +// safely use t.GetKey() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Key == nil' before retrieving the leaf's value. +func (t *Model_SingleKey_SingleKey) GetKey() string { + if t == nil || t.Key == nil { + return "" + } + return *t.Key +} + +// GetValue retrieves the value of the leaf Value from the Model_SingleKey_SingleKey +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Value is set, it can +// safely use t.GetValue() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Value == nil' before retrieving the leaf's value. +func (t *Model_SingleKey_SingleKey) GetValue() int64 { + if t == nil || t.Value == nil { + return 0 + } + return *t.Value +} + +// SetKey sets the value of the leaf Key in the Model_SingleKey_SingleKey +// struct. +func (t *Model_SingleKey_SingleKey) SetKey(v string) { + t.Key = &v +} + +// SetValue sets the value of the leaf Value in the Model_SingleKey_SingleKey +// struct. +func (t *Model_SingleKey_SingleKey) SetValue(v int64) { + t.Value = &v +} + +// PopulateDefaults recursively populates unset leaf fields in the Model_SingleKey_SingleKey +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *Model_SingleKey_SingleKey) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) +} + +// ΛListKeyMap returns the keys of the Model_SingleKey_SingleKey struct, which is a YANG list entry. +func (t *Model_SingleKey_SingleKey) ΛListKeyMap() (map[string]interface{}, error) { + if t.Key == nil { + return nil, fmt.Errorf("nil value for key Key") + } + + return map[string]interface{}{ + "key": *t.Key, + }, nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Model_SingleKey_SingleKey) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Model_SingleKey_SingleKey"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Model_SingleKey_SingleKey) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Model_SingleKey_SingleKey) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of Model_SingleKey_SingleKey. +func (*Model_SingleKey_SingleKey) ΛBelongingModule() string { + return "openconfig-withlistval" +} + +// Parent represents the /openconfig-simple/parent YANG schema element. +type Parent struct { + Child *Parent_Child `path:"child" module:"openconfig-simple"` +} + +// IsYANGGoStruct ensures that Parent implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Parent) IsYANGGoStruct() {} + +// GetOrCreateChild retrieves the value of the Child field +// or returns the existing field if it already exists. +func (t *Parent) GetOrCreateChild() *Parent_Child { + if t.Child != nil { + return t.Child + } + t.Child = &Parent_Child{} + return t.Child +} + +// GetChild returns the value of the Child struct pointer +// from Parent. If the receiver or the field Child is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *Parent) GetChild() *Parent_Child { + if t != nil && t.Child != nil { + return t.Child + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the Parent +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *Parent) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.Child.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Parent) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Parent"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Parent) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Parent) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of Parent. +func (*Parent) ΛBelongingModule() string { + return "openconfig-simple" +} + +// Parent_Child represents the /openconfig-simple/parent/child YANG schema element. +type Parent_Child struct { + Five Binary `path:"config/five" module:"openconfig-simple/openconfig-simple" shadow-path:"state/five" shadow-module:"openconfig-simple/openconfig-simple"` + Four Binary `path:"config/four" module:"openconfig-simple/openconfig-simple" shadow-path:"state/four" shadow-module:"openconfig-simple/openconfig-simple"` + One *string `path:"config/one" module:"openconfig-simple/openconfig-simple" shadow-path:"state/one" shadow-module:"openconfig-simple/openconfig-simple"` + Six []Binary `path:"config/six" module:"openconfig-simple/openconfig-simple" shadow-path:"state/six" shadow-module:"openconfig-simple/openconfig-simple"` + Three E_Child_Three `path:"config/three" module:"openconfig-simple/openconfig-simple" shadow-path:"state/three" shadow-module:"openconfig-simple/openconfig-simple"` + Two *string `path:"state/two" module:"openconfig-simple/openconfig-simple"` +} + +// IsYANGGoStruct ensures that Parent_Child implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Parent_Child) IsYANGGoStruct() {} + +// GetFive retrieves the value of the leaf Five from the Parent_Child +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Five is set, it can +// safely use t.GetFive() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Five == nil' before retrieving the leaf's value. +func (t *Parent_Child) GetFive() Binary { + if t == nil || t.Five == nil { + return nil + } + return t.Five +} + +// GetFour retrieves the value of the leaf Four from the Parent_Child +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Four is set, it can +// safely use t.GetFour() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Four == nil' before retrieving the leaf's value. +func (t *Parent_Child) GetFour() Binary { + if t == nil || t.Four == nil { + return nil + } + return t.Four +} + +// GetOne retrieves the value of the leaf One from the Parent_Child +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if One is set, it can +// safely use t.GetOne() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.One == nil' before retrieving the leaf's value. +func (t *Parent_Child) GetOne() string { + if t == nil || t.One == nil { + return "" + } + return *t.One +} + +// GetSix retrieves the value of the leaf Six from the Parent_Child +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Six is set, it can +// safely use t.GetSix() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Six == nil' before retrieving the leaf's value. +func (t *Parent_Child) GetSix() []Binary { + if t == nil || t.Six == nil { + return nil + } + return t.Six +} + +// GetThree retrieves the value of the leaf Three from the Parent_Child +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Three is set, it can +// safely use t.GetThree() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Three == nil' before retrieving the leaf's value. +func (t *Parent_Child) GetThree() E_Child_Three { + if t == nil || t.Three == 0 { + return 0 + } + return t.Three +} + +// GetTwo retrieves the value of the leaf Two from the Parent_Child +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if Two is set, it can +// safely use t.GetTwo() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.Two == nil' before retrieving the leaf's value. +func (t *Parent_Child) GetTwo() string { + if t == nil || t.Two == nil { + return "" + } + return *t.Two +} + +// SetFive sets the value of the leaf Five in the Parent_Child +// struct. +func (t *Parent_Child) SetFive(v Binary) { + t.Five = v +} + +// SetFour sets the value of the leaf Four in the Parent_Child +// struct. +func (t *Parent_Child) SetFour(v Binary) { + t.Four = v +} + +// SetOne sets the value of the leaf One in the Parent_Child +// struct. +func (t *Parent_Child) SetOne(v string) { + t.One = &v +} + +// SetSix sets the value of the leaf Six in the Parent_Child +// struct. +func (t *Parent_Child) SetSix(v []Binary) { + t.Six = v +} + +// SetThree sets the value of the leaf Three in the Parent_Child +// struct. +func (t *Parent_Child) SetThree(v E_Child_Three) { + t.Three = v +} + +// SetTwo sets the value of the leaf Two in the Parent_Child +// struct. +func (t *Parent_Child) SetTwo(v string) { + t.Two = &v +} + +// PopulateDefaults recursively populates unset leaf fields in the Parent_Child +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *Parent_Child) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Parent_Child) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Parent_Child"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Parent_Child) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Parent_Child) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of Parent_Child. +func (*Parent_Child) ΛBelongingModule() string { + return "openconfig-simple" +} + +// RemoteContainer represents the /openconfig-simple/remote-container YANG schema element. +type RemoteContainer struct { + ALeaf *string `path:"config/a-leaf" module:"openconfig-simple/openconfig-simple" shadow-path:"state/a-leaf" shadow-module:"openconfig-simple/openconfig-simple"` +} + +// IsYANGGoStruct ensures that RemoteContainer implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*RemoteContainer) IsYANGGoStruct() {} + +// GetALeaf retrieves the value of the leaf ALeaf from the RemoteContainer +// struct. If the field is unset but has a default value in the YANG schema, +// then the default value will be returned. +// Caution should be exercised whilst using this method since when without a +// default value, it will return the Go zero value if the field is explicitly +// unset. If the caller explicitly does not care if ALeaf is set, it can +// safely use t.GetALeaf() to retrieve the value. In the case that the +// caller has different actions based on whether the leaf is set or unset, it +// should use 'if t.ALeaf == nil' before retrieving the leaf's value. +func (t *RemoteContainer) GetALeaf() string { + if t == nil || t.ALeaf == nil { + return "" + } + return *t.ALeaf +} + +// SetALeaf sets the value of the leaf ALeaf in the RemoteContainer +// struct. +func (t *RemoteContainer) SetALeaf(v string) { + t.ALeaf = &v +} + +// PopulateDefaults recursively populates unset leaf fields in the RemoteContainer +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *RemoteContainer) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *RemoteContainer) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["RemoteContainer"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *RemoteContainer) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *RemoteContainer) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of RemoteContainer. +func (*RemoteContainer) ΛBelongingModule() string { + return "openconfig-simple" +} + +// Root represents the /root YANG schema element. +type Root struct { + A *A `path:"a" module:"openconfig-nested"` + Container *Container `path:"container" module:"openconfig-nested"` + Model *Model `path:"model" module:"openconfig-withlistval"` + Parent *Parent `path:"parent" module:"openconfig-simple"` + RemoteContainer *RemoteContainer `path:"remote-container" module:"openconfig-simple"` +} + +// IsYANGGoStruct ensures that Root implements the yang.GoStruct +// interface. This allows functions that need to handle this struct to +// identify it as being generated by ygen. +func (*Root) IsYANGGoStruct() {} + +// GetOrCreateA retrieves the value of the A field +// or returns the existing field if it already exists. +func (t *Root) GetOrCreateA() *A { + if t.A != nil { + return t.A + } + t.A = &A{} + return t.A +} + +// GetOrCreateContainer retrieves the value of the Container field +// or returns the existing field if it already exists. +func (t *Root) GetOrCreateContainer() *Container { + if t.Container != nil { + return t.Container + } + t.Container = &Container{} + return t.Container +} + +// GetOrCreateModel retrieves the value of the Model field +// or returns the existing field if it already exists. +func (t *Root) GetOrCreateModel() *Model { + if t.Model != nil { + return t.Model + } + t.Model = &Model{} + return t.Model +} + +// GetOrCreateParent retrieves the value of the Parent field +// or returns the existing field if it already exists. +func (t *Root) GetOrCreateParent() *Parent { + if t.Parent != nil { + return t.Parent + } + t.Parent = &Parent{} + return t.Parent +} + +// GetOrCreateRemoteContainer retrieves the value of the RemoteContainer field +// or returns the existing field if it already exists. +func (t *Root) GetOrCreateRemoteContainer() *RemoteContainer { + if t.RemoteContainer != nil { + return t.RemoteContainer + } + t.RemoteContainer = &RemoteContainer{} + return t.RemoteContainer +} + +// GetA returns the value of the A struct pointer +// from Root. If the receiver or the field A is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *Root) GetA() *A { + if t != nil && t.A != nil { + return t.A + } + return nil +} + +// GetContainer returns the value of the Container struct pointer +// from Root. If the receiver or the field Container is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *Root) GetContainer() *Container { + if t != nil && t.Container != nil { + return t.Container + } + return nil +} + +// GetModel returns the value of the Model struct pointer +// from Root. If the receiver or the field Model is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *Root) GetModel() *Model { + if t != nil && t.Model != nil { + return t.Model + } + return nil +} + +// GetParent returns the value of the Parent struct pointer +// from Root. If the receiver or the field Parent is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *Root) GetParent() *Parent { + if t != nil && t.Parent != nil { + return t.Parent + } + return nil +} + +// GetRemoteContainer returns the value of the RemoteContainer struct pointer +// from Root. If the receiver or the field RemoteContainer is nil, nil +// is returned such that the Get* methods can be safely chained. +func (t *Root) GetRemoteContainer() *RemoteContainer { + if t != nil && t.RemoteContainer != nil { + return t.RemoteContainer + } + return nil +} + +// PopulateDefaults recursively populates unset leaf fields in the Root +// with default values as specified in the YANG schema, instantiating any nil +// container fields. +func (t *Root) PopulateDefaults() { + if t == nil { + return + } + ygot.BuildEmptyTree(t) + t.A.PopulateDefaults() + t.Container.PopulateDefaults() + t.Model.PopulateDefaults() + t.Parent.PopulateDefaults() + t.RemoteContainer.PopulateDefaults() +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Root) ΛValidate(opts ...ygot.ValidationOption) error { + if err := ytypes.Validate(SchemaTree["Root"], t, opts...); err != nil { + return err + } + return nil +} + +// Validate validates s against the YANG schema corresponding to its type. +func (t *Root) Validate(opts ...ygot.ValidationOption) error { + return t.ΛValidate(opts...) +} + +// ΛEnumTypeMap returns a map, keyed by YANG schema path, of the enumerated types +// that are included in the generated code. +func (t *Root) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes } + +// ΛBelongingModule returns the name of the module that defines the namespace +// of Root. +func (*Root) ΛBelongingModule() string { + return "" +} diff --git a/internal/exampleocconfig/union.go b/internal/exampleocconfig/union.go new file mode 100644 index 0000000..39f06c0 --- /dev/null +++ b/internal/exampleocconfig/union.go @@ -0,0 +1,29 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* +Package exampleocconfig is a generated package which contains definitions +of structs which represent a YANG schema. The generated schema can be +compressed by a series of transformations (compression was true +in this case). + +This package was generated by ygnmi version: (devel): (ygot: v0.29.12) +using the following YANG input files: + - ../../pathgen/testdata/yang/openconfig-simple.yang + - ../../pathgen/testdata/yang/openconfig-withlistval.yang + - ../../pathgen/testdata/yang/openconfig-nested.yang + +Imported modules were sourced from: +*/ +package exampleocconfig diff --git a/internal/exampleocunordered/exampleocunorderedpath/exampleocunorderedpath.go b/internal/exampleocunordered/exampleocunorderedpath/exampleocunorderedpath.go index f4a5f7e..4dffacf 100644 --- a/internal/exampleocunordered/exampleocunorderedpath/exampleocunorderedpath.go +++ b/internal/exampleocunordered/exampleocunorderedpath/exampleocunorderedpath.go @@ -154,6 +154,7 @@ func (b *Batch) State() ygnmi.SingletonQuery[*oc.Root] { true, false, false, + false, true, false, ygnmi.NewDeviceRootBase(), @@ -179,6 +180,7 @@ func (b *Batch) Config() ygnmi.SingletonQuery[*oc.Root] { return ygnmi.NewSingletonQuery[*oc.Root]( "Root", false, + true, false, false, true, @@ -213,6 +215,7 @@ func (n *RootPath) State() ygnmi.SingletonQuery[*oc.Root] { true, false, false, + false, true, false, n, @@ -235,6 +238,7 @@ func (n *RootPath) Config() ygnmi.ConfigQuery[*oc.Root] { return ygnmi.NewConfigQuery[*oc.Root]( "Root", false, + true, false, false, true, diff --git a/internal/exampleocunordered/nested/nested-0.go b/internal/exampleocunordered/nested/nested-0.go index 4ff4a2d..c8d637a 100644 --- a/internal/exampleocunordered/nested/nested-0.go +++ b/internal/exampleocunordered/nested/nested-0.go @@ -92,6 +92,7 @@ func (n *APath) State() ygnmi.SingletonQuery[*oc.A] { true, false, false, + false, true, false, n, @@ -116,6 +117,7 @@ func (n *APathAny) State() ygnmi.WildcardQuery[*oc.A] { true, false, false, + false, true, false, n, @@ -138,6 +140,7 @@ func (n *APath) Config() ygnmi.ConfigQuery[*oc.A] { return ygnmi.NewConfigQuery[*oc.A]( "A", false, + true, false, false, true, @@ -162,6 +165,7 @@ func (n *APathAny) Config() ygnmi.WildcardQuery[*oc.A] { return ygnmi.NewWildcardQuery[*oc.A]( "A", false, + true, false, false, true, @@ -232,6 +236,7 @@ func (n *A_BPath) State() ygnmi.SingletonQuery[*oc.A_B] { true, false, false, + false, true, false, n, @@ -256,6 +261,7 @@ func (n *A_BPathAny) State() ygnmi.WildcardQuery[*oc.A_B] { true, false, false, + false, true, false, n, @@ -278,6 +284,7 @@ func (n *A_BPath) Config() ygnmi.ConfigQuery[*oc.A_B] { return ygnmi.NewConfigQuery[*oc.A_B]( "A_B", false, + true, false, false, true, @@ -302,6 +309,7 @@ func (n *A_BPathAny) Config() ygnmi.WildcardQuery[*oc.A_B] { return ygnmi.NewWildcardQuery[*oc.A_B]( "A_B", false, + true, false, false, true, @@ -372,6 +380,7 @@ func (n *A_B_CPath) State() ygnmi.SingletonQuery[*oc.A_B_C] { true, false, false, + false, true, false, n, @@ -396,6 +405,7 @@ func (n *A_B_CPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C] { true, false, false, + false, true, false, n, @@ -418,6 +428,7 @@ func (n *A_B_CPath) Config() ygnmi.ConfigQuery[*oc.A_B_C] { return ygnmi.NewConfigQuery[*oc.A_B_C]( "A_B_C", false, + true, false, false, true, @@ -442,6 +453,7 @@ func (n *A_B_CPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C] { return ygnmi.NewWildcardQuery[*oc.A_B_C]( "A_B_C", false, + true, false, false, true, @@ -512,6 +524,7 @@ func (n *A_B_C_DPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D] { true, false, false, + false, true, false, n, @@ -536,6 +549,7 @@ func (n *A_B_C_DPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D] { true, false, false, + false, true, false, n, @@ -558,6 +572,7 @@ func (n *A_B_C_DPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D] { return ygnmi.NewConfigQuery[*oc.A_B_C_D]( "A_B_C_D", false, + true, false, false, true, @@ -582,6 +597,7 @@ func (n *A_B_C_DPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D] { return ygnmi.NewWildcardQuery[*oc.A_B_C_D]( "A_B_C_D", false, + true, false, false, true, @@ -652,6 +668,7 @@ func (n *A_B_C_D_EPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E] { true, false, false, + false, true, false, n, @@ -676,6 +693,7 @@ func (n *A_B_C_D_EPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E] { true, false, false, + false, true, false, n, @@ -698,6 +716,7 @@ func (n *A_B_C_D_EPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E] { return ygnmi.NewConfigQuery[*oc.A_B_C_D_E]( "A_B_C_D_E", false, + true, false, false, true, @@ -722,6 +741,7 @@ func (n *A_B_C_D_EPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E] { return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E]( "A_B_C_D_E", false, + true, false, false, true, @@ -792,6 +812,7 @@ func (n *A_B_C_D_E_FPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F] { true, false, false, + false, true, false, n, @@ -816,6 +837,7 @@ func (n *A_B_C_D_E_FPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F] { true, false, false, + false, true, false, n, @@ -838,6 +860,7 @@ func (n *A_B_C_D_E_FPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F] { return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F]( "A_B_C_D_E_F", false, + true, false, false, true, @@ -862,6 +885,7 @@ func (n *A_B_C_D_E_FPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F] { return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F]( "A_B_C_D_E_F", false, + true, false, false, true, @@ -932,6 +956,7 @@ func (n *A_B_C_D_E_F_GPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G] { true, false, false, + false, true, false, n, @@ -956,6 +981,7 @@ func (n *A_B_C_D_E_F_GPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G] { true, false, false, + false, true, false, n, @@ -978,6 +1004,7 @@ func (n *A_B_C_D_E_F_GPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G] { return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G]( "A_B_C_D_E_F_G", false, + true, false, false, true, @@ -1002,6 +1029,7 @@ func (n *A_B_C_D_E_F_GPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G] { return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G]( "A_B_C_D_E_F_G", false, + true, false, false, true, @@ -1072,6 +1100,7 @@ func (n *A_B_C_D_E_F_G_HPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G_H] true, false, false, + false, true, false, n, @@ -1096,6 +1125,7 @@ func (n *A_B_C_D_E_F_G_HPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_H true, false, false, + false, true, false, n, @@ -1118,6 +1148,7 @@ func (n *A_B_C_D_E_F_G_HPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G_H] { return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H]( "A_B_C_D_E_F_G_H", false, + true, false, false, true, @@ -1142,6 +1173,7 @@ func (n *A_B_C_D_E_F_G_HPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G_ return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H]( "A_B_C_D_E_F_G_H", false, + true, false, false, true, @@ -1212,6 +1244,7 @@ func (n *A_B_C_D_E_F_G_H_IPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G_H true, false, false, + false, true, false, n, @@ -1236,6 +1269,7 @@ func (n *A_B_C_D_E_F_G_H_IPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_G true, false, false, + false, true, false, n, @@ -1258,6 +1292,7 @@ func (n *A_B_C_D_E_F_G_H_IPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G_H_I return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I]( "A_B_C_D_E_F_G_H_I", false, + true, false, false, true, @@ -1282,6 +1317,7 @@ func (n *A_B_C_D_E_F_G_H_IPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F_ return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I]( "A_B_C_D_E_F_G_H_I", false, + true, false, false, true, @@ -1352,6 +1388,7 @@ func (n *A_B_C_D_E_F_G_H_I_JPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F_G true, false, false, + false, true, false, n, @@ -1376,6 +1413,7 @@ func (n *A_B_C_D_E_F_G_H_I_JPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E_F true, false, false, + false, true, false, n, @@ -1398,6 +1436,7 @@ func (n *A_B_C_D_E_F_G_H_I_JPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G_H return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J]( "A_B_C_D_E_F_G_H_I_J", false, + true, false, false, true, @@ -1422,6 +1461,7 @@ func (n *A_B_C_D_E_F_G_H_I_JPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_E_ return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J]( "A_B_C_D_E_F_G_H_I_J", false, + true, false, false, true, @@ -1492,6 +1532,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_KPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E_F true, false, false, + false, true, false, n, @@ -1516,6 +1557,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_KPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D_E true, false, false, + false, true, false, n, @@ -1538,6 +1580,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_KPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F_G return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J_K]( "A_B_C_D_E_F_G_H_I_J_K", false, + true, false, false, true, @@ -1562,6 +1605,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_KPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_D_ return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K]( "A_B_C_D_E_F_G_H_I_J_K", false, + true, false, false, true, @@ -1632,6 +1676,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_LPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D_E true, false, false, + false, true, false, n, @@ -1656,6 +1701,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_LPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C_D true, false, false, + false, true, false, n, @@ -1678,6 +1724,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_LPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E_F return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L]( "A_B_C_D_E_F_G_H_I_J_K_L", false, + true, false, false, true, @@ -1702,6 +1749,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_LPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_C_ return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L]( "A_B_C_D_E_F_G_H_I_J_K_L", false, + true, false, false, true, @@ -1743,6 +1791,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_L_M_FooPath) State() ygnmi.SingletonQuery[string] return ygnmi.NewSingletonQuery[string]( "A_B_C_D_E_F_G_H_I_J_K_L_M", true, + false, true, true, true, @@ -1783,6 +1832,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_L_M_FooPathAny) State() ygnmi.WildcardQuery[strin return ygnmi.NewWildcardQuery[string]( "A_B_C_D_E_F_G_H_I_J_K_L_M", true, + false, true, true, true, @@ -1866,6 +1916,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_L_MPath) State() ygnmi.SingletonQuery[*oc.A_B_C_D true, false, false, + false, true, false, n, @@ -1890,6 +1941,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_L_MPathAny) State() ygnmi.WildcardQuery[*oc.A_B_C true, false, false, + false, true, false, n, @@ -1912,6 +1964,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_L_MPath) Config() ygnmi.ConfigQuery[*oc.A_B_C_D_E return ygnmi.NewConfigQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L_M]( "A_B_C_D_E_F_G_H_I_J_K_L_M", false, + true, false, false, true, @@ -1936,6 +1989,7 @@ func (n *A_B_C_D_E_F_G_H_I_J_K_L_MPathAny) Config() ygnmi.WildcardQuery[*oc.A_B_ return ygnmi.NewWildcardQuery[*oc.A_B_C_D_E_F_G_H_I_J_K_L_M]( "A_B_C_D_E_F_G_H_I_J_K_L_M", false, + true, false, false, true, @@ -1977,6 +2031,7 @@ func (n *Container_EnabledPath) State() ygnmi.SingletonQuery[bool] { return ygnmi.NewSingletonQuery[bool]( "Container", true, + false, true, true, true, @@ -2017,6 +2072,7 @@ func (n *Container_EnabledPathAny) State() ygnmi.WildcardQuery[bool] { return ygnmi.NewWildcardQuery[bool]( "Container", true, + false, true, true, true, @@ -2100,6 +2156,7 @@ func (n *ContainerPath) State() ygnmi.SingletonQuery[*oc.Container] { true, false, false, + false, true, false, n, @@ -2124,6 +2181,7 @@ func (n *ContainerPathAny) State() ygnmi.WildcardQuery[*oc.Container] { true, false, false, + false, true, false, n, @@ -2146,6 +2204,7 @@ func (n *ContainerPath) Config() ygnmi.ConfigQuery[*oc.Container] { return ygnmi.NewConfigQuery[*oc.Container]( "Container", false, + true, false, false, true, @@ -2170,6 +2229,7 @@ func (n *ContainerPathAny) Config() ygnmi.WildcardQuery[*oc.Container] { return ygnmi.NewWildcardQuery[*oc.Container]( "Container", false, + true, false, false, true, diff --git a/internal/exampleocunordered/simple/simple-0.go b/internal/exampleocunordered/simple/simple-0.go index 9a6a2c7..89311ad 100644 --- a/internal/exampleocunordered/simple/simple-0.go +++ b/internal/exampleocunordered/simple/simple-0.go @@ -94,6 +94,7 @@ func (n *ParentPath) State() ygnmi.SingletonQuery[*oc.Parent] { true, false, false, + false, true, false, n, @@ -118,6 +119,7 @@ func (n *ParentPathAny) State() ygnmi.WildcardQuery[*oc.Parent] { true, false, false, + false, true, false, n, @@ -140,6 +142,7 @@ func (n *ParentPath) Config() ygnmi.ConfigQuery[*oc.Parent] { return ygnmi.NewConfigQuery[*oc.Parent]( "Parent", false, + true, false, false, true, @@ -164,6 +167,7 @@ func (n *ParentPathAny) Config() ygnmi.WildcardQuery[*oc.Parent] { return ygnmi.NewWildcardQuery[*oc.Parent]( "Parent", false, + true, false, false, true, @@ -205,6 +209,7 @@ func (n *Parent_Child_FivePath) State() ygnmi.SingletonQuery[float32] { return ygnmi.NewSingletonQuery[float32]( "Parent_Child", true, + false, true, false, true, @@ -241,6 +246,7 @@ func (n *Parent_Child_FivePathAny) State() ygnmi.WildcardQuery[float32] { return ygnmi.NewWildcardQuery[float32]( "Parent_Child", true, + false, true, false, true, @@ -278,6 +284,7 @@ func (n *Parent_Child_FivePath) Config() ygnmi.ConfigQuery[float32] { "Parent_Child", false, true, + true, false, true, false, @@ -314,6 +321,7 @@ func (n *Parent_Child_FivePathAny) Config() ygnmi.WildcardQuery[float32] { "Parent_Child", false, true, + true, false, true, false, @@ -361,6 +369,7 @@ func (n *Parent_Child_FourPath) State() ygnmi.SingletonQuery[oc.Binary] { return ygnmi.NewSingletonQuery[oc.Binary]( "Parent_Child", true, + false, true, false, true, @@ -397,6 +406,7 @@ func (n *Parent_Child_FourPathAny) State() ygnmi.WildcardQuery[oc.Binary] { return ygnmi.NewWildcardQuery[oc.Binary]( "Parent_Child", true, + false, true, false, true, @@ -434,6 +444,7 @@ func (n *Parent_Child_FourPath) Config() ygnmi.ConfigQuery[oc.Binary] { "Parent_Child", false, true, + true, false, true, false, @@ -470,6 +481,7 @@ func (n *Parent_Child_FourPathAny) Config() ygnmi.WildcardQuery[oc.Binary] { "Parent_Child", false, true, + true, false, true, false, @@ -517,6 +529,7 @@ func (n *Parent_Child_OnePath) State() ygnmi.SingletonQuery[string] { return ygnmi.NewSingletonQuery[string]( "Parent_Child", true, + false, true, true, true, @@ -557,6 +570,7 @@ func (n *Parent_Child_OnePathAny) State() ygnmi.WildcardQuery[string] { return ygnmi.NewWildcardQuery[string]( "Parent_Child", true, + false, true, true, true, @@ -600,6 +614,7 @@ func (n *Parent_Child_OnePath) Config() ygnmi.ConfigQuery[string] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "one"}, @@ -640,6 +655,7 @@ func (n *Parent_Child_OnePathAny) Config() ygnmi.WildcardQuery[string] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "one"}, @@ -689,6 +705,7 @@ func (n *Parent_Child_SixPath) State() ygnmi.SingletonQuery[[]float32] { return ygnmi.NewSingletonQuery[[]float32]( "Parent_Child", true, + false, true, false, true, @@ -725,6 +742,7 @@ func (n *Parent_Child_SixPathAny) State() ygnmi.WildcardQuery[[]float32] { return ygnmi.NewWildcardQuery[[]float32]( "Parent_Child", true, + false, true, false, true, @@ -762,6 +780,7 @@ func (n *Parent_Child_SixPath) Config() ygnmi.ConfigQuery[[]float32] { "Parent_Child", false, true, + true, false, true, false, @@ -798,6 +817,7 @@ func (n *Parent_Child_SixPathAny) Config() ygnmi.WildcardQuery[[]float32] { "Parent_Child", false, true, + true, false, true, false, @@ -845,6 +865,7 @@ func (n *Parent_Child_ThreePath) State() ygnmi.SingletonQuery[oc.E_Child_Three] return ygnmi.NewSingletonQuery[oc.E_Child_Three]( "Parent_Child", true, + false, true, false, true, @@ -881,6 +902,7 @@ func (n *Parent_Child_ThreePathAny) State() ygnmi.WildcardQuery[oc.E_Child_Three return ygnmi.NewWildcardQuery[oc.E_Child_Three]( "Parent_Child", true, + false, true, false, true, @@ -918,6 +940,7 @@ func (n *Parent_Child_ThreePath) Config() ygnmi.ConfigQuery[oc.E_Child_Three] { "Parent_Child", false, true, + true, false, true, false, @@ -954,6 +977,7 @@ func (n *Parent_Child_ThreePathAny) Config() ygnmi.WildcardQuery[oc.E_Child_Thre "Parent_Child", false, true, + true, false, true, false, @@ -1001,6 +1025,7 @@ func (n *Parent_Child_TwoPath) State() ygnmi.SingletonQuery[string] { return ygnmi.NewSingletonQuery[string]( "Parent_Child", true, + false, true, true, true, @@ -1041,6 +1066,7 @@ func (n *Parent_Child_TwoPathAny) State() ygnmi.WildcardQuery[string] { return ygnmi.NewWildcardQuery[string]( "Parent_Child", true, + false, true, true, true, @@ -1304,6 +1330,7 @@ func (n *Parent_ChildPath) State() ygnmi.SingletonQuery[*oc.Parent_Child] { true, false, false, + false, true, false, n, @@ -1328,6 +1355,7 @@ func (n *Parent_ChildPathAny) State() ygnmi.WildcardQuery[*oc.Parent_Child] { true, false, false, + false, true, false, n, @@ -1350,6 +1378,7 @@ func (n *Parent_ChildPath) Config() ygnmi.ConfigQuery[*oc.Parent_Child] { return ygnmi.NewConfigQuery[*oc.Parent_Child]( "Parent_Child", false, + true, false, false, true, @@ -1374,6 +1403,7 @@ func (n *Parent_ChildPathAny) Config() ygnmi.WildcardQuery[*oc.Parent_Child] { return ygnmi.NewWildcardQuery[*oc.Parent_Child]( "Parent_Child", false, + true, false, false, true, @@ -1415,6 +1445,7 @@ func (n *RemoteContainer_ALeafPath) State() ygnmi.SingletonQuery[string] { return ygnmi.NewSingletonQuery[string]( "RemoteContainer", true, + false, true, true, true, @@ -1455,6 +1486,7 @@ func (n *RemoteContainer_ALeafPathAny) State() ygnmi.WildcardQuery[string] { return ygnmi.NewWildcardQuery[string]( "RemoteContainer", true, + false, true, true, true, @@ -1498,6 +1530,7 @@ func (n *RemoteContainer_ALeafPath) Config() ygnmi.ConfigQuery[string] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "a-leaf"}, @@ -1538,6 +1571,7 @@ func (n *RemoteContainer_ALeafPathAny) Config() ygnmi.WildcardQuery[string] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "a-leaf"}, @@ -1618,6 +1652,7 @@ func (n *RemoteContainerPath) State() ygnmi.SingletonQuery[*oc.RemoteContainer] true, false, false, + false, true, false, n, @@ -1642,6 +1677,7 @@ func (n *RemoteContainerPathAny) State() ygnmi.WildcardQuery[*oc.RemoteContainer true, false, false, + false, true, false, n, @@ -1664,6 +1700,7 @@ func (n *RemoteContainerPath) Config() ygnmi.ConfigQuery[*oc.RemoteContainer] { return ygnmi.NewConfigQuery[*oc.RemoteContainer]( "RemoteContainer", false, + true, false, false, true, @@ -1688,6 +1725,7 @@ func (n *RemoteContainerPathAny) Config() ygnmi.WildcardQuery[*oc.RemoteContaine return ygnmi.NewWildcardQuery[*oc.RemoteContainer]( "RemoteContainer", false, + true, false, false, true, diff --git a/internal/exampleocunordered/withlistval/withlistval-0.go b/internal/exampleocunordered/withlistval/withlistval-0.go index 6872f37..4666413 100644 --- a/internal/exampleocunordered/withlistval/withlistval-0.go +++ b/internal/exampleocunordered/withlistval/withlistval-0.go @@ -254,6 +254,7 @@ func (n *ModelPath) State() ygnmi.SingletonQuery[*oc.Model] { true, false, false, + false, true, false, n, @@ -278,6 +279,7 @@ func (n *ModelPathAny) State() ygnmi.WildcardQuery[*oc.Model] { true, false, false, + false, true, false, n, @@ -300,6 +302,7 @@ func (n *ModelPath) Config() ygnmi.ConfigQuery[*oc.Model] { return ygnmi.NewConfigQuery[*oc.Model]( "Model", false, + true, false, false, true, @@ -324,6 +327,7 @@ func (n *ModelPathAny) Config() ygnmi.WildcardQuery[*oc.Model] { return ygnmi.NewWildcardQuery[*oc.Model]( "Model", false, + true, false, false, true, @@ -365,6 +369,7 @@ func (n *Model_MultiKey_Key1Path) State() ygnmi.SingletonQuery[uint32] { return ygnmi.NewSingletonQuery[uint32]( "Model_MultiKey", true, + false, true, true, true, @@ -405,6 +410,7 @@ func (n *Model_MultiKey_Key1PathAny) State() ygnmi.WildcardQuery[uint32] { return ygnmi.NewWildcardQuery[uint32]( "Model_MultiKey", true, + false, true, true, true, @@ -448,6 +454,7 @@ func (n *Model_MultiKey_Key1Path) Config() ygnmi.ConfigQuery[uint32] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key1"}, @@ -488,6 +495,7 @@ func (n *Model_MultiKey_Key1PathAny) Config() ygnmi.WildcardQuery[uint32] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key1"}, @@ -537,6 +545,7 @@ func (n *Model_MultiKey_Key2Path) State() ygnmi.SingletonQuery[uint64] { return ygnmi.NewSingletonQuery[uint64]( "Model_MultiKey", true, + false, true, true, true, @@ -577,6 +586,7 @@ func (n *Model_MultiKey_Key2PathAny) State() ygnmi.WildcardQuery[uint64] { return ygnmi.NewWildcardQuery[uint64]( "Model_MultiKey", true, + false, true, true, true, @@ -620,6 +630,7 @@ func (n *Model_MultiKey_Key2Path) Config() ygnmi.ConfigQuery[uint64] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key2"}, @@ -660,6 +671,7 @@ func (n *Model_MultiKey_Key2PathAny) Config() ygnmi.WildcardQuery[uint64] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key2"}, @@ -786,6 +798,7 @@ func (n *Model_MultiKeyPath) State() ygnmi.SingletonQuery[*oc.Model_MultiKey] { true, false, false, + false, true, false, n, @@ -810,6 +823,7 @@ func (n *Model_MultiKeyPathAny) State() ygnmi.WildcardQuery[*oc.Model_MultiKey] true, false, false, + false, true, false, n, @@ -832,6 +846,7 @@ func (n *Model_MultiKeyPath) Config() ygnmi.ConfigQuery[*oc.Model_MultiKey] { return ygnmi.NewConfigQuery[*oc.Model_MultiKey]( "Model_MultiKey", false, + true, false, false, true, @@ -856,6 +871,7 @@ func (n *Model_MultiKeyPathAny) Config() ygnmi.WildcardQuery[*oc.Model_MultiKey] return ygnmi.NewWildcardQuery[*oc.Model_MultiKey]( "Model_MultiKey", false, + true, false, false, true, @@ -892,6 +908,7 @@ func (n *Model_NoKeyPath) State() ygnmi.SingletonQuery[*oc.Model_NoKey] { true, false, false, + false, true, false, n, @@ -916,6 +933,7 @@ func (n *Model_NoKeyPathAny) State() ygnmi.WildcardQuery[*oc.Model_NoKey] { true, false, false, + false, true, false, n, @@ -955,6 +973,7 @@ func (n *Model_NoKey_Foo_KeyPath) State() ygnmi.SingletonQuery[string] { return ygnmi.NewSingletonQuery[string]( "Model_NoKey_Foo", true, + false, true, true, true, @@ -995,6 +1014,7 @@ func (n *Model_NoKey_Foo_KeyPathAny) State() ygnmi.WildcardQuery[string] { return ygnmi.NewWildcardQuery[string]( "Model_NoKey_Foo", true, + false, true, true, true, @@ -1047,6 +1067,7 @@ func (n *Model_NoKey_Foo_ValuePath) State() ygnmi.SingletonQuery[int64] { return ygnmi.NewSingletonQuery[int64]( "Model_NoKey_Foo", true, + false, true, true, true, @@ -1087,6 +1108,7 @@ func (n *Model_NoKey_Foo_ValuePathAny) State() ygnmi.WildcardQuery[int64] { return ygnmi.NewWildcardQuery[int64]( "Model_NoKey_Foo", true, + false, true, true, true, @@ -1206,6 +1228,7 @@ func (n *Model_NoKey_FooPath) State() ygnmi.SingletonQuery[*oc.Model_NoKey_Foo] true, false, false, + false, true, false, n, @@ -1230,6 +1253,7 @@ func (n *Model_NoKey_FooPathAny) State() ygnmi.WildcardQuery[*oc.Model_NoKey_Foo true, false, false, + false, true, false, n, @@ -1269,6 +1293,7 @@ func (n *Model_SingleKey_CounterPath) State() ygnmi.SingletonQuery[float32] { return ygnmi.NewSingletonQuery[float32]( "Model_SingleKey", true, + false, true, false, true, @@ -1305,6 +1330,7 @@ func (n *Model_SingleKey_CounterPathAny) State() ygnmi.WildcardQuery[float32] { return ygnmi.NewWildcardQuery[float32]( "Model_SingleKey", true, + false, true, false, true, @@ -1353,6 +1379,7 @@ func (n *Model_SingleKey_CountersPath) State() ygnmi.SingletonQuery[[]float32] { return ygnmi.NewSingletonQuery[[]float32]( "Model_SingleKey", true, + false, true, false, true, @@ -1389,6 +1416,7 @@ func (n *Model_SingleKey_CountersPathAny) State() ygnmi.WildcardQuery[[]float32] return ygnmi.NewWildcardQuery[[]float32]( "Model_SingleKey", true, + false, true, false, true, @@ -1437,6 +1465,7 @@ func (n *Model_SingleKey_KeyPath) State() ygnmi.SingletonQuery[string] { return ygnmi.NewSingletonQuery[string]( "Model_SingleKey", true, + false, true, true, true, @@ -1477,6 +1506,7 @@ func (n *Model_SingleKey_KeyPathAny) State() ygnmi.WildcardQuery[string] { return ygnmi.NewWildcardQuery[string]( "Model_SingleKey", true, + false, true, true, true, @@ -1520,6 +1550,7 @@ func (n *Model_SingleKey_KeyPath) Config() ygnmi.ConfigQuery[string] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key"}, @@ -1560,6 +1591,7 @@ func (n *Model_SingleKey_KeyPathAny) Config() ygnmi.WildcardQuery[string] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key"}, @@ -1609,6 +1641,7 @@ func (n *Model_SingleKey_ValuePath) State() ygnmi.SingletonQuery[int64] { return ygnmi.NewSingletonQuery[int64]( "Model_SingleKey", true, + false, true, true, true, @@ -1649,6 +1682,7 @@ func (n *Model_SingleKey_ValuePathAny) State() ygnmi.WildcardQuery[int64] { return ygnmi.NewWildcardQuery[int64]( "Model_SingleKey", true, + false, true, true, true, @@ -1692,6 +1726,7 @@ func (n *Model_SingleKey_ValuePath) Config() ygnmi.ConfigQuery[int64] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "value"}, @@ -1732,6 +1767,7 @@ func (n *Model_SingleKey_ValuePathAny) Config() ygnmi.WildcardQuery[int64] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "value"}, @@ -2074,6 +2110,7 @@ func (n *Model_SingleKeyPath) State() ygnmi.SingletonQuery[*oc.Model_SingleKey] true, false, false, + false, true, false, n, @@ -2098,6 +2135,7 @@ func (n *Model_SingleKeyPathAny) State() ygnmi.WildcardQuery[*oc.Model_SingleKey true, false, false, + false, true, false, n, @@ -2120,6 +2158,7 @@ func (n *Model_SingleKeyPath) Config() ygnmi.ConfigQuery[*oc.Model_SingleKey] { return ygnmi.NewConfigQuery[*oc.Model_SingleKey]( "Model_SingleKey", false, + true, false, false, true, @@ -2144,6 +2183,7 @@ func (n *Model_SingleKeyPathAny) Config() ygnmi.WildcardQuery[*oc.Model_SingleKe return ygnmi.NewWildcardQuery[*oc.Model_SingleKey]( "Model_SingleKey", false, + true, false, false, true, @@ -2185,6 +2225,7 @@ func (n *Model_SingleKey_OrderedList_KeyPath) State() ygnmi.SingletonQuery[strin return ygnmi.NewSingletonQuery[string]( "Model_SingleKey_OrderedList", true, + false, true, true, true, @@ -2225,6 +2266,7 @@ func (n *Model_SingleKey_OrderedList_KeyPathAny) State() ygnmi.WildcardQuery[str return ygnmi.NewWildcardQuery[string]( "Model_SingleKey_OrderedList", true, + false, true, true, true, @@ -2268,6 +2310,7 @@ func (n *Model_SingleKey_OrderedList_KeyPath) Config() ygnmi.ConfigQuery[string] true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key"}, @@ -2308,6 +2351,7 @@ func (n *Model_SingleKey_OrderedList_KeyPathAny) Config() ygnmi.WildcardQuery[st true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key"}, @@ -2357,6 +2401,7 @@ func (n *Model_SingleKey_OrderedList_ValuePath) State() ygnmi.SingletonQuery[int return ygnmi.NewSingletonQuery[int64]( "Model_SingleKey_OrderedList", true, + false, true, true, true, @@ -2397,6 +2442,7 @@ func (n *Model_SingleKey_OrderedList_ValuePathAny) State() ygnmi.WildcardQuery[i return ygnmi.NewWildcardQuery[int64]( "Model_SingleKey_OrderedList", true, + false, true, true, true, @@ -2440,6 +2486,7 @@ func (n *Model_SingleKey_OrderedList_ValuePath) Config() ygnmi.ConfigQuery[int64 true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "value"}, @@ -2480,6 +2527,7 @@ func (n *Model_SingleKey_OrderedList_ValuePathAny) Config() ygnmi.WildcardQuery[ true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "value"}, @@ -2606,6 +2654,7 @@ func (n *Model_SingleKey_OrderedListPath) State() ygnmi.SingletonQuery[*oc.Model true, false, false, + false, true, false, n, @@ -2630,6 +2679,7 @@ func (n *Model_SingleKey_OrderedListPathAny) State() ygnmi.WildcardQuery[*oc.Mod true, false, false, + false, true, false, n, @@ -2652,6 +2702,7 @@ func (n *Model_SingleKey_OrderedListPath) Config() ygnmi.ConfigQuery[*oc.Model_S return ygnmi.NewConfigQuery[*oc.Model_SingleKey_OrderedList]( "Model_SingleKey_OrderedList", false, + true, false, false, true, @@ -2676,6 +2727,7 @@ func (n *Model_SingleKey_OrderedListPathAny) Config() ygnmi.WildcardQuery[*oc.Mo return ygnmi.NewWildcardQuery[*oc.Model_SingleKey_OrderedList]( "Model_SingleKey_OrderedList", false, + true, false, false, true, @@ -2717,6 +2769,7 @@ func (n *Model_SingleKey_SingleKey_KeyPath) State() ygnmi.SingletonQuery[string] return ygnmi.NewSingletonQuery[string]( "Model_SingleKey_SingleKey", true, + false, true, true, true, @@ -2757,6 +2810,7 @@ func (n *Model_SingleKey_SingleKey_KeyPathAny) State() ygnmi.WildcardQuery[strin return ygnmi.NewWildcardQuery[string]( "Model_SingleKey_SingleKey", true, + false, true, true, true, @@ -2800,6 +2854,7 @@ func (n *Model_SingleKey_SingleKey_KeyPath) Config() ygnmi.ConfigQuery[string] { true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key"}, @@ -2840,6 +2895,7 @@ func (n *Model_SingleKey_SingleKey_KeyPathAny) Config() ygnmi.WildcardQuery[stri true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "key"}, @@ -2889,6 +2945,7 @@ func (n *Model_SingleKey_SingleKey_ValuePath) State() ygnmi.SingletonQuery[int64 return ygnmi.NewSingletonQuery[int64]( "Model_SingleKey_SingleKey", true, + false, true, true, true, @@ -2929,6 +2986,7 @@ func (n *Model_SingleKey_SingleKey_ValuePathAny) State() ygnmi.WildcardQuery[int return ygnmi.NewWildcardQuery[int64]( "Model_SingleKey_SingleKey", true, + false, true, true, true, @@ -2972,6 +3030,7 @@ func (n *Model_SingleKey_SingleKey_ValuePath) Config() ygnmi.ConfigQuery[int64] true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "value"}, @@ -3012,6 +3071,7 @@ func (n *Model_SingleKey_SingleKey_ValuePathAny) Config() ygnmi.WildcardQuery[in true, true, true, + true, false, ygnmi.NewNodePath( []string{"config", "value"}, @@ -3138,6 +3198,7 @@ func (n *Model_SingleKey_SingleKeyPath) State() ygnmi.SingletonQuery[*oc.Model_S true, false, false, + false, true, false, n, @@ -3162,6 +3223,7 @@ func (n *Model_SingleKey_SingleKeyPathAny) State() ygnmi.WildcardQuery[*oc.Model true, false, false, + false, true, false, n, @@ -3184,6 +3246,7 @@ func (n *Model_SingleKey_SingleKeyPath) Config() ygnmi.ConfigQuery[*oc.Model_Sin return ygnmi.NewConfigQuery[*oc.Model_SingleKey_SingleKey]( "Model_SingleKey_SingleKey", false, + true, false, false, true, @@ -3208,6 +3271,7 @@ func (n *Model_SingleKey_SingleKeyPathAny) Config() ygnmi.WildcardQuery[*oc.Mode return ygnmi.NewWildcardQuery[*oc.Model_SingleKey_SingleKey]( "Model_SingleKey_SingleKey", false, + true, false, false, true, diff --git a/internal/uexampleoc/a/a-0.go b/internal/uexampleoc/a/a-0.go index 567cff6..52be2d2 100644 --- a/internal/uexampleoc/a/a-0.go +++ b/internal/uexampleoc/a/a-0.go @@ -68,6 +68,7 @@ func (n *OpenconfigWithlistval_Model_APath) SingleKeyAny() *OpenconfigWithlistva false, false, false, + false, ps, nil, nil, @@ -106,6 +107,7 @@ func (n *OpenconfigWithlistval_Model_APathAny) SingleKeyAny() *OpenconfigWithlis false, false, false, + false, ps, nil, nil, @@ -146,6 +148,7 @@ func (n *OpenconfigWithlistval_Model_APath) SingleKey(Key string) *OpenconfigWit false, false, false, + false, ps, nil, nil, @@ -186,6 +189,7 @@ func (n *OpenconfigWithlistval_Model_APathAny) SingleKey(Key string) *Openconfig false, false, false, + false, ps, nil, nil, @@ -223,6 +227,7 @@ func (n *OpenconfigWithlistval_Model_APath) SingleKeyMap() *OpenconfigWithlistva false, false, false, + false, true, ps, func(gs ygot.ValidatedGoStruct) (map[string]*oc.OpenconfigWithlistval_Model_A_SingleKey, bool) { @@ -264,6 +269,7 @@ func (n *OpenconfigWithlistval_Model_APathAny) SingleKeyMap() *OpenconfigWithlis false, false, false, + false, true, ps, func(gs ygot.ValidatedGoStruct) (map[string]*oc.OpenconfigWithlistval_Model_A_SingleKey, bool) { @@ -352,6 +358,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKeyPath) Config() *OpenconfigWithli false, false, false, + false, ps, nil, nil, @@ -390,6 +397,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKeyPathAny) Config() *OpenconfigWit false, false, false, + false, ps, nil, nil, @@ -428,6 +436,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKeyPath) InnerA() *OpenconfigWithli false, false, false, + false, ps, nil, nil, @@ -466,6 +475,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKeyPathAny) InnerA() *OpenconfigWit false, false, false, + false, ps, nil, nil, @@ -501,6 +511,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKeyPath) Key() *OpenconfigWithlistv ps.ConfigQuery = ygnmi.NewConfigQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey", true, + false, true, true, false, @@ -547,6 +558,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKeyPathAny) Key() *OpenconfigWithli ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey", true, + false, true, true, false, @@ -596,6 +608,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKeyPath) OrderedLists() *Openconfig false, false, false, + false, ps, nil, nil, @@ -634,6 +647,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKeyPathAny) OrderedLists() *Opencon false, false, false, + false, ps, nil, nil, @@ -672,6 +686,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKeyPath) State() *OpenconfigWithlis false, false, false, + false, ps, nil, nil, @@ -710,6 +725,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKeyPathAny) State() *OpenconfigWith false, false, false, + false, ps, nil, nil, @@ -785,6 +801,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_ConfigPath) Key() *OpenconfigWi ps.ConfigQuery = ygnmi.NewConfigQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey_Config", true, + false, true, true, false, @@ -831,6 +848,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_ConfigPathAny) Key() *Openconfi ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey_Config", true, + false, true, true, false, @@ -877,6 +895,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_ConfigPath) Value() *Openconfig ps.ConfigQuery = ygnmi.NewConfigQuery[int64]( "OpenconfigWithlistval_Model_A_SingleKey_Config", true, + false, true, true, false, @@ -923,6 +942,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_ConfigPathAny) Value() *Opencon ps.WildcardQuery = ygnmi.NewWildcardQuery[int64]( "OpenconfigWithlistval_Model_A_SingleKey_Config", true, + false, true, true, false, @@ -1022,6 +1042,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKeyPath) Config() false, false, false, + false, ps, nil, nil, @@ -1060,6 +1081,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKeyPathAny) Config false, false, false, + false, ps, nil, nil, @@ -1095,6 +1117,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKeyPath) Key() *Op ps.ConfigQuery = ygnmi.NewConfigQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey", true, + false, true, true, false, @@ -1141,6 +1164,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKeyPathAny) Key() ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey", true, + false, true, true, false, @@ -1190,6 +1214,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKeyPath) State() * false, false, false, + false, ps, nil, nil, @@ -1228,6 +1253,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKeyPathAny) State( false, false, false, + false, ps, nil, nil, @@ -1303,6 +1329,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_ConfigPath) Ke ps.ConfigQuery = ygnmi.NewConfigQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_Config", true, + false, true, true, false, @@ -1351,6 +1378,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_ConfigPathAny) ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_Config", true, + false, true, true, false, @@ -1399,6 +1427,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_ConfigPath) Va ps.ConfigQuery = ygnmi.NewConfigQuery[int64]( "OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_Config", true, + false, true, true, false, @@ -1447,6 +1476,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_ConfigPathAny) ps.WildcardQuery = ygnmi.NewWildcardQuery[int64]( "OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_Config", true, + false, true, true, false, @@ -1535,6 +1565,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_StatePath) Key ps.SingletonQuery = ygnmi.NewSingletonQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_State", true, + false, true, true, false, @@ -1583,6 +1614,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_StatePathAny) ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_State", true, + false, true, true, false, @@ -1631,6 +1663,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_StatePath) Val ps.SingletonQuery = ygnmi.NewSingletonQuery[int64]( "OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_State", true, + false, true, true, false, @@ -1679,6 +1712,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_StatePathAny) ps.WildcardQuery = ygnmi.NewWildcardQuery[int64]( "OpenconfigWithlistval_Model_A_SingleKey_InnerA_SingleKey_State", true, + false, true, true, false, @@ -1741,6 +1775,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_OrderedListsPath) OrderedListMa false, false, false, + false, true, ps, func(gs ygot.ValidatedGoStruct) (*oc.OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_OrderedMap, bool) { @@ -1782,6 +1817,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_OrderedListsPathAny) OrderedLis false, false, false, + false, true, ps, func(gs ygot.ValidatedGoStruct) (*oc.OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_OrderedMap, bool) { @@ -1883,6 +1919,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_Config ps.ConfigQuery = ygnmi.NewConfigQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_Config", true, + false, true, true, false, @@ -1931,6 +1968,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_Config ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_Config", true, + false, true, true, false, @@ -1979,6 +2017,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_Config ps.ConfigQuery = ygnmi.NewConfigQuery[int64]( "OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_Config", true, + false, true, true, false, @@ -2027,6 +2066,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_Config ps.WildcardQuery = ygnmi.NewWildcardQuery[int64]( "OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_Config", true, + false, true, true, false, @@ -2115,6 +2155,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_StateP ps.SingletonQuery = ygnmi.NewSingletonQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_State", true, + false, true, true, false, @@ -2163,6 +2204,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_StateP ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_State", true, + false, true, true, false, @@ -2211,6 +2253,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_StateP ps.SingletonQuery = ygnmi.NewSingletonQuery[int64]( "OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_State", true, + false, true, true, false, @@ -2259,6 +2302,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_StateP ps.WildcardQuery = ygnmi.NewWildcardQuery[int64]( "OpenconfigWithlistval_Model_A_SingleKey_OrderedLists_OrderedList_State", true, + false, true, true, false, @@ -2375,6 +2419,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_StatePath) Counter() *Openconfi ps.SingletonQuery = ygnmi.NewSingletonQuery[float32]( "OpenconfigWithlistval_Model_A_SingleKey_State", true, + false, true, false, false, @@ -2417,6 +2462,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_StatePathAny) Counter() *Openco ps.WildcardQuery = ygnmi.NewWildcardQuery[float32]( "OpenconfigWithlistval_Model_A_SingleKey_State", true, + false, true, false, false, @@ -2459,6 +2505,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_StatePath) Counters() *Openconf ps.SingletonQuery = ygnmi.NewSingletonQuery[[]float32]( "OpenconfigWithlistval_Model_A_SingleKey_State", true, + false, true, false, false, @@ -2501,6 +2548,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_StatePathAny) Counters() *Openc ps.WildcardQuery = ygnmi.NewWildcardQuery[[]float32]( "OpenconfigWithlistval_Model_A_SingleKey_State", true, + false, true, false, false, @@ -2543,6 +2591,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_StatePath) Key() *OpenconfigWit ps.SingletonQuery = ygnmi.NewSingletonQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey_State", true, + false, true, true, false, @@ -2589,6 +2638,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_StatePathAny) Key() *Openconfig ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigWithlistval_Model_A_SingleKey_State", true, + false, true, true, false, @@ -2635,6 +2685,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_StatePath) Value() *OpenconfigW ps.SingletonQuery = ygnmi.NewSingletonQuery[int64]( "OpenconfigWithlistval_Model_A_SingleKey_State", true, + false, true, true, false, @@ -2681,6 +2732,7 @@ func (n *OpenconfigWithlistval_Model_A_SingleKey_StatePathAny) Value() *Openconf ps.WildcardQuery = ygnmi.NewWildcardQuery[int64]( "OpenconfigWithlistval_Model_A_SingleKey_State", true, + false, true, true, false, diff --git a/internal/uexampleoc/modelb/modelb-0.go b/internal/uexampleoc/modelb/modelb-0.go index 775ab46..7eeb52e 100644 --- a/internal/uexampleoc/modelb/modelb-0.go +++ b/internal/uexampleoc/modelb/modelb-0.go @@ -66,6 +66,7 @@ func (n *OpenconfigWithlistval_Model_BPath) MultiKeyAny() *OpenconfigWithlistval false, false, false, + false, ps, nil, nil, @@ -104,6 +105,7 @@ func (n *OpenconfigWithlistval_Model_BPathAny) MultiKeyAny() *OpenconfigWithlist false, false, false, + false, ps, nil, nil, @@ -159,6 +161,7 @@ func (n *OpenconfigWithlistval_Model_BPath) MultiKey(Key1 uint32, Key2 uint64) * false, false, false, + false, ps, nil, nil, @@ -200,6 +203,7 @@ func (n *OpenconfigWithlistval_Model_BPathAny) MultiKey(Key1 uint32, Key2 uint64 false, false, false, + false, ps, nil, nil, @@ -237,6 +241,7 @@ func (n *OpenconfigWithlistval_Model_BPath) MultiKeyMap() *OpenconfigWithlistval false, false, false, + false, true, ps, func(gs ygot.ValidatedGoStruct) (map[oc.OpenconfigWithlistval_Model_B_MultiKey_Key]*oc.OpenconfigWithlistval_Model_B_MultiKey, bool) { @@ -278,6 +283,7 @@ func (n *OpenconfigWithlistval_Model_BPathAny) MultiKeyMap() *OpenconfigWithlist false, false, false, + false, true, ps, func(gs ygot.ValidatedGoStruct) (map[oc.OpenconfigWithlistval_Model_B_MultiKey_Key]*oc.OpenconfigWithlistval_Model_B_MultiKey, bool) { @@ -380,6 +386,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKeyPath) Config() *OpenconfigWithlis false, false, false, + false, ps, nil, nil, @@ -418,6 +425,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKeyPathAny) Config() *OpenconfigWith false, false, false, + false, ps, nil, nil, @@ -453,6 +461,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKeyPath) Key1() *OpenconfigWithlistv ps.ConfigQuery = ygnmi.NewConfigQuery[uint32]( "OpenconfigWithlistval_Model_B_MultiKey", true, + false, true, true, false, @@ -499,6 +508,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKeyPathAny) Key1() *OpenconfigWithli ps.WildcardQuery = ygnmi.NewWildcardQuery[uint32]( "OpenconfigWithlistval_Model_B_MultiKey", true, + false, true, true, false, @@ -545,6 +555,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKeyPath) Key2() *OpenconfigWithlistv ps.ConfigQuery = ygnmi.NewConfigQuery[uint64]( "OpenconfigWithlistval_Model_B_MultiKey", true, + false, true, true, false, @@ -591,6 +602,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKeyPathAny) Key2() *OpenconfigWithli ps.WildcardQuery = ygnmi.NewWildcardQuery[uint64]( "OpenconfigWithlistval_Model_B_MultiKey", true, + false, true, true, false, @@ -640,6 +652,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKeyPath) State() *OpenconfigWithlist false, false, false, + false, ps, nil, nil, @@ -678,6 +691,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKeyPathAny) State() *OpenconfigWithl false, false, false, + false, ps, nil, nil, @@ -753,6 +767,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKey_ConfigPath) Key1() *OpenconfigWi ps.ConfigQuery = ygnmi.NewConfigQuery[uint32]( "OpenconfigWithlistval_Model_B_MultiKey_Config", true, + false, true, true, false, @@ -799,6 +814,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKey_ConfigPathAny) Key1() *Openconfi ps.WildcardQuery = ygnmi.NewWildcardQuery[uint32]( "OpenconfigWithlistval_Model_B_MultiKey_Config", true, + false, true, true, false, @@ -845,6 +861,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKey_ConfigPath) Key2() *OpenconfigWi ps.ConfigQuery = ygnmi.NewConfigQuery[uint64]( "OpenconfigWithlistval_Model_B_MultiKey_Config", true, + false, true, true, false, @@ -891,6 +908,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKey_ConfigPathAny) Key2() *Openconfi ps.WildcardQuery = ygnmi.NewWildcardQuery[uint64]( "OpenconfigWithlistval_Model_B_MultiKey_Config", true, + false, true, true, false, @@ -977,6 +995,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKey_StatePath) Key1() *OpenconfigWit ps.SingletonQuery = ygnmi.NewSingletonQuery[uint32]( "OpenconfigWithlistval_Model_B_MultiKey_State", true, + false, true, true, false, @@ -1023,6 +1042,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKey_StatePathAny) Key1() *Openconfig ps.WildcardQuery = ygnmi.NewWildcardQuery[uint32]( "OpenconfigWithlistval_Model_B_MultiKey_State", true, + false, true, true, false, @@ -1069,6 +1089,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKey_StatePath) Key2() *OpenconfigWit ps.SingletonQuery = ygnmi.NewSingletonQuery[uint64]( "OpenconfigWithlistval_Model_B_MultiKey_State", true, + false, true, true, false, @@ -1115,6 +1136,7 @@ func (n *OpenconfigWithlistval_Model_B_MultiKey_StatePathAny) Key2() *Openconfig ps.WildcardQuery = ygnmi.NewWildcardQuery[uint64]( "OpenconfigWithlistval_Model_B_MultiKey_State", true, + false, true, true, false, diff --git a/internal/uexampleoc/nested/nested-0.go b/internal/uexampleoc/nested/nested-0.go index e5a25f5..2c41dd6 100644 --- a/internal/uexampleoc/nested/nested-0.go +++ b/internal/uexampleoc/nested/nested-0.go @@ -66,6 +66,7 @@ func (n *OpenconfigNested_APath) B() *OpenconfigNested_A_BPath { false, false, false, + false, ps, nil, nil, @@ -104,6 +105,7 @@ func (n *OpenconfigNested_APathAny) B() *OpenconfigNested_A_BPathAny { false, false, false, + false, ps, nil, nil, @@ -162,6 +164,7 @@ func (n *OpenconfigNested_A_BPath) C() *OpenconfigNested_A_B_CPath { false, false, false, + false, ps, nil, nil, @@ -200,6 +203,7 @@ func (n *OpenconfigNested_A_BPathAny) C() *OpenconfigNested_A_B_CPathAny { false, false, false, + false, ps, nil, nil, @@ -250,6 +254,7 @@ func (n *OpenconfigNested_A_B_CPath) D() *OpenconfigNested_A_B_C_DPath { false, false, false, + false, ps, nil, nil, @@ -288,6 +293,7 @@ func (n *OpenconfigNested_A_B_CPathAny) D() *OpenconfigNested_A_B_C_DPathAny { false, false, false, + false, ps, nil, nil, @@ -338,6 +344,7 @@ func (n *OpenconfigNested_A_B_C_DPath) E() *OpenconfigNested_A_B_C_D_EPath { false, false, false, + false, ps, nil, nil, @@ -376,6 +383,7 @@ func (n *OpenconfigNested_A_B_C_DPathAny) E() *OpenconfigNested_A_B_C_D_EPathAny false, false, false, + false, ps, nil, nil, @@ -426,6 +434,7 @@ func (n *OpenconfigNested_A_B_C_D_EPath) F() *OpenconfigNested_A_B_C_D_E_FPath { false, false, false, + false, ps, nil, nil, @@ -464,6 +473,7 @@ func (n *OpenconfigNested_A_B_C_D_EPathAny) F() *OpenconfigNested_A_B_C_D_E_FPat false, false, false, + false, ps, nil, nil, @@ -514,6 +524,7 @@ func (n *OpenconfigNested_A_B_C_D_E_FPath) G() *OpenconfigNested_A_B_C_D_E_F_GPa false, false, false, + false, ps, nil, nil, @@ -552,6 +563,7 @@ func (n *OpenconfigNested_A_B_C_D_E_FPathAny) G() *OpenconfigNested_A_B_C_D_E_F_ false, false, false, + false, ps, nil, nil, @@ -602,6 +614,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_GPath) H() *OpenconfigNested_A_B_C_D_E_F_G false, false, false, + false, ps, nil, nil, @@ -640,6 +653,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_GPathAny) H() *OpenconfigNested_A_B_C_D_E_ false, false, false, + false, ps, nil, nil, @@ -690,6 +704,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_G_HPath) I() *OpenconfigNested_A_B_C_D_E_F false, false, false, + false, ps, nil, nil, @@ -728,6 +743,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_G_HPathAny) I() *OpenconfigNested_A_B_C_D_ false, false, false, + false, ps, nil, nil, @@ -778,6 +794,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_G_H_IPath) J() *OpenconfigNested_A_B_C_D_E false, false, false, + false, ps, nil, nil, @@ -816,6 +833,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_G_H_IPathAny) J() *OpenconfigNested_A_B_C_ false, false, false, + false, ps, nil, nil, @@ -866,6 +884,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_G_H_I_JPath) K() *OpenconfigNested_A_B_C_D false, false, false, + false, ps, nil, nil, @@ -904,6 +923,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_G_H_I_JPathAny) K() *OpenconfigNested_A_B_ false, false, false, + false, ps, nil, nil, @@ -954,6 +974,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_G_H_I_J_KPath) L() *OpenconfigNested_A_B_C false, false, false, + false, ps, nil, nil, @@ -992,6 +1013,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_G_H_I_J_KPathAny) L() *OpenconfigNested_A_ false, false, false, + false, ps, nil, nil, @@ -1042,6 +1064,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_G_H_I_J_K_LPath) M() *OpenconfigNested_A_B false, false, false, + false, ps, nil, nil, @@ -1080,6 +1103,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_G_H_I_J_K_LPathAny) M() *OpenconfigNested_ false, false, false, + false, ps, nil, nil, @@ -1130,6 +1154,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_G_H_I_J_K_L_MPath) State() *OpenconfigNest false, false, false, + false, ps, nil, nil, @@ -1168,6 +1193,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_G_H_I_J_K_L_MPathAny) State() *OpenconfigN false, false, false, + false, ps, nil, nil, @@ -1229,6 +1255,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_G_H_I_J_K_L_M_StatePath) Foo() *Openconfig ps.SingletonQuery = ygnmi.NewSingletonQuery[string]( "OpenconfigNested_A_B_C_D_E_F_G_H_I_J_K_L_M_State", true, + false, true, true, false, @@ -1275,6 +1302,7 @@ func (n *OpenconfigNested_A_B_C_D_E_F_G_H_I_J_K_L_M_StatePathAny) Foo() *Opencon ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigNested_A_B_C_D_E_F_G_H_I_J_K_L_M_State", true, + false, true, true, false, diff --git a/internal/uexampleoc/simple/simple-0.go b/internal/uexampleoc/simple/simple-0.go index aaf64e2..9bcc2d0 100644 --- a/internal/uexampleoc/simple/simple-0.go +++ b/internal/uexampleoc/simple/simple-0.go @@ -68,6 +68,7 @@ func (n *OpenconfigSimple_ParentPath) Child() *OpenconfigSimple_Parent_ChildPath false, false, false, + false, ps, nil, nil, @@ -106,6 +107,7 @@ func (n *OpenconfigSimple_ParentPathAny) Child() *OpenconfigSimple_Parent_ChildP false, false, false, + false, ps, nil, nil, @@ -164,6 +166,7 @@ func (n *OpenconfigSimple_Parent_ChildPath) Config() *OpenconfigSimple_Parent_Ch false, false, false, + false, ps, nil, nil, @@ -202,6 +205,7 @@ func (n *OpenconfigSimple_Parent_ChildPathAny) Config() *OpenconfigSimple_Parent false, false, false, + false, ps, nil, nil, @@ -240,6 +244,7 @@ func (n *OpenconfigSimple_Parent_ChildPath) State() *OpenconfigSimple_Parent_Chi false, false, false, + false, ps, nil, nil, @@ -278,6 +283,7 @@ func (n *OpenconfigSimple_Parent_ChildPathAny) State() *OpenconfigSimple_Parent_ false, false, false, + false, ps, nil, nil, @@ -395,6 +401,7 @@ func (n *OpenconfigSimple_Parent_Child_ConfigPath) Five() *OpenconfigSimple_Pare ps.ConfigQuery = ygnmi.NewConfigQuery[float32]( "OpenconfigSimple_Parent_Child_Config", true, + false, true, false, false, @@ -437,6 +444,7 @@ func (n *OpenconfigSimple_Parent_Child_ConfigPathAny) Five() *OpenconfigSimple_P ps.WildcardQuery = ygnmi.NewWildcardQuery[float32]( "OpenconfigSimple_Parent_Child_Config", true, + false, true, false, false, @@ -479,6 +487,7 @@ func (n *OpenconfigSimple_Parent_Child_ConfigPath) Four() *OpenconfigSimple_Pare ps.ConfigQuery = ygnmi.NewConfigQuery[oc.Binary]( "OpenconfigSimple_Parent_Child_Config", true, + false, true, false, false, @@ -521,6 +530,7 @@ func (n *OpenconfigSimple_Parent_Child_ConfigPathAny) Four() *OpenconfigSimple_P ps.WildcardQuery = ygnmi.NewWildcardQuery[oc.Binary]( "OpenconfigSimple_Parent_Child_Config", true, + false, true, false, false, @@ -563,6 +573,7 @@ func (n *OpenconfigSimple_Parent_Child_ConfigPath) One() *OpenconfigSimple_Paren ps.ConfigQuery = ygnmi.NewConfigQuery[string]( "OpenconfigSimple_Parent_Child_Config", true, + false, true, true, false, @@ -609,6 +620,7 @@ func (n *OpenconfigSimple_Parent_Child_ConfigPathAny) One() *OpenconfigSimple_Pa ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigSimple_Parent_Child_Config", true, + false, true, true, false, @@ -655,6 +667,7 @@ func (n *OpenconfigSimple_Parent_Child_ConfigPath) Six() *OpenconfigSimple_Paren ps.ConfigQuery = ygnmi.NewConfigQuery[[]float32]( "OpenconfigSimple_Parent_Child_Config", true, + false, true, false, false, @@ -697,6 +710,7 @@ func (n *OpenconfigSimple_Parent_Child_ConfigPathAny) Six() *OpenconfigSimple_Pa ps.WildcardQuery = ygnmi.NewWildcardQuery[[]float32]( "OpenconfigSimple_Parent_Child_Config", true, + false, true, false, false, @@ -739,6 +753,7 @@ func (n *OpenconfigSimple_Parent_Child_ConfigPath) Three() *OpenconfigSimple_Par ps.ConfigQuery = ygnmi.NewConfigQuery[oc.E_Simple_Parent_Child_Config_Three]( "OpenconfigSimple_Parent_Child_Config", true, + false, true, false, false, @@ -781,6 +796,7 @@ func (n *OpenconfigSimple_Parent_Child_ConfigPathAny) Three() *OpenconfigSimple_ ps.WildcardQuery = ygnmi.NewWildcardQuery[oc.E_Simple_Parent_Child_Config_Three]( "OpenconfigSimple_Parent_Child_Config", true, + false, true, false, false, @@ -919,6 +935,7 @@ func (n *OpenconfigSimple_Parent_Child_StatePath) Five() *OpenconfigSimple_Paren ps.SingletonQuery = ygnmi.NewSingletonQuery[float32]( "OpenconfigSimple_Parent_Child_State", true, + false, true, false, false, @@ -961,6 +978,7 @@ func (n *OpenconfigSimple_Parent_Child_StatePathAny) Five() *OpenconfigSimple_Pa ps.WildcardQuery = ygnmi.NewWildcardQuery[float32]( "OpenconfigSimple_Parent_Child_State", true, + false, true, false, false, @@ -1003,6 +1021,7 @@ func (n *OpenconfigSimple_Parent_Child_StatePath) Four() *OpenconfigSimple_Paren ps.SingletonQuery = ygnmi.NewSingletonQuery[oc.Binary]( "OpenconfigSimple_Parent_Child_State", true, + false, true, false, false, @@ -1045,6 +1064,7 @@ func (n *OpenconfigSimple_Parent_Child_StatePathAny) Four() *OpenconfigSimple_Pa ps.WildcardQuery = ygnmi.NewWildcardQuery[oc.Binary]( "OpenconfigSimple_Parent_Child_State", true, + false, true, false, false, @@ -1087,6 +1107,7 @@ func (n *OpenconfigSimple_Parent_Child_StatePath) One() *OpenconfigSimple_Parent ps.SingletonQuery = ygnmi.NewSingletonQuery[string]( "OpenconfigSimple_Parent_Child_State", true, + false, true, true, false, @@ -1133,6 +1154,7 @@ func (n *OpenconfigSimple_Parent_Child_StatePathAny) One() *OpenconfigSimple_Par ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigSimple_Parent_Child_State", true, + false, true, true, false, @@ -1179,6 +1201,7 @@ func (n *OpenconfigSimple_Parent_Child_StatePath) Six() *OpenconfigSimple_Parent ps.SingletonQuery = ygnmi.NewSingletonQuery[[]float32]( "OpenconfigSimple_Parent_Child_State", true, + false, true, false, false, @@ -1221,6 +1244,7 @@ func (n *OpenconfigSimple_Parent_Child_StatePathAny) Six() *OpenconfigSimple_Par ps.WildcardQuery = ygnmi.NewWildcardQuery[[]float32]( "OpenconfigSimple_Parent_Child_State", true, + false, true, false, false, @@ -1263,6 +1287,7 @@ func (n *OpenconfigSimple_Parent_Child_StatePath) Three() *OpenconfigSimple_Pare ps.SingletonQuery = ygnmi.NewSingletonQuery[oc.E_Simple_Parent_Child_Config_Three]( "OpenconfigSimple_Parent_Child_State", true, + false, true, false, false, @@ -1305,6 +1330,7 @@ func (n *OpenconfigSimple_Parent_Child_StatePathAny) Three() *OpenconfigSimple_P ps.WildcardQuery = ygnmi.NewWildcardQuery[oc.E_Simple_Parent_Child_Config_Three]( "OpenconfigSimple_Parent_Child_State", true, + false, true, false, false, @@ -1347,6 +1373,7 @@ func (n *OpenconfigSimple_Parent_Child_StatePath) Two() *OpenconfigSimple_Parent ps.SingletonQuery = ygnmi.NewSingletonQuery[string]( "OpenconfigSimple_Parent_Child_State", true, + false, true, true, false, @@ -1393,6 +1420,7 @@ func (n *OpenconfigSimple_Parent_Child_StatePathAny) Two() *OpenconfigSimple_Par ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigSimple_Parent_Child_State", true, + false, true, true, false, @@ -1454,6 +1482,7 @@ func (n *OpenconfigSimple_RemoteContainerPath) Config() *OpenconfigSimple_Remote false, false, false, + false, ps, nil, nil, @@ -1492,6 +1521,7 @@ func (n *OpenconfigSimple_RemoteContainerPathAny) Config() *OpenconfigSimple_Rem false, false, false, + false, ps, nil, nil, @@ -1530,6 +1560,7 @@ func (n *OpenconfigSimple_RemoteContainerPath) State() *OpenconfigSimple_RemoteC false, false, false, + false, ps, nil, nil, @@ -1568,6 +1599,7 @@ func (n *OpenconfigSimple_RemoteContainerPathAny) State() *OpenconfigSimple_Remo false, false, false, + false, ps, nil, nil, @@ -1629,6 +1661,7 @@ func (n *OpenconfigSimple_RemoteContainer_ConfigPath) ALeaf() *OpenconfigSimple_ ps.ConfigQuery = ygnmi.NewConfigQuery[string]( "OpenconfigSimple_RemoteContainer_Config", true, + false, true, true, false, @@ -1675,6 +1708,7 @@ func (n *OpenconfigSimple_RemoteContainer_ConfigPathAny) ALeaf() *OpenconfigSimp ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigSimple_RemoteContainer_Config", true, + false, true, true, false, @@ -1747,6 +1781,7 @@ func (n *OpenconfigSimple_RemoteContainer_StatePath) ALeaf() *OpenconfigSimple_R ps.SingletonQuery = ygnmi.NewSingletonQuery[string]( "OpenconfigSimple_RemoteContainer_State", true, + false, true, true, false, @@ -1793,6 +1828,7 @@ func (n *OpenconfigSimple_RemoteContainer_StatePathAny) ALeaf() *OpenconfigSimpl ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigSimple_RemoteContainer_State", true, + false, true, true, false, diff --git a/internal/uexampleoc/uexampleocpath/uexampleocpath.go b/internal/uexampleoc/uexampleocpath/uexampleocpath.go index de5f424..406e027 100644 --- a/internal/uexampleoc/uexampleocpath/uexampleocpath.go +++ b/internal/uexampleoc/uexampleocpath/uexampleocpath.go @@ -67,6 +67,7 @@ func (n *DevicePath) A() *nested.OpenconfigNested_APath { false, false, false, + false, ps, nil, nil, @@ -105,6 +106,7 @@ func (n *DevicePath) Container() *nested.OpenconfigNested_ContainerPath { false, false, false, + false, ps, nil, nil, @@ -143,6 +145,7 @@ func (n *DevicePath) Model() *withlistval.OpenconfigWithlistval_ModelPath { false, false, false, + false, ps, nil, nil, @@ -182,6 +185,7 @@ func (n *DevicePath) Parent() *simple.OpenconfigSimple_ParentPath { false, false, false, + false, ps, nil, nil, @@ -220,6 +224,7 @@ func (n *DevicePath) RemoteContainer() *simple.OpenconfigSimple_RemoteContainerP false, false, false, + false, ps, nil, nil, @@ -259,6 +264,7 @@ func (b *Batch) Query() ygnmi.SingletonQuery[*oc.Device] { true, false, false, + false, true, false, ygnmi.NewDeviceRootBase(), diff --git a/internal/uexampleoc/withlistval/withlistval-0.go b/internal/uexampleoc/withlistval/withlistval-0.go index e9e40e8..4ad2fb8 100644 --- a/internal/uexampleoc/withlistval/withlistval-0.go +++ b/internal/uexampleoc/withlistval/withlistval-0.go @@ -68,6 +68,7 @@ func (n *OpenconfigWithlistval_ModelPath) A() *a.OpenconfigWithlistval_Model_APa false, false, false, + false, ps, nil, nil, @@ -106,6 +107,7 @@ func (n *OpenconfigWithlistval_ModelPathAny) A() *a.OpenconfigWithlistval_Model_ false, false, false, + false, ps, nil, nil, @@ -144,6 +146,7 @@ func (n *OpenconfigWithlistval_ModelPath) B() *modelb.OpenconfigWithlistval_Mode false, false, false, + false, ps, nil, nil, @@ -182,6 +185,7 @@ func (n *OpenconfigWithlistval_ModelPathAny) B() *modelb.OpenconfigWithlistval_M false, false, false, + false, ps, nil, nil, @@ -220,6 +224,7 @@ func (n *OpenconfigWithlistval_ModelPath) C() *OpenconfigWithlistval_Model_CPath false, false, false, + false, ps, nil, nil, @@ -258,6 +263,7 @@ func (n *OpenconfigWithlistval_ModelPathAny) C() *OpenconfigWithlistval_Model_CP false, false, false, + false, ps, nil, nil, @@ -316,6 +322,7 @@ func (n *OpenconfigWithlistval_Model_CPath) NoKeyAny() *OpenconfigWithlistval_Mo false, false, false, + false, ps, nil, nil, @@ -354,6 +361,7 @@ func (n *OpenconfigWithlistval_Model_CPathAny) NoKeyAny() *OpenconfigWithlistval false, false, false, + false, ps, nil, nil, @@ -416,6 +424,7 @@ func (n *OpenconfigWithlistval_Model_C_NoKey_FooPath) State() *OpenconfigWithlis false, false, false, + false, ps, nil, nil, @@ -454,6 +463,7 @@ func (n *OpenconfigWithlistval_Model_C_NoKey_FooPathAny) State() *OpenconfigWith false, false, false, + false, ps, nil, nil, @@ -529,6 +539,7 @@ func (n *OpenconfigWithlistval_Model_C_NoKey_Foo_StatePath) Key() *OpenconfigWit ps.SingletonQuery = ygnmi.NewSingletonQuery[string]( "OpenconfigWithlistval_Model_C_NoKey_Foo_State", true, + false, true, true, false, @@ -575,6 +586,7 @@ func (n *OpenconfigWithlistval_Model_C_NoKey_Foo_StatePathAny) Key() *Openconfig ps.WildcardQuery = ygnmi.NewWildcardQuery[string]( "OpenconfigWithlistval_Model_C_NoKey_Foo_State", true, + false, true, true, false, @@ -621,6 +633,7 @@ func (n *OpenconfigWithlistval_Model_C_NoKey_Foo_StatePath) Value() *OpenconfigW ps.SingletonQuery = ygnmi.NewSingletonQuery[int64]( "OpenconfigWithlistval_Model_C_NoKey_Foo_State", true, + false, true, true, false, @@ -667,6 +680,7 @@ func (n *OpenconfigWithlistval_Model_C_NoKey_Foo_StatePathAny) Value() *Openconf ps.WildcardQuery = ygnmi.NewWildcardQuery[int64]( "OpenconfigWithlistval_Model_C_NoKey_Foo_State", true, + false, true, true, false, diff --git a/pathgen/gnmigen.go b/pathgen/gnmigen.go index f34a5d8..3c8c104 100644 --- a/pathgen/gnmigen.go +++ b/pathgen/gnmigen.go @@ -20,6 +20,7 @@ import ( "text/template" "github.com/openconfig/ygnmi/ygnmi" + "github.com/openconfig/ygot/genutil" "github.com/openconfig/ygot/ygen" ) @@ -33,6 +34,7 @@ type gnmiStruct struct { SchemaStructPkgAccessor string RelPathList string IsState bool + IsShadowPath bool MethodName string IsScalar bool GenerateWildcard bool @@ -67,10 +69,10 @@ var packagesSeen = map[string]bool{} // // Note: GNMIGenerator requires that PreferOperationalState be true when generating PathStructs. // TODO(DanG100): pass schema from parent to child. -func GNMIGenerator(pathStructName, fakeRootName string, dir *ygen.ParsedDirectory, node *NodeData, _ bool) (string, error) { - tmplStruct := defaultTmplStruct(pathStructName, fakeRootName, node) +func GNMIGenerator(pathStructName, fakeRootName string, compressBehaviour genutil.CompressBehaviour, dir *ygen.ParsedDirectory, node *NodeData, _ bool) (string, error) { + tmplStruct := defaultStateTmplStruct(pathStructName, fakeRootName, compressBehaviour, node) var b strings.Builder - if err := generateOneOff(&b, fakeRootName, node, tmplStruct, true); err != nil { + if err := generateOneOff(&b, fakeRootName, compressBehaviour, node, tmplStruct, true); err != nil { return "", err } if err := modifyQueryType(node, &tmplStruct); err != nil { @@ -82,9 +84,9 @@ func GNMIGenerator(pathStructName, fakeRootName string, dir *ygen.ParsedDirector tmpl = goGNMILeafTemplate } - generate := func(tmplStruct gnmiStruct, shadow bool) error { + generate := func(tmplStruct gnmiStruct, config bool) error { if node.IsLeaf { - if err := populateTmplForLeaf(dir, node.YANGFieldName, shadow, &tmplStruct); err != nil { + if err := populateTmplForLeaf(dir, node.YANGFieldName, compressBehaviour, config, &tmplStruct); err != nil { return err } } @@ -102,6 +104,7 @@ func GNMIGenerator(pathStructName, fakeRootName string, dir *ygen.ParsedDirector tmplStruct.MethodName = "Config" tmplStruct.SingletonTypeName = configQueryTypeName tmplStruct.IsState = false + tmplStruct.IsShadowPath = compressBehaviour == genutil.PreferOperationalState if err := generate(tmplStruct, true); err != nil { return "", err } @@ -111,15 +114,15 @@ func GNMIGenerator(pathStructName, fakeRootName string, dir *ygen.ParsedDirector // GNMIGeneratorUncompressed is a plugin generator for generating ygnmi query objects for // uncompressed structs. -func GNMIGeneratorUncompressed(pathStructName, fakeRootName string, dir *ygen.ParsedDirectory, node *NodeData, _ bool) (string, error) { +func GNMIGeneratorUncompressed(pathStructName, fakeRootName string, compressBehaviour genutil.CompressBehaviour, dir *ygen.ParsedDirectory, node *NodeData, _ bool) (string, error) { var b strings.Builder - if err := generateOneOff(&b, fakeRootName, node, defaultTmplStruct(pathStructName, fakeRootName, node), false); err != nil { + if err := generateOneOff(&b, fakeRootName, compressBehaviour, node, defaultStateTmplStruct(pathStructName, fakeRootName, compressBehaviour, node), false); err != nil { return "", err } return b.String(), nil } -func defaultTmplStruct(pathStructName, fakeRootName string, node *NodeData) gnmiStruct { +func defaultStateTmplStruct(pathStructName, fakeRootName string, compressBehaviour genutil.CompressBehaviour, node *NodeData) gnmiStruct { return gnmiStruct{ PathStructName: pathStructName, GoTypeName: node.GoTypeName, @@ -128,6 +131,7 @@ func defaultTmplStruct(pathStructName, fakeRootName string, node *NodeData) gnmi GoFieldName: node.GoFieldName, SchemaStructPkgAccessor: "oc.", IsState: true, + IsShadowPath: compressBehaviour == genutil.PreferIntendedConfig, IsCompressedSchema: true, MethodName: "State", SingletonTypeName: singletonQueryTypeName, @@ -142,13 +146,14 @@ func defaultTmplStruct(pathStructName, fakeRootName string, node *NodeData) gnmi } // generateOneOff generates one-off free-form generated code. -func generateOneOff(b *strings.Builder, fakeRootName string, node *NodeData, tmplStruct gnmiStruct, compressPaths bool) error { +func generateOneOff(b *strings.Builder, fakeRootName string, compressBehaviour genutil.CompressBehaviour, node *NodeData, tmplStruct gnmiStruct, compressPaths bool) error { if strings.TrimLeft(node.LocalGoTypeName, "*") == fakeRootName { tmplStruct.MethodName = "Query" if compressPaths { tmplStruct.MethodName = "State" } tmplStruct.IsState = true + tmplStruct.IsShadowPath = compressBehaviour == genutil.PreferIntendedConfig if err := batchStructTemplate.Execute(b, &tmplStruct); err != nil { return err } @@ -158,6 +163,7 @@ func generateOneOff(b *strings.Builder, fakeRootName string, node *NodeData, tmp if compressPaths { tmplStruct.MethodName = "Config" tmplStruct.IsState = false + tmplStruct.IsShadowPath = compressBehaviour == genutil.PreferOperationalState if err := batchTemplate.Execute(b, &tmplStruct); err != nil { return err } @@ -196,7 +202,7 @@ func modifyQueryType(node *NodeData, s *gnmiStruct) error { // // This is meant to be used for uncompressed generation, where there is no need // to distinguish between config and state queries. -func GNMIFieldGenerator(pathStructName, _ string, _ *ygen.ParsedDirectory, node *NodeData, wildcard bool) (string, error) { +func GNMIFieldGenerator(pathStructName, _ string, compressBehaviour genutil.CompressBehaviour, _ *ygen.ParsedDirectory, node *NodeData, wildcard bool) (string, error) { tmplStruct := gnmiStruct{ GoTypeName: node.GoTypeName, } @@ -222,8 +228,8 @@ func GNMIFieldGenerator(pathStructName, _ string, _ *ygen.ParsedDirectory, node // // This is meant to be used for uncompressed generation, where there is no need // to distinguish between config and state queries. -func GNMIInitGenerator(pathStructName, fakeRootName string, _ *ygen.ParsedDirectory, node *NodeData, wildcard bool) (string, error) { - tmplStruct := defaultTmplStruct(pathStructName, fakeRootName, node) +func GNMIInitGenerator(pathStructName, fakeRootName string, compressBehaviour genutil.CompressBehaviour, _ *ygen.ParsedDirectory, node *NodeData, wildcard bool) (string, error) { + tmplStruct := defaultStateTmplStruct(pathStructName, fakeRootName, compressBehaviour, node) tmplStruct.IsCompressedSchema = false if err := modifyQueryType(node, &tmplStruct); err != nil { return "", err @@ -260,22 +266,31 @@ func GNMIInitGenerator(pathStructName, fakeRootName string, _ *ygen.ParsedDirect return fmt.Sprintf("\n\tps.%s = %s", queryTypeName, b.String()), nil } +func getMappedStateAndConfigInfo(field *ygen.NodeDetails, compressBehaviour genutil.CompressBehaviour) (bool, [][]string, [][]string, [][]string, [][]string) { + if compressBehaviour == genutil.PreferIntendedConfig && len(field.ShadowMappedPaths) > 0 { + return true, field.ShadowMappedPaths, field.ShadowMappedPathModules, field.MappedPaths, field.MappedPathModules + } else { + return false, field.MappedPaths, field.MappedPathModules, field.ShadowMappedPaths, field.ShadowMappedPathModules + } +} + // populateTmplForLeaf adds leaf specific fields to the gnmiStruct template. -func populateTmplForLeaf(dir *ygen.ParsedDirectory, fieldName string, shadow bool, tmplStruct *gnmiStruct) error { +func populateTmplForLeaf(dir *ygen.ParsedDirectory, fieldName string, compressBehaviour genutil.CompressBehaviour, config bool, tmplStruct *gnmiStruct) error { field, ok := dir.Fields[fieldName] if !ok { return fmt.Errorf("field %q does not exist in directory %s", fieldName, dir.Path) } // The longest path is the non-key path. This is the one we want to use // since the key is "compressed out". - relPath := longestPath(field.MappedPaths) - if shadow { - relPath = longestPath(field.ShadowMappedPaths) + preferConfig, mappedStatePaths, _, mappedConfigPaths, _ := getMappedStateAndConfigInfo(field, compressBehaviour) + relPath := longestPath(mappedStatePaths) + if config { + relPath = longestPath(mappedConfigPaths) } tmplStruct.RelPathList = `"` + strings.Join(relPath, `", "`) + `"` tmplStruct.AbsPath = field.YANGDetails.SchemaPath - if shadow { + if config != preferConfig { tmplStruct.AbsPath = field.YANGDetails.ShadowSchemaPath } tmplStruct.RelPath = strings.Join(relPath, `/`) @@ -285,13 +300,12 @@ func populateTmplForLeaf(dir *ygen.ParsedDirectory, fieldName string, shadow boo } // generateConfigFunc determines if a node should have a .Config() method. -// For leaves, it checks if the directory has a shadow-path field. +// For leaves, it checks if the directory has a config-path field. // For non-leaves, it checks if the directory or any of its descendants are config nodes. func generateConfigFunc(dir *ygen.ParsedDirectory, node *NodeData) bool { if node.IsLeaf { - // Since we're generating with PreferOperationalState, we need - // to check shadow-fields to know whether this has a config - // sibling. + // Regardless of the compression mode, existence of shadow + // paths means that there is a config sibling for this leaf. field, ok := dir.Fields[node.YANGFieldName] return ok && len(field.ShadowMappedPaths) > 0 } @@ -313,6 +327,7 @@ var ( ygnmi.New{{ .SingletonTypeName }}[{{ .GoTypeName }}]( "{{ .GoStructTypeName }}", {{ .IsState }}, + {{ .IsShadowPath }}, true, {{ .IsScalar }}, {{ .IsCompressedSchema }}, @@ -358,6 +373,7 @@ ygnmi.New{{ .SingletonTypeName }}[{{ .GoTypeName }}]( ygnmi.New{{ .WildcardTypeName }}[{{ .GoTypeName }}]( "{{ .GoStructTypeName }}", {{ .IsState }}, + {{ .IsShadowPath }}, true, {{ .IsScalar }}, {{ .IsCompressedSchema }}, @@ -427,6 +443,7 @@ func (n *{{ .PathStructName }}{{ .WildcardSuffix }}) {{ .MethodName }}() ygnmi.{ ygnmi.New{{ .SingletonTypeName }}[{{ .GoTypeName }}]( "{{ .GoStructTypeName }}", {{ .IsState }}, + {{ .IsShadowPath }}, false, false, {{ .IsCompressedSchema }}, @@ -468,6 +485,7 @@ ygnmi.New{{ .SingletonTypeName }}[{{ .GoTypeName }}]( ygnmi.New{{ .WildcardTypeName }}[{{ .GoTypeName }}]( "{{ .GoStructTypeName }}", {{ .IsState }}, + {{ .IsShadowPath }}, false, false, {{ .IsCompressedSchema }}, @@ -544,6 +562,7 @@ func (b *Batch) {{ .MethodName }}() ygnmi.{{ .SingletonTypeName }}[{{ .GoTypeNam return ygnmi.New{{ .SingletonTypeName }}[{{ .GoTypeName }}]( "{{ .GoStructTypeName }}", {{ .IsState }}, + {{ .IsShadowPath }}, false, false, {{ .IsCompressedSchema }}, diff --git a/pathgen/gnmigen_test.go b/pathgen/gnmigen_test.go index b494b24..94a6908 100644 --- a/pathgen/gnmigen_test.go +++ b/pathgen/gnmigen_test.go @@ -19,6 +19,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/openconfig/gnmi/errdiff" + "github.com/openconfig/ygot/genutil" "github.com/openconfig/ygot/ygen" ) @@ -65,6 +66,7 @@ func (n *Container_Leaf) State() ygnmi.SingletonQuery[int32] { return ygnmi.NewSingletonQuery[int32]( "Container", true, + false, true, true, true, @@ -104,6 +106,7 @@ func (n *Container_LeafAny) State() ygnmi.WildcardQuery[int32] { return ygnmi.NewWildcardQuery[int32]( "Container", true, + false, true, true, true, @@ -159,6 +162,7 @@ func (n *Leaf) State() ygnmi.SingletonQuery[int32] { return ygnmi.NewSingletonQuery[int32]( "Root", true, + false, true, true, true, @@ -198,6 +202,7 @@ func (n *LeafAny) State() ygnmi.WildcardQuery[int32] { return ygnmi.NewWildcardQuery[int32]( "Root", true, + false, true, true, true, @@ -264,6 +269,7 @@ func (n *Container_LeafList) State() ygnmi.SingletonQuery[[]uint32] { return ygnmi.NewSingletonQuery[[]uint32]( "Container", true, + false, true, false, true, @@ -299,6 +305,7 @@ func (n *Container_LeafListAny) State() ygnmi.WildcardQuery[[]uint32] { return ygnmi.NewWildcardQuery[[]uint32]( "Container", true, + false, true, false, true, @@ -335,6 +342,7 @@ func (n *Container_LeafList) Config() ygnmi.ConfigQuery[[]uint32] { "Container", false, true, + true, false, true, false, @@ -370,6 +378,7 @@ func (n *Container_LeafListAny) Config() ygnmi.WildcardQuery[[]uint32] { "Container", false, true, + true, false, true, false, @@ -420,6 +429,7 @@ func (n *Container_Leaf) State() ygnmi.SingletonQuery[E_Child_Three] { return ygnmi.NewSingletonQuery[E_Child_Three]( "Container", true, + false, true, false, true, @@ -455,6 +465,7 @@ func (n *Container_LeafAny) State() ygnmi.WildcardQuery[E_Child_Three] { return ygnmi.NewWildcardQuery[E_Child_Three]( "Container", true, + false, true, false, true, @@ -519,6 +530,7 @@ func (b *Batch) State() ygnmi.SingletonQuery[*oc.Root] { true, false, false, + false, true, false, ygnmi.NewDeviceRootBase(), @@ -544,6 +556,7 @@ func (b *Batch) Config() ygnmi.SingletonQuery[*oc.Root] { return ygnmi.NewSingletonQuery[*oc.Root]( "Root", false, + true, false, false, true, @@ -570,6 +583,7 @@ func (n *Root) State() ygnmi.SingletonQuery[*oc.Root] { true, false, false, + false, true, false, n, @@ -592,6 +606,7 @@ func (n *Root) Config() ygnmi.ConfigQuery[*oc.Root] { return ygnmi.NewConfigQuery[*oc.Root]( "Root", false, + true, false, false, true, @@ -614,7 +629,7 @@ func (n *Root) Config() ygnmi.ConfigQuery[*oc.Root] { }} for _, tt := range tests { t.Run(tt.desc, func(t *testing.T) { - got, err := GNMIGenerator(tt.pathStructName, "Root", tt.dir, tt.node, false) + got, err := GNMIGenerator(tt.pathStructName, "Root", genutil.PreferOperationalState, tt.dir, tt.node, false) if diff := errdiff.Substring(err, tt.wantErr); diff != "" { t.Fatalf("GNMIGenerator(%q, %v, %v) returned unexpected error diff: %s", tt.pathStructName, tt.dir, tt.node, diff) } diff --git a/pathgen/pathgen.go b/pathgen/pathgen.go index 4223105..b38b138 100644 --- a/pathgen/pathgen.go +++ b/pathgen/pathgen.go @@ -99,7 +99,7 @@ func NewDefaultConfig(schemaStructPkgPath string) *GenConfig { } // Generator is func to returns extra generated code for a given node. -type Generator func(string, string, *ygen.ParsedDirectory, *NodeData, bool) (string, error) +type Generator func(string, string, genutil.CompressBehaviour, *ygen.ParsedDirectory, *NodeData, bool) (string, error) // ExtraGenerators is the set of all generators for a generation invocation. type ExtraGenerators struct { @@ -284,7 +284,7 @@ func (cg *GenConfig) GeneratePathCode(yangFiles, includePaths []string) (map[str } // Get NodeDataMap for the schema. - nodeDataMap, es := getNodeDataMap(ir, yang.CamelCase(cg.FakeRootName), schemaStructPkgAccessor, cg.PathStructSuffix, cg.PackageName, cg.PackageSuffix, cg.SplitByModule, cg.TrimPackageModulePrefix, !cg.IgnoreAtomicLists, cg.CompressBehaviour.CompressEnabled(), cg.SplitPackagePaths) + nodeDataMap, es := getNodeDataMap(ir, yang.CamelCase(cg.FakeRootName), schemaStructPkgAccessor, cg.PathStructSuffix, cg.PackageName, cg.PackageSuffix, cg.SplitByModule, cg.TrimPackageModulePrefix, !cg.IgnoreAtomicLists, cg.CompressBehaviour, cg.SplitPackagePaths) if es != nil { errs = util.AppendErrs(errs, es) } @@ -294,7 +294,7 @@ func (cg *GenConfig) GeneratePathCode(yangFiles, includePaths []string) (map[str for _, directoryPath := range ir.OrderedDirectoryPathsByName() { directory := ir.Directories[directoryPath] - structSnippet, es := generateDirectorySnippet(directory, ir.Directories, nodeDataMap, yang.CamelCase(cg.FakeRootName), cg.ExtraGenerators, schemaStructPkgAccessor, cg.PathStructSuffix, cg.GenerateWildcardPaths, cg.SplitByModule, cg.TrimPackageModulePrefix, cg.PackageName, cg.PackageSuffix, cg.SplitPackagePaths, cg.UnifyPathStructs, !cg.IgnoreAtomic, !cg.IgnoreAtomicLists, cg.CompressBehaviour.CompressEnabled()) + structSnippet, es := generateDirectorySnippet(directory, ir.Directories, nodeDataMap, yang.CamelCase(cg.FakeRootName), cg.ExtraGenerators, schemaStructPkgAccessor, cg.PathStructSuffix, cg.GenerateWildcardPaths, cg.SplitByModule, cg.TrimPackageModulePrefix, cg.PackageName, cg.PackageSuffix, cg.SplitPackagePaths, cg.UnifyPathStructs, !cg.IgnoreAtomic, !cg.IgnoreAtomicLists, cg.CompressBehaviour) if es != nil { errs = util.AppendErrs(errs, es) } @@ -478,7 +478,7 @@ func (g *GoPathStructCodeSnippet) String() string { return b.String() } -func genExtras(psName, fakeRootName string, nodeDataMap NodeDataMap, dir *ygen.ParsedDirectory, wildcard bool, extraGens []Generator, errs *errlist.List) string { +func genExtras(psName, fakeRootName string, compressBehaviour genutil.CompressBehaviour, nodeDataMap NodeDataMap, dir *ygen.ParsedDirectory, wildcard bool, extraGens []Generator, errs *errlist.List) string { node, ok := nodeDataMap[psName] if !ok { return "" @@ -486,7 +486,7 @@ func genExtras(psName, fakeRootName string, nodeDataMap NodeDataMap, dir *ygen.P var b strings.Builder for _, gen := range extraGens { - extra, err := gen(psName, fakeRootName, dir, node, wildcard) + extra, err := gen(psName, fakeRootName, compressBehaviour, dir, node, wildcard) if err != nil { errs.Add(err) continue @@ -506,11 +506,11 @@ func genExtras(psName, fakeRootName string, nodeDataMap NodeDataMap, dir *ygen.P // // - nodeDataMap is the set of all nodes keyed by pathstruct name. // - dir is the directory to which this snippet belongs. -func (g *GoPathStructCodeSnippet) genExtras(nodeDataMap NodeDataMap, fakeRootName string, dir *ygen.ParsedDirectory, extraGens []Generator) error { +func (g *GoPathStructCodeSnippet) genExtras(nodeDataMap NodeDataMap, fakeRootName string, compressBehaviour genutil.CompressBehaviour, dir *ygen.ParsedDirectory, extraGens []Generator) error { var errs errlist.List - g.ExtraGeneration += genExtras(g.PathStructName, fakeRootName, nodeDataMap, dir, false, extraGens, &errs) + g.ExtraGeneration += genExtras(g.PathStructName, fakeRootName, compressBehaviour, nodeDataMap, dir, false, extraGens, &errs) // Extra generation for keyed list types. - g.ExtraGeneration += genExtras(g.PathStructName+WholeKeyedListSuffix, fakeRootName, nodeDataMap, dir, false, extraGens, &errs) + g.ExtraGeneration += genExtras(g.PathStructName+WholeKeyedListSuffix, fakeRootName, compressBehaviour, nodeDataMap, dir, false, extraGens, &errs) return errs.Err() } @@ -742,7 +742,7 @@ func mustTemplate(name, src string) *template.Template { // // TODO(wenbli): Change this function to be callable while traversing the IR // rather than traversing the IR itself again. -func getNodeDataMap(ir *ygen.IR, fakeRootName, schemaStructPkgAccessor, pathStructSuffix, packageName, packageSuffix string, splitByModule bool, trimPrefix string, generateAtomicLists, compressPaths bool, splitPackagePaths map[string]string) (NodeDataMap, util.Errors) { +func getNodeDataMap(ir *ygen.IR, fakeRootName, schemaStructPkgAccessor, pathStructSuffix, packageName, packageSuffix string, splitByModule bool, trimPrefix string, generateAtomicLists bool, compressBehaviour genutil.CompressBehaviour, splitPackagePaths map[string]string) (NodeDataMap, util.Errors) { nodeDataMap := NodeDataMap{} var errs util.Errors for _, dir := range ir.Directories { @@ -860,7 +860,7 @@ func getNodeDataMap(ir *ygen.IR, fakeRootName, schemaStructPkgAccessor, pathStru nodeData.LocalGoTypeName = fmt.Sprintf("map[%s]%s", keyType, nodeData.LocalGoTypeName) } - if compressPaths { + if compressBehaviour.CompressEnabled() { relPath := longestPath(field.MappedPaths) relMods := longestPath(field.MappedPathModules) if gotLen := len(relPath); gotLen != 2 { @@ -973,10 +973,10 @@ type goPathStructData struct { // // - nodeDataMap is the set of all nodes keyed by pathstruct name. // - dir is the directory to which this snippet belongs. -func (s *goPathStructData) genExtraFields(nodeDataMap NodeDataMap, fakeRootName string, dir *ygen.ParsedDirectory, extraFieldGens []Generator) error { +func (s *goPathStructData) genExtraFields(nodeDataMap NodeDataMap, fakeRootName string, compressBehaviour genutil.CompressBehaviour, dir *ygen.ParsedDirectory, extraFieldGens []Generator) error { var errs errlist.List - s.ExtraFields += genExtras(s.TypeName, fakeRootName, nodeDataMap, dir, false, extraFieldGens, &errs) - s.ExtraWildcardFields += genExtras(s.TypeName, fakeRootName, nodeDataMap, dir, true, extraFieldGens, &errs) + s.ExtraFields += genExtras(s.TypeName, fakeRootName, compressBehaviour, nodeDataMap, dir, false, extraFieldGens, &errs) + s.ExtraWildcardFields += genExtras(s.TypeName, fakeRootName, compressBehaviour, nodeDataMap, dir, true, extraFieldGens, &errs) return errs.Err() } @@ -1040,10 +1040,10 @@ type goPathFieldData struct { // // - nodeDataMap is the set of all nodes keyed by pathstruct name. // - dir is the directory to which this snippet belongs. -func (s *goPathFieldData) genExtraInits(nodeDataMap NodeDataMap, fakeRootName string, dir *ygen.ParsedDirectory, extraInitGens []Generator) error { +func (s *goPathFieldData) genExtraInits(nodeDataMap NodeDataMap, fakeRootName string, compressBehaviour genutil.CompressBehaviour, dir *ygen.ParsedDirectory, extraInitGens []Generator) error { var errs errlist.List - s.ExtraInits += genExtras(s.TypeName, fakeRootName, nodeDataMap, dir, false, extraInitGens, &errs) - s.ExtraWildcardInits += genExtras(s.TypeName, fakeRootName, nodeDataMap, dir, true, extraInitGens, &errs) + s.ExtraInits += genExtras(s.TypeName, fakeRootName, compressBehaviour, nodeDataMap, dir, false, extraInitGens, &errs) + s.ExtraWildcardInits += genExtras(s.TypeName, fakeRootName, compressBehaviour, nodeDataMap, dir, true, extraInitGens, &errs) return errs.Err() } @@ -1074,7 +1074,7 @@ func isCompressedAtomicList(directory *ygen.ParsedDirectory) bool { // node, and directories is a map from path to a parsed schema node for all // directory nodes in the schema. func generateDirectorySnippet(directory *ygen.ParsedDirectory, directories map[string]*ygen.ParsedDirectory, nodeDataMap NodeDataMap, fakeRootName string, extraGens ExtraGenerators, schemaStructPkgAccessor, pathStructSuffix string, - generateWildcardPaths, splitByModule bool, trimPrefix, packageName, packageSuffix string, splitPackagePaths map[string]string, unified bool, generateAtomic, generateAtomicLists, compressPaths bool) ([]GoPathStructCodeSnippet, util.Errors) { + generateWildcardPaths, splitByModule bool, trimPrefix, packageName, packageSuffix string, splitPackagePaths map[string]string, unified bool, generateAtomic, generateAtomicLists bool, compressBehaviour genutil.CompressBehaviour) ([]GoPathStructCodeSnippet, util.Errors) { var errs util.Errors // structBuf is used to store the code associated with the struct defined for @@ -1091,7 +1091,7 @@ func generateDirectorySnippet(directory *ygen.ParsedDirectory, directories map[s return nil, util.AppendErr(errs, err) } } else { - if err := structData.genExtraFields(nodeDataMap, fakeRootName, directory, extraGens.StructFields); err != nil { + if err := structData.genExtraFields(nodeDataMap, fakeRootName, compressBehaviour, directory, extraGens.StructFields); err != nil { return nil, util.AppendErr(errs, err) } if err := goPathStructTemplate.Execute(&structBuf, structData); err != nil { @@ -1104,7 +1104,7 @@ func generateDirectorySnippet(directory *ygen.ParsedDirectory, directories map[s structData.TypeName += WholeKeyedListSuffix structData.clearExtraFields() - if err := structData.genExtraFields(nodeDataMap, fakeRootName, directory, extraGens.StructFields); err != nil { + if err := structData.genExtraFields(nodeDataMap, fakeRootName, compressBehaviour, directory, extraGens.StructFields); err != nil { return nil, util.AppendErr(errs, err) } if err := goPathStructTemplate.Execute(&structBuf, structData); err != nil { @@ -1119,7 +1119,7 @@ func generateDirectorySnippet(directory *ygen.ParsedDirectory, directories map[s StructBase: structBuf.String(), Package: parentPackage, } - errs = util.AppendErr(errs, nonLeafSnippet.genExtras(nodeDataMap, fakeRootName, directory, extraGens.Extras)) + errs = util.AppendErr(errs, nonLeafSnippet.genExtras(nodeDataMap, fakeRootName, compressBehaviour, directory, extraGens.Extras)) // Since it is not possible for gNMI to refer to individual nodes // underneath an unkeyed list or a telemetry-atomic node (ordered lists @@ -1166,7 +1166,7 @@ func generateDirectorySnippet(directory *ygen.ParsedDirectory, directories map[s } } - if es := generateChildConstructors(&methodBuf, buildBuf, directory, fName, goFieldName, directories, fakeRootName, schemaStructPkgAccessor, pathStructSuffix, generateWildcardPaths, childPkgAccessor, unified, generateAtomicLists, compressPaths, nodeDataMap, extraGens); es != nil { + if es := generateChildConstructors(&methodBuf, buildBuf, directory, fName, goFieldName, directories, fakeRootName, schemaStructPkgAccessor, pathStructSuffix, generateWildcardPaths, childPkgAccessor, unified, generateAtomicLists, compressBehaviour, nodeDataMap, extraGens); es != nil { errs = util.AppendErrs(errs, es) } @@ -1188,7 +1188,7 @@ func generateDirectorySnippet(directory *ygen.ParsedDirectory, directories map[s GenerateWildcardPaths: generateWildcardPaths, GenerateParentField: unified, } - errs = util.AppendErr(errs, structData.genExtraFields(nodeDataMap, fakeRootName, directory, extraGens.StructFields)) + errs = util.AppendErr(errs, structData.genExtraFields(nodeDataMap, fakeRootName, compressBehaviour, directory, extraGens.StructFields)) errs = util.AppendErr(errs, goPathStructTemplate.Execute(&buf, structData)) } leafSnippet := GoPathStructCodeSnippet{ @@ -1196,7 +1196,7 @@ func generateDirectorySnippet(directory *ygen.ParsedDirectory, directories map[s StructBase: buf.String(), Package: goPackageName(directory.RootElementModule, directory.SchemaPath, splitByModule, directory.IsFakeRoot, packageName, trimPrefix, packageSuffix, splitPackagePaths), } - errs = util.AppendErr(errs, leafSnippet.genExtras(nodeDataMap, fakeRootName, directory, extraGens.Extras)) + errs = util.AppendErr(errs, leafSnippet.genExtras(nodeDataMap, fakeRootName, compressBehaviour, directory, extraGens.Extras)) snippets = append(snippets, leafSnippet) } } @@ -1254,7 +1254,7 @@ func relPathListFn(path []string) string { // type name of of the child path struct, and a map of all directories of the // whole schema keyed by their schema paths. func generateChildConstructors(methodBuf *strings.Builder, builderBuf *strings.Builder, directory *ygen.ParsedDirectory, directoryFieldName string, goFieldName string, directories map[string]*ygen.ParsedDirectory, fakeRootName, schemaStructPkgAccessor, - pathStructSuffix string, generateWildcardPaths bool, childPkgAccessor string, unified bool, generateAtomicLists, compressPaths bool, nodeDataMap NodeDataMap, extraGens ExtraGenerators) []error { + pathStructSuffix string, generateWildcardPaths bool, childPkgAccessor string, unified bool, generateAtomicLists bool, compressBehaviour genutil.CompressBehaviour, nodeDataMap NodeDataMap, extraGens ExtraGenerators) []error { field, ok := directory.Fields[directoryFieldName] if !ok { @@ -1283,10 +1283,14 @@ func generateChildConstructors(methodBuf *strings.Builder, builderBuf *strings.B // a leaf struct with a shadow path could be either state or config, so replace state with a wildcard. if unified && len(field.ShadowMappedPaths) > 0 && (field.Type == ygen.LeafNode || field.Type == ygen.LeafListNode) { path[0] = "*" - schemaPath = strings.ReplaceAll(schemaPath, "/state/", "/*/") + parent := "/state/" + if compressBehaviour == genutil.PreferIntendedConfig { + parent = "/config/" + } + schemaPath = strings.ReplaceAll(schemaPath, parent, "/*/") } - if err := structData.genExtraFields(nodeDataMap, fakeRootName, directory, extraGens.StructFields); err != nil { + if err := structData.genExtraFields(nodeDataMap, fakeRootName, compressBehaviour, directory, extraGens.StructFields); err != nil { return []error{err} } @@ -1310,7 +1314,7 @@ func generateChildConstructors(methodBuf *strings.Builder, builderBuf *strings.B // This is expected to be nil for leaf fields. fieldDirectory := directories[field.YANGDetails.Path] - if err := fieldData.genExtraInits(nodeDataMap, fakeRootName, directory, extraGens.StructInits); err != nil { + if err := fieldData.genExtraInits(nodeDataMap, fakeRootName, compressBehaviour, directory, extraGens.StructInits); err != nil { return []error{err} } @@ -1335,7 +1339,7 @@ func generateChildConstructors(methodBuf *strings.Builder, builderBuf *strings.B if !generateAtomicLists { return nil } - if gotLen := len(path); compressPaths && gotLen != 2 { + if gotLen := len(path); compressBehaviour.CompressEnabled() && gotLen != 2 { return []error{fmt.Errorf("expected two path elements for the relative path of an ordered map, got %d: %v", gotLen, path)} } fieldData.RelPathList = relPathListFn(path[:1]) @@ -1343,7 +1347,7 @@ func generateChildConstructors(methodBuf *strings.Builder, builderBuf *strings.B fieldData.MethodName += WholeKeyedListSuffix fieldData.clearExtraInit() - if err := fieldData.genExtraInits(nodeDataMap, fakeRootName, directory, extraGens.StructInits); err != nil { + if err := fieldData.genExtraInits(nodeDataMap, fakeRootName, compressBehaviour, directory, extraGens.StructInits); err != nil { return []error{err} } diff --git a/pathgen/pathgen_test.go b/pathgen/pathgen_test.go index 4b08fff..4daeead 100644 --- a/pathgen/pathgen_test.go +++ b/pathgen/pathgen_test.go @@ -2372,7 +2372,7 @@ func TestGetNodeDataMap(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, gotErrs := getNodeDataMap(tt.inIR, tt.inFakeRootName, tt.inSchemaStructPkgAccessor, tt.inPathStructSuffix, tt.inPackageName, tt.inPackageSuffix, tt.inSplitByModule, "", true, true, nil) + got, gotErrs := getNodeDataMap(tt.inIR, tt.inFakeRootName, tt.inSchemaStructPkgAccessor, tt.inPathStructSuffix, tt.inPackageName, tt.inPackageSuffix, tt.inSplitByModule, "", true, genutil.PreferOperationalState, nil) // TODO(wenbli): Enhance gNMI's errdiff with checking a slice of substrings and use here. var gotErrStrs []string for _, err := range gotErrs { @@ -3459,7 +3459,7 @@ func (n *ListPathAny) WithUnionKey(UnionKey oc.RootElementModule_List_UnionKey_U for _, tt := range tests { if tt.want != nil { t.Run(tt.name, func(t *testing.T) { - got, gotErr := generateDirectorySnippet(tt.inDirectory, directories, nil, "Root", ExtraGenerators{}, "oc.", tt.inPathStructSuffix, true, tt.inSplitByModule, "", tt.inPackageName, tt.inPackageSuffix, nil, tt.inUnifiedPath, true, true, true) + got, gotErr := generateDirectorySnippet(tt.inDirectory, directories, nil, "Root", ExtraGenerators{}, "oc.", tt.inPathStructSuffix, true, tt.inSplitByModule, "", tt.inPackageName, tt.inPackageSuffix, nil, tt.inUnifiedPath, true, true, genutil.PreferOperationalState) if gotErr != nil { t.Fatalf("func generateDirectorySnippet, unexpected error: %v", gotErr) } @@ -3476,7 +3476,7 @@ func (n *ListPathAny) WithUnionKey(UnionKey oc.RootElementModule_List_UnionKey_U if tt.wantNoWildcard != nil { t.Run(tt.name+" no wildcard", func(t *testing.T) { - got, gotErr := generateDirectorySnippet(tt.inDirectory, directories, nil, "Root", ExtraGenerators{}, "oc.", tt.inPathStructSuffix, false, tt.inSplitByModule, "", tt.inPackageName, tt.inPackageSuffix, nil, tt.inUnifiedPath, true, true, true) + got, gotErr := generateDirectorySnippet(tt.inDirectory, directories, nil, "Root", ExtraGenerators{}, "oc.", tt.inPathStructSuffix, false, tt.inSplitByModule, "", tt.inPackageName, tt.inPackageSuffix, nil, tt.inUnifiedPath, true, true, genutil.PreferOperationalState) if gotErr != nil { t.Fatalf("func generateDirectorySnippet, unexpected error: %v", gotErr) } @@ -3804,7 +3804,7 @@ func (n *ListPathAny) WithUnionKey(UnionKey oc.RootElementModule_List_UnionKey_U t.Run(tt.name, func(t *testing.T) { var methodBuf strings.Builder var builderBuf strings.Builder - if errs := generateChildConstructors(&methodBuf, &builderBuf, tt.inDirectory, tt.inFieldName, tt.inUniqueFieldName, tt.inDirectories, "Root", "oc.", tt.inPathStructSuffix, tt.inGenerateWildcardPaths, tt.inChildAccessor, tt.inUnifiedPaths, true, true, NodeDataMap{}, ExtraGenerators{}); errs != nil { + if errs := generateChildConstructors(&methodBuf, &builderBuf, tt.inDirectory, tt.inFieldName, tt.inUniqueFieldName, tt.inDirectories, "Root", "oc.", tt.inPathStructSuffix, tt.inGenerateWildcardPaths, tt.inChildAccessor, tt.inUnifiedPaths, true, genutil.PreferOperationalState, NodeDataMap{}, ExtraGenerators{}); errs != nil { t.Fatal(errs) } diff --git a/schemaless/schemaless.go b/schemaless/schemaless.go index 60f89c9..3845e2f 100644 --- a/schemaless/schemaless.go +++ b/schemaless/schemaless.go @@ -40,6 +40,7 @@ func NewConfig[T any](path, origin string) (ygnmi.ConfigQuery[T], error) { } return ygnmi.NewConfigQuery("", + false, false, true, scalar, @@ -66,6 +67,7 @@ func NewWildcard[T any](path, origin string) (ygnmi.WildcardQuery[T], error) { } return ygnmi.NewWildcardQuery("", + false, false, true, scalar, diff --git a/ygnmi/create_preferconfig_test.sh b/ygnmi/create_preferconfig_test.sh new file mode 100755 index 0000000..b408c63 --- /dev/null +++ b/ygnmi/create_preferconfig_test.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SRC_TEST_NAME="ygnmi_test.go" +TARGET_TEST_NAME="ygnmi_preferconfig_test.go" + +printf "// Code generated from ygnmi_test.go. DO NOT EDIT.\n\n" > "${TARGET_TEST_NAME}" +cat "${SRC_TEST_NAME}" >> "${TARGET_TEST_NAME}" +sed -i -e 's/exampleoc/exampleocconfig/g' "${TARGET_TEST_NAME}" +sed -i -e 's/github.com\/openconfig\/ygnmi\/exampleocconfig/github.com\/openconfig\/ygnmi\/internal\/exampleocconfig/g' "${TARGET_TEST_NAME}" +sed -i -e 's/^func Test/func TestPreferConfig/' "${TARGET_TEST_NAME}" +sed -i -e 's/getSample/getSamplePreferConfig/' "${TARGET_TEST_NAME}" +gofmt -w -s "${TARGET_TEST_NAME}" diff --git a/ygnmi/gentest.go b/ygnmi/gentest.go new file mode 100644 index 0000000..9a65b09 --- /dev/null +++ b/ygnmi/gentest.go @@ -0,0 +1,16 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:generate ./create_preferconfig_test.sh +package ygnmi diff --git a/ygnmi/gnmi.go b/ygnmi/gnmi.go index cf2e724..f91f997 100644 --- a/ygnmi/gnmi.go +++ b/ygnmi/gnmi.go @@ -404,7 +404,7 @@ func set[T any](ctx context.Context, c *Client, q ConfigQuery[T], val T, op setO // as far as the JSON is concerned. modifyTypedValueFn = func(tv *gpb.TypedValue) error { return wrapJSONIETF(tv, q.compressInfo().PostRelPath) } } - if err := populateSetRequest(req, path, setVal, op, !q.IsState(), modifyTypedValueFn, opts...); err != nil { + if err := populateSetRequest(req, path, setVal, op, q.isShadowPath(), modifyTypedValueFn, opts...); err != nil { return nil, nil, err } diff --git a/ygnmi/types.go b/ygnmi/types.go index facfc1c..d25b146 100644 --- a/ygnmi/types.go +++ b/ygnmi/types.go @@ -42,11 +42,12 @@ type CompressionInfo struct { type ExtractFn[T any] func(ygot.ValidatedGoStruct) (T, bool) // NewSingletonQuery creates a new SingletonQueryStruct object. -func NewSingletonQuery[T any](goStructName string, state, leaf, scalar, compressedSchema, listContainer bool, ps PathStruct, extractFn ExtractFn[T], goStructFn func() ygot.ValidatedGoStruct, schemaFn func() *ytypes.Schema, subPaths []PathStruct, compressInfo *CompressionInfo) *SingletonQueryStruct[T] { +func NewSingletonQuery[T any](goStructName string, state, shadowpath, leaf, scalar, compressedSchema, listContainer bool, ps PathStruct, extractFn ExtractFn[T], goStructFn func() ygot.ValidatedGoStruct, schemaFn func() *ytypes.Schema, subPaths []PathStruct, compressInfo *CompressionInfo) *SingletonQueryStruct[T] { return &SingletonQueryStruct[T]{ baseQuery: baseQuery[T]{ goStructName, state, + shadowpath, ps, leaf, scalar, @@ -62,11 +63,12 @@ func NewSingletonQuery[T any](goStructName string, state, leaf, scalar, compress } // NewConfigQuery creates a new NewLeafConfigQuery object. -func NewConfigQuery[T any](goStructName string, state, leaf, scalar, compressedSchema, listContainer bool, ps PathStruct, extractFn ExtractFn[T], goStructFn func() ygot.ValidatedGoStruct, schemaFn func() *ytypes.Schema, subPaths []PathStruct, compressInfo *CompressionInfo) *ConfigQueryStruct[T] { +func NewConfigQuery[T any](goStructName string, state, shadowpath, leaf, scalar, compressedSchema, listContainer bool, ps PathStruct, extractFn ExtractFn[T], goStructFn func() ygot.ValidatedGoStruct, schemaFn func() *ytypes.Schema, subPaths []PathStruct, compressInfo *CompressionInfo) *ConfigQueryStruct[T] { return &ConfigQueryStruct[T]{ baseQuery: baseQuery[T]{ goStructName, state, + shadowpath, ps, leaf, scalar, @@ -82,11 +84,12 @@ func NewConfigQuery[T any](goStructName string, state, leaf, scalar, compressedS } // NewWildcardQuery creates a new NewLeafWildcardQuery object. -func NewWildcardQuery[T any](goStructName string, state, leaf, scalar, compressedSchema, listContainer bool, ps PathStruct, extractFn ExtractFn[T], goStructFn func() ygot.ValidatedGoStruct, schemaFn func() *ytypes.Schema, subPaths []PathStruct, compressInfo *CompressionInfo) *WildcardQueryStruct[T] { +func NewWildcardQuery[T any](goStructName string, state, shadowpath, leaf, scalar, compressedSchema, listContainer bool, ps PathStruct, extractFn ExtractFn[T], goStructFn func() ygot.ValidatedGoStruct, schemaFn func() *ytypes.Schema, subPaths []PathStruct, compressInfo *CompressionInfo) *WildcardQueryStruct[T] { return &WildcardQueryStruct[T]{ baseQuery: baseQuery[T]{ goStructName, state, + shadowpath, ps, leaf, scalar, @@ -139,8 +142,10 @@ type baseQuery[T any] struct { // - For GoStructs this is the struct itself. // - For others this is the parent dir. goStructName string - // state controls if state or config values should be unmarshalled. + // state indicates whether the path is a config or a state path. state bool + // shadowpath controls unmarshal behaviour. + shadowpath bool // ps contains the path specification of the query. ps PathStruct // leaf indicates whether the query is on a leaf node. @@ -183,6 +188,11 @@ func (q *baseQuery[T]) IsState() bool { return q.state } +// IsState returns if the Query is for a shadow path node. +func (q *baseQuery[T]) isShadowPath() bool { + return q.shadowpath +} + // PathStruct returns the path struct containing the path for the Query. func (q *baseQuery[T]) PathStruct() PathStruct { return q.ps diff --git a/ygnmi/unmarshal.go b/ygnmi/unmarshal.go index a8321cc..b48d7f2 100644 --- a/ygnmi/unmarshal.go +++ b/ygnmi/unmarshal.go @@ -169,7 +169,7 @@ func unmarshalAndExtract[T any](data []*DataPoint, q AnyQuery[T], goStruct ygot. return ret, nil } - unmarshalledData, complianceErrs, err := unmarshal(data, schema.SchemaTree[q.dirName()], goStruct, queryPath, schema, q.isLeaf(), !q.IsState(), q.compressInfo(), opts) + unmarshalledData, complianceErrs, err := unmarshal(data, schema.SchemaTree[q.dirName()], goStruct, queryPath, schema, q.isLeaf(), q.isShadowPath(), q.compressInfo(), opts) ret.ComplianceErrors = complianceErrs if err != nil { return ret, err @@ -290,7 +290,7 @@ func unmarshalSchemaless(data []*DataPoint, val any) (bool, error) { // NOTE: The subset of datapoints includes datapoints that are value restriction noncompliant. // The second error slice are internal errors, while the returned // *ComplianceError stores the compliance errors. -func unmarshal(data []*DataPoint, structSchema *yang.Entry, structPtr ygot.ValidatedGoStruct, queryPath *gpb.Path, schema *ytypes.Schema, isLeaf, isConfig bool, compressInfo *CompressionInfo, opts *opt) ([]*DataPoint, *ComplianceErrors, error) { +func unmarshal(data []*DataPoint, structSchema *yang.Entry, structPtr ygot.ValidatedGoStruct, queryPath *gpb.Path, schema *ytypes.Schema, isLeaf, isShadowPath bool, compressInfo *CompressionInfo, opts *opt) ([]*DataPoint, *ComplianceErrors, error) { queryPathStr := pathToString(queryPath) if isLeaf { switch { @@ -317,7 +317,7 @@ func unmarshal(data []*DataPoint, structSchema *yang.Entry, structPtr ygot.Valid // TODO(wenbli): Add fatal check for duplicate paths, as they're not allowed by GET semantics. for _, dp := range data { var gcopts []ytypes.GetOrCreateNodeOpt - if isConfig { + if isShadowPath { gcopts = append(gcopts, &ytypes.PreferShadowPath{}) } // Sync datapoints don't contain path nor values. @@ -376,7 +376,7 @@ func unmarshal(data []*DataPoint, structSchema *yang.Entry, structPtr ygot.Valid relPath := util.TrimGNMIPathPrefix(unmarshalPath, util.PathStringToElements(structSchema.Path())[1:]) if dp.Value == nil { var dopts []ytypes.DelNodeOpt - if isConfig { + if isShadowPath { dopts = append(dopts, &ytypes.PreferShadowPath{}) } if err := ytypes.DeleteNode(structSchema, structPtr, relPath, dopts...); err == nil { @@ -386,7 +386,7 @@ func unmarshal(data []*DataPoint, structSchema *yang.Entry, structPtr ygot.Valid } } else { sopts := []ytypes.SetNodeOpt{&ytypes.InitMissingElements{}, &ytypes.TolerateJSONInconsistencies{}} - if isConfig { + if isShadowPath { sopts = append(sopts, &ytypes.PreferShadowPath{}) } // TODO: Fully support partial unmarshaling of JSON blobs. diff --git a/ygnmi/ygnmi.go b/ygnmi/ygnmi.go index 27c7e27..8e5cc64 100644 --- a/ygnmi/ygnmi.go +++ b/ygnmi/ygnmi.go @@ -51,6 +51,8 @@ type UntypedQuery interface { goStruct() ygot.ValidatedGoStruct // IsState returns if the path for this query is a state node. IsState() bool + // isShadowPath returns if the path for this query is a shadow-path node. + isShadowPath() bool // isLeaf returns if the path for this query is a leaf. isLeaf() bool // isCompressedSchema returns whether the query is for compressed ygot schema. @@ -614,10 +616,10 @@ func Delete[T any](ctx context.Context, c *Client, q ConfigQuery[T], opts ...Opt } type batchOp struct { - path PathStruct - val interface{} - mode setOperation - config bool + path PathStruct + val interface{} + mode setOperation + shadowpath bool } // SetBatch allows multiple Set operations (Replace, Update, Delete) to be applied as part of a single Set transaction. @@ -634,7 +636,7 @@ func (sb *SetBatch) Set(ctx context.Context, c *Client, opts ...Option) (*Result if err != nil { return nil, err } - if err := populateSetRequest(req, path, op.val, op.mode, op.config, nil, opts...); err != nil { + if err := populateSetRequest(req, path, op.val, op.mode, op.shadowpath, nil, opts...); err != nil { return nil, err } } @@ -654,10 +656,10 @@ func BatchUpdate[T any](sb *SetBatch, q ConfigQuery[T], val T) { setVal = &val } sb.ops = append(sb.ops, &batchOp{ - path: q.PathStruct(), - val: setVal, - mode: updatePath, - config: !q.IsState(), + path: q.PathStruct(), + val: setVal, + mode: updatePath, + shadowpath: q.isShadowPath(), }) } @@ -668,10 +670,10 @@ func BatchReplace[T any](sb *SetBatch, q ConfigQuery[T], val T) { setVal = &val } sb.ops = append(sb.ops, &batchOp{ - path: q.PathStruct(), - val: setVal, - mode: replacePath, - config: !q.IsState(), + path: q.PathStruct(), + val: setVal, + mode: replacePath, + shadowpath: q.isShadowPath(), }) } @@ -684,10 +686,10 @@ func BatchUnionReplace[T any](sb *SetBatch, q ConfigQuery[T], val T) { setVal = &val } sb.ops = append(sb.ops, &batchOp{ - path: q.PathStruct(), - val: setVal, - mode: unionreplacePath, - config: !q.IsState(), + path: q.PathStruct(), + val: setVal, + mode: unionreplacePath, + shadowpath: q.isShadowPath(), }) } @@ -703,19 +705,19 @@ func BatchUnionReplaceCLI(sb *SetBatch, nos, ascii string) { ps := NewDeviceRootBase() ps.PutCustomData(OriginOverride, nos+"_cli") sb.ops = append(sb.ops, &batchOp{ - path: ps, - val: ascii, - mode: unionreplacePath, - config: true, + path: ps, + val: ascii, + mode: unionreplacePath, + shadowpath: false, }) } // BatchDelete stores a delete operation in the SetBatch. func BatchDelete[T any](sb *SetBatch, q ConfigQuery[T]) { sb.ops = append(sb.ops, &batchOp{ - path: q.PathStruct(), - mode: deletePath, - config: !q.IsState(), + path: q.PathStruct(), + mode: deletePath, + shadowpath: q.isShadowPath(), }) } @@ -764,6 +766,7 @@ func (b *Batch[T]) Query() SingletonQuery[T] { return NewSingletonQuery[T]( b.root.dirName(), b.root.IsState(), + b.root.isShadowPath(), b.root.isLeaf(), b.root.isScalar(), b.root.isCompressedSchema(), @@ -822,6 +825,7 @@ func (b *WildcardBatch[T]) Query() WildcardQuery[T] { return NewWildcardQuery[T]( b.root.dirName(), b.root.IsState(), + b.root.isShadowPath(), b.root.isLeaf(), b.root.isScalar(), b.root.isCompressedSchema(), diff --git a/ygnmi/ygnmi_preferconfig_test.go b/ygnmi/ygnmi_preferconfig_test.go new file mode 100644 index 0000000..6b34dbe --- /dev/null +++ b/ygnmi/ygnmi_preferconfig_test.go @@ -0,0 +1,4399 @@ +// Code generated from ygnmi_test.go. DO NOT EDIT. + +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ygnmi_test + +import ( + "context" + "fmt" + "net" + "testing" + "time" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/openconfig/gnmi/errdiff" + "github.com/openconfig/ygnmi/internal/exampleocconfig" + "github.com/openconfig/ygnmi/internal/exampleocconfig/exampleocconfigpath" + "github.com/openconfig/ygnmi/internal/testutil" + "github.com/openconfig/ygnmi/schemaless" + "github.com/openconfig/ygnmi/ygnmi" + "github.com/openconfig/ygot/ygot" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials/local" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/testing/protocmp" + + gpb "github.com/openconfig/gnmi/proto/gnmi" +) + +func getSamplePreferConfigOrderedMap(t *testing.T) *exampleocconfig.Model_SingleKey_OrderedList_OrderedMap { + om := &exampleocconfig.Model_SingleKey_OrderedList_OrderedMap{} + ol, err := om.AppendNew("foo") + if err != nil { + t.Fatal(err) + } + ol.SetValue(42) + ol, err = om.AppendNew("bar") + if err != nil { + t.Fatal(err) + } + ol.SetValue(43) + ol, err = om.AppendNew("baz") + if err != nil { + t.Fatal(err) + } + ol.SetValue(44) + return om +} + +func getSamplePreferConfigOrderedMapIncomplete(t *testing.T) *exampleocconfig.Model_SingleKey_OrderedList_OrderedMap { + om := &exampleocconfig.Model_SingleKey_OrderedList_OrderedMap{} + ol, err := om.AppendNew("foo") + if err != nil { + t.Fatal(err) + } + ol.SetValue(42) + ol, err = om.AppendNew("bar") + if err != nil { + t.Fatal(err) + } + ol.SetValue(43) + return om +} + +func getSamplePreferConfigSingleKeyedMap(t *testing.T) map[string]*exampleocconfig.Model_SingleKey { + model := &exampleocconfig.Model{} + model.GetOrCreateSingleKey("foo").SetValue(42) + model.GetOrCreateSingleKey("bar").SetValue(43) + model.GetOrCreateSingleKey("baz").SetValue(44) + return model.SingleKey +} + +func getSamplePreferConfigSingleKeyedMapIncomplete(t *testing.T) map[string]*exampleocconfig.Model_SingleKey { + model := &exampleocconfig.Model{} + model.GetOrCreateSingleKey("foo").SetValue(42) + model.GetOrCreateSingleKey("bar").SetValue(43) + return model.SingleKey +} + +func getSamplePreferConfigInnerSingleKeyedMap(t *testing.T) map[string]*exampleocconfig.Model_SingleKey_SingleKey { + sk := &exampleocconfig.Model_SingleKey{} + sk.GetOrCreateSingleKey("foo").SetValue(42) + sk.GetOrCreateSingleKey("bar").SetValue(43) + sk.GetOrCreateSingleKey("baz").SetValue(44) + return sk.SingleKey +} + +func getSamplePreferConfigInnerSingleKeyedMapIncomplete(t *testing.T) map[string]*exampleocconfig.Model_SingleKey_SingleKey { + sk := &exampleocconfig.Model_SingleKey{} + sk.GetOrCreateSingleKey("foo").SetValue(42) + sk.GetOrCreateSingleKey("bar").SetValue(43) + return sk.SingleKey +} + +func TestPreferConfigLookup(t *testing.T) { + fakeGNMI, c := newClient(t) + leafPath := testutil.GNMIPath(t, "/remote-container/state/a-leaf") + lq := exampleocconfigpath.Root().RemoteContainer().ALeaf().State() + + leafTests := []struct { + desc string + stub func(s *testutil.Stubber) + inQuery ygnmi.SingletonQuery[string] + wantSubscriptionPath *gpb.Path + wantVal *ygnmi.Value[string] + wantErr string + }{{ + desc: "success update and sync", + inQuery: lq, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: leafPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + wantSubscriptionPath: leafPath, + wantVal: (&ygnmi.Value[string]{ + Path: leafPath, + Timestamp: time.Unix(0, 100), + }).SetVal("foo"), + }, { + desc: "success update and no sync", + inQuery: lq, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: leafPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }) + }, + wantSubscriptionPath: leafPath, + wantVal: (&ygnmi.Value[string]{ + Path: leafPath, + Timestamp: time.Unix(0, 100), + }).SetVal("foo"), + }, { + desc: "success with prefix", + inQuery: lq, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Prefix: testutil.GNMIPath(t, "remote-container"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "state/a-leaf"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + wantSubscriptionPath: leafPath, + wantVal: (&ygnmi.Value[string]{ + Path: leafPath, + Timestamp: time.Unix(0, 100), + }).SetVal("foo"), + }, { + desc: "success multiple notifs and first no value", + inQuery: lq, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Update: []*gpb.Update{}, + }).Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: leafPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + wantSubscriptionPath: leafPath, + wantVal: (&ygnmi.Value[string]{ + Path: leafPath, + Timestamp: time.Unix(0, 100), + }).SetVal("foo"), + }, { + desc: "success no value", + inQuery: lq, + stub: func(s *testutil.Stubber) { + s.Sync() + }, + wantSubscriptionPath: leafPath, + wantVal: (&ygnmi.Value[string]{ + Path: leafPath, + }), + }, { + desc: "error multiple values", + inQuery: lq, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: leafPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Notification(&gpb.Notification{ + Timestamp: 101, + Update: []*gpb.Update{{ + Path: leafPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 11}}, + }}, + }).Sync() + }, + wantErr: "noncompliant data encountered while unmarshalling leaf", + }, { + desc: "error deprecated path", + inQuery: lq, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 101, + Update: []*gpb.Update{{ + Path: &gpb.Path{ + Element: []string{"super-container", "leaf-container-struct", "uint64-leaf"}, + }, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 11}}, + }}, + }).Sync() + }, + wantErr: "noncompliant data encountered while unmarshalling leaf", + }, { + desc: "error last path element wrong", + inQuery: lq, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 101, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "leaf-container-struct/enum-leaf"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "E_VALUE_FORTY_THREE"}}, + }}, + }).Sync() + }, + wantErr: "noncompliant data encountered while unmarshalling leaf", + }, { + desc: "error non existant path", + inQuery: lq, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 101, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "leaf-container-struct/does-not-exist"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + wantErr: "does-not-exist", + }, { + desc: "error nil update", + inQuery: lq, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 101, + Update: []*gpb.Update{{ + Path: leafPath, + Val: nil, + }}, + }).Sync() + }, + wantErr: "invalid nil Val", + }, { + desc: "error wrong type", + inQuery: lq, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 101, + Update: []*gpb.Update{{ + Path: leafPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 10}}, + }}, + }).Sync() + }, + wantErr: "failed to unmarshal", + }} + for _, tt := range leafTests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + lookupCheckFn(t, fakeGNMI, c, tt.inQuery, tt.wantErr, tt.wantSubscriptionPath, tt.wantVal) + }) + } + + rootPath := testutil.GNMIPath(t, "parent/child") + strPath := testutil.GNMIPath(t, "parent/child/state/one") + enumPath := testutil.GNMIPath(t, "parent/child/state/three") + strCfgPath := testutil.GNMIPath(t, "parent/child/config/one") + + configQuery := exampleocconfigpath.Root().Parent().Child().Config() + stateQuery := exampleocconfigpath.Root().Parent().Child().State() + + nonLeafTests := []struct { + desc string + stub func(s *testutil.Stubber) + inQuery ygnmi.SingletonQuery[*exampleocconfig.Parent_Child] + wantSubscriptionPath *gpb.Path + wantVal *ygnmi.Value[*exampleocconfig.Parent_Child] + wantErr string + }{{ + desc: "success one update and state false", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: strCfgPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + inQuery: configQuery, + wantSubscriptionPath: rootPath, + wantVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Path: rootPath, + Timestamp: time.Unix(0, 100), + }).SetVal(&exampleocconfig.Parent_Child{ + One: ygot.String("foo"), + }), + }, { + desc: "success one update and state true", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: strPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + inQuery: stateQuery, + wantSubscriptionPath: rootPath, + wantVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Path: rootPath, + Timestamp: time.Unix(0, 100), + }).SetVal(&exampleocconfig.Parent_Child{ + One: ygot.String("foo"), + }), + }, { + desc: "success one update with prefix", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Prefix: testutil.GNMIPath(t, "parent"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "child/state/one"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + inQuery: stateQuery, + wantSubscriptionPath: rootPath, + wantVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Path: rootPath, + Timestamp: time.Unix(0, 100), + }).SetVal(&exampleocconfig.Parent_Child{ + One: ygot.String("foo"), + }), + }, { + desc: "success ignore state update when state false", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: strPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + inQuery: configQuery, + wantSubscriptionPath: rootPath, + wantVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Path: rootPath, + Timestamp: time.Unix(0, 100), + }), + }, { + desc: "success ignore non-state update when state true", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: strCfgPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + inQuery: stateQuery, + wantSubscriptionPath: rootPath, + wantVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Path: rootPath, + Timestamp: time.Unix(0, 100), + }), + }, { + desc: "success multiple updates in single notification", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: enumPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "ONE"}}, + }, { + Path: strPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + inQuery: stateQuery, + wantSubscriptionPath: rootPath, + wantVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Path: rootPath, + Timestamp: time.Unix(0, 100), + }).SetVal(&exampleocconfig.Parent_Child{ + One: ygot.String("foo"), + Three: exampleocconfig.Child_Three_ONE, + }), + }, { + desc: "success multiple notifications", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: enumPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "ONE"}}, + }}, + }).Notification(&gpb.Notification{ + Timestamp: 102, + Update: []*gpb.Update{{ + Path: strPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + inQuery: stateQuery, + wantSubscriptionPath: rootPath, + wantVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Path: rootPath, + Timestamp: time.Unix(0, 102), + }).SetVal(&exampleocconfig.Parent_Child{ + One: ygot.String("foo"), + Three: exampleocconfig.Child_Three_ONE, + }), + }, { + desc: "success no values", + stub: func(s *testutil.Stubber) { + s.Sync() + }, + inQuery: stateQuery, + wantSubscriptionPath: rootPath, + wantVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Path: rootPath, + }), + }} + + for _, tt := range nonLeafTests { + t.Run("nonleaf "+tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + lookupCheckFn(t, fakeGNMI, c, tt.inQuery, tt.wantErr, tt.wantSubscriptionPath, tt.wantVal) + }) + } + + t.Run("success with ieeefloat32", func(t *testing.T) { + fakeGNMI.Stub().Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/state/counter"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_BytesVal{BytesVal: []byte{0xc0, 0x00, 0x00, 0x00}}}, + }}, + }).Sync() + + lookupCheckFn( + t, fakeGNMI, c, + exampleocconfigpath.Root().Model().SingleKey("foo").Counter().State(), + "", + testutil.GNMIPath(t, "/model/a/single-key[key=foo]/state/counter"), + (&ygnmi.Value[float32]{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/state/counter"), + Timestamp: time.Unix(0, 100), + }).SetVal(-2), + ) + }) + + t.Run("success with leaf-list ieeefloat32", func(t *testing.T) { + fakeGNMI.Stub().Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/state/counters"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_LeaflistVal{LeaflistVal: &gpb.ScalarArray{Element: []*gpb.TypedValue{{Value: &gpb.TypedValue_BytesVal{BytesVal: []byte{0xc0, 0x00, 0x00, 0x00}}}}}}}, + }}, + }).Sync() + + lookupCheckFn( + t, fakeGNMI, c, + exampleocconfigpath.Root().Model().SingleKey("foo").Counters().State(), + "", + testutil.GNMIPath(t, "/model/a/single-key[key=foo]/state/counters"), + (&ygnmi.Value[[]float32]{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/state/counters"), + Timestamp: time.Unix(0, 100), + }).SetVal([]float32{-2}), + ) + }) + + t.Run("success ordered map", func(t *testing.T) { + fakeGNMI.Stub().Notification(&gpb.Notification{ + Timestamp: 100, + Atomic: true, + Prefix: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/config/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/config/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 42}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/config/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/config/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=baz]/config/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=baz]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=baz]/config/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 44}}, + }}, + }).Sync() + + lookupCheckFn( + t, fakeGNMI, c, + ygnmi.SingletonQuery[*exampleocconfig.Model_SingleKey_OrderedList_OrderedMap](exampleocconfigpath.Root().Model().SingleKey("foo").OrderedListMap().Config()), + "", + testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + (&ygnmi.Value[*exampleocconfig.Model_SingleKey_OrderedList_OrderedMap]{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Timestamp: time.Unix(0, 100), + }).SetVal(getSamplePreferConfigOrderedMap(t)), + ) + }) + + t.Run("success whole single-keyed map", func(t *testing.T) { + fakeGNMI.Stub().Notification(&gpb.Notification{ + Timestamp: 100, + Prefix: testutil.GNMIPath(t, "/model/a"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, `single-key[key=foo]/config/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=foo]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=foo]/config/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 42}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/config/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/config/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=baz]/config/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=baz]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=baz]/config/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 44}}, + }}, + }).Sync() + + lookupCheckFn( + t, fakeGNMI, c, + ygnmi.SingletonQuery[map[string]*exampleocconfig.Model_SingleKey](exampleocconfigpath.Root().Model().SingleKeyMap().Config()), + "", + testutil.GNMIPath(t, "/model/a"), + (&ygnmi.Value[map[string]*exampleocconfig.Model_SingleKey]{ + Path: testutil.GNMIPath(t, "/model/a"), + Timestamp: time.Unix(0, 100), + }).SetVal(getSamplePreferConfigSingleKeyedMap(t)), + ) + }) +} + +func TestPreferConfigLookupWithGet(t *testing.T) { + fakeGNMI, c := newClient(t) + leafPath := testutil.GNMIPath(t, "/remote-container/state/a-leaf") + + tests := []struct { + desc string + stub func(s *testutil.Stubber) + wantVal *ygnmi.Value[string] + wantRequest *gpb.GetRequest + wantErr string + }{{ + desc: "success", + stub: func(s *testutil.Stubber) { + s.GetResponse(&gpb.GetResponse{ + Notification: []*gpb.Notification{{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: leafPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(`"foo"`)}}, + }}, + }}, + }, nil) + }, + wantVal: (&ygnmi.Value[string]{ + Path: leafPath, + Timestamp: time.Unix(0, 100), + }).SetVal("foo"), + wantRequest: &gpb.GetRequest{ + Encoding: gpb.Encoding_JSON_IETF, + Type: gpb.GetRequest_STATE, + Prefix: &gpb.Path{}, + Path: []*gpb.Path{leafPath}, + }, + }, { + desc: "not found error", + stub: func(s *testutil.Stubber) { + s.GetResponse(nil, status.Error(codes.NotFound, "test")) + }, + wantVal: (&ygnmi.Value[string]{ + Path: leafPath, + }), + wantRequest: &gpb.GetRequest{ + Encoding: gpb.Encoding_JSON_IETF, + Type: gpb.GetRequest_STATE, + Prefix: &gpb.Path{}, + Path: []*gpb.Path{leafPath}, + }, + }} + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + lookupWithGetCheckFn( + t, fakeGNMI, c, + exampleocconfigpath.Root().RemoteContainer().ALeaf().State(), + "", + tt.wantRequest, + tt.wantVal, + ) + }) + } + + nonLeafPath := testutil.GNMIPath(t, "/parent/child") + nonLeafTests := []struct { + desc string + stub func(s *testutil.Stubber) + wantVal *ygnmi.Value[*exampleocconfig.Parent_Child] + wantErr string + }{{ + desc: "single leaf", + stub: func(s *testutil.Stubber) { + s.GetResponse(&gpb.GetResponse{ + Notification: []*gpb.Notification{{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: nonLeafPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(`{"config": {"three": "ONE" }}`)}}, + }}, + }}, + }, nil) + }, + wantVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Path: nonLeafPath, + Timestamp: time.Unix(0, 100), + }).SetVal(&exampleocconfig.Parent_Child{Three: exampleocconfig.Child_Three_ONE}), + }, { + desc: "with extra value", + stub: func(s *testutil.Stubber) { + s.GetResponse(&gpb.GetResponse{ + Notification: []*gpb.Notification{{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: nonLeafPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(`{"config": {"three": "ONE", "ten": "ten" }}`)}}, + }}, + }}, + }, nil) + }, + wantVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Path: nonLeafPath, + Timestamp: time.Unix(0, 100), + }).SetVal(&exampleocconfig.Parent_Child{Three: exampleocconfig.Child_Three_ONE}), + }, { + desc: "with invalid type", // TODO: When partial unmarshaling of JSON is supports, this test case should have a value. + stub: func(s *testutil.Stubber) { + s.GetResponse(&gpb.GetResponse{ + Notification: []*gpb.Notification{{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: nonLeafPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(`{"config": {"three": "ONE", "one": 10 }}`)}}, + }}, + }}, + }, nil) + }, + wantVal: &ygnmi.Value[*exampleocconfig.Parent_Child]{ + Path: nonLeafPath, + ComplianceErrors: &ygnmi.ComplianceErrors{ + TypeErrors: []*ygnmi.TelemetryError{{ + Path: nonLeafPath, + Value: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(`{"config": {"three": "ONE", "one": 10 }}`)}}, + }}, + }, + }, + }} + for _, tt := range nonLeafTests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + got, err := ygnmi.Lookup[*exampleocconfig.Parent_Child](context.Background(), c, exampleocconfigpath.Root().Parent().Child().Config(), ygnmi.WithUseGet()) + if err != nil { + t.Fatalf("Lookup() returned unexpected error: %v", err) + } + if diff := cmp.Diff(tt.wantVal, got, cmp.AllowUnexported(ygnmi.Value[*exampleocconfig.Parent_Child]{}), cmpopts.IgnoreFields(ygnmi.TelemetryError{}, "Err"), cmpopts.IgnoreFields(ygnmi.Value[*exampleocconfig.Parent_Child]{}, "RecvTimestamp"), protocmp.Transform()); diff != "" { + t.Errorf("Lookup() returned unexpected diff: %s", diff) + } + }) + } + + t.Run("success ordered map", func(t *testing.T) { + fakeGNMI.Stub().GetResponse(&gpb.GetResponse{ + Notification: []*gpb.Notification{{ + Timestamp: 100, + Atomic: true, + Prefix: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, ""), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(`{ + "openconfig-withlistval:ordered-list": [ + { + "config": { + "key": "foo", + "value": "42" + }, + "key": "foo" + }, + { + "config": { + "key": "bar", + "value": "43" + }, + "key": "bar" + }, + { + "config": { + "key": "baz", + "value": "44" + }, + "key": "baz" + } + ] +}`)}}, + }}, + }}, + }, nil) + + lookupWithGetCheckFn( + t, fakeGNMI, c, + ygnmi.SingletonQuery[*exampleocconfig.Model_SingleKey_OrderedList_OrderedMap](exampleocconfigpath.Root().Model().SingleKey("foo").OrderedListMap().Config()), + "", + &gpb.GetRequest{ + Encoding: gpb.Encoding_JSON_IETF, + Type: gpb.GetRequest_CONFIG, + Prefix: &gpb.Path{}, + Path: []*gpb.Path{testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists")}, + }, + (&ygnmi.Value[*exampleocconfig.Model_SingleKey_OrderedList_OrderedMap]{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Timestamp: time.Unix(0, 100), + }).SetVal(getSamplePreferConfigOrderedMap(t)), + ) + }) + + t.Run("success whole single-keyed map", func(t *testing.T) { + fakeGNMI.Stub().GetResponse(&gpb.GetResponse{ + Notification: []*gpb.Notification{{ + Timestamp: 100, + Prefix: testutil.GNMIPath(t, "/model/a"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, ""), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(`{ + "openconfig-withlistval:single-key": [ + { + "config": { + "key": "foo", + "value": "42" + }, + "key": "foo" + }, + { + "config": { + "key": "bar", + "value": "43" + }, + "key": "bar" + }, + { + "config": { + "key": "baz", + "value": "44" + }, + "key": "baz" + } + ] +}`)}}, + }}, + }}, + }, nil) + + lookupWithGetCheckFn( + t, fakeGNMI, c, + ygnmi.SingletonQuery[map[string]*exampleocconfig.Model_SingleKey](exampleocconfigpath.Root().Model().SingleKeyMap().Config()), + "", + &gpb.GetRequest{ + Encoding: gpb.Encoding_JSON_IETF, + Type: gpb.GetRequest_CONFIG, + Prefix: &gpb.Path{}, + Path: []*gpb.Path{testutil.GNMIPath(t, "/model/a")}, + }, + (&ygnmi.Value[map[string]*exampleocconfig.Model_SingleKey]{ + Path: testutil.GNMIPath(t, "/model/a"), + Timestamp: time.Unix(0, 100), + }).SetVal(getSamplePreferConfigSingleKeyedMap(t)), + ) + }) +} + +func TestPreferConfigGet(t *testing.T) { + fakeGNMI, c := newClient(t) + leafPath := testutil.GNMIPath(t, "/remote-container/state/a-leaf") + lq := exampleocconfigpath.Root().RemoteContainer().ALeaf().State() + + tests := []struct { + desc string + stub func(s *testutil.Stubber) + wantSubscriptionPath *gpb.Path + want string + wantVal string + wantErr string + }{{ + desc: "value present", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: leafPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + wantSubscriptionPath: leafPath, + wantVal: "foo", + }, { + desc: "value not present", + stub: func(s *testutil.Stubber) { + s.Sync() + }, + wantSubscriptionPath: leafPath, + wantErr: "value not present", + }, { + desc: "error nil update", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 101, + Update: []*gpb.Update{{ + Path: leafPath, + Val: nil, + }}, + }).Sync() + }, + wantErr: "invalid nil Val", + }} + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + getCheckFn(t, fakeGNMI, c, lq, tt.wantErr, tt.wantSubscriptionPath, tt.wantVal) + }) + } + + t.Run("use get", func(t *testing.T) { + fakeGNMI.Stub().GetResponse(&gpb.GetResponse{ + Notification: []*gpb.Notification{{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "/remote-container/config/a-leaf"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(`"foo"`)}}, + }}, + }}, + }, nil) + wantGetRequest := &gpb.GetRequest{ + Encoding: gpb.Encoding_JSON_IETF, + Type: gpb.GetRequest_CONFIG, + Prefix: &gpb.Path{}, + Path: []*gpb.Path{testutil.GNMIPath(t, "/remote-container/config/a-leaf")}, + } + wantVal := "foo" + + got, err := ygnmi.Get[string](context.Background(), c, exampleocconfigpath.Root().RemoteContainer().ALeaf().Config(), ygnmi.WithUseGet()) + if err != nil { + t.Fatalf("Get() returned unexpected error: %v", err) + } + if diff := cmp.Diff(wantVal, got, cmp.AllowUnexported(ygnmi.Value[string]{}), cmpopts.IgnoreFields(ygnmi.Value[string]{}, "RecvTimestamp"), protocmp.Transform()); diff != "" { + t.Errorf("Get() returned unexpected diff: %s", diff) + } + if diff := cmp.Diff(wantGetRequest, fakeGNMI.GetRequests()[0], protocmp.Transform()); diff != "" { + t.Errorf("Get() GetRequest different from expected: %s", diff) + } + }) + + t.Run("success ordered map", func(t *testing.T) { + fakeGNMI.Stub().Notification(&gpb.Notification{ + Timestamp: 100, + Atomic: true, + Prefix: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 42}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=baz]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=baz]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=baz]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 44}}, + }}, + }).Sync() + + getCheckFn(t, fakeGNMI, c, + exampleocconfigpath.Root().Model().SingleKey("foo").OrderedListMap().State(), + "", + testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + getSamplePreferConfigOrderedMap(t), + ) + }) +} + +func TestPreferConfigWatch(t *testing.T) { + fakeGNMI, client := newClient(t) + path := testutil.GNMIPath(t, "/remote-container/state/a-leaf") + lq := exampleocconfigpath.Root().RemoteContainer().ALeaf().State() + + startTime := time.Now() + tests := []struct { + desc string + stub func(s *testutil.Stubber) + dur time.Duration + wantSubscriptionPath *gpb.Path + wantLastVal *ygnmi.Value[string] + wantVals []*ygnmi.Value[string] + wantErr string + wantMode gpb.SubscriptionMode + wantInterval uint64 + opts []ygnmi.Option + }{{ + desc: "single notif and pred true", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + dur: time.Second, + wantVals: []*ygnmi.Value[string]{ + (&ygnmi.Value[string]{ + Timestamp: startTime, + Path: path, + }).SetVal("foo")}, + wantSubscriptionPath: path, + wantLastVal: (&ygnmi.Value[string]{ + Timestamp: startTime, + Path: path, + }).SetVal("foo"), + }, { + desc: "single notif and pred true with custom mode", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + dur: time.Second, + opts: []ygnmi.Option{ygnmi.WithSubscriptionMode(gpb.SubscriptionMode_ON_CHANGE)}, + wantMode: gpb.SubscriptionMode_ON_CHANGE, + wantVals: []*ygnmi.Value[string]{ + (&ygnmi.Value[string]{ + Timestamp: startTime, + Path: path, + }).SetVal("foo")}, + wantSubscriptionPath: path, + wantLastVal: (&ygnmi.Value[string]{ + Timestamp: startTime, + Path: path, + }).SetVal("foo"), + }, { + desc: "single notif and pred true with custom interval", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + dur: time.Second, + opts: []ygnmi.Option{ygnmi.WithSampleInterval(time.Millisecond)}, + wantInterval: 1000000, + wantVals: []*ygnmi.Value[string]{ + (&ygnmi.Value[string]{ + Timestamp: startTime, + Path: path, + }).SetVal("foo")}, + wantSubscriptionPath: path, + wantLastVal: (&ygnmi.Value[string]{ + Timestamp: startTime, + Path: path, + }).SetVal("foo"), + }, { + desc: "single notif and pred false error EOF", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }).Sync() + }, + dur: time.Second, + wantVals: []*ygnmi.Value[string]{ + (&ygnmi.Value[string]{ + Timestamp: startTime, + Path: path, + }).SetVal("bar"), + }, + wantSubscriptionPath: path, + wantLastVal: (&ygnmi.Value[string]{ + Timestamp: startTime, + Path: path, + }).SetVal("bar"), + wantErr: "error receiving gNMI response: EOF", + }, { + desc: "multiple notif and pred true", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Update: []*gpb.Update{{ + Path: path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }) + }, + dur: time.Second, + wantVals: []*ygnmi.Value[string]{ + (&ygnmi.Value[string]{ + Timestamp: startTime, + Path: path, + }).SetVal("bar"), + (&ygnmi.Value[string]{ + Timestamp: startTime.Add(time.Millisecond), + Path: path, + }).SetVal("foo"), + }, + wantSubscriptionPath: path, + wantLastVal: (&ygnmi.Value[string]{ + Timestamp: startTime.Add(time.Millisecond), + Path: path, + }).SetVal("foo"), + }, { + desc: "multiple notif with deletes", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Delete: []*gpb.Path{path}, + }) + }, + dur: time.Second, + wantVals: []*ygnmi.Value[string]{ + (&ygnmi.Value[string]{ + Timestamp: startTime, + Path: path, + }).SetVal("bar"), + (&ygnmi.Value[string]{ + Timestamp: startTime.Add(time.Millisecond), + Path: path, + }), + }, + wantSubscriptionPath: path, + wantLastVal: (&ygnmi.Value[string]{ + Timestamp: startTime.Add(time.Millisecond), + Path: path, + }), + wantErr: "EOF", + }, { + desc: "negative duration", + stub: func(s *testutil.Stubber) { + s.Sync() + }, + dur: -1 * time.Second, + wantErr: "context deadline exceeded", + }} + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + watchCheckFn(t, fakeGNMI, tt.dur, client, + lq, + tt.opts, + func(val string) bool { return val == "foo" }, + tt.wantErr, + []*gpb.Path{tt.wantSubscriptionPath}, + []gpb.SubscriptionMode{tt.wantMode}, + []uint64{tt.wantInterval}, + tt.wantVals, + tt.wantLastVal, + ) + }) + } + + t.Run("multiple awaits", func(t *testing.T) { + fakeGNMI.Stub().Sync() + w := ygnmi.Watch(context.Background(), client, exampleocconfigpath.Root().RemoteContainer().ALeaf().State(), func(v *ygnmi.Value[string]) error { return nil }) + want := &ygnmi.Value[string]{ + Path: path, + } + val, err := w.Await() + if err != nil { + t.Fatalf("Await() got unexpected error: %v", err) + } + if diff := cmp.Diff(want, val, cmp.AllowUnexported(ygnmi.Value[string]{}), protocmp.Transform()); diff != "" { + t.Errorf("Await() returned unexpected value (-want,+got):\n%s", diff) + } + _, err = w.Await() + if d := errdiff.Check(err, "Await already called and Watcher is closed"); d != "" { + t.Fatalf("Await() returned unexpected diff: %s", d) + } + }) + + rootPath := testutil.GNMIPath(t, "parent/child") + strPath := testutil.GNMIPath(t, "parent/child/state/one") + enumPath := testutil.GNMIPath(t, "parent/child/state/three") + startTime = time.Now() + nonLeafQuery := exampleocconfigpath.Root().Parent().Child().State() + + nonLeafTests := []struct { + desc string + stub func(s *testutil.Stubber) + opts []ygnmi.Option + wantSubscriptionPath *gpb.Path + wantLastVal *ygnmi.Value[*exampleocconfig.Parent_Child] + wantVals []*ygnmi.Value[*exampleocconfig.Parent_Child] + wantErr string + }{{ + desc: "single notif and pred false", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: strPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }).Sync() + }, + wantVals: []*ygnmi.Value[*exampleocconfig.Parent_Child]{ + (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime, + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + One: ygot.String("bar"), + }), + }, + wantErr: "EOF", + wantSubscriptionPath: rootPath, + wantLastVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime, + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + One: ygot.String("bar"), + }), + }, { + desc: "multiple notif and pred true", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: strPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Update: []*gpb.Update{{ + Path: enumPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "ONE"}}, + }}, + }) + }, + wantVals: []*ygnmi.Value[*exampleocconfig.Parent_Child]{ + (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime, + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + One: ygot.String("foo"), + }), + (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime.Add(time.Millisecond), + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + Three: exampleocconfig.Child_Three_ONE, + One: ygot.String("foo"), + }), + }, + wantSubscriptionPath: rootPath, + wantLastVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime.Add(time.Millisecond), + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + Three: exampleocconfig.Child_Three_ONE, + One: ygot.String("foo"), + }), + }, { + desc: "multiple notif before sync", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: strPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Update: []*gpb.Update{{ + Path: enumPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "ONE"}}, + }}, + }).Sync() + }, + wantVals: []*ygnmi.Value[*exampleocconfig.Parent_Child]{ + (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime.Add(time.Millisecond), + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + Three: exampleocconfig.Child_Three_ONE, + One: ygot.String("foo"), + })}, + wantSubscriptionPath: rootPath, + wantLastVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime.Add(time.Millisecond), + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + Three: exampleocconfig.Child_Three_ONE, + One: ygot.String("foo"), + }), + }, { + desc: "delete leaf in container", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: strPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: enumPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "ONE"}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Delete: []*gpb.Path{strPath}, + }) + }, + wantVals: []*ygnmi.Value[*exampleocconfig.Parent_Child]{ + (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime, + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + Three: exampleocconfig.Child_Three_ONE, + One: ygot.String("bar"), + }), + (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime.Add(time.Millisecond), + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + Three: exampleocconfig.Child_Three_ONE, + }), + }, + wantSubscriptionPath: rootPath, + wantErr: "EOF", + wantLastVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime.Add(time.Millisecond), + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + Three: exampleocconfig.Child_Three_ONE, + }), + }, { + desc: "delete at container level", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: strPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: enumPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "ONE"}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Delete: []*gpb.Path{testutil.GNMIPath(t, "parent/child")}, + }) + }, + wantVals: []*ygnmi.Value[*exampleocconfig.Parent_Child]{ + (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime, + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + Three: exampleocconfig.Child_Three_ONE, + One: ygot.String("bar"), + }), + (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime.Add(time.Millisecond), + Path: rootPath, + }), + }, + wantSubscriptionPath: rootPath, + wantErr: "EOF", + wantLastVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime.Add(time.Millisecond), + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + Three: exampleocconfig.Child_Three_ONE, + }), + }} + + for _, tt := range nonLeafTests { + t.Run("nonleaf "+tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + watchCheckFn(t, fakeGNMI, 2*time.Second, client, + nonLeafQuery, + tt.opts, + func(val *exampleocconfig.Parent_Child) bool { + return val.One != nil && *val.One == "foo" && val.Three == exampleocconfig.Child_Three_ONE + }, + tt.wantErr, + []*gpb.Path{tt.wantSubscriptionPath}, + []gpb.SubscriptionMode{gpb.SubscriptionMode_TARGET_DEFINED}, + []uint64{0}, + tt.wantVals, + tt.wantLastVal, + ) + }) + } + + t.Run("success ordered map", func(t *testing.T) { + fakeGNMI.Stub().Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Atomic: true, + Prefix: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 42}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Atomic: true, + Prefix: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 42}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=baz]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=baz]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=baz]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 44}}, + }}, + }) + + want := getSamplePreferConfigOrderedMap(t) + watchCheckFn(t, fakeGNMI, 2*time.Second, client, + exampleocconfigpath.Root().Model().SingleKey("foo").OrderedListMap().State(), + nil, + func(val *exampleocconfig.Model_SingleKey_OrderedList_OrderedMap) bool { + return cmp.Equal(val, want, cmp.AllowUnexported(exampleocconfig.Model_SingleKey_OrderedList_OrderedMap{})) + }, + "", + []*gpb.Path{testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists")}, + []gpb.SubscriptionMode{gpb.SubscriptionMode_TARGET_DEFINED}, + []uint64{0}, + []*ygnmi.Value[*exampleocconfig.Model_SingleKey_OrderedList_OrderedMap]{ + (&ygnmi.Value[*exampleocconfig.Model_SingleKey_OrderedList_OrderedMap]{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Timestamp: startTime, + }).SetVal(getSamplePreferConfigOrderedMapIncomplete(t)), + (&ygnmi.Value[*exampleocconfig.Model_SingleKey_OrderedList_OrderedMap]{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Timestamp: startTime.Add(time.Millisecond), + }).SetVal(getSamplePreferConfigOrderedMap(t)), + }, + (&ygnmi.Value[*exampleocconfig.Model_SingleKey_OrderedList_OrderedMap]{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Timestamp: startTime.Add(time.Millisecond), + }).SetVal(getSamplePreferConfigOrderedMap(t)), + ) + }) + + t.Run("success whole single-keyed map", func(t *testing.T) { + fakeGNMI.Stub().Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Prefix: testutil.GNMIPath(t, "/model/a"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, `single-key[key=foo]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=foo]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=foo]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 42}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Prefix: testutil.GNMIPath(t, "/model/a"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, `single-key[key=foo]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=foo]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=foo]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 42}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=baz]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=baz]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=baz]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 44}}, + }}, + }) + + want := getSamplePreferConfigSingleKeyedMap(t) + watchCheckFn(t, fakeGNMI, 2*time.Second, client, + exampleocconfigpath.Root().Model().SingleKeyMap().State(), + nil, + func(val map[string]*exampleocconfig.Model_SingleKey) bool { + return cmp.Equal(val, want) + }, + "", + []*gpb.Path{testutil.GNMIPath(t, "/model/a")}, + []gpb.SubscriptionMode{gpb.SubscriptionMode_TARGET_DEFINED}, + []uint64{0}, + []*ygnmi.Value[map[string]*exampleocconfig.Model_SingleKey]{ + (&ygnmi.Value[map[string]*exampleocconfig.Model_SingleKey]{ + Path: testutil.GNMIPath(t, "/model/a"), + Timestamp: startTime, + }).SetVal(getSamplePreferConfigSingleKeyedMapIncomplete(t)), + (&ygnmi.Value[map[string]*exampleocconfig.Model_SingleKey]{ + Path: testutil.GNMIPath(t, "/model/a"), + Timestamp: startTime.Add(time.Millisecond), + }).SetVal(getSamplePreferConfigSingleKeyedMap(t)), + }, + (&ygnmi.Value[map[string]*exampleocconfig.Model_SingleKey]{ + Path: testutil.GNMIPath(t, "/model/a"), + Timestamp: startTime.Add(time.Millisecond), + }).SetVal(getSamplePreferConfigSingleKeyedMap(t)), + ) + }) +} + +func TestPreferConfigAwait(t *testing.T) { + fakeGNMI, client := newClient(t) + path := testutil.GNMIPath(t, "/remote-container/state/a-leaf") + lq := exampleocconfigpath.Root().RemoteContainer().ALeaf().State() + + startTime := time.Now() + tests := []struct { + desc string + stub func(s *testutil.Stubber) + dur time.Duration + wantSubscriptionPath *gpb.Path + wantVal *ygnmi.Value[string] + wantErr string + wantMode gpb.SubscriptionMode + opts []ygnmi.Option + }{{ + desc: "value never equal", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }).Sync() + }, + dur: time.Second, + wantSubscriptionPath: path, + wantErr: "EOF", + }, { + desc: "success", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + dur: time.Second, + wantSubscriptionPath: path, + wantVal: (&ygnmi.Value[string]{ + Timestamp: startTime, + Path: path, + }).SetVal("foo"), + }, { + desc: "success with custom mode", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + dur: time.Second, + opts: []ygnmi.Option{ygnmi.WithSubscriptionMode(gpb.SubscriptionMode_ON_CHANGE)}, + wantMode: gpb.SubscriptionMode_ON_CHANGE, + wantSubscriptionPath: path, + wantVal: (&ygnmi.Value[string]{ + Timestamp: startTime, + Path: path, + }).SetVal("foo"), + }} + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + ctx, cancel := context.WithTimeout(context.Background(), tt.dur) + defer cancel() + val, err := ygnmi.Await(ctx, client, lq, "foo", tt.opts...) + verifySubscriptionModesSent(t, fakeGNMI, tt.wantMode) + if diff := errdiff.Substring(err, tt.wantErr); diff != "" { + t.Fatalf("Await() returned unexpected diff: %s", diff) + } + if err != nil { + return + } + if val != nil { + checkJustReceived(t, val.RecvTimestamp) + tt.wantVal.RecvTimestamp = val.RecvTimestamp + } + if diff := cmp.Diff(tt.wantVal, val, cmp.AllowUnexported(ygnmi.Value[string]{}), protocmp.Transform()); diff != "" { + t.Errorf("Await() returned unexpected value (-want,+got):\n%s", diff) + } + }) + } + + rootPath := testutil.GNMIPath(t, "parent/child") + strPath := testutil.GNMIPath(t, "parent/child/state/one") + enumPath := testutil.GNMIPath(t, "parent/child/state/three") + startTime = time.Now() + nonLeafQuery := exampleocconfigpath.Root().Parent().Child().State() + + nonLeafTests := []struct { + desc string + stub func(s *testutil.Stubber) + wantSubscriptionPath *gpb.Path + wantLastVal *ygnmi.Value[*exampleocconfig.Parent_Child] + wantErr string + }{{ + desc: "value never equal", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: strPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }).Sync() + }, + wantErr: "EOF", + wantSubscriptionPath: rootPath, + wantLastVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime, + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + One: ygot.String("bar"), + }), + }, { + desc: "success", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: strPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Update: []*gpb.Update{{ + Path: enumPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "ONE"}}, + }}, + }) + }, + wantSubscriptionPath: rootPath, + wantLastVal: (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime.Add(time.Millisecond), + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + Three: exampleocconfig.Child_Three_ONE, + One: ygot.String("foo"), + }), + }} + + for _, tt := range nonLeafTests { + t.Run("nonleaf "+tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + val, err := ygnmi.Await(context.Background(), client, nonLeafQuery, &exampleocconfig.Parent_Child{One: ygot.String("foo"), Three: exampleocconfig.Child_Three_ONE}) + if diff := errdiff.Substring(err, tt.wantErr); diff != "" { + t.Fatalf("Await() returned unexpected diff: %s", diff) + } + if err != nil { + return + } + verifySubscriptionPathsSent(t, fakeGNMI, tt.wantSubscriptionPath) + if val != nil { + checkJustReceived(t, val.RecvTimestamp) + tt.wantLastVal.RecvTimestamp = val.RecvTimestamp + } + if diff := cmp.Diff(tt.wantLastVal, val, cmp.AllowUnexported(ygnmi.Value[*exampleocconfig.Parent_Child]{}), protocmp.Transform()); diff != "" { + t.Errorf("Await() returned unexpected value (-want,+got):\n%s", diff) + } + }) + } +} + +func TestPreferConfigCollect(t *testing.T) { + fakeGNMI, client := newClient(t) + path := testutil.GNMIPath(t, "/remote-container/state/a-leaf") + lq := exampleocconfigpath.Root().RemoteContainer().ALeaf().State() + + startTime := time.Now() + tests := []struct { + desc string + stub func(s *testutil.Stubber) + dur time.Duration + wantSubscriptionPath *gpb.Path + wantVals []*ygnmi.Value[string] + wantErr string + wantMode gpb.SubscriptionMode + opts []ygnmi.Option + }{{ + desc: "no values", + stub: func(s *testutil.Stubber) { + s.Sync() + }, + dur: time.Second, + wantSubscriptionPath: path, + wantErr: "EOF", + wantVals: []*ygnmi.Value[string]{ + (&ygnmi.Value[string]{ + Path: path, + }), + }, + }, { + desc: "multiple values", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Update: []*gpb.Update{{ + Path: path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }) + }, + dur: 100 * time.Millisecond, + wantSubscriptionPath: path, + wantErr: "EOF", + wantVals: []*ygnmi.Value[string]{ + (&ygnmi.Value[string]{ + Timestamp: startTime, + Path: path, + }).SetVal("foo"), + (&ygnmi.Value[string]{ + Timestamp: startTime.Add(time.Millisecond), + Path: path, + }).SetVal("bar"), + }, + }, { + desc: "multiple values and custom mode", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Update: []*gpb.Update{{ + Path: path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }) + }, + dur: 100 * time.Millisecond, + wantSubscriptionPath: path, + opts: []ygnmi.Option{ygnmi.WithSubscriptionMode(gpb.SubscriptionMode_ON_CHANGE)}, + wantMode: gpb.SubscriptionMode_ON_CHANGE, + wantErr: "EOF", + wantVals: []*ygnmi.Value[string]{ + (&ygnmi.Value[string]{ + Timestamp: startTime, + Path: path, + }).SetVal("foo"), + (&ygnmi.Value[string]{ + Timestamp: startTime.Add(time.Millisecond), + Path: path, + }).SetVal("bar"), + }, + }} + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + collectCheckFn(t, fakeGNMI, client, lq, tt.wantErr, tt.wantSubscriptionPath, tt.wantVals) + }) + } + + rootPath := testutil.GNMIPath(t, "parent/child") + strPath := testutil.GNMIPath(t, "parent/child/state/one") + enumPath := testutil.GNMIPath(t, "parent/child/state/three") + startTime = time.Now() + nonLeafQuery := exampleocconfigpath.Root().Parent().Child().State() + + nonLeafTests := []struct { + desc string + stub func(s *testutil.Stubber) + wantSubscriptionPath *gpb.Path + wantVals []*ygnmi.Value[*exampleocconfig.Parent_Child] + wantErr string + }{{ + desc: "one val", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: strPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }).Sync() + }, + wantErr: "EOF", + wantSubscriptionPath: rootPath, + wantVals: []*ygnmi.Value[*exampleocconfig.Parent_Child]{ + (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime, + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + One: ygot.String("bar"), + }), + }, + }, { + desc: "multiple values", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: strPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Update: []*gpb.Update{{ + Path: enumPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "ONE"}}, + }}, + }) + }, + wantErr: "EOF", + wantSubscriptionPath: rootPath, + wantVals: []*ygnmi.Value[*exampleocconfig.Parent_Child]{ + (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime, + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + One: ygot.String("foo"), + }), + (&ygnmi.Value[*exampleocconfig.Parent_Child]{ + Timestamp: startTime.Add(time.Millisecond), + Path: rootPath, + }).SetVal(&exampleocconfig.Parent_Child{ + Three: exampleocconfig.Child_Three_ONE, + One: ygot.String("foo"), + }), + }, + }} + + for _, tt := range nonLeafTests { + t.Run("nonleaf "+tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + collectCheckFn(t, fakeGNMI, client, nonLeafQuery, tt.wantErr, tt.wantSubscriptionPath, tt.wantVals) + }) + } +} + +func TestPreferConfigLookupAll(t *testing.T) { + fakeGNMI, c := newClient(t) + leafPath := testutil.GNMIPath(t, "model/a/single-key[key=*]/state/value") + lq := exampleocconfigpath.Root().Model().SingleKeyAny().Value().State() + + leafTests := []struct { + desc string + stub func(s *testutil.Stubber) + wantSubscriptionPath *gpb.Path + wantVals []*ygnmi.Value[int64] + wantErr string + }{{ + desc: "success one value", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 10}}, + }}, + }).Sync() + }, + wantVals: []*ygnmi.Value[int64]{ + (&ygnmi.Value[int64]{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value"), + Timestamp: time.Unix(0, 100), + }).SetVal(10), + }, + wantSubscriptionPath: leafPath, + }, { + desc: "success no values", + stub: func(s *testutil.Stubber) { + s.Sync() + }, + wantVals: nil, + wantSubscriptionPath: leafPath, + }, { + desc: "non compliant value", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 10}}, + }, { + Path: testutil.GNMIPath(t, "model/a/single-key[key=11]/state/fake-val"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 11}}, + }}, + }).Sync() + }, + wantVals: []*ygnmi.Value[int64]{ + (&ygnmi.Value[int64]{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value"), + Timestamp: time.Unix(0, 100), + }).SetVal(10), + }, + wantSubscriptionPath: leafPath, + }, { + desc: "success multiples value in same notification", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 10}}, + }, { + Path: testutil.GNMIPath(t, "model/a/single-key[key=11]/state/value"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 11}}, + }}, + }).Sync() + }, + wantVals: []*ygnmi.Value[int64]{ + (&ygnmi.Value[int64]{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value"), + Timestamp: time.Unix(0, 100), + }).SetVal(10), + (&ygnmi.Value[int64]{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=11]/state/value"), + Timestamp: time.Unix(0, 100), + }).SetVal(11)}, + wantSubscriptionPath: leafPath, + }, { + desc: "success multiples value in different notifications", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 10}}, + }}, + }).Notification(&gpb.Notification{ + Timestamp: 101, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=11]/state/value"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 11}}, + }}, + }).Sync() + }, + wantVals: []*ygnmi.Value[int64]{ + (&ygnmi.Value[int64]{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value"), + Timestamp: time.Unix(0, 100), + }).SetVal(10), + (&ygnmi.Value[int64]{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=11]/state/value"), + Timestamp: time.Unix(0, 101), + }).SetVal(11)}, + wantSubscriptionPath: leafPath, + }, { + desc: "success ignore mismatched paths", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=11]/config/value"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 11}}, + }}, + }).Sync() + }, + wantVals: nil, + wantSubscriptionPath: leafPath, + }, { + desc: "success ignore mismatched types", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=11]/state/value"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: ""}}, + }}, + }).Sync() + }, + wantVals: nil, + wantSubscriptionPath: leafPath, + }, { + desc: "error nil update val", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=11]/state/value"), + Val: nil, + }}, + }).Sync() + }, + wantErr: "failed to receive to data", + wantSubscriptionPath: leafPath, + }} + + for _, tt := range leafTests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + lookupAllCheckFn(t, fakeGNMI, c, lq, tt.wantErr, tt.wantSubscriptionPath, tt.wantVals, false) + }) + } + + nonLeafPath := testutil.GNMIPath(t, "model/a/single-key[key=*]") + nonLeafQ := exampleocconfigpath.Root().Model().SingleKeyAny().State() + nonLeafTests := []struct { + desc string + stub func(s *testutil.Stubber) + wantSubscriptionPath *gpb.Path + wantVals []*ygnmi.Value[*exampleocconfig.Model_SingleKey] + wantErr string + }{{ + desc: "one value", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 10}}, + }}, + }).Sync() + }, + wantVals: []*ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]"), + Timestamp: time.Unix(0, 100), + }).SetVal(&exampleocconfig.Model_SingleKey{ + Value: ygot.Int64(10), + }), + }, + wantSubscriptionPath: nonLeafPath, + }, { + desc: "multiple values", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 100}}, + }, { + Path: testutil.GNMIPath(t, "model/a/single-key[key=11]/state/value"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 101}}, + }, { + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/key"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "10"}}, + }}, + }).Notification(&gpb.Notification{ + Timestamp: 101, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=11]/state/key"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "11"}}, + }}, + }).Sync() + }, + wantVals: []*ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]"), + Timestamp: time.Unix(0, 100), + }).SetVal(&exampleocconfig.Model_SingleKey{ + Value: ygot.Int64(100), + Key: ygot.String("10"), + }), + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=11]"), + Timestamp: time.Unix(0, 101), + }).SetVal(&exampleocconfig.Model_SingleKey{ + Value: ygot.Int64(101), + Key: ygot.String("11"), + }), + }, + wantSubscriptionPath: nonLeafPath, + }, { + desc: "non compliant values", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value-fake"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 100}}, + }, { + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/key"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "10"}}, + }}, + }).Sync() + }, + wantVals: []*ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]"), + Timestamp: time.Unix(0, 100), + ComplianceErrors: &ygnmi.ComplianceErrors{ + PathErrors: []*ygnmi.TelemetryError{{ + Value: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 100}}, + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value-fake"), + }}, + }, + }).SetVal(&exampleocconfig.Model_SingleKey{ + Key: ygot.String("10"), + }), + }, + wantSubscriptionPath: nonLeafPath, + }, { + desc: "no values", + stub: func(s *testutil.Stubber) { + s.Sync() + }, + wantVals: nil, + wantSubscriptionPath: nonLeafPath, + }} + + for _, tt := range nonLeafTests { + t.Run("nonLeaf "+tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + lookupAllCheckFn(t, fakeGNMI, c, nonLeafQ, tt.wantErr, tt.wantSubscriptionPath, tt.wantVals, true) + }) + } + + t.Run("success ordered map", func(t *testing.T) { + fakeGNMI.Stub().Notification(&gpb.Notification{ + Timestamp: 100, + Atomic: true, + Prefix: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 42}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=baz]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=baz]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=baz]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 44}}, + }}, + }).Notification(&gpb.Notification{ + Timestamp: 101, + Atomic: true, + Prefix: testutil.GNMIPath(t, "/model/a/single-key[key=bar]/ordered-lists"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 42}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }, { + Path: testutil.GNMIPath(t, `ordered-list[key=bar]/state/dne-value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }}, + }).Sync() + + lookupAllCheckFn( + t, fakeGNMI, c, + exampleocconfigpath.Root().Model().SingleKeyAny().OrderedListMap().State(), + "", + testutil.GNMIPath(t, "/model/a/single-key[key=*]/ordered-lists"), + []*ygnmi.Value[*exampleocconfig.Model_SingleKey_OrderedList_OrderedMap]{ + // In alphabetical order. + (&ygnmi.Value[*exampleocconfig.Model_SingleKey_OrderedList_OrderedMap]{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=bar]/ordered-lists"), + Timestamp: time.Unix(0, 101), + ComplianceErrors: &ygnmi.ComplianceErrors{ + PathErrors: []*ygnmi.TelemetryError{{ + Value: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + Path: testutil.GNMIPath(t, "model/a/single-key[key=bar]/ordered-lists/ordered-list[key=bar]/state/dne-value"), + }}, + }, + }).SetVal(getSamplePreferConfigOrderedMapIncomplete(t)), + (&ygnmi.Value[*exampleocconfig.Model_SingleKey_OrderedList_OrderedMap]{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Timestamp: time.Unix(0, 100), + }).SetVal(getSamplePreferConfigOrderedMap(t)), + }, + true, + ) + }) + + t.Run("success whole single-keyed map", func(t *testing.T) { + fakeGNMI.Stub().Notification(&gpb.Notification{ + Timestamp: 100, + Atomic: true, + Prefix: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/inner-a"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, `single-key[key=foo]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=foo]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=foo]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 42}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=baz]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=baz]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=baz]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 44}}, + }}, + }).Notification(&gpb.Notification{ + Timestamp: 101, + Atomic: true, + Prefix: testutil.GNMIPath(t, "/model/a/single-key[key=bar]/inner-a"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, `single-key[key=foo]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=foo]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=foo]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 42}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/state/dne-value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }}, + }).Sync() + + lookupAllCheckFn( + t, fakeGNMI, c, + exampleocconfigpath.Root().Model().SingleKeyAny().SingleKeyMap().State(), + "", + testutil.GNMIPath(t, "/model/a/single-key[key=*]/inner-a"), + []*ygnmi.Value[map[string]*exampleocconfig.Model_SingleKey_SingleKey]{ + // In alphabetical order. + (&ygnmi.Value[map[string]*exampleocconfig.Model_SingleKey_SingleKey]{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=bar]/inner-a"), + Timestamp: time.Unix(0, 101), + ComplianceErrors: &ygnmi.ComplianceErrors{ + PathErrors: []*ygnmi.TelemetryError{{ + Value: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + Path: testutil.GNMIPath(t, "model/a/single-key[key=bar]/inner-a/single-key[key=bar]/state/dne-value"), + }}, + }, + }).SetVal(getSamplePreferConfigInnerSingleKeyedMapIncomplete(t)), + (&ygnmi.Value[map[string]*exampleocconfig.Model_SingleKey_SingleKey]{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/inner-a"), + Timestamp: time.Unix(0, 100), + }).SetVal(getSamplePreferConfigInnerSingleKeyedMap(t)), + }, + true, + ) + }) + + t.Run("use get", func(t *testing.T) { + fakeGNMI.Stub().GetResponse(&gpb.GetResponse{ + Notification: []*gpb.Notification{{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: leafPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(`"1"`)}}, + }}, + }}, + }, nil) + wantGetRequest := &gpb.GetRequest{ + Encoding: gpb.Encoding_JSON_IETF, + Type: gpb.GetRequest_STATE, + Prefix: &gpb.Path{}, + Path: []*gpb.Path{leafPath}, + } + wantVal := []*ygnmi.Value[int64]{(&ygnmi.Value[int64]{ + Path: leafPath, + Timestamp: time.Unix(0, 100), + }).SetVal(1)} + + got, err := ygnmi.LookupAll(context.Background(), c, lq, ygnmi.WithUseGet()) + if err != nil { + t.Fatalf("LookupAll() returned unexpected error: %v", err) + } + if diff := cmp.Diff(wantVal, got, cmp.AllowUnexported(ygnmi.Value[int64]{}), cmpopts.IgnoreFields(ygnmi.Value[int64]{}, "RecvTimestamp"), protocmp.Transform()); diff != "" { + t.Errorf("LookupAll() returned unexpected diff: %s", diff) + } + if diff := cmp.Diff(wantGetRequest, fakeGNMI.GetRequests()[0], protocmp.Transform()); diff != "" { + t.Errorf("LookupAll() GetRequest different from expected: %s", diff) + } + }) +} + +func TestPreferConfigGetAll(t *testing.T) { + fakeGNMI, c := newClient(t) + leafPath := testutil.GNMIPath(t, "model/a/single-key[key=*]/state/value") + lq := exampleocconfigpath.Root().Model().SingleKeyAny().Value().State() + + tests := []struct { + desc string + stub func(s *testutil.Stubber) + wantSubscriptionPath *gpb.Path + wantVals []int64 + wantErr string + }{{ + desc: "success", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 10}}, + }}, + }).Sync() + }, + wantVals: []int64{10}, + wantSubscriptionPath: leafPath, + }, { + desc: "success no values", + stub: func(s *testutil.Stubber) { + s.Sync() + }, + wantErr: ygnmi.ErrNotPresent.Error(), + wantSubscriptionPath: leafPath, + }} + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + got, err := ygnmi.GetAll(context.Background(), c, lq) + if diff := errdiff.Substring(err, tt.wantErr); diff != "" { + t.Fatalf("LookupAll(ctx, c, %v) returned unexpected diff: %s", lq, diff) + } + if err != nil { + return + } + verifySubscriptionPathsSent(t, fakeGNMI, tt.wantSubscriptionPath) + if diff := cmp.Diff(tt.wantVals, got); diff != "" { + t.Errorf("LookupAll() returned unexpected diff (-want,+got):\n%s", diff) + } + }) + } + t.Run("use get", func(t *testing.T) { + fakeGNMI.Stub().GetResponse(&gpb.GetResponse{ + Notification: []*gpb.Notification{{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: leafPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(`"1"`)}}, + }}, + }}, + }, nil) + wantGetRequest := &gpb.GetRequest{ + Encoding: gpb.Encoding_JSON_IETF, + Type: gpb.GetRequest_STATE, + Prefix: &gpb.Path{}, + Path: []*gpb.Path{leafPath}, + } + wantVal := []int64{1} + + got, err := ygnmi.GetAll(context.Background(), c, exampleocconfigpath.Root().Model().SingleKeyAny().Value().State(), ygnmi.WithUseGet()) + if err != nil { + t.Fatalf("Get() returned unexpected error: %v", err) + } + if diff := cmp.Diff(wantVal, got, cmp.AllowUnexported(ygnmi.Value[string]{}), cmpopts.IgnoreFields(ygnmi.Value[string]{}, "RecvTimestamp"), protocmp.Transform()); diff != "" { + t.Errorf("Get() returned unexpected diff: %s", diff) + } + if diff := cmp.Diff(wantGetRequest, fakeGNMI.GetRequests()[0], protocmp.Transform()); diff != "" { + t.Errorf("Get() GetRequest different from expected: %s", diff) + } + }) +} + +func TestPreferConfigWatchAll(t *testing.T) { + fakeGNMI, client := newClient(t) + leafQueryPath := testutil.GNMIPath(t, "model/a/single-key[key=*]/state/value") + key10Path := testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value") + key11Path := testutil.GNMIPath(t, "model/a/single-key[key=11]/state/value") + + startTime := time.Now() + lq := exampleocconfigpath.Root().Model().SingleKeyAny().Value().State() + tests := []struct { + desc string + stub func(s *testutil.Stubber) + dur time.Duration + wantSubscriptionPath *gpb.Path + wantLastVal *ygnmi.Value[int64] + wantVals []*ygnmi.Value[int64] + wantErr string + wantMode gpb.SubscriptionMode + opts []ygnmi.Option + }{{ + desc: "predicate not true", + dur: time.Second, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: key10Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 100}}, + }}, + }).Sync() + }, + wantSubscriptionPath: leafQueryPath, + wantVals: []*ygnmi.Value[int64]{ + (&ygnmi.Value[int64]{ + Timestamp: startTime, + Path: key10Path, + }).SetVal(100), + }, + wantLastVal: (&ygnmi.Value[int64]{ + Timestamp: startTime, + Path: key10Path, + }).SetVal(100), + wantErr: "EOF", + }, { + desc: "predicate becomes true", + dur: time.Second, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: key10Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 100}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Update: []*gpb.Update{{ + Path: key11Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 101}}, + }}, + }) + }, + wantSubscriptionPath: leafQueryPath, + wantVals: []*ygnmi.Value[int64]{ + (&ygnmi.Value[int64]{ + Timestamp: startTime, + Path: key10Path, + }).SetVal(100), + (&ygnmi.Value[int64]{ + Timestamp: startTime.Add(time.Millisecond), + Path: key11Path, + }).SetVal(101), + }, + wantLastVal: (&ygnmi.Value[int64]{ + Timestamp: startTime.Add(time.Millisecond), + Path: key11Path, + }).SetVal(101), + }, { + desc: "predicate becomes true with custom mode", + dur: time.Second, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: key10Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 100}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Update: []*gpb.Update{{ + Path: key11Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 101}}, + }}, + }) + }, + opts: []ygnmi.Option{ygnmi.WithSubscriptionMode(gpb.SubscriptionMode_ON_CHANGE)}, + wantMode: gpb.SubscriptionMode_ON_CHANGE, + wantSubscriptionPath: leafQueryPath, + wantVals: []*ygnmi.Value[int64]{ + (&ygnmi.Value[int64]{ + Timestamp: startTime, + Path: key10Path, + }).SetVal(100), + (&ygnmi.Value[int64]{ + Timestamp: startTime.Add(time.Millisecond), + Path: key11Path, + }).SetVal(101), + }, + wantLastVal: (&ygnmi.Value[int64]{ + Timestamp: startTime.Add(time.Millisecond), + Path: key11Path, + }).SetVal(101), + }, { + desc: "multiple values in notification", + dur: time.Second, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: key10Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 100}}, + }, { + Path: key11Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 101}}, + }}, + }).Sync() + }, + wantSubscriptionPath: leafQueryPath, + wantVals: []*ygnmi.Value[int64]{ + (&ygnmi.Value[int64]{ + Timestamp: startTime, + Path: key10Path, + }).SetVal(100), + (&ygnmi.Value[int64]{ + Timestamp: startTime, + Path: key11Path, + }).SetVal(101), + }, + wantLastVal: (&ygnmi.Value[int64]{ + Timestamp: startTime, + Path: key11Path, + }).SetVal(101), + }, { + desc: "error nil value", + dur: time.Second, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: key10Path, + Val: nil, + }}, + }).Sync() + }, + wantSubscriptionPath: leafQueryPath, + wantLastVal: nil, + wantErr: "invalid nil Val in update", + }, { + desc: "subscribe fails", + dur: -1 * time.Second, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: key10Path, + Val: nil, + }}, + }).Sync() + }, + wantSubscriptionPath: leafQueryPath, + wantLastVal: nil, + wantErr: "gNMI failed to Subscribe", + }} + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + i := 0 + ctx, cancel := context.WithTimeout(context.Background(), tt.dur) + defer cancel() + var key10Cond, key11Cond bool + + w := ygnmi.WatchAll(ctx, client, lq, func(v *ygnmi.Value[int64]) error { + if i > len(tt.wantVals) { + t.Fatalf("Predicate(%d) expected no more values but got: %+v", i, v) + } + if diff := cmp.Diff(tt.wantVals[i], v, cmpopts.IgnoreFields(ygnmi.Value[int64]{}, "RecvTimestamp"), cmp.AllowUnexported(ygnmi.Value[int64]{}), protocmp.Transform()); diff != "" { + t.Errorf("Predicate(%d) got unexpected input (-want,+got):\n %s\nComplianceErrors:\n%v", i, diff, v.ComplianceErrors) + } + val, present := v.Val() + key10Cond = key10Cond || (present && proto.Equal(v.Path, key10Path) && val == 100) + key11Cond = key11Cond || (present && proto.Equal(v.Path, key11Path) && val == 101) + i++ + if key10Cond && key11Cond { + return nil + } + return ygnmi.Continue + }, tt.opts...) + val, err := w.Await() + if i < len(tt.wantVals) { + t.Errorf("Predicate received too few values: got %d, want %d", i, len(tt.wantVals)) + } + if diff := errdiff.Substring(err, tt.wantErr); diff != "" { + t.Fatalf("Await() returned unexpected diff: %s", diff) + } + verifySubscriptionModesSent(t, fakeGNMI, tt.wantMode) + if val != nil { + checkJustReceived(t, val.RecvTimestamp) + tt.wantLastVal.RecvTimestamp = val.RecvTimestamp + } + if diff := cmp.Diff(tt.wantLastVal, val, cmp.AllowUnexported(ygnmi.Value[int64]{}), protocmp.Transform()); diff != "" { + t.Errorf("Await() returned unexpected value (-want,+got):\n%s", diff) + } + }) + } + + nonLeafPath := testutil.GNMIPath(t, "model/a/single-key[key=*]") + nonLeafKey10Path := testutil.GNMIPath(t, "model/a/single-key[key=10]") + nonLeafKey11Path := testutil.GNMIPath(t, "model/a/single-key[key=11]") + + nonLeafQ := exampleocconfigpath.Root().Model().SingleKeyAny().State() + nonLeafTests := []struct { + desc string + stub func(s *testutil.Stubber) + dur time.Duration + wantSubscriptionPath *gpb.Path + wantLastVal *ygnmi.Value[*exampleocconfig.Model_SingleKey] + wantVals []*ygnmi.Value[*exampleocconfig.Model_SingleKey] + wantErr string + }{{ + desc: "predicate not true", + dur: time.Second, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: key10Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 100}}, + }}, + }).Sync() + }, + wantSubscriptionPath: nonLeafPath, + wantVals: []*ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime, + Path: nonLeafKey10Path, + }).SetVal(&exampleocconfig.Model_SingleKey{ + Value: ygot.Int64(100), + }), + }, + wantLastVal: (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime, + Path: nonLeafKey10Path, + }).SetVal(&exampleocconfig.Model_SingleKey{ + Value: ygot.Int64(100), + }), + wantErr: "EOF", + }, { + desc: "predicate becomes true", + dur: time.Second, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: key10Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 100}}, + }, { + Path: testutil.GNMIPath(t, "model/a/single-key[key=11]/state/key"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "test"}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Update: []*gpb.Update{{ + Path: key11Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 101}}, + }}, + }) + }, + wantSubscriptionPath: nonLeafPath, + wantVals: []*ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime, + Path: nonLeafKey10Path, + }).SetVal(&exampleocconfig.Model_SingleKey{ + Value: ygot.Int64(100), + }), + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime, + Path: nonLeafKey11Path, + }).SetVal(&exampleocconfig.Model_SingleKey{ + Key: ygot.String("test"), + }), + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime.Add(time.Millisecond), + Path: nonLeafKey11Path, + }).SetVal(&exampleocconfig.Model_SingleKey{ + Value: ygot.Int64(101), + Key: ygot.String("test"), + }), + }, + wantLastVal: (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime.Add(time.Millisecond), + Path: nonLeafKey11Path, + }).SetVal(&exampleocconfig.Model_SingleKey{ + Value: ygot.Int64(101), + Key: ygot.String("test"), + }), + }, { + desc: "predicate becomes true after some deletions", + dur: time.Second, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: key10Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 100}}, + }, { + Path: testutil.GNMIPath(t, "model/a/single-key[key=11]/state/key"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "test"}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Delete: []*gpb.Path{testutil.GNMIPath(t, "model/a/single-key[key=11]/state/key")}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(2 * time.Millisecond).UnixNano(), + Delete: []*gpb.Path{testutil.GNMIPath(t, "model/a/single-key[key=10]")}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(3 * time.Millisecond).UnixNano(), + Update: []*gpb.Update{{ + Path: key10Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 100}}, + }, { + Path: testutil.GNMIPath(t, "model/a/single-key[key=11]/state/key"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "test"}}, + }, { + Path: key11Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 101}}, + }}, + }) + }, + wantSubscriptionPath: nonLeafPath, + wantVals: []*ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime, + Path: nonLeafKey10Path, + }).SetVal(&exampleocconfig.Model_SingleKey{ + Value: ygot.Int64(100), + }), + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime, + Path: nonLeafKey11Path, + }).SetVal(&exampleocconfig.Model_SingleKey{ + Key: ygot.String("test"), + }), + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime.Add(time.Millisecond), + Path: nonLeafKey11Path, + }), + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime.Add(2 * time.Millisecond), + Path: nonLeafKey10Path, + }), + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime.Add(3 * time.Millisecond), + Path: nonLeafKey10Path, + }).SetVal(&exampleocconfig.Model_SingleKey{ + Value: ygot.Int64(100), + }), + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime.Add(3 * time.Millisecond), + Path: nonLeafKey11Path, + }).SetVal(&exampleocconfig.Model_SingleKey{ + Value: ygot.Int64(101), + Key: ygot.String("test"), + }), + }, + wantLastVal: (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime.Add(3 * time.Millisecond), + Path: nonLeafKey11Path, + }).SetVal(&exampleocconfig.Model_SingleKey{ + Value: ygot.Int64(101), + Key: ygot.String("test"), + }), + }} + for _, tt := range nonLeafTests { + t.Run("nonLeaf "+tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + i := 0 + ctx, cancel := context.WithTimeout(context.Background(), tt.dur) + defer cancel() + var key10Cond, key11Cond bool + + w := ygnmi.WatchAll(ctx, client, nonLeafQ, func(v *ygnmi.Value[*exampleocconfig.Model_SingleKey]) error { + if i > len(tt.wantVals) { + t.Fatalf("Predicate(%d) expected no more values but got: %+v", i, v) + } + if diff := cmp.Diff(tt.wantVals[i], v, cmpopts.IgnoreFields(ygnmi.Value[*exampleocconfig.Model_SingleKey]{}, "RecvTimestamp"), cmp.AllowUnexported(ygnmi.Value[*exampleocconfig.Model_SingleKey]{}), protocmp.Transform()); diff != "" { + t.Errorf("Predicate(%d) got unexpected input (-want,+got):\n %s\nComplianceErrors:\n%v", i, diff, v.ComplianceErrors) + } + val, present := v.Val() + key10Cond = key10Cond || (present && proto.Equal(v.Path, nonLeafKey10Path) && val.Value != nil && *val.Value == 100) + key11Cond = key11Cond || (present && proto.Equal(v.Path, nonLeafKey11Path) && val.Value != nil && *val.Value == 101) + i++ + if key10Cond && key11Cond { + return nil + } + return ygnmi.Continue + }) + val, err := w.Await() + if i < len(tt.wantVals) { + t.Errorf("Predicate received too few values: got %d, want %d", i, len(tt.wantVals)) + } + if diff := errdiff.Substring(err, tt.wantErr); diff != "" { + t.Fatalf("Await() returned unexpected diff: %s", diff) + } + if val != nil { + checkJustReceived(t, val.RecvTimestamp) + tt.wantLastVal.RecvTimestamp = val.RecvTimestamp + } + if diff := cmp.Diff(tt.wantLastVal, val, cmp.AllowUnexported(ygnmi.Value[*exampleocconfig.Model_SingleKey]{}), protocmp.Transform()); diff != "" { + t.Errorf("Await() returned unexpected value (-want,+got):\n%s", diff) + } + }) + } +} + +func TestPreferConfigCollectAll(t *testing.T) { + fakeGNMI, client := newClient(t) + leafQueryPath := testutil.GNMIPath(t, "model/a/single-key[key=*]/state/value") + key10Path := testutil.GNMIPath(t, "model/a/single-key[key=10]/state/value") + key11Path := testutil.GNMIPath(t, "model/a/single-key[key=11]/state/value") + + startTime := time.Now() + lq := exampleocconfigpath.Root().Model().SingleKeyAny().Value().State() + tests := []struct { + desc string + stub func(s *testutil.Stubber) + dur time.Duration + wantSubscriptionPath *gpb.Path + wantVals []*ygnmi.Value[int64] + wantErr string + wantMode gpb.SubscriptionMode + opts []ygnmi.Option + }{{ + desc: "no values", + dur: time.Second, + stub: func(s *testutil.Stubber) { + s.Sync() + }, + wantErr: "EOF", + wantSubscriptionPath: leafQueryPath, + wantVals: nil, + }, { + desc: "no values with custom mode", + dur: time.Second, + stub: func(s *testutil.Stubber) { + s.Sync() + }, + opts: []ygnmi.Option{ygnmi.WithSubscriptionMode(gpb.SubscriptionMode_ON_CHANGE)}, + wantMode: gpb.SubscriptionMode_ON_CHANGE, + wantErr: "EOF", + wantSubscriptionPath: leafQueryPath, + wantVals: nil, + }, { + desc: "multiple values", + dur: time.Second, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: key10Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 100}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Update: []*gpb.Update{{ + Path: key11Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 101}}, + }}, + }) + }, + wantErr: "EOF", + wantSubscriptionPath: leafQueryPath, + wantVals: []*ygnmi.Value[int64]{ + (&ygnmi.Value[int64]{ + Timestamp: startTime, + Path: key10Path, + }).SetVal(100), + (&ygnmi.Value[int64]{ + Timestamp: startTime.Add(time.Millisecond), + Path: key11Path, + }).SetVal(101), + }, + }} + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + ctx, cancel := context.WithTimeout(context.Background(), tt.dur) + defer cancel() + + vals, err := ygnmi.CollectAll(ctx, client, lq, tt.opts...).Await() + if diff := errdiff.Substring(err, tt.wantErr); diff != "" { + t.Fatalf("Await() returned unexpected diff: %s", diff) + } + verifySubscriptionModesSent(t, fakeGNMI, tt.wantMode) + for _, val := range vals { + checkJustReceived(t, val.RecvTimestamp) + } + if diff := cmp.Diff(tt.wantVals, vals, cmpopts.IgnoreFields(ygnmi.Value[int64]{}, "RecvTimestamp"), cmp.AllowUnexported(ygnmi.Value[int64]{}), protocmp.Transform()); diff != "" { + t.Errorf("Await() returned unexpected value (-want,+got):\n%s", diff) + } + }) + } + + nonLeafPath := testutil.GNMIPath(t, "model/a/single-key[key=*]") + nonLeafKey10Path := testutil.GNMIPath(t, "model/a/single-key[key=10]") + nonLeafKey11Path := testutil.GNMIPath(t, "model/a/single-key[key=11]") + + nonLeafQ := exampleocconfigpath.Root().Model().SingleKeyAny().State() + nonLeafTests := []struct { + desc string + stub func(s *testutil.Stubber) + dur time.Duration + wantSubscriptionPath *gpb.Path + wantVals []*ygnmi.Value[*exampleocconfig.Model_SingleKey] + wantErr string + }{{ + desc: "no values", + dur: time.Second, + stub: func(s *testutil.Stubber) { + s.Sync() + }, + wantSubscriptionPath: nonLeafPath, + wantVals: nil, + wantErr: "EOF", + }, { + desc: "multiple values", + dur: time.Second, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Update: []*gpb.Update{{ + Path: key10Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 100}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Update: []*gpb.Update{{ + Path: key11Path, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 101}}, + }}, + }) + }, + wantSubscriptionPath: nonLeafPath, + wantErr: "EOF", + wantVals: []*ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime, + Path: nonLeafKey10Path, + }).SetVal(&exampleocconfig.Model_SingleKey{ + Value: ygot.Int64(100), + }), + (&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: startTime.Add(time.Millisecond), + Path: nonLeafKey11Path, + }).SetVal(&exampleocconfig.Model_SingleKey{ + Value: ygot.Int64(101), + }), + }, + }} + for _, tt := range nonLeafTests { + t.Run("nonLeaf "+tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + ctx, cancel := context.WithTimeout(context.Background(), tt.dur) + defer cancel() + + vals, err := ygnmi.CollectAll(ctx, client, nonLeafQ).Await() + if diff := errdiff.Substring(err, tt.wantErr); diff != "" { + t.Fatalf("Await() returned unexpected diff: %s", diff) + } + for _, val := range vals { + checkJustReceived(t, val.RecvTimestamp) + } + if diff := cmp.Diff(tt.wantVals, vals, cmpopts.IgnoreFields(ygnmi.Value[*exampleocconfig.Model_SingleKey]{}, "RecvTimestamp"), cmp.AllowUnexported(ygnmi.Value[*exampleocconfig.Model_SingleKey]{}), protocmp.Transform()); diff != "" { + t.Errorf("Await() returned unexpected value (-want,+got):\n%s", diff) + } + }) + } +} + +func TestPreferConfigUpdate(t *testing.T) { + setClient := &testutil.SetClient{} + client, err := ygnmi.NewClient(setClient, ygnmi.WithTarget("dut")) + if err != nil { + t.Fatalf("Unexpected error creating client: %v", err) + } + + tests := []struct { + desc string + op func(*ygnmi.Client) (*ygnmi.Result, error) + wantErr string + wantRequest *gpb.SetRequest + stubResponse *gpb.SetResponse + stubErr error + }{{ + desc: "scalar leaf", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Update(context.Background(), c, exampleocconfigpath.Root().Parent().Child().One().Config(), "10") + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "parent/child/config/one"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte("\"10\"")}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "non scalar leaf", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Update(context.Background(), c, exampleocconfigpath.Root().Parent().Child().Three().Config(), exampleocconfig.Child_Three_ONE) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "parent/child/config/three"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte("\"ONE\"")}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "non leaf", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Update(context.Background(), c, exampleocconfigpath.Root().Parent().Child().Config(), &exampleocconfig.Parent_Child{One: ygot.String("10")}) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "parent/child"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte("{\n \"openconfig-simple:config\": {\n \"one\": \"10\"\n }\n}")}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "server error", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Update(context.Background(), c, exampleocconfigpath.Root().Parent().Child().One().Config(), "10") + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "parent/child/config/one"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(`"10"`)}}, + }}, + }, + stubErr: fmt.Errorf("fake"), + wantErr: "fake", + }, { + desc: "YANG ordered list", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + om := &exampleocconfig.Model_SingleKey_OrderedList_OrderedMap{} + ol, err := om.AppendNew("foo") + if err != nil { + t.Fatal(err) + } + ol.SetValue(42) + ol, err = om.AppendNew("bar") + if err != nil { + t.Fatal(err) + } + ol.SetValue(43) + ol, err = om.AppendNew("baz") + if err != nil { + t.Fatal(err) + } + ol.SetValue(44) + return ygnmi.Update(context.Background(), c, exampleocconfigpath.Root().Model().SingleKey("foo").OrderedListMap().Config(), om) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:ordered-list": [ + { + "config": { + "key": "foo", + "value": "42" + }, + "key": "foo" + }, + { + "config": { + "key": "bar", + "value": "43" + }, + "key": "bar" + }, + { + "config": { + "key": "baz", + "value": "44" + }, + "key": "baz" + } + ] +}`))}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "whole single-keyed list", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Update(context.Background(), c, exampleocconfigpath.Root().Model().SingleKeyMap().Config(), getSamplePreferConfigSingleKeyedMap(t)) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "/model/a"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:single-key": [ + { + "config": { + "key": "bar", + "value": "43" + }, + "key": "bar" + }, + { + "config": { + "key": "baz", + "value": "44" + }, + "key": "baz" + }, + { + "config": { + "key": "foo", + "value": "42" + }, + "key": "foo" + } + ] +}`))}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "leaf and prefer proto", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Update(context.Background(), c, exampleocconfigpath.Root().Parent().Child().One().Config(), "10", ygnmi.WithSetPreferProtoEncoding()) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "parent/child/config/one"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "10"}}, + }}, + }, + }, { + desc: "non leaf and prefer proto", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Update(context.Background(), c, exampleocconfigpath.Root().Parent().Child().Config(), &exampleocconfig.Parent_Child{One: ygot.String("10")}, ygnmi.WithSetPreferProtoEncoding()) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "parent/child"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte("{\n \"openconfig-simple:config\": {\n \"one\": \"10\"\n }\n}")}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "fallback openconfig origin", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Update(context.Background(), c, mustSchemaless[*gpb.CapabilityResponse](t, "/foo", "openconfig"), &gpb.CapabilityResponse{GNMIVersion: "1"}, ygnmi.WithSetFallbackEncoding()) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "foo"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_AnyVal{AnyVal: mustAnyNew(t, &gpb.CapabilityResponse{GNMIVersion: "1"})}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + wantErr: "failed to encode set request", + }, { + desc: "fallback empty origin", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Update(context.Background(), c, mustSchemaless[*gpb.CapabilityResponse](t, "/foo", "openconfig"), &gpb.CapabilityResponse{GNMIVersion: "1"}, ygnmi.WithSetFallbackEncoding()) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "foo"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_AnyVal{AnyVal: mustAnyNew(t, &gpb.CapabilityResponse{GNMIVersion: "1"})}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + wantErr: "failed to encode set request", + }, { + desc: "fallback proto", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Update(context.Background(), c, mustSchemaless[*gpb.CapabilityResponse](t, "/foo", "test"), &gpb.CapabilityResponse{GNMIVersion: "1"}, ygnmi.WithSetFallbackEncoding()) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Update: []*gpb.Update{{ + Path: &gpb.Path{ + Elem: []*gpb.PathElem{{Name: "foo"}}, + Origin: "test", + }, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_AnyVal{AnyVal: mustAnyNew(t, &gpb.CapabilityResponse{GNMIVersion: "1"})}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "fallback json", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Update(context.Background(), c, mustSchemaless[*testStruct](t, "/foo", "test"), &testStruct{Val: "test"}, ygnmi.WithSetFallbackEncoding()) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Update: []*gpb.Update{{ + Path: &gpb.Path{ + Origin: "test", + Elem: []*gpb.PathElem{{Name: "foo"}}, + }, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonVal{JsonVal: []byte(`{"Val":"test"}`)}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }} + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + setClient.Reset() + setClient.AddResponse(tt.stubResponse, tt.stubErr) + + got, err := tt.op(client) + if diff := errdiff.Substring(err, tt.wantErr); diff != "" { + t.Fatalf("Update() returned unexpected diff: %s", diff) + } + if err != nil { + return + } + if diff := cmp.Diff(tt.wantRequest, setClient.Requests[0], protocmp.Transform()); diff != "" { + t.Errorf("Update() sent unexpected request (-want,+got):\n%s", diff) + } + want := &ygnmi.Result{ + RawResponse: tt.stubResponse, + Timestamp: time.Unix(0, tt.stubResponse.GetTimestamp()), + } + if diff := cmp.Diff(want, got, protocmp.Transform()); diff != "" { + t.Errorf("Update() returned unexpected value (-want,+got):\n%s", diff) + } + }) + } +} + +func TestPreferConfigReplace(t *testing.T) { + setClient := &testutil.SetClient{} + client, err := ygnmi.NewClient(setClient, ygnmi.WithTarget("dut")) + if err != nil { + t.Fatalf("Unexpected error creating client: %v", err) + } + tests := []struct { + desc string + op func(*ygnmi.Client) (*ygnmi.Result, error) + wantErr string + wantRequest *gpb.SetRequest + stubResponse *gpb.SetResponse + stubErr error + }{{ + desc: "scalar leaf", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Replace(context.Background(), c, exampleocconfigpath.Root().Parent().Child().One().Config(), "10") + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Replace: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "parent/child/config/one"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte("\"10\"")}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "non scalar leaf", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Replace(context.Background(), c, exampleocconfigpath.Root().Parent().Child().Three().Config(), exampleocconfig.Child_Three_ONE) + + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Replace: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "parent/child/config/three"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte("\"ONE\"")}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "non leaf", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Replace(context.Background(), c, exampleocconfigpath.Root().Parent().Child().Config(), &exampleocconfig.Parent_Child{One: ygot.String("10")}) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Replace: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "parent/child"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte("{\n \"openconfig-simple:config\": {\n \"one\": \"10\"\n }\n}")}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "YANG ordered list", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + om := &exampleocconfig.Model_SingleKey_OrderedList_OrderedMap{} + ol, err := om.AppendNew("foo") + if err != nil { + t.Fatal(err) + } + ol.SetValue(42) + ol, err = om.AppendNew("bar") + if err != nil { + t.Fatal(err) + } + ol.SetValue(43) + ol, err = om.AppendNew("baz") + if err != nil { + t.Fatal(err) + } + ol.SetValue(44) + return ygnmi.Replace(context.Background(), c, exampleocconfigpath.Root().Model().SingleKey("foo").OrderedListMap().Config(), om) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Replace: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:ordered-list": [ + { + "config": { + "key": "foo", + "value": "42" + }, + "key": "foo" + }, + { + "config": { + "key": "bar", + "value": "43" + }, + "key": "bar" + }, + { + "config": { + "key": "baz", + "value": "44" + }, + "key": "baz" + } + ] +}`))}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "whole single-keyed list", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Replace(context.Background(), c, exampleocconfigpath.Root().Model().SingleKeyMap().Config(), getSamplePreferConfigSingleKeyedMap(t)) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Replace: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "/model/a"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:single-key": [ + { + "config": { + "key": "bar", + "value": "43" + }, + "key": "bar" + }, + { + "config": { + "key": "baz", + "value": "44" + }, + "key": "baz" + }, + { + "config": { + "key": "foo", + "value": "42" + }, + "key": "foo" + } + ] +}`))}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "server error", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Replace(context.Background(), c, exampleocconfigpath.Root().Parent().Child().One().Config(), "10") + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Replace: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "parent/child/config/one"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(`"10"`)}}, + }}, + }, + stubErr: fmt.Errorf("fake"), + wantErr: "fake", + }} + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + configCheckFn(t, setClient, client, tt.op, tt.wantRequest, tt.stubResponse, tt.wantErr, tt.stubErr) + }) + } +} + +func TestPreferConfigDelete(t *testing.T) { + setClient := &testutil.SetClient{} + client, err := ygnmi.NewClient(setClient, ygnmi.WithTarget("dut")) + if err != nil { + t.Fatalf("Unexpected error creating client: %v", err) + } + tests := []struct { + desc string + op func(*ygnmi.Client) (*ygnmi.Result, error) + wantErr string + wantRequest *gpb.SetRequest + stubResponse *gpb.SetResponse + stubErr error + }{{ + desc: "success", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Delete(context.Background(), c, exampleocconfigpath.Root().Parent().Child().One().Config()) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Delete: []*gpb.Path{ + testutil.GNMIPath(t, "parent/child/config/one"), + }, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "YANG ordered list", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Delete(context.Background(), c, exampleocconfigpath.Root().Model().SingleKey("foo").OrderedListMap().Config()) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Delete: []*gpb.Path{ + testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + }, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "whole single-keyed list", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Delete(context.Background(), c, exampleocconfigpath.Root().Model().SingleKeyMap().Config()) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Delete: []*gpb.Path{ + testutil.GNMIPath(t, "/model/a"), + }, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "server error", + op: func(c *ygnmi.Client) (*ygnmi.Result, error) { + return ygnmi.Delete(context.Background(), c, exampleocconfigpath.Root().Parent().Child().One().Config()) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Delete: []*gpb.Path{ + testutil.GNMIPath(t, "super-container/leaf-container-struct/uint64-leaf"), + }, + }, + stubErr: fmt.Errorf("fake"), + wantErr: "fake", + }} + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + configCheckFn(t, setClient, client, tt.op, tt.wantRequest, tt.stubResponse, tt.wantErr, tt.stubErr) + }) + } +} + +func TestPreferConfigBatchGet(t *testing.T) { + fakeGNMI, c := newClient(t) + aLeafStatePath := testutil.GNMIPath(t, "/remote-container/state/a-leaf") + aLeafConfigPath := testutil.GNMIPath(t, "/remote-container/config/a-leaf") + twoPath := testutil.GNMIPath(t, "/parent/child/state/two") + aLeafSubPath := testutil.GNMIPath(t, "/remote-container/*/a-leaf") + + tests := []struct { + desc string + stub func(s *testutil.Stubber) + config bool + paths []ygnmi.PathStruct + wantSubscriptionPath []*gpb.Path + wantVal *ygnmi.Value[*exampleocconfig.Root] + wantErr string + }{{ + desc: "state leaves", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: aLeafStatePath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: aLeafConfigPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "config"}}, + }, { + Path: twoPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }).Sync() + }, + paths: []ygnmi.PathStruct{ + exampleocconfigpath.Root().RemoteContainer().ALeaf(), + exampleocconfigpath.Root().Parent().Child().Two(), + }, + wantSubscriptionPath: []*gpb.Path{ + aLeafSubPath, + twoPath, + }, + wantVal: (&ygnmi.Value[*exampleocconfig.Root]{ + Timestamp: time.Unix(0, 100), + Path: testutil.GNMIPath(t, "/"), + }).SetVal(&exampleocconfig.Root{ + RemoteContainer: &exampleocconfig.RemoteContainer{ALeaf: ygot.String("foo")}, + Parent: &exampleocconfig.Parent{Child: &exampleocconfig.Parent_Child{Two: ygot.String("bar")}}, + }), + }, { + desc: "config ignore state leaves", + config: true, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: aLeafStatePath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: twoPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }).Sync() + }, + paths: []ygnmi.PathStruct{ + exampleocconfigpath.Root().RemoteContainer().ALeaf(), + exampleocconfigpath.Root().Parent().Child().Two(), + }, + wantSubscriptionPath: []*gpb.Path{ + aLeafSubPath, + twoPath, + }, + wantVal: (&ygnmi.Value[*exampleocconfig.Root]{ + Timestamp: time.Unix(0, 100), + Path: testutil.GNMIPath(t, "/"), + }).SetVal(&exampleocconfig.Root{ + RemoteContainer: &exampleocconfig.RemoteContainer{}, + Parent: &exampleocconfig.Parent{Child: &exampleocconfig.Parent_Child{}}, + }), + }, { + desc: "non leaves", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: aLeafStatePath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: twoPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }).Sync() + }, + paths: []ygnmi.PathStruct{ + exampleocconfigpath.Root().RemoteContainer(), + exampleocconfigpath.Root().Parent(), + }, + wantSubscriptionPath: []*gpb.Path{ + testutil.GNMIPath(t, "/remote-container"), + testutil.GNMIPath(t, "/parent"), + }, + wantVal: (&ygnmi.Value[*exampleocconfig.Root]{ + Timestamp: time.Unix(0, 100), + Path: testutil.GNMIPath(t, "/"), + }).SetVal(&exampleocconfig.Root{ + RemoteContainer: &exampleocconfig.RemoteContainer{ALeaf: ygot.String("foo")}, + Parent: &exampleocconfig.Parent{Child: &exampleocconfig.Parent_Child{Two: ygot.String("bar")}}, + }), + }} + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + b := &exampleocconfigpath.Batch{} + b.AddPaths(tt.paths...) + query := b.State() + if tt.config { + query = b.Config() + } + got, err := ygnmi.Lookup(context.Background(), c, query) + if diff := errdiff.Substring(err, tt.wantErr); diff != "" { + t.Fatalf("Lookup() returned unexpected diff: %s", diff) + } + if err != nil { + return + } + checkJustReceived(t, got.RecvTimestamp) + verifySubscriptionPathsSent(t, fakeGNMI, tt.wantSubscriptionPath...) + tt.wantVal.RecvTimestamp = got.RecvTimestamp + + if diff := cmp.Diff(tt.wantVal, got, cmp.AllowUnexported(ygnmi.Value[*exampleocconfig.Root]{}), protocmp.Transform()); diff != "" { + t.Errorf("Lookup() returned unexpected diff (-want,+got):\n %s\nComplianceErrors:\n%v", diff, got.ComplianceErrors) + } + }) + } + t.Run("immutable query", func(t *testing.T) { + fakeGNMI.Stub().Sync() + b := &exampleocconfigpath.Batch{} + b.AddPaths(exampleocconfigpath.Root().Model()) + q := b.State() + if _, err := ygnmi.Lookup(context.Background(), c, q); err != nil { + t.Fatal(err) + } + verifySubscriptionPathsSent(t, fakeGNMI, testutil.GNMIPath(t, "/model")) + b.AddPaths(exampleocconfigpath.Root().A(), exampleocconfigpath.Root().A().B()) + if _, err := ygnmi.Lookup(context.Background(), c, q); err != nil { + t.Fatal(err) + } + verifySubscriptionPathsSent(t, fakeGNMI, testutil.GNMIPath(t, "/model")) + }) +} + +func TestPreferConfigBatchWatch(t *testing.T) { + fakeGNMI, c := newClient(t) + aLeafStatePath := testutil.GNMIPath(t, "/remote-container/state/a-leaf") + twoPath := testutil.GNMIPath(t, "/parent/child/state/two") + aLeafSubPath := testutil.GNMIPath(t, "/remote-container/*/a-leaf") + + tests := []struct { + desc string + stub func(s *testutil.Stubber) + config bool + paths []ygnmi.PathStruct + wantSubscriptionPath []*gpb.Path + wantVal *ygnmi.Value[*exampleocconfig.Root] + wantErr string + }{{ + desc: "predicate true", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: aLeafStatePath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: twoPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }).Sync() + }, + paths: []ygnmi.PathStruct{ + exampleocconfigpath.Root().RemoteContainer().ALeaf(), + exampleocconfigpath.Root().Parent().Child().Two(), + }, + wantSubscriptionPath: []*gpb.Path{ + aLeafSubPath, + twoPath, + }, + wantVal: (&ygnmi.Value[*exampleocconfig.Root]{ + Timestamp: time.Unix(0, 100), + Path: testutil.GNMIPath(t, "/"), + }).SetVal(&exampleocconfig.Root{ + RemoteContainer: &exampleocconfig.RemoteContainer{ALeaf: ygot.String("foo")}, + Parent: &exampleocconfig.Parent{Child: &exampleocconfig.Parent_Child{Two: ygot.String("bar")}}, + }), + }, { + desc: "predicate false true false", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: aLeafStatePath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: 101, + Update: []*gpb.Update{{ + Path: twoPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }).Notification(&gpb.Notification{ + Timestamp: 102, + Update: []*gpb.Update{{ + Path: twoPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "sample"}}, + }}, + }) + }, + paths: []ygnmi.PathStruct{ + exampleocconfigpath.Root().RemoteContainer().ALeaf(), + exampleocconfigpath.Root().Parent().Child().Two(), + }, + wantSubscriptionPath: []*gpb.Path{ + aLeafSubPath, + twoPath, + }, + wantVal: (&ygnmi.Value[*exampleocconfig.Root]{ + Timestamp: time.Unix(0, 101), + Path: testutil.GNMIPath(t, "/"), + }).SetVal(&exampleocconfig.Root{ + RemoteContainer: &exampleocconfig.RemoteContainer{ALeaf: ygot.String("foo")}, + Parent: &exampleocconfig.Parent{Child: &exampleocconfig.Parent_Child{Two: ygot.String("bar")}}, + }), + }, { + desc: "predicate false", + config: true, + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: twoPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }).Sync() + }, + paths: []ygnmi.PathStruct{ + exampleocconfigpath.Root().RemoteContainer().ALeaf(), + exampleocconfigpath.Root().Parent().Child().Two(), + }, + wantSubscriptionPath: []*gpb.Path{ + aLeafSubPath, + twoPath, + }, + wantErr: "EOF", + }, { + desc: "non leaves", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: aLeafStatePath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: twoPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }}, + }).Sync() + }, + paths: []ygnmi.PathStruct{ + exampleocconfigpath.Root().RemoteContainer(), + exampleocconfigpath.Root().Parent(), + }, + wantSubscriptionPath: []*gpb.Path{ + testutil.GNMIPath(t, "/remote-container"), + testutil.GNMIPath(t, "/parent"), + }, + wantVal: (&ygnmi.Value[*exampleocconfig.Root]{ + Timestamp: time.Unix(0, 100), + Path: testutil.GNMIPath(t, "/"), + }).SetVal(&exampleocconfig.Root{ + RemoteContainer: &exampleocconfig.RemoteContainer{ALeaf: ygot.String("foo")}, + Parent: &exampleocconfig.Parent{Child: &exampleocconfig.Parent_Child{Two: ygot.String("bar")}}, + }), + }} + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + b := &exampleocconfigpath.Batch{} + b.AddPaths(tt.paths...) + query := b.State() + if tt.config { + query = b.Config() + } + + got, err := ygnmi.Watch(context.Background(), c, query, func(v *ygnmi.Value[*exampleocconfig.Root]) error { + if v, ok := v.Val(); ok && v.GetRemoteContainer().GetALeaf() == "foo" && v.GetParent().GetChild().GetTwo() == "bar" { + return nil + } + return ygnmi.Continue + }).Await() + if diff := errdiff.Substring(err, tt.wantErr); diff != "" { + t.Fatalf("Watch() returned unexpected diff: %s", diff) + } + if err != nil { + return + } + checkJustReceived(t, got.RecvTimestamp) + verifySubscriptionPathsSent(t, fakeGNMI, tt.wantSubscriptionPath...) + tt.wantVal.RecvTimestamp = got.RecvTimestamp + + if diff := cmp.Diff(tt.wantVal, got, cmp.AllowUnexported(ygnmi.Value[*exampleocconfig.Root]{}), protocmp.Transform()); diff != "" { + t.Errorf("Watch() returned unexpected diff (-want,+got):\n %s\nComplianceErrors:\n%v", diff, got.ComplianceErrors) + } + }) + } +} + +func TestPreferConfigCustomRootBatch(t *testing.T) { + fakeGNMI, c := newClient(t) + twoPath := testutil.GNMIPath(t, "/parent/child/state/two") + + tests := []struct { + desc string + stub func(s *testutil.Stubber) + paths []ygnmi.UntypedQuery + wantSubscriptionPath []*gpb.Path + wantVal *ygnmi.Value[*exampleocconfig.Parent] + wantAddErr string + wantLookupErr string + }{{ + desc: "not prefix", + stub: func(s *testutil.Stubber) {}, + paths: []ygnmi.UntypedQuery{ + exampleocconfigpath.Root().Model().Config(), + }, + wantAddErr: "is not a prefix", + }, { + desc: "success", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: twoPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + paths: []ygnmi.UntypedQuery{ + exampleocconfigpath.Root().Parent().Child().Two().State(), + }, + wantSubscriptionPath: []*gpb.Path{ + twoPath, + }, + wantVal: (&ygnmi.Value[*exampleocconfig.Parent]{ + Timestamp: time.Unix(0, 100), + Path: testutil.GNMIPath(t, "/parent"), + }).SetVal(&exampleocconfig.Parent{ + Child: &exampleocconfig.Parent_Child{ + Two: ygot.String("foo"), + }, + }), + }} + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + b := ygnmi.NewBatch(exampleocconfigpath.Root().Parent().State()) + err := b.AddPaths(tt.paths...) + if diff := errdiff.Substring(err, tt.wantAddErr); diff != "" { + t.Fatalf("AddPaths returned unexpected diff: %s", diff) + } + if err != nil { + return + } + got, gotErr := ygnmi.Lookup(context.Background(), c, b.Query()) + if diff := errdiff.Substring(gotErr, tt.wantLookupErr); diff != "" { + t.Fatalf("Watch() returned unexpected diff: %s", diff) + } + if gotErr != nil { + return + } + checkJustReceived(t, got.RecvTimestamp) + verifySubscriptionPathsSent(t, fakeGNMI, tt.wantSubscriptionPath...) + tt.wantVal.RecvTimestamp = got.RecvTimestamp + + if diff := cmp.Diff(tt.wantVal, got, cmp.AllowUnexported(ygnmi.Value[*exampleocconfig.Parent]{}), protocmp.Transform()); diff != "" { + t.Errorf("Watch() returned unexpected diff (-want,+got):\n %s\nComplianceErrors:\n%v", diff, got.ComplianceErrors) + } + }) + } + + fakeGNMI, client := newClient(t) + startTime := time.Now() + t.Run("success whole single-keyed map", func(t *testing.T) { + fakeGNMI.Stub().Notification(&gpb.Notification{ + Timestamp: startTime.UnixNano(), + Prefix: testutil.GNMIPath(t, "/model/a"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, `single-key[key=foo]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=foo]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 42}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }}, + }).Sync().Notification(&gpb.Notification{ + Timestamp: startTime.Add(time.Millisecond).UnixNano(), + Prefix: testutil.GNMIPath(t, "/model/a"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, `single-key[key=foo]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=foo]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 42}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "bar"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=bar]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 43}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=baz]/state/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "baz"}}, + }, { + Path: testutil.GNMIPath(t, `single-key[key=baz]/state/value`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 44}}, + }}, + }) + + modelPath := exampleocconfigpath.Root().Model() + b := ygnmi.NewBatch(modelPath.SingleKeyMap().State()) + if err := b.AddPaths( + modelPath.SingleKeyAny().Key().State(), + modelPath.SingleKeyAny().Value().State(), + ); err != nil { + t.Fatal(err) + } + + want := getSamplePreferConfigSingleKeyedMap(t) + watchCheckFn(t, fakeGNMI, 2*time.Second, client, + b.Query(), + nil, + func(val map[string]*exampleocconfig.Model_SingleKey) bool { + return cmp.Equal(val, want) + }, + "", + []*gpb.Path{ + testutil.GNMIPath(t, "/model/a/single-key[key=*]/state/key"), + testutil.GNMIPath(t, "/model/a/single-key[key=*]/state/value"), + }, + []gpb.SubscriptionMode{ + gpb.SubscriptionMode_TARGET_DEFINED, + gpb.SubscriptionMode_TARGET_DEFINED, + }, + []uint64{0, 0}, + []*ygnmi.Value[map[string]*exampleocconfig.Model_SingleKey]{ + (&ygnmi.Value[map[string]*exampleocconfig.Model_SingleKey]{ + Path: testutil.GNMIPath(t, "/model/a"), + Timestamp: startTime, + }).SetVal(getSamplePreferConfigSingleKeyedMapIncomplete(t)), + (&ygnmi.Value[map[string]*exampleocconfig.Model_SingleKey]{ + Path: testutil.GNMIPath(t, "/model/a"), + Timestamp: startTime.Add(time.Millisecond), + }).SetVal(getSamplePreferConfigSingleKeyedMap(t)), + }, + (&ygnmi.Value[map[string]*exampleocconfig.Model_SingleKey]{ + Path: testutil.GNMIPath(t, "/model/a"), + Timestamp: startTime.Add(time.Millisecond), + }).SetVal(getSamplePreferConfigSingleKeyedMap(t)), + ) + }) +} + +func TestPreferConfigCustomRootWildcardBatch(t *testing.T) { + fakeGNMI, c := newClient(t) + valuePathWild := testutil.GNMIPath(t, "/model/a/single-key[key=*]/state/value") + valuePath := testutil.GNMIPath(t, "/model/a/single-key[key=foo]/state/value") + keyPathWild := testutil.GNMIPath(t, "/model/a/single-key[key=*]/state/key") + keyPath := testutil.GNMIPath(t, "/model/a/single-key[key=foo]/state/key") + + tests := []struct { + desc string + stub func(s *testutil.Stubber) + paths []ygnmi.UntypedQuery + wantSubscriptionPath []*gpb.Path + wantVal []*ygnmi.Value[*exampleocconfig.Model_SingleKey] + wantAddErr string + wantLookupErr string + }{{ + desc: "not prefix", + stub: func(s *testutil.Stubber) {}, + paths: []ygnmi.UntypedQuery{ + exampleocconfigpath.Root().Model().Config(), + }, + wantAddErr: "is not a prefix", + }, { + desc: "success", + stub: func(s *testutil.Stubber) { + s.Notification(&gpb.Notification{ + Timestamp: 100, + Update: []*gpb.Update{{ + Path: valuePath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_IntVal{IntVal: 42}}, + }, { + Path: keyPath, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + }, + paths: []ygnmi.UntypedQuery{ + exampleocconfigpath.Root().Model().SingleKeyAny().Value().State(), + exampleocconfigpath.Root().Model().SingleKeyAny().Key().State(), + }, + wantSubscriptionPath: []*gpb.Path{ + keyPathWild, + valuePathWild, + }, + wantVal: []*ygnmi.Value[*exampleocconfig.Model_SingleKey]{(&ygnmi.Value[*exampleocconfig.Model_SingleKey]{ + Timestamp: time.Unix(0, 100), + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]"), + }).SetVal(&exampleocconfig.Model_SingleKey{ + Key: ygot.String("foo"), + Value: ygot.Int64(42), + })}, + }} + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + tt.stub(fakeGNMI.Stub()) + b := ygnmi.NewWildcardBatch(exampleocconfigpath.Root().Model().SingleKeyAny().State()) + err := b.AddPaths(tt.paths...) + if diff := errdiff.Substring(err, tt.wantAddErr); diff != "" { + t.Fatalf("AddPaths returned unexpected diff: %s", diff) + } + if err != nil { + return + } + got, gotErr := ygnmi.LookupAll(context.Background(), c, b.Query()) + if diff := errdiff.Substring(gotErr, tt.wantLookupErr); diff != "" { + t.Fatalf("Watch() returned unexpected diff: %s", diff) + } + if gotErr != nil { + return + } + verifySubscriptionPathsSent(t, fakeGNMI, tt.wantSubscriptionPath...) + + if diff := cmp.Diff(tt.wantVal, got, cmp.AllowUnexported(ygnmi.Value[*exampleocconfig.Model_SingleKey]{}), protocmp.Transform(), cmpopts.IgnoreFields(ygnmi.Value[*exampleocconfig.Model_SingleKey]{}, "RecvTimestamp")); diff != "" { + t.Errorf("Watch() returned unexpected diff (-want,+got):\n%s", diff) + } + }) + } +} + +func TestPreferConfigSetBatch(t *testing.T) { + setClient := &testutil.SetClient{} + client, err := ygnmi.NewClient(setClient, ygnmi.WithTarget("dut")) + if err != nil { + t.Fatalf("Unexpected error creating client: %v", err) + } + tests := []struct { + desc string + addPaths func(*ygnmi.SetBatch) + wantErr string + wantRequest *gpb.SetRequest + stubResponse *gpb.SetResponse + stubErr error + }{{ + desc: "leaf update replace delete unionreplace", + addPaths: func(sb *ygnmi.SetBatch) { + cliPath, err := schemaless.NewConfig[string]("", "cli") + if err != nil { + t.Fatalf("Failed to create CLI ygnmi query: %v", err) + } + ygnmi.BatchUpdate(sb, cliPath, "hello, mercury") + ygnmi.BatchUpdate(sb, exampleocconfigpath.Root().Parent().Child().One().Config(), "foo") + ygnmi.BatchReplace(sb, cliPath, "hello, venus") + ygnmi.BatchReplace(sb, exampleocconfigpath.Root().Parent().Child().One().Config(), "bar") + ygnmi.BatchDelete(sb, cliPath) + ygnmi.BatchDelete(sb, exampleocconfigpath.Root().Parent().Child().One().Config()) + ygnmi.BatchUnionReplace(sb, exampleocconfigpath.Root().Parent().Child().One().Config(), "baz") + ygnmi.BatchUnionReplaceCLI(sb, "openos", "open sesame") + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Update: []*gpb.Update{{ + Path: &gpb.Path{Origin: "cli"}, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_AsciiVal{AsciiVal: "hello, mercury"}}, + }, { + Path: testutil.GNMIPath(t, "parent/child/config/one"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte("\"foo\"")}}, + }}, + Replace: []*gpb.Update{{ + Path: &gpb.Path{Origin: "cli"}, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_AsciiVal{AsciiVal: "hello, venus"}}, + }, { + Path: testutil.GNMIPath(t, "parent/child/config/one"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte("\"bar\"")}}, + }}, + Delete: []*gpb.Path{ + {Origin: "cli"}, + testutil.GNMIPath(t, "parent/child/config/one"), + }, + UnionReplace: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "parent/child/config/one"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte("\"baz\"")}}, + }, { + Path: &gpb.Path{Origin: "openos_cli"}, + Val: &gpb.TypedValue{Value: &gpb.TypedValue_AsciiVal{AsciiVal: "open sesame"}}, + }}, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "non leaf update delete", + addPaths: func(sb *ygnmi.SetBatch) { + ygnmi.BatchUpdate(sb, exampleocconfigpath.Root().Parent().Child().Config(), &exampleocconfig.Parent_Child{One: ygot.String("foo")}) + ygnmi.BatchDelete(sb, exampleocconfigpath.Root().Parent().Child().One().Config()) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", + }, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "parent/child/"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte("{\n \"openconfig-simple:config\": {\n \"one\": \"foo\"\n }\n}")}}, + }}, + Delete: []*gpb.Path{ + testutil.GNMIPath(t, "parent/child/config/one"), + }, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "server error", + addPaths: func(sb *ygnmi.SetBatch) { + ygnmi.BatchDelete(sb, exampleocconfigpath.Root().Parent().Child().One().Config()) + }, + stubErr: fmt.Errorf("fake"), + wantErr: "fake", + }} + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + setClient.Reset() + setClient.AddResponse(tt.stubResponse, tt.stubErr) + b := &ygnmi.SetBatch{} + tt.addPaths(b) + + got, err := b.Set(context.Background(), client) + if diff := errdiff.Substring(err, tt.wantErr); diff != "" { + t.Fatalf("Set() returned unexpected diff: %s", diff) + } + if err != nil { + return + } + if diff := cmp.Diff(tt.wantRequest, setClient.Requests[0], protocmp.Transform()); diff != "" { + t.Errorf("Set() sent unexpected request (-want,+got):\n%s", diff) + } + want := &ygnmi.Result{ + RawResponse: tt.stubResponse, + Timestamp: time.Unix(0, tt.stubResponse.GetTimestamp()), + } + if diff := cmp.Diff(want, got, protocmp.Transform()); diff != "" { + t.Errorf("Set() returned unexpected value (-want,+got):\n%s", diff) + } + }) + } +} + +func TestPreferConfigWatchCancel(t *testing.T) { + srv := &gnmiS{ + errCh: make(chan error, 1), + } + s := grpc.NewServer(grpc.Creds(local.NewCredentials())) + gpb.RegisterGNMIServer(s, srv) + l, err := net.Listen("tcp", ":0") + if err != nil { + t.Fatal(err) + } + go func() { + //nolint:errcheck // Don't care about this error. + s.Serve(l) + }() + conn, err := grpc.Dial(l.Addr().String(), grpc.WithTransportCredentials(local.NewCredentials())) + if err != nil { + t.Fatal(err) + } + c, _ := ygnmi.NewClient(gpb.NewGNMIClient(conn)) + + w := ygnmi.Watch(context.Background(), c, exampleocconfigpath.Root().RemoteContainer().ALeaf().State(), func(v *ygnmi.Value[string]) error { + return nil + }) + if _, err := w.Await(); err != nil { + t.Fatal(err) + } + if err := <-srv.errCh; err == nil { + t.Fatalf("Watch() unexpected error: got %v, want context.Cancel", err) + } +} diff --git a/ygnmi/ygnmi_test.go b/ygnmi/ygnmi_test.go index fc5d1e6..d2311b0 100644 --- a/ygnmi/ygnmi_test.go +++ b/ygnmi/ygnmi_test.go @@ -18,7 +18,6 @@ import ( "context" "fmt" "net" - "strings" "testing" "time" @@ -27,11 +26,9 @@ import ( "github.com/openconfig/gnmi/errdiff" "github.com/openconfig/ygnmi/exampleoc" "github.com/openconfig/ygnmi/exampleoc/exampleocpath" - "github.com/openconfig/ygnmi/internal/exampleocunordered/exampleocunorderedpath" "github.com/openconfig/ygnmi/internal/testutil" "github.com/openconfig/ygnmi/schemaless" "github.com/openconfig/ygnmi/ygnmi" - "github.com/openconfig/ygot/util" "github.com/openconfig/ygot/ygot" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -39,10 +36,8 @@ import ( "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/testing/protocmp" - "google.golang.org/protobuf/types/known/anypb" gpb "github.com/openconfig/gnmi/proto/gnmi" - ygottestutil "github.com/openconfig/ygot/testutil" ) func getSampleOrderedMap(t *testing.T) *exampleoc.Model_SingleKey_OrderedList_OrderedMap { @@ -110,164 +105,6 @@ func getSampleInnerSingleKeyedMapIncomplete(t *testing.T) map[string]*exampleoc. return sk.SingleKey } -func lookupCheckFn[T any](t *testing.T, fakeGNMI *testutil.FakeGNMI, c *ygnmi.Client, inQuery ygnmi.SingletonQuery[T], wantErrSubstring string, wantSubscriptionPath *gpb.Path, wantVal *ygnmi.Value[T]) { - t.Helper() - got, err := ygnmi.Lookup(context.Background(), c, inQuery) - if diff := errdiff.Substring(err, wantErrSubstring); diff != "" { - t.Fatalf("Lookup(ctx, c, %v) returned unexpected diff: %s", inQuery, diff) - } - if err != nil { - return - } - verifySubscriptionPathsSent(t, fakeGNMI, wantSubscriptionPath) - checkJustReceived(t, got.RecvTimestamp) - wantVal.RecvTimestamp = got.RecvTimestamp - - if diff := cmp.Diff(wantVal, got, cmp.AllowUnexported(ygnmi.Value[T]{}, exampleoc.Model_SingleKey_OrderedList_OrderedMap{}), protocmp.Transform()); diff != "" { - t.Errorf("Lookup(ctx, c, %v) returned unexpected diff (-want,+got):\n %s\nComplianceErrors:\n%v", inQuery, diff, got.ComplianceErrors) - } -} - -func lookupWithGetCheckFn[T any](t *testing.T, fakeGNMI *testutil.FakeGNMI, c *ygnmi.Client, inQuery ygnmi.SingletonQuery[T], wantErrSubstring string, wantRequest *gpb.GetRequest, wantVal *ygnmi.Value[T]) { - t.Helper() - got, err := ygnmi.Lookup(context.Background(), c, inQuery, ygnmi.WithUseGet()) - if diff := errdiff.Substring(err, wantErrSubstring); diff != "" { - t.Fatalf("Lookup(ctx, c, %v) returned unexpected diff (-want, +got):\n%s", inQuery, diff) - } - if err != nil { - return - } - if diff := cmp.Diff(wantVal, got, cmp.AllowUnexported(ygnmi.Value[T]{}, exampleoc.Model_SingleKey_OrderedList_OrderedMap{}), cmpopts.IgnoreFields(ygnmi.Value[T]{}, "RecvTimestamp"), protocmp.Transform()); diff != "" { - t.Errorf("Lookup() returned unexpected diff (-want, +got):\n%s", diff) - } - if diff := cmp.Diff(wantRequest, fakeGNMI.GetRequests()[0], protocmp.Transform()); diff != "" { - t.Errorf("Lookup() GetRequest different from expected (-want, +got):\n%s", diff) - } -} - -func getCheckFn[T any](t *testing.T, fakeGNMI *testutil.FakeGNMI, c *ygnmi.Client, inQuery ygnmi.SingletonQuery[T], wantErrSubstring string, wantSubscriptionPath *gpb.Path, wantVal T) { - t.Helper() - got, err := ygnmi.Get(context.Background(), c, inQuery) - if diff := errdiff.Substring(err, wantErrSubstring); diff != "" { - t.Fatalf("Get(ctx, c, %v) returned unexpected diff: %s", inQuery, diff) - } - if err != nil { - return - } - verifySubscriptionPathsSent(t, fakeGNMI, wantSubscriptionPath) - - if diff := cmp.Diff(wantVal, got, cmp.AllowUnexported(exampleoc.Model_SingleKey_OrderedList_OrderedMap{})); diff != "" { - t.Errorf("Get(ctx, c, %v) returned unexpected diff (-want,+got):\n %s", inQuery, diff) - } -} - -func watchCheckFn[T any](t *testing.T, fakeGNMI *testutil.FakeGNMI, duration time.Duration, c *ygnmi.Client, inQuery ygnmi.SingletonQuery[T], - inOpts []ygnmi.Option, valPred func(T) bool, wantErrSubstring string, wantSubscriptionPaths []*gpb.Path, wantModes []gpb.SubscriptionMode, wantIntervals []uint64, wantVals []*ygnmi.Value[T], wantLastVal *ygnmi.Value[T]) { - t.Helper() - i := 0 - ctx, cancel := context.WithTimeout(context.Background(), duration) - defer cancel() - w := ygnmi.Watch(ctx, c, inQuery, func(v *ygnmi.Value[T]) error { - if i > len(wantVals) { - t.Fatalf("Predicate(%d) expected no more values but got: %+v", i, v) - } - if diff := cmp.Diff(wantVals[i], v, cmpopts.IgnoreFields(ygnmi.Value[T]{}, "RecvTimestamp"), cmp.AllowUnexported(ygnmi.Value[T]{}, exampleoc.Model_SingleKey_OrderedList_OrderedMap{}), protocmp.Transform()); diff != "" { - t.Errorf("Predicate(%d) got unexpected input (-want,+got):\n %s\nComplianceErrors:\n%v", i, diff, v.ComplianceErrors) - } - val, present := v.Val() - i++ - if present && valPred(val) { - return nil - } - return ygnmi.Continue - }, inOpts...) - val, err := w.Await() - if i < len(wantVals) { - t.Errorf("Predicate received too few values: got %d, want %d", i, len(wantVals)) - } - if diff := errdiff.Substring(err, wantErrSubstring); diff != "" { - t.Fatalf("Await() returned unexpected diff: %s", diff) - } - if err != nil { - return - } - verifySubscriptionPathsSent(t, fakeGNMI, wantSubscriptionPaths...) - verifySubscriptionModesSent(t, fakeGNMI, wantModes...) - verifySubscriptionSampleIntervalsSent(t, fakeGNMI, wantIntervals...) - if val != nil { - checkJustReceived(t, val.RecvTimestamp) - wantLastVal.RecvTimestamp = val.RecvTimestamp - } - if diff := cmp.Diff(wantLastVal, val, cmp.AllowUnexported(ygnmi.Value[T]{}, exampleoc.Model_SingleKey_OrderedList_OrderedMap{}), protocmp.Transform()); diff != "" { - t.Errorf("Await() returned unexpected value (-want,+got):\n%s", diff) - } -} - -func collectCheckFn[T any](t *testing.T, fakeGNMI *testutil.FakeGNMI, c *ygnmi.Client, inQuery ygnmi.SingletonQuery[T], wantErrSubstring string, wantSubscriptionPath *gpb.Path, wantVals []*ygnmi.Value[T]) { - t.Helper() - vals, err := ygnmi.Collect(context.Background(), c, inQuery).Await() - if diff := errdiff.Substring(err, wantErrSubstring); diff != "" { - t.Errorf("Await() returned unexpected diff: %s", diff) - } - verifySubscriptionPathsSent(t, fakeGNMI, wantSubscriptionPath) - for _, val := range vals { - checkJustReceived(t, val.RecvTimestamp) - } - if diff := cmp.Diff(wantVals, vals, cmpopts.IgnoreFields(ygnmi.Value[T]{}, "RecvTimestamp"), cmp.AllowUnexported(ygnmi.Value[T]{}), protocmp.Transform()); diff != "" { - t.Errorf("Await() returned unexpected value (-want,+got):\n%s", diff) - } -} - -func lookupAllCheckFn[T any](t *testing.T, fakeGNMI *testutil.FakeGNMI, c *ygnmi.Client, inQuery ygnmi.WildcardQuery[T], wantErrSubstring string, wantSubscriptionPath *gpb.Path, wantVals []*ygnmi.Value[T], nonLeaf bool) { - t.Helper() - got, err := ygnmi.LookupAll(context.Background(), c, inQuery) - if diff := errdiff.Substring(err, wantErrSubstring); diff != "" { - t.Fatalf("LookupAll(ctx, c, %v) returned unexpected diff: %s", inQuery, diff) - } - if err != nil { - return - } - verifySubscriptionPathsSent(t, fakeGNMI, wantSubscriptionPath) - for _, val := range got { - checkJustReceived(t, val.RecvTimestamp) - } - copts := []cmp.Option{ - cmp.AllowUnexported(ygnmi.Value[T]{}, exampleoc.Model_SingleKey_OrderedList_OrderedMap{}), - cmpopts.IgnoreFields(ygnmi.Value[T]{}, "RecvTimestamp"), - protocmp.Transform(), - } - if nonLeaf { - copts = append(copts, cmpopts.IgnoreFields(ygnmi.TelemetryError{}, "Err")) - } - if diff := cmp.Diff(wantVals, got, copts...); diff != "" { - t.Errorf("LookupAll() returned unexpected diff (-want,+got):\n%s", diff) - } -} - -func configCheckFn(t *testing.T, setClient *testutil.SetClient, c *ygnmi.Client, op func(*ygnmi.Client) (*ygnmi.Result, error), wantRequest *gpb.SetRequest, stubResponse *gpb.SetResponse, wantErrSubstring string, stubErr error) { - t.Helper() - setClient.Reset() - setClient.AddResponse(stubResponse, stubErr) - - got, err := op(c) - if diff := errdiff.Substring(err, wantErrSubstring); diff != "" { - t.Fatalf("config operation returned unexpected diff: %s", diff) - } - if err != nil { - return - } - if diff := cmp.Diff(wantRequest, setClient.Requests[0], protocmp.Transform()); diff != "" { - t.Errorf("config operation sent unexpected request (-want,+got):\n%s", diff) - } - want := &ygnmi.Result{ - RawResponse: stubResponse, - Timestamp: time.Unix(0, stubResponse.GetTimestamp()), - } - if diff := cmp.Diff(want, got, protocmp.Transform()); diff != "" { - t.Errorf("config operation returned unexpected value (-want,+got):\n%s", diff) - } -} - func TestLookup(t *testing.T) { fakeGNMI, c := newClient(t) leafPath := testutil.GNMIPath(t, "/remote-container/state/a-leaf") @@ -766,31 +603,6 @@ func TestLookup(t *testing.T) { }) } -func TestUnorderedOrderedMap(t *testing.T) { - fakeGNMI, c := newClient(t) - t.Run("success unordered ordered map leaf", func(t *testing.T) { - fakeGNMI.Stub().Notification(&gpb.Notification{ - Timestamp: 100, - Prefix: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), - Update: []*gpb.Update{{ - Path: testutil.GNMIPath(t, `ordered-list[key=foo]/config/key`), - Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, - }}, - }).Sync() - - lookupCheckFn( - t, fakeGNMI, c, - ygnmi.SingletonQuery[string](exampleocunorderedpath.Root().Model().SingleKey("foo").OrderedList("foo").Key().Config()), - "", - testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists/ordered-list[key=foo]/config/key"), - (&ygnmi.Value[string]{ - Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists/ordered-list[key=foo]/config/key"), - Timestamp: time.Unix(0, 100), - }).SetVal("foo"), - ) - }) -} - func TestLookupWithGet(t *testing.T) { fakeGNMI, c := newClient(t) leafPath := testutil.GNMIPath(t, "/remote-container/state/a-leaf") @@ -3254,10 +3066,6 @@ func TestCollectAll(t *testing.T) { } } -type testStruct struct { - Val string -} - func TestUpdate(t *testing.T) { setClient := &testutil.SetClient{} client, err := ygnmi.NewClient(setClient, ygnmi.WithTarget("dut")) @@ -3591,26 +3399,6 @@ func TestUpdate(t *testing.T) { } } -func mustSchemaless[T any](t testing.TB, path, origin string) ygnmi.ConfigQuery[T] { - q, err := schemaless.NewConfig[T](path, origin) - if err != nil { - t.Fatal(err) - } - return q -} - -func mustAnyNew(t testing.TB, m proto.Message) *anypb.Any { - any, err := anypb.New(m) - if err != nil { - t.Fatal(err) - } - return any -} - -func removeWhitespace(s string) string { - return strings.Join(strings.Fields(s), "") -} - func TestReplace(t *testing.T) { setClient := &testutil.SetClient{} client, err := ygnmi.NewClient(setClient, ygnmi.WithTarget("dut")) @@ -4577,110 +4365,6 @@ func TestSetBatch(t *testing.T) { } } -func newClient(t testing.TB) (*testutil.FakeGNMI, *ygnmi.Client) { - fakeGNMI, err := testutil.StartGNMI(0) - if err != nil { - t.Fatal(err) - } - gnmiClient, err := fakeGNMI.Dial(context.Background()) - if err != nil { - t.Fatal(err) - } - c, err := ygnmi.NewClient(gnmiClient) - if err != nil { - t.Fatal(err) - } - return fakeGNMI, c -} - -// checkJustReceived checks that the received time is just before now. -func checkJustReceived(t *testing.T, recvTime time.Time) { - if diffSecs := time.Since(recvTime).Seconds(); diffSecs <= 0 && diffSecs > 1 { - t.Errorf("Received time is too far (%v seconds) away from now", diffSecs) - } -} - -// verifySubscriptionPathsSent verifies the paths of the sent subscription requests is the same as wantPaths. -func verifySubscriptionPathsSent(t *testing.T, fakeGNMI *testutil.FakeGNMI, wantPaths ...*gpb.Path) { - t.Helper() - requests := fakeGNMI.Requests() - if len(requests) != 1 { - t.Errorf("Number of subscription requests sent is not 1: %v", requests) - return - } - - var gotPaths []*gpb.Path - req := requests[0].GetSubscribe() - for _, sub := range req.GetSubscription() { - got, err := util.JoinPaths(req.GetPrefix(), sub.GetPath()) - if err != nil { - t.Fatal(err) - } - got.Target = "" - gotPaths = append(gotPaths, got) - } - if diff := cmp.Diff(wantPaths, gotPaths, protocmp.Transform(), cmpopts.SortSlices(ygottestutil.PathLess)); diff != "" { - t.Errorf("Subscription paths (-want, +got):\n%s", diff) - } -} - -// verifySubscriptionModesSent verifies the modes of the sent subscription requests is the same as wantModes. -func verifySubscriptionModesSent(t *testing.T, fakeGNMI *testutil.FakeGNMI, wantModes ...gpb.SubscriptionMode) { - t.Helper() - requests := fakeGNMI.Requests() - if len(requests) != 1 { - t.Errorf("Number of subscription requests sent is not 1: %v", requests) - return - } - - var gotModes []gpb.SubscriptionMode - req := requests[0].GetSubscribe() - for _, sub := range req.GetSubscription() { - gotModes = append(gotModes, sub.Mode) - } - if diff := cmp.Diff(wantModes, gotModes, protocmp.Transform()); diff != "" { - t.Errorf("Subscription modes (-want, +got):\n%s", diff) - } -} - -// verifySubscriptionSampleIntervalsSent verifies the modes of the sent subscription requests is the same as wantModes. -func verifySubscriptionSampleIntervalsSent(t *testing.T, fakeGNMI *testutil.FakeGNMI, wantIntervals ...uint64) { - t.Helper() - requests := fakeGNMI.Requests() - if len(requests) != 1 { - t.Errorf("Number of subscription requests sent is not 1: %v", requests) - return - } - - var gotIntervals []uint64 - req := requests[0].GetSubscribe() - for _, sub := range req.GetSubscription() { - gotIntervals = append(gotIntervals, sub.SampleInterval) - } - if diff := cmp.Diff(wantIntervals, gotIntervals); diff != "" { - t.Errorf("Subscription sample intervals (-want, +got):\n%s", diff) - } -} - -type gnmiS struct { - gpb.UnimplementedGNMIServer - errCh chan error -} - -func (g *gnmiS) Subscribe(srv gpb.GNMI_SubscribeServer) error { - if _, err := srv.Recv(); err != nil { - return err - } - if err := srv.Send(&gpb.SubscribeResponse{Response: &gpb.SubscribeResponse_SyncResponse{}}); err != nil { - return err - } - // This send must fail because the client will have cancelled the subscription context. - time.Sleep(time.Second) - err := srv.Send(&gpb.SubscribeResponse{Response: &gpb.SubscribeResponse_SyncResponse{}}) - g.errCh <- err - return nil -} - func TestWatchCancel(t *testing.T) { srv := &gnmiS{ errCh: make(chan error, 1), diff --git a/ygnmi/ygnmi_testhelpers_test.go b/ygnmi/ygnmi_testhelpers_test.go new file mode 100644 index 0000000..126f62b --- /dev/null +++ b/ygnmi/ygnmi_testhelpers_test.go @@ -0,0 +1,324 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ygnmi_test + +import ( + "context" + "strings" + "testing" + "time" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/openconfig/gnmi/errdiff" + "github.com/openconfig/ygnmi/exampleoc" + "github.com/openconfig/ygnmi/internal/exampleocconfig" + "github.com/openconfig/ygnmi/internal/testutil" + "github.com/openconfig/ygnmi/schemaless" + "github.com/openconfig/ygnmi/ygnmi" + "github.com/openconfig/ygot/util" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/testing/protocmp" + "google.golang.org/protobuf/types/known/anypb" + + gpb "github.com/openconfig/gnmi/proto/gnmi" + ygottestutil "github.com/openconfig/ygot/testutil" +) + +func lookupCheckFn[T any](t *testing.T, fakeGNMI *testutil.FakeGNMI, c *ygnmi.Client, inQuery ygnmi.SingletonQuery[T], wantErrSubstring string, wantSubscriptionPath *gpb.Path, wantVal *ygnmi.Value[T]) { + t.Helper() + got, err := ygnmi.Lookup(context.Background(), c, inQuery) + if diff := errdiff.Substring(err, wantErrSubstring); diff != "" { + t.Fatalf("Lookup(ctx, c, %v) returned unexpected diff: %s", inQuery, diff) + } + if err != nil { + return + } + verifySubscriptionPathsSent(t, fakeGNMI, wantSubscriptionPath) + checkJustReceived(t, got.RecvTimestamp) + wantVal.RecvTimestamp = got.RecvTimestamp + + if diff := cmp.Diff(wantVal, got, cmp.AllowUnexported(ygnmi.Value[T]{}, exampleoc.Model_SingleKey_OrderedList_OrderedMap{}, exampleocconfig.Model_SingleKey_OrderedList_OrderedMap{}), protocmp.Transform()); diff != "" { + t.Errorf("Lookup(ctx, c, %v) returned unexpected diff (-want,+got):\n %s\nComplianceErrors:\n%v", inQuery, diff, got.ComplianceErrors) + } +} + +func lookupWithGetCheckFn[T any](t *testing.T, fakeGNMI *testutil.FakeGNMI, c *ygnmi.Client, inQuery ygnmi.SingletonQuery[T], wantErrSubstring string, wantRequest *gpb.GetRequest, wantVal *ygnmi.Value[T]) { + t.Helper() + got, err := ygnmi.Lookup(context.Background(), c, inQuery, ygnmi.WithUseGet()) + if diff := errdiff.Substring(err, wantErrSubstring); diff != "" { + t.Fatalf("Lookup(ctx, c, %v) returned unexpected diff (-want, +got):\n%s", inQuery, diff) + } + if err != nil { + return + } + if diff := cmp.Diff(wantVal, got, cmp.AllowUnexported(ygnmi.Value[T]{}, exampleoc.Model_SingleKey_OrderedList_OrderedMap{}, exampleocconfig.Model_SingleKey_OrderedList_OrderedMap{}), cmpopts.IgnoreFields(ygnmi.Value[T]{}, "RecvTimestamp"), protocmp.Transform()); diff != "" { + t.Errorf("Lookup() returned unexpected diff (-want, +got):\n%s", diff) + } + if diff := cmp.Diff(wantRequest, fakeGNMI.GetRequests()[0], protocmp.Transform()); diff != "" { + t.Errorf("Lookup() GetRequest different from expected (-want, +got):\n%s", diff) + } +} + +func getCheckFn[T any](t *testing.T, fakeGNMI *testutil.FakeGNMI, c *ygnmi.Client, inQuery ygnmi.SingletonQuery[T], wantErrSubstring string, wantSubscriptionPath *gpb.Path, wantVal T) { + t.Helper() + got, err := ygnmi.Get(context.Background(), c, inQuery) + if diff := errdiff.Substring(err, wantErrSubstring); diff != "" { + t.Fatalf("Get(ctx, c, %v) returned unexpected diff: %s", inQuery, diff) + } + if err != nil { + return + } + verifySubscriptionPathsSent(t, fakeGNMI, wantSubscriptionPath) + + if diff := cmp.Diff(wantVal, got, cmp.AllowUnexported(exampleoc.Model_SingleKey_OrderedList_OrderedMap{}, exampleocconfig.Model_SingleKey_OrderedList_OrderedMap{})); diff != "" { + t.Errorf("Get(ctx, c, %v) returned unexpected diff (-want,+got):\n %s", inQuery, diff) + } +} + +func watchCheckFn[T any](t *testing.T, fakeGNMI *testutil.FakeGNMI, duration time.Duration, c *ygnmi.Client, inQuery ygnmi.SingletonQuery[T], + inOpts []ygnmi.Option, valPred func(T) bool, wantErrSubstring string, wantSubscriptionPaths []*gpb.Path, wantModes []gpb.SubscriptionMode, wantIntervals []uint64, wantVals []*ygnmi.Value[T], wantLastVal *ygnmi.Value[T]) { + t.Helper() + i := 0 + ctx, cancel := context.WithTimeout(context.Background(), duration) + defer cancel() + w := ygnmi.Watch(ctx, c, inQuery, func(v *ygnmi.Value[T]) error { + if i > len(wantVals) { + t.Fatalf("Predicate(%d) expected no more values but got: %+v", i, v) + } + if diff := cmp.Diff(wantVals[i], v, cmpopts.IgnoreFields(ygnmi.Value[T]{}, "RecvTimestamp"), cmp.AllowUnexported(ygnmi.Value[T]{}, exampleoc.Model_SingleKey_OrderedList_OrderedMap{}, exampleocconfig.Model_SingleKey_OrderedList_OrderedMap{}), protocmp.Transform()); diff != "" { + t.Errorf("Predicate(%d) got unexpected input (-want,+got):\n %s\nComplianceErrors:\n%v", i, diff, v.ComplianceErrors) + } + val, present := v.Val() + i++ + if present && valPred(val) { + return nil + } + return ygnmi.Continue + }, inOpts...) + val, err := w.Await() + if i < len(wantVals) { + t.Errorf("Predicate received too few values: got %d, want %d", i, len(wantVals)) + } + if diff := errdiff.Substring(err, wantErrSubstring); diff != "" { + t.Fatalf("Await() returned unexpected diff: %s", diff) + } + if err != nil { + return + } + verifySubscriptionPathsSent(t, fakeGNMI, wantSubscriptionPaths...) + verifySubscriptionModesSent(t, fakeGNMI, wantModes...) + verifySubscriptionSampleIntervalsSent(t, fakeGNMI, wantIntervals...) + if val != nil { + checkJustReceived(t, val.RecvTimestamp) + wantLastVal.RecvTimestamp = val.RecvTimestamp + } + if diff := cmp.Diff(wantLastVal, val, cmp.AllowUnexported(ygnmi.Value[T]{}, exampleoc.Model_SingleKey_OrderedList_OrderedMap{}, exampleocconfig.Model_SingleKey_OrderedList_OrderedMap{}), protocmp.Transform()); diff != "" { + t.Errorf("Await() returned unexpected value (-want,+got):\n%s", diff) + } +} + +func collectCheckFn[T any](t *testing.T, fakeGNMI *testutil.FakeGNMI, c *ygnmi.Client, inQuery ygnmi.SingletonQuery[T], wantErrSubstring string, wantSubscriptionPath *gpb.Path, wantVals []*ygnmi.Value[T]) { + t.Helper() + vals, err := ygnmi.Collect(context.Background(), c, inQuery).Await() + if diff := errdiff.Substring(err, wantErrSubstring); diff != "" { + t.Errorf("Await() returned unexpected diff: %s", diff) + } + verifySubscriptionPathsSent(t, fakeGNMI, wantSubscriptionPath) + for _, val := range vals { + checkJustReceived(t, val.RecvTimestamp) + } + if diff := cmp.Diff(wantVals, vals, cmpopts.IgnoreFields(ygnmi.Value[T]{}, "RecvTimestamp"), cmp.AllowUnexported(ygnmi.Value[T]{}), protocmp.Transform()); diff != "" { + t.Errorf("Await() returned unexpected value (-want,+got):\n%s", diff) + } +} + +func lookupAllCheckFn[T any](t *testing.T, fakeGNMI *testutil.FakeGNMI, c *ygnmi.Client, inQuery ygnmi.WildcardQuery[T], wantErrSubstring string, wantSubscriptionPath *gpb.Path, wantVals []*ygnmi.Value[T], nonLeaf bool) { + t.Helper() + got, err := ygnmi.LookupAll(context.Background(), c, inQuery) + if diff := errdiff.Substring(err, wantErrSubstring); diff != "" { + t.Fatalf("LookupAll(ctx, c, %v) returned unexpected diff: %s", inQuery, diff) + } + if err != nil { + return + } + verifySubscriptionPathsSent(t, fakeGNMI, wantSubscriptionPath) + for _, val := range got { + checkJustReceived(t, val.RecvTimestamp) + } + copts := []cmp.Option{ + cmp.AllowUnexported(ygnmi.Value[T]{}, exampleoc.Model_SingleKey_OrderedList_OrderedMap{}, exampleocconfig.Model_SingleKey_OrderedList_OrderedMap{}), + cmpopts.IgnoreFields(ygnmi.Value[T]{}, "RecvTimestamp"), + protocmp.Transform(), + } + if nonLeaf { + copts = append(copts, cmpopts.IgnoreFields(ygnmi.TelemetryError{}, "Err")) + } + if diff := cmp.Diff(wantVals, got, copts...); diff != "" { + t.Errorf("LookupAll() returned unexpected diff (-want,+got):\n%s", diff) + } +} + +func configCheckFn(t *testing.T, setClient *testutil.SetClient, c *ygnmi.Client, op func(*ygnmi.Client) (*ygnmi.Result, error), wantRequest *gpb.SetRequest, stubResponse *gpb.SetResponse, wantErrSubstring string, stubErr error) { + t.Helper() + setClient.Reset() + setClient.AddResponse(stubResponse, stubErr) + + got, err := op(c) + if diff := errdiff.Substring(err, wantErrSubstring); diff != "" { + t.Fatalf("config operation returned unexpected diff: %s", diff) + } + if err != nil { + return + } + if diff := cmp.Diff(wantRequest, setClient.Requests[0], protocmp.Transform()); diff != "" { + t.Errorf("config operation sent unexpected request (-want,+got):\n%s", diff) + } + want := &ygnmi.Result{ + RawResponse: stubResponse, + Timestamp: time.Unix(0, stubResponse.GetTimestamp()), + } + if diff := cmp.Diff(want, got, protocmp.Transform()); diff != "" { + t.Errorf("config operation returned unexpected value (-want,+got):\n%s", diff) + } +} + +type testStruct struct { + Val string +} + +func mustSchemaless[T any](t testing.TB, path, origin string) ygnmi.ConfigQuery[T] { + q, err := schemaless.NewConfig[T](path, origin) + if err != nil { + t.Fatal(err) + } + return q +} + +func mustAnyNew(t testing.TB, m proto.Message) *anypb.Any { + any, err := anypb.New(m) + if err != nil { + t.Fatal(err) + } + return any +} + +func removeWhitespace(s string) string { + return strings.Join(strings.Fields(s), "") +} + +func newClient(t testing.TB) (*testutil.FakeGNMI, *ygnmi.Client) { + fakeGNMI, err := testutil.StartGNMI(0) + if err != nil { + t.Fatal(err) + } + gnmiClient, err := fakeGNMI.Dial(context.Background()) + if err != nil { + t.Fatal(err) + } + c, err := ygnmi.NewClient(gnmiClient) + if err != nil { + t.Fatal(err) + } + return fakeGNMI, c +} + +// checkJustReceived checks that the received time is just before now. +func checkJustReceived(t *testing.T, recvTime time.Time) { + if diffSecs := time.Since(recvTime).Seconds(); diffSecs <= 0 && diffSecs > 1 { + t.Errorf("Received time is too far (%v seconds) away from now", diffSecs) + } +} + +// verifySubscriptionPathsSent verifies the paths of the sent subscription requests is the same as wantPaths. +func verifySubscriptionPathsSent(t *testing.T, fakeGNMI *testutil.FakeGNMI, wantPaths ...*gpb.Path) { + t.Helper() + requests := fakeGNMI.Requests() + if len(requests) != 1 { + t.Errorf("Number of subscription requests sent is not 1: %v", requests) + return + } + + var gotPaths []*gpb.Path + req := requests[0].GetSubscribe() + for _, sub := range req.GetSubscription() { + got, err := util.JoinPaths(req.GetPrefix(), sub.GetPath()) + if err != nil { + t.Fatal(err) + } + got.Target = "" + gotPaths = append(gotPaths, got) + } + if diff := cmp.Diff(wantPaths, gotPaths, protocmp.Transform(), cmpopts.SortSlices(ygottestutil.PathLess)); diff != "" { + t.Errorf("Subscription paths (-want, +got):\n%s", diff) + } +} + +// verifySubscriptionModesSent verifies the modes of the sent subscription requests is the same as wantModes. +func verifySubscriptionModesSent(t *testing.T, fakeGNMI *testutil.FakeGNMI, wantModes ...gpb.SubscriptionMode) { + t.Helper() + requests := fakeGNMI.Requests() + if len(requests) != 1 { + t.Errorf("Number of subscription requests sent is not 1: %v", requests) + return + } + + var gotModes []gpb.SubscriptionMode + req := requests[0].GetSubscribe() + for _, sub := range req.GetSubscription() { + gotModes = append(gotModes, sub.Mode) + } + if diff := cmp.Diff(wantModes, gotModes, protocmp.Transform()); diff != "" { + t.Errorf("Subscription modes (-want, +got):\n%s", diff) + } +} + +// verifySubscriptionSampleIntervalsSent verifies the modes of the sent subscription requests is the same as wantModes. +func verifySubscriptionSampleIntervalsSent(t *testing.T, fakeGNMI *testutil.FakeGNMI, wantIntervals ...uint64) { + t.Helper() + requests := fakeGNMI.Requests() + if len(requests) != 1 { + t.Errorf("Number of subscription requests sent is not 1: %v", requests) + return + } + + var gotIntervals []uint64 + req := requests[0].GetSubscribe() + for _, sub := range req.GetSubscription() { + gotIntervals = append(gotIntervals, sub.SampleInterval) + } + if diff := cmp.Diff(wantIntervals, gotIntervals); diff != "" { + t.Errorf("Subscription sample intervals (-want, +got):\n%s", diff) + } +} + +type gnmiS struct { + gpb.UnimplementedGNMIServer + errCh chan error +} + +func (g *gnmiS) Subscribe(srv gpb.GNMI_SubscribeServer) error { + if _, err := srv.Recv(); err != nil { + return err + } + if err := srv.Send(&gpb.SubscribeResponse{Response: &gpb.SubscribeResponse_SyncResponse{}}); err != nil { + return err + } + // This send must fail because the client will have cancelled the subscription context. + time.Sleep(time.Second) + err := srv.Send(&gpb.SubscribeResponse{Response: &gpb.SubscribeResponse_SyncResponse{}}) + g.errCh <- err + return nil +} diff --git a/ygnmi/ygnmi_uncompressed_test.go b/ygnmi/ygnmi_uncompressed_test.go index 8058168..092c097 100644 --- a/ygnmi/ygnmi_uncompressed_test.go +++ b/ygnmi/ygnmi_uncompressed_test.go @@ -21,7 +21,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/openconfig/gnmi/errdiff" - gpb "github.com/openconfig/gnmi/proto/gnmi" "github.com/openconfig/ygnmi/internal/testutil" "github.com/openconfig/ygnmi/internal/uexampleoc" "github.com/openconfig/ygnmi/internal/uexampleoc/uexampleocpath" @@ -29,6 +28,8 @@ import ( "github.com/openconfig/ygnmi/ygnmi" "github.com/openconfig/ygot/ygot" "google.golang.org/protobuf/testing/protocmp" + + gpb "github.com/openconfig/gnmi/proto/gnmi" ) func getSampleSingleKeyedMapUncompressed(t *testing.T) map[string]*uexampleoc.OpenconfigWithlistval_Model_A_SingleKey { diff --git a/ygnmi/ygnmi_unordered_test.go b/ygnmi/ygnmi_unordered_test.go new file mode 100644 index 0000000..8654e7c --- /dev/null +++ b/ygnmi/ygnmi_unordered_test.go @@ -0,0 +1,51 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ygnmi_test + +import ( + "testing" + "time" + + "github.com/openconfig/ygnmi/internal/exampleocunordered/exampleocunorderedpath" + "github.com/openconfig/ygnmi/internal/testutil" + "github.com/openconfig/ygnmi/ygnmi" + + gpb "github.com/openconfig/gnmi/proto/gnmi" +) + +func TestUnorderedOrderedMap(t *testing.T) { + fakeGNMI, c := newClient(t) + t.Run("success unordered ordered map leaf", func(t *testing.T) { + fakeGNMI.Stub().Notification(&gpb.Notification{ + Timestamp: 100, + Prefix: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, `ordered-list[key=foo]/config/key`), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_StringVal{StringVal: "foo"}}, + }}, + }).Sync() + + lookupCheckFn( + t, fakeGNMI, c, + ygnmi.SingletonQuery[string](exampleocunorderedpath.Root().Model().SingleKey("foo").OrderedList("foo").Key().Config()), + "", + testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists/ordered-list[key=foo]/config/key"), + (&ygnmi.Value[string]{ + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists/ordered-list[key=foo]/config/key"), + Timestamp: time.Unix(0, 100), + }).SetVal("foo"), + ) + }) +}