Search in sources :

Example 6 with TagsManager

use of jetbrains.buildServer.tags.TagsManager in project teamcity-rest by JetBrains.

the class BuildRequest method addTagsToBuild.

/**
 * Adds a set of tags to a build
 *
 * @param buildLocator build locator
 */
@POST
@Path("/{buildLocator}/tags/")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Add tags to the matching build.", nickname = "addTagsToBuild")
public Tags addTagsToBuild(@ApiParam(format = LocatorName.BUILD) @PathParam("buildLocator") String buildLocator, Tags tags, @QueryParam("fields") String fields) {
    BuildPromotion build = myBuildFinder.getBuildPromotion(null, buildLocator);
    final TagsManager tagsManager = myBeanContext.getSingletonService(TagsManager.class);
    final List<TagData> tagsPosted = tags.getFromPosted(myBeanContext.getSingletonService(UserFinder.class));
    tagsManager.addTagDatas(build, tagsPosted);
    return new Tags(tagsPosted, new Fields(fields), myBeanContext);
}
Also used : TagsManager(jetbrains.buildServer.tags.TagsManager) ApiOperation(io.swagger.annotations.ApiOperation)

Example 7 with TagsManager

use of jetbrains.buildServer.tags.TagsManager in project teamcity-rest by JetBrains.

the class BuildQueueRequest method addTags.

/**
 * Adds a set of tags to a build
 *
 * @param buildLocator build locator
 */
@POST
@Path("/{buildLocator}/tags/")
@Consumes({ "application/xml", "application/json" })
@ApiOperation(value = "Add tags to the matching build.", nickname = "addTagsToBuild")
public void addTags(@ApiParam(format = LocatorName.BUILD) @PathParam("buildLocator") String buildLocator, Tags tags, @Context HttpServletRequest request) {
    BuildPromotion buildPromotion = myBuildPromotionFinder.getItem(Locator.createLocator(buildLocator, getBuildPromotionLocatorDefaults(), null).getStringRepresentation());
    final TagsManager tagsManager = myBeanContext.getSingletonService(TagsManager.class);
    tagsManager.addTagDatas(buildPromotion, tags.getFromPosted(myBeanContext.getSingletonService(UserFinder.class)));
}
Also used : TagsManager(jetbrains.buildServer.tags.TagsManager) ApiOperation(io.swagger.annotations.ApiOperation)

Example 8 with TagsManager

use of jetbrains.buildServer.tags.TagsManager 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

ApiOperation (io.swagger.annotations.ApiOperation)8 TagsManager (jetbrains.buildServer.tags.TagsManager)8 TagFinder (jetbrains.buildServer.server.rest.data.build.TagFinder)2 Fields (jetbrains.buildServer.server.rest.model.Fields)1 Tags (jetbrains.buildServer.server.rest.model.build.Tags)1