use of com.microsoft.rest.ServiceResponseWithHeaders in project azure-sdk-for-java by Azure.
the class PoolsImpl method listPoolUsageMetrics.
/**
* Lists the usage metrics, aggregated by pool across individual time intervals, for the specified account.
*
* @param poolListPoolUsageMetricsOptions 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 List<PoolUsageMetrics> object wrapped in {@link ServiceResponseWithHeaders} if successful.
*/
public ServiceResponseWithHeaders<PagedList<PoolUsageMetrics>, PoolListPoolUsageMetricsHeaders> listPoolUsageMetrics(final PoolListPoolUsageMetricsOptions poolListPoolUsageMetricsOptions) throws BatchErrorException, IOException, IllegalArgumentException {
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
Validator.validate(poolListPoolUsageMetricsOptions);
DateTime startTime = null;
if (poolListPoolUsageMetricsOptions != null) {
startTime = poolListPoolUsageMetricsOptions.startTime();
}
DateTime endTime = null;
if (poolListPoolUsageMetricsOptions != null) {
endTime = poolListPoolUsageMetricsOptions.endTime();
}
String filter = null;
if (poolListPoolUsageMetricsOptions != null) {
filter = poolListPoolUsageMetricsOptions.filter();
}
Integer maxResults = null;
if (poolListPoolUsageMetricsOptions != null) {
maxResults = poolListPoolUsageMetricsOptions.maxResults();
}
Integer timeout = null;
if (poolListPoolUsageMetricsOptions != null) {
timeout = poolListPoolUsageMetricsOptions.timeout();
}
String clientRequestId = null;
if (poolListPoolUsageMetricsOptions != null) {
clientRequestId = poolListPoolUsageMetricsOptions.clientRequestId();
}
Boolean returnClientRequestId = null;
if (poolListPoolUsageMetricsOptions != null) {
returnClientRequestId = poolListPoolUsageMetricsOptions.returnClientRequestId();
}
DateTime ocpDate = null;
if (poolListPoolUsageMetricsOptions != null) {
ocpDate = poolListPoolUsageMetricsOptions.ocpDate();
}
DateTimeRfc1123 ocpDateConverted = null;
if (ocpDate != null) {
ocpDateConverted = new DateTimeRfc1123(ocpDate);
}
Call<ResponseBody> call = service.listPoolUsageMetrics(this.client.apiVersion(), this.client.acceptLanguage(), startTime, endTime, filter, maxResults, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
ServiceResponseWithHeaders<PageImpl<PoolUsageMetrics>, PoolListPoolUsageMetricsHeaders> response = listPoolUsageMetricsDelegate(call.execute());
PagedList<PoolUsageMetrics> result = new PagedList<PoolUsageMetrics>(response.getBody()) {
@Override
public Page<PoolUsageMetrics> nextPage(String nextPageLink) throws BatchErrorException, IOException {
PoolListPoolUsageMetricsNextOptions poolListPoolUsageMetricsNextOptions = null;
if (poolListPoolUsageMetricsOptions != null) {
poolListPoolUsageMetricsNextOptions = new PoolListPoolUsageMetricsNextOptions();
poolListPoolUsageMetricsNextOptions.withClientRequestId(poolListPoolUsageMetricsOptions.clientRequestId());
poolListPoolUsageMetricsNextOptions.withReturnClientRequestId(poolListPoolUsageMetricsOptions.returnClientRequestId());
poolListPoolUsageMetricsNextOptions.withOcpDate(poolListPoolUsageMetricsOptions.ocpDate());
}
return listPoolUsageMetricsNext(nextPageLink, poolListPoolUsageMetricsNextOptions).getBody();
}
};
return new ServiceResponseWithHeaders<>(result, response.getHeaders(), response.getResponse());
}
use of com.microsoft.rest.ServiceResponseWithHeaders in project azure-sdk-for-java by Azure.
the class PoolsImpl method listPoolUsageMetricsNextAsync.
/**
* Lists the usage metrics, aggregated by pool across individual time intervals, for the specified account.
*
* @param nextPageLink The NextLink from the previous successful call to List operation.
* @param poolListPoolUsageMetricsNextOptions Additional parameters for the 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 listPoolUsageMetricsNextAsync(final String nextPageLink, final PoolListPoolUsageMetricsNextOptions poolListPoolUsageMetricsNextOptions, final ServiceCall serviceCall, final ListOperationCallback<PoolUsageMetrics> 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;
}
Validator.validate(poolListPoolUsageMetricsNextOptions, serviceCallback);
String clientRequestId = null;
if (poolListPoolUsageMetricsNextOptions != null) {
clientRequestId = poolListPoolUsageMetricsNextOptions.clientRequestId();
}
Boolean returnClientRequestId = null;
if (poolListPoolUsageMetricsNextOptions != null) {
returnClientRequestId = poolListPoolUsageMetricsNextOptions.returnClientRequestId();
}
DateTime ocpDate = null;
if (poolListPoolUsageMetricsNextOptions != null) {
ocpDate = poolListPoolUsageMetricsNextOptions.ocpDate();
}
DateTimeRfc1123 ocpDateConverted = null;
if (ocpDate != null) {
ocpDateConverted = new DateTimeRfc1123(ocpDate);
}
Call<ResponseBody> call = service.listPoolUsageMetricsNext(nextPageLink, this.client.acceptLanguage(), clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
serviceCall.newCall(call);
call.enqueue(new ServiceResponseCallback<List<PoolUsageMetrics>>(serviceCallback) {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
try {
ServiceResponseWithHeaders<PageImpl<PoolUsageMetrics>, PoolListPoolUsageMetricsHeaders> result = listPoolUsageMetricsNextDelegate(response);
serviceCallback.load(result.getBody().getItems());
if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) {
listPoolUsageMetricsNextAsync(result.getBody().getNextPageLink(), poolListPoolUsageMetricsNextOptions, serviceCall, serviceCallback);
} else {
serviceCallback.success(new ServiceResponseWithHeaders<>(serviceCallback.get(), result.getHeaders(), result.getResponse()));
}
} catch (BatchErrorException | IOException exception) {
serviceCallback.failure(exception);
}
}
});
return serviceCall;
}
use of com.microsoft.rest.ServiceResponseWithHeaders in project azure-sdk-for-java by Azure.
the class PoolsImpl method listPoolUsageMetrics.
/**
* Lists the usage metrics, aggregated by pool across individual time intervals, for the specified account.
*
* @throws BatchErrorException exception thrown from REST call
* @throws IOException exception thrown from serialization/deserialization
* @throws IllegalArgumentException exception thrown from invalid parameters
* @return the List<PoolUsageMetrics> object wrapped in {@link ServiceResponseWithHeaders} if successful.
*/
public ServiceResponseWithHeaders<PagedList<PoolUsageMetrics>, PoolListPoolUsageMetricsHeaders> listPoolUsageMetrics() throws BatchErrorException, IOException, IllegalArgumentException {
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
final PoolListPoolUsageMetricsOptions poolListPoolUsageMetricsOptions = null;
DateTime startTime = null;
DateTime endTime = 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.listPoolUsageMetrics(this.client.apiVersion(), this.client.acceptLanguage(), startTime, endTime, filter, maxResults, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
ServiceResponseWithHeaders<PageImpl<PoolUsageMetrics>, PoolListPoolUsageMetricsHeaders> response = listPoolUsageMetricsDelegate(call.execute());
PagedList<PoolUsageMetrics> result = new PagedList<PoolUsageMetrics>(response.getBody()) {
@Override
public Page<PoolUsageMetrics> nextPage(String nextPageLink) throws BatchErrorException, IOException {
return listPoolUsageMetricsNext(nextPageLink, null).getBody();
}
};
return new ServiceResponseWithHeaders<>(result, response.getHeaders(), response.getResponse());
}
use of com.microsoft.rest.ServiceResponseWithHeaders in project azure-sdk-for-java by Azure.
the class PoolsImpl method list.
/**
* Lists all of the pools in the specified account.
*
* @param poolListOptions 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 List<CloudPool> object wrapped in {@link ServiceResponseWithHeaders} if successful.
*/
public ServiceResponseWithHeaders<PagedList<CloudPool>, PoolListHeaders> list(final PoolListOptions poolListOptions) throws BatchErrorException, IOException, IllegalArgumentException {
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
Validator.validate(poolListOptions);
String filter = null;
if (poolListOptions != null) {
filter = poolListOptions.filter();
}
String select = null;
if (poolListOptions != null) {
select = poolListOptions.select();
}
String expand = null;
if (poolListOptions != null) {
expand = poolListOptions.expand();
}
Integer maxResults = null;
if (poolListOptions != null) {
maxResults = poolListOptions.maxResults();
}
Integer timeout = null;
if (poolListOptions != null) {
timeout = poolListOptions.timeout();
}
String clientRequestId = null;
if (poolListOptions != null) {
clientRequestId = poolListOptions.clientRequestId();
}
Boolean returnClientRequestId = null;
if (poolListOptions != null) {
returnClientRequestId = poolListOptions.returnClientRequestId();
}
DateTime ocpDate = null;
if (poolListOptions != null) {
ocpDate = poolListOptions.ocpDate();
}
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());
ServiceResponseWithHeaders<PageImpl<CloudPool>, PoolListHeaders> response = listDelegate(call.execute());
PagedList<CloudPool> result = new PagedList<CloudPool>(response.getBody()) {
@Override
public Page<CloudPool> nextPage(String nextPageLink) throws BatchErrorException, IOException {
PoolListNextOptions poolListNextOptions = null;
if (poolListOptions != null) {
poolListNextOptions = new PoolListNextOptions();
poolListNextOptions.withClientRequestId(poolListOptions.clientRequestId());
poolListNextOptions.withReturnClientRequestId(poolListOptions.returnClientRequestId());
poolListNextOptions.withOcpDate(poolListOptions.ocpDate());
}
return listNext(nextPageLink, poolListNextOptions).getBody();
}
};
return new ServiceResponseWithHeaders<>(result, response.getHeaders(), response.getResponse());
}
use of com.microsoft.rest.ServiceResponseWithHeaders 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 certificateListOptions 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 listAsync(final CertificateListOptions certificateListOptions, 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;
}
Validator.validate(certificateListOptions, serviceCallback);
String filter = null;
if (certificateListOptions != null) {
filter = certificateListOptions.filter();
}
String select = null;
if (certificateListOptions != null) {
select = certificateListOptions.select();
}
Integer maxResults = null;
if (certificateListOptions != null) {
maxResults = certificateListOptions.maxResults();
}
Integer timeout = null;
if (certificateListOptions != null) {
timeout = certificateListOptions.timeout();
}
String clientRequestId = null;
if (certificateListOptions != null) {
clientRequestId = certificateListOptions.clientRequestId();
}
Boolean returnClientRequestId = null;
if (certificateListOptions != null) {
returnClientRequestId = certificateListOptions.returnClientRequestId();
}
DateTime ocpDate = null;
if (certificateListOptions != null) {
ocpDate = certificateListOptions.ocpDate();
}
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) {
CertificateListNextOptions certificateListNextOptions = null;
if (certificateListOptions != null) {
certificateListNextOptions = new CertificateListNextOptions();
certificateListNextOptions.withClientRequestId(certificateListOptions.clientRequestId());
certificateListNextOptions.withReturnClientRequestId(certificateListOptions.returnClientRequestId());
certificateListNextOptions.withOcpDate(certificateListOptions.ocpDate());
}
listNextAsync(result.getBody().getNextPageLink(), certificateListNextOptions, serviceCall, serviceCallback);
} else {
serviceCallback.success(new ServiceResponseWithHeaders<>(serviceCallback.get(), result.getHeaders(), result.getResponse()));
}
} catch (BatchErrorException | IOException exception) {
serviceCallback.failure(exception);
}
}
});
return serviceCall;
}
Aggregations