@forestvpn/forestvpn_api
Version:
A package to interact api.forestvpn.com (manage vpn profiles, check usage statistics, manage locations, ...)
215 lines (204 loc) • 9.6 kB
text/typescript
/* tslint:disable */
/* eslint-disable */
/**
* ForestVPN API
* ForestVPN - Fast, secure, and modern VPN. It offers Distributed Computing, Crypto Mining, P2P, Ad Blocking, TOR over VPN, 30+ locations, and a free version with unlimited data.
*
* OpenAPI spec version: 2.0
* Contact: support@forestvpn.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import globalAxios, { AxiosResponse, AxiosInstance, AxiosRequestConfig } from 'axios';
import { Configuration } from '../configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
import { WireGuardPeerInfo } from '../models';
/**
* WireguardApi - axios parameter creator
* @export
*/
export const WireguardApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
* @summary Wireguard peer info
* @param {string} pubKey
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getWireGuardPeerInfo: async (pubKey: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'pubKey' is not null or undefined
if (pubKey === null || pubKey === undefined) {
throw new RequiredError('pubKey','Required parameter pubKey was null or undefined when calling getWireGuardPeerInfo.');
}
const localVarPath = `/wireguard/peers/{pubKey}/`
.replace(`{${"pubKey"}}`, encodeURIComponent(String(pubKey)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions :AxiosRequestConfig = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication bearerAuth required
// http bearer authentication required
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? await configuration.accessToken()
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
}
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
/**
*
* @summary Wireguard peers list
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
listWireGuardPeers: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/wireguard/peers/`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions :AxiosRequestConfig = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication bearerAuth required
// http bearer authentication required
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? await configuration.accessToken()
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
}
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
}
};
/**
* WireguardApi - functional programming interface
* @export
*/
export const WireguardApiFp = function(configuration?: Configuration) {
return {
/**
*
* @summary Wireguard peer info
* @param {string} pubKey
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getWireGuardPeerInfo(pubKey: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<WireGuardPeerInfo>>> {
const localVarAxiosArgs = await WireguardApiAxiosParamCreator(configuration).getWireGuardPeerInfo(pubKey, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary Wireguard peers list
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async listWireGuardPeers(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<Array<WireGuardPeerInfo>>>> {
const localVarAxiosArgs = await WireguardApiAxiosParamCreator(configuration).listWireGuardPeers(options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
}
};
/**
* WireguardApi - factory interface
* @export
*/
export const WireguardApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
return {
/**
*
* @summary Wireguard peer info
* @param {string} pubKey
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async getWireGuardPeerInfo(pubKey: string, options?: AxiosRequestConfig): Promise<AxiosResponse<WireGuardPeerInfo>> {
return WireguardApiFp(configuration).getWireGuardPeerInfo(pubKey, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Wireguard peers list
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async listWireGuardPeers(options?: AxiosRequestConfig): Promise<AxiosResponse<Array<WireGuardPeerInfo>>> {
return WireguardApiFp(configuration).listWireGuardPeers(options).then((request) => request(axios, basePath));
},
};
};
/**
* WireguardApi - object-oriented interface
* @export
* @class WireguardApi
* @extends {BaseAPI}
*/
export class WireguardApi extends BaseAPI {
/**
*
* @summary Wireguard peer info
* @param {string} pubKey
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof WireguardApi
*/
public async getWireGuardPeerInfo(pubKey: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<WireGuardPeerInfo>> {
return WireguardApiFp(this.configuration).getWireGuardPeerInfo(pubKey, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary Wireguard peers list
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof WireguardApi
*/
public async listWireGuardPeers(options?: AxiosRequestConfig) : Promise<AxiosResponse<Array<WireGuardPeerInfo>>> {
return WireguardApiFp(this.configuration).listWireGuardPeers(options).then((request) => request(this.axios, this.basePath));
}
}