use of com.hubspot.horizon.HttpResponse in project Singularity by HubSpot.
the class SingularityClient method getSingleWithParams.
private <T> Optional<T> getSingleWithParams(Function<String, String> hostToUrl, String type, String id, Optional<Map<String, Object>> queryParams, TypeReference<T> typeReference) {
final long start = System.currentTimeMillis();
HttpResponse response = executeGetSingleWithParams(hostToUrl, type, id, queryParams);
if (response.getStatusCode() == 404) {
return Optional.absent();
}
checkResponse(type, response);
LOG.info("Got {} {} in {}ms", type, id, System.currentTimeMillis() - start);
return Optional.fromNullable(response.getAs(typeReference));
}
use of com.hubspot.horizon.HttpResponse in project Singularity by HubSpot.
the class SingularityClient method checkAuthForRequestGroupsUpdate.
public boolean checkAuthForRequestGroupsUpdate(String requestId, SingularityUpdateGroupsRequest updateGroupsRequest) {
final Function<String, String> requestUri = (host) -> String.format(REQUEST_GROUPS_UPDATE_AUTH_CHECK_FORMAT, getApiBase(host), requestId);
final HttpResponse response = post(requestUri, String.format("check auth for update authorized groups of request %s", requestId), Optional.of(updateGroupsRequest));
return response.isSuccess();
}
use of com.hubspot.horizon.HttpResponse in project Singularity by HubSpot.
the class SingularityClient method updateIncrementalDeployInstanceCount.
public SingularityRequestParent updateIncrementalDeployInstanceCount(SingularityUpdatePendingDeployRequest updateRequest) {
final Function<String, String> requestUri = (host) -> String.format(UPDATE_DEPLOY_FORMAT, getApiBase(host));
HttpResponse response = post(requestUri, String.format("update deploy %s", new SingularityDeployKey(updateRequest.getRequestId(), updateRequest.getDeployId())), Optional.of(updateRequest));
return getAndLogRequestAndDeployStatus(response.getAs(SingularityRequestParent.class));
}
use of com.hubspot.horizon.HttpResponse in project Singularity by HubSpot.
the class SingularityClient method updateAuthorizedGroups.
public SingularityPendingRequestParent updateAuthorizedGroups(String requestId, SingularityUpdateGroupsRequest updateGroupsRequest) {
final Function<String, String> requestUri = (host) -> String.format(REQUEST_GROUPS_UPDATE_FORMAT, getApiBase(host), requestId);
final HttpResponse response = post(requestUri, String.format("update authorized groups of request %s", requestId), Optional.of(updateGroupsRequest));
return response.getAs(SingularityPendingRequestParent.class);
}
use of com.hubspot.horizon.HttpResponse in project Singularity by HubSpot.
the class SingularityClient method runSingularityRequest.
public SingularityPendingRequestParent runSingularityRequest(String requestId, Optional<SingularityRunNowRequest> runNowRequest) {
final Function<String, String> requestUri = (host) -> String.format(REQUEST_RUN_FORMAT, getApiBase(host), requestId);
final HttpResponse response = post(requestUri, String.format("run of request %s", requestId), runNowRequest);
return response.getAs(SingularityPendingRequestParent.class);
}
Aggregations