Search in sources :

Example 71 with POST

use of javax.ws.rs.POST in project jersey by jersey.

the class ClientShutdownLeakResource method invokeClient.

@POST
@Path("invoke")
public String invokeClient() {
    WebTarget target2 = target.property("Washington", "Irving");
    Invocation.Builder req = target2.request().property("how", "now");
    req.buildGet().property("Irving", "Washington");
    return target.toString();
}
Also used : Invocation(javax.ws.rs.client.Invocation) WebTarget(javax.ws.rs.client.WebTarget) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 72 with POST

use of javax.ws.rs.POST in project jersey by jersey.

the class ChatResource method postMessage.

@POST
@ManagedAsync
public String postMessage(final Message message) throws InterruptedException {
    final AsyncResponse asyncResponse = suspended.take();
    asyncResponse.resume(message);
    return "Sent!";
}
Also used : AsyncResponse(javax.ws.rs.container.AsyncResponse) POST(javax.ws.rs.POST) ManagedAsync(org.glassfish.jersey.server.ManagedAsync)

Example 73 with POST

use of javax.ws.rs.POST in project jersey by jersey.

the class DomainResource method post.

@Path("start")
@POST
public Response post(@DefaultValue("0") @QueryParam("testSources") int testSources) {
    final Process process = new Process(testSources);
    processes.put(process.getId(), process);
    Executors.newSingleThreadExecutor().execute(process);
    final URI processIdUri = UriBuilder.fromResource(DomainResource.class).path("process/{id}").build(process.getId());
    return Response.created(processIdUri).build();
}
Also used : URI(java.net.URI) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 74 with POST

use of javax.ws.rs.POST in project jersey by jersey.

the class FormResource method processForm.

/**
     * Process the form submission. Produces a table showing the form field
     * values submitted.
     * @return a dynamically generated HTML table.
     * @param formData the data from the form submission
     */
@POST
@Consumes("application/x-www-form-urlencoded")
public String processForm(MultivaluedMap<String, String> formData) {
    StringBuilder buf = new StringBuilder();
    buf.append("<html><head><title>Form results</title></head><body>");
    buf.append("<p>Hello, you entered the following information: </p><table border='1'>");
    for (String key : formData.keySet()) {
        if (key.equals("submit")) {
            continue;
        }
        buf.append("<tr><td>");
        buf.append(key);
        buf.append("</td><td>");
        buf.append(formData.getFirst(key));
        buf.append("</td></tr>");
    }
    for (Cookie c : headers.getCookies().values()) {
        buf.append("<tr><td>Cookie: ");
        buf.append(c.getName());
        buf.append("</td><td>");
        buf.append(c.getValue());
        buf.append("</td></tr>");
    }
    buf.append("</table></body></html>");
    return buf.toString();
}
Also used : NewCookie(javax.ws.rs.core.NewCookie) Cookie(javax.ws.rs.core.Cookie) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 75 with POST

use of javax.ws.rs.POST in project pinot by linkedin.

the class DetectionJobResource method computeSeverity.

/**
   * Returns the weight of the metric at the given window. The calculation of baseline (history) data is specified by
   * seasonal period (in days) and season count. Seasonal period is the difference of duration from one window to the
   * other. For instance, to use the data that is one week before current window, set seasonal period to 7. The season
   * count specify how many seasons of history data to retrieve. If there are more than 1 season, then the baseline is
   * the average of all seasons.
   *
   * Examples of the configuration of baseline:
   * 1. Week-Over-Week: seasonalPeriodInDays = 7, seasonCount = 1
   * 2. Week-Over-4-Weeks-Mean: seasonalPeriodInDays = 7, seasonCount = 4
   * 3. Month-Over-Month: seasonalPeriodInDays = 30, seasonCount = 1
   *
   * @param collectionName the collection to which the metric belong
   * @param metricName the metric name
   * @param startTimeIso start time of current window, inclusive
   * @param endTimeIso end time of current window, exclusive
   * @param seasonalPeriodInDays the difference of duration between the start time of each window
   * @param seasonCount the number of history windows
   *
   * @return the weight of the metric at the given window
   * @throws Exception
   */
@POST
@Path("/anomaly-weight")
public Response computeSeverity(@NotNull @QueryParam("collection") String collectionName, @NotNull @QueryParam("metric") String metricName, @NotNull @QueryParam("start") String startTimeIso, @NotNull @QueryParam("end") String endTimeIso, @QueryParam("period") String seasonalPeriodInDays, @QueryParam("seasonCount") String seasonCount) throws Exception {
    DateTime startTime = null;
    DateTime endTime = null;
    if (StringUtils.isNotBlank(startTimeIso)) {
        startTime = ISODateTimeFormat.dateTimeParser().parseDateTime(startTimeIso);
    }
    if (StringUtils.isNotBlank(endTimeIso)) {
        endTime = ISODateTimeFormat.dateTimeParser().parseDateTime(endTimeIso);
    }
    long currentWindowStart = startTime.getMillis();
    long currentWindowEnd = endTime.getMillis();
    // Default is using one week data priors current values for calculating weight
    long seasonalPeriodMillis = TimeUnit.DAYS.toMillis(7);
    if (StringUtils.isNotBlank(seasonalPeriodInDays)) {
        seasonalPeriodMillis = TimeUnit.DAYS.toMillis(Integer.parseInt(seasonalPeriodInDays));
    }
    int seasonCountInt = 1;
    if (StringUtils.isNotBlank(seasonCount)) {
        seasonCountInt = Integer.parseInt(seasonCount);
    }
    ThirdEyeClient thirdEyeClient = CACHE_REGISTRY_INSTANCE.getQueryCache().getClient();
    SeverityComputationUtil util = new SeverityComputationUtil(thirdEyeClient, collectionName, metricName);
    Map<String, Object> severity = util.computeSeverity(currentWindowStart, currentWindowEnd, seasonalPeriodMillis, seasonCountInt);
    return Response.ok(severity.toString(), MediaType.TEXT_PLAIN_TYPE).build();
}
Also used : SeverityComputationUtil(com.linkedin.thirdeye.util.SeverityComputationUtil) ThirdEyeClient(com.linkedin.thirdeye.client.ThirdEyeClient) DateTime(org.joda.time.DateTime) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

POST (javax.ws.rs.POST)513 Path (javax.ws.rs.Path)360 Consumes (javax.ws.rs.Consumes)242 Produces (javax.ws.rs.Produces)222 ApiOperation (io.swagger.annotations.ApiOperation)133 ApiResponses (io.swagger.annotations.ApiResponses)107 IOException (java.io.IOException)74 URI (java.net.URI)63 WebApplicationException (javax.ws.rs.WebApplicationException)62 Timed (com.codahale.metrics.annotation.Timed)55 Response (javax.ws.rs.core.Response)50 TimedResource (org.killbill.commons.metrics.TimedResource)36 CallContext (org.killbill.billing.util.callcontext.CallContext)35 AuditEvent (org.graylog2.audit.jersey.AuditEvent)33 HashMap (java.util.HashMap)32 BadRequestException (co.cask.cdap.common.BadRequestException)24 AuditPolicy (co.cask.cdap.common.security.AuditPolicy)24 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)23 Account (org.killbill.billing.account.api.Account)22 ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)20