private void entityCommand(CommandLine commandLine)
throws FalconCLIException, IOException {
String falconUrl = getFalconEndpoint(commandLine);
FalconClient client = new FalconClient(falconUrl);
Set<String> optionsList = new HashSet<String>();
for (Option option : commandLine.getOptions()) {
optionsList.add(option.getOpt());
}
String result = null;
String entityType = commandLine.getOptionValue(ENTITY_TYPE_OPT);
String entityName = commandLine.getOptionValue(ENTITY_NAME_OPT);
String filePath = commandLine.getOptionValue(FILE_PATH_OPT);
String colo = commandLine.getOptionValue(COLO_OPT);
validateEntityType(entityType);
if (optionsList.contains(SUBMIT_OPT)) {
validateFilePath(filePath);
validateColo(optionsList);
result = client.submit(entityType, filePath);
} else if (optionsList.contains(UPDATE_OPT)) {
validateFilePath(filePath);
validateColo(optionsList);
validateEntityName(entityName);
result = client.update(entityType, entityName, filePath);
} else if (optionsList.contains(SUBMIT_AND_SCHEDULE_OPT)) {
validateFilePath(filePath);
validateColo(optionsList);
result = client.submitAndSchedule(entityType, filePath);
} else if (optionsList.contains(VALIDATE_OPT)) {
validateFilePath(filePath);
validateColo(optionsList);
result = client.validate(entityType, filePath);
} else if (optionsList.contains(SCHEDULE_OPT)) {
validateEntityName(entityName);
colo = getColo(colo);
result = client.schedule(entityType, entityName, colo);
} else if (optionsList.contains(SUSPEND_OPT)) {
validateEntityName(entityName);
colo = getColo(colo);
result = client.suspend(entityType, entityName, colo);
} else if (optionsList.contains(RESUME_OPT)) {
validateEntityName(entityName);
colo = getColo(colo);
result = client.resume(entityType, entityName, colo);
} else if (optionsList.contains(DELETE_OPT)) {
validateColo(optionsList);
validateEntityName(entityName);
result = client.delete(entityType, entityName);
} else if (optionsList.contains(STATUS_OPT)) {
validateEntityName(entityName);
colo = getColo(colo);
result = client.getStatus(entityType, entityName, colo);
} else if (optionsList.contains(DEFINITION_OPT)) {
validateColo(optionsList);
validateEntityName(entityName);
result = client.getDefinition(entityType, entityName);
} else if (optionsList.contains(DEPENDENCY_OPT)) {
validateColo(optionsList);
validateEntityName(entityName);
result = client.getDependency(entityType, entityName);
} else if (optionsList.contains(LIST_OPT)) {
validateColo(optionsList);
result = client.getEntityList(entityType);
} else if (optionsList.contains(HELP_CMD)) {
OUT.get().println("Falcon Help");
} else {
throw new FalconCLIException("Invalid command");
}