use of jetbrains.buildServer.serverSide.SProject in project teamcity-rest by JetBrains.
the class AgentPoolRequest method addProject.
/**
* Adds the posted project to the pool associated projects
* @param agentPoolLocator
* @param projects
* @return
*/
@POST
@Path("/{agentPoolLocator}/projects")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Assign the project to the matching agent pool.", nickname = "addProjectToAgentPool")
public Project addProject(@ApiParam(format = LocatorName.AGENT_POOL) @PathParam("agentPoolLocator") String agentPoolLocator, Project project) {
final jetbrains.buildServer.serverSide.agentPools.AgentPool agentPool = myAgentPoolFinder.getItem(agentPoolLocator);
final AgentPoolManager agentPoolManager = myServiceLocator.getSingletonService(AgentPoolManager.class);
final int agentPoolId = agentPool.getAgentPoolId();
final SProject postedProject = project.getProjectFromPosted(myProjectFinder);
try {
agentPoolManager.associateProjectsWithPool(agentPoolId, Collections.singleton(postedProject.getProjectId()));
} catch (NoSuchAgentPoolException e) {
throw new BadRequestException("Agent pool with id \'" + agentPoolId + "' is not found.");
}
return new Project(postedProject, Fields.LONG, myBeanContext);
}
use of jetbrains.buildServer.serverSide.SProject in project teamcity-rest by JetBrains.
the class AgentPoolRequest method getPoolProject.
@GET
@Path("/{agentPoolLocator}/projects/{projectLocator}")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "getPoolProject", hidden = true)
public Project getPoolProject(@ApiParam(format = LocatorName.AGENT_POOL) @PathParam("agentPoolLocator") String agentPoolLocator, @ApiParam(format = LocatorName.PROJECT) @PathParam("projectLocator") String projectLocator, @QueryParam("fields") String fields) {
final jetbrains.buildServer.serverSide.agentPools.AgentPool agentPool = myAgentPoolFinder.getItem(agentPoolLocator);
final SProject project = myProjectFinder.getItem(projectLocator);
return new Project(project, new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.serverSide.SProject in project teamcity-rest by JetBrains.
the class ProjectAgentPoolResolver method project.
@NotNull
public Project project(@NotNull ProjectAgentPool pool, @NotNull DataFetchingEnvironment env) {
AgentPool realPool = pool.getRealPool();
if (!realPool.isProjectPool()) {
throw new RuntimeException(String.format("Pool id=%d is not a project pool.", realPool.getAgentPoolId()));
}
String projectId = ((ProjectAgentPoolImpl) realPool).getProjectId();
SProject project = myProjectManager.findProjectById(projectId);
if (project == null) {
throw new RuntimeException(String.format("ProjectAgentPool id=%d does not have a project.", realPool.getAgentPoolId()));
}
return new Project(project);
}
use of jetbrains.buildServer.serverSide.SProject in project teamcity-rest by JetBrains.
the class CloudImageResolver method project.
@NotNull
public DataFetcherResult<Project> project(@NotNull CloudImage image, @NotNull DataFetchingEnvironment env) {
String projectId = image.getRealProfile().getProjectId();
SProject project;
if (SProject.ROOT_PROJECT_ID.equals(projectId)) {
project = myProjectManager.getRootProject();
} else {
project = myProjectManager.findProjectById(projectId);
}
DataFetcherResult.Builder<Project> result = new DataFetcherResult.Builder<>();
if (project == null) {
result.error(new EntityNotFoundGraphQLError(String.format("Could not find project for instance id=%s", image.getRawId())));
} else {
result.data(new Project(project)).localContext(project);
}
return result.build();
}
use of jetbrains.buildServer.serverSide.SProject in project teamcity-rest by JetBrains.
the class ProjectResolver method projectAgentPool.
@Nullable
public ProjectAgentPool projectAgentPool(@NotNull Project source, @NotNull DataFetchingEnvironment env) {
SProject self = source.getRealProject();
AgentPool pool = myAgentPoolManager.findProjectPoolByProjectId(self.getProjectId());
if (pool == null)
return null;
return new ProjectAgentPool(pool);
}
Aggregations