Search in sources :

Example 1 with TagFinder

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);
    });
}
Also used : TagFinder(jetbrains.buildServer.server.rest.data.build.TagFinder) XmlElement(javax.xml.bind.annotation.XmlElement)

Example 2 with TagFinder

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);
}
Also used : TagFinder(jetbrains.buildServer.server.rest.data.build.TagFinder) TagsManager(jetbrains.buildServer.tags.TagsManager) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with TagFinder

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);
}
Also used : Fields(jetbrains.buildServer.server.rest.model.Fields) TagFinder(jetbrains.buildServer.server.rest.data.build.TagFinder) TagsManager(jetbrains.buildServer.tags.TagsManager) Tags(jetbrains.buildServer.server.rest.model.build.Tags) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

TagFinder (jetbrains.buildServer.server.rest.data.build.TagFinder)3 ApiOperation (io.swagger.annotations.ApiOperation)2 TagsManager (jetbrains.buildServer.tags.TagsManager)2 XmlElement (javax.xml.bind.annotation.XmlElement)1 Fields (jetbrains.buildServer.server.rest.model.Fields)1 Tags (jetbrains.buildServer.server.rest.model.build.Tags)1