Search in sources :

Example 81 with ServiceCall

use of com.microsoft.rest.ServiceCall 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 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, 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);
    final PoolRemoveNodesOptions poolRemoveNodesOptions = 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.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) PoolRemoveNodesOptions(com.microsoft.azure.batch.protocol.models.PoolRemoveNodesOptions)

Example 82 with ServiceCall

use of com.microsoft.rest.ServiceCall in project azure-sdk-for-java by Azure.

the class PoolsImpl method disableAutoScaleAsync.

/**
     * Disables automatic scaling for a pool.
     *
     * @param poolId The id of the pool on which to disable automatic scaling.
     * @param poolDisableAutoScaleOptions 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 disableAutoScaleAsync(String poolId, PoolDisableAutoScaleOptions poolDisableAutoScaleOptions, 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;
    }
    Validator.validate(poolDisableAutoScaleOptions, serviceCallback);
    Integer timeout = null;
    if (poolDisableAutoScaleOptions != null) {
        timeout = poolDisableAutoScaleOptions.timeout();
    }
    String clientRequestId = null;
    if (poolDisableAutoScaleOptions != null) {
        clientRequestId = poolDisableAutoScaleOptions.clientRequestId();
    }
    Boolean returnClientRequestId = null;
    if (poolDisableAutoScaleOptions != null) {
        returnClientRequestId = poolDisableAutoScaleOptions.returnClientRequestId();
    }
    DateTime ocpDate = null;
    if (poolDisableAutoScaleOptions != null) {
        ocpDate = poolDisableAutoScaleOptions.ocpDate();
    }
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.disableAutoScale(poolId, 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(disableAutoScaleDelegate(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 83 with ServiceCall

use of com.microsoft.rest.ServiceCall in project azure-sdk-for-java by Azure.

the class PoolsImpl method addAsync.

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

use of com.microsoft.rest.ServiceCall 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 poolPatchOptions 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 patchAsync(String poolId, PoolPatchParameter poolPatchParameter, PoolPatchOptions poolPatchOptions, 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);
    Validator.validate(poolPatchOptions, serviceCallback);
    Integer timeout = null;
    if (poolPatchOptions != null) {
        timeout = poolPatchOptions.timeout();
    }
    String clientRequestId = null;
    if (poolPatchOptions != null) {
        clientRequestId = poolPatchOptions.clientRequestId();
    }
    Boolean returnClientRequestId = null;
    if (poolPatchOptions != null) {
        returnClientRequestId = poolPatchOptions.returnClientRequestId();
    }
    DateTime ocpDate = null;
    if (poolPatchOptions != null) {
        ocpDate = poolPatchOptions.ocpDate();
    }
    String ifMatch = null;
    if (poolPatchOptions != null) {
        ifMatch = poolPatchOptions.ifMatch();
    }
    String ifNoneMatch = null;
    if (poolPatchOptions != null) {
        ifNoneMatch = poolPatchOptions.ifNoneMatch();
    }
    DateTime ifModifiedSince = null;
    if (poolPatchOptions != null) {
        ifModifiedSince = poolPatchOptions.ifModifiedSince();
    }
    DateTime ifUnmodifiedSince = null;
    if (poolPatchOptions != null) {
        ifUnmodifiedSince = poolPatchOptions.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.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)

Example 85 with ServiceCall

use of com.microsoft.rest.ServiceCall in project azure-sdk-for-java by Azure.

the class PoolsImpl method listAsync.

/**
     * Lists all of the pools in 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<CloudPool> 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 PoolListOptions poolListOptions = null;
    String filter = null;
    String select = null;
    String expand = 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, expand, maxResults, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<List<CloudPool>>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                ServiceResponseWithHeaders<PageImpl<CloudPool>, PoolListHeaders> 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 : PoolListOptions(com.microsoft.azure.batch.protocol.models.PoolListOptions) ServiceCall(com.microsoft.rest.ServiceCall) DateTime(org.joda.time.DateTime) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123) CloudPool(com.microsoft.azure.batch.protocol.models.CloudPool) List(java.util.List) PagedList(com.microsoft.azure.PagedList)

Aggregations

DateTimeRfc1123 (com.microsoft.rest.DateTimeRfc1123)148 ServiceCall (com.microsoft.rest.ServiceCall)148 DateTime (org.joda.time.DateTime)148 ResponseBody (okhttp3.ResponseBody)140 PagedList (com.microsoft.azure.PagedList)26 ServiceResponseWithHeaders (com.microsoft.rest.ServiceResponseWithHeaders)26 List (java.util.List)26 CloudJob (com.microsoft.azure.batch.protocol.models.CloudJob)6 InputStream (java.io.InputStream)6 ApplicationSummary (com.microsoft.azure.batch.protocol.models.ApplicationSummary)4 Certificate (com.microsoft.azure.batch.protocol.models.Certificate)4 CloudJobSchedule (com.microsoft.azure.batch.protocol.models.CloudJobSchedule)4 CloudPool (com.microsoft.azure.batch.protocol.models.CloudPool)4 CloudTask (com.microsoft.azure.batch.protocol.models.CloudTask)4 ComputeNode (com.microsoft.azure.batch.protocol.models.ComputeNode)4 NodeFile (com.microsoft.azure.batch.protocol.models.NodeFile)3 AutoScaleRun (com.microsoft.azure.batch.protocol.models.AutoScaleRun)2 CloudTaskListSubtasksResult (com.microsoft.azure.batch.protocol.models.CloudTaskListSubtasksResult)2 ComputeNodeGetRemoteLoginSettingsResult (com.microsoft.azure.batch.protocol.models.ComputeNodeGetRemoteLoginSettingsResult)2 JobDisableParameter (com.microsoft.azure.batch.protocol.models.JobDisableParameter)2