use of jetbrains.buildServer.serverSide.SBuildAgent in project teamcity-rest by JetBrains.
the class CloudInstanceData method getAgent.
@Nullable
public SBuildAgent getAgent() {
CloudImage image = myInstance.getImage();
String profileId = myServiceLocator.getSingletonService(CloudInstanceFinder.class).myCloudUtil.getProfileId(image);
if (profileId == null)
return null;
Collection<SBuildAgent> agents = myServiceLocator.getSingletonService(CloudManager.class).findAgentByInstance(profileId, myInstance.getInstanceId());
return agents.size() > 0 ? agents.iterator().next() : null;
}
use of jetbrains.buildServer.serverSide.SBuildAgent in project teamcity-rest by JetBrains.
the class AgentRequest method getCompatibleBuildTypes.
/**
* Experimental support to get currently compatible build types
*/
@GET
@Path("/{agentLocator}/compatibleBuildTypes")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get build types compatible with the matching agent.", nickname = "getCompatibleBuildTypes")
public BuildTypes getCompatibleBuildTypes(@ApiParam(format = LocatorName.AGENT) @PathParam("agentLocator") String agentLocator, @QueryParam("fields") String fields) {
final SBuildAgent agent = myAgentFinder.getItem(agentLocator);
if (!AuthUtil.canViewAgentDetails(myBeanContext.getServiceLocator().getSingletonService(SecurityContext.class).getAuthorityHolder(), agent)) {
throw new AuthorizationFailedException("No permission to view agent details");
}
Fields fieldsDefinition = new Fields(Agent.COMPATIBLE_BUILD_TYPES + "(" + (StringUtil.isEmpty(fields) ? "$long" : fields) + ")");
return new Agent(agent, fieldsDefinition, myBeanContext).compatibleBuildTypes;
}
use of jetbrains.buildServer.serverSide.SBuildAgent in project teamcity-rest by JetBrains.
the class AgentRequest method serveAgents.
/**
* Returns list of agents
*
* @param includeDisconnected Deprecated, use "locator" parameter instead
* @param includeUnauthorized Deprecated, use "locator" parameter instead
* @param locator
* @return
*/
@GET
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get all known agents.", nickname = "getAllAgents")
public Agents serveAgents(@ApiParam(hidden = true) @QueryParam("includeDisconnected") Boolean includeDisconnected, @ApiParam(hidden = true) @QueryParam("includeUnauthorized") Boolean includeUnauthorized, @ApiParam(format = LocatorName.AGENT) @QueryParam("locator") String locator, @QueryParam("fields") String fields, @Context UriInfo uriInfo, @Context HttpServletRequest request) {
if (locator != null && includeDisconnected != null) {
throw new BadRequestException("Both 'includeDisconnected' URL parameter and '" + AgentFinder.CONNECTED + "' locator dimension are specified. Please use locator only.");
}
if (locator != null && includeUnauthorized != null) {
throw new BadRequestException("Both 'includeUnauthorized' URL parameter and '" + AgentFinder.AUTHORIZED + "' locator dimension are specified. Please use locator only.");
}
String locatorToUse = locator;
if (includeDisconnected != null) {
// pre-8.1 compatibility:
locatorToUse = Locator.createEmptyLocator().setDimensionIfNotPresent(AgentFinder.CONNECTED, String.valueOf(!includeDisconnected)).getStringRepresentation();
}
final Locator parsedLocator = StringUtil.isEmpty(locatorToUse) ? Locator.createEmptyLocator() : new Locator(locatorToUse);
if (includeUnauthorized != null) {
// pre-8.1 compatibility:
locatorToUse = parsedLocator.setDimensionIfNotPresent(AgentFinder.AUTHORIZED, String.valueOf(!includeUnauthorized)).getStringRepresentation();
}
final PagedSearchResult<SBuildAgent> result = myAgentFinder.getItems(locatorToUse);
final PagerData pager = new PagerData(uriInfo.getRequestUriBuilder(), request.getContextPath(), result, locatorToUse, "locator");
return new Agents(result.myEntries, pager, new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.serverSide.SBuildAgent in project teamcity-rest by JetBrains.
the class AgentRequest method setAgentPool.
@PUT
@Path("/{agentLocator}/pool")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Assign the matching agent to the specified agent pool.", nickname = "setAgentPool")
public AgentPool setAgentPool(@ApiParam(format = LocatorName.AGENT) @PathParam("agentLocator") String agentLocator, AgentPool agentPool, @QueryParam("fields") String fields) {
final SBuildAgent agent = myAgentFinder.getItem(agentLocator);
myDataProvider.addAgentToPool(agentPool.getAgentPoolFromPosted(myAgentPoolFinder), agent.getAgentTypeId());
final jetbrains.buildServer.serverSide.agentPools.AgentPool foundPool = myAgentPoolFinder.getAgentPool(agent);
return new AgentPool(foundPool, new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.serverSide.SBuildAgent in project teamcity-rest by JetBrains.
the class AgentRequest method geIncompatibleBuildTypes.
/**
* Experimental support to get currently incompatible build types with incompatibility reason
*/
@GET
@Path("/{agentLocator}/incompatibleBuildTypes")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get build types incompatible with the matching agent.", nickname = "getIncompatibleBuildTypes")
public Compatibilities geIncompatibleBuildTypes(@ApiParam(format = LocatorName.AGENT) @PathParam("agentLocator") String agentLocator, @QueryParam("fields") String fields) {
final SBuildAgent agent = myAgentFinder.getItem(agentLocator);
if (!AuthUtil.canViewAgentDetails(myBeanContext.getServiceLocator().getSingletonService(SecurityContext.class).getAuthorityHolder(), agent)) {
throw new AuthorizationFailedException("No permission to view agent details");
}
Fields fieldsDefinition = new Fields(Agent.INCOMPATIBLE_BUILD_TYPES + "(" + (StringUtil.isEmpty(fields) ? "$long" : fields) + ")");
return new Agent(agent, fieldsDefinition, myBeanContext).incompatibleBuildTypes;
}
Aggregations