Search in sources :

Example 1 with AgentUpdateRequest

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);
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) NullAgentInstance(com.thoughtworks.go.domain.NullAgentInstance) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) HttpException(com.thoughtworks.go.config.exceptions.HttpException) AgentUpdateRequest(com.thoughtworks.go.apiv7.agents.model.AgentUpdateRequest) TriState(com.thoughtworks.go.util.TriState) HttpException(com.thoughtworks.go.config.exceptions.HttpException) InvalidAgentInstructionException(com.thoughtworks.go.domain.exception.InvalidAgentInstructionException) IOException(java.io.IOException)

Aggregations

AgentUpdateRequest (com.thoughtworks.go.apiv7.agents.model.AgentUpdateRequest)1 HttpException (com.thoughtworks.go.config.exceptions.HttpException)1 AgentInstance (com.thoughtworks.go.domain.AgentInstance)1 NullAgentInstance (com.thoughtworks.go.domain.NullAgentInstance)1 InvalidAgentInstructionException (com.thoughtworks.go.domain.exception.InvalidAgentInstructionException)1 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)1 TriState (com.thoughtworks.go.util.TriState)1 IOException (java.io.IOException)1