leapp.models.fields package
Module contents
- class leapp.models.fields.Blob(default=None, help=None)
Bases:
BuiltinField
Blob field
- Parameters:
default – Default value to be used if the field is not set
help (str) – Documentation string for generating model documentation
- class leapp.models.fields.Boolean(default=None, help=None)
Bases:
BuiltinField
Boolean field
- Parameters:
default – Default value to be used if the field is not set
help (str) – Documentation string for generating model documentation
- class leapp.models.fields.BuiltinField(default=None, help=None)
Bases:
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
- class leapp.models.fields.DateTime(default=None, help=None)
Bases:
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
- class leapp.models.fields.EnumMixin(choices, **kwargs)
Bases:
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
- serialize()
- Returns:
Serialized form of the field
- 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
- property help
- Returns:
Documentation help string defining what the field is about.
- serialize()
- Returns:
Serialized form of the field
- 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:
BuiltinField
Float field
- Parameters:
default – Default value to be used if the field is not set
help (str) – Documentation string for generating model documentation
- class leapp.models.fields.FloatEnum(choices, **kwargs)
-
Field that represents an enumeration of Floats
- Parameters:
choices (List or tuple of allowed values) – List of values that are allowed for this field
- class leapp.models.fields.Integer(default=None, help=None)
Bases:
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
- class leapp.models.fields.IntegerEnum(choices, **kwargs)
-
Field that represents an enumeration of Integers
- Parameters:
choices (List or tuple of allowed values) – List of values that are allowed for this field
- class leapp.models.fields.JSON(default=None, help=None)
Bases:
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
- class leapp.models.fields.List(elem_field, minimum=None, maximum=None, **kwargs)
Bases:
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
- serialize()
- Returns:
Serialized form of the field
- class leapp.models.fields.Model(model_type, **kwargs)
Bases:
Field
Model is used to use other Models as fields
- Parameters:
model_type (
leapp.model.Model
derived class) – Aleapp.model.Model
derived classhelp (str) – Documentation string for generating the model documentation
- serialize()
- Returns:
Serialized form of the field
- exception leapp.models.fields.ModelMisuseError
Bases:
Exception
ModelMisuseError is raised if the Model definition is not valid.
- exception leapp.models.fields.ModelViolationError
Bases:
Exception
ModelViolationError is raised if the data in the instances is not matching its definition.
- leapp.models.fields.Nullable(elem_field)
Helper function to make a field nullable
- class leapp.models.fields.Number(default=None, help=None)
Bases:
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
- class leapp.models.fields.NumberEnum(choices, **kwargs)
-
Field that represents an enumeration of Numbers
- Parameters:
choices (List or tuple of allowed values) – List of values that are allowed for this field
- class leapp.models.fields.String(default=None, help=None)
Bases:
BuiltinField
String field
- Parameters:
default – Default value to be used if the field is not set
help (str) – Documentation string for generating model documentation
- class leapp.models.fields.StringEnum(choices, **kwargs)
-
Field that represents an enumeration of Strings
- Parameters:
choices (List or tuple of allowed values) – List of values that are allowed for this field
- class leapp.models.fields.StringMap(value_type, **kwargs)
Bases:
Field
Map from strings to instances of a given value type.
- Parameters:
default – Default value to be used if the field is not set
help (str) – Documentation string for generating model documentation
- serialize()
- Returns:
Serialized form of the field