YDK Types¶
import "github.com/CiscoDevNet/ydk-go/ydk/types"
-
struct
ydk/types/DataNode¶
-
struct
ydk/types/RootSchemaNode¶
-
struct
ydk/types/Session¶
-
struct
ydk/types/Repository¶
-
ServiceProvider ServiceProvider is an interface type defined for supported Service Providers.
-
GetPrivate()¶ Return type: interface{}
-
Connect()¶
-
Disconnect()¶
-
GetType() string
-
ExecuteRpc(string, Entity, map[string]string) DataNode
-
-
struct
ydk/types/CServiceProvider¶
-
struct
ydk/types/COpenDaylightServiceProvider¶
-
CodecServiceProvider CodecServiceProvider is an interface type for
CodecServiceProvider-
Initialize(Entity)¶
-
GetEncoding()¶ Return type: Encoding Format
-
GetRootSchemaNode(Entity)¶ Return type: RootSchemaNode
-
GetState() Return type: *State
-
YANG Types¶
The Types package provides built-in types specified in YANG RFC 6020 and types used in YDK Go APIs.
These are how YANG types are represented in Go.
-
Bits¶ Represents a YANG built-in bits type with base type of
map[string]bool.
-
struct
ydk/types/Decimal64(value)¶ Represents a YANG built-in decimal64 type.
-
Value¶ A string representation for decimal value.
-
-
struct
ydk/types/Empty¶ Represents a YANG built-in empty type.
-
(e *Empty) String() Returns the string representation of empty type
Parameters: e – EmptyReturns: The string representation of the given type Return type: A Go string
-
struct
ydk/types/EnumYLeaf¶ Represents variable data
-
value¶ The value of the variable
-
name¶ The name of the variable
-
-
struct
ydk/types/Enum¶ Represents a YANG built-in enum type, a base type for all YDK enums.
-
struct
ydk/types/LeafData¶ Represents the data contained in a YANG leaf
-
Value A Go
stringrepresenting the data of the leaf
-
IsSet¶ boolrepresenting whether the filter is set or not
-
-
struct
ydk/types/NameLeafData¶ Represents a YANG leaf to which a name and data can be assigned
-
Name¶ A Go
stringrepresenting the name of the leaf
-
-
NameLeafDataList¶ A slice ([]
NameLeafData) that represents a YANG leaf-list-
(p NameLeafDataList) Len() Returns: The length of a given leaf-list Return type: int
-
(p NameLeafDataList) Swap(i, j int) Swaps the
NameLeafDataat indices i and j
-
(p NameLeafDataList) Less(i, j int) Returns: If the name of the NameLeafDataat index i is less than the one at index jReturn type: bool
-
-
List¶ In YDK YANG list is represented by Go slice of references to a structure, which implements interface Entity.
Example:
If Go structure YangList implements interface Entity, meaning implements func (e *YangList) GetEntityData() *CommonEntityData {}, then the list of entities should be implemented as []*YangList. according to the YANG model the list may have one or more keys, which uniquely identify list element, or may have no keys. The slices can be created and list elements can be accessed using standard Go functions and methods. The YDK provides package ylist containing functions, which allow user access list elements by key or keys.
-
Get(slice interface{}, keys ... interface{}) (int, Entity)¶ Get list element (entity) by key or keys, if list element has more than one key
Parameters: - slice – Slice variable, which is defined in the list holding entity
- keys – Comma separated list of key values
Returns: Tuple of found element index and the element itself, which has matching key(s) value(s). If element is not found - (-1, nil).
Return type: Tuple( int, Entity)
-
Keys(slice interface{}) []interface{} Entity Get keys for all list elements
Parameters: slice – Slice variable, which is defined in the list holding entity Returns: Values of all keys, that have matching elements in the list Return type: Go []interface{}; if list has more than one key, the set of keys for one element is returned as[]interface{}
-
-
struct
ydk/types/EntityPath¶ -
ValuePaths¶ A slice ([]
NameLeafData) representing a list of YANG leafs
-
-
struct
ydk/types/YChild¶ YChild encapsulates the GoName of an entity as well as the entity itself
-
GoName¶ A
stringrepresenting the GoName of an entity
-
Value The Entity itself
-
-
struct
ydk/types/YLeaf¶ YLeaf encapsulates the GoName of a leaf as well as the leaf itself
-
GoName A
stringrepresenting the GoName of an entity
-
Value The leaf (type
interface{}) itself
-
-
struct
ydk/types/CommonEntityData¶ CommonEntityData encapsulate common data within an Entity
-
YangName¶ A
stringrepresenting Yang name of the entity
-
BundleName¶ A
stringrepresenting the bundle name of the entity
-
ParentYangName¶ A
stringrepresenting the parent Yang name of the entity
-
SegmentPath¶ A
stringrepresenting the segment path
-
CapabilitiesTable¶ A
map[string]stringrepresenting the capabilities table
-
NamespaceTable¶ A
map[string]stringrepresenting the namespace table
-
BundleYangModelsLocation¶ A
stringrepresenting the models path
-
-
Entity An interface type that represents a basic container in YANG
-
GetEntityData() *CommonEntityData The Entity interface function
Returns: a pointer to CommonEntityDatarepresenting entity data
-
-
GetSegmentPath(entity Entity) string Parameters: entity – An instance of Entity Returns: The entity’s segment path value
-
GetAbsolutePath(entity Entity) string Parameters: entity – An instance of Entity Returns: The entity’s absolute path value - Note: The parent-child relations must be set before calling this function.
- As an advice the SetAllParents on the top level entity must be called to set the references.
-
GetParent(entity Entity) Entity Parameters: entity – An instance of Entity Returns: Entity, which represents given entity’s parent; if parent entity is not set, returns nil
-
SetParent(entity, parent Entity)¶ SetParent sets the given Entity parent field to the given parent Entity
Parameters: entity – An instance of Entity
-
SetAllParents(entity Entity)¶ The function sets Parent field in all children recursively starting from the given Entity
Parameters: entity – An instance of Entity
-
HasDataOrFilter(entity Entity) bool Parameters: entity – An instance of Entity Returns: A Go boolean representing whether the Entity or any of its children have their data/filter set
-
GetEntityPath(entity Entity)¶ Parameters: entity – An instance of Entity Returns: EntityPathfor the given entity
-
GetChildByName(entity Entity, childYangName string, segmentPath string) Entity Finds entity’s child entity by name and segment path
Parameters: - entity – An instance of Entity
- childYangName – The YangName of the child entity
- segmentPath – The SegmentPath value of the child entity
Returns: Entity described by the given childYangName and segmentPath or
nilif there is no match
-
SetValue(entity Entity, valuePath string, value interface{})¶ Sets leaf value
Parameters:
-
IsPresenceContainer(entity Entity) bool returns if the given Entity is a presence container
Parameters: entity – An instance of Entity Returns: A Go boolean representing whether the Entity is a presence container or not
-
GetPresenceFlag(entity Entity) bool returns whether the presence flag of the given Entity
Parameters: entity – An instance of Entity Returns: A Go boolean representing whether the Entity is the presence flag has been set or not
-
SetPresenceFlag(entity Entity)¶ sets the presence flag of the given Entity if it is a presence container
Parameters: entity – An instance of Entity
-
EntityToString(entity Entity) string Utility function to get string representation of the entity.
Returns: Go stringin format: “Type: entity-instance-type, Path: entity-segment-path”.
-
EntityToDict(entity Entity) map[string]string Utility function to get dictionary of all leaves and presence containers recursively in this entity and its children.
Parameters: entity – An instance of Entity Returns: A map[string]string, where key represents leaf absolute path and value represents string value of the leaf; In case of presence container the key represents the container absolute path and value is empty string.
-
struct
ydk/types/StringPair¶ Type StringPair defines a pair of string values. Both members of the structure are of
stringtype:-
Left¶
-
Right¶
-
-
EntityDiff(entity1, entity2 Entity) map[string]StringPair Utility function to compare two entities of the same underlying type. Compared are presence containers and all leaves recursively.
Parameters: entity – An instance of Entity Returns: A map[string]StringPair, map of differences between two entities, where key represents leaf or presence container absolute path and value StringPair represents difference in string values of the leaves.
-
struct
ydk/types/EntityCollection¶ Type EntityCollection along with its methods implements ordered map collection of entities. The string value of entity SegmentPath serves as a map key for the entity. Ordered means, the collection retains order of entities, in which they were added to collection.
The EntityCollection type has two aliases - Config and Filter.
-
GetEntityData() *CommonEntityData Implements Entity interface.
Returns: a reference to CommonEntityDatarepresenting data for the first entity in the collection;nil- if collection is empty
-
Add(entities ... Entity)¶ Method of EntityCollection. Adds new elements into collection.
Parameters: entities – Non-empty list of comma separated instances of Entity.
-
Append(entities []Entity)¶ Method of EntityCollection. Adds new elements into EntityCollection.
Parameters: entities – Non-empty slicen of ‘Entity’ type instances.
-
Len() int Method of EntityCollection.
Returns: Number of elements in the collection.
-
Get(key string) Entity Method of EntityCollection. Gets collection elements by key.
Parameters: key – Go string, which represents SegmentPath of an entity.Returns: Instance of Entity if matching key is present in collection, nil- otherwise.
-
GetItem(item int) Entity Method of EntityCollection. Gets collection elements by item/order number.
Parameters: item – Sequential number of an entity in the collection. Returns: Instance of Entity, which stands in the ordered map by the number item; nil- item value is not in the range of collection size.
-
HasKey(key string) bool Method of EntityCollection. Checks if the collection contains an entity with given key value.
Parameters: key – Go string, which represents SegmentPath of an entity.Returns: Go bool:true- if collection contains corresponding entity;false- otherwise.
-
Pop(key string) Entity Method of EntityCollection. Removes entity from collection. When element is removed from inside of the collection, all the following elements are shifted, meaning their indexes changed by -1. This way the order of elements is retained.
Parameters: key – Go string, which represents SegmentPath of an entity.Returns: Instance of Entity, if corresponding key is found in the collection; nil- otherwise.
-
Clear()¶ Method of EntityCollection. Removes all elements from collection.
-
Keys() []string Method of EntityCollection.
Returns: Slice of stringrepresenting array of all the keys in the collection.
-
Entities() []Entity Method of EntityCollection.
Returns: Slice/array of all the Entity instances in the collection.
-
String() string Method of EntityCollection.
Returns: Go string, which represents entity collection.
-
-
NewEntityCollection(entities ... Entity) EntityCollection Function creates new EntityCollection instance and populates it with supplied entities.
Parameters: entities – list of comma separated instances of Entity, including empty list. Returns: Instance of EntityCollection, which includes specified in the parameters entities. If no entities is listed as parameters, the function returns empty collection.
-
NewConfig(entities ... Entity) Config Function creates new Config instance similar to function NewEntityCollection.
-
NewFilter(entities ... Entity) Filter Function creates new Filter instance similar to function NewEntityCollection.
-
EntityToCollection (entity Entity) *EntityCollection Function converts or casts Entity to EntityCollection.
Parameters: entity – Instance of type Entity or EntityCollection. Returns: Pointer to instance of EntityCollection. If parameter is instance of EntityCollection the function returns the same. If entity is instance of Entity, the function creates new entity collection, which includes entity as its element.
-
IsEntityCollection (entity Entity) bool Function checks type of entity.
Parameters: entity – Instance of type Entity or EntityCollection. Returns: Go bool:true- if entity is instance of EntityCollection;false- otherwise.