Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub issues rebase #679

Merged
3 commits merged into from
Feb 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions sdk/cpp/core/src/path/data_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,25 @@ ydk::path::DataNodeImpl::populate_new_schemas_from_path(const std::string& path)
ydk::path::DataNode&
ydk::path::DataNodeImpl::create_datanode(const std::string& path, const std::string& value)
{
std::string v = value;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest moving lines 117-129 into a separate function called something like 'escape_xml_declaration()'. This is so that it is clear what is being done by these lines of code.

if(value.substr(0, 5) == "<?xml") {
for(unsigned int i = 5; i<value.length(); i++) {
if (value[i] == '>'){
v = value.substr(i+1);
break;
}
}

if(v != value){
YLOG_DEBUG("Replacing 'value' with '{}'", v);
}
}

YLOG_DEBUG("Populating schemas for {}", path);
populate_new_schemas_from_path(path);
YLOG_DEBUG("Populating schemas for {}", value);
populate_new_schemas_from_path(value);
return create_helper(path, value);
YLOG_DEBUG("Populating schemas for {}", v);
populate_new_schemas_from_path(v);
return create_helper(path, v);
}

ydk::path::DataNode&
Expand Down
19 changes: 19 additions & 0 deletions sdk/cpp/tests/test_sanity_codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,3 +477,22 @@ TEST_CASE("embedded_quote_codec")
auto rp_decode = codec_service.decode(codec_provider, xml, make_unique<openconfig_routing_policy::RoutingPolicy>());
CHECK(*rp == *rp_decode);
}

TEST_CASE("TestSessionPathAnyxml")
{
ydk::path::Codec s{};
ydk::path::NetconfSession session{"127.0.0.1", "admin", "admin", 12022};
ydk::path::RootSchemaNode& root_schema = session.get_root_schema();

auto & schema = session.get_root_schema();

std::string xml = R"(<?xml version="1.0"?><runner xmlns="http://cisco.com/ns/yang/ydktest-sanity"><ytypes><built-in-t><bits-value>disable-nagle auto-sense-speed</bits-value></built-in-t></ytypes></runner>)";
auto a = s.decode(schema, xml, EncodingFormat::XML);
REQUIRE(a!=nullptr);

schema = session.get_root_schema();
xml = R"(<?xml version="1.0"?>
<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity"><ytypes><built-in-t><bits-value>disable-nagle auto-sense-speed</bits-value></built-in-t></ytypes></runner>)";
a = s.decode(schema, xml, EncodingFormat::XML);
REQUIRE(a!=nullptr);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
.. _types-errors:
.. _ydk-errors:

Errors
======

.. go:package:: ydk/types
.. go:package:: ydk/errors
:synopsis: YDK Go Errors

.. code-block:: sh

import "github.com/CiscoDevNet/ydk-go/ydk/types"
import "github.com/CiscoDevNet/ydk-go/ydk/errors"

.. attribute:: Y_ERROR_TYPE

Expand Down Expand Up @@ -62,6 +63,7 @@ Errors
Type is ``interface{}``

.. _errors-cerror:

.. object:: CError

CError is an interface type that represents a basic error in Go.
Expand Down
20 changes: 10 additions & 10 deletions sdk/go/core/docsgen/api/path/path.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Path

Connects to NETCONF service provider by creating a connection to the given provider using given address, username, password, and port.

:param state: (pointer to :go:struct:`State<ydk/types/State>`) Current state of execution
:param state: (pointer to :go:struct:`State<ydk/errors/State>`) Current state of execution
:param repo: (:go:struct:`Repository<ydk/types/Repository>`).
:param address: (``string``) A Go string.
:param username: (``string``) A Go string.
Expand All @@ -58,13 +58,13 @@ Path

CleanUpErrorState cleans up memory for CState

:param state: (pointer to :go:struct:`State<ydk/types/State>`) Current state of execution
:param state: (pointer to :go:struct:`State<ydk/errors/State>`) Current state of execution

.. function:: ConnectToRestconfProvider(state *State, path, address, username, password string, port int)

ConnectToRestconfProvider connects to RESTCONF device by creating a connection to the provider using given path, address, username, password, and port.

:param state: (pointer to :go:struct:`State<ydk/types/State>`) Current state of execution
:param state: (pointer to :go:struct:`State<ydk/errors/State>`) Current state of execution
:param path: (``string``) A Go string.
:param address: (``string``) A Go string.
:param username: (``string``) A Go string.
Expand All @@ -83,7 +83,7 @@ Path

InitCodecServiceProvider initializes CodecServiceProvider

:param state: (pointer to :go:struct:`State<ydk/types/State>`) Current state of execution
:param state: (pointer to :go:struct:`State<ydk/errors/State>`) Current state of execution
:param entity: :ref:`Entity <types-entity>`
:param repo: (:go:struct:`Repository<ydk/types/Repository>`).
:return: The root schema node parsed from repository
Expand All @@ -93,7 +93,7 @@ Path

CodecServiceEncode encodes entity to XML/JSON payloads based on encoding format passed in

:param state: (pointer to :go:struct:`State<ydk/types/State>`) Current state of execution
:param state: (pointer to :go:struct:`State<ydk/errors/State>`) Current state of execution
:param entity: (:ref:`Entity <types-entity>`).
:param rootSchema: (:go:struct:`RootSchemaNode<ydk/types/RootSchemaNode>`).
:param encoding: (:ref:`encoding-format-ydk`).
Expand All @@ -104,7 +104,7 @@ Path

CodecServiceDecode decodes XML/JSON payloads passed in to entity.

:param state: (pointer to :go:struct:`State<ydk/types/State>`) Current state of execution
:param state: (pointer to :go:struct:`State<ydk/errors/State>`) Current state of execution
:param rootSchema: (:go:struct:`RootSchemaNode<ydk/types/RootSchemaNode>`).
:param payload: (``string``) A Go string.
:param encoding: (:ref:`encoding-format-ydk`).
Expand All @@ -116,7 +116,7 @@ Path

ConnectToOpenDaylightProvider connects to OpenDaylight device.

:param state: (pointer to :go:struct:`State<ydk/types/State>`) Current state of execution
:param state: (pointer to :go:struct:`State<ydk/errors/State>`) Current state of execution
:param path: (``string``) A Go string.
:param address: (``string``) A Go string.
:param username: (``string``) A Go string.
Expand All @@ -137,7 +137,7 @@ Path

A getter function for the node ids given the opendaylight service provider.

:param state: (pointer to :go:struct:`State<ydk/types/State>`) Current state of execution
:param state: (pointer to :go:struct:`State<ydk/errors/State>`) Current state of execution
:param provider: (:go:struct:`COpenDaylightServiceProvider<ydk/types/COpenDaylightServiceProvider>`).
:returns: A slice of Go strings representing node ids.
:rtype: ``[]string``
Expand All @@ -146,7 +146,7 @@ Path

A getter function for the node provider given the opendaylight service provider and node id.

:param state: (pointer to :go:struct:`State<ydk/types/State>`) Current state of execution
:param state: (pointer to :go:struct:`State<ydk/errors/State>`) Current state of execution
:param provider: (:go:struct:`COpenDaylightServiceProvider<ydk/types/COpenDaylightServiceProvider>`).
:param nodeID: (``string``) A Go string.
:return: The service provider.
Expand All @@ -156,4 +156,4 @@ Path

AddCState creates and adds cstate to given state.

:param state: (pointer to :go:struct:`State<ydk/types/State>`) Current state of execution
:param state: (pointer to :go:struct:`State<ydk/errors/State>`) Current state of execution
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Open Daylight

.. attribute:: State

An instance of :go:struct:`State<ydk/types/State>` which represents the error state of this provider
An instance of :go:struct:`State<ydk/errors/State>` which represents the error state of this provider

.. function:: (provider *OpenDaylightServiceProvider) GetPrivate()

Expand All @@ -81,7 +81,7 @@ Open Daylight
.. function:: (provider *OpenDaylightServiceProvider) GetState()

:return: error state from OpenDaylightServiceProvider
:rtype: :go:struct:`*State<ydk/types/State>`
:rtype: :go:struct:`*State<ydk/errors/State>`

.. function:: (provider *OpenDaylightServiceProvider) Disconnect()

Expand Down Expand Up @@ -125,7 +125,7 @@ Netconf

.. attribute:: State

An instance of :go:struct:`State<ydk/types/State>`
An instance of :go:struct:`State<ydk/errors/State>`

.. function:: (provider *NetconfServiceProvider) GetPrivate()

Expand All @@ -139,7 +139,7 @@ Netconf
.. function:: (provider *NetconfServiceProvider) GetState()

:return: error state from NetconfServiceProvider
:rtype: :go:struct:`*State<ydk/types/State>`
:rtype: :go:struct:`*State<ydk/errors/State>`

.. function:: (provider *NetconfServiceProvider) Disconnect()

Expand Down Expand Up @@ -191,7 +191,7 @@ Restconf

.. attribute:: State

An instance of :go:struct:`State<ydk/types/State>`
An instance of :go:struct:`State<ydk/errors/State>`

.. function:: (provider *RestconfServiceProvider) GetPrivate()

Expand All @@ -205,7 +205,7 @@ Restconf
.. function:: (provider *RestconfServiceProvider) GetState()

:return: error state from RestconfServiceProvider
:rtype: :go:struct:`*State<ydk/types/State>`
:rtype: :go:struct:`*State<ydk/errors/State>`

.. function:: (provider *RestconfServiceProvider) Disconnect

Expand Down Expand Up @@ -233,7 +233,7 @@ Codec

.. attribute:: State

An instance of :go:struct:`State<ydk/types/State>`
An instance of :go:struct:`State<ydk/errors/State>`

.. function:: (provider *CodecServiceProvider) Initialize()

Expand All @@ -247,7 +247,7 @@ Codec
.. function:: (provider *CodecServiceProvider) GetState()

:return: error state from CodecServiceProvider
:rtype: :go:struct:`*State<ydk/types/State>`
:rtype: :go:struct:`*State<ydk/errors/State>`

.. function:: (provider *CodecServiceProvider) GetRootSchemaNode(entity types.Entity)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Executor
:param topEntity: Provide an instance of :ref:`Entity <types-entity>` only when expecting data to be returned
:return: Any data the resulting from the operation when provided topEntity parameter
:rtype: :ref:`Entity <types-entity>` or ``nil``
:raises: :go:struct:`YError<ydk/types/YError>` If error has occurred
:raises: :go:struct:`YError<ydk/errors/YError>` If error has occurred

Possible Errors:
* a server side error
Expand All @@ -126,7 +126,7 @@ Netconf
:param persistID: An ``int``
:return: whether or not the operation succeeded
:rtype: ``bool``
:raises: :go:struct:`YError<ydk/types/YError>` If error has occurred
:raises: :go:struct:`YError<ydk/errors/YError>` If error has occurred

.. function:: (ns *NetconfService) CloseSession(provider ServiceProvider)

Expand All @@ -135,7 +135,7 @@ Netconf
:param provider: An instance of :go:struct:`NetconfServiceProvider<ydk/providers/NetconfServiceProvider>`
:return: whether or not the operation succeeded
:rtype: ``bool``
:raises: :go:struct:`YError<ydk/types/YError>` If error has occurred
:raises: :go:struct:`YError<ydk/errors/YError>` If error has occurred

.. function:: (ns *NetconfService) Commit(
provider ServiceProvider, confirmed bool, confirmTimeOut, persist, persistID int)
Expand All @@ -149,7 +149,7 @@ Netconf
:param persistID: An ``int`` that is given in order to commit a persistent confirmed commit
:return: whether or not the operation succeeded
:rtype: ``bool``
:raises: :go:struct:`YError<ydk/types/YError>` If error has occurred
:raises: :go:struct:`YError<ydk/errors/YError>` If error has occurred

.. function:: (ns *NetconfService) CopyConfig(
provider ServiceProvider, target, sourceDS DataStore, sourceEntity Entity, url string)
Expand All @@ -164,7 +164,7 @@ Netconf
:param url: A ``string`` representing the configuration url
:return: whether or not the operation succeeded
:rtype: ``bool``
:raises: :go:struct:`YError<ydk/types/YError>` If error has occurred
:raises: :go:struct:`YError<ydk/errors/YError>` If error has occurred

.. function:: (ns *NetconfService) DeleteConfig(provider ServiceProvider, target DataStore, url string)

Expand All @@ -175,7 +175,7 @@ Netconf
:param url: A ``string`` representing the configuration url
:return: whether or not the operation succeeded
:rtype: ``bool``
:raises: :go:struct:`YError<ydk/types/YError>` If error has occurred
:raises: :go:struct:`YError<ydk/errors/YError>` If error has occurred

.. function:: (ns *NetconfService) DiscardChanges(provider ServiceProvider)

Expand All @@ -184,7 +184,7 @@ Netconf
:param provider: An instance of :go:struct:`NetconfServiceProvider<ydk/providers/NetconfServiceProvider>`
:return: whether or not the operation succeeded
:rtype: ``bool``
:raises: :go:struct:`YError<ydk/types/YError>` If error has occurred
:raises: :go:struct:`YError<ydk/errors/YError>` If error has occurred

.. function:: (ns *NetconfService) EditConfig(
provider ServiceProvider, target DataStore, config Entity, defaultOper, testOp, errorOp string)
Expand All @@ -199,7 +199,7 @@ Netconf
:param errOp: A ``string`` that can be set to ``stop-on-error``, ``continue-on-error``, or ``rollback-on-error``
:return: whether or not the operation succeeded
:rtype: ``bool``
:raises: :go:struct:`YError<ydk/types/YError>` If error has occurred
:raises: :go:struct:`YError<ydk/errors/YError>` If error has occurred

.. function:: (ns *NetconfService) GetConfig(provider ServiceProvider, source DataStore, filter Entity)

Expand All @@ -210,7 +210,7 @@ Netconf
:param filter: An instance of :ref:`Entity <types-entity>` which specifies the portion of the system configuration and state data to retrieve
:return: The requested data
:rtype: :ref:`Entity <types-entity>`
:raises: :go:struct:`YError<ydk/types/YError>` If error has occurred
:raises: :go:struct:`YError<ydk/errors/YError>` If error has occurred


.. function:: (ns *NetconfService) Get(provider ServiceProvider, filter Entity)
Expand All @@ -221,7 +221,7 @@ Netconf
:param filter: An instance of :ref:`Entity <types-entity>` which specifies the portion of the system configuration and state data to retrieve
:return: The requested data
:rtype: :ref:`Entity <types-entity>`
:raises: :go:struct:`YError<ydk/types/YError>` If error has occurred
:raises: :go:struct:`YError<ydk/errors/YError>` If error has occurred

.. function:: (ns *NetconfService) KillSession(provider ServiceProvider, sessionID int)

Expand All @@ -231,7 +231,7 @@ Netconf
:param sessionID: An ``int`` that is the session identifier of the NETCONF session to be terminated
:return: whether or not the operation succeeded
:rtype: ``bool``
:raises: :go:struct:`YError<ydk/types/YError>` If error has occurred
:raises: :go:struct:`YError<ydk/errors/YError>` If error has occurred

.. function:: (ns *NetconfService) Lock(provider ServiceProvider, target DataStore)

Expand All @@ -241,7 +241,7 @@ Netconf
:param target: An instance of :ref:`DataStore <datastore-ydk>` representing the configuration to lock
:return: whether or not the operation succeeded
:rtype: ``bool``
:raises: :go:struct:`YError<ydk/types/YError>` If error has occurred
:raises: :go:struct:`YError<ydk/errors/YError>` If error has occurred

.. function:: (ns *NetconfService) Unlock(provider ServiceProvider, target DataStore)

Expand All @@ -251,7 +251,7 @@ Netconf
:param target: An instance of :ref:`DataStore <datastore-ydk>` representing the configuration to unlock
:return: whether or not the operation succeeded
:rtype: ``bool``
:raises: :go:struct:`YError<ydk/types/YError>` If error has occurred
:raises: :go:struct:`YError<ydk/errors/YError>` If error has occurred

.. function:: (ns *NetconfService) Validate(
provider ServiceProvider, sourceDS DataStore, sourceEntity Entity, url string)
Expand All @@ -264,4 +264,4 @@ Netconf
:param url: A ``string`` representing the configuration url
:return: whether or not the operation succeeded
:rtype: ``bool``
:raises: :go:struct:`YError<ydk/types/YError>` If error has occurred
:raises: :go:struct:`YError<ydk/errors/YError>` If error has occurred
1 change: 0 additions & 1 deletion sdk/go/core/docsgen/api/types/_types_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ Types
base_constants/yfilters.rst
base_constants/ytype.rst
ydk_types.rst
errors.rst
4 changes: 2 additions & 2 deletions sdk/go/core/docsgen/api/types/base_constants/yfilters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ filtering read operations by leaf to be used with various :go:struct:`Services<y
containing this attribute is added to the configuration if
and only if the configuration data does not already exist in
the configuration datastore. If the configuration data
exists, an error (:go:struct:`YServiceProviderError<ydk/types/YServiceProviderError>`) will be thrown
exists, an error (:go:struct:`YServiceProviderError<ydk/errors/YServiceProviderError>`) will be thrown
with XML error message.

.. attribute:: Remove
Expand All @@ -75,7 +75,7 @@ filtering read operations by leaf to be used with various :go:struct:`Services<y
containing this attribute is deleted from the configuration
if and only if the configuration data currently exists in
the configuration datastore. If the configuration data does
not exist, an :go:struct:`YServiceProviderError<ydk/types/YServiceProviderError>` will be
not exist, an :go:struct:`YServiceProviderError<ydk/errors/YServiceProviderError>` will be
thrown with XML error message.

.. attribute:: Replace
Expand Down
Loading