'Get the latest data from REST API.'

def update(self):

    self.rest.update()
    value = self.rest.data
    if (value is not None):
        if (self.type == 'disk_use_percent'):
            self._state = value['fs'][0]['percent']
        elif (self.type == 'disk_use'):
            self._state = round((value['fs'][0]['used'] / (1024 ** 3)), 1)
        elif (self.type == 'disk_free'):
            try:
                self._state = round((value['fs'][0]['free'] / (1024 ** 3)), 1)
            except KeyError:
                self._state = round(((value['fs'][0]['size'] - value['fs'][0]['used']) / (1024 ** 3)), 1)
        elif (self.type == 'memory_use_percent'):
            self._state = value['mem']['percent']
        elif (self.type == 'memory_use'):
            self._state = round((value['mem']['used'] / (1024 ** 2)), 1)
        elif (self.type == 'memory_free'):
            self._state = round((value['mem']['free'] / (1024 ** 2)), 1)
        elif (self.type == 'swap_use_percent'):
            self._state = value['memswap']['percent']
        elif (self.type == 'swap_use'):
            self._state = round((value['memswap']['used'] / (1024 ** 3)), 1)
        elif (self.type == 'swap_free'):
            self._state = round((value['memswap']['free'] / (1024 ** 3)), 1)
        elif (self.type == 'processor_load'):
            try:
                self._state = value['load']['min15']
            except KeyError:
                self._state = value['cpu']['total']
        elif (self.type == 'process_running'):
            self._state = value['processcount']['running']
        elif (self.type == 'process_total'):
            self._state = value['processcount']['total']
        elif (self.type == 'process_thread'):
            self._state = value['processcount']['thread']
        elif (self.type == 'process_sleeping'):
            self._state = value['processcount']['sleeping']
        elif (self.type == 'cpu_temp'):
            for sensor in value['sensors']:
                if (sensor['label'] == 'CPU'):
                    self._state = sensor['value']
            self._state = None
