import { Observable } from 'rxjs'; import { AuthorizationManager, AuthorizationToken } from '../security/authorization-manager'; import { GatewayConnection, GatewayRequest } from './gateway-connection'; import { PowerShellCommandWithoutState } from './powershell'; /** * Node Cim output type. */ export declare enum NodeCimOutput { /** * Single instance. */ Single = 0, /** * Multiple instances. */ Multiple = 1, /** * Invoke result. */ Result = 2, /** * WQL query result. */ Query = 3 } /** * Node Request options that we use to extend the GatewayRequest interface */ export interface NodeRequestOptions { /** * Indicates that no auth failure handling should take place, however, any auth headers for this node will still be added. */ noAuth?: boolean; /** * Provides an alternative token to use for just this request */ authToken?: AuthorizationToken; /** * Authentication mechanism. */ authenticationMechanism?: 'Credssp' | 'NotSpecified'; /** * Indicates if command should run in local runspace instead of remote runspace. */ useInProcRunspace?: boolean; /** * Indicates that audit logging for this request should be made. Default is false. */ logAudit?: boolean; /** * Indicates that telemetry logging for this request should be made. Default is false. * SmeWebTelemetry will not be sent for polling PS events. */ logTelemetry?: boolean; /** * Indicates targeting to specific PowerShell endpoint. * The endpoint data is inserted to the endpoint header. */ powerShellEndpoint?: string; /** * The PowerShell command resource on JEA PowerShell endpoint. * The command object is used for auto fallback time on a CIM query. * (Only CIM query uses this property) */ powerShell?: PowerShellCommandWithoutState; /** * The parameters for instance query powershell alternative. * (Only CIM query uses this property) */ powerShellParameters?: any; /** * The PowerShell context to replace CIM call. * (Only CIM query uses this property) */ powerShellContext?: { /** * CIM output data type. */ cimOutput: NodeCimOutput; /** * CIM input parameters. */ parameters?: any; }; } /** * Extension of GatewayRequest interface for calling the Gateway Node API */ export interface NodeRequest extends GatewayRequest, NodeRequestOptions { } /** * Service request interface for gateway version 2. */ export interface ServiceRequest { /** * The service name such as "WinRest", "WinStream", "LinuxBase" and so on. */ serviceName: string; /** * The controller name such as "PowerShell", "Cim", "Ssh" and so on. */ controllerName: string; /** * The node name. */ nodeName: string; } /** * The Node Connection class for creating requests and calling the Gateway's Node API */ export declare class NodeConnection { private gateway; private authorizationManager; /** * Initializes a new instance of the GatewayService class. * * @param gateway the gateway Connection * @param authorizationManager the authorization manager. */ constructor(gateway: GatewayConnection, authorizationManager: AuthorizationManager); /** * Makes a POST call to the gateway node api * * @param serviceRequest the object of service request. * @param remained the remained Url after 'nodes/'. * @param body the body string JSON.stringfy'ed * @param request the node request object. * @remarks this API is for gateway version 2. It doesn't work on gateway version 1. */ post(serviceRequest: ServiceRequest, remained: string, body?: any, request?: NodeRequest): Observable; /** * @deprecated This API is for version 1 gateway server, use new API for version 2 gateway. * Makes a POST call to the gateway node api * * @param nodeName the name of the node to call the API for * @param relativeUrl the relative Url after "/api/nodes/" * @param body the body string JSON.stringfy'ed * @param request the node request object. */ post(nodeName: string, relativeUrl: string, body?: any, request?: NodeRequest): Observable; /** * Makes a GET call to the gateway node api * * @param serviceRequest the object of service request. * @param relativeUrl the relative Url after "/api/nodes/" * @param request the node request object. * @remarks this API is for gateway version 2. It doesn't work on gateway version 1. */ get(serviceRequest: ServiceRequest, relativeUrl: string, request?: NodeRequest): Observable; /** * @deprecated This API is for version 1 gateway server, use new API for version 2 gateway. * Makes a GET call to the gateway node api * * @param nodeName the name of the node to call the API for * @param relativeUrl the relative Url after "/api/nodes/" * @param request the node request object. */ get(nodeName: string, relativeUrl: string, request?: NodeRequest): Observable; /** * Makes a PUT call to the gateway node api * * @param serviceRequest the object of service request. * @param relativeUrl the relative Url after "/api/nodes/" * @param body the body string JSON.stringfy'ed * @param request the node request object. * @remarks this API is for gateway version 2. It doesn't work on gateway version 1. */ put(serviceRequest: ServiceRequest, relativeUrl: string, body?: string, request?: NodeRequest): Observable; /** * @deprecated This API is for version 1 gateway server, use new API for version 2 gateway. * Makes a PUT call to the gateway node api * * @param nodeName the name of the node to call the API for * @param relativeUrl the relative Url after "/api/nodes/" * @param body the body string JSON.stringfy'ed * @param request the node request object. */ put(nodeName: string, relativeUrl: string, body?: string, request?: NodeRequest): Observable; /** * Makes a PATCH call to the gateway node api * * @param serviceRequest the object of service request. * @param relativeUrl the relative Url after "/api/nodes/" * @param body the body string JSON.stringfy'ed * @param request the node request object. * @remarks this API is for gateway version 2. It doesn't work on gateway version 1. */ patch(serviceRequest: ServiceRequest, relativeUrl: string, body?: string, request?: NodeRequest): Observable; /** * @deprecated This API is for version 1 gateway server, use new API for version 2 gateway. * Makes a PATCH call to the gateway node api * * @param nodeName the name of the node to call the API for * @param relativeUrl the relative Url after "/api/nodes/" * @param body the body string JSON.stringfy'ed * @param request the node request object. */ patch(nodeName: string, relativeUrl: string, body?: string, request?: NodeRequest): Observable; /** * Makes a DELETE call to the gateway node api * * @param serviceRequest the object of service request. * @param relativeUrl the relative Url after "/api/nodes/" * @param body the body string JSON.stringfy'ed * @param request the node request object. * @remarks this API is for gateway version 2. It doesn't work on gateway version 1. */ delete(serviceRequest: ServiceRequest, relativeUrl: string, body?: string, request?: NodeRequest): Observable; /** * @deprecated This API is for version 1 gateway server, use new API for version 2 gateway. * Makes a DELETE call to the gateway node api * * @param nodeName the name of the node to call the API for * @param relativeUrl the relative Url after "/api/nodes/" * @param body the body string JSON.stringfy'ed * @param request the node request object. */ delete(nodeName: string, relativeUrl: string, body?: string, request?: NodeRequest): Observable; /** * Makes a DELETE call to the gateway node api without waiting for the response. * * @param serviceRequest the object of service request. * @param relativeUrl the relative Url after "/api/nodes/" * @param request the node request object. * @remarks this API is for gateway version 2. It doesn't work on gateway version 1. */ deleteQuick(serviceRequest: ServiceRequest, relativeUrl: string, request?: NodeRequest): void; /** * @deprecated This API is for version 1 gateway server, use new API for version 2 gateway. * Makes a DELETE call to the gateway node api without waiting for the response. * * @param nodeName the name of the node to call the API for * @param relativeUrl the relative Url after "/api/nodes/" * @param request the node request object. */ deleteQuick(nodeName: string, relativeUrl: string, request?: NodeRequest): void; /** * Persists the JEA powershell endpoint context * @param nodeName The node name * @param endpoint The powershell endpoint */ saveJeaContext(nodeName: string, endpoint: string): void; /** * Gets the JEA powershell endpoint, if it exists * @param nodeName The node name */ getJeaEndpoint(nodeName: string): string; /** * Creates service node API for Gateway V2. * * @param serviceName the name of service. * @param apiName the name of api. * @param nodeName the name of node. * @param remained the remained URL after it including option parameters. * @returns URL string. */ getServiceUrl(serviceName: string, apiName: string, nodeName: string, remained: string): string; /** * Adds default parameters to a NodeRequest * * @param method the http method to use * @param relativeUrl the relative Url after "/api/" * @param body the body string JSON.stringfy'ed * @param request the node request object to extend. */ private createNodeRequest; /** * Get node name and node url. * @param nodeOrService The node name or service request object. * @param remained The remained url. * @returns node name and node url. */ private getNodeUrl; /** * Creates a Node url * * @param nodeName the name of the node to make a call against * @param relativeUrl the relative Url after "/nodes//" */ private getNodeMappedUrl; }