Search in sources :

Example 1 with AutoScaleRun

use of com.microsoft.azure.batch.protocol.models.AutoScaleRun in project azure-sdk-for-java by Azure.

the class PoolsImpl method evaluateAutoScaleAsync.

/**
     * Gets the result of evaluating an automatic scaling formula on the pool.
     *
     * @param poolId The id of the pool on which to evaluate the automatic scaling formula.
     * @param autoScaleFormula A formula for the desired number of compute nodes in the pool.
     * @param poolEvaluateAutoScaleOptions 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 evaluateAutoScaleAsync(String poolId, String autoScaleFormula, PoolEvaluateAutoScaleOptions poolEvaluateAutoScaleOptions, final ServiceCallback<AutoScaleRun> 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;
    }
    if (autoScaleFormula == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter autoScaleFormula is required and cannot be null."));
        return null;
    }
    Validator.validate(poolEvaluateAutoScaleOptions, serviceCallback);
    Integer timeout = null;
    if (poolEvaluateAutoScaleOptions != null) {
        timeout = poolEvaluateAutoScaleOptions.timeout();
    }
    String clientRequestId = null;
    if (poolEvaluateAutoScaleOptions != null) {
        clientRequestId = poolEvaluateAutoScaleOptions.clientRequestId();
    }
    Boolean returnClientRequestId = null;
    if (poolEvaluateAutoScaleOptions != null) {
        returnClientRequestId = poolEvaluateAutoScaleOptions.returnClientRequestId();
    }
    DateTime ocpDate = null;
    if (poolEvaluateAutoScaleOptions != null) {
        ocpDate = poolEvaluateAutoScaleOptions.ocpDate();
    }
    PoolEvaluateAutoScaleParameter poolEvaluateAutoScaleParameter = new PoolEvaluateAutoScaleParameter();
    poolEvaluateAutoScaleParameter.withAutoScaleFormula(autoScaleFormula);
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.evaluateAutoScale(poolId, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, poolEvaluateAutoScaleParameter, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<AutoScaleRun>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                serviceCallback.success(evaluateAutoScaleDelegate(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) AutoScaleRun(com.microsoft.azure.batch.protocol.models.AutoScaleRun) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123) PoolEvaluateAutoScaleParameter(com.microsoft.azure.batch.protocol.models.PoolEvaluateAutoScaleParameter)

Example 2 with AutoScaleRun

use of com.microsoft.azure.batch.protocol.models.AutoScaleRun in project azure-sdk-for-java by Azure.

the class PoolsImpl method evaluateAutoScaleAsync.

/**
     * Gets the result of evaluating an automatic scaling formula on the pool.
     *
     * @param poolId The id of the pool on which to evaluate the automatic scaling formula.
     * @param autoScaleFormula A formula for the desired number of compute nodes in the pool.
     * @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 evaluateAutoScaleAsync(String poolId, String autoScaleFormula, final ServiceCallback<AutoScaleRun> 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;
    }
    if (autoScaleFormula == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter autoScaleFormula is required and cannot be null."));
        return null;
    }
    final PoolEvaluateAutoScaleOptions poolEvaluateAutoScaleOptions = null;
    Integer timeout = null;
    String clientRequestId = null;
    Boolean returnClientRequestId = null;
    DateTime ocpDate = null;
    PoolEvaluateAutoScaleParameter poolEvaluateAutoScaleParameter = new PoolEvaluateAutoScaleParameter();
    poolEvaluateAutoScaleParameter.withAutoScaleFormula(autoScaleFormula);
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.evaluateAutoScale(poolId, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, poolEvaluateAutoScaleParameter, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<AutoScaleRun>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                serviceCallback.success(evaluateAutoScaleDelegate(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) AutoScaleRun(com.microsoft.azure.batch.protocol.models.AutoScaleRun) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123) PoolEvaluateAutoScaleOptions(com.microsoft.azure.batch.protocol.models.PoolEvaluateAutoScaleOptions) PoolEvaluateAutoScaleParameter(com.microsoft.azure.batch.protocol.models.PoolEvaluateAutoScaleParameter)

Aggregations

AutoScaleRun (com.microsoft.azure.batch.protocol.models.AutoScaleRun)2 PoolEvaluateAutoScaleParameter (com.microsoft.azure.batch.protocol.models.PoolEvaluateAutoScaleParameter)2 DateTimeRfc1123 (com.microsoft.rest.DateTimeRfc1123)2 ServiceCall (com.microsoft.rest.ServiceCall)2 ResponseBody (okhttp3.ResponseBody)2 DateTime (org.joda.time.DateTime)2 PoolEvaluateAutoScaleOptions (com.microsoft.azure.batch.protocol.models.PoolEvaluateAutoScaleOptions)1