Search in sources :

Example 1 with MuteInfo

use of jetbrains.buildServer.serverSide.mute.MuteInfo in project teamcity-rest by JetBrains.

the class Mutes method createMutesWithActualAttributes.

/**
 * This method creates Mutes object with attributes which are actual to the current moment, not the moment when the mute was initially created.
 * Unfortunately, this includes loading of all mutes for the Root project, so this method is really slow.
 */
@NotNull
static Mutes createMutesWithActualAttributes(@NotNull String problemLocator, @NotNull Fields fields, @NotNull BeanContext beanContext) {
    Fields nestedFields = fields.getNestedField("mutes", Fields.NONE, Fields.LONG);
    final String actualLocatorText = Locator.merge(nestedFields.getLocator(), problemLocator);
    List<MuteInfo> entries = beanContext.getSingletonService(MuteFinder.class).getItems(actualLocatorText).myEntries;
    return new Mutes(entries, null, nestedFields, beanContext);
}
Also used : MuteInfo(jetbrains.buildServer.serverSide.mute.MuteInfo) Fields(jetbrains.buildServer.server.rest.model.Fields) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with MuteInfo

use of jetbrains.buildServer.serverSide.mute.MuteInfo in project teamcity-rest by JetBrains.

the class MuteRequest method deleteInstance.

/**
 * Comment is read from the body as an experimental approach
 */
@DELETE
@Path("/{muteLocator}")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Unmute the matching test.", nickname = "unmuteTest")
public void deleteInstance(@ApiParam(format = LocatorName.MUTE) @PathParam("muteLocator") String locatorText, String comment) {
    MuteInfo item = myMuteFinder.getItem(locatorText);
    MuteData muteData = new MuteData(item.getScope(), StringUtil.isEmpty(comment) ? null : comment, item.getTests(), item.getBuildProblemIds().stream().map(i -> i.longValue()).collect(Collectors.toList()), myServiceLocator);
    muteData.unmute();
}
Also used : MuteInfo(jetbrains.buildServer.serverSide.mute.MuteInfo) MuteData(jetbrains.buildServer.server.rest.data.problem.MuteData) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with MuteInfo

use of jetbrains.buildServer.serverSide.mute.MuteInfo in project teamcity-rest by JetBrains.

the class MuteRequest method createInstances.

/**
 * Experimental use only!
 */
@POST
@Path("/multiple")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Mute multiple tests.", nickname = "muteMultipleTests")
public Mutes createInstances(Mutes mutes, @QueryParam("fields") String fields) {
    List<MuteData> postedEntities = mutes.getFromPosted(myServiceLocator);
    // muting after getting objects to report any deserialize errors before
    List<MuteInfo> results = postedEntities.stream().map(muteData -> muteData.mute()).collect(Collectors.toList());
    return new Mutes(results, null, new Fields(fields), myBeanContext);
}
Also used : MuteInfo(jetbrains.buildServer.serverSide.mute.MuteInfo) Fields(jetbrains.buildServer.server.rest.model.Fields) LocatorName(jetbrains.buildServer.server.rest.swagger.constants.LocatorName) Context(javax.ws.rs.core.Context) ServiceLocator(jetbrains.buildServer.ServiceLocator) MuteFinder(jetbrains.buildServer.server.rest.data.mutes.MuteFinder) ApiParam(io.swagger.annotations.ApiParam) ApiUrlBuilder(jetbrains.buildServer.server.rest.ApiUrlBuilder) PagedSearchResult(jetbrains.buildServer.server.rest.data.PagedSearchResult) MuteData(jetbrains.buildServer.server.rest.data.problem.MuteData) Collectors(java.util.stream.Collectors) MuteInfo(jetbrains.buildServer.serverSide.mute.MuteInfo) ApiOperation(io.swagger.annotations.ApiOperation) HttpServletRequest(javax.servlet.http.HttpServletRequest) List(java.util.List) javax.ws.rs(javax.ws.rs) Mutes(jetbrains.buildServer.server.rest.model.problem.Mutes) StringUtil(jetbrains.buildServer.util.StringUtil) Api(io.swagger.annotations.Api) Mute(jetbrains.buildServer.server.rest.model.problem.Mute) UriInfo(javax.ws.rs.core.UriInfo) BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) NotNull(org.jetbrains.annotations.NotNull) PagerData(jetbrains.buildServer.server.rest.model.PagerData) Fields(jetbrains.buildServer.server.rest.model.Fields) MuteData(jetbrains.buildServer.server.rest.data.problem.MuteData) Mutes(jetbrains.buildServer.server.rest.model.problem.Mutes) ApiOperation(io.swagger.annotations.ApiOperation)

Example 4 with MuteInfo

use of jetbrains.buildServer.serverSide.mute.MuteInfo in project teamcity-rest by JetBrains.

the class ProblemWrapper method getMutes.

@NotNull
public List<MuteInfo> getMutes() {
    // this returns not full mute data, but only confined to the problem (MuteInfo.getBuildProblemIds() will not return all the problems affected by the mute)
    if (mutes == null) {
        Set<MuteInfo> mutesSet = new TreeSet<MuteInfo>();
        final SProject rootProject = myServiceLocator.getSingletonService(ProjectManager.class).getRootProject();
        final CurrentMuteInfo currentMuteInfo = myServiceLocator.getSingletonService(ProblemMutingService.class).getBuildProblemCurrentMuteInfo(rootProject.getProjectId(), id);
        if (currentMuteInfo != null) {
            mutesSet.addAll(currentMuteInfo.getProjectsMuteInfo().values());
            mutesSet.addAll(currentMuteInfo.getBuildTypeMuteInfo().values());
        }
        mutes = new ArrayList<MuteInfo>(mutesSet);
    }
    return mutes;
}
Also used : MuteInfo(jetbrains.buildServer.serverSide.mute.MuteInfo) CurrentMuteInfo(jetbrains.buildServer.serverSide.mute.CurrentMuteInfo) CurrentMuteInfo(jetbrains.buildServer.serverSide.mute.CurrentMuteInfo) TreeSet(java.util.TreeSet) ProblemMutingService(jetbrains.buildServer.serverSide.mute.ProblemMutingService) SProject(jetbrains.buildServer.serverSide.SProject) ProjectManager(jetbrains.buildServer.serverSide.ProjectManager) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

MuteInfo (jetbrains.buildServer.serverSide.mute.MuteInfo)4 NotNull (org.jetbrains.annotations.NotNull)3 ApiOperation (io.swagger.annotations.ApiOperation)2 MuteData (jetbrains.buildServer.server.rest.data.problem.MuteData)2 Fields (jetbrains.buildServer.server.rest.model.Fields)2 Api (io.swagger.annotations.Api)1 ApiParam (io.swagger.annotations.ApiParam)1 List (java.util.List)1 TreeSet (java.util.TreeSet)1 Collectors (java.util.stream.Collectors)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 javax.ws.rs (javax.ws.rs)1 Context (javax.ws.rs.core.Context)1 UriInfo (javax.ws.rs.core.UriInfo)1 ServiceLocator (jetbrains.buildServer.ServiceLocator)1 ApiUrlBuilder (jetbrains.buildServer.server.rest.ApiUrlBuilder)1 PagedSearchResult (jetbrains.buildServer.server.rest.data.PagedSearchResult)1 MuteFinder (jetbrains.buildServer.server.rest.data.mutes.MuteFinder)1 PagerData (jetbrains.buildServer.server.rest.model.PagerData)1 Mute (jetbrains.buildServer.server.rest.model.problem.Mute)1