use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.
the class BuildRequest method deleteComment.
@DELETE
@Path("/{buildLocator}/comment")
@ApiOperation(value = "Remove the build comment matching the locator.", nickname = "deleteBuildComment")
public void deleteComment(@ApiParam(format = LocatorName.BUILD) @PathParam("buildLocator") String buildLocator, @Context HttpServletRequest request) {
BuildPromotion build = myBuildFinder.getBuildPromotion(null, buildLocator);
final SUser user = SessionUser.getUser(request);
setBuildComment(build, null, user);
}
use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.
the class BuildRequest method pinMultiple.
/**
* Experimental.
* Pins multiple builds
* @return List of error messages with associated entities, if any
*/
@PUT
@Path("/multiple/{buildLocator}/pinInfo/")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Pin multiple matching builds.", nickname = "pinMultipleBuilds")
public MultipleOperationResult pinMultiple(@ApiParam(format = LocatorName.BUILD) @PathParam("buildLocator") String buildLocator, PinInfo pinStatus, @QueryParam("fields") String fields, @Context HttpServletRequest request) {
Boolean newStatus = pinStatus.getStatusFromPosted();
if (newStatus == null)
throw new BadRequestException("Pin status should be specified in the payload");
String commentText = pinStatus.getCommentTextFromPosted();
SUser user = SessionUser.getUser(request);
return processMultiple(buildLocator, (build) -> pinBuild(build, user, commentText, newStatus), new Fields(fields));
}
use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.
the class BuildRequest method replaceComment.
@PUT
@Path("/{buildLocator}/comment")
@Consumes({ "text/plain" })
@ApiOperation(value = "Update the comment on the matching build.", nickname = "setBuildComment")
public void replaceComment(@ApiParam(format = LocatorName.BUILD) @PathParam("buildLocator") String buildLocator, String text, @Context HttpServletRequest request) {
BuildPromotion build = myBuildFinder.getBuildPromotion(null, buildLocator);
final SUser user = SessionUser.getUser(request);
setBuildComment(build, text, user);
}
use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.
the class BuildRequest method cancelBuild.
// todo: deprecate in favor of posting to .../canceledInfo
@POST
@Path("/{buildLocator}")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "cancelBuild")
public Build cancelBuild(@ApiParam(format = LocatorName.BUILD) @PathParam("buildLocator") String buildLocator, BuildCancelRequest cancelRequest, @QueryParam("fields") String fields, @Context HttpServletRequest request) {
final SUser currentUser = SessionUser.getUser(request);
BuildPromotion build = myBuildFinder.getBuildPromotion(null, buildLocator);
LinkedHashMap<Long, RuntimeException> errors = cancelBuilds(Collections.singletonList(build), cancelRequest, currentUser);
if (!errors.isEmpty()) {
throw errors.entrySet().iterator().next().getValue();
}
final SBuild associatedBuild = build.getAssociatedBuild();
if (associatedBuild == null) {
return null;
}
return new Build(associatedBuild, new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.users.SUser in project teamcity-rest by JetBrains.
the class CloudRequest method stopInstance.
@DELETE
@Path("/instances/{instanceLocator}")
@ApiOperation(value = "Stop cloud instance matching the locator.", nickname = "stopInstance")
public void stopInstance(@PathParam("instanceLocator") String instanceLocator) {
jetbrains.buildServer.clouds.CloudInstance instance = myCloudInstanceFinder.getItem(instanceLocator).getInstance();
final SUser user = myServiceLocator.getSingletonService(UserFinder.class).getCurrentUser();
CloudUtil cloudUtil = myBeanContext.getSingletonService(CloudUtil.class);
String profileId = cloudUtil.getProfileId(instance.getImage());
if (profileId == null) {
throw new InvalidStateException("Cannot find profile for the cloud image");
}
myBeanContext.getSingletonService(CloudManager.class).terminateInstance(profileId, instance.getImageId(), instance.getInstanceId(), TerminateInstanceReason.userAction(user));
}
Aggregations