leapp.models.fields package¶
Module contents¶
-
class
leapp.models.fields.
Blob
(default=None, help=None)¶ Bases:
leapp.models.fields.BuiltinField
Blob field
Parameters: - default – Default value to be used if the field is not set
- help (str) – Documentation string for generating model documentation
-
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶ Returns: Serialized form of the workflow
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
class
leapp.models.fields.
Boolean
(default=None, help=None)¶ Bases:
leapp.models.fields.BuiltinField
Boolean field
Parameters: - default – Default value to be used if the field is not set
- help (str) – Documentation string for generating model documentation
-
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶ Returns: Serialized form of the workflow
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
class
leapp.models.fields.
BuiltinField
(default=None, help=None)¶ Bases:
leapp.models.fields.Field
Base class for all builtin types to act as pass-through with an additional validation
Parameters: - default – Default value to be used if the field is not set
- help (str) – Documentation string for generating model documentation
-
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶ Returns: Serialized form of the workflow
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
class
leapp.models.fields.
DateTime
(default=None, help=None)¶ Bases:
leapp.models.fields.BuiltinField
DateTime field to handle datetime objects which are converted to the ISO format and parsed back from there
Parameters: - default – Default value to be used if the field is not set
- help (str) – Documentation string for generating model documentation
-
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶ Returns: Serialized form of the workflow
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
class
leapp.models.fields.
EnumMixin
(choices, **kwargs)¶ Bases:
leapp.models.fields.Field
EnumMixin adds the ability to use the field as an Enum type of the field
Parameters: choices (List or tuple of allowed values) – List of values that are allowed for this field -
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
-
class
leapp.models.fields.
Field
(default=None, help=None)¶ Bases:
object
Field is the base of all supported fields.
Parameters: - default – Default value to be used if the field is not set
- help (str) – Documentation string for generating model documentation
-
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶ Returns: Serialized form of the workflow
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
class
leapp.models.fields.
Float
(default=None, help=None)¶ Bases:
leapp.models.fields.BuiltinField
Float field
Parameters: - default – Default value to be used if the field is not set
- help (str) – Documentation string for generating model documentation
-
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶ Returns: Serialized form of the workflow
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
class
leapp.models.fields.
FloatEnum
(choices, **kwargs)¶ Bases:
leapp.models.fields.EnumMixin
,leapp.models.fields.Float
Field that represents an enumeration of Floats
Parameters: choices (List or tuple of allowed values) – List of values that are allowed for this field -
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
-
class
leapp.models.fields.
Integer
(default=None, help=None)¶ Bases:
leapp.models.fields.BuiltinField
Integer field (int, long in python 2, int in python 3)
Parameters: - default – Default value to be used if the field is not set
- help (str) – Documentation string for generating model documentation
-
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶ Returns: Serialized form of the workflow
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
class
leapp.models.fields.
IntegerEnum
(choices, **kwargs)¶ Bases:
leapp.models.fields.EnumMixin
,leapp.models.fields.Integer
Field that represents an enumeration of Integers
Parameters: choices (List or tuple of allowed values) – List of values that are allowed for this field -
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
-
class
leapp.models.fields.
JSON
(default=None, help=None)¶ Bases:
leapp.models.fields.String
The JSON field allows to use json encodable python types as a value.
The value will be internally encoded to a JSON string and converted back into, whatever the result of json.loads is for that value passed.
- Note: The value None, however follows the same rules as for all fields and requires the field to be nullable,
- to allow this value. Within nested values such as lists or dicts, a None value is perfectly valid.
Parameters: - default – Default value to be used if the field is not set
- help (str) – Documentation string for generating model documentation
-
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶ Returns: Serialized form of the workflow
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
class
leapp.models.fields.
List
(elem_field, minimum=None, maximum=None, **kwargs)¶ Bases:
leapp.models.fields.Field
List represents lists of elem_field values
Parameters: - elem_field –
- minimum (int or None) – Minimal number of elements
- maximum (int or None) – Maximum number of elements
- default (A list of elements with the value type as specified in elem_field) – Default value to use if the field is not set
- help (str) – Documentation string for generating model documentation
-
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
class
leapp.models.fields.
Model
(model_type, **kwargs)¶ Bases:
leapp.models.fields.Field
Model is used to use other Models as fields
Parameters: - model_type (
leapp.model.Model
derived class) – Aleapp.model.Model
derived class - help (str) – Documentation string for generating the model documentation
-
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
- model_type (
-
exception
leapp.models.fields.
ModelMisuseError
¶ Bases:
exceptions.Exception
ModelMisuseError is raised if the Model definition is not valid.
-
args
¶
-
message
¶
-
-
exception
leapp.models.fields.
ModelViolationError
¶ Bases:
exceptions.Exception
ModelViolationError is raised if the data in the instances is not matching its definition.
-
args
¶
-
message
¶
-
-
leapp.models.fields.
Nullable
(elem_field)¶ Helper function to make a field nullable
-
class
leapp.models.fields.
Number
(default=None, help=None)¶ Bases:
leapp.models.fields.BuiltinField
Combined Integer and Float field
Parameters: - default – Default value to be used if the field is not set
- help (str) – Documentation string for generating model documentation
-
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶ Returns: Serialized form of the workflow
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
class
leapp.models.fields.
NumberEnum
(choices, **kwargs)¶ Bases:
leapp.models.fields.EnumMixin
,leapp.models.fields.Number
Field that represents an enumeration of Numbers
Parameters: choices (List or tuple of allowed values) – List of values that are allowed for this field -
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
-
class
leapp.models.fields.
String
(default=None, help=None)¶ Bases:
leapp.models.fields.BuiltinField
String field
Parameters: - default – Default value to be used if the field is not set
- help (str) – Documentation string for generating model documentation
-
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶ Returns: Serialized form of the workflow
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
class
leapp.models.fields.
StringEnum
(choices, **kwargs)¶ Bases:
leapp.models.fields.EnumMixin
,leapp.models.fields.String
Field that represents an enumeration of Strings
Parameters: choices (List or tuple of allowed values) – List of values that are allowed for this field -
as_nullable
()¶ Set object` “_nullable_” field to True and return the object back
-
from_initialization
(source, name, target)¶ Assigns the value to the target model passed through during the model initialization
Parameters: - source (dict) – Dictionary to extract the value from (usually kwargs)
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-
help
¶ Returns: Documentation help string defining what the field is about.
-
serialize
()¶
-
to_builtin
(source, name, target)¶ Converts the value with the given name to the builtin representation and assigns the field
Parameters: - source (Instance of a Model derived class) – Source model to get the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (dict) – Dictionary to set the value to
Returns: None
-
to_model
(source, name, target)¶ Converts the value with the given name to the model representation and assigns the attribute
Parameters: - source (dict) – Dictionary to extract the value from
- name (str) – Name of the field (used for a better error reporting only)
- target (Instance of a Model derived class) – Target model instance
Returns: None
-