Search in sources :

Example 16 with Hidden

use of io.swagger.v3.oas.annotations.Hidden in project Singularity by HubSpot.

the class TaskResource method getTaskStatistics.

@GET
@Path("/task/{taskId}/statistics")
@Operation(summary = "Retrieve resource usage statistics about a specific active task", responses = { @ApiResponse(responseCode = "404", description = "A task with this id, or agent and executor with matching statistics was not found") })
public MesosTaskStatisticsObject getTaskStatistics(@Parameter(hidden = true) @Auth SingularityUser user, @Parameter(description = "Id of the task") @PathParam("taskId") String taskId) {
    SingularityTask task = checkActiveTask(taskId, SingularityAuthorizationScope.READ, user);
    String executorIdToMatch = null;
    if (task.getMesosTask().hasExecutor()) {
        executorIdToMatch = task.getMesosTask().getExecutor().getExecutorId().getValue();
    } else {
        executorIdToMatch = taskId;
    }
    for (MesosTaskMonitorObject taskMonitor : mesosClient.getSlaveResourceUsage(task.getHostname())) {
        if (taskMonitor.getExecutorId().equals(executorIdToMatch)) {
            return taskMonitor.getStatistics();
        }
    }
    throw notFound("Couldn't find executor %s for %s on agent %s", executorIdToMatch, taskId, task.getHostname());
}
Also used : SingularityTask(com.hubspot.singularity.SingularityTask) MesosTaskMonitorObject(com.hubspot.mesos.json.MesosTaskMonitorObject) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation)

Example 17 with Hidden

use of io.swagger.v3.oas.annotations.Hidden in project Singularity by HubSpot.

the class PriorityResource method deleteActivePriorityFreeze.

@DELETE
@Path("/freeze")
@Operation(summary = "Stops the active priority freeze", responses = { @ApiResponse(responseCode = "202", description = "The active priority freeze was deleted"), @ApiResponse(responseCode = "400", description = "There was no active priority freeze to delete") })
public void deleteActivePriorityFreeze(@Parameter(hidden = true) @Auth SingularityUser user) {
    authorizationHelper.checkAdminAuthorization(user);
    final SingularityDeleteResult deleteResult = priorityManager.deleteActivePriorityFreeze();
    checkBadRequest(deleteResult == SingularityDeleteResult.DELETED, "No active priority freeze to delete.");
    priorityManager.clearPriorityKill();
}
Also used : SingularityDeleteResult(com.hubspot.singularity.SingularityDeleteResult) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Operation(io.swagger.v3.oas.annotations.Operation)

Example 18 with Hidden

use of io.swagger.v3.oas.annotations.Hidden in project Singularity by HubSpot.

the class PriorityResource method createPriorityFreeze.

@POST
@Path("/freeze")
@Operation(summary = "Stop scheduling tasks below a certain priority level", responses = { @ApiResponse(responseCode = "200", description = "The priority freeze request was accepted"), @ApiResponse(responseCode = "400", description = "There was a validation error with the priority freeze request") })
public SingularityPriorityFreezeParent createPriorityFreeze(@Parameter(hidden = true) @Auth SingularityUser user, @RequestBody(description = "the new priority freeze to create") SingularityPriorityFreeze priorityFreezeRequest) {
    authorizationHelper.checkAdminAuthorization(user);
    priorityFreezeRequest = singularityValidator.checkSingularityPriorityFreeze(priorityFreezeRequest);
    final SingularityPriorityFreezeParent priorityFreezeRequestParent = new SingularityPriorityFreezeParent(priorityFreezeRequest, System.currentTimeMillis(), user.getEmail());
    priorityManager.createPriorityFreeze(priorityFreezeRequestParent);
    if (priorityFreezeRequest.isKillTasks()) {
        priorityManager.setPriorityKill();
    }
    return priorityFreezeRequestParent;
}
Also used : SingularityPriorityFreezeParent(com.hubspot.singularity.SingularityPriorityFreezeParent) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Operation(io.swagger.v3.oas.annotations.Operation)

Example 19 with Hidden

use of io.swagger.v3.oas.annotations.Hidden in project cxf by apache.

the class OpenApiCustomizedResource method getOpenApi.

@GET
@Produces({ MediaType.APPLICATION_JSON, "application/yaml" })
@Operation(hidden = true)
public Response getOpenApi(@Context ServletConfig config, @Context HttpHeaders headers, @Context UriInfo uriInfo, @PathParam("type") String type) throws Exception {
    if (customizer != null) {
        final OpenAPIConfiguration configuration = customizer.customize(getOpenApiConfiguration());
        setOpenApiConfiguration(configuration);
        // By default, the OpenApiContext instance is cached. It means that the configuration
        // changes won't be taken into account (due to the deep copying rather than reference
        // passing). In order to reflect any changes which customization may do, we have to
        // update reader's configuration directly.
        final String ctxId = ServletConfigContextUtils.getContextIdFromServletConfig(config);
        final OpenApiContext ctx = OpenApiContextLocator.getInstance().getOpenApiContext(ctxId);
        if (ctx instanceof GenericOpenApiContext<?>) {
            ((GenericOpenApiContext<?>) ctx).getOpenApiReader().setConfiguration(configuration);
            customizer.customize(ctx.read());
        }
    }
    return super.getOpenApi(headers, uriInfo, type);
}
Also used : OpenAPIConfiguration(io.swagger.v3.oas.integration.api.OpenAPIConfiguration) GenericOpenApiContext(io.swagger.v3.oas.integration.GenericOpenApiContext) GenericOpenApiContext(io.swagger.v3.oas.integration.GenericOpenApiContext) OpenApiContext(io.swagger.v3.oas.integration.api.OpenApiContext) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation)

Example 20 with Hidden

use of io.swagger.v3.oas.annotations.Hidden in project cxf by apache.

the class OpenApiCustomizedResource method getOpenApi.

@GET
@Produces({ MediaType.APPLICATION_JSON, "application/yaml" })
@Operation(hidden = true)
public Response getOpenApi(@Context Application app, @Context ServletConfig config, @Context HttpHeaders headers, @Context UriInfo uriInfo, @PathParam("type") String type) throws Exception {
    if (customizer != null) {
        final OpenAPIConfiguration configuration = customizer.customize(getOpenApiConfiguration());
        setOpenApiConfiguration(configuration);
        // By default, the OpenApiContext instance is cached. It means that the configuration
        // changes won't be taken into account (due to the deep copying rather than reference
        // passing). In order to reflect any changes which customization may do, we have to
        // update reader's configuration directly.
        OpenApiContext ctx = getOpenApiContext(config);
        if (ctx == null) {
            // If there is no context associated with the servlet config, let us
            // try to fallback to default one.
            ctx = getOpenApiContext(null);
        }
        if (ctx instanceof GenericOpenApiContext<?>) {
            ((GenericOpenApiContext<?>) ctx).getOpenApiReader().setConfiguration(configuration);
            final OpenAPI oas = ctx.read();
            customizer.customize(oas);
            if (!Objects.equals(configuration.getOpenAPI().getInfo(), oas.getInfo())) {
                configuration.getOpenAPI().setInfo(oas.getInfo());
            }
            if (!Objects.equals(configuration.getOpenAPI().getComponents(), oas.getComponents())) {
                configuration.getOpenAPI().setComponents(oas.getComponents());
            }
            if (!Objects.equals(configuration.getOpenAPI().getExternalDocs(), oas.getExternalDocs())) {
                configuration.getOpenAPI().setExternalDocs(oas.getExternalDocs());
            }
            if (!Objects.equals(configuration.getOpenAPI().getPaths(), oas.getPaths())) {
                configuration.getOpenAPI().setPaths(oas.getPaths());
            }
            if (!Objects.equals(configuration.getOpenAPI().getTags(), oas.getTags())) {
                configuration.getOpenAPI().setTags(oas.getTags());
            }
            if (!Objects.equals(configuration.getOpenAPI().getExtensions(), oas.getExtensions())) {
                configuration.getOpenAPI().setExtensions(oas.getExtensions());
            }
        }
    }
    return super.getOpenApi(headers, config, app, uriInfo, type);
}
Also used : OpenAPIConfiguration(io.swagger.v3.oas.integration.api.OpenAPIConfiguration) GenericOpenApiContext(io.swagger.v3.oas.integration.GenericOpenApiContext) OpenAPI(io.swagger.v3.oas.models.OpenAPI) GenericOpenApiContext(io.swagger.v3.oas.integration.GenericOpenApiContext) OpenApiContext(io.swagger.v3.oas.integration.api.OpenApiContext) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation)

Aggregations

Operation (io.swagger.v3.oas.annotations.Operation)29 Path (javax.ws.rs.Path)25 GET (javax.ws.rs.GET)21 POST (javax.ws.rs.POST)6 SingularityTaskHistoryQuery (com.hubspot.singularity.SingularityTaskHistoryQuery)5 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)5 List (java.util.List)4 Consumes (javax.ws.rs.Consumes)4 Produces (javax.ws.rs.Produces)4 SingularityPaginatedResponse (com.hubspot.singularity.SingularityPaginatedResponse)3 SingularityRequestWithState (com.hubspot.singularity.SingularityRequestWithState)3 SingularityTaskIdHistory (com.hubspot.singularity.SingularityTaskIdHistory)3 Schema (io.swagger.v3.oas.models.media.Schema)3 BeanDescription (com.fasterxml.jackson.databind.BeanDescription)2 AnnotatedMethod (com.fasterxml.jackson.databind.introspect.AnnotatedMethod)2 SingularityTaskHistory (com.hubspot.singularity.SingularityTaskHistory)2 Hidden (io.swagger.v3.oas.annotations.Hidden)2 GenericOpenApiContext (io.swagger.v3.oas.integration.GenericOpenApiContext)2 OpenAPIConfiguration (io.swagger.v3.oas.integration.api.OpenAPIConfiguration)2 OpenApiContext (io.swagger.v3.oas.integration.api.OpenApiContext)2