Class: ClientContent
Defined in: netconf/src/client-content.ts:128
client.content: the Content layer. Read and change configuration by YANG path (read(), set(), configure()), compare datastores, list the server's datastores and modules, convert between XML and JSON, and each enabled extension's decoded readers under its id. Reads resolve with RFC 7951 JSON by default. See Content.
Methods
checkEdits()
checkEdits(build, options?): Promise<void>;Defined in: netconf/src/client-content.ts:458
Check a configure() callback's changes without applying them: rejects with the PathError configure() would give (a malformed path, an unknown module or @name, two changes to the same node, a value given to remove). Sends no edit and takes no lock; like configure(), it may read the YANG library once to resolve a module only the library lists.
Parameters
build
(txn) => unknown
options?
RpcOptions & Pick<ConfigureOptions, "json" | "editTarget"> = {}
Returns
Promise<void>
compareDatastores()
compareDatastores(options): Promise<DatastoreChange[]>;Defined in: netconf/src/client-content.ts:351
How two configuration datastores differ: the changes that turn source into target, or an empty array when they hold the same configuration. Both are read with <get-config> (pipelined, with the same filter) and compared here with the server's YANG schema, so it works on any server that has both datastores, with no RFC 9144 <compare> support needed.
const changes = await client.content.compareDatastores({
source: 'running',
target: 'startup',
});
for (const c of changes) {
console.log(c.operation, c.path, c.previous, '→', c.value);
}
// replace /ietf-interfaces:interfaces/interface[name='eth0']/mtu 1500 → 9000List entries are matched by their keys and leaf-list entries by value, so one inserted entry is one create. Unlike ops.compare.datastores() (the server's own comparison, as a YANG Patch), the changes are RFC 7951 JSON with data paths, the same on every server.
Parameters
options
Returns
Promise<DatastoreChange[]>
Throws
CapabilityError (by the client's capability policy) for candidate without :candidate or startup without :startup; SchemaUnavailableError when the data can't be typed with the server's YANG schema, or a YANG data error when it doesn't match it. There is no schema-less comparison: without keys, list entries could only be matched by position.
configure()
Call Signature
configure(build, options): Promise<PendingCommit | undefined>;Defined in: netconf/src/client-content.ts:406
Make configuration changes in one <edit-config>, applied with the device's workflow: lock, edit, validate, commit, unlock. A candidate workflow with commit runs through withCandidate(): it locks running and the candidate, discards on failure, always unlocks, and rejects with a TransactionError (LockDeniedError for a held lock).
const IFS = '/ietf-interfaces:interfaces';
await client.content.configure((txn) => {
txn.set(`${IFS}/interface[name="eth0"]/description`, 'uplink');
txn.remove(`${IFS}/interface[name="eth9"]`);
});txn.merge(json) and txn.replace(json) add whole RFC 7951 JSON subtrees, converted with the edit target's YANG schema before anything is locked or sent (json options apply). A top-level node can't be edited by both a path and JSON. Options override the profile's workflow, which overrides the defaults (candidate if supported, with lock, validate and commit).
Parameters
build
(txn) => unknown
options
ConfigureOptions & object
Returns
Promise<PendingCommit | undefined>
Call Signature
configure(build, options?): Promise<void>;Defined in: netconf/src/client-content.ts:407
Make configuration changes in one <edit-config>, applied with the device's workflow: lock, edit, validate, commit, unlock. A candidate workflow with commit runs through withCandidate(): it locks running and the candidate, discards on failure, always unlocks, and rejects with a TransactionError (LockDeniedError for a held lock).
const IFS = '/ietf-interfaces:interfaces';
await client.content.configure((txn) => {
txn.set(`${IFS}/interface[name="eth0"]/description`, 'uplink');
txn.remove(`${IFS}/interface[name="eth9"]`);
});txn.merge(json) and txn.replace(json) add whole RFC 7951 JSON subtrees, converted with the edit target's YANG schema before anything is locked or sent (json options apply). A top-level node can't be edited by both a path and JSON. Options override the profile's workflow, which overrides the defaults (candidate if supported, with lock, validate and commit).
Parameters
build
(txn) => unknown
options?
Returns
Promise<void>
datastores()
datastores(options?): Promise<ServerDatastores>;Defined in: netconf/src/client-content.ts:633
The datastores the server has, from one source, never merged:
source: 'yang-library': on a server with:yang-library:1.1(NMDA, RFC 8525), its/yang-library/datastorelist, in library order, with each datastore's schema. The library is the server's complete list.source: 'capabilities': on any other server (no YANG library, or only:yang-library:1.0, whose RFC 7895 list has no datastores), and on one whose library lists none:running, thencandidatewith:candidate, thenstartupwith:startup(RFC 6241). Nothing is sent.
Capabilities are the ones after the device profile's corrections. The library read is the session's shared one (as loadModules()); later calls send nothing unless refresh is set, and a failed read rejects.
const { source, datastores } = await client.content.datastores();
datastores.some((d) => d.name === 'ietf-datastores:candidate');Parameters
options?
RpcOptions & object = {}
Returns
Promise<ServerDatastores>
expandPath()
expandPath(path): string;Defined in: netconf/src/client-content.ts:509
The YANG path a named path stands for, with its parameters filled in; any other path as given. As for a read, a parameter that is a whole predicate value may be left out, dropping its predicate; set(), remove() and configure() need every parameter. Sends nothing.
// "ifDescription":
// "/ietf-interfaces:interfaces/interface[name={{ifName}}]/description"
client.content.expandPath('@ifDescription(eth0)');
// '/ietf-interfaces:interfaces/interface[name="eth0"]/description'
client.content.expandPath('@ifDescription');
// '/ietf-interfaces:interfaces/interface/description'Parameters
path
string
Returns
string
Throws
PathError for an unknown name, or parameters that don't fit.
getCandidateChanges()
getCandidateChanges(options?): Promise<DatastoreChange[]>;Defined in: netconf/src/client-content.ts:381
What has been changed in the candidate and not yet committed: exactly compareDatastores({ source: 'running', target: 'candidate', ...options }). Another session can change either datastore between the reads, or after them; inside withCandidate(), txn.getCandidateChanges() reads them under the transaction's locks.
await client.ops.editConfig({ target: 'candidate', config });
console.log(await client.content.getCandidateChanges());Parameters
options?
Returns
Promise<DatastoreChange[]>
invoke()
Call Signature
invoke(
path,
input,
options
): Promise<XmlElement[]>;Defined in: netconf/src/client-content.ts:246
Invoke the RPC or YANG 1.1 action a path names, and resolve with its output parameters. A path of one step names an RPC (/ex:restart). A longer one names an action on that data node (/ex:servers/server[name="a"]/reset), sent as an <action> holding the ancestors and their keys (RFC 7950 §7.15.2). Paths, named paths and module resolution work as for read().
input is the input parameters: XML elements, or an RFC 7951 JSON object whose members are named as inside the operation, converted with the server's schema. The output is an RFC 7951 JSON object named the same way by default, or with format: 'xml' the output elements.
const path = '/ex:servers/server[name="a"]/reset';
// { 'finished-at': '2026-11-15T04:40:00Z' }
await client.content.invoke(path, { delay: 3 });Parameters
path
string
input
InvokeInput | undefined
options
Returns
Promise<XmlElement[]>
Throws
TypeError for a path whose last step has a predicate, or input that isn't XML or a JSON object; PathError for an unknown module.
Call Signature
invoke(
path,
input?,
options?
): Promise<YangJsonObject>;Defined in: netconf/src/client-content.ts:247
Invoke the RPC or YANG 1.1 action a path names, and resolve with its output parameters. A path of one step names an RPC (/ex:restart). A longer one names an action on that data node (/ex:servers/server[name="a"]/reset), sent as an <action> holding the ancestors and their keys (RFC 7950 §7.15.2). Paths, named paths and module resolution work as for read().
input is the input parameters: XML elements, or an RFC 7951 JSON object whose members are named as inside the operation, converted with the server's schema. The output is an RFC 7951 JSON object named the same way by default, or with format: 'xml' the output elements.
const path = '/ex:servers/server[name="a"]/reset';
// { 'finished-at': '2026-11-15T04:40:00Z' }
await client.content.invoke(path, { delay: 3 });Parameters
path
string
input?
options?
RpcOptions & ContentJsonFormat
Returns
Promise<YangJsonObject>
Throws
TypeError for a path whose last step has a predicate, or input that isn't XML or a JSON object; PathError for an unknown module.
Call Signature
invoke(
path,
input?,
options?
): Promise<
| XmlElement[]
| YangJsonObject>;Defined in: netconf/src/client-content.ts:248
Invoke the RPC or YANG 1.1 action a path names, and resolve with its output parameters. A path of one step names an RPC (/ex:restart). A longer one names an action on that data node (/ex:servers/server[name="a"]/reset), sent as an <action> holding the ancestors and their keys (RFC 7950 §7.15.2). Paths, named paths and module resolution work as for read().
input is the input parameters: XML elements, or an RFC 7951 JSON object whose members are named as inside the operation, converted with the server's schema. The output is an RFC 7951 JSON object named the same way by default, or with format: 'xml' the output elements.
const path = '/ex:servers/server[name="a"]/reset';
// { 'finished-at': '2026-11-15T04:40:00Z' }
await client.content.invoke(path, { delay: 3 });Parameters
path
string
input?
options?
Returns
Promise< | XmlElement[] | YangJsonObject>
Throws
TypeError for a path whose last step has a predicate, or input that isn't XML or a JSON object; PathError for an unknown module.
loadModules()
loadModules(options?): Promise<ReadonlyMap<string, string>>;Defined in: netconf/src/client-content.ts:608
Learn module namespaces from the server's YANG library (RFC 8525 /yang-library, or RFC 7895 /modules-state on a :yang-library:1.0 server), so paths can use modules the hello doesn't list (every YANG 1.1 module). The session reads its library once, shared with the yangLibrary extension; later calls send nothing unless refresh is set, and a failed read is tried again next time. Resolves with moduleNamespaces(): every module the session knows, the library's added, from every datastore's schema. On a server that advertises no YANG library it sends nothing.
read(), configure(), set() and remove() call this by themselves when a path names an unknown module; toXPath() and resolvePath() are synchronous, so call it first for those.
Parameters
options?
RpcOptions & object = {}
Returns
Promise<ReadonlyMap<string, string>>
moduleNamespace()
moduleNamespace(module): string | undefined;Defined in: netconf/src/client-content.ts:528
A module's namespace: from connect({ namespaces }), then the device profile's namespaces, then the server's hello, then its YANG library if the session has read it. Sends nothing; see loadModules().
A namespace belongs to its module, so one lookup serves every datastore: the library's modules come from every datastore's schema. Whether a datastore has the module is a separate question, which modules({ datastore }) answers.
Parameters
module
string
Returns
string | undefined
moduleNamespaces()
moduleNamespaces(options?): ReadonlyMap<string, string>;Defined in: netconf/src/client-content.ts:565
Every module the session knows, name → namespace, each with the namespace moduleNamespace() gives. Modules from connect({ namespaces }), the device profile and the hello come first, then the ones only the YANG library lists, once the session has read it. Sends nothing; see loadModules().
It isn't a list of one datastore's modules: the library's entries come from every datastore's schema and module set, and the other sources have no datastore. For the modules a datastore has, use modules({ datastore }).
With source, that source's whole list instead, as with moduleNamespacesInfo(): every module it names with the namespace it gives, whether or not an earlier source beats it.
client.content.moduleNamespaces().get('ietf-interfaces');
// 'urn:ietf:params:xml:ns:yang:ietf-interfaces'
client.content.moduleNamespaces({ source: 'hello' });Parameters
options?
source?
Returns
ReadonlyMap<string, string>
moduleNamespacesInfo()
moduleNamespacesInfo(options?): ReadonlyMap<string, ModuleNamespaceInfo>;Defined in: netconf/src/client-content.ts:589
moduleNamespaces(), with where each namespace came from, and the namespaces later sources gave that it overrode: what a device profile corrected in the hello, say. Sends nothing. Like moduleNamespaces(), it spans every datastore; modules({ datastore }) lists one.
With source, that source's whole list instead, in its own order: every module it names with the namespace it gives, whether or not an earlier source beats it. overrides then lists only disagreements within the source (two YANG library module sets, say). library is empty until the session has read the library; see loadModules().
client.content.moduleNamespacesInfo().get('acme-system');
// { namespace: 'urn:acme:system', source: 'profile',
// overrides: [{ source: 'hello', namespace: 'urn:acme:sys' }] }
client.content.moduleNamespacesInfo({ source: 'hello' }).get('acme-system');
// { namespace: 'urn:acme:sys', source: 'hello' }Parameters
options?
source?
Returns
ReadonlyMap<string, ModuleNamespaceInfo>
moduleOf()
moduleOf(namespace): string | undefined;Defined in: netconf/src/client-content.ts:539
The module a namespace belongs to, by the same lookup as moduleNamespace(), or undefined if no source knows it. Sends nothing. Pass it to decoders used on their own, such as decodeBaseNotification(n, { moduleOf: (ns) => client.content.moduleOf(ns) }), so the identities and paths they return name the session's modules.
Parameters
namespace
string
Returns
string | undefined
modules()
modules(options?): Promise<ServerModules>;Defined in: netconf/src/client-content.ts:663
The YANG modules the server has for one datastore (default running) or one YANG library schema, with the features it supports. From one source, never merged:
source: 'yang-library': on a server with:yang-library:1.1or:yang-library:1.0, its library. With datastores listed, the datastore's schema (or the schema named); a datastore or schema it doesn't list is rejected. Without (RFC 7895, or a 1.1 library that lists none), every module set is one schema serving every datastore.source: 'capabilities': on any other server, and on one whose library lists no modules, the module capabilities in the hello, after the device profile's corrections. Nothing is sent.
Implemented modules come first, then import-only ones. module keeps one module by name. declared: true reads and compiles each implemented module's source (the client's YANG sources: given directories, the profile, the bundled IETF modules, <get-schema>) and adds every feature it declares, with whether the server supports it.
const { modules } = await client.content.modules({ module: 'ietf-netconf' });
modules[0]?.features.includes('candidate');Parameters
options?
ModulesOptions = {}
Returns
Promise<ServerModules>
Throws
TypeError when both datastore and schema are given; SchemaUnavailableError for a datastore or schema the server doesn't list.
namedPathTemplate()
namedPathTemplate(name): NamedPathTemplate | undefined;Defined in: netconf/src/client-content.ts:514
The named path's template, compiled once.
Parameters
name
string
Returns
NamedPathTemplate | undefined
read()
Call Signature
read(path, options): Promise<XmlElement[]>;Defined in: netconf/src/client-content.ts:163
Read the nodes a YANG path selects, as RFC 7951 JSON by default.
const eth0 = '/ietf-interfaces:interfaces/interface[name="eth0"]';
await client.content.read(eth0);
// { 'ietf-interfaces:interface': [{ name: 'eth0', enabled: true, ... }] }
// a named path from the device profile
await client.content.read('@systemName');
// a named path with a parameter
await client.content.read('@interface(eth0)');
// ...left out: every interface
await client.content.read('@interface');
// the elements, as the server sent them
await client.content.read(eth0, { format: 'xml' });Parameters
path
string
options
ReadOptions & ContentXmlFormat
Returns
Promise<XmlElement[]>
The target node as RESTCONF returns it (RFC 8040): { 'module:name': value }, a list's matching entries as an array, a container as an object and a leaf as its typed value; {} if none. With format: 'xml', every matching element (an empty array if none).
Throws
SchemaUnavailableError or a YANG data error with json.requireSchema, when the data can't be typed. Its message suggests format: 'xml'.
Call Signature
read(path, options?): Promise<YangJsonObject>;Defined in: netconf/src/client-content.ts:164
Read the nodes a YANG path selects, as RFC 7951 JSON by default.
const eth0 = '/ietf-interfaces:interfaces/interface[name="eth0"]';
await client.content.read(eth0);
// { 'ietf-interfaces:interface': [{ name: 'eth0', enabled: true, ... }] }
// a named path from the device profile
await client.content.read('@systemName');
// a named path with a parameter
await client.content.read('@interface(eth0)');
// ...left out: every interface
await client.content.read('@interface');
// the elements, as the server sent them
await client.content.read(eth0, { format: 'xml' });Parameters
path
string
options?
ReadOptions & ContentJsonFormat
Returns
Promise<YangJsonObject>
The target node as RESTCONF returns it (RFC 8040): { 'module:name': value }, a list's matching entries as an array, a container as an object and a leaf as its typed value; {} if none. With format: 'xml', every matching element (an empty array if none).
Throws
SchemaUnavailableError or a YANG data error with json.requireSchema, when the data can't be typed. Its message suggests format: 'xml'.
Call Signature
read(path, options?): Promise<
| XmlElement[]
| YangJsonObject>;Defined in: netconf/src/client-content.ts:165
Read the nodes a YANG path selects, as RFC 7951 JSON by default.
const eth0 = '/ietf-interfaces:interfaces/interface[name="eth0"]';
await client.content.read(eth0);
// { 'ietf-interfaces:interface': [{ name: 'eth0', enabled: true, ... }] }
// a named path from the device profile
await client.content.read('@systemName');
// a named path with a parameter
await client.content.read('@interface(eth0)');
// ...left out: every interface
await client.content.read('@interface');
// the elements, as the server sent them
await client.content.read(eth0, { format: 'xml' });Parameters
path
string
options?
Returns
Promise< | XmlElement[] | YangJsonObject>
The target node as RESTCONF returns it (RFC 8040): { 'module:name': value }, a list's matching entries as an array, a container as an object and a leaf as its typed value; {} if none. With format: 'xml', every matching element (an empty array if none).
Throws
SchemaUnavailableError or a YANG data error with json.requireSchema, when the data can't be typed. Its message suggests format: 'xml'.
readFilter()
readFilter(path): Filter | undefined;Defined in: netconf/src/client-content.ts:198
The filter read() sends for a path or @alias, after the profile's subtreeFilter quirk: the whole path by default, trimmed to subtreeFilterDepth with 'containers', or undefined with 'unsupported' (read() then fetches the datastore and selects locally). Sends nothing.
Parameters
path
string
Returns
Filter | undefined
Throws
PathError for a malformed path or an unknown module.
readValue()
Call Signature
readValue(path, options): Promise<string | undefined>;Defined in: netconf/src/client-content.ts:214
Read the first node a path selects, or undefined if there is none: its typed RFC 7951 value by default (a number, string, boolean or [null] for a leaf, an object for a container), or with format: 'xml', its trimmed text.
const mtu = '/ietf-interfaces:interfaces/interface[name="eth0"]/mtu';
await client.content.readValue(mtu); // 1500
await client.content.readValue(mtu, { format: 'xml' }); // '1500'Parameters
path
string
options
ReadOptions & ContentXmlFormat
Returns
Promise<string | undefined>
Call Signature
readValue(path, options?): Promise<YangJsonValue | undefined>;Defined in: netconf/src/client-content.ts:215
Read the first node a path selects, or undefined if there is none: its typed RFC 7951 value by default (a number, string, boolean or [null] for a leaf, an object for a container), or with format: 'xml', its trimmed text.
const mtu = '/ietf-interfaces:interfaces/interface[name="eth0"]/mtu';
await client.content.readValue(mtu); // 1500
await client.content.readValue(mtu, { format: 'xml' }); // '1500'Parameters
path
string
options?
ReadOptions & ContentJsonFormat
Returns
Promise<YangJsonValue | undefined>
Call Signature
readValue(path, options?): Promise<YangJsonValue | undefined>;Defined in: netconf/src/client-content.ts:216
Read the first node a path selects, or undefined if there is none: its typed RFC 7951 value by default (a number, string, boolean or [null] for a leaf, an object for a container), or with format: 'xml', its trimmed text.
const mtu = '/ietf-interfaces:interfaces/interface[name="eth0"]/mtu';
await client.content.readValue(mtu); // 1500
await client.content.readValue(mtu, { format: 'xml' }); // '1500'Parameters
path
string
options?
Returns
Promise<YangJsonValue | undefined>
remove()
Call Signature
remove(path, options): Promise<PendingCommit | undefined>;Defined in: netconf/src/client-content.ts:477
Delete one node if it exists: configure((txn) => txn.remove(path), options). With confirmed, resolves with the PendingCommit.
Parameters
path
string
options
ConfigureOptions & object
Returns
Promise<PendingCommit | undefined>
Call Signature
remove(path, options?): Promise<void>;Defined in: netconf/src/client-content.ts:478
Delete one node if it exists: configure((txn) => txn.remove(path), options). With confirmed, resolves with the PendingCommit.
Parameters
path
string
options?
Returns
Promise<void>
resolvePath()
resolvePath(path): ResolvedStep[];Defined in: netconf/src/client-content.ts:489
Resolve a path or @alias against the module namespaces (see moduleNamespace()). Sends nothing. A named path's parameters are filled in as for a read (see expandPath()).
Parameters
path
string
Returns
ResolvedStep[]
Throws
PathError for a malformed path or an unknown module.
set()
Call Signature
set(
path,
value,
options
): Promise<PendingCommit | undefined>;Defined in: netconf/src/client-content.ts:470
Set one value: configure((txn) => txn.set(path, value), options). With confirmed, resolves with the PendingCommit.
Parameters
path
string
value
options
ConfigureOptions & object
Returns
Promise<PendingCommit | undefined>
Call Signature
set(
path,
value,
options?
): Promise<void>;Defined in: netconf/src/client-content.ts:471
Set one value: configure((txn) => txn.set(path, value), options). With confirmed, resolves with the PendingCommit.
Parameters
path
string
value
options?
Returns
Promise<void>
toJson()
toJson(data, options?): Promise<YangJsonObject>;Defined in: netconf/src/client-content.ts:292
Convert YANG data in XML to RFC 7951 JSON, by the same rules and schemas as format: 'json': a <data> element, or any element holding YANG data nodes, such as a transaction's read, a raw RPC reply's data or a notification's content. datastore (default 'operational') picks the schema; scope gives prefixes declared above data (such as on its <rpc-reply>), for prefixes used in values.
const reply = await client.session.rpc(x('get', { xmlns: NETCONF_NS }));
const json = await client.content.toJson(reply.data!);Parameters
data
options?
ToJsonOptions = {}
Returns
Promise<YangJsonObject>
Throws
SchemaUnavailableError or a YANG data error with requireSchema.
toXml()
toXml(json, options?): Promise<XmlElement[]>;Defined in: netconf/src/client-content.ts:319
Convert RFC 7951 JSON to XML by the same rules and schemas as JSON config on edit-config: the elements an edit would send (RFC 7952 metadata ietf-netconf:operation and yang:insert becoming the edit attributes), or with filter: true, subtree-filter content. The inverse of toJson(). datastore (default 'running') picks the schema. Sends nothing but any schema reads it needs.
const config = await client.content.toXml({
'ietf-interfaces:interfaces': {
interface: [{ name: 'eth0', enabled: false }],
},
});
await client.session.rpc(
x('edit-config', { xmlns: NETCONF_NS },
x('target', x('running')),
x('config', config)),
);Parameters
json
options?
ToXmlOptions = {}
Returns
Promise<XmlElement[]>
Throws
a YANG data error when the JSON doesn't match the schema, SchemaUnavailableError with requireSchema when there is none, or TypeError when it isn't a JSON object.
toXPath()
toXPath(path): XPathFilter;Defined in: netconf/src/client-content.ts:682
The XPath for a YANG path or @alias: an instance-identifier with module names as prefixes and their namespaces, ready for anything that takes an XPath, such as an XPath filter or an RFC 5717 partial-lock select.
client.content.toXPath('/ietf-interfaces:interfaces/interface[name="eth0"]');
// xpath(
// "/ietf-interfaces:interfaces/ietf-interfaces:interface"
// + "[ietf-interfaces:name='eth0']",
// { 'ietf-interfaces': 'urn:ietf:params:xml:ns:yang:ietf-interfaces' },
// )Parameters
path
string
Returns
Throws
PathError for a malformed path or an unknown module.