Skip to content

Commit

Permalink
Merge pull request #723 from ylil93/golang_merge
Browse files Browse the repository at this point in the history
Golang package reduction merge
  • Loading branch information
Abhi Keshav authored Mar 26, 2018
2 parents 3cfffeb + f2ea0f7 commit c9b8708
Show file tree
Hide file tree
Showing 14 changed files with 307 additions and 644 deletions.
142 changes: 59 additions & 83 deletions sdk/go/core/docsgen/api/types/ydk_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,153 +180,129 @@ These are how YANG types are represented in Go.
:return: If the name of the :go:struct:`NameLeafData` at index i is less than the one at index j
:rtype: ``bool``

.. go:struct:: YLeaf
.. go:struct:: EntityPath
.. attribute:: Path

Represents a YANG ``leaf`` to which data can be assigned.
A Go ``string`` representing the path

.. attribute:: name
.. attribute:: ValuePaths

A Go ``string`` representing the name of the leaf
A slice ([] :go:struct:`NameLeafData`) representing a list of YANG leafs

.. attribute:: leafType
.. go:struct:: YChild
:ref:`YTypes <y-type>` represents the YANG data type assigned to the leaf
YChild encapsulates the GoName of an entity as well as the entity itself

.. attribute:: bitsValue
.. attribute:: GoName

The :ref:`Bits <type-bits>` value assigned to the leaf
A ``string`` representing the GoName of an entity

.. attribute:: Value

A Go ``string`` representing the value of the leaf
The :ref:`Entity <types-entity>` itself

.. attribute:: IsSet
.. go:struct:: YLeaf
``bool`` representing whether the leaf is set or not
YLeaf encapsulates the GoName of a leaf as well as the leaf itself

.. attribute:: Filter
.. attribute:: GoName

:ref:`YFilter <y-filter>`
A ``string`` representing the GoName of an entity

.. function:: (y *YLeaf) GetNameLeafdata()
.. attribute:: Value

Instantiates and returns name leaf data type for this leaf
The leaf (type ``interface{}``) itself

:return: name leaf data
:rtype: :go:struct:`NameLeafData`
.. go:struct:: CommonEntityData
Example usage for creating a ``YLeaf`` of YANG type ``int8``:
CommonEntityData encapsulate common data within an :ref:`Entity <types-entity>`

.. code-block:: go
.. attribute:: YangName

import "github.com/CiscoDevNet/ydk-go/ydk/types"
A ``string`` representing the yang name

var yleaf YLeaf
yleaf.leafType = types.Int8
yleaf.name = "afi-safi-name"
.. attribute:: BundleName

.. go:struct:: YLeafList
A ``string`` representing the bundle name

Represents a YANG ``leaf-list`` to which multiple instances of data can be appended to
.. attribute:: ParentYangName

.. attribute:: name
A ``string`` representing the parent yang name

A Go ``string`` representing the name of the leaf-list
.. attribute:: YFilter

.. attribute:: values
A :ref:`YFilter <y-filter>` representing the yfilter

A slice of :go:struct:`YLeaf` representing the multiple instances of data
.. attribute:: Children

.. attribute:: Filter
A ``map`` of ``string`` representing yang name to :go:struct:`YChild`, representing the children

:ref:`YFilter <y-filter>`
.. attribute:: Leafs

.. attribute:: leafType
A ``map`` of ``string`` representing yang name to :go:struct:`YLeaf`, representing the leafs

:ref:`YTypes <y-type>` represents the YANG data type assigned to the leaf
.. attribute:: SegmentPath

.. function:: (y *YLeafList) GetYLeafs()
A ``string`` representing the segment path

Getter function for :go:struct:`YLeafList` values
.. attribute:: CapabilitiesTable

:return: A slice of the multiple instances of data
:rtype: [] :go:struct:`YLeaf`
A ``map[string]string`` representing the capabilities table

.. function:: (y *YLeafList) GetNameLeafdata()
.. attribute:: NamespaceTable

Instantiates and returns name leaf data type for this leaf-list

:return: slice of name leaf data
:rtype: [] :go:struct:`NameLeafData`

.. go:struct:: EntityPath
.. attribute:: Path
A ``map[string]string`` representing the namespace table

A Go ``string`` representing the path
.. attribute:: BundleYangModelsLocation

.. attribute:: ValuePaths
A ``string`` representing the models path

A slice ([] :go:struct:`NameLeafData`) representing a list of YANG leafs
.. attribute:: Parent

An :ref:`Entity <types-entity>` representing the parent

.. _types-entity:

.. object:: Entity

An interface type that represents a basic container in YANG

.. function:: GetSegmentPath()

:return: (``string``) A Go string.

.. function:: GetChildByName(string, string)

:return: :ref:`Entity <types-entity>`

.. function:: GetChildren()

:return: ``map[string]Entity``

.. function:: SetParent(Entity)
.. function:: GetEntityData()

.. function:: GetParent()
:return: a reference to :go:struct:`CommonEntityData` representing the data of the entity

:return: :ref:`Entity <types-entity>`
.. function:: GetSegmentPath(entity Entity)

.. function:: GetCapabilitiesTable()
GetSegmentPath returns the segment path

:return: ``map[string]string``
:return: (``string``) A Go string.

.. function:: GetNamespaceTable()
.. function:: GetParent(entity Entity)

:return: ``map[string]string``
GetParent returns the given entity's parent

.. function:: GetBundleYangModelsLocation()

:return: (``string``) The bundle yang model's location

.. function:: GetBundleName()
:return: :ref:`Entity <types-entity>`

:return: (``string``) The name of the bundle
.. function:: SetParent(entity, parent Entity)

.. function:: GetYangName()
SetParent sets the given :ref:`Entity <types-entity>` parent field to the given parent :ref:`Entity <types-entity>`

:return: (``string``) The yang name
.. function:: HasDataOrFilter(entity Entity)

.. function:: GetParentYangName()
HasDataOrFilter returns a bool representing whether the :ref:`Entity <types-entity>` or any of its children have their data/filter set

:return: (``string``) The parent's yang name
:return: (``bool``) A Go boolean.

.. function:: GetFilter()
.. function:: GetEntityPath(entity Entity)

:return: :ref:`YFilter <y-filter>`
GetEntityPath returns an EntityPath struct for the given entity

.. function:: HasDataOrFilter(entity Entity)
:return: :go:struct:`EntityPath`

:return: (``bool``) A Go boolean.
.. function:: GetChildByName(entity Entity, childYangName, segmentPath string)

.. function:: GetEntityPath(entity Entity)
GetChildByName takes an :ref:`Entity <types-entity>` and returns the child :ref:`Entity <types-entity>` described by the given childYangName and segmentPath or nil if there is no match

:return: :ref:`Entity <types-entity>`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
ysanity_bgp "github.com/CiscoDevNet/ydk-go/ydk/models/ydktest/openconfig_bgp"
"github.com/CiscoDevNet/ydk-go/ydk/providers"
"github.com/CiscoDevNet/ydk-go/ydk/services"
"github.com/CiscoDevNet/ydk-go/ydk/types"
encoding "github.com/CiscoDevNet/ydk-go/ydk/types/encoding_format"
)

Expand Down
4 changes: 2 additions & 2 deletions sdk/go/core/samples/bgp_codec_encode/bgp_codec_encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
ysanity_bgp_types "github.com/CiscoDevNet/ydk-go/ydk/models/ydktest/openconfig_bgp_types"
"github.com/CiscoDevNet/ydk-go/ydk/providers"
"github.com/CiscoDevNet/ydk-go/ydk/services"
"github.com/CiscoDevNet/ydk-go/ydk/types"
"github.com/CiscoDevNet/ydk-go/ydk/types/encoding_format"
encoding "github.com/CiscoDevNet/ydk-go/ydk/types/encoding_format"
)

Expand Down Expand Up @@ -80,7 +80,7 @@ func main() {
if *vPtr {
ydk.EnableLogging(ydk.Info)
}
var ef types.EncodingFormat
var ef encodingformat.EncodingFormat

switch encoding_fmt {
case "xml":
Expand Down
5 changes: 3 additions & 2 deletions sdk/go/core/samples/bgp_delete/bgp_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
oc_bgp "github.com/CiscoDevNet/ydk-go/ydk/models/ydktest/openconfig_bgp"
"github.com/CiscoDevNet/ydk-go/ydk/providers"
"github.com/CiscoDevNet/ydk-go/ydk/services"
"github.com/CiscoDevNet/ydk-go/ydk/types"
)

func main() {
Expand Down Expand Up @@ -99,8 +100,8 @@ func main() {
crud := services.CrudService{}

bgp := oc_bgp.Bgp{}
bgp.Global.SetParent(&bgp)
bgp.Global.Config.SetParent(&bgp.Global)
types.SetParent(&bgp.Global, &bgp)
types.SetParent(&bgp.Global.Config, &bgp.Global)

result := crud.Delete(&provider, &bgp.Global.Config)

Expand Down
4 changes: 4 additions & 0 deletions sdk/go/core/tests/filter_read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package test
import (
"fmt"
filterread "github.com/CiscoDevNet/ydk-go/ydk/models/ydktest/filterread"
"github.com/CiscoDevNet/ydk-go/ydk"
"github.com/CiscoDevNet/ydk-go/ydk/providers"
"github.com/CiscoDevNet/ydk-go/ydk/services"
"github.com/CiscoDevNet/ydk-go/ydk/types"
Expand Down Expand Up @@ -195,5 +196,8 @@ func (suite *FilterReadTestSuite) BeforeTest(suiteName, testName string) {
}

func TestFilterReadTestSuite(t *testing.T) {
if testing.Verbose() {
ydk.EnableLogging(ydk.Debug)
}
suite.Run(t, new(FilterReadTestSuite))
}
Loading

0 comments on commit c9b8708

Please sign in to comment.