def getUsage(api_key=None, api_version=None):
 ret = {'res': True}
 if ((not api_key) or (not api_version)):
  try:
   options = __salt__['config.option']('random_org')
   if (not api_key):
    api_key = options.get('api_key')
   if (not api_version):
    api_version = options.get('api_version')
  except (NameError, KeyError, AttributeError):
   log.error('No Random.org api key found.')
   ret['message'] = 'No Random.org api key or api version found.'
   ret['res'] = False
   return ret
 if isinstance(api_version, int):
  api_version = str(api_version)
 _function = RANDOM_ORG_FUNCTIONS.get(api_version).get('getUsage').get('method')
 data = {}
 data['id'] = 1911220
 data['jsonrpc'] = '2.0'
 data['method'] = _function
 data['params'] = {'apiKey': api_key}
 result = _query(api_version=api_version, data=data)
 if result:
  ret['bitsLeft'] = result.get('bitsLeft')
  ret['requestsLeft'] = result.get('requestsLeft')
  ret['totalBits'] = result.get('totalBits')
  ret['totalRequests'] = result.get('totalRequests')
 else:
  ret['res'] = False
  ret['message'] = result['message']
 return ret

def getUsage ( api_key = None , api_version = None ) : ret = { 'res' : True } if ( ( not api_key ) or ( not api_version ) ) : try : options = __salt__ [ 'config.option' ] ( 'random_org' ) if ( not api_key ) : api_key = options . get ( 'api_key' ) if ( not api_version ) : api_version = options . get ( 'api_version' ) except ( NameError , KeyError , AttributeError ) : log . error ( 'No Random.org api key found.' ) ret [ 'message' ] = 'No Random.org api key or api version found.' ret [ 'res' ] = False return ret if isinstance ( api_version , int ) : api_version = str ( api_version ) _function = RANDOM_ORG_FUNCTIONS . get ( api_version ) . get ( 'getUsage' ) . get ( 'method' ) data = { } data [ 'id' ] = 1911220 data [ 'jsonrpc' ] = '2.0' data [ 'method' ] = _function data [ 'params' ] = { 'apiKey' : api_key } result = _query ( api_version = api_version , data = data ) if result : ret [ 'bitsLeft' ] = result . get ( 'bitsLeft' ) ret [ 'requestsLeft' ] = result . get ( 'requestsLeft' ) ret [ 'totalBits' ] = result . get ( 'totalBits' ) ret [ 'totalRequests' ] = result . get ( 'totalRequests' ) else : ret [ 'res' ] = False ret [ 'message' ] = result [ 'message' ] return ret
show current usages statistics .