Skip to content

Class: ClientOps ​

Defined in: netconf/src/client-ops.ts:85

client.ops: the Operations layer. The RFC 6241 base operations as methods, every operation the client can run as data (list, run()), the device profile's operations (device), and each enabled extension's operations under its id. Each call sends an operation and hands back XML, the reply, or a handle on what it started; an <rpc-error> rejects with an RpcError. See Operations.

Properties ​

device ​

ts
readonly device: DeviceOps;

Defined in: netconf/src/client-ops.ts:94

The device profile's own operations. Always present; without a profile, call() refuses every name.


list ​

ts
readonly list: readonly OperationDescriptor[];

Defined in: netconf/src/client-ops.ts:92

Every operation this client can run, described as plain data: the base operations (with options added by enabled extensions), then each enabled extension's own operations and reads, then the device profile's operations. Run one with run.

Methods ​

action() ​

ts
action(target, options?): Promise<RpcReply>;

Defined in: netconf/src/client-ops.ts:256

<action>: invoke a YANG 1.1 action on a data node (RFC 7950 §7.15). target is the data-node tree from the top-level node down to the action element, with list keys and the action's input inside it. It may be an RFC 7951 JSON object of that tree, converted with the server's schema (the operational datastore's). Read the action's output from the reply's output. To name the action by path and get typed output, use client.content.invoke().

ts
const reply = await client.ops.action({
  'ex:servers': { server: [{ name: 'a', reset: { delay: 3 } }] },
});
// [<finished-at>…</finished-at>]
reply.output;

Parameters ​

target ​

| XmlElement | YangJsonObject

options? ​

JsonInput & RpcOptions = {}

Returns ​

Promise<RpcReply>

Throws ​

TypeError when target isn't an XML element or a JSON object.


cancelCommit() ​

ts
cancelCommit(options?): Promise<RpcReply>;

Defined in: netconf/src/client-ops.ts:219

<cancel-commit>: cancel a pending confirmed commit, reverting to the configuration before it (:confirmed-commit:1.1). Give persistId to cancel a persistent one from another session.

Parameters ​

options? ​

object & RpcOptions = {}

Returns ​

Promise<RpcReply>


commit() ​

ts
commit(options?): Promise<RpcReply>;

Defined in: netconf/src/client-ops.ts:210

<commit>: make the candidate the running configuration (:candidate), optionally as a confirmed commit that reverts unless confirmed. See Committing the candidate and Confirmed commits.

Parameters ​

options? ​

CommitOptions & RpcOptions = {}

Returns ​

Promise<RpcReply>


copyConfig() ​

ts
copyConfig(options): Promise<RpcReply>;

Defined in: netconf/src/client-ops.ts:180

<copy-config>. Inline source: { config } may be an RFC 7951 JSON object, converted as for editConfig.

Parameters ​

options ​

CopyConfigOptions & JsonInput & RpcOptions

Returns ​

Promise<RpcReply>


deleteConfig() ​

ts
deleteConfig(target, options?): Promise<RpcReply>;

Defined in: netconf/src/client-ops.ts:186

<delete-config>: delete the startup datastore or a URL (:url). running can't be deleted.

Parameters ​

target ​

| "startup" | { url: string; }

options? ​

RpcOptions = {}

Returns ​

Promise<RpcReply>


discardChanges() ​

ts
discardChanges(options?): Promise<RpcReply>;

Defined in: netconf/src/client-ops.ts:224

<discard-changes>: reset the candidate to the running configuration (:candidate).

Parameters ​

options? ​

RpcOptions = {}

Returns ​

Promise<RpcReply>


editConfig() ​

ts
editConfig(options): Promise<RpcReply>;

Defined in: netconf/src/client-ops.ts:174

<edit-config>. config is XML, or an RFC 7951 JSON object, converted with the YANG schema of the target datastore: RFC 7952 metadata ietf-netconf:operation becomes the operation attribute, and yang:insert with yang:key or yang:value positions an entry of an ordered-by-user list. json options are never sent.

ts
await client.ops.editConfig({
  target: 'candidate',
  config: {
    'ietf-interfaces:interfaces': {
      interface: [{ name: 'eth0', description: 'uplink' }],
    },
  },
});

Parameters ​

options ​

EditConfigOptions & JsonInput & RpcOptions

Returns ​

Promise<RpcReply>

Throws ​

a YANG data error when JSON config doesn't match the schema (every problem, with its path), or SchemaUnavailableError when there is no schema and json.requireSchema is set.


get() ​

Call Signature ​

ts
get(options): Promise<YangJsonObject>;

Defined in: netconf/src/client-ops.ts:126

<get>: running configuration and state data. Resolves with the <data> element, or with format: 'json', an RFC 7951 JSON object of the data, typed by the server's YANG schema (on an NMDA server, the operational datastore's). format and json are never sent.

ts
const data = await client.ops.get({ filter, format: 'json' });
// { 'ietf-interfaces:interfaces':
//     { interface: [{ name: 'eth0', enabled: true, ... }] } }
Parameters ​
options ​

GetOptions & RpcOptions & JsonFormat

Returns ​

Promise<YangJsonObject>

Throws ​

SchemaUnavailableError or a YANG data error with format: 'json' and json.requireSchema, when the data can't be typed.

Call Signature ​

ts
get(options?): Promise<XmlElement>;

Defined in: netconf/src/client-ops.ts:127

<get>: running configuration and state data. Resolves with the <data> element, or with format: 'json', an RFC 7951 JSON object of the data, typed by the server's YANG schema (on an NMDA server, the operational datastore's). format and json are never sent.

ts
const data = await client.ops.get({ filter, format: 'json' });
// { 'ietf-interfaces:interfaces':
//     { interface: [{ name: 'eth0', enabled: true, ... }] } }
Parameters ​
options? ​

GetOptions & RpcOptions & XmlFormat

Returns ​

Promise<XmlElement>

Throws ​

SchemaUnavailableError or a YANG data error with format: 'json' and json.requireSchema, when the data can't be typed.

Call Signature ​

ts
get(options?): Promise<
  | XmlElement
| YangJsonObject>;

Defined in: netconf/src/client-ops.ts:128

<get>: running configuration and state data. Resolves with the <data> element, or with format: 'json', an RFC 7951 JSON object of the data, typed by the server's YANG schema (on an NMDA server, the operational datastore's). format and json are never sent.

ts
const data = await client.ops.get({ filter, format: 'json' });
// { 'ietf-interfaces:interfaces':
//     { interface: [{ name: 'eth0', enabled: true, ... }] } }
Parameters ​
options? ​

GetOptions & RpcOptions & FormatOptions

Returns ​

Promise< | XmlElement | YangJsonObject>

Throws ​

SchemaUnavailableError or a YANG data error with format: 'json' and json.requireSchema, when the data can't be typed.


getConfig() ​

Call Signature ​

ts
getConfig(options): Promise<YangJsonObject>;

Defined in: netconf/src/client-ops.ts:144

<get-config>: configuration from a datastore (default running). Resolves with the <data> element, or with format: 'json', an RFC 7951 JSON object of the data, typed by the server's YANG schema for that datastore. format and json are never sent.

Parameters ​
options ​

GetConfigOptions & RpcOptions & JsonFormat

Returns ​

Promise<YangJsonObject>

Throws ​

SchemaUnavailableError or a YANG data error with format: 'json' and json.requireSchema, when the data can't be typed.

Call Signature ​

ts
getConfig(options?): Promise<XmlElement>;

Defined in: netconf/src/client-ops.ts:145

<get-config>: configuration from a datastore (default running). Resolves with the <data> element, or with format: 'json', an RFC 7951 JSON object of the data, typed by the server's YANG schema for that datastore. format and json are never sent.

Parameters ​
options? ​

GetConfigOptions & RpcOptions & XmlFormat

Returns ​

Promise<XmlElement>

Throws ​

SchemaUnavailableError or a YANG data error with format: 'json' and json.requireSchema, when the data can't be typed.

Call Signature ​

ts
getConfig(options?): Promise<
  | XmlElement
| YangJsonObject>;

Defined in: netconf/src/client-ops.ts:146

<get-config>: configuration from a datastore (default running). Resolves with the <data> element, or with format: 'json', an RFC 7951 JSON object of the data, typed by the server's YANG schema for that datastore. format and json are never sent.

Parameters ​
options? ​

GetConfigOptions & RpcOptions & FormatOptions

Returns ​

Promise< | XmlElement | YangJsonObject>

Throws ​

SchemaUnavailableError or a YANG data error with format: 'json' and json.requireSchema, when the data can't be typed.


killSession() ​

ts
killSession(sessionId, options?): Promise<RpcReply>;

Defined in: netconf/src/client-ops.ts:265

Force another session to close (RFC 6241 §7.9).

Parameters ​

sessionId ​

number

options? ​

RpcOptions = {}

Returns ​

Promise<RpcReply>


lock() ​

ts
lock(target, options?): Promise<RpcReply>;

Defined in: netconf/src/client-ops.ts:195

<lock>: lock a whole datastore against changes by other sessions, until unlock or this session ends. See Locking.

Parameters ​

target ​

Datastore

options? ​

RpcOptions = {}

Returns ​

Promise<RpcReply>


run() ​

ts
run(
   name, 
   args?, 
   options?
): Promise<unknown>;

Defined in: netconf/src/client-ops.ts:285

Run any operation in list from plain arguments, keyed as in its descriptor: run('get-config', { source: 'running' }). Options added by enabled extensions apply, and capabilities are checked, just as for the matching method. close-session closes the client and resolves with undefined.

Base and extension operations resolve with the RpcReply. An extension's read (kind: 'read') runs its content method, client.content.<id>.<method>({ ...args, ...options }), and resolves with the decoded result. A device profile operation runs exactly as device.call(name, args) and resolves with what that returns (text, an element, an object or the reply), so the result is typed unknown; per-call options don't apply to it.

Parameters ​

name ​

string

args? ​

Readonly<Record<string, unknown>> = {}

options? ​

RpcOptions = {}

Returns ​

Promise<unknown>

Throws ​

TypeError for an unknown operation or argument.


unlock() ​

ts
unlock(target, options?): Promise<RpcReply>;

Defined in: netconf/src/client-ops.ts:200

<unlock>: release a lock this session holds on a datastore.

Parameters ​

target ​

Datastore

options? ​

RpcOptions = {}

Returns ​

Promise<RpcReply>


validate() ​

ts
validate(source, options?): Promise<RpcReply>;

Defined in: netconf/src/client-ops.ts:233

<validate>: check a configuration without applying it (:validate). Inline { config } may be an RFC 7951 JSON object, converted as for editConfig. See Validating.

Parameters ​

source ​

ConfigSource

options? ​

JsonInput & RpcOptions = {}

Returns ​

Promise<RpcReply>

Released under the MIT Licence.