use of jetbrains.buildServer.serverSide.SBuildAgent in project teamcity-rest by JetBrains.
the class AgentRequest method setAgentField.
@PUT
@Path("/{agentLocator}/{field}")
@Consumes("text/plain")
@Produces("text/plain")
@ApiOperation(value = "Update a field of the matching agent.", nickname = "setAgentField")
public String setAgentField(@ApiParam(format = LocatorName.AGENT) @PathParam("agentLocator") String agentLocator, @PathParam("field") String fieldName, String value) {
final SBuildAgent agent = myAgentFinder.getItem(agentLocator);
Agent.setFieldValue(agent, fieldName, value, myServiceLocator);
return Agent.getFieldValue(agent, fieldName, myServiceLocator);
}
use of jetbrains.buildServer.serverSide.SBuildAgent in project teamcity-rest by JetBrains.
the class AgentRequest method setAuthorizedInfo.
@PUT
@Path("/{agentLocator}/authorizedInfo")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Update the authorization info of the matching agent.", nickname = "setAuthorizedInfo")
public AgentAuthorizedInfo setAuthorizedInfo(@ApiParam(format = LocatorName.AGENT) @PathParam("agentLocator") String agentLocator, AgentAuthorizedInfo authorizedInfo, @QueryParam("fields") String fields) {
final SBuildAgent agent = myAgentFinder.getItem(agentLocator);
if (authorizedInfo == null)
throw new BadRequestException("No data is sent as payload.");
String commentText = authorizedInfo.getCommentTextFromPosted();
Boolean value = authorizedInfo.getStatusFromPosted();
if (value == null && commentText == null)
throw new BadRequestException("Neither value nor comment are provided, nothing to change");
agent.setAuthorized(value != null ? value : agent.isAuthorized(), myServiceLocator.getSingletonService(UserFinder.class).getCurrentUser(), Agent.getActualActionComment(commentText));
return new AgentAuthorizedInfo(agent, new Fields(fields), myBeanContext);
}
Aggregations