class JobTemplateSpec(StrictJSONObject['JobTemplateSpec']): """ JSON document which specifies a job template. """ # The name to give the template name: str = StringProperty(min_length=1, max_length=200) # The version to give the template (omit for latest version) version: int = NumberProperty(minimum=1, integer_only=True, optional=True) # A description of the task the template performs description: str = StringProperty(optional=True, default="") # The scope of the template scope: str = StringProperty(min_length=1, max_length=16) # The licence the template is issued under licence: str = StringProperty(min_length=1, max_length=100) # The domain of the template, if any domain: str = StringProperty(min_length=2, max_length=2, optional=True) # The specific information which determines what type of template is defined specific: Union[WorkableTemplateSpec, DependencyGraph] = OneOfProperty(sub_properties=( # Defines a base workable job template WorkableTemplateSpec.as_property(), # Defines a workflow meta-job template DependencyGraph.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__}")
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 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 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)
class Compare(FieldFilterExpression['Compare']): """ Filter expression which filters the list to those entries whose field compares to a given value (e.g. >, <, >=, <=). """ # Keyword identifying this object as a 'compare' expression type: str = ConstantProperty(value="compare") # The type of comparison to perform operator: str = EnumProperty(values=("<", ">", ">=", "<=")) # The value to compare to value: Union[str, int, float] = OneOfProperty(sub_properties=(StringProperty(), NumberProperty())) def __init__(self, **initial_values): # Automatically supply the type argument initial_values.setdefault("type", "compare") super().__init__(**initial_values)
class Exact(FieldFilterExpression['Exact']): """ Filter expression which filters the list to those entries whose field exactly matches some value. """ # Keyword identifying this object as an 'exact' expression type: str = ConstantProperty(value="exact") # The value to match exactly value: Union[str, int, float, bool] = OneOfProperty(sub_properties=(StringProperty(), NumberProperty(), BoolProperty())) # Whether the filtering should be performed without regard to case case_insensitive: bool = BoolProperty(optional=True, default=False) def __init__(self, **initial_values): # Automatically supply the type argument initial_values.setdefault("type", "exact") super().__init__(**initial_values)