Edit Operations

enum class EditOperation

Operations as defined under netconf edit-config operation attribute in RFC 6241 to be used with various YDK services and entities.

enumerator merge

The configuration data identified by the element containing this attribute is merged with the configuration at the corresponding level in the configuration datastore identified by the <target> parameter. This is the default behavior.

enumerator create

The configuration data identified by the element 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 <rpc-error> element is returned with an <error-tag> value of “data-exists”.

enumerator remove

The configuration data identified by the element containing this attribute is deleted from the configuration if the configuration data currently exists in the configuration datastore. If the configuration data does not exist, the “remove” operation is silently ignored by the server.

enumerator delete_

The configuration data identified by the element 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 <rpc-error> element is returned with an <error-tag> value of “data-missing”.

enumerator replace

The configuration data identified by the element containing this attribute replaces any related configuration in the configuration datastore identified by the <target> parameter. If no such configuration data exists in the configuration datastore, it is created. Unlike a <copy-config> operation, which replaces the entire target configuration, only the configuration actually present in the <config> parameter is affected.

enumerator not_set

Default value to which all configuration data is initialized to, indicating no operation has been selected. If no operation is selected, merge is performed

Example usage

An example of setting the operation for an entity (address family) under openconfig BGP is shown below

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Instantiate a bgp smart pointer object representing the bgp container from the openconfig-bgp YANG model
auto bgp = std::make_unique<ydk::openconfig_bgp::Bgp>();

// Instantiate an af-safi object representing the af-safi list from the openconfig-bgp YANG model
auto afi_safi = make_unique<ydk::openconfig_bgp::Bgp::Global::AfiSafis::AfiSafi>();

// Set the operation to delete, which will delete this instance of the address family
afi_safi->operation = EditOperation::delete_;

// Set the key
afi_safi->afi_safi_name = L3VpnIpv4UnicastIdentity();
// Set afi-safis as the parent of the list instance
afi_safi->parent = bgp->global->afi_safis.get();
//Append the list instance to afi-safis's afi-safi field
bgp->global->afi_safis->afi_safi.push_back(std::move(afi_safi));

// Instantiate the CRUD service and Netconf provider to connect to a device with address 10.0.0.1
CrudService crud_service{};
NetconfServiceProvider provider{"10.0.0.1", "test", "test", 830};

// Invoke the CRUD Update method
crud_service.update(provider, *bgp);