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;
}
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;
}
Aggregations