Search in sources :

Example 96 with ResponseBody

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

the class ComputeNodesImpl method listNextAsync.

/**
     * Lists the compute nodes in the specified pool.
     *
     * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @param serviceCall the ServiceCall object tracking the Retrofit calls
     * @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 listNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback<ComputeNode> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (nextPageLink == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."));
        return null;
    }
    final ComputeNodeListNextOptions computeNodeListNextOptions = null;
    String clientRequestId = null;
    Boolean returnClientRequestId = null;
    DateTime ocpDate = null;
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.listNext(nextPageLink, this.client.acceptLanguage(), clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
    serviceCall.newCall(call);
    call.enqueue(new ServiceResponseCallback<List<ComputeNode>>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                ServiceResponseWithHeaders<PageImpl<ComputeNode>, ComputeNodeListHeaders> result = listNextDelegate(response);
                serviceCallback.load(result.getBody().getItems());
                if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) {
                    listNextAsync(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 : ComputeNode(com.microsoft.azure.batch.protocol.models.ComputeNode) DateTime(org.joda.time.DateTime) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) ResponseBody(okhttp3.ResponseBody) ComputeNodeListNextOptions(com.microsoft.azure.batch.protocol.models.ComputeNodeListNextOptions) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123) List(java.util.List) PagedList(com.microsoft.azure.PagedList)

Example 97 with ResponseBody

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

the class ComputeNodesImpl method enableScheduling.

/**
     * Enables task scheduling on the specified compute node.
     *
     * @param poolId The id of the pool that contains the compute node.
     * @param nodeId The id of the compute node on which you want to enable task scheduling.
     * @param computeNodeEnableSchedulingOptions Additional parameters for the operation
     * @throws BatchErrorException exception thrown from REST call
     * @throws IOException exception thrown from serialization/deserialization
     * @throws IllegalArgumentException exception thrown from invalid parameters
     * @return the {@link ServiceResponseWithHeaders} object if successful.
     */
public ServiceResponseWithHeaders<Void, ComputeNodeEnableSchedulingHeaders> enableScheduling(String poolId, String nodeId, ComputeNodeEnableSchedulingOptions computeNodeEnableSchedulingOptions) throws BatchErrorException, IOException, IllegalArgumentException {
    if (poolId == null) {
        throw new IllegalArgumentException("Parameter poolId is required and cannot be null.");
    }
    if (nodeId == null) {
        throw new IllegalArgumentException("Parameter nodeId is required and cannot be null.");
    }
    if (this.client.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
    }
    Validator.validate(computeNodeEnableSchedulingOptions);
    Integer timeout = null;
    if (computeNodeEnableSchedulingOptions != null) {
        timeout = computeNodeEnableSchedulingOptions.timeout();
    }
    String clientRequestId = null;
    if (computeNodeEnableSchedulingOptions != null) {
        clientRequestId = computeNodeEnableSchedulingOptions.clientRequestId();
    }
    Boolean returnClientRequestId = null;
    if (computeNodeEnableSchedulingOptions != null) {
        returnClientRequestId = computeNodeEnableSchedulingOptions.returnClientRequestId();
    }
    DateTime ocpDate = null;
    if (computeNodeEnableSchedulingOptions != null) {
        ocpDate = computeNodeEnableSchedulingOptions.ocpDate();
    }
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.enableScheduling(poolId, nodeId, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
    return enableSchedulingDelegate(call.execute());
}
Also used : DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody)

Example 98 with ResponseBody

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

the class ComputeNodesImpl method addUser.

/**
     * Adds a user account to the specified compute node.
     *
     * @param poolId The id of the pool that contains the compute node.
     * @param nodeId The id of the machine on which you want to create a user account.
     * @param user The user account to be created.
     * @throws BatchErrorException exception thrown from REST call
     * @throws IOException exception thrown from serialization/deserialization
     * @throws IllegalArgumentException exception thrown from invalid parameters
     * @return the {@link ServiceResponseWithHeaders} object if successful.
     */
public ServiceResponseWithHeaders<Void, ComputeNodeAddUserHeaders> addUser(String poolId, String nodeId, ComputeNodeUser user) throws BatchErrorException, IOException, IllegalArgumentException {
    if (poolId == null) {
        throw new IllegalArgumentException("Parameter poolId is required and cannot be null.");
    }
    if (nodeId == null) {
        throw new IllegalArgumentException("Parameter nodeId is required and cannot be null.");
    }
    if (user == null) {
        throw new IllegalArgumentException("Parameter user is required and cannot be null.");
    }
    if (this.client.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
    }
    Validator.validate(user);
    final ComputeNodeAddUserOptions computeNodeAddUserOptions = 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.addUser(poolId, nodeId, user, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
    return addUserDelegate(call.execute());
}
Also used : DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123) ComputeNodeAddUserOptions(com.microsoft.azure.batch.protocol.models.ComputeNodeAddUserOptions) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody)

Example 99 with ResponseBody

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

the class CertificatesImpl method getAsync.

/**
     * Gets information about the specified certificate.
     *
     * @param thumbprintAlgorithm The algorithm used to derive the thumbprint parameter. This must be sha1.
     * @param thumbprint The thumbprint of the certificate to get.
     * @param certificateGetOptions 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 thumbprintAlgorithm, String thumbprint, CertificateGetOptions certificateGetOptions, final ServiceCallback<Certificate> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (thumbprintAlgorithm == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter thumbprintAlgorithm is required and cannot be null."));
        return null;
    }
    if (thumbprint == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter thumbprint 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(certificateGetOptions, serviceCallback);
    String select = null;
    if (certificateGetOptions != null) {
        select = certificateGetOptions.select();
    }
    Integer timeout = null;
    if (certificateGetOptions != null) {
        timeout = certificateGetOptions.timeout();
    }
    String clientRequestId = null;
    if (certificateGetOptions != null) {
        clientRequestId = certificateGetOptions.clientRequestId();
    }
    Boolean returnClientRequestId = null;
    if (certificateGetOptions != null) {
        returnClientRequestId = certificateGetOptions.returnClientRequestId();
    }
    DateTime ocpDate = null;
    if (certificateGetOptions != null) {
        ocpDate = certificateGetOptions.ocpDate();
    }
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.get(thumbprintAlgorithm, thumbprint, this.client.apiVersion(), this.client.acceptLanguage(), select, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<Certificate>(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) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123) Certificate(com.microsoft.azure.batch.protocol.models.Certificate)

Example 100 with ResponseBody

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

the class CertificatesImpl method listAsync.

/**
     * Lists all of the certificates that have been added to the specified account.
     *
     * @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 listAsync(final ListOperationCallback<Certificate> 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 CertificateListOptions certificateListOptions = null;
    String filter = null;
    String select = 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.list(this.client.apiVersion(), this.client.acceptLanguage(), filter, select, maxResults, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<List<Certificate>>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                ServiceResponseWithHeaders<PageImpl<Certificate>, CertificateListHeaders> result = listDelegate(response);
                serviceCallback.load(result.getBody().getItems());
                if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) {
                    listNextAsync(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) DateTime(org.joda.time.DateTime) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) ResponseBody(okhttp3.ResponseBody) CertificateListOptions(com.microsoft.azure.batch.protocol.models.CertificateListOptions) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123) PagedList(com.microsoft.azure.PagedList) List(java.util.List) Certificate(com.microsoft.azure.batch.protocol.models.Certificate)

Aggregations

ResponseBody (okhttp3.ResponseBody)584 DateTimeRfc1123 (com.microsoft.rest.DateTimeRfc1123)332 DateTime (org.joda.time.DateTime)332 ServiceCall (com.microsoft.rest.ServiceCall)140 Test (org.junit.Test)123 Request (okhttp3.Request)112 Observable (rx.Observable)97 Response (retrofit2.Response)94 ServiceResponse (com.microsoft.rest.ServiceResponse)92 PagedList (com.microsoft.azure.PagedList)80 ServiceResponseWithHeaders (com.microsoft.rest.ServiceResponseWithHeaders)78 List (java.util.List)64 IOException (java.io.IOException)33 Response (okhttp3.Response)33 Buffer (okio.Buffer)33 RequestBody (okhttp3.RequestBody)31 PageImpl (com.microsoft.azure.batch.protocol.models.PageImpl)26 MockResponse (okhttp3.mockwebserver.MockResponse)24 InputStream (java.io.InputStream)19 MultipartBody (okhttp3.MultipartBody)16