cloudcms-cli
Version:
Cloud CMS Command-Line client
94 lines (87 loc) • 3.43 kB
JavaScript
var helper = require("../../../helper");
var AbstractCommand = require("../../abstract");
class ValidateDBIndexesCommand extends AbstractCommand
{
constructor()
{
super({
"group": "db",
"name": "validate-indexes",
"description": "Validates DB indexes for a datastore",
"schema": {
"properties": [{
"name": "datastoreTypeId",
"type": "string",
"description": "Enter the data store type ID",
"required": false,
"default": "cluster",
"args": ["datastoreTypeId", "type"]
}, {
"name": "datastoreId",
"type": "string",
"description": "Enter the data store ID",
"required": false,
"default": "default",
"args": ["datastoreId", "id"]
}, {
"name": "children",
"type": "boolean",
"description": "Whether to index any child data stores as well",
"required": false,
"default": false,
"args": ["children", "c"]
}, {
"name": "force",
"type": "boolean",
"description": "Whether to force the recreation of indexes (even if they're in a good state)",
"required": false,
"default": false,
"args": ["force", "f"]
}, {
"name": "include",
"type": "string",
"description": "Comma-delimited regex string of paths to include",
"required": false,
"default": false,
"args": ["includes", "include"]
}, {
"name": "exclude",
"type": "string",
"description": "Comma-delimited regex string of paths to exclude",
"required": false,
"default": false,
"args": ["excludes", "exclude"]
}, {
"name": "username",
"type": "string",
"description": "Admin username",
"required": true,
"args": ["username", "u"]
}, {
"name": "password",
"type": "string",
"description": "Admin password",
"required": true,
"hidden": true,
"args": ["password", "p"]
}]
}
});
}
handle(options, callback)
{
// call workhorse function
var includeArray = [];
var excludeArray = [];
if (options.include) {
includeArray = options.include.split(",");
}
if (options.exclude) {
excludeArray = options.exclude.split(",");
}
helper.validateDBIndexes(options.datastoreTypeId, options.datastoreId, options.children, options.force, includeArray, excludeArray, options.username, options.password, function(err) {
callback(err);
});
}
}
module.exports = ValidateDBIndexesCommand;