Search in sources :

Example 1 with ProjectAgentPool

use of jetbrains.buildServer.server.graphql.model.agentPool.ProjectAgentPool 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);
}
Also used : ProjectAgentPoolImpl(jetbrains.buildServer.serverSide.agentPools.ProjectAgentPoolImpl) SProject(jetbrains.buildServer.serverSide.SProject) Project(jetbrains.buildServer.server.graphql.model.Project) SProject(jetbrains.buildServer.serverSide.SProject) AgentPool(jetbrains.buildServer.serverSide.agentPools.AgentPool) ProjectAgentPool(jetbrains.buildServer.server.graphql.model.agentPool.ProjectAgentPool) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ProjectAgentPool

use of jetbrains.buildServer.server.graphql.model.agentPool.ProjectAgentPool in project teamcity-rest by JetBrains.

the class CloudImageResolver method agentPool.

@NotNull
public DataFetcherResult<AbstractAgentPool> agentPool(@NotNull CloudImage image, @NotNull DataFetchingEnvironment env) {
    DataFetcherResult.Builder<AbstractAgentPool> result = new DataFetcherResult.Builder<>();
    AgentType agentType = findAgentType(image);
    AgentPool pool = agentType != null ? myAgentPoolManager.findAgentPoolById(agentType.getAgentPoolId()) : null;
    if (agentType == null || pool == null) {
        result.error(new EntityNotFoundGraphQLError(String.format("Could not find agent pool for image id=%s in profile id=%s", image.getRawId(), image.getProfileId())));
        return result.build();
    }
    return result.data(new ProjectAgentPool(pool)).localContext(pool).build();
}
Also used : AgentType(jetbrains.buildServer.serverSide.agentTypes.AgentType) DataFetcherResult(graphql.execution.DataFetcherResult) ProjectAgentPool(jetbrains.buildServer.server.graphql.model.agentPool.ProjectAgentPool) AbstractAgentPool(jetbrains.buildServer.server.graphql.model.agentPool.AbstractAgentPool) EntityNotFoundGraphQLError(jetbrains.buildServer.server.graphql.util.EntityNotFoundGraphQLError) AbstractAgentPool(jetbrains.buildServer.server.graphql.model.agentPool.AbstractAgentPool) AgentPool(jetbrains.buildServer.serverSide.agentPools.AgentPool) ProjectAgentPool(jetbrains.buildServer.server.graphql.model.agentPool.ProjectAgentPool) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ProjectAgentPool

use of jetbrains.buildServer.server.graphql.model.agentPool.ProjectAgentPool 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);
}
Also used : ProjectAgentPool(jetbrains.buildServer.server.graphql.model.agentPool.ProjectAgentPool) SProject(jetbrains.buildServer.serverSide.SProject) AgentPool(jetbrains.buildServer.serverSide.agentPools.AgentPool) ProjectAgentPool(jetbrains.buildServer.server.graphql.model.agentPool.ProjectAgentPool) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ProjectAgentPool (jetbrains.buildServer.server.graphql.model.agentPool.ProjectAgentPool)3 AgentPool (jetbrains.buildServer.serverSide.agentPools.AgentPool)3 SProject (jetbrains.buildServer.serverSide.SProject)2 NotNull (org.jetbrains.annotations.NotNull)2 DataFetcherResult (graphql.execution.DataFetcherResult)1 Project (jetbrains.buildServer.server.graphql.model.Project)1 AbstractAgentPool (jetbrains.buildServer.server.graphql.model.agentPool.AbstractAgentPool)1 EntityNotFoundGraphQLError (jetbrains.buildServer.server.graphql.util.EntityNotFoundGraphQLError)1 ProjectAgentPoolImpl (jetbrains.buildServer.serverSide.agentPools.ProjectAgentPoolImpl)1 AgentType (jetbrains.buildServer.serverSide.agentTypes.AgentType)1 Nullable (org.jetbrains.annotations.Nullable)1