Search in sources :

Example 1 with NoSuchAgentPoolException

use of jetbrains.buildServer.serverSide.agentPools.NoSuchAgentPoolException in project teamcity-rest by JetBrains.

the class ProjectRequest method deleteProjectAgentPools.

@DELETE
@Path("/{projectLocator}/agentPools/{agentPoolLocator}")
@ApiOperation(value = "Unassign a project from the matching agent pool.", nickname = "removeProjectFromAgentPool")
public void deleteProjectAgentPools(@ApiParam(format = LocatorName.PROJECT) @PathParam("projectLocator") String projectLocator, @PathParam("agentPoolLocator") String agentPoolLocator) {
    SProject project = myProjectFinder.getItem(projectLocator);
    final jetbrains.buildServer.serverSide.agentPools.AgentPool agentPool = myAgentPoolFinder.getItem(agentPoolLocator);
    final AgentPoolManager agentPoolManager = myServiceLocator.getSingletonService(AgentPoolManager.class);
    final int agentPoolId = agentPool.getAgentPoolId();
    try {
        agentPoolManager.dissociateProjectsFromPool(agentPoolId, singleton(project.getProjectId()));
    } catch (NoSuchAgentPoolException e) {
        throw new BadRequestException("Agent pool with id \'" + agentPoolId + "' is not found.");
    }
}
Also used : NoSuchAgentPoolException(jetbrains.buildServer.serverSide.agentPools.NoSuchAgentPoolException) AgentPoolManager(jetbrains.buildServer.serverSide.agentPools.AgentPoolManager) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with NoSuchAgentPoolException

use of jetbrains.buildServer.serverSide.agentPools.NoSuchAgentPoolException in project teamcity-rest by JetBrains.

the class ProjectRequest method setProjectAgentPools.

@POST
@Path("/{projectLocator}/agentPools")
@Produces({ "application/xml", "application/json" })
@Consumes({ "application/xml", "application/json" })
@ApiOperation(value = "Assign the matching project to the agent pool.", nickname = "addAgentPoolsProject")
public AgentPool setProjectAgentPools(@ApiParam(format = LocatorName.PROJECT) @PathParam("projectLocator") String projectLocator, AgentPool pool) {
    SProject project = myProjectFinder.getItem(projectLocator);
    final AgentPoolManager agentPoolManager = myServiceLocator.getSingletonService(AgentPoolManager.class);
    final jetbrains.buildServer.serverSide.agentPools.AgentPool agentPoolFromPosted = pool.getAgentPoolFromPosted(myAgentPoolFinder);
    final int agentPoolId = agentPoolFromPosted.getAgentPoolId();
    try {
        agentPoolManager.associateProjectsWithPool(agentPoolId, singleton(project.getProjectId()));
    } catch (NoSuchAgentPoolException e) {
        throw new BadRequestException("Agent pool with id \'" + agentPoolId + "' is not found.");
    }
    return new AgentPool(agentPoolFromPosted, Fields.LONG, myBeanContext);
}
Also used : NoSuchAgentPoolException(jetbrains.buildServer.serverSide.agentPools.NoSuchAgentPoolException) AgentPoolManager(jetbrains.buildServer.serverSide.agentPools.AgentPoolManager) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) AgentPool(jetbrains.buildServer.server.rest.model.agent.AgentPool) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)2 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)2 AgentPoolManager (jetbrains.buildServer.serverSide.agentPools.AgentPoolManager)2 NoSuchAgentPoolException (jetbrains.buildServer.serverSide.agentPools.NoSuchAgentPoolException)2 AgentPool (jetbrains.buildServer.server.rest.model.agent.AgentPool)1