use of jetbrains.buildServer.serverSide.SBuildAgent in project teamcity-rest by JetBrains.
the class AgentRequest method setAllowedRunConfigurations.
/**
* Experimental use only
*/
@PUT
@Path("/{agentLocator}/compatibilityPolicy")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Update build configuration run policy of agent matching locator.", nickname = "setBuildConfigurationRunPolicy")
public CompatibilityPolicy setAllowedRunConfigurations(@ApiParam(format = LocatorName.AGENT) @PathParam("agentLocator") String agentLocator, CompatibilityPolicy payload, @QueryParam("fields") String fields) {
final SBuildAgent agent = myAgentFinder.getItem(agentLocator);
payload.applyTo(agent, myServiceLocator);
return CompatibilityPolicy.getCompatibilityPolicy(agent, new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.serverSide.SBuildAgent in project teamcity-rest by JetBrains.
the class AgentRequest method setEnabledInfo.
@PUT
@Path("/{agentLocator}/enabledInfo")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Update the enablement status of the matching agent.", nickname = "setEnabledInfo")
public AgentEnabledInfo setEnabledInfo(@ApiParam(format = LocatorName.AGENT) @PathParam("agentLocator") String agentLocator, AgentEnabledInfo enabledInfo, @QueryParam("fields") String fields) {
final SBuildAgent agent = myAgentFinder.getItem(agentLocator);
if (enabledInfo == null)
throw new BadRequestException("No data is sent as payload.");
String commentText = enabledInfo.getCommentTextFromPosted();
Boolean value = enabledInfo.getStatusFromPosted();
if (value == null && commentText == null)
throw new BadRequestException("Neither value nor comment are provided, nothing to change");
Date switchTime = enabledInfo.getStatusSwitchTimeFromPosted(myServiceLocator);
SUser currentUser = myServiceLocator.getSingletonService(UserFinder.class).getCurrentUser();
if (switchTime == null) {
agent.setEnabled(value != null ? value : agent.isEnabled(), currentUser, Agent.getActualActionComment(commentText));
} else {
agent.setEnabled(value != null ? value : agent.isEnabled(), currentUser, Agent.getActualActionComment(commentText), switchTime.getTime());
}
return new AgentEnabledInfo(agent, new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.serverSide.SBuildAgent in project teamcity-rest by JetBrains.
the class AgentRequest method getAgentPool.
@GET
@Path("/{agentLocator}/pool")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get the agent pool of the matching agent.", nickname = "getAgentPool")
public AgentPool getAgentPool(@ApiParam(format = LocatorName.AGENT) @PathParam("agentLocator") String agentLocator, @QueryParam("fields") String fields) {
final SBuildAgent agent = myAgentFinder.getItem(agentLocator);
final jetbrains.buildServer.serverSide.agentPools.AgentPool agentPool = myAgentPoolFinder.getAgentPool(agent);
return agentPool == null ? null : new AgentPool(agentPool, new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.serverSide.SBuildAgent in project teamcity-rest by JetBrains.
the class AgentRequest method deleteAgent.
@DELETE
@Path("/{agentLocator}")
@ApiOperation(value = "Delete an inactive agent.", nickname = "deleteAgent")
public void deleteAgent(@ApiParam(format = LocatorName.AGENT) @PathParam("agentLocator") String agentLocator) {
final SBuildAgent agent = myAgentFinder.getItem(agentLocator);
myServiceLocator.getSingletonService(BuildAgentManager.class).removeAgent(agent, myServiceLocator.getSingletonService(UserFinder.class).getCurrentUser());
}
use of jetbrains.buildServer.serverSide.SBuildAgent in project teamcity-rest by JetBrains.
the class Agents method init.
private void init(@Nullable final Collection<SBuildAgent> agentObjects, @Nullable final PagerData pagerData, @NotNull final Fields fields, @NotNull final BeanContext beanContext) {
if (agentObjects != null) {
agents = ValueWithDefault.decideDefault(fields.isIncluded(AGENT, false, true), new ValueWithDefault.Value<List<Agent>>() {
@Nullable
public List<Agent> get() {
final ArrayList<Agent> items = new ArrayList<Agent>(agentObjects.size());
Fields agentFields = fields.getNestedField(AGENT);
for (SBuildAgent item : agentObjects) {
items.add(new Agent(item, agentFields, beanContext));
}
return items;
}
});
count = ValueWithDefault.decideIncludeByDefault(fields.isIncluded(COUNT), agentObjects.size());
}
if (pagerData != null) {
href = ValueWithDefault.decideDefault(fields.isIncluded("href", true), beanContext.getApiUrlBuilder().transformRelativePath(pagerData.getHref()));
nextHref = ValueWithDefault.decideDefault(fields.isIncluded("nextHref"), pagerData.getNextHref() != null ? beanContext.getApiUrlBuilder().transformRelativePath(pagerData.getNextHref()) : null);
prevHref = ValueWithDefault.decideDefault(fields.isIncluded("prevHref"), pagerData.getPrevHref() != null ? beanContext.getApiUrlBuilder().transformRelativePath(pagerData.getPrevHref()) : null);
}
}
Aggregations