Search in sources :

Example 11 with Path

use of retrofit2.http.Path in project azure-sdk-for-java by Azure.

the class EndpointsInner method beginLoadContentWithServiceResponseAsync.

/**
     * Pre-loads a content to CDN. Available for Verizon Profiles.
     *
     * @param resourceGroupName Name of the Resource group within the Azure subscription.
     * @param profileName Name of the CDN profile which is unique within the resource group.
     * @param endpointName Name of the endpoint under the profile which is unique globally.
     * @param contentPaths The path to the content to be loaded. Path should be a relative file URL of the origin.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceResponse} object if successful.
     */
public Observable<ServiceResponse<Void>> beginLoadContentWithServiceResponseAsync(String resourceGroupName, String profileName, String endpointName, List<String> contentPaths) {
    if (resourceGroupName == null) {
        throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
    }
    if (profileName == null) {
        throw new IllegalArgumentException("Parameter profileName is required and cannot be null.");
    }
    if (endpointName == null) {
        throw new IllegalArgumentException("Parameter endpointName is required and cannot be null.");
    }
    if (this.client.subscriptionId() == null) {
        throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
    }
    if (this.client.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
    }
    if (contentPaths == null) {
        throw new IllegalArgumentException("Parameter contentPaths is required and cannot be null.");
    }
    Validator.validate(contentPaths);
    LoadParameters contentFilePaths = new LoadParameters();
    contentFilePaths.withContentPaths(contentPaths);
    return service.beginLoadContent(resourceGroupName, profileName, endpointName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), contentFilePaths, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {

        @Override
        public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<Void> clientResponse = beginLoadContentDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse) LoadParameters(com.microsoft.azure.management.cdn.LoadParameters) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Example 12 with Path

use of retrofit2.http.Path in project azure-sdk-for-java by Azure.

the class EndpointsInner method loadContentWithServiceResponseAsync.

/**
     * Pre-loads a content to CDN. Available for Verizon Profiles.
     *
     * @param resourceGroupName Name of the Resource group within the Azure subscription.
     * @param profileName Name of the CDN profile which is unique within the resource group.
     * @param endpointName Name of the endpoint under the profile which is unique globally.
     * @param contentPaths The path to the content to be loaded. Path should be a relative file URL of the origin.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable for the request
     */
public Observable<ServiceResponse<Void>> loadContentWithServiceResponseAsync(String resourceGroupName, String profileName, String endpointName, List<String> contentPaths) {
    if (resourceGroupName == null) {
        throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
    }
    if (profileName == null) {
        throw new IllegalArgumentException("Parameter profileName is required and cannot be null.");
    }
    if (endpointName == null) {
        throw new IllegalArgumentException("Parameter endpointName is required and cannot be null.");
    }
    if (this.client.subscriptionId() == null) {
        throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
    }
    if (this.client.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
    }
    if (contentPaths == null) {
        throw new IllegalArgumentException("Parameter contentPaths is required and cannot be null.");
    }
    Validator.validate(contentPaths);
    LoadParameters contentFilePaths = new LoadParameters();
    contentFilePaths.withContentPaths(contentPaths);
    Observable<Response<ResponseBody>> observable = service.loadContent(resourceGroupName, profileName, endpointName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), contentFilePaths, this.client.userAgent());
    return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<Void>() {
    }.getType());
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) LoadParameters(com.microsoft.azure.management.cdn.LoadParameters) TypeToken(com.google.common.reflect.TypeToken)

Example 13 with Path

use of retrofit2.http.Path in project graylog2-server by Graylog2.

the class ClusterLoadBalancerStatusResource method override.

@PUT
@Timed
@RequiresAuthentication
@RequiresPermissions(RestPermissions.LBSTATUS_CHANGE)
@ApiOperation(value = "Override load balancer status of this graylog-server node. Next lifecycle " + "change will override it again to its default. Set to ALIVE, DEAD, or THROTTLED.")
@Path("/override/{status}")
@NoAuditEvent("this is a proxy resource, the audit event will be emitted on the target node")
public void override(@ApiParam(name = "nodeId", value = "The id of the node whose LB status will be changed", required = true) @PathParam("nodeId") String nodeId, @ApiParam(name = "status") @PathParam("status") String status) throws IOException, NodeNotFoundException {
    final Node targetNode = nodeService.byNodeId(nodeId);
    RemoteLoadBalancerStatusResource remoteLoadBalancerStatusResource = remoteInterfaceProvider.get(targetNode, this.authenticationToken, RemoteLoadBalancerStatusResource.class);
    final Response response = remoteLoadBalancerStatusResource.override(status).execute();
    if (!response.isSuccessful()) {
        LOG.warn("Unable to override load balancer status on node {}: {}", nodeId, response.message());
        throw new WebApplicationException(response.message(), BAD_GATEWAY);
    }
}
Also used : Response(retrofit2.Response) WebApplicationException(javax.ws.rs.WebApplicationException) RemoteLoadBalancerStatusResource(org.graylog2.shared.rest.resources.system.RemoteLoadBalancerStatusResource) Node(org.graylog2.cluster.Node) Path(javax.ws.rs.Path) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) RequiresAuthentication(org.apache.shiro.authz.annotation.RequiresAuthentication) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT) NoAuditEvent(org.graylog2.audit.jersey.NoAuditEvent)

Example 14 with Path

use of retrofit2.http.Path in project retrofit by square.

the class RequestBuilderTest method getWithPathAndQueryAmpersandParam.

@Test
public void getWithPathAndQueryAmpersandParam() {
    class Example {

        //
        @GET("/foo/bar/{ping}/")
        Call<ResponseBody> method(@Path("ping") String ping, @Query("kit") String kit) {
            return null;
        }
    }
    Request request = buildRequest(Example.class, "pong&", "kat&");
    assertThat(request.method()).isEqualTo("GET");
    assertThat(request.headers().size()).isZero();
    assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/pong&/?kit=kat%26");
    assertThat(request.body()).isNull();
}
Also used : Path(retrofit2.http.Path) Query(retrofit2.http.Query) Request(okhttp3.Request) ResponseBody(okhttp3.ResponseBody) Test(org.junit.Test)

Example 15 with Path

use of retrofit2.http.Path in project retrofit by square.

the class RequestBuilderTest method customMethodWithBody.

@Ignore("https://github.com/square/okhttp/issues/229")
@Test
public void customMethodWithBody() {
    class Example {

        @HTTP(method = "CUSTOM2", path = "/foo", hasBody = true)
        Call<ResponseBody> method(@Body RequestBody body) {
            return null;
        }
    }
    RequestBody body = RequestBody.create(MediaType.parse("text/plain"), "hi");
    Request request = buildRequest(Example.class, body);
    assertThat(request.method()).isEqualTo("CUSTOM2");
    assertThat(request.url().toString()).isEqualTo("http://example.com/foo");
    assertBody(request.body(), "hi");
}
Also used : Request(okhttp3.Request) RequestBody(okhttp3.RequestBody) ResponseBody(okhttp3.ResponseBody) MultipartBody(okhttp3.MultipartBody) Body(retrofit2.http.Body) RequestBody(okhttp3.RequestBody) ResponseBody(okhttp3.ResponseBody) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

ResponseBody (okhttp3.ResponseBody)16 Request (okhttp3.Request)13 Test (org.junit.Test)13 Path (retrofit2.http.Path)12 Response (retrofit2.Response)5 ServiceResponse (com.microsoft.rest.ServiceResponse)4 Query (retrofit2.http.Query)4 MultipartBody (okhttp3.MultipartBody)3 RequestBody (okhttp3.RequestBody)3 Body (retrofit2.http.Body)3 TypeToken (com.google.common.reflect.TypeToken)2 LoadParameters (com.microsoft.azure.management.cdn.LoadParameters)2 PurgeParameters (com.microsoft.azure.management.cdn.PurgeParameters)2 Observable (rx.Observable)2 Timed (com.codahale.metrics.annotation.Timed)1 ApiOperation (io.swagger.annotations.ApiOperation)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 MockResponse (okhttp3.mockwebserver.MockResponse)1