use of jetbrains.buildServer.server.rest.data.build.TagFinder in project teamcity-rest by JetBrains.
the class Build method getTags.
@XmlElement
public Tags getTags() {
return ValueWithDefault.decideDefault(myFields.isIncluded("tags", false), () -> {
final Fields fields = myFields.getNestedField("tags", Fields.NONE, Fields.LONG);
final TagFinder tagFinder = new TagFinder(myBeanContext.getSingletonService(UserFinder.class), myBuildPromotion);
return new Tags(tagFinder.getItems(fields.getLocator(), TagFinder.getDefaultLocator()).myEntries, fields, myBeanContext);
});
}
use of jetbrains.buildServer.server.rest.data.build.TagFinder in project teamcity-rest by JetBrains.
the class BuildRequest method replaceTagsOnBuild.
/**
* Replaces the build's tags designated by the tags 'locator' to the set of tags passed.
*/
@PUT
@Path("/{buildLocator}/tags/")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Update tags of the matching build.", nickname = "setBuildTags")
public Tags replaceTagsOnBuild(@ApiParam(format = LocatorName.BUILD) @PathParam("buildLocator") String buildLocator, @ApiParam(format = LocatorName.TAG) @QueryParam("locator") String tagLocator, Tags tags, @QueryParam("fields") String fields, @Context HttpServletRequest request) {
BuildPromotion build = myBuildFinder.getBuildPromotion(null, buildLocator);
final TagFinder tagFinder = new TagFinder(myBeanContext.getSingletonService(UserFinder.class), build);
final TagsManager tagsManager = myBeanContext.getSingletonService(TagsManager.class);
tagsManager.removeTagDatas(build, tagFinder.getItems(tagLocator, TagFinder.getDefaultLocator()).myEntries);
List<TagData> postedTagDatas = tags.getFromPosted(myBeanContext.getSingletonService(UserFinder.class));
tagsManager.addTagDatas(build, postedTagDatas);
// returning the tags posted as the default locator might not match the tags just created
return new Tags(postedTagDatas, new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.server.rest.data.build.TagFinder in project teamcity-rest by JetBrains.
the class BuildQueueRequest method replaceTags.
/**
* Replaces build's tags.
*
* @param buildLocator build locator
*/
@PUT
@Path("/{buildLocator}/tags/")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "replaceTags", hidden = true)
public Tags replaceTags(@ApiParam(format = LocatorName.BUILD_QUEUE) @PathParam("buildLocator") String buildLocator, @ApiParam(format = LocatorName.TAG) @QueryParam("locator") String tagLocator, Tags tags, @QueryParam("fields") String fields, @Context HttpServletRequest request) {
BuildPromotion buildPromotion = myBuildPromotionFinder.getItem(Locator.createLocator(buildLocator, getBuildPromotionLocatorDefaults(), null).getStringRepresentation());
final TagFinder tagFinder = new TagFinder(myBeanContext.getSingletonService(UserFinder.class), buildPromotion);
final TagsManager tagsManager = myBeanContext.getSingletonService(TagsManager.class);
tagsManager.removeTagDatas(buildPromotion, tagFinder.getItems(tagLocator, TagFinder.getDefaultLocator()).myEntries);
tagsManager.addTagDatas(buildPromotion, tags.getFromPosted(myBeanContext.getSingletonService(UserFinder.class)));
return new Tags(tagFinder.getItems(null, TagFinder.getDefaultLocator()).myEntries, new Fields(fields), myBeanContext);
}
Aggregations