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.");
}
}
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);
}
Aggregations