class EmailNotification(Notification['EmailNotification']): """ Notification specification for sending an email. """ # The subject of the email subject: str = StringProperty() # The body of the email body: str = StringProperty() # The recipients of the email (defaults to the job's creator if omitted) to: List[str] = ArrayProperty(element_property=StringProperty(), min_elements=1, unique_elements=True, optional=True) # Copied recipients of the email (defaults to no-one) cc: List[str] = ArrayProperty(element_property=StringProperty(), min_elements=1, unique_elements=True, optional=True) # Blind-copied recipients of the email (defaults to no-one) bcc: List[str] = ArrayProperty(element_property=StringProperty(), min_elements=1, unique_elements=True, optional=True)
class WorkableTemplateSpec(StrictJSONObject['WorkableTemplateSpec']): """ JSON document specifying parameters for a job template which can be worked by worker-nodes. """ # The framework being used by the worker node, in 'name|version' format framework: str = StringProperty(min_length=3, max_length=49) # The type of job this template performs job_type: str = StringProperty(min_length=1, max_length=32) # The executor class responsible for executing this template executor_class: str = StringProperty(max_length=128) # Any packages that the executor class requires to complete the task required_packages: str = StringProperty() # The body of the job body: str = StringProperty() # Any inputs to the job required to perform the task inputs: List[InputSpec] = ArrayProperty(element_property=InputSpec.as_property()) # Any parameters to the job required to perform the task parameters: List[ParameterSpec] = ArrayProperty(element_property=ParameterSpec.as_property())
class Or(FilterExpression['Or']): """ Filter expression which is the logical or of a number of sub-expresssions. """ # Keyword identifying this object as an 'and' expression type: str = ConstantProperty(value="or") # The sub-expressions of the logical and sub_expressions: List[Union[And, FieldFilterExpression]] = ArrayProperty( element_property=OneOfProperty(sub_properties=( And.as_property(), *(field_filter_expression.as_property() for field_filter_expression in ALL_FIELD_FILTER_EXPRESSIONS))), min_elements=2) def __init__(self, **initial_values): # Automatically supply the type argument initial_values.setdefault("type", "or") super().__init__(**initial_values) def __or__(self, other): if isinstance(other, Or): return Or(sub_expressions=self.sub_expressions + other.sub_expressions) elif isinstance(other, (And, FieldFilterExpression)): return Or(sub_expressions=self.sub_expressions + [other]) else: raise TypeError( f"Can't perform logical or between " f"{self.__class__.__name__} and {other.__class__.__name__}")
class AnnotationsModSpec(StrictJSONObject['AnnotationsModSpec']): """ Represents a modification to the annotations of an image. """ # The annotations to set on the image annotations: List[Annotation] = ArrayProperty( element_property=Annotation.as_property() )
class FilterSpec(StrictJSONObject['FilterSpec']): """ The top-level document describing how to filter a list request. """ # The sequential stages of filters of the list request expressions: List[FilterExpression] = ArrayProperty( element_property=OneOfProperty(sub_properties=( And.as_property(), Or.as_property(), *(field_filter_expression.as_property() for field_filter_expression in ALL_FIELD_FILTER_EXPRESSIONS))), optional=True) # An optional final ordering on the result, in order of precedence order_by: List[OrderBy] = ArrayProperty( element_property=OrderBy.as_property(), optional=True) # An optional flag to include soft-deleted models as well include_inactive: bool = BoolProperty(optional=True, default=False)
class DependencyGraph(StrictJSONObject['DependencyGraph']): """ Graph describing the child templates to a meta-template, and the connections between their inputs/outputs. """ # The child templates that participate in this meta-template, keyed by name nodes: Dict[str, Node] = MapProperty(value_property=Node.as_property()) # The dependencies between the inputs/outputs of the child templates dependencies: List[Dependency] = ArrayProperty( element_property=Dependency.as_property())
def _create_notification_array_property() -> ArrayProperty: """ Creates a property which holds an array of notification types. :return: The array property. """ return ArrayProperty(element_property=OneOfProperty(sub_properties=tuple( NotificationType.as_property() for NotificationType in NotificationTypes)), optional=True, default=[])
class CategoriesModSpec(StrictJSONObject['CategoriesModSpec']): """ A specification of which images to modify the categories for, and which categories to modify for those images. """ # The method to use to modify the categories method: str = EnumProperty( values=("add", "remove") ) # The images to modify the categories for images: List[str] = ArrayProperty( element_property=StringProperty(min_length=1), min_elements=1, unique_elements=True ) # The categories to add/remove from the images categories: List[str] = ArrayProperty( element_property=StringProperty(min_length=1), min_elements=1, unique_elements=True )
class Image(StrictJSONObject['Image']): """ Represents a single image and its annotations. """ # The image's format format: str = StringProperty(optional=True) # The image's dimensions dimensions: List[int] = ArrayProperty(element_property=NumberProperty( integer_only=True, minimum=1), min_elements=2, max_elements=2, optional=True) # The annotations of the image annotations: List[Annotation] = ArrayProperty( element_property=Annotation.as_property()) @property def width(self) -> Optional[int]: """ Gets the width from the dimensions. :return: The width, or None if not available. """ if self.dimensions is not Absent: return self.dimensions[0] @property def height(self) -> Optional[int]: """ Gets the height from the dimensions. :return: The height, or None if not available. """ if self.dimensions is not Absent: return self.dimensions[1]
class InputSpec(StrictJSONObject['InputSpec']): """ Specifies the JSON data structure for specifying the type and options to an input to a job template. """ # The name of the input name: str = StringProperty(min_length=1) # The possible types of value the input expects types: List[str] = ArrayProperty( element_property=StringProperty(min_length=1), min_elements=1 ) # The options to the input options: str = StringProperty(optional=True, default="") # The help text for the input help: str = StringProperty(optional=True, default="")
class LicenceSubdescriptorModSpec( StrictJSONObject['LicenceSubdescriptorModSpec']): """ Message to modify the sub-descriptors of a licence. """ # The type of sub-descriptor to modify type: str = EnumProperty(values=("permissions", "conditions", "limitations", "domains")) # The type of modification to make method: str = EnumProperty(values=("add", "remove")) # The name of the sub-descriptor names: List[Union[str, int]] = ArrayProperty( element_property=OneOfProperty( sub_properties=(StringProperty(min_length=1, max_length=100), NumberProperty(minimum=1, integer_only=True))), min_elements=1, unique_elements=True)
def _additional_properties_validation(cls) -> ArrayProperty: return ArrayProperty( element_property=StringProperty(min_length=1), unique_elements=True, # Each category should only appear once optional=True, default=[])