Search in sources :

Example 1 with AgentPoolPermissions

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

the class AbstractAgentPoolResolver method permissions.

@NotNull
public AgentPoolPermissions permissions(@NotNull AbstractAgentPool pool, @NotNull DataFetchingEnvironment env) {
    jetbrains.buildServer.serverSide.agentPools.AgentPool realPool = pool.getRealPool();
    int poolId = realPool.getAgentPoolId();
    AuthorityHolder authHolder = mySecurityContext.getAuthorityHolder();
    boolean canManagePool = !realPool.isProjectPool() && realPool.getAgentPoolId() != AgentPool.DEFAULT_POOL_ID && authHolder.isPermissionGrantedGlobally(Permission.MANAGE_AGENT_POOLS);
    BooleanSupplier canAuthorizeUnauthorizeAgent = () -> AuthUtil.hasPermissionToAuthorizeAgentsInPool(authHolder, realPool);
    BooleanSupplier canEnableDisableAgent = () -> AuthUtil.hasPermissionToEnableAgentsInPool(authHolder, realPool);
    BooleanSupplier canManageProjectPoolAssociations = () -> myPoolActionsAccessChecker.canManageProjectsInPool(poolId);
    BooleanSupplier canManageAgents = () -> myPoolActionsAccessChecker.canManageAgentsInPool(realPool);
    return new AgentPoolPermissions(canAuthorizeUnauthorizeAgent, canManageProjectPoolAssociations, canEnableDisableAgent, canManageAgents, canManagePool);
}
Also used : AgentPool(jetbrains.buildServer.serverSide.agentPools.AgentPool) AgentPoolPermissions(jetbrains.buildServer.server.graphql.model.agentPool.AgentPoolPermissions) AuthorityHolder(jetbrains.buildServer.serverSide.auth.AuthorityHolder) BooleanSupplier(java.util.function.BooleanSupplier) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

BooleanSupplier (java.util.function.BooleanSupplier)1 AgentPoolPermissions (jetbrains.buildServer.server.graphql.model.agentPool.AgentPoolPermissions)1 AgentPool (jetbrains.buildServer.serverSide.agentPools.AgentPool)1 AuthorityHolder (jetbrains.buildServer.serverSide.auth.AuthorityHolder)1 NotNull (org.jetbrains.annotations.NotNull)1