use of com.thoughtworks.go.apiv7.agents.model.AgentUpdateRequest in project gocd by gocd.
the class AgentsControllerV7 method update.
public String update(Request request, Response response) {
String uuid = request.params("uuid");
AgentUpdateRequest req = fromJSON(request.body());
String hostname = req.getHostname();
String resources = req.getResources();
String environments = filterOutEnvsWhichAreAssociatedViaConfigRepo(uuid, req.getEnvironments());
TriState configState = req.getAgentConfigState();
HttpOperationResult result = new HttpOperationResult();
AgentInstance updatedAgentInstance = null;
try {
updatedAgentInstance = agentService.updateAgentAttributes(uuid, hostname, resources, environments, configState);
handleUpdateAgentResponse(updatedAgentInstance, result);
} catch (HttpException e) {
throw e;
} catch (Exception e) {
throw halt(HttpStatus.SC_INTERNAL_SERVER_ERROR, MessageJson.create(e.getMessage()));
}
return handleCreateOrUpdateResponse(request, response, updatedAgentInstance, result);
}
Aggregations