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'¶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: |
|
---|
If nullable, ‘None’ should be added the values set.
Example:
Gender = Enum(str, 'male', 'female')
Specie = Enum(str, 'cat', 'dog')
ironic.api.types.
IntegerType
(minimum=None, maximum=None)[source]¶Bases: ironic.api.types.UserType
A simple integer type. Can validate a value range.
Parameters: |
|
---|
Example:
Price = IntegerType(minimum=1)
basetype
¶alias of builtins.int
name
= 'integer'¶ironic.api.types.
PassthruResponse
(obj, status_code=None)[source]¶Bases: object
Object to hold the “response” from a passthru call
obj
= None¶Store the result object from the view
status_code
= None¶Store an optional status_code
ironic.api.types.
Registry
[source]¶Bases: object
complex_types
¶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: |
|
---|
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 :
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)
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
= None¶Default value. The attribute will return this instead
of Unset
if no value has been set.
key
= None¶The attribute name in the parent python class.
Set by inspect_class()
mandatory
= None¶True if the attribute is mandatory
readonly
= None¶If True value cannot be set from json/xml input data
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
= None¶property data type
key
= None¶The property name in the parent python class
mandatory
= None¶True if the property is mandatory
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.