use of jetbrains.buildServer.serverSide.agentTypes.SAgentType in project teamcity-rest by JetBrains.
the class AbstractAgentPoolResolver method cloudImages.
@NotNull
public AgentPoolCloudImagesConnection cloudImages(@NotNull AbstractAgentPool pool, @NotNull DataFetchingEnvironment env) {
List<Pair<CloudProfile, CloudImage>> images = new ArrayList<>();
for (SAgentType agentType : myAgentTypeFinder.getAgentTypesByPool(pool.getRealPool().getAgentPoolId())) {
if (!agentType.isCloud())
continue;
AgentTypeKey targetAgentTypeKey = agentType.getAgentTypeKey();
CloudProfile profile = myCloudManager.findProfileGloballyById(targetAgentTypeKey.getProfileId());
if (profile == null)
continue;
CloudClientEx client = myCloudManager.getClient(profile.getProjectId(), profile.getProfileId());
for (CloudImage image : client.getImages()) {
SAgentType type = myCloudManager.getDescriptionFor(profile, image.getId());
if (type == null)
continue;
if (targetAgentTypeKey.equals(type.getAgentTypeKey())) {
images.add(new Pair<>(profile, image));
break;
}
}
}
return new AgentPoolCloudImagesConnection(images, PaginationArguments.everything());
}
use of jetbrains.buildServer.serverSide.agentTypes.SAgentType in project teamcity-rest by JetBrains.
the class Build method getAgent.
@XmlElement(name = "agent")
public Agent getAgent() {
return ValueWithDefault.decideDefault(myFields.isIncluded("agent", false), () -> {
if (myBuild != null) {
if (myBuild.isAgentLessBuild())
return null;
SBuildAgent agent = myBuild.getAgent();
return new Agent(agent, myFields.getNestedField("agent"), myBeanContext);
}
if (myQueuedBuild != null) {
final AgentRestrictor agentRestrictor = myQueuedBuild.getAgentRestrictor();
if (agentRestrictor != null) {
if (agentRestrictor.getType() == AgentRestrictorType.SINGLE_AGENT) {
SBuildAgent agent = myQueuedBuild.getBuildAgent();
if (agent != null) {
return new Agent(agent, myFields.getNestedField("agent"), myBeanContext);
}
}
if (agentRestrictor.getType() == AgentRestrictorType.AGENT_POOL) {
final int agentPoolId = agentRestrictor.getId();
final AgentPool agentPool = myBeanContext.getSingletonService(AgentPoolFinder.class).getAgentPoolById(agentPoolId);
return new Agent(agentPool, myFields.getNestedField("agent"), myBeanContext);
}
if (agentRestrictor.getType() == AgentRestrictorType.CLOUD_IMAGE) {
final int agentTypeId = agentRestrictor.getId();
final SAgentType agentType = AgentFinder.getAgentType(String.valueOf(agentTypeId), myBeanContext.getSingletonService(AgentTypeFinder.class));
return new Agent(agentType, myFields.getNestedField("agent"), myBeanContext);
}
}
}
return null;
});
}
use of jetbrains.buildServer.serverSide.agentTypes.SAgentType in project teamcity-rest by JetBrains.
the class AgentFinder method getAgentType.
public static SAgentType getAgentType(@NotNull final String agentTypeLocator, @NotNull final AgentTypeFinder agentTypeFinder) {
// support only int single value for now
Integer agentTypeId = null;
try {
agentTypeId = Integer.valueOf(agentTypeLocator);
} catch (NumberFormatException e) {
throw new BadRequestException("Bad agent type id '" + agentTypeLocator + "': should be a number");
}
// make AgentFinder finding agent types in the future
SAgentType agentType = agentTypeFinder.findAgentType(agentTypeId);
if (agentType == null) {
throw new NotFoundException("No agent type is found by id '" + agentTypeId + "'");
}
return agentType;
}
Aggregations