f5-conx-core
Version:
F5 SDK for JavaScript with Typescript type definitions
214 lines (213 loc) • 6.86 kB
TypeScript
/**
* Copyright 2021 F5 Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// <reference types="node" />
/// <reference types="node" />
import { EventEmitter } from 'events';
import { AxiosInstance } from 'axios';
import { F5DownLoad, F5Upload, F5InfoApi } from './bigipModels';
import { uuidAxiosRequestConfig, AxiosResponseWithTimings } from "../utils/httpModels";
import { Ntoken } from './nextModels';
/**
* F5 connectivity mgmt client
*
* @param host
* @param user
* @param password
* @param options.port (default = 443)
* @param options.provider (default = tmos)
*
*/
export declare class NextMgmtClient {
/**
* hostname or IP address of F5 device
*/
host: string;
/**
* tcp port for mgmt connectivity (default=443)
*/
port: number;
/**
* F5 Device host information api output from
*
* '/mgmt/shared/identified-devices/config/device-info'
*
* Used to understand details of connected device
*/
hostInfo: F5InfoApi | undefined;
/**
* event emitter instance for all events related to this class
*
* typically passed in from parent F5Client class
*/
events: EventEmitter;
/**
* custom axsios instance for making calls to the connect F5 device
*
* managed authentication/token
*/
axios: AxiosInstance;
/**
* username for connected f5 device
*/
user: string;
/**
* password for connected device
*/
password: string;
/**
* authentication provider for connected device
*/
provider: string;
/**
* new token
*/
token: Ntoken | undefined;
/**
* token timer value
*
* Starts when a token is refreshed, start value is token time out
*
* An asyncronous timer counts down till zero
*
*/
tokenTimeout: number | undefined;
/**
* system interval id for the async token timer
*
* **pre-emptivly clears token at <10 seconds but keeps counting to zero**
*/
tokenIntervalId: NodeJS.Timeout | undefined;
/**
* reject self signed certs
*
* looks for process.env.F5_CONX_CORE_REJECT_UNAUTORIZED = false/true
*/
rejectUnauthorized: boolean;
/**
* TEEM environment variable definition
*
* ex. process.env.F5_VSCODE_TEEM=true
*/
teemEnv: string | undefined;
/**
* TEEM agent string software/version
*
* ex. vscode-f5/3.2.0
*/
teemAgent: string | undefined;
/**
* ENV name for cookies to be added to outbound http requests, used for connecting to lab environments like UDF
*
* ex. process.env.F5_CONX_CORE_COOKIES = "udf.sid=s:9Wkdfer8CFsoo1VFnOTSKAenbpHJwDMt.lsI+Du9vw2BOBS+afDlSzz5CkC2fAFuL1w31QeEz94w; Domain=.udf.f5.com; Path=/"
*
* pretty sure just the udf.sig cookie is needed for udf, but the example shows how to do multiple cookies if needed
*/
cookies: string;
authEndpoint: string;
/**
* @param options function options
*/
constructor(host: string, user: string, password: string, options?: {
port?: number;
provider?: string;
}, eventEmitter?: EventEmitter, teemEnv?: string, teemAgent?: string);
/**
*
* @return event emitter instance
*/
getEvenEmitter(): EventEmitter;
/**
* clear auth token and timer
* - used for logging out/disconnecting, and testing
*/
clearToken(): Promise<number>;
/**
* creates the axios instance that will be used for all f5 calls
*
* includes auth/token management
*/
private createAxiosInstance;
/**
* sets/gets/refreshes auth token
*/
private getToken;
/**
* Make HTTP request
*
* @param uri request URI
* @param options axios options
*
* @returns request response
*/
makeRequest(uri: string, options?: uuidAxiosRequestConfig): Promise<AxiosResponseWithTimings>;
/**
* bigip auth token lifetime countdown
* will clear auth token details when finished
* prompting the next http call to get a new token
*/
private tokenTimer;
followAsync(url: string): Promise<AxiosResponseWithTimings>;
/**
* download file (multi-part) from f5 (ucs/qkview/iso)
* - UCS
* - uri: /mgmt/shared/file-transfer/ucs-downloads/${fileName}
* - path: /var/local/ucs/${fileName}
* - QKVIEW
* - uri: /mgmt/cm/autodeploy/qkview-downloads/${fileName}
* - path: /var/tmp/${fileName}
* - ISO
* - uri: /mgmt/cm/autodeploy/software-image-downloads/${fileName}
* - path: /shared/images/${fileName}
*
* **I don't think any of the f5 download paths support non-multipart**
*
* https://support.f5.com/csp/article/K41763344
*
* @param fileName file name on bigip
* @param localDestPathFile where to put the file (including file name)
* @param downloadType: type F5DownLoad = "UCS" | "QKVIEW" | "ISO"
* **expand/update return value**
*/
download(fileName: string, localDestPath: string, downloadType: F5DownLoad): Promise<AxiosResponseWithTimings>;
/**
* upload file to f5 -> used for ucs/ilx-rpms/.conf-merges
*
* types of F5 uploads
* - FILE
* - uri: '/mgmt/shared/file-transfer/uploads'
* - path: '/var/config/rest/downloads'
* - ISO
* - uri: '/mgmt/cm/autodeploy/software-image-uploads'
* - path: '/shared/images'
* - UCS
* - uri: '/mgmt/shared/file-transfer/ucs-uploads/'
* - path: '/var/local/ucs'
*
* https://devcentral.f5.com/s/articles/demystifying-icontrol-rest-part-5-transferring-files
* https://support.f5.com/csp/article/K41763344
* https://www.devcentral.f5.com/s/articles/Tinkering-with-the-BIGREST-Python-SDK-Part-2
* @param localSourcePathFilename
* @param uploadType
*/
upload(localSourcePathFilename: string, uploadType: F5Upload): Promise<AxiosResponseWithTimings>;
/**
* this funciton is used to build a filename for with all necessary host specific details
* for files like ucs/qkviews
* @returns string with `${this.hostname}_${this.host}_${cleanISOdateTime}`
* @example bigip1_10.200.244.101_20201127T220451142Z
*/
getFileName(): Promise<string>;
}