ironic.api.types module¶
-
class
ironic.api.types.
BinaryType
[source]¶ Bases:
ironic.api.types.UserType
A user type that use base64 strings to carry binary data.
-
basetype
¶ alias of
builtins.bytes
-
name
= 'binary'¶
-
-
class
ironic.api.types.
Enum
(basetype, *values, **kw)[source]¶ Bases:
ironic.api.types.UserType
A simple enumeration type. Can be based on any non-complex type.
- Parameters
basetype – The actual data type
values – A set of possible values
If nullable, ‘None’ should be added the values set.
Example:
Gender = Enum(str, 'male', 'female') Specie = Enum(str, 'cat', 'dog')
-
class
ironic.api.types.
IntegerType
(minimum=None, maximum=None)[source]¶ Bases:
ironic.api.types.UserType
A simple integer type. Can validate a value range.
- Parameters
minimum – Possible minimum value
maximum – Possible maximum value
Example:
Price = IntegerType(minimum=1)
-
basetype
¶ alias of
builtins.int
-
name
= 'integer'¶
-
class
ironic.api.types.
PassthruResponse
(obj, status_code=None)[source]¶ Bases:
object
Object to hold the “response” from a passthru call
-
obj
¶ Store the result object from the view
-
status_code
¶ Store an optional status_code
-
-
class
ironic.api.types.
Registry
[source]¶ Bases:
object
-
property
complex_types
¶
-
property
-
class
ironic.api.types.
StringType
(min_length=None, max_length=None, pattern=None)[source]¶ Bases:
ironic.api.types.UserType
A simple string type. Can validate a length and a pattern.
- Parameters
min_length – Possible minimum length
max_length – Possible maximum length
pattern – Possible string pattern
Example:
Name = StringType(min_length=1, pattern='^[a-zA-Z ]*$')
-
basetype
¶ alias of
builtins.str
-
name
= 'string'¶
-
ironic.api.types.
binary
= <ironic.api.types.BinaryType object>¶ The binary almost-native type
-
ironic.api.types.
inspect_class
(class_)[source]¶ Extract a list of (name, wsattr|wsproperty) for the given class
-
ironic.api.types.
sort_attributes
(class_, attributes)[source]¶ Sort a class attributes list.
3 mechanisms are attempted :
Look for a _wsme_attr_order attribute on the class. This allow to define an arbitrary order of the attributes (useful for generated types).
Access the object source code to find the declaration order.
Sort by alphabetically
-
class
ironic.api.types.
wsattr
(datatype, mandatory=False, name=None, default=Unset, readonly=False)[source]¶ Bases:
object
Complex type attribute definition.
Example:
class MyComplexType(ctypes.Base): optionalvalue = int mandatoryvalue = wsattr(int, mandatory=True) named_value = wsattr(int, name='named.value')
After inspection, the non-wsattr attributes will be replaced, and the above class will be equivalent to:
class MyComplexType(ctypes.Base): optionalvalue = wsattr(int) mandatoryvalue = wsattr(int, mandatory=True)
-
property
datatype
¶ attribute data type. Can be either an actual type, or a type name, in which case the actual type will be determined when needed (generally just before scanning the api).
-
default
¶ Default value. The attribute will return this instead of
Unset
if no value has been set.
-
key
¶ The attribute name in the parent python class. Set by
inspect_class()
-
mandatory
¶ True if the attribute is mandatory
-
readonly
¶ If True value cannot be set from json/xml input data
-
property
-
class
ironic.api.types.
wsproperty
(datatype, fget, fset=None, mandatory=False, doc=None, name=None)[source]¶ Bases:
property
A specialised
property
to define typed-property on complex types.Example:
class MyComplexType(Base): def get_aint(self): return self._aint def set_aint(self, value): assert avalue < 10 # Dummy input validation self._aint = value aint = wsproperty(int, get_aint, set_aint, mandatory=True)
-
datatype
¶ property data type
-
key
¶ The property name in the parent python class
-
mandatory
¶ True if the property is mandatory
-