Search in sources :

Example 66 with Callback

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

the class TasksImpl method updateAsync.

/**
     * Updates the properties of the specified task.
     *
     * @param jobId The id of the job containing the task.
     * @param taskId The id of the task to update.
     * @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 updateAsync(String jobId, String taskId, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (jobId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter jobId is required and cannot be null."));
        return null;
    }
    if (taskId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter taskId 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 TaskConstraints constraints = null;
    final TaskUpdateOptions taskUpdateOptions = 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;
    TaskUpdateParameter taskUpdateParameter = new TaskUpdateParameter();
    taskUpdateParameter.withConstraints(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.update(jobId, taskId, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, ifMatch, ifNoneMatch, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, taskUpdateParameter, 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(updateDelegate(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) TaskUpdateOptions(com.microsoft.azure.batch.protocol.models.TaskUpdateOptions) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123) TaskConstraints(com.microsoft.azure.batch.protocol.models.TaskConstraints) TaskUpdateParameter(com.microsoft.azure.batch.protocol.models.TaskUpdateParameter)

Example 67 with Callback

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

the class TasksImpl method addCollectionAsync.

/**
     * Adds a collection of tasks to the specified job.
     *
     * @param jobId The id of the job to which the task collection is to be added.
     * @param value The collection of tasks to add.
     * @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 addCollectionAsync(String jobId, List<TaskAddParameter> value, final ServiceCallback<TaskAddCollectionResult> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (jobId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter jobId 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;
    }
    if (value == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null."));
        return null;
    }
    Validator.validate(value, serviceCallback);
    final TaskAddCollectionOptions taskAddCollectionOptions = null;
    Integer timeout = null;
    String clientRequestId = null;
    Boolean returnClientRequestId = null;
    DateTime ocpDate = null;
    TaskAddCollectionParameter taskCollection = new TaskAddCollectionParameter();
    taskCollection.withValue(value);
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.addCollection(jobId, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, taskCollection, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<TaskAddCollectionResult>(serviceCallback) {

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

Example 68 with Callback

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

the class TasksImpl method addAsync.

/**
     * Adds a task to the specified job.
     *
     * @param jobId The id of the job to which the task is to be added.
     * @param task The task to be added.
     * @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 addAsync(String jobId, TaskAddParameter task, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (jobId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter jobId is required and cannot be null."));
        return null;
    }
    if (task == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter task 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(task, serviceCallback);
    final TaskAddOptions taskAddOptions = 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.add(jobId, task, 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(addDelegate(response));
            } catch (BatchErrorException | IOException exception) {
                serviceCallback.failure(exception);
            }
        }
    });
    return serviceCall;
}
Also used : ServiceCall(com.microsoft.rest.ServiceCall) TaskAddOptions(com.microsoft.azure.batch.protocol.models.TaskAddOptions) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123)

Example 69 with Callback

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

the class TasksImpl method addAsync.

/**
     * Adds a task to the specified job.
     *
     * @param jobId The id of the job to which the task is to be added.
     * @param task The task to be added.
     * @param taskAddOptions 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 addAsync(String jobId, TaskAddParameter task, TaskAddOptions taskAddOptions, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (jobId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter jobId is required and cannot be null."));
        return null;
    }
    if (task == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter task 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(task, serviceCallback);
    Validator.validate(taskAddOptions, serviceCallback);
    Integer timeout = null;
    if (taskAddOptions != null) {
        timeout = taskAddOptions.timeout();
    }
    String clientRequestId = null;
    if (taskAddOptions != null) {
        clientRequestId = taskAddOptions.clientRequestId();
    }
    Boolean returnClientRequestId = null;
    if (taskAddOptions != null) {
        returnClientRequestId = taskAddOptions.returnClientRequestId();
    }
    DateTime ocpDate = null;
    if (taskAddOptions != null) {
        ocpDate = taskAddOptions.ocpDate();
    }
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.add(jobId, task, 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(addDelegate(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 70 with Callback

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

the class PoolsImpl method resizeAsync.

/**
     * Changes the number of compute nodes that are assigned to a pool.
     *
     * @param poolId The id of the pool to resize.
     * @param poolResizeParameter 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 resizeAsync(String poolId, PoolResizeParameter poolResizeParameter, 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 (poolResizeParameter == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter poolResizeParameter 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(poolResizeParameter, serviceCallback);
    final PoolResizeOptions poolResizeOptions = 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.resize(poolId, poolResizeParameter, 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(resizeDelegate(response));
            } catch (BatchErrorException | IOException exception) {
                serviceCallback.failure(exception);
            }
        }
    });
    return serviceCall;
}
Also used : ServiceCall(com.microsoft.rest.ServiceCall) PoolResizeOptions(com.microsoft.azure.batch.protocol.models.PoolResizeOptions) 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