redis-cloud-api-sdk
Version:
This is a client for the Redislabs Cloud API
411 lines (410 loc) • 18 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudAPISDK = void 0;
const general_1 = require("./api/general");
const subscription_1 = require("./api/subscription");
const task_1 = require("./api/task");
const database_1 = require("./api/database");
const cloud_account_1 = require("./api/cloud-account");
const api_base_1 = require("./api/api.base");
class CloudAPISDK extends api_base_1.Client {
/**
* Initializing the constructur with given custom parameters
* @param parameters The parameters we can pass you customize our sdk client
*/
constructor(parameters) {
super(parameters);
this.general = new general_1.General(this);
this.subscription = new subscription_1.Subscription(this);
this.database = new database_1.Database(this);
this.cloudAccount = new cloud_account_1.CloudAccount(this);
this.task = new task_1.Task(this);
}
/**
* Returning current account and related information
*/
getAccountInformation() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.general.getAccountInformation();
});
}
/**
* Returning a lookup list of data persistence values
*/
getDataPersistences() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.general.getDataPersistences();
});
}
/**
* Returning a lookup list of database modules supported in current account (support may differ based on subscription and database settings)
*/
getDatabaseModules() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.general.getDatabaseModules();
});
}
/**
* Returning system log information for current account
* @param limit Maximum number of items to return
* @param offset Number of items to skip
*/
getSystemLogs(limit, offset) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.general.getSystemLogs(limit, offset);
});
}
/**
* Returning a lookup list of current account’s payment methods
*/
getPaymentMethods() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.general.getPaymentMethods();
});
}
/**
* Returning a lookup list of current account's plans
* @param provider The cloud provider of the plan
*/
getPlans(provider) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.general.getPlans(provider);
});
}
/**
* Returning a lookup list of current account's regions
* @param provider The cloud provider of the plan
*/
getRegions(provider) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.general.getRegions(provider);
});
}
/* ------------------------------------------------------------------------------Subscription------------------------------------------------------------------------------*/
/**
* Returning a lookup list of current account's subscriptions
*/
getSubscriptions() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.subscription.getSubscriptions();
});
}
/**
* Creating a subscription
* @param createParameters The given parameters given for the subscription creation
*/
createSubscription(createParameters) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.subscription.createSubscription(createParameters);
});
}
/**
* Returning a subscription
* @param subscriptionId The id of the subscription
*/
getSubscription(subscriptionId) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.subscription.getSubscription(subscriptionId);
});
}
/**
* Updating a subscription
* @param subscriptionId The id of the subscription
* @param updateParameters The given update parameters to update the subscription with
*/
updateSubscription(subscriptionId, updateParameters) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.subscription.updateSubscription(subscriptionId, updateParameters);
});
}
/**
* Deleting a subscription
* @param subscriptionId The id of the subscription
*/
deleteSubscription(subscriptionId) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.subscription.deleteSubscription(subscriptionId);
});
}
/**
* Returning a lookup list of a subscription CIDR whitelists
* @param subscriptionId The id of the subscription
*/
getSubscriptionCidrWhitelist(subscriptionId) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.subscription.getSubscriptionCidrWhitelist(subscriptionId);
});
}
/**
* Updating a subscription CIDR whitelists
* @param subscriptionId The id of the subscription
* @param updateParameters The parameters to update the subscription with
*/
updateSubscriptionCidrWhitelists(subscriptionId, updateParameters) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.subscription.updateSubscriptionCidrWhitelists(subscriptionId, updateParameters);
});
}
/**
* Returning a lookup list of the subscription VPC Peerings
* @param subscriptionId The id of the subscription
*/
getVpcPeerings(subscriptionId) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.subscription.getVpcPeerings(subscriptionId);
});
}
/**
* Creating a subscription VPC peering
* @param subscriptionId The id of the subscription
* @param createParameters The create parameters to create the VPC peering with
*/
createSubscriptionVpcPeering(subscriptionId, createParameters) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.subscription.createSubscriptionVpcPeering(subscriptionId, createParameters);
});
}
/**
* Deleting a subscription VPC peering
* @param subscriptionId The id of the subscription
* @param vpcPeeringId The id of the VPC peering
*/
deleteSubscriptionVpcPeering(subscriptionId, vpcPeeringId) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.subscription.deleteSubscriptionVpcPeering(subscriptionId, vpcPeeringId);
});
}
/* ---------------------------------------------------------------------------------Database---------------------------------------------------------------------------------*/
/**
* Returning a lookup list of databases owned by the account
* @param subscriptionId The id of the subscription
*/
getDatabases(subscriptionId) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.database.getDatabases(subscriptionId);
});
}
/**
* Creating a database
* @param subscriptionId The id of the subscription
* @param createParameters The create parameters to create the database
*/
createDatabase(subscriptionId, createParameters) {
return __awaiter(this, void 0, void 0, function* () {
return this.database.createDatabase(subscriptionId, createParameters);
});
}
/**
* Returning a database
* @param subscriptionId The id of the subscription
* @param databaseId The id of the database
*/
getDatabase(subscriptionId, databaseId) {
return __awaiter(this, void 0, void 0, function* () {
return this.database.getDatabase(subscriptionId, databaseId);
});
}
/**
* Updating a database
* @param subscriptionId The id of the subscription
* @param databaseId The id of the database
* @param updateParameters The update parameters to update the database
*/
updateDatabase(subscriptionId, databaseId, updateParameters) {
return __awaiter(this, void 0, void 0, function* () {
return this.database.updateDatabase(subscriptionId, databaseId, updateParameters);
});
}
/**
* Deleting a database
* @param subscriptionId The id of the subscription
* @param databaseId The id of the database
*/
deleteDatabase(subscriptionId, databaseId) {
return __awaiter(this, void 0, void 0, function* () {
return this.database.deleteDatabase(subscriptionId, databaseId);
});
}
/**
* Backing up a database
* @param subscriptionId The id of the subscription
* @param databaseId The id of the database
*/
backupDatabase(subscriptionId, databaseId) {
return __awaiter(this, void 0, void 0, function* () {
return this.database.backupDatabase(subscriptionId, databaseId);
});
}
/**
* Importing a dataset into a database
* @param subscriptionId The id of the subscription
* @param databaseId The id of the database
* @param importParameters The import parameters to import into a database
*/
importIntoDatabase(subscriptionId, databaseId, importParameters) {
return __awaiter(this, void 0, void 0, function* () {
return this.database.importIntoDatabase(subscriptionId, databaseId, importParameters);
});
}
/* ------------------------------------------------------------------------------Cloud-Account------------------------------------------------------------------------------*/
/**
* Returning a lookup list of cloud accounts owned by the account
*/
getCloudAccounts() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.cloudAccount.getCloudAccounts();
});
}
/**
* Returning a cloud account
* @param cloudAccountId The id of the cloud account
*/
getCloudAccount(cloudAccountId) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.cloudAccount.getCloudAccount(cloudAccountId);
});
}
/**
* Creating a cloud account
* @param createParameters The create parameters to create a cloud account
*/
createCloudAccount(createParameters) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.cloudAccount.createCloudAccount(createParameters);
});
}
/**
* Updating a cloud account
* @param cloudAccountId The id of the cloud account
* @param updateParameters The update parameters to update a cloud account
*/
updateCloudAccount(cloudAccountId, updateParameters) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.cloudAccount.updateCloudAccount(cloudAccountId, updateParameters);
});
}
/**
* Deleting a cloud account
* @param cloudAccountId The id of the cloud account
*/
deleteCloudAccount(cloudAccountId) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.cloudAccount.deleteCloudAccount(cloudAccountId);
});
}
/*------------------------------------------------------------------------------Task-------------------------------------------------------------------------------/*
/**
* Returning a lookup list of tasks owned by the account
*/
getTasks() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.task.getTasks();
});
}
/**
* Returning a task
* @param taskId The id of the task
*/
getTask(taskId) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.task.getTask(taskId);
});
}
/*--------------------------------------------------------------------------------------Helper--functions-----------------------------------------------------------------------------------*/
/**
* Waiting for the subscription status to change to a given status
* @param subscriptionId The id of the subscription
* @param expectedStatus The expected status
* @param timeoutInSeconds The timeout of waiting for the status. Default: 20 minutes
* @param sleepTimeInSeconds The sleep time between requests. Default: 5 seconds
*/
waitForSubscriptionStatus(subscriptionId, expectedStatus, timeoutInSeconds = 20 * 60, sleepTimeInSeconds = 5) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.subscription.waitForSubscriptionStatus(subscriptionId, expectedStatus, timeoutInSeconds, sleepTimeInSeconds);
});
}
/**
* Waiting for existing subscriptions statuses to change to a given status
* @param expectedStatus The expected status
* @param timeoutInSeconds The timeout of waiting for the status. Default: 20 minutes
* @param sleepTimeInSeconds The sleep time between requests. Default: 5 seconds
* @returns A batch of subscription responses
*/
waitForSubscriptionsStatus(expectedStatus, timeoutInSeconds = 20 * 60, sleepTimeInSeconds = 5) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.subscription.waitForSubscriptionsStatus(expectedStatus, timeoutInSeconds, sleepTimeInSeconds);
});
}
/**
* Waiting for the subscription VPC peering status to change to a given status
* @param subscriptionId The id of the subscription
* @param vpcPeeringId The id of the subscription VPC peering
* @param expectedStatus The expected status
* @param timeoutInSeconds The timeout of waiting for the status. Default: 5 minutes
* @param sleepTimeInSeconds The sleep time between requests. Default: 5 seconds
*/
waitForVpcPeeringStatus(subscriptionId, vpcPeeringId, expectedStatus, timeoutInSeconds = 5 * 60, sleepTimeInSeconds = 5) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.subscription.waitForVpcPeeringStatus(subscriptionId, vpcPeeringId, expectedStatus, timeoutInSeconds, sleepTimeInSeconds);
});
}
/**
* Waiting for database status to change to a given status
* @param subscriptionId The id of the subscription
* @param databaseId The id of the database
* @param expectedStatus The expected status
* @param timeoutInSeconds The timeout of waiting for the status. Default: 5 minutes
* @param sleepTimeInSeconds The sleep time between requests. Default: 5 seconds
*/
waitForDatabaseStatus(subscriptionId, databaseId, expectedStatus, timeoutInSeconds = 5 * 60, sleepTimeInSeconds = 5) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.database.waitForDatabaseStatus(subscriptionId, databaseId, expectedStatus, timeoutInSeconds, sleepTimeInSeconds);
});
}
/**
* Waiting for all databases status under subscription to change to the expected status
* @param subscriptionId The id of the subscription
* @param expectedStatus The expected status
* @param timeoutInSeconds The timeout of waiting for the status. Default: 5 minutes
* @param sleepTimeInSeconds The sleep time between requests. Default: 5 seconds
*/
waitForSubscriptionDatabasesStatus(subscriptionId, expectedStatus = 'active', timeoutInSeconds = 5 * 60, sleepTimeInSeconds = 5) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.database.waitForSubscriptionDatabasesStatus(subscriptionId, expectedStatus, timeoutInSeconds, sleepTimeInSeconds);
});
}
/**
* Waiting for cloud account status to change to a given status
* @param cloudAccountId The id of the cloud account
* @param expectedStatus The expected status
* @param timeoutInSeconds The timeout of waiting for the status. Default: 5 minutes
* @param sleepTimeInSeconds The sleep time between requests. Default: 5 seconds
*/
waitForCloudAccountStatus(cloudAccountId, expectedStatus, timeoutInSeconds = 5 * 60, sleepTimeInSeconds = 5) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.cloudAccount.waitForCloudAccountStatus(cloudAccountId, expectedStatus, timeoutInSeconds, sleepTimeInSeconds);
});
}
/**
* Waiting for task status to change to a given status
* @param taskId The id of the task
* @param expectedStatus The expected status
* @param timeoutInSeconds The timeout of waiting for the status. Default: 20 minutes
* @param sleepTimeInSeconds The sleep time between requests. Default: 5 seconds
*/
waitForTaskStatus(taskId, expectedStatus, timeoutInSeconds = 20 * 60, sleepTimeInSeconds = 5) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.task.waitForTaskStatus(taskId, expectedStatus, timeoutInSeconds, sleepTimeInSeconds);
});
}
}
exports.CloudAPISDK = CloudAPISDK;