def task_template_ids(self, task_template_ids): """Set the associated task templates IDs for this schedule. :param task_template_ids: A list of task template IDs. :type task_template_ids: list of int :raise: ValidationError: Thrown if task_template_ids is not a list, if each item's ID is not an integer, or if each item's ID in the list is not a finite positive integer. """ if task_template_ids is None: self._set('task_templates', []) elif not isinstance(task_template_ids, list): raise ValidationError( "Task template ids must be a list, not a %s." % type(task_template_ids).__name__) else: task_template_ids = list(set(task_template_ids)) for task_template_id in task_template_ids: if not Number.is_integer(task_template_id): raise ValidationError( "Each item in task template IDs must be an int (%s is %s)." % (task_template_id, type(task_template_id).__name__)) elif not Number.is_finite_positive(task_template_id): raise ValidationError( "Each item in task template IDs must be finite positive (item is %s)." % task_template_id) self._set('task_templates', task_template_ids)
def __init__(self, id=None, version=None, parent=None, map=None, areas=None, name=None, created=None, modified=None, **kwargs): """ :param integer id: The ID of the revision (assigned automatically upon creation). :param integer version: The version of this revision. If NULL, it is considered to be a draft, unpublished version. :param parent: The parent revision that this revision was based off of. :param integer map: The map this revision is associated with. :param string name: The display name for this revision. :param created: The date and time of this revision's creation (assigned automatically). :param modified: The date and time this revision was last modified (updated automatically). :type parent: int, Revision :type created: str, ~datetime.datetime :type modified: str, ~datetime.datetime """ super(Revision, self).__init__(id=id, created=created, modified=modified, **kwargs) self.version = version self.parent = parent self.map = map self.name = name if Number.is_integer(map): if not Number.is_finite_positive(map): raise ValidationError("Map ID must be finite positive (item is %s)." % map) self.endpoint = 'maps/%(map_id)s/revisions' % {'map_id': str(map)} else: raise ValidationError("Map ID must be an integer (%s is %s)." % (map, type(map).__name__)) if areas: self.__areas = areas
def modifiers(self, modifier_ids): """Set the the users who modified this annotation. :param modifier_ids: A list of user IDs. :type modifier_ids: list of int :raise: ValidationError: Thrown if modifier_ids is not a list, if each item's ID is not an integer, or if each item's ID in the list is not a finite positive integer. """ if modifier_ids is None: self._set('modifiers', []) elif not isinstance(modifier_ids, list): raise ValidationError("Modifier ids must be a list, not a %s." % type(modifier_ids).__name__) else: modifier_ids = list(set(modifier_ids)) for modifier_id in modifier_ids: if not Number.is_integer(modifier_id): raise ValidationError( "Each item in modifier IDs must be an int (%s is %s)." % (modifier_id, type(modifier_id).__name__)) elif not Number.is_finite_positive(modifier_id): raise ValidationError( "Each item in modifier IDs must be finite positive (item is %s)." % modifier_id) self._set('modifiers', modifier_ids)
def action_id(self, id): """Sets the action ID that this survey state belongs to. :param id: (integer) The action id of the survey state. :raise fetchcore.exceptions.ValidationError: Thrown if id is not a positive integer. """ if Number.is_integer(id): if not Number.is_finite_positive(id): raise ValidationError("Action ID must be a finite positive number (value is %s)" % id) self._set("action", id) else: raise ValidationError("Action ID must be a number (value is %s)" % id)
def survey_path_id(self, value): """Sets the ID of survey path for this action to follow. :param value: (integer) Survey path ID :raises ValidationError if value is not a positive finite integer """ if Number.is_integer(value): if not Number.is_finite_positive(value): raise ValidationError("Survey path ID must be a finite positive number (value is %s)" % value) self.set_input("survey_path_id", value) else: raise ValidationError("Survey path ID must be a number (value is %s)" % value)
def map(self, map): """Set the map that this revision belongs to. :param integer map: The map. :raise fetchcore.exceptions.ValidationError:: Thrown if map not a finite positive integer. """ if Number.is_integer(map): if not Number.is_finite_positive(map): raise ValidationError("Map ID must be finite positive (item is %s)." % map) self._set('map', map) else: raise ValidationError("Map ID must be an integer (%s is %s)." % (map, type(map).__name__))
def intermediate_task_template_id(self, value): """Sets the optional ID of the task template to run at each intermediate survey pose. :param value: (integer) Task template ID :raises ValidationError if value is not a positive finite integer """ if Number.is_integer(value): if not Number.is_finite_positive(value): raise ValidationError( "Intermediate task template ID must be a finite positive number (value is %s)" % value) self.set_input("intermediate_task_template_id", value) else: raise ValidationError("Intermediate task template ID must be a number (value is %s)" % value)
def survey_state_id(self, survey_state_id): """Set the survey state ID that this pose belongs to. :param integer survey_state_id: The survey_state ID. :raise fetchcore.exceptions.ValidationError: Thrown if survey_state_id not a finite positive integer. """ if Number.is_integer(survey_state_id): if not Number.is_finite_positive(survey_state_id): raise ValidationError("Survey state ID must be finite positive (item is %s)." % survey_state_id) self._set('survey_state', survey_state_id) else: raise ValidationError("Survey state ID must be an integer (%s is %s)." % (survey_state_id, type(survey_state_id).__name__))
def survey_path_id(self, survey_path_id): """Set the ID for this survey path. :param integer survey_path: The survey path ID. :raise fetchcore.exceptions.ValidationError: Thrown if survey_path_id is not a finite positive integer. """ if Number.is_integer(survey_path_id): if not Number.is_finite_positive(survey_path_id): raise ValidationError("Survey Path ID must be finite positive (item is %s)." % survey_path_id) self._set('survey_path', survey_path_id) else: raise ValidationError("Survey Path ID must be an integer (%s is %s)." % (survey_path_id, type(survey_path_id).__name__))
def start_id(self, start_id): """Set the starting node ID for this pose. :param integer start_id: The survey node ID. :raise fetchcore.exceptions.ValidationError: Thrown if start_id is not a finite positive integer. """ if Number.is_integer(start_id): if not Number.is_finite_positive(start_id): raise ValidationError("Start ID must be finite positive (item is %s)." % start_id) self._set('start', start_id) else: raise ValidationError("Start ID must be an integer (%s is %s)." % (start_id, type(start_id).__name__))
def pose_id(self, pose_id): """Set the associated pose ID for this queue. :param integer pose_id: The pose ID. :raise fetchcore.exceptions.ValidationError: Thrown if pose_id is not a finite positive integer. """ if Number.is_integer(pose_id): if not Number.is_finite_positive(pose_id): raise ValidationError("Pose ID must be finite positive (item is %s)." % pose_id) self._set('pose', pose_id) else: raise ValidationError("Pose ID must be an integer (%s is %s)." % (pose_id, type(pose_id).__name__))
def map_id(self, value): """Set the associated map ID for this robot. :param value: (integer) The map ID. :raise ~fetchcore.exceptions.ValidationError: Thrown if value is not a finite positive integer. """ if value is None: self._set('map', value) elif Number.is_integer(value): if not Number.is_finite_positive(value): raise ValidationError("Map ID must be a finite positive integer (item is %s)." % value) self._set('map', value) else: raise ValidationError("Map ID must be an integer (%s is %s)." % (value, type(value).__name__))
def survey_pose_id(self, id): """Sets the survey pose ID that this state represents. :param id: (integer) The resource id of the survey pose. :raise fetchcore.exceptions.ValidationError: Thrown if id is not None or a positive integer. """ if id is None: self._set("survey_pose", id) elif Number.is_integer(id): if not Number.is_finite_positive(id): raise ValidationError("Survey pose ID must be a finite positive number or None (value is %s)" % id) self._set("survey_pose", id) else: raise ValidationError("Survey pose ID must be a number or None (value is %s)" % id)
def end_id(self, end_id): """Set the associated end ID for this edge. :param integer end_id: The end ID. :raise fetchcore.exceptions.ValidationError: Thrown if end_id is not a finite positive integer. """ if Number.is_integer(end_id): if not Number.is_finite_positive(end_id): raise ValidationError( "End ID must be finite positive (item is %s)." % end_id) self._set('end', end_id) else: raise ValidationError("End ID must be an integer (%s is %s)." % (end_id, type(end_id).__name__))
def buttons_per_row(self, buttons): """Sets number of HMI buttons per row :param buttons: (integer) A positive integer :raises ValidationError if buttons is not an integer :raises ValidationError if buttons is not a positive integer """ if not Number.is_integer(buttons): raise ValidationError("Buttons per row must be a number (buttons per row is %s)" % buttons) elif not Number.is_finite_positive(buttons): raise ValidationError("Buttons per row must be a finite positive number " "(buttons is %s)" % buttons) else: self.set_input("buttons_per_row", buttons)
def parent_id(self, parent_id): """Set the parent revision id that this revision was based off of. :param integer parent_id: The ID of the parent revision. :raise fetchcore.exceptions.ValidationError:: Thrown if parent_id not a finite positive integer. """ if parent_id is None: self._set('parent', parent_id) elif Number.is_integer(parent_id): if not Number.is_finite_positive(parent_id): raise ValidationError("Parent ID must be finite positive (item is %s)." % parent_id) self._set('parent', parent_id) else: raise ValidationError("Parent ID must be an integer (%s is %s)." % (parent_id, type(parent_id).__name__))
def task_template_id(self, id): """Sets resource ID the task template that this task is associated with :param id: (integer|None) The associated task template :raises fetchcore.exceptions.ValidationError: Thrown if value is not a finite positive integer or None. """ if id is None or Number.is_integer(id): if id is not None and not Number.is_finite_positive(id): raise ValidationError( "Task template ID must be a finite positive number or None (value is %s)" % id) self._set("task_template", id) else: raise ValidationError( "Task template ID must be a number or None (value is %s)" % id)
def survey_node_id(self, survey_node_id): """Set the associated survey node ID for this survey node draft. :param integer survey_node_id: The survey node ID. :raise fetchcore.exceptions.ValidationError: Thrown if survey_node_id not a finite positive integer. """ if survey_node_id is None: self._set('survey_node', survey_node_id) elif Number.is_integer(survey_node_id): if not Number.is_finite_positive(survey_node_id): raise ValidationError("Survey node ID must be finite positive (item is %s)." % survey_node_id) self._set('survey_node', survey_node_id) else: raise ValidationError("Survey node ID must be an integer (%s is %s)." % (survey_node_id, type(survey_node_id).__name__))
def parent(self, id): """Sets the ID of the parent task that spawned this task. :param id: (integer|None) The associated parent task. :raises fetchcore.exceptions.ValidationError: Thrown if value is not a finite positive integer or None. """ if id is None or Number.is_integer(id): if id is not None and not Number.is_finite_positive(id): raise ValidationError( "Parent task ID must be a finite positive number or None (value is %s)" % id) self._set("parent", id) else: raise ValidationError( "Parent task ID must be a number or None (value is %s)" % id)
def frequency(self, frequency): """Set the repeat frequency of the schedule (e.g., every 2 days). :param int frequency: The schedule repeat frequency. :raise: fetchcore.exceptions.ValidationError: Thrown if frequency is not a finite positive integer. """ if Number.is_integer(frequency): if not Number.is_finite_positive(frequency): raise ValidationError( "Frequency must be a finite positive number (frequency is %s)." % frequency) self._set('frequency', frequency) else: raise ValidationError( "Frequency must be an int (frequency is %s)." % frequency)
def version(self, version): """Set the version of this revision. :param integer version: The version number. :raise fetchcore.exceptions.ValidationError:: Thrown if version not a finite positive integer. """ if version is None: self._set('version', version) elif Number.is_integer(version): if not Number.is_finite_positive(version): raise ValidationError("Version number must be finite positive (item is %s)." % version) self._set('version', version) else: raise ValidationError("Version number must be an integer (%s is %s)." % (version, type(version).__name__))
def queue_id(self, queue_id): """Set the associated queue ID for this queue draft. :param integer queue_id: The queue ID. :raise fetchcore.exceptions.ValidationError: Thrown if queue_id not a finite positive integer. """ if queue_id is None: self._set('queue', queue_id) elif Number.is_integer(queue_id): if not Number.is_finite_positive(queue_id): raise ValidationError("Queue ID must be finite positive (item is %s)." % queue_id) self._set('queue', queue_id) else: raise ValidationError("Queue ID must be an integer (%s is %s)." % (queue_id, type(queue_id).__name__))
def task_id_output(self, task_id_output): """ :param task_id_output: The id of the task generated by this response. :raise fetchcore.exceptions.ValidationError: Thrown if task_id_output is not a positive integer or None. """ if task_id_output is None: return elif Number.is_integer(task_id_output) and Number.is_finite_positive( task_id_output): self.set_output('task_id', task_id_output) else: raise ValidationError( 'Task ID should be a positive integer or None, not a %s.' % type(task_id_output).__name__)
def prev_node_id(self, prev_node_id): """Sets the previous node in the path. :param prev_node_id: An ID to the previous survey node. :type prev_node_id: int :raises fetchcore.exceptions.ValidationError: Thrown if prev_node_id not a finite positive integer. """ if prev_node_id is None: self._set('prev_node', prev_node_id) elif Number.is_integer(prev_node_id): if not Number.is_finite_positive(prev_node_id): raise ValidationError("Previous node ID must be finite positive (item is %s)." % prev_node_id) self._set('prev_node', prev_node_id) else: raise ValidationError("Previous node ID must be an integer (%s is %s)." % (prev_node_id, type(prev_node_id).__name__))
def next_node_id(self, next_node_id): """Sets the next node in the path :param next_node_id: An ID to the next survey node. :type next_node_id: int :raises fetchcore.exceptions.ValidationError: Thrown if next_node_id not a finite positive integer. """ if next_node_id is None: self._set('next_node', next_node_id) elif Number.is_integer(next_node_id): if not Number.is_finite_positive(next_node_id): raise ValidationError("Next node ID must be finite positive (item is %s)." % next_node_id) self._set('next_node', next_node_id) else: raise ValidationError("Next node ID must be an integer (%s is %s)." % (next_node_id, type(next_node_id).__name__))
def pose_id(self, value): """Sets or creates the poses that robot is trying to navigate to :param value: (integer) The goal pose ID :raises ValidationError if poses is not an ID """ if value and Number.is_integer(value): if not Number.is_finite_positive(value): raise ValidationError( "Pose ID must be a finite positive number (value is %s)" % value) self.set_input("pose_id", value) elif value: raise ValidationError("Pose ID must be a number (value is %s)" % value) self.set_input("pose_id", value)
def number_agents_required(self, number_agents_required): """Set the number of required agents running this schedule concurrently. :param int number_agents_required: The number of required agents. :raise: fetchcore.exceptions.ValidationError: Thrown if value is not a positive finite integer. """ if Number.is_integer(number_agents_required): if not Number.is_finite_positive(number_agents_required): raise ValidationError( "Number agents required must be a finite positive number " "(number agents required is %s)." % number_agents_required) self._set('number_agents_required', number_agents_required) else: raise ValidationError( "Number agents required must be an int (number required is %s)." % number_agents_required)
def map_id(self, map_id): """Set the associated pose map ID for this pose. :param integer map_id: The pose map ID. :raise fetchcore.exceptions.ValidationError: Thrown if map_id not a finite positive integer. """ if Number.is_integer(map_id): if not Number.is_finite_positive(map_id): raise ValidationError( "Area map ID must be finite positive (item is %s)." % map_id) self._set('map', map_id) else: raise ValidationError( "Area map ID must be an integer (%s is %s)." % (map_id, type(map_id).__name__))
def area_id(self, area_id): """Set the associated area ID for this area draft. :param integer area_id: The area ID. :raise fetchcore.exceptions.ValidationError: Thrown if area_id not a finite positive integer. """ if area_id is None: self._set('area', area_id) elif Number.is_integer(area_id): if not Number.is_finite_positive(area_id): raise ValidationError( "Area ID must be finite positive (item is %s)." % area_id) self._set('area', area_id) else: raise ValidationError("Area ID must be an integer (%s is %s)." % (area_id, type(area_id).__name__))
def dock_id(self, value): """Sets the ID of the dock :param value: (integer) Dock ID :raises ValidationError if value is not an integer :raises ValidationError if value not a positive finite integer """ if Number.is_integer(value): if not Number.is_finite_positive(value): raise ValidationError( "Dock ID must be a finite positive number (value is %s)" % value) self.set_input("dock_id", value) else: raise ValidationError("Dock ID must be a number (value is %s)" % value)