Skip to content

Commit

Permalink
Added documentation for enhancement CiscoDevNet#925
Browse files Browse the repository at this point in the history
  • Loading branch information
ygorelik committed Jul 17, 2019
1 parent 2036891 commit c7998dc
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
16 changes: 10 additions & 6 deletions sdk/go/core/docsgen/api/types/ydk_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,12 @@ These are how YANG types are represented in Go.
.. function:: GetSegmentPath(entity Entity) string

:param entity: An instance of :ref:`Entity <types-entity>`
:return: The entity's `SegmentPath` value
:return: The entity's segment path value

.. function:: GetAbsolutePath(entity Entity) string

:param entity: An instance of :ref:`Entity <types-entity>`
:return: The entity's `AbsolutePath` value
:return: 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.
Expand Down Expand Up @@ -406,10 +406,11 @@ These are how YANG types are represented in Go.

.. function:: EntityToDict(entity Entity) map[string]string

Utility function to get dictionary of all leaves recursively in this entity and its children.
Utility function to get dictionary of all leaves and presence containers recursively in this entity and its children.

:param entity: An instance of :ref:`Entity <types-entity>`
:return: A `map[string]string`, where key represent leaf absolute path and value represents string value of the leaf
:return: 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.

.. _string-pair:

Expand All @@ -427,14 +428,17 @@ These are how YANG types are represented in Go.
Compared are presence containers and all leaves recursively.

:param entity: An instance of :ref:`Entity <types-entity>`
:return: A `map[string]StringPair`, map of differences between two entities, where key represents leaf or presence container absolute path and value represents string value of the leaf.
:return: A `map[string]StringPair`, map of differences between two entities, where key represents leaf or presence
container absolute path and value :ref:`StringPair <string-pair>` represents difference in string values of the leaves.


.. _entity-collection:

.. go:struct:: 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.
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`.

Expand Down
29 changes: 29 additions & 0 deletions sdk/python/core/docsgen/api/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,35 @@ YDK types
uint8 type.


Utility functions
-----------------

.. function:: absolute_path(entity)

Utility function to get absolute path of the entity.

:param entity: An instance of :py:class:`Entity<ydk.types.Entity>`.
:return: A ``str`` representing entity's absolute path.

.. function:: entity_to_dict(entity)

Utility function to get dictionary of all leaves and presence containers recursively in this entity and its children.

:param entity: An instance of :py:class:`Entity<ydk.types.Entity>`.
:return: A dictionary, where key represents leaf absolute path and value represents string value of the leaf;
In case of presence container the key represents the container's absolute path and value is empty string.

.. function:: entity_diff(entity1, entity2)

Utility function to compare two entities of the same underlying type.
Compared are presence containers and all leaves recursively.

:param entity1: An instance of :py:class:`Entity<ydk.types.Entity>`.
:param entity2: An instance of :py:class:`Entity<ydk.types.Entity>`.
:return: A dictionary of differences between two entities, where key of type `str` represents leaf or presence
container absolute path and value of type `tuple` represents difference in `str` values of the leaves.
:raises: Exception :py:exc:`YInvalidArgumentError<ydk.error.YInvalidArgumentError>`, if supplied entities are None or have different types.

Examples
--------

Expand Down

0 comments on commit c7998dc

Please sign in to comment.