Search in sources :

Example 96 with Callback

use of okhttp3.Callback in project azure-sdk-for-java by Azure.

the class PoolsImpl method getAsync.

/**
     * Gets information about the specified pool.
     *
     * @param poolId The id of the pool to get.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if callback is null
     * @return the {@link Call} object
     */
public ServiceCall getAsync(String poolId, final ServiceCallback<CloudPool> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (poolId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter poolId is required and cannot be null."));
        return null;
    }
    if (this.client.apiVersion() == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
        return null;
    }
    final PoolGetOptions poolGetOptions = null;
    String select = null;
    String expand = null;
    Integer timeout = null;
    String clientRequestId = null;
    Boolean returnClientRequestId = null;
    DateTime ocpDate = null;
    String ifMatch = null;
    String ifNoneMatch = null;
    DateTime ifModifiedSince = null;
    DateTime ifUnmodifiedSince = null;
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    DateTimeRfc1123 ifModifiedSinceConverted = null;
    if (ifModifiedSince != null) {
        ifModifiedSinceConverted = new DateTimeRfc1123(ifModifiedSince);
    }
    DateTimeRfc1123 ifUnmodifiedSinceConverted = null;
    if (ifUnmodifiedSince != null) {
        ifUnmodifiedSinceConverted = new DateTimeRfc1123(ifUnmodifiedSince);
    }
    Call<ResponseBody> call = service.get(poolId, this.client.apiVersion(), this.client.acceptLanguage(), select, expand, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, ifMatch, ifNoneMatch, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<CloudPool>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                serviceCallback.success(getDelegate(response));
            } catch (BatchErrorException | IOException exception) {
                serviceCallback.failure(exception);
            }
        }
    });
    return serviceCall;
}
Also used : PoolGetOptions(com.microsoft.azure.batch.protocol.models.PoolGetOptions) ServiceCall(com.microsoft.rest.ServiceCall) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123) CloudPool(com.microsoft.azure.batch.protocol.models.CloudPool)

Example 97 with Callback

use of okhttp3.Callback in project azure-sdk-for-java by Azure.

the class PoolsImpl method removeNodesAsync.

/**
     * Removes compute nodes from the specified pool.
     *
     * @param poolId The id of the pool from which you want to remove nodes.
     * @param nodeRemoveParameter The parameters for the request.
     * @param poolRemoveNodesOptions Additional parameters for the operation
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if callback is null
     * @return the {@link Call} object
     */
public ServiceCall removeNodesAsync(String poolId, NodeRemoveParameter nodeRemoveParameter, PoolRemoveNodesOptions poolRemoveNodesOptions, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (poolId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter poolId is required and cannot be null."));
        return null;
    }
    if (nodeRemoveParameter == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter nodeRemoveParameter is required and cannot be null."));
        return null;
    }
    if (this.client.apiVersion() == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
        return null;
    }
    Validator.validate(nodeRemoveParameter, serviceCallback);
    Validator.validate(poolRemoveNodesOptions, serviceCallback);
    Integer timeout = null;
    if (poolRemoveNodesOptions != null) {
        timeout = poolRemoveNodesOptions.timeout();
    }
    String clientRequestId = null;
    if (poolRemoveNodesOptions != null) {
        clientRequestId = poolRemoveNodesOptions.clientRequestId();
    }
    Boolean returnClientRequestId = null;
    if (poolRemoveNodesOptions != null) {
        returnClientRequestId = poolRemoveNodesOptions.returnClientRequestId();
    }
    DateTime ocpDate = null;
    if (poolRemoveNodesOptions != null) {
        ocpDate = poolRemoveNodesOptions.ocpDate();
    }
    String ifMatch = null;
    if (poolRemoveNodesOptions != null) {
        ifMatch = poolRemoveNodesOptions.ifMatch();
    }
    String ifNoneMatch = null;
    if (poolRemoveNodesOptions != null) {
        ifNoneMatch = poolRemoveNodesOptions.ifNoneMatch();
    }
    DateTime ifModifiedSince = null;
    if (poolRemoveNodesOptions != null) {
        ifModifiedSince = poolRemoveNodesOptions.ifModifiedSince();
    }
    DateTime ifUnmodifiedSince = null;
    if (poolRemoveNodesOptions != null) {
        ifUnmodifiedSince = poolRemoveNodesOptions.ifUnmodifiedSince();
    }
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    DateTimeRfc1123 ifModifiedSinceConverted = null;
    if (ifModifiedSince != null) {
        ifModifiedSinceConverted = new DateTimeRfc1123(ifModifiedSince);
    }
    DateTimeRfc1123 ifUnmodifiedSinceConverted = null;
    if (ifUnmodifiedSince != null) {
        ifUnmodifiedSinceConverted = new DateTimeRfc1123(ifUnmodifiedSince);
    }
    Call<ResponseBody> call = service.removeNodes(poolId, nodeRemoveParameter, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, ifMatch, ifNoneMatch, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<Void>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                serviceCallback.success(removeNodesDelegate(response));
            } catch (BatchErrorException | IOException exception) {
                serviceCallback.failure(exception);
            }
        }
    });
    return serviceCall;
}
Also used : ServiceCall(com.microsoft.rest.ServiceCall) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123)

Example 98 with Callback

use of okhttp3.Callback in project azure-sdk-for-java by Azure.

the class PoolsImpl method patchAsync.

/**
     * Updates the properties of a pool.
     *
     * @param poolId The id of the pool to update.
     * @param poolPatchParameter The parameters for the request.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if callback is null
     * @return the {@link Call} object
     */
public ServiceCall patchAsync(String poolId, PoolPatchParameter poolPatchParameter, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (poolId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter poolId is required and cannot be null."));
        return null;
    }
    if (poolPatchParameter == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter poolPatchParameter is required and cannot be null."));
        return null;
    }
    if (this.client.apiVersion() == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
        return null;
    }
    Validator.validate(poolPatchParameter, serviceCallback);
    final PoolPatchOptions poolPatchOptions = null;
    Integer timeout = null;
    String clientRequestId = null;
    Boolean returnClientRequestId = null;
    DateTime ocpDate = null;
    String ifMatch = null;
    String ifNoneMatch = null;
    DateTime ifModifiedSince = null;
    DateTime ifUnmodifiedSince = null;
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    DateTimeRfc1123 ifModifiedSinceConverted = null;
    if (ifModifiedSince != null) {
        ifModifiedSinceConverted = new DateTimeRfc1123(ifModifiedSince);
    }
    DateTimeRfc1123 ifUnmodifiedSinceConverted = null;
    if (ifUnmodifiedSince != null) {
        ifUnmodifiedSinceConverted = new DateTimeRfc1123(ifUnmodifiedSince);
    }
    Call<ResponseBody> call = service.patch(poolId, poolPatchParameter, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, ifMatch, ifNoneMatch, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<Void>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                serviceCallback.success(patchDelegate(response));
            } catch (BatchErrorException | IOException exception) {
                serviceCallback.failure(exception);
            }
        }
    });
    return serviceCall;
}
Also used : ServiceCall(com.microsoft.rest.ServiceCall) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123) PoolPatchOptions(com.microsoft.azure.batch.protocol.models.PoolPatchOptions)

Example 99 with Callback

use of okhttp3.Callback in project azure-sdk-for-java by Azure.

the class PoolsImpl method deleteAsync.

/**
     * Deletes a pool from the specified account.
     *
     * @param poolId The id of the pool to delete.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if callback is null
     * @return the {@link Call} object
     */
public ServiceCall deleteAsync(String poolId, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (poolId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter poolId is required and cannot be null."));
        return null;
    }
    if (this.client.apiVersion() == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
        return null;
    }
    final PoolDeleteOptions poolDeleteOptions = null;
    Integer timeout = null;
    String clientRequestId = null;
    Boolean returnClientRequestId = null;
    DateTime ocpDate = null;
    String ifMatch = null;
    String ifNoneMatch = null;
    DateTime ifModifiedSince = null;
    DateTime ifUnmodifiedSince = null;
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    DateTimeRfc1123 ifModifiedSinceConverted = null;
    if (ifModifiedSince != null) {
        ifModifiedSinceConverted = new DateTimeRfc1123(ifModifiedSince);
    }
    DateTimeRfc1123 ifUnmodifiedSinceConverted = null;
    if (ifUnmodifiedSince != null) {
        ifUnmodifiedSinceConverted = new DateTimeRfc1123(ifUnmodifiedSince);
    }
    Call<ResponseBody> call = service.delete(poolId, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, ifMatch, ifNoneMatch, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<Void>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                serviceCallback.success(deleteDelegate(response));
            } catch (BatchErrorException | IOException exception) {
                serviceCallback.failure(exception);
            }
        }
    });
    return serviceCall;
}
Also used : ServiceCall(com.microsoft.rest.ServiceCall) PoolDeleteOptions(com.microsoft.azure.batch.protocol.models.PoolDeleteOptions) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123)

Example 100 with Callback

use of okhttp3.Callback in project azure-sdk-for-java by Azure.

the class PoolsImpl method updatePropertiesAsync.

/**
     * Updates the properties of a pool.
     *
     * @param poolId The id of the pool to update.
     * @param poolUpdatePropertiesParameter The parameters for the request.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if callback is null
     * @return the {@link Call} object
     */
public ServiceCall updatePropertiesAsync(String poolId, PoolUpdatePropertiesParameter poolUpdatePropertiesParameter, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (poolId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter poolId is required and cannot be null."));
        return null;
    }
    if (poolUpdatePropertiesParameter == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter poolUpdatePropertiesParameter is required and cannot be null."));
        return null;
    }
    if (this.client.apiVersion() == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
        return null;
    }
    Validator.validate(poolUpdatePropertiesParameter, serviceCallback);
    final PoolUpdatePropertiesOptions poolUpdatePropertiesOptions = null;
    Integer timeout = null;
    String clientRequestId = null;
    Boolean returnClientRequestId = null;
    DateTime ocpDate = null;
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.updateProperties(poolId, poolUpdatePropertiesParameter, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<Void>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                serviceCallback.success(updatePropertiesDelegate(response));
            } catch (BatchErrorException | IOException exception) {
                serviceCallback.failure(exception);
            }
        }
    });
    return serviceCall;
}
Also used : ServiceCall(com.microsoft.rest.ServiceCall) PoolUpdatePropertiesOptions(com.microsoft.azure.batch.protocol.models.PoolUpdatePropertiesOptions) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123)

Aggregations

ResponseBody (okhttp3.ResponseBody)248 Response (okhttp3.Response)214 Request (okhttp3.Request)208 IOException (java.io.IOException)203 Callback (okhttp3.Callback)172 DateTimeRfc1123 (com.microsoft.rest.DateTimeRfc1123)166 Call (okhttp3.Call)166 DateTime (org.joda.time.DateTime)166 ServiceCall (com.microsoft.rest.ServiceCall)140 Test (org.junit.Test)119 List (java.util.List)101 Call (retrofit2.Call)87 MockResponse (okhttp3.mockwebserver.MockResponse)72 RequestBody (okhttp3.RequestBody)62 OkHttpClient (okhttp3.OkHttpClient)61 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)57 GsonBuilder (com.google.gson.GsonBuilder)53 Retrofit (retrofit2.Retrofit)53 PagedList (com.microsoft.azure.PagedList)52 ServiceResponseWithHeaders (com.microsoft.rest.ServiceResponseWithHeaders)52