netconf-client
Version:
267 lines • 6.42 kB
TypeScript
import { GetDataResultType, NamespaceType, NetconfType } from '../lib/index.ts';
export declare const DEFAULT_USER = "admin";
export declare const DEFAULT_PASS = "admin";
export declare const DEFAULT_PORT = 2022;
export declare const DEFAULT_XPATH = "/";
export declare enum OperationType {
/**
* Print hello message and exit
*/
HELLO = "hello",
/**
* get-data operation
*/
GET = "get",
/**
* edit-config, nc:operation="merge"
*/
MERGE = "merge",
/**
* edit-config, nc:operation="create"
*/
CREATE = "create",
/**
* edit-config, nc:operation="delete"
*/
DELETE = "delete",
/**
* edit-config, nc:operation="replace"
*/
REPLACE = "replace",
/**
* subscribe to notifications
*/
SUBSCRIBE = "subscribe",
/**
* arbitrary rpc exec
*/
RPC = "rpc"
}
/**
* Options for Get operation.
*/
type GetOptions = {
/**
* XPath filter to use for the operation
*/
xpath: string;
/**
* Request only the configuration, state or schema. If not provided, all data will be requested.
*/
configFilter?: GetDataResultType;
/**
* If true, print the full tree of the result.
* If false, strip parent nodes to simplify the output
*/
fullTree?: boolean;
/**
* Print namespaces in the result. Namespaces are sent by the server and stripped by default.
*/
showNamespaces?: boolean;
};
/**
* Options for edit-config with operation="merge".
*/
type MergeOptions = {
/**
* XPath filter to use for the operation.
* If XPath is /config/interfaces/interface[name='GigabitEthernet1/0/1']
* then the operation will be performed on the `interface` node.
*/
xpath: string;
/**
* Key-value pairs to be merged into the set
*/
values?: NetconfType;
/**
* Allow multiple schema branches to be edited in a single operation
*/
allowMultiple?: boolean;
};
type EditConfigValues = {
type: 'keyvalue';
/**
* Object of key-value pairs
*/
values: NetconfType;
} | {
type: 'list';
/**
* Array of values
*/
values: string[];
};
/**
* Options for edit-config with operation="create".
*/
type CreateOptions = {
/**
* XPath filter to use for the operation.
* If XPath is /config/interfaces/interface[name='GigabitEthernet1/0/1']
* then the `interface` node will be created with key name=GigabitEthernet1/0/1.
*/
xpath: string;
/**
* Key-value pairs to be created in the set
* or array of values to be added to the list
*/
editConfigValues: EditConfigValues;
/**
* Key to insert the new object before
*/
beforeKey?: string;
/**
* Allow multiple schema branches to be edited in a single operation
*/
allowMultiple?: boolean;
};
/**
* Options for edit-config with operation="delete".
*/
type DeleteOptions = {
/**
* XPath filter to use for the operation.
* If XPath is /config/interfaces/interface[name='GigabitEthernet1/0/1']
* then the `interface` node will be deleted.
*/
xpath: string;
/**
* Key-value pairs to be deleted from the set
* or array of values to be deleted from the list
*/
editConfigValues: EditConfigValues;
/**
* Allow multiple schema branches to be edited in a single operation
*/
allowMultiple?: boolean;
};
/**
* Options for edit-config with operation="replace".
*/
type ReplaceOptions = {
/**
* XPath filter to use for the operation.
*/
xpath: string;
/**
* Key-value pairs to be deleted from the set
* or array of values to be deleted from the list
*/
editConfigValues: EditConfigValues;
/**
* Allow multiple schema branches to be edited in a single operation
*/
allowMultiple?: boolean;
};
/**
* Options for subscription to notifications.
*/
type SubscribeOptions = {
type: 'xpath';
/**
* XPath filter to use for the operation.
*/
xpath: string;
} | {
type: 'stream';
/**
* Notification stream to use for the operation, for example "netconf".
*/
stream: string;
};
/**
* Options for RPC operation.
*/
type RpcOptions = {
/**
* Command to execute.
*/
cmd: string;
/**
* Key-value pairs to be added to the RPC request
*/
values?: NetconfType;
};
type Operation = {
type: undefined;
} | {
type: OperationType.HELLO;
} | {
type: OperationType.GET;
options: GetOptions;
} | {
type: OperationType.MERGE;
options: MergeOptions;
} | {
type: OperationType.CREATE;
options: CreateOptions;
} | {
type: OperationType.DELETE;
options: DeleteOptions;
} | {
type: OperationType.REPLACE;
options: ReplaceOptions;
} | {
type: OperationType.SUBSCRIBE;
options: SubscribeOptions;
} | {
type: OperationType.RPC;
options: RpcOptions;
};
export declare enum ResultFormat {
JSON = "json",
XML = "xml",
YAML = "yaml",
/**
* all data is printed in key=value format (nested keys are joined with a dot)
*/
KEYVALUE = "keyvalue",
/**
* all data is printed in tree format, useful for reviewing the data
*/
TREE = "tree"
}
export interface CliOptions {
/**
* Netconf host name or IP address
*/
host: string;
/**
* Netconf port number
*/
port: number;
/**
* Netconf username
*/
user: string;
/**
* Netconf password
*/
pass: string;
/**
* Operation to be performed
*/
operation: Operation;
/**
* YANG namespace to add to the request
*/
namespaces?: (string | NamespaceType)[];
/**
* Print result in the specified format
*/
resultFormat: ResultFormat;
/**
* Only read the data from the server, no edit-config or RPC operations
*/
readOnly?: boolean;
}
/**
* Parse command line arguments
*
* @returns If parsing was successful, an object with the parsed options is returned. In case when help or version
* options are provided, the function will return undefined and the program must exit with 0 (success) code.
* If parsing fails, the function will throw an error.
*/
export declare function parseArgs(): Promise<CliOptions | undefined>;
export {};
//# sourceMappingURL=parse-args.d.ts.map