Search in sources :

Example 91 with Response

use of com.ecwid.consul.v1.Response in project azure-sdk-for-java by Azure.

the class StorageAccountsInner method checkNameAvailabilityWithServiceResponseAsync.

/**
     * Checks that the storage account name is valid and is not already in use.
     *
     * @param name the String value
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the CheckNameAvailabilityResultInner object
     */
public Observable<ServiceResponse<CheckNameAvailabilityResultInner>> checkNameAvailabilityWithServiceResponseAsync(String name) {
    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 (name == null) {
        throw new IllegalArgumentException("Parameter name is required and cannot be null.");
    }
    StorageAccountCheckNameAvailabilityParameters accountName = new StorageAccountCheckNameAvailabilityParameters();
    accountName.withName(name);
    return service.checkNameAvailability(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), accountName, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<CheckNameAvailabilityResultInner>>>() {

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

Example 92 with Response

use of com.ecwid.consul.v1.Response in project Gradle-demo by Arisono.

the class OkhttpUtils method sendGetHttp.

/** 
	 * get http 
	 * @param url
	 * @param tag
	 */
public static void sendGetHttp(String url, Map<String, Object> params, String cookies, String tag) {
    StringBuilder buf = new StringBuilder(url);
    if (params != null) {
        if (!params.isEmpty()) {
            if (url.indexOf("?") == -1)
                buf.append("?");
            else if (!url.endsWith("&"))
                buf.append("&");
            Iterator<Map.Entry<String, Object>> entries = params.entrySet().iterator();
            while (entries.hasNext()) {
                Map.Entry<String, Object> entry = entries.next();
                buf.append(String.valueOf(entry.getKey())).append("=").append(String.valueOf(entry.getValue())).append("&");
            }
            buf.deleteCharAt(buf.length() - 1);
        }
    }
    Request request = new Request.Builder().url(buf.toString()).addHeader("content-type", "text/html;charset:utf-8").addHeader("Cookie", "12").build();
    OkhttpUtils.println(tag + ":" + buf.toString());
    OkhttpUtils.client.newCall(request).enqueue(new Callback() {

        @Override
        public void onResponse(Call call, Response response) throws IOException {
            String requestJson;
            requestJson = OkhttpUtils.getResponseString(response);
            OkhttpUtils.println(requestJson);
            RxBus.getInstance().send(tag + ":" + requestJson);
        }

        @Override
        public void onFailure(Call call, IOException e) {
            OkhttpUtils.onFailurePrintln(call, e, this);
        }
    });
}
Also used : Call(okhttp3.Call) Builder(okhttp3.FormBody.Builder) Request(okhttp3.Request) IOException(java.io.IOException) Response(okhttp3.Response) Callback(okhttp3.Callback) Map(java.util.Map)

Example 93 with Response

use of com.ecwid.consul.v1.Response in project Gradle-demo by Arisono.

the class RetryIntercepter method intercept.

@SuppressWarnings("resource")
@Override
public Response intercept(Chain chain) throws IOException {
    Request request = chain.request();
    Response response = chain.proceed(request);
    try {
        // OkhttpUtils.println("重试拦截器:"+response.isSuccessful());
        while (!response.isSuccessful() && retryNum < maxRetry) {
            retryNum++;
            response = chain.proceed(request);
        }
    } catch (ConnectException e) {
        OkhttpUtils.println("服务器拒绝连接.....");
    } catch (IOException e) {
        OkhttpUtils.println("服务器拒绝连接.....");
    }
    return response;
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) IOException(java.io.IOException) ConnectException(java.net.ConnectException)

Example 94 with Response

use of com.ecwid.consul.v1.Response in project azure-sdk-for-java by Azure.

the class EndpointsInner method purgeContentWithServiceResponseAsync.

/**
     * Removes a content from CDN.
     *
     * @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 purged. Can describe a file path or a wild card directory.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable for the request
     */
public Observable<ServiceResponse<Void>> purgeContentWithServiceResponseAsync(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);
    PurgeParameters contentFilePaths = new PurgeParameters();
    contentFilePaths.withContentPaths(contentPaths);
    Observable<Response<ResponseBody>> observable = service.purgeContent(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) PurgeParameters(com.microsoft.azure.management.cdn.PurgeParameters) TypeToken(com.google.common.reflect.TypeToken)

Example 95 with Response

use of com.ecwid.consul.v1.Response in project azure-sdk-for-java by Azure.

the class ProfilesInner method beginUpdateWithServiceResponseAsync.

/**
     * Updates an existing CDN profile with the specified profile name under the specified subscription and resource group.
     *
     * @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 tags Profile tags
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the ProfileInner object
     */
public Observable<ServiceResponse<ProfileInner>> beginUpdateWithServiceResponseAsync(String resourceGroupName, String profileName, Map<String, String> tags) {
    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 (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 (tags == null) {
        throw new IllegalArgumentException("Parameter tags is required and cannot be null.");
    }
    Validator.validate(tags);
    ProfileUpdateParameters profileUpdateParameters = new ProfileUpdateParameters();
    profileUpdateParameters.withTags(tags);
    return service.beginUpdate(resourceGroupName, profileName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), profileUpdateParameters, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ProfileInner>>>() {

        @Override
        public Observable<ServiceResponse<ProfileInner>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<ProfileInner> clientResponse = beginUpdateDelegate(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) ProfileUpdateParameters(com.microsoft.azure.management.cdn.ProfileUpdateParameters) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Aggregations

Response (okhttp3.Response)1402 Request (okhttp3.Request)993 IOException (java.io.IOException)526 Test (org.junit.Test)432 Response (retrofit2.Response)337 OkHttpClient (okhttp3.OkHttpClient)275 Call (okhttp3.Call)274 ResponseBody (okhttp3.ResponseBody)237 ServiceResponse (com.microsoft.rest.ServiceResponse)179 MockResponse (okhttp3.mockwebserver.MockResponse)148 RequestBody (okhttp3.RequestBody)142 Callback (okhttp3.Callback)123 List (java.util.List)119 Observable (rx.Observable)114 ArrayList (java.util.ArrayList)89 HttpUrl (okhttp3.HttpUrl)86 JSONObject (org.json.JSONObject)85 ANResponse (com.androidnetworking.common.ANResponse)84 AtomicReference (java.util.concurrent.atomic.AtomicReference)79 ANError (com.androidnetworking.error.ANError)77