UNPKG

netconf-client

Version:
135 lines 5.27 kB
import { Observable, Subject } from 'rxjs'; import { CreateSubscriptionRequest, HelloResult, NetconfConnectionState, NetconfParams, NetconfType, NotificationResult, RpcReply } from './netconf-types.ts'; export declare class NetconfClient { /** * Get the current connection state * * @returns {NetconfConnectionState} The current connection state */ get connectionState(): NetconfConnectionState; protected params: NetconfParams; private sshClient?; private idCounter; private xmlBuilder; private xmlParserIgnoreAttrs?; private xmlParser?; private defaultIgnoreAttrs?; /** * XML parser options */ private xmlParserOptions; /** * XML builder options */ private xmlBuilderOptions; private helloDataSubject$; /** * Subject that stores and emits the netconf channel. * The value is undefined until the channel is ready. * The value is null if the channel is closed. */ private netconfChannelSubject$?; private netconfChannel$; /** * @param {NetconfParams} params - Netconf client parameters */ constructor(params: NetconfParams); /** * Close the Netconf channel and SSH connection. */ close(): Observable<void>; /** * Observable that emits the hello message or an error */ hello(): Observable<HelloResult>; /** * Send a netconf RPC request. * * Send a request and wait for a response. The first response is emitted and the observable completes. * * @param {NetconfObjType} request - The netconf request object * @returns {Observable<NetconfData>} An observable that emits the response */ protected rpcExec(request: NetconfType, ignoreAttrs?: boolean): Observable<RpcReply>; /** * Send a request and wait for notifications. The returned observable will continue to emit * notifications as they are received. Used for subscriptions. * * @param {NetconfObjType} request - The netconf request object * @param {Observable<void>} stop$ - An observable that emits when the request should be stopped * @returns {Observable<NetconfData>} An observable that emits the response */ protected rpcStream(request: CreateSubscriptionRequest, stop$?: Subject<void>): Observable<NotificationResult | RpcReply>; protected debug(message: string, tag: string, level?: number): void; /** * Send a netconf request and return an observable that emits the response(s). * * @param {NetconfObjType} request - The netconf request object * @param {Observable<void>} stop$ - Controls the subscription behavior: * - If undefined: Single-response mode. Emits first server response and completes immediately after. * - If provided: Subscription mode. Continuously emits notifications from server and completes when stop$ emits. * @returns {Observable<NetconfData>} Server response(s): * - Single response in single-response mode * - Stream of notifications in subscription mode */ private sendRequest; private sendXml; /** * Handles the ssh ready event from the ssh lib. Event is sent by the ssh lib when the connection is ready, * but not the netconf channel yet. */ private sshReadyEvent; /** * Handles the ssh error event from the ssh lib. * * @param {Error} err - The error event */ private sshErrorEvent; /** * Handles the ssh timeout event from the ssh lib. */ private sshTimeoutEvent; /** * Handles the ssh close event. Event is sent by the ssh lib when the connection is closed. */ private sshCloseEvent; /** Clean up on error and send the error to the connection subject */ private handleError; /** * Handles the channel ready event. Event is sent by the ssh lib when the Netconf channel is ready. * * @param {Error | undefined} err - The error event * @param {ClientChannel} channel - The opened channel (Netconf) */ private channelReady; /** * Sends the hello message to the netconf server. */ private sendHello; /** * Handles the first data event from the netconf channel. * The first (or few first - depending on the number of chunks) data event is the hello message. * * @param {ClientChannel} channel - The netconf channel * @param {Buffer} chunk - The chunk of data received from the netconf channel * @param {Buffer} rcvBuffer - The buffer to store the received data * @param {Function} helloListenerRef - The reference to the wrapper data listener function */ private channelHelloEvent; private sendCloseSession; /** * Converts Netconf XML response into a NetconfType object * * @param {string} xml - XML string to parse * @return {Observable<NetconfType>} Observable that emits the object parsed from the XML */ private parseXml; /** * Checks if the rpc reply has an error and returns the error message * * @param rpcReply - The rpc reply to check * @returns The error message if there is an error, otherwise undefined */ private hasError; } //# sourceMappingURL=netconf-client.d.ts.map