use of jetbrains.buildServer.server.rest.data.CloudUtil in project teamcity-rest by JetBrains.
the class CloudInstance method startInstance.
@Nullable
public jetbrains.buildServer.clouds.CloudInstance startInstance(@NotNull final SUser user, @NotNull final ServiceLocator serviceLocator) {
if (submittedImage == null) {
throw new BadRequestException("Cloud Instance should contain image");
}
CloudUtil util = serviceLocator.getSingletonService(CloudUtil.class);
jetbrains.buildServer.clouds.CloudImage image = submittedImage.getFromPosted(serviceLocator);
String profileId = util.getProfileId(image);
if (profileId == null) {
throw new InvalidStateException("Cannot find profile for the cloud image");
}
CloudManager cloudManager = serviceLocator.getSingletonService(CloudManager.class);
cloudManager.startInstance(profileId, image.getId(), StartInstanceReason.userAction(user));
return null;
}
Aggregations