use of io.swagger.v3.oas.annotations.Hidden in project Singularity by HubSpot.
the class SandboxResource method browse.
@GET
@Path("/{taskId}/browse")
@Operation(summary = "Retrieve information about a specific task's sandbox", responses = { @ApiResponse(responseCode = "404", description = "An agent or task with the specified id was not found") })
public SingularitySandbox browse(@Parameter(hidden = true) @Auth SingularityUser user, @Parameter(required = true, description = "The task ID to browse") @PathParam("taskId") String taskId, @Parameter(required = true, description = "The path to browse from") @QueryParam("path") String path) {
authorizationHelper.checkForAuthorizationByTaskId(taskId, user, SingularityAuthorizationScope.READ);
// Remove all trailing slashes from the path
if (path != null) {
path = path.replaceAll("\\/+$", "");
}
final String currentDirectory = getCurrentDirectory(taskId, path);
final SingularityTaskHistory history = checkHistory(taskId, user);
final String hostname = history.getTask().getHostname();
final String pathToRoot = history.getDirectory().get();
final String fullPath = new File(pathToRoot, currentDirectory).toString();
final int substringTruncationLength = currentDirectory.length() == 0 ? pathToRoot.length() + 1 : pathToRoot.length() + currentDirectory.length() + 2;
try {
Collection<MesosFileObject> mesosFiles = sandboxManager.browse(hostname, fullPath);
List<SingularitySandboxFile> sandboxFiles = Lists.newArrayList(Iterables.transform(mesosFiles, new Function<MesosFileObject, SingularitySandboxFile>() {
@Override
public SingularitySandboxFile apply(MesosFileObject input) {
return new SingularitySandboxFile(input.getPath().substring(substringTruncationLength), input.getMtime(), input.getSize(), input.getMode());
}
}));
return new SingularitySandbox(sandboxFiles, pathToRoot, currentDirectory, hostname);
} catch (AgentNotFoundException snfe) {
throw notFound("Slave @ %s was not found, it is probably offline", hostname);
}
}
use of io.swagger.v3.oas.annotations.Hidden in project Singularity by HubSpot.
the class HistoryResource method getInactiveDeployTasks.
@GET
@Path("/request/{requestId}/deploy/{deployId}/tasks/inactive")
@Operation(summary = "Retrieve the task history for a specific deploy")
public List<SingularityTaskIdHistory> getInactiveDeployTasks(@Parameter(hidden = true) @Auth SingularityUser user, @Parameter(required = true, description = "Request ID for deploy") @PathParam("requestId") String requestId, @Parameter(required = true, description = "Deploy ID") @PathParam("deployId") String deployId, @Parameter(description = "Maximum number of items to return") @QueryParam("count") Integer count, @Parameter(description = "Which page of items to view") @QueryParam("page") Integer page, @Parameter(description = "Skip checking zookeeper, items that have not been persisted yet may not appear") @QueryParam("skipZk") @DefaultValue("true") boolean skipZk) {
authorizationHelper.checkForAuthorizationByRequestId(requestId, user, SingularityAuthorizationScope.READ);
final Integer limitCount = getLimitCount(count);
final Integer limitStart = getLimitStart(limitCount, page);
SingularityDeployKey key = new SingularityDeployKey(requestId, deployId);
return deployTaskHistoryHelper.getBlendedHistory(key, limitStart, limitCount, skipZk);
}
use of io.swagger.v3.oas.annotations.Hidden in project Singularity by HubSpot.
the class HistoryResource method getRequestHistoryForRequestWithMetadata.
@GET
@Path("/request/{requestId}/requests/withmetadata")
@Operation(summary = "Get request history for a single request")
public SingularityPaginatedResponse<SingularityRequestHistory> getRequestHistoryForRequestWithMetadata(@Parameter(hidden = true) @Auth SingularityUser user, @Parameter(required = true, description = "Request ID to look up") @PathParam("requestId") String requestId, @Parameter(description = "Maximum number of items to return") @QueryParam("count") Integer count, @Parameter(description = "Which page of items to view") @QueryParam("page") Integer page, @Parameter(description = "Skip checking zookeeper, items that have not been persisted yet may not appear") @QueryParam("skipZk") @DefaultValue("true") boolean skipZk) {
authorizationHelper.checkForAuthorizationByRequestId(requestId, user, SingularityAuthorizationScope.READ);
SingularityRequestHistoryQuery requestHistoryQuery = new SingularityRequestHistoryQuery(requestId, Optional.empty(), Optional.empty(), Optional.empty());
final Optional<Integer> dataCount = requestHistoryHelper.getBlendedHistoryCount(requestHistoryQuery, skipZk);
final Integer limitCount = getLimitCount(count);
final Integer limitStart = getLimitStart(limitCount, page);
final List<SingularityRequestHistory> data = requestHistoryHelper.getBlendedHistory(requestHistoryQuery, limitStart, limitCount, skipZk);
final Optional<Integer> pageCount = getPageCount(dataCount, limitCount);
return new SingularityPaginatedResponse<>(dataCount, pageCount, Optional.ofNullable(page), data);
}
use of io.swagger.v3.oas.annotations.Hidden in project Singularity by HubSpot.
the class HistoryResource method getTaskHistory.
@GET
@Path("/tasks")
@Operation(summary = "Retrieve the history sorted by startedAt for all inactive tasks")
public List<SingularityTaskIdHistory> getTaskHistory(@Parameter(hidden = true) @Auth SingularityUser user, @Parameter(description = "Optional Request ID to match") @QueryParam("requestId") Optional<String> requestId, @Parameter(description = "Optional deploy ID to match") @QueryParam("deployId") Optional<String> deployId, @Parameter(description = "Optional runId to match") @QueryParam("runId") Optional<String> runId, @Parameter(description = "Optional host to match") @QueryParam("host") Optional<String> host, @Parameter(description = "Optional last task status to match") @QueryParam("lastTaskStatus") Optional<ExtendedTaskState> lastTaskStatus, @Parameter(description = "Optionally match only tasks started before") @QueryParam("startedBefore") Optional<Long> startedBefore, @Parameter(description = "Optionally match only tasks started after") @QueryParam("startedAfter") Optional<Long> startedAfter, @Parameter(description = "Optionally match tasks last updated before") @QueryParam("updatedBefore") Optional<Long> updatedBefore, @Parameter(description = "Optionally match tasks last updated after") @QueryParam("updatedAfter") Optional<Long> updatedAfter, @Parameter(description = "Sort direction") @QueryParam("orderDirection") Optional<OrderDirection> orderDirection, @Parameter(description = "Maximum number of items to return") @QueryParam("count") Integer count, @Parameter(description = "Which page of items to view") @QueryParam("page") Integer page, @Parameter(description = "Skip checking zookeeper, items that have not been persisted yet may not appear") @QueryParam("skipZk") @DefaultValue("true") boolean skipZk) {
if (requestId.isPresent()) {
authorizationHelper.checkForAuthorizationByRequestId(requestId.get(), user, SingularityAuthorizationScope.READ);
} else {
authorizationHelper.checkGlobalReadAuthorization(user);
}
final Integer limitCount = getLimitCount(count);
final Integer limitStart = getLimitStart(limitCount, page);
return taskHistoryHelper.getBlendedHistory(new SingularityTaskHistoryQuery(requestId, deployId, runId, host, lastTaskStatus, startedBefore, startedAfter, updatedBefore, updatedAfter, orderDirection), limitStart, limitCount, skipZk);
}
use of io.swagger.v3.oas.annotations.Hidden in project Singularity by HubSpot.
the class HistoryResource method getTaskHistoryForRequest.
@GET
@Path("/request/{requestId}/tasks")
@Operation(summary = "Retrieve the history sorted by startedAt for all inactive tasks of a specific request")
public List<SingularityTaskIdHistory> getTaskHistoryForRequest(@Parameter(hidden = true) @Auth SingularityUser user, @Parameter(required = true, description = "Request ID to match") @PathParam("requestId") String requestId, @Parameter(description = "Optional deploy ID to match") @QueryParam("deployId") Optional<String> deployId, @Parameter(description = "Optional runId to match") @QueryParam("runId") Optional<String> runId, @Parameter(description = "Optional host to match") @QueryParam("host") Optional<String> host, @Parameter(description = "Optional last task status to match") @QueryParam("lastTaskStatus") Optional<ExtendedTaskState> lastTaskStatus, @Parameter(description = "Optionally match only tasks started before") @QueryParam("startedBefore") Optional<Long> startedBefore, @Parameter(description = "Optionally match only tasks started after") @QueryParam("startedAfter") Optional<Long> startedAfter, @Parameter(description = "Optionally match tasks last updated before") @QueryParam("updatedBefore") Optional<Long> updatedBefore, @Parameter(description = "Optionally match tasks last updated after") @QueryParam("updatedAfter") Optional<Long> updatedAfter, @Parameter(description = "Sort direction") @QueryParam("orderDirection") Optional<OrderDirection> orderDirection, @Parameter(description = "Maximum number of items to return") @QueryParam("count") Integer count, @Parameter(description = "Which page of items to view") @QueryParam("page") Integer page, @Parameter(description = "Skip checking zookeeper, items that have not been persisted yet may not appear") @QueryParam("skipZk") @DefaultValue("false") boolean skipZk) {
authorizationHelper.checkForAuthorizationByRequestId(requestId, user, SingularityAuthorizationScope.READ);
final Integer limitCount = getLimitCount(count);
final Integer limitStart = getLimitStart(limitCount, page);
return taskHistoryHelper.getBlendedHistory(new SingularityTaskHistoryQuery(Optional.of(requestId), deployId, runId, host, lastTaskStatus, startedBefore, startedAfter, updatedBefore, updatedAfter, orderDirection), limitStart, limitCount, skipZk);
}
Aggregations