def __init__(self, id=None, created=None, modified=None, **kwargs): """Creates a new Resource with the given optional arguments. :param int id: The ID of the resource (assigned automatically upon creation). :param created: The created timestamp (assigned automatically). :param modified: The modification timestamp (updated automatically). :type created: str, ~datetime.datetime :type modified: str, ~datetime.datetime """ super(TimestampedResource, self).__init__(id=id) try: if created: self._set('created', Timestamp.to_datetime(created)) if modified: self._set('modified', Timestamp.to_datetime(modified)) except (TypeError, ValueError) as e: raise exceptions.ValidationError(e)
def start(self, start): """Set the timestamp for the first scheduled instance. :param start: The start timestamp. :type start: str, ~datetime.datetime :raise ~fetchcore.exceptions.ValidationError: Thrown if the timestamp is not a string or cannot be parsed. """ try: self._set('start', Timestamp.to_datetime(start)) except (TypeError, ValueError) as e: raise ValidationError(e)
def end(self, end): """Sets the timestamp that indicates when the action stopped execution :param str, ~datetime.datetime end: A timestamp """ if end is None: self._set("end", end) else: try: self._set("end", Timestamp.to_datetime(end)) except (TypeError, ValueError) as e: raise ValidationError(e)
def start(self, start): """Sets the timestamp that indicates when the action started execution :param str, ~datetime.datetime start: A timestamp """ if start is None: self._set("start", start) else: try: self._set("start", Timestamp.to_datetime(start)) except (TypeError, ValueError) as e: raise ValidationError(e)
def last_boot(self, last_boot): """Sets the timestamp that indicates when the robot's computer last booted :param last_boot: (string|datetime.datetime) A timestamp """ if last_boot is None: self._set("last_boot", last_boot) else: try: self._set("last_boot", Timestamp.to_datetime(last_boot)) except (TypeError, ValueError) as e: raise exceptions.ValidationError(e)
def last_connection_time(self, last_connection_time): """Sets the timestamp that indicates when the robot last connected :param last_connection_time: (string|datetime.datetime) A timestamp """ if last_connection_time is None: self._set("last_connection_time", last_connection_time) else: try: self._set("last_connection_time", Timestamp.to_datetime(last_connection_time)) except (TypeError, ValueError) as e: raise exceptions.ValidationError(e)
def last_deep_charge(self, last_deep_charge): """Sets the timestamp that indicates when the robot was last charged :param last_deep_charge: (string|datetime.datetime) A timestamp """ if last_deep_charge is None: self._set("last_deep_charge", last_deep_charge) else: try: self._set("last_deep_charge", Timestamp.to_datetime(last_deep_charge)) except (TypeError, ValueError) as e: raise ValidationError(e)
def end(self, end): """Set the timestamp for the last scheduled instance :param end: The end timestamp. :type end: str, ~datetime.datetime :raise: ~fetchcore.exceptions.ValidationError Thrown if the timestamp is not a string or cannot be parsed. """ if end is None: self._set('end', end) else: try: self._set('end', Timestamp.to_datetime(end)) except (TypeError, ValueError) as e: raise ValidationError(e)
def set_values(self, key, value): """Saves the data that is received from the server. :param key: The key to save the data for. :param value: The value to save. """ if key == 'created' or key == 'modified': try: self._set(key, Timestamp.to_datetime(value)) except (TypeError, ValueError) as e: raise exceptions.ValidationError(e) elif key == 'id': self._set(key, value) elif key in self.read_only_fields: self._set(key, value) else: self.__setattr__(key, value)