class ValidationError(base.DesignateObject): fields = { 'path': fields.AnyField(nullable=True), 'message': fields.AnyField(nullable=True), 'validator': fields.AnyField(nullable=True), 'validator_value': fields.AnyField(nullable=True), 'raw': fields.AnyField(nullable=True), } @classmethod def from_js_error(cls, js_error): """Convert a JSON Schema ValidationError instance into a ValidationError instance. """ e = cls() e.path = list(getattr(js_error, 'releative_path', js_error.path)) e.message = js_error.message e.validator = js_error.validator e.validator_value = js_error.validator_value e.raw = js_error._contents() return e
class TestObject(objects.DesignateObject): fields = { 'id': fields.AnyField(nullable=True), 'name': fields.AnyField(nullable=True), 'nested': fields.ObjectFields('TestObject', nullable=True), 'nested_list': fields.ObjectFields('TestObjectList', nullable=True), }
class Quota(base.DictObjectMixin, base.PersistentObjectMixin, base.DesignateObject): fields = { 'tenant_id': fields.AnyField(nullable=True), 'resource': fields.AnyField(nullable=True), 'hard_limit': fields.AnyField(nullable=True) } STRING_KEYS = ['resource', 'tenant_id', 'hard_limit']
class Tenant(base.DesignateObject, base.DictObjectMixin): def __init__(self, *args, **kwargs): super(Tenant, self).__init__(*args, **kwargs) fields = { 'id': fields.AnyField(nullable=True), 'zone_count': fields.AnyField(nullable=True), 'zones': fields.AnyField(nullable=True) } STRING_KEYS = ['id']
class PoolTarget(base.DictObjectMixin, base.PersistentObjectMixin, base.DesignateObject): fields = { 'pool_id': fields.UUIDFields(nullable=True), 'type': fields.AnyField(nullable=True), 'tsigkey_id': fields.UUIDFields(nullable=True), 'description': fields.StringFields(maxLength=160, nullable=True), 'masters': fields.ObjectFields('PoolTargetMasterList'), 'options': fields.ObjectFields('PoolTargetOptionList'), 'backend': fields.AnyField(nullable=True), } STRING_KEYS = ['id', 'type', 'pool_id']
class Record(base.DesignateObject, base.PersistentObjectMixin, base.DictObjectMixin): def __init__(self, *args, **kwargs): super(Record, self).__init__(*args, **kwargs) fields = { 'shard': fields.IntegerFields(nullable=True, minimum=0, maximum=4095), 'data': fields.AnyField(nullable=True), 'zone_id': fields.UUIDFields(nullable=True), 'managed': fields.BooleanField(nullable=True), 'managed_resource_type': fields.StringFields(nullable=True, maxLength=160), 'managed_resource_id': fields.UUIDFields(nullable=True), 'managed_plugin_name': fields.StringFields(nullable=True, maxLength=160), 'managed_plugin_type': fields.StringFields(nullable=True, maxLength=160), 'hash': fields.StringFields(nullable=True, maxLength=32), 'description': fields.StringFields(nullable=True, maxLength=160), 'status': fields.EnumField( valid_values=['ACTIVE', 'PENDING', 'ERROR', 'DELETED'], nullable=True), 'tenant_id': fields.StringFields(nullable=True), 'recordset_id': fields.UUIDFields(nullable=True), 'managed_tenant_id': fields.StringFields(nullable=True), 'managed_resource_region': fields.StringFields(nullable=True, maxLength=160), 'managed_extra': fields.StringFields(nullable=True, maxLength=160), 'action': fields.EnumField(valid_values=['CREATE', 'DELETE', 'UPDATE', 'NONE'], nullable=True), 'serial': fields.IntegerFields(nullable=True, minimum=1, maximum=4294967295), } @classmethod def get_recordset_schema_changes(cls): # This is to allow record types to override the validation on a # recordset return {} STRING_KEYS = ['id', 'recordset_id', 'data'] def __str__(self): record = self.to_dict() record['data'] = record['data'][:35] return (self._make_obj_str(self.STRING_KEYS) % record)
class PoolTargetOption(base.DictObjectMixin, base.PersistentObjectMixin, base.DesignateObject): fields = { 'pool_target_id': fields.UUIDFields(nullable=True), 'key': fields.StringFields(maxLength=255), 'value': fields.AnyField(), } STRING_KEYS = ['id', 'key', 'value', 'pool_target_id']