use of javax.ws.rs.PUT in project killbill by killbill.
the class SubscriptionResource method uncancelEntitlementPlan.
@TimedResource
@PUT
@Path("/{subscriptionId:" + UUID_PATTERN + "}/uncancel")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Un-cancel an entitlement")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid subscription id supplied"), @ApiResponse(code = 404, message = "Entitlement not found") })
public Response uncancelEntitlementPlan(@PathParam("subscriptionId") final String subscriptionId, @QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final HttpServletRequest request) throws EntitlementApiException {
final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
final UUID uuid = UUID.fromString(subscriptionId);
final Entitlement current = entitlementApi.getEntitlementForId(uuid, context.createContext(createdBy, reason, comment, request));
current.uncancelEntitlement(pluginProperties, context.createContext(createdBy, reason, comment, request));
return Response.status(Status.OK).build();
}
use of javax.ws.rs.PUT in project killbill by killbill.
the class TestResource method updateTestClockTime.
@PUT
@Path("/clock")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Move the current time", response = ClockResource.class)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid timezone supplied") })
public Response updateTestClockTime(@QueryParam("days") final Integer addDays, @QueryParam("weeks") final Integer addWeeks, @QueryParam("months") final Integer addMonths, @QueryParam("years") final Integer addYears, @QueryParam("timeZone") final String timeZoneStr, @QueryParam("timeoutSec") @DefaultValue("5") final Long timeoutSec, @javax.ws.rs.core.Context final HttpServletRequest request) {
final ClockMock testClock = getClockMock();
if (addDays != null) {
testClock.addDays(addDays);
} else if (addWeeks != null) {
testClock.addWeeks(addWeeks);
} else if (addMonths != null) {
testClock.addMonths(addMonths);
} else if (addYears != null) {
testClock.addYears(addYears);
}
waitForNotificationToComplete(request, timeoutSec);
return getCurrentTime(timeZoneStr);
}
use of javax.ws.rs.PUT in project killbill by killbill.
the class AccountResource method setEmailNotificationsForAccount.
@TimedResource
@PUT
@Path("/{accountId:" + UUID_PATTERN + "}/" + EMAIL_NOTIFICATIONS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Set account email notification")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied"), @ApiResponse(code = 404, message = "Account not found") })
public Response setEmailNotificationsForAccount(final InvoiceEmailJson json, @PathParam("accountId") final String accountIdString, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
verifyNonNullOrEmpty(json, "InvoiceEmailJson body should be specified");
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final UUID accountId = UUID.fromString(accountIdString);
final Account account = accountUserApi.getAccountById(accountId, callContext);
final MutableAccountData mutableAccountData = account.toMutableAccountData();
mutableAccountData.setIsNotifiedForInvoices(json.isNotifiedForInvoices());
accountUserApi.updateAccount(accountId, mutableAccountData, callContext);
return Response.status(Status.OK).build();
}
use of javax.ws.rs.PUT in project platformlayer by platformlayer.
the class ManagedItemResource method createItemJson.
@PUT
@Consumes({ JSON })
@Produces({ XML, JSON })
public <T extends ItemBase> T createItemJson(String json, @QueryParam("unique") String uniqueTag) throws RepositoryException, OpsException, JAXBException, IOException {
// String json2 = json.replace("{\"value\":\"pl", "{\"value\":\"pl");
Class<T> javaClass = (Class<T>) getModelClass().getJavaClass();
T item = jsonMapper.readItem(javaClass, json);
checkItemKey(item);
return itemService.putItem(getProjectAuthorization(), item, uniqueTag);
}
use of javax.ws.rs.PUT in project helios by spotify.
the class HostsResource method jobPut.
/**
* Sets the deployment of the job identified by its {@link JobId} on the host named by
* {@code host} to {@code deployment}.
* @param host The host to deploy to.
* @param jobId The job to deploy.
* @param deployment Deployment information.
* @param username The user deploying.
* @param token The authorization token for this deployment.
* @return The response.
*/
@PUT
@Path("/{host}/jobs/{job}")
@Produces(APPLICATION_JSON)
@Timed
@ExceptionMetered
public JobDeployResponse jobPut(@PathParam("host") final String host, @PathParam("job") final JobId jobId, @Valid final Deployment deployment, @RequestUser final String username, @QueryParam("token") @DefaultValue(EMPTY_TOKEN) final String token) {
if (!jobId.isFullyQualified()) {
throw badRequest(new JobDeployResponse(JobDeployResponse.Status.INVALID_ID, host, jobId));
}
try {
final Deployment actualDeployment = deployment.toBuilder().setDeployerUser(username).build();
model.deployJob(host, actualDeployment, token);
return new JobDeployResponse(JobDeployResponse.Status.OK, host, jobId);
} catch (JobAlreadyDeployedException e) {
throw badRequest(new JobDeployResponse(JobDeployResponse.Status.JOB_ALREADY_DEPLOYED, host, jobId));
} catch (HostNotFoundException e) {
throw badRequest(new JobDeployResponse(JobDeployResponse.Status.HOST_NOT_FOUND, host, jobId));
} catch (JobDoesNotExistException e) {
throw badRequest(new JobDeployResponse(JobDeployResponse.Status.JOB_NOT_FOUND, host, jobId));
} catch (JobPortAllocationConflictException e) {
throw badRequest(new JobDeployResponse(JobDeployResponse.Status.PORT_CONFLICT, host, jobId));
} catch (TokenVerificationException e) {
throw forbidden(new JobDeployResponse(JobDeployResponse.Status.FORBIDDEN, host, jobId));
}
}
Aggregations