Search in sources :

Example 51 with Callback

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

the class AccountsImpl method listNodeAgentSkusAsync.

/**
     * Lists all node agent SKUs supported by the Azure Batch service.
     *
     * @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 listNodeAgentSkusAsync(final ListOperationCallback<NodeAgentSku> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (this.client.apiVersion() == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
        return null;
    }
    final AccountListNodeAgentSkusOptions accountListNodeAgentSkusOptions = null;
    String filter = null;
    Integer maxResults = 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.listNodeAgentSkus(this.client.apiVersion(), this.client.acceptLanguage(), filter, maxResults, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<List<NodeAgentSku>>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                ServiceResponseWithHeaders<PageImpl<NodeAgentSku>, AccountListNodeAgentSkusHeaders> result = listNodeAgentSkusDelegate(response);
                serviceCallback.load(result.getBody().getItems());
                if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) {
                    listNodeAgentSkusNextAsync(result.getBody().getNextPageLink(), null, serviceCall, serviceCallback);
                } else {
                    serviceCallback.success(new ServiceResponseWithHeaders<>(serviceCallback.get(), result.getHeaders(), result.getResponse()));
                }
            } catch (BatchErrorException | IOException exception) {
                serviceCallback.failure(exception);
            }
        }
    });
    return serviceCall;
}
Also used : ServiceCall(com.microsoft.rest.ServiceCall) AccountListNodeAgentSkusOptions(com.microsoft.azure.batch.protocol.models.AccountListNodeAgentSkusOptions) DateTime(org.joda.time.DateTime) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123) PagedList(com.microsoft.azure.PagedList) List(java.util.List) NodeAgentSku(com.microsoft.azure.batch.protocol.models.NodeAgentSku)

Example 52 with Callback

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

the class JobSchedulesImpl method getAsync.

/**
     * Gets information about the specified job schedule.
     *
     * @param jobScheduleId The id of the job schedule to get.
     * @param jobScheduleGetOptions 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 getAsync(String jobScheduleId, JobScheduleGetOptions jobScheduleGetOptions, final ServiceCallback<CloudJobSchedule> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (jobScheduleId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter jobScheduleId 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(jobScheduleGetOptions, serviceCallback);
    String select = null;
    if (jobScheduleGetOptions != null) {
        select = jobScheduleGetOptions.select();
    }
    String expand = null;
    if (jobScheduleGetOptions != null) {
        expand = jobScheduleGetOptions.expand();
    }
    Integer timeout = null;
    if (jobScheduleGetOptions != null) {
        timeout = jobScheduleGetOptions.timeout();
    }
    String clientRequestId = null;
    if (jobScheduleGetOptions != null) {
        clientRequestId = jobScheduleGetOptions.clientRequestId();
    }
    Boolean returnClientRequestId = null;
    if (jobScheduleGetOptions != null) {
        returnClientRequestId = jobScheduleGetOptions.returnClientRequestId();
    }
    DateTime ocpDate = null;
    if (jobScheduleGetOptions != null) {
        ocpDate = jobScheduleGetOptions.ocpDate();
    }
    String ifMatch = null;
    if (jobScheduleGetOptions != null) {
        ifMatch = jobScheduleGetOptions.ifMatch();
    }
    String ifNoneMatch = null;
    if (jobScheduleGetOptions != null) {
        ifNoneMatch = jobScheduleGetOptions.ifNoneMatch();
    }
    DateTime ifModifiedSince = null;
    if (jobScheduleGetOptions != null) {
        ifModifiedSince = jobScheduleGetOptions.ifModifiedSince();
    }
    DateTime ifUnmodifiedSince = null;
    if (jobScheduleGetOptions != null) {
        ifUnmodifiedSince = jobScheduleGetOptions.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.get(jobScheduleId, 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<CloudJobSchedule>(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 : ServiceCall(com.microsoft.rest.ServiceCall) CloudJobSchedule(com.microsoft.azure.batch.protocol.models.CloudJobSchedule) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123)

Example 53 with Callback

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

the class JobSchedulesImpl method addAsync.

/**
     * Adds a job schedule to the specified account.
     *
     * @param cloudJobSchedule The job schedule 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(JobScheduleAddParameter cloudJobSchedule, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (cloudJobSchedule == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter cloudJobSchedule 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(cloudJobSchedule, serviceCallback);
    final JobScheduleAddOptions jobScheduleAddOptions = 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(cloudJobSchedule, 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 : JobScheduleAddOptions(com.microsoft.azure.batch.protocol.models.JobScheduleAddOptions) ServiceCall(com.microsoft.rest.ServiceCall) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123)

Example 54 with Callback

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

the class JobSchedulesImpl method patchAsync.

/**
     * Updates the properties of the specified job schedule.
     *
     * @param jobScheduleId The id of the job schedule to update.
     * @param jobSchedulePatchParameter 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 jobScheduleId, JobSchedulePatchParameter jobSchedulePatchParameter, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (jobScheduleId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter jobScheduleId is required and cannot be null."));
        return null;
    }
    if (jobSchedulePatchParameter == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter jobSchedulePatchParameter 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(jobSchedulePatchParameter, serviceCallback);
    final JobSchedulePatchOptions jobSchedulePatchOptions = 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(jobScheduleId, jobSchedulePatchParameter, 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) JobSchedulePatchOptions(com.microsoft.azure.batch.protocol.models.JobSchedulePatchOptions) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123)

Example 55 with Callback

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

the class JobSchedulesImpl method addAsync.

/**
     * Adds a job schedule to the specified account.
     *
     * @param cloudJobSchedule The job schedule to be added.
     * @param jobScheduleAddOptions 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(JobScheduleAddParameter cloudJobSchedule, JobScheduleAddOptions jobScheduleAddOptions, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (cloudJobSchedule == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter cloudJobSchedule 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(cloudJobSchedule, serviceCallback);
    Validator.validate(jobScheduleAddOptions, serviceCallback);
    Integer timeout = null;
    if (jobScheduleAddOptions != null) {
        timeout = jobScheduleAddOptions.timeout();
    }
    String clientRequestId = null;
    if (jobScheduleAddOptions != null) {
        clientRequestId = jobScheduleAddOptions.clientRequestId();
    }
    Boolean returnClientRequestId = null;
    if (jobScheduleAddOptions != null) {
        returnClientRequestId = jobScheduleAddOptions.returnClientRequestId();
    }
    DateTime ocpDate = null;
    if (jobScheduleAddOptions != null) {
        ocpDate = jobScheduleAddOptions.ocpDate();
    }
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.add(cloudJobSchedule, 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)

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