Search in sources :

Example 26 with PUT

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();
}
Also used : PluginProperty(org.killbill.billing.payment.api.PluginProperty) UUID(java.util.UUID) Entitlement(org.killbill.billing.entitlement.api.Entitlement) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Example 27 with PUT

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);
}
Also used : ClockMock(org.killbill.clock.ClockMock) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Example 28 with PUT

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();
}
Also used : Account(org.killbill.billing.account.api.Account) MutableAccountData(org.killbill.billing.account.api.MutableAccountData) UUID(java.util.UUID) CallContext(org.killbill.billing.util.callcontext.CallContext) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Example 29 with PUT

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);
}
Also used : GET(javax.ws.rs.GET) PUT(javax.ws.rs.PUT) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 30 with PUT

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));
    }
}
Also used : JobPortAllocationConflictException(com.spotify.helios.master.JobPortAllocationConflictException) JobDoesNotExistException(com.spotify.helios.master.JobDoesNotExistException) HostNotFoundException(com.spotify.helios.master.HostNotFoundException) TokenVerificationException(com.spotify.helios.master.TokenVerificationException) Deployment(com.spotify.helios.common.descriptors.Deployment) JobAlreadyDeployedException(com.spotify.helios.master.JobAlreadyDeployedException) JobDeployResponse(com.spotify.helios.common.protocol.JobDeployResponse) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) ExceptionMetered(com.codahale.metrics.annotation.ExceptionMetered) PUT(javax.ws.rs.PUT)

Aggregations

PUT (javax.ws.rs.PUT)203 Path (javax.ws.rs.Path)172 Consumes (javax.ws.rs.Consumes)108 Produces (javax.ws.rs.Produces)72 ApiOperation (io.swagger.annotations.ApiOperation)70 ApiResponses (io.swagger.annotations.ApiResponses)53 Timed (com.codahale.metrics.annotation.Timed)36 AuditEvent (org.graylog2.audit.jersey.AuditEvent)36 URI (java.net.URI)24 Response (javax.ws.rs.core.Response)23 AuditPolicy (co.cask.cdap.common.security.AuditPolicy)19 IOException (java.io.IOException)18 BeanWrapper (org.springframework.beans.BeanWrapper)16 BadRequestException (javax.ws.rs.BadRequestException)14 NotFoundException (javax.ws.rs.NotFoundException)14 WebApplicationException (javax.ws.rs.WebApplicationException)12 UriBuilder (javax.ws.rs.core.UriBuilder)12 UUID (java.util.UUID)11 GET (javax.ws.rs.GET)11 POST (javax.ws.rs.POST)11