Search in sources :

Example 21 with Summary

use of com.linkedin.pinot.common.restlet.swagger.Summary in project pinot by linkedin.

the class PinotInstanceRestletResource method addInstance.

@HttpVerb("post")
@Summary("Adds an instance")
@Tags({ "instance" })
@Paths({ "/instances", "/instances/" })
@Responses({ @Response(statusCode = "200", description = "The instance was created successfully"), @Response(statusCode = "409", description = "The instance already exists and no action was taken"), @Response(statusCode = "500", description = "Failed to create the instance") })
private StringRepresentation addInstance(@Parameter(name = "instance", in = "body", description = "The instance to add", required = true) Instance instance) throws JSONException {
    StringRepresentation presentation;
    LOGGER.info("Instance creation request received for instance " + instance.toInstanceId());
    final PinotResourceManagerResponse resp = _pinotHelixResourceManager.addInstance(instance);
    if (resp.status == PinotResourceManagerResponse.ResponseStatus.failure) {
        setStatus(Status.CLIENT_ERROR_CONFLICT);
    }
    presentation = new StringRepresentation(resp.toJSON().toString());
    return presentation;
}
Also used : StringRepresentation(org.restlet.representation.StringRepresentation) PinotResourceManagerResponse(com.linkedin.pinot.controller.helix.core.PinotResourceManagerResponse) Summary(com.linkedin.pinot.common.restlet.swagger.Summary) HttpVerb(com.linkedin.pinot.common.restlet.swagger.HttpVerb) Paths(com.linkedin.pinot.common.restlet.swagger.Paths) Tags(com.linkedin.pinot.common.restlet.swagger.Tags) Responses(com.linkedin.pinot.common.restlet.swagger.Responses)

Example 22 with Summary

use of com.linkedin.pinot.common.restlet.swagger.Summary in project pinot by linkedin.

the class PinotInstanceRestletResource method toggleInstanceState.

/**
   *
   * @param instanceName: Name of the instance to enable/disable/drop
   * @param state: One of '{enable|disable|drop}'
   * @return StringRepresentation of state after trying to enable/disable/drop instance.
   * @throws JSONException
   */
@HttpVerb("post")
@Summary("Enable, disable or drop an instance")
@Tags({ "instance" })
@Paths({ "/instances/{instanceName}/state", "/instances/{instanceName}/state" })
@Responses({ @Response(statusCode = "200", description = "The instance state was changed successfully"), @Response(statusCode = "400", description = "The state given was not enable, disable or drop"), @Response(statusCode = "404", description = "The instance was not found") })
private StringRepresentation toggleInstanceState(@Parameter(name = "instanceName", in = "path", description = "The name of the instance for which to toggle its state", required = true) String instanceName, @Parameter(name = "state", in = "body", description = "The desired instance state, either enable, disable or drop", required = true) String state) throws JSONException {
    if (StateType.ENABLE.name().equalsIgnoreCase(state)) {
        return new StringRepresentation(_pinotHelixResourceManager.enableInstance(instanceName).toJSON().toString());
    } else if (StateType.DISABLE.name().equalsIgnoreCase(state)) {
        return new StringRepresentation(_pinotHelixResourceManager.disableInstance(instanceName).toJSON().toString());
    } else if (StateType.DROP.name().equalsIgnoreCase(state)) {
        return new StringRepresentation(_pinotHelixResourceManager.dropInstance(instanceName).toJSON().toString());
    } else {
        LOGGER.error(INVALID_INSTANCE_URI_ERROR);
        setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
        return new StringRepresentation(INVALID_INSTANCE_URI_ERROR);
    }
}
Also used : StringRepresentation(org.restlet.representation.StringRepresentation) Summary(com.linkedin.pinot.common.restlet.swagger.Summary) HttpVerb(com.linkedin.pinot.common.restlet.swagger.HttpVerb) Paths(com.linkedin.pinot.common.restlet.swagger.Paths) Tags(com.linkedin.pinot.common.restlet.swagger.Tags) Responses(com.linkedin.pinot.common.restlet.swagger.Responses)

Example 23 with Summary

use of com.linkedin.pinot.common.restlet.swagger.Summary in project pinot by linkedin.

the class PinotInstanceRestletResource method getAllInstances.

/**
   * Get all instances in the cluster
   * @return List of all instances in the cluster.
   * @throws JSONException
   */
@HttpVerb("get")
@Summary("Views all instances")
@Tags({ "instance" })
@Paths({ "/instances", "/instances/" })
@Responses({ @Response(statusCode = "200", description = "A list of instances") })
private Representation getAllInstances() throws JSONException {
    JSONObject object = new JSONObject();
    JSONArray instanceArray = new JSONArray();
    List<String> instanceNames = _pinotHelixResourceManager.getAllInstanceNames();
    for (String instanceName : instanceNames) {
        instanceArray.put(instanceName);
    }
    object.put("instances", instanceArray);
    return new StringRepresentation(object.toString());
}
Also used : JSONObject(org.json.JSONObject) StringRepresentation(org.restlet.representation.StringRepresentation) JSONArray(org.json.JSONArray) Summary(com.linkedin.pinot.common.restlet.swagger.Summary) HttpVerb(com.linkedin.pinot.common.restlet.swagger.HttpVerb) Paths(com.linkedin.pinot.common.restlet.swagger.Paths) Tags(com.linkedin.pinot.common.restlet.swagger.Tags) Responses(com.linkedin.pinot.common.restlet.swagger.Responses)

Example 24 with Summary

use of com.linkedin.pinot.common.restlet.swagger.Summary in project pinot by linkedin.

the class PinotSchemaRestletResource method getSchema.

@HttpVerb("get")
@Summary("Gets a schema")
@Tags({ "schema" })
@Paths({ "/schemas/{schemaName}", "/schemas/{schemaName}/" })
@Responses({ @Response(statusCode = "200", description = "The contents of the specified schema"), @Response(statusCode = "404", description = "The specified schema does not exist") })
private Representation getSchema(@Parameter(name = "schemaName", in = "path", description = "The name of the schema to get") String schemaName) throws IOException {
    LOGGER.info("looking for schema {}", schemaName);
    Schema schema = _pinotHelixResourceManager.getSchema(schemaName);
    if (schema == null) {
        setStatus(Status.CLIENT_ERROR_NOT_FOUND);
        return new StringRepresentation("{}");
    }
    LOGGER.info("schema string is : " + schema.getJSONSchema());
    return new StringRepresentation(schema.getJSONSchema());
}
Also used : StringRepresentation(org.restlet.representation.StringRepresentation) Schema(com.linkedin.pinot.common.data.Schema) Summary(com.linkedin.pinot.common.restlet.swagger.Summary) HttpVerb(com.linkedin.pinot.common.restlet.swagger.HttpVerb) Paths(com.linkedin.pinot.common.restlet.swagger.Paths) Tags(com.linkedin.pinot.common.restlet.swagger.Tags) Responses(com.linkedin.pinot.common.restlet.swagger.Responses)

Example 25 with Summary

use of com.linkedin.pinot.common.restlet.swagger.Summary in project pinot by linkedin.

the class PinotSchemaRestletResource method getAllSchemas.

@HttpVerb("get")
@Summary("Get a list of all schemas")
@Tags({ "schema" })
@Paths({ "/schemas", "/schemas/" })
@Responses({ @Response(statusCode = "200", description = "A list of all schemas") })
private Representation getAllSchemas() {
    List<String> schemaNames = _pinotHelixResourceManager.getSchemaNames();
    JSONArray ret = new JSONArray();
    if (schemaNames == null) {
        return new StringRepresentation(ret.toString());
    }
    for (String schema : schemaNames) {
        ret.put(schema);
    }
    return new StringRepresentation(ret.toString());
}
Also used : StringRepresentation(org.restlet.representation.StringRepresentation) JSONArray(org.json.JSONArray) Summary(com.linkedin.pinot.common.restlet.swagger.Summary) HttpVerb(com.linkedin.pinot.common.restlet.swagger.HttpVerb) Paths(com.linkedin.pinot.common.restlet.swagger.Paths) Tags(com.linkedin.pinot.common.restlet.swagger.Tags) Responses(com.linkedin.pinot.common.restlet.swagger.Responses)

Aggregations

HttpVerb (com.linkedin.pinot.common.restlet.swagger.HttpVerb)32 Paths (com.linkedin.pinot.common.restlet.swagger.Paths)32 Summary (com.linkedin.pinot.common.restlet.swagger.Summary)32 Tags (com.linkedin.pinot.common.restlet.swagger.Tags)31 StringRepresentation (org.restlet.representation.StringRepresentation)30 Responses (com.linkedin.pinot.common.restlet.swagger.Responses)14 JSONObject (org.json.JSONObject)10 JSONArray (org.json.JSONArray)9 AbstractTableConfig (com.linkedin.pinot.common.config.AbstractTableConfig)7 Schema (com.linkedin.pinot.common.data.Schema)5 PinotResourceManagerResponse (com.linkedin.pinot.controller.helix.core.PinotResourceManagerResponse)5 File (java.io.File)5 IOException (java.io.IOException)4 JSONException (org.json.JSONException)4 FileRepresentation (org.restlet.representation.FileRepresentation)3 Representation (org.restlet.representation.Representation)3 Description (com.linkedin.pinot.common.restlet.swagger.Description)2 JSONArray (com.alibaba.fastjson.JSONArray)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 OfflineTableConfig (com.linkedin.pinot.common.config.OfflineTableConfig)1