congress.data_types module

congress.data_types module

class congress.data_types.Bool

Bases: congress.data_types.Scalar

classmethod marshal(value)
class congress.data_types.CongressDataType

Bases: object

exception CongressDataTypeHierarchyError

Bases: TypeError

exception CongressDataTypeNoParent

Bases: TypeError

classmethod convert_to_ancestor(value, ancestor_type)

Convert this type’s exchange value to ancestor_type’s exchange value

Generally there is no actual conversion because descendant type value is directly interpretable as ancestor type value. The only exception is the conversion from non-string descendents to string. This conversion is needed by Agnostic engine does not support boolean.

Warning

undefined behavior if ancestor_type is not an ancestor of this type.

classmethod least_ancestor(target_types)

Find this type’s least ancestor among target_types

This method helps a data consumer find the least common ancestor of this type among the types the data consumer supports.

Parameters:supported_types – iterable collection of types
Returns:the subclass of CongressDataType which is the least ancestor
classmethod marshal(value)

Validate a value as valid for this type.

Raises ValueError:
 if the value is not valid for this type
class congress.data_types.CongressTypeFiniteDomain

Bases: object

Abstract base class for a Congress type of bounded domain.

Each type inheriting from this class must have a class variable DOMAIN which is a frozenset of the set of values allowed in the type.

class congress.data_types.Float

Bases: congress.data_types.Scalar

classmethod marshal(value)
class congress.data_types.IPAddress

Bases: congress.data_types.Str

classmethod marshal(value)
class congress.data_types.IPNetwork

Bases: congress.data_types.Str

classmethod marshal(value)
class congress.data_types.Int

Bases: congress.data_types.Scalar

classmethod marshal(value)
class congress.data_types.Scalar

Bases: congress.data_types.CongressDataType

Most general type, emcompassing all JSON scalar values

ACCEPTED_VALUE_TYPES = [(<class 'str'>,), <class 'str'>, (<class 'int'>,), <class 'float'>, <class 'bool'>]
classmethod marshal(value)
class congress.data_types.Str

Bases: congress.data_types.Scalar

classmethod marshal(value)
class congress.data_types.TypeNullabilityTuple(type, nullable)

Bases: tuple

nullable

Alias for field number 1

type

Alias for field number 0

class congress.data_types.TypesRegistry

Bases: object

classmethod register(type_class)
classmethod type_class(type_name)
class congress.data_types.UUID

Bases: congress.data_types.Str

classmethod marshal(value)
class congress.data_types.UnqualifiedNameStr

Bases: abc.ABCMeta

metaclass to make str(Type) == Type

congress.data_types.create_congress_enum_type(class_name, enum_items, base_type, catch_all_default_value=None)

Return a sub-type of base_type

representing a value of type base_type from a fixed, finite domain. :param enum_items: collection of items forming the domain :param catch_all_default_value: value to use for any value outside the domain. Defaults to None to disallow any avy value outside the domain.

congress.data_types.nullable(marshal)

decorator to make marshal function accept None value

congress.data_types.type_class

alias of congress.data_types.IPNetwork

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.