@cpanel/api
Version:
cPanel API JavaScript and TypeScript interface libraries. This library provides a set of classes for calling cPanel WHM API 1 and UAPI calls. The classes hide much of the complexity of these APIs behind classes the abstract the underlying variances betwee
91 lines (90 loc) • 2.76 kB
TypeScript
import { IMetaData } from "../metadata";
import { Response, ResponseOptions } from "../response";
/**
* This class will extract the available metadata from the WHM API format into a standard format for JavaScript developers.
*/
export declare class WhmApiMetaData implements IMetaData {
/**
* Indicates if the data is paged.
*/
isPaged: boolean;
/**
* The record number of the first record of a page.
*/
record: number;
/**
* The current page.
*/
page: number;
/**
* The page size of the returned set.
*/
pageSize: number;
/**
* The total number of records available on the backend.
*/
totalRecords: number;
/**
* The total number of pages of records on the backend.
*/
totalPages: number;
/**
* Indicates if the data set if filtered.
*/
isFiltered: boolean;
/**
* Number of records available before the filter was processed.
*/
recordsBeforeFilter: number;
/**
* Indicates the response was the result of a batch API.
*/
batch: boolean;
/**
* A collection of the other less-common or custom WHM API metadata properties.
*/
properties: {
[index: string]: any;
};
/**
* Build a new MetaData object from the metadata response from the server.
*
* @param meta WHM API metadata object.
*/
constructor(meta: any);
}
/**
* Parser that will convert a WHM API wire-formatted object into a standard response object for JavaScript developers.
*/
export declare class WhmApiResponse extends Response {
/**
* Parse out the status from the response.
*
* @param resMetadata Metadata returned in response object from the backend.
* @return Number indicating success or failure. > 1 success, 0 failure.
*/
private _parseStatus;
/**
* Parse out the messages from the response.
*
* @param resMetadata Metadata returned in response object from the backend.
*/
private _parseMessages;
/**
* WHM API 1 usually puts list data into a single-key hash.
* This isn't useful for us, so we get rid of the extra hash.
*
* @method _reduce_list_data
* @private
* @param data The "data" member of the API JSON response
* @return The reduced data object.
*/
private _reduce_list_data;
/**
* Parse out the status, data and metadata from a WHM API response into the abstract Response and IMetaData structures.
*
* @param response Raw response from the server. It's just been JSON.parse() at this point.
* @param Options On how to handle parsing of the response.
*/
constructor(response: any, options?: ResponseOptions);
}