Search in sources :

Example 11 with SBuildAgent

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);
}
Also used : SBuildAgent(jetbrains.buildServer.serverSide.SBuildAgent) ApiOperation(io.swagger.annotations.ApiOperation)

Example 12 with SBuildAgent

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);
}
Also used : Fields(jetbrains.buildServer.server.rest.model.Fields) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) SBuildAgent(jetbrains.buildServer.serverSide.SBuildAgent) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

SBuildAgent (jetbrains.buildServer.serverSide.SBuildAgent)12 ApiOperation (io.swagger.annotations.ApiOperation)10 Fields (jetbrains.buildServer.server.rest.model.Fields)9 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)3 AuthorizationFailedException (jetbrains.buildServer.server.rest.errors.AuthorizationFailedException)2 SecurityContext (jetbrains.buildServer.serverSide.auth.SecurityContext)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ServiceLocator (jetbrains.buildServer.ServiceLocator)1 CloudImage (jetbrains.buildServer.clouds.CloudImage)1 CloudManager (jetbrains.buildServer.clouds.server.CloudManager)1 PagerData (jetbrains.buildServer.server.rest.model.PagerData)1 BuildAgentManager (jetbrains.buildServer.serverSide.BuildAgentManager)1 SUser (jetbrains.buildServer.users.SUser)1 Nullable (org.jetbrains.annotations.Nullable)1