/** * Gets the current usage count and the limit for the resources under the subscription. * * @throws CloudException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the UsageListResultInner object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse<UsageListResultInner> list() throws CloudException, IOException, IllegalArgumentException { if (this.client.subscriptionId() == null) { throw new IllegalArgumentException( "Parameter this.client.subscriptionId() is required and cannot be null."); } if (this.client.apiVersion() == null) { throw new IllegalArgumentException( "Parameter this.client.apiVersion() is required and cannot be null."); } Call<ResponseBody> call = service.list( this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); return listDelegate(call.execute()); }
/** * Gets the current usage count and the limit for the resources under the subscription. * * @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 ServiceCallback<UsageListResultInner> serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (this.client.subscriptionId() == null) { serviceCallback.failure( new IllegalArgumentException( "Parameter this.client.subscriptionId() 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; } Call<ResponseBody> call = service.list( this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue( new ServiceResponseCallback<UsageListResultInner>(serviceCallback) { @Override public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { try { serviceCallback.success(listDelegate(response)); } catch (CloudException | IOException exception) { serviceCallback.failure(exception); } } }); return serviceCall; }