src/unifi_api/api.py
def _ap_stats(self, gran, def_range, ap_mac=None, start=None, end=None, site=None):
        '''
            Get ap stats
            -------------------------
            returns an array of stats for the given ap or for all aps on a given site
            params:
                Name        | required  | description
                -----------------------------------------
                gran        |   True    | granularity of the stats, only permitted: 5minutes, hourly, daily
                def_range   |   True    | default range for the stats, only used if start wasn't given
                ap_mac      |   False   | mac address of the ap
                start       |   False   | Unix timestamp in seconds or datetime, defaults to end - 12h
                end         |   False   | Unix timestamp in seconds or datetime, defaults to now
                site        |   False   | site of the ap, if not provided `find_device` will be used (or `default` if ap_mac wasn't provided)

            # support and restrictions apply from 'ap_stat_*' functions
        '''
        end = end*1000 if isinstance(end, int) else int(datetime.now().timestamp()*1000) if end is None else int(end.timestamp()*1000)
        start = start*1000 if isinstance(start, int) else end - def_range if start is None else int(start.timestamp()*1000)
        assert 0 < start < end, 'start must be before end (and both positive)'

        data = {
            'attrs': ['bytes', 'num_sta', 'time'],
            'start': start,
            'end': end,
        }

        if ap_mac is not None:
            site = self.find_device(ap_mac) if site is None else site
            assert site is not None, 'No site provided and AP does not belong to any known site'
            data['mac'] = ap_mac
        elif site is None:
            site = 'default'

        r = self.get(self.endpoint('/api/s/%s/stat/report/%s.ap' % (site, gran)), json=data)
        return self.process_response(r)

            Get ap stats
            -------------------------
            returns an array of stats for the given ap or for all aps on a given site
            params:
                Name        | required  | description
                -----------------------------------------
                gran        |   True    | granularity of the stats, only permitted: 5minutes, hourly, daily
                def_range   |   True    | default range for the stats, only used if start wasn't given
                ap_mac      |   False   | mac address of the ap
                start       |   False   | Unix timestamp in seconds or datetime, defaults to end - 12h
                end         |   False   | Unix timestamp in seconds or datetime, defaults to now
                site        |   False   | site of the ap, if not provided `find_device` will be used (or `default` if ap_mac wasn't provided)

            # support and restrictions apply from 'ap_stat_*' functions
        
Get ap stats
returns an array of stats for the given ap or for all aps on a given site
params:
Name        | required  | description



support and restrictions apply from 'ap_stat_*' functions
Get ap stats returns an array of stats for the given ap or for all aps on a given site params : Name | required | description support and restrictions apply from ' ap_stat_ * ' functions
def _ap_stats(self, gran, def_range, ap_mac=None, start=None, end=None, site=None):
        end = end*1000 if isinstance(end, int) else int(datetime.now().timestamp()*1000) if end is None else int(end.timestamp()*1000)
        start = start*1000 if isinstance(start, int) else end - def_range if start is None else int(start.timestamp()*1000)
        assert 0 < start < end, 'start must be before end (and both positive)'
        data = {
            'attrs': ['bytes', 'num_sta', 'time'],
            'start': start,
            'end': end,
        }
        if ap_mac is not None:
            site = self.find_device(ap_mac) if site is None else site
            assert site is not None, 'No site provided and AP does not belong to any known site'
            data['mac'] = ap_mac
        elif site is None:
            site = 'default'
        r = self.get(self.endpoint('/api/s/%s/stat/report/%s.ap' % (site, gran)), json=data)
        return self.process_response(r)
def _ap_stats ( self , gran , def_range , ap_mac = None , start = None , end = None , site = None ) : end = end * 1000 if isinstance ( end , int ) else int ( datetime . now ( ) . timestamp ( ) * 1000 ) if end is None else int ( end . timestamp ( ) * 1000 ) start = start * 1000 if isinstance ( start , int ) else end - def_range if start is None else int ( start . timestamp ( ) * 1000 ) assert 0 < start < end , 'start must be before end (and both positive)' data = { 'attrs' : [ 'bytes' , 'num_sta' , 'time' ] , 'start' : start , 'end' : end , } if ap_mac is not None : site = self . find_device ( ap_mac ) if site is None else site assert site is not None , 'No site provided and AP does not belong to any known site' data [ 'mac' ] = ap_mac elif site is None : site = 'default' r = self . get ( self . endpoint ( '/api/s/%s/stat/report/%s.ap' % ( site , gran ) ) , json = data ) return self . process_response ( r )
Get ap stats
returns an array of stats for the given ap or for all aps on a given site
params:
Name        | required  | description
Get ap stats returns an array of stats for the given ap or for all aps on a given site params : Name | required | description
'''
            Get ap stats
            -------------------------
            returns an array of stats for the given ap or for all aps on a given site
            params:
                Name        | required  | description
                -----------------------------------------
                gran        |   True    | granularity of the stats, only permitted: 5minutes, hourly, daily
                def_range   |   True    | default range for the stats, only used if start wasn't given
                ap_mac      |   False   | mac address of the ap
                start       |   False   | Unix timestamp in seconds or datetime, defaults to end - 12h
                end         |   False   | Unix timestamp in seconds or datetime, defaults to now
                site        |   False   | site of the ap, if not provided `find_device` will be used (or `default` if ap_mac wasn't provided)

            # support and restrictions apply from 'ap_stat_*' functions
        '''
self
gran
def_range
ap_mac
start
end
site