# Path: cdrouter/cdr_datetime.py
# class DateTime(fields.DateTime):
#     def __init__(self, format=None, **kwargs):
#         super(DateTime, self).__init__(format=format, **kwargs)
#         
#     def _serialize(self, value, attr, obj):
#         try:
#             return super(DateTime, self)._serialize(value, attr, obj)
#         except ValidationError:
#             return datetime.min
# 
#     def _deserialize(self, value, attr, data):
#         try:
#             return super(DateTime, self)._deserialize(value, attr, data)
#         except ValidationError:
#             return datetime.min
# 
# Path: cdrouter/cdr_dictfield.py
# class DictField(fields.Field):
#     def __init__(self, key_field, nested_field, *args, **kwargs):
#         super(DictField, self).__init__(self, *args, **kwargs)
#         self.key_field = key_field
#         self.nested_field = nested_field
# 
#     def _deserialize(self, value, attr, data):
#         if not isinstance(value, collections.Mapping):
#             self.fail('invalid')
# 
#         ret = {}
#         for key, val in value.items():
#             k = self.key_field._deserialize(key, attr, data)
#             data, errors = self.nested_field.load(val)
#             if errors:
#                 raise ValidationError(errors, data=data)
#             v = data
#             ret[k] = v
# 
#         return ret
# 
#     def _serialize(self, value, attr, obj):
#         ret = {}
#         for key, val in value.items():
#             k = self.key_field._serialize(key, attr, obj)
#             data, errors = self.nested_field.dump(val)
#             if errors:
#                 raise ValidationError(errors, data=data)
#             v = data
#             ret[k] = v
#         return ret
# 
# Path: cdrouter/testresults.py
# class TestResultSchema(Schema):
#     id = fields.Int(as_string=True)
#     seq = fields.Int(as_string=True)
#     loop = fields.Int(as_string=True)
#     result = fields.Str()
#     alerts = fields.Int()
#     retries = fields.Int()
#     started = DateTime()
#     duration = fields.Int()
#     flagged = fields.Bool()
#     name = fields.Str()
#     description = fields.Str()
#     skip_name = fields.Str()
#     skip_reason = fields.Str()
#     log = fields.Str()
#     note = fields.Str()
# 
#     @post_load
#     def post_load(self, data):
#         return TestResult(**data)
# 
# Path: cdrouter/alerts.py
# class AlertSchema(Schema):
#     id = fields.Int(as_string=True)
#     idx = fields.Int(as_string=True)
#     created = DateTime()
#     updated = DateTime()
# 
#     seq = fields.Int(as_string=True)
#     loop = fields.Int(as_string=True)
#     test_name = fields.Str()
#     test_description = fields.Str()
# 
#     category = fields.Str()
#     description = fields.Str(missing=None)
#     dest_ip = fields.Str()
#     dest_port = fields.Int(as_string=True, missing=None)
#     interface = fields.Str()
#     payload = fields.Str(missing=None)
#     payload_ascii = fields.Str(missing=None)
#     payload_hex = fields.Str(missing=None)
#     proto = fields.Str()
#     references = fields.List(fields.Str(), missing=None)
#     rev = fields.Int(as_string=True)
#     rule = fields.Str()
#     rule_set = fields.Str()
#     severity = fields.Int(as_string=True)
#     sid = fields.Int(as_string=True)
#     signature = fields.Str()
#     src_ip = fields.Str()
#     src_port = fields.Int(as_string=True, missing=None)
# 
#     @post_load
#     def post_load(self, data):
#         return Alert(**data)


import collections
import io
from requests_toolbelt.downloadutils import stream
from marshmallow import Schema, fields, post_load
from marshmallow.exceptions import ValidationError
from .cdr_datetime import DateTime
from .cdr_dictfield import DictField
from .testresults import TestResultSchema
from .alerts import AlertSchema
class ResultSchema(Schema):
    id = fields.Int(as_string=True)
    created = DateTime()
    updated = DateTime()
    result = fields.Str()
    status = fields.Str()
    loops = fields.Int()
    tests = fields.Int()
    passed = fields.Int(attribute='pass', load_from='pass', dump_to='pass')
    fail = fields.Int()
    alerts = fields.Int()
    duration = fields.Int()
    size_on_disk = fields.Int()
    starred = fields.Bool()
    archived = fields.Bool()
    result_dir = fields.Str()
    agent_name = fields.Str()
    package_name = fields.Str()
    device_name = fields.Str()
    config_name = fields.Str()
    package_id = fields.Int(as_string=True)
    device_id = fields.Int(as_string=True)
    config_id = fields.Int(as_string=True)
    user_id = fields.Int(as_string=True)
    note = fields.Str()
    pause_message = fields.Str(missing=None)
    build_info = fields.Str(missing=None)
    tags = fields.List(fields.Str())
    testcases = fields.List(fields.Str(), missing=None)
    options = fields.Nested(OptionsSchema)

# Path: cdrouter/cdr_datetime.py
# class DateTime(fields.DateTime):
#     def __init__(self, format=None, **kwargs):
#         super(DateTime, self).__init__(format=format, **kwargs)
#         
#     def _serialize(self, value, attr, obj):
#         try:
#             return super(DateTime, self)._serialize(value, attr, obj)
#         except ValidationError:
#             return datetime.min
# 
#     def _deserialize(self, value, attr, data):
#         try:
#             return super(DateTime, self)._deserialize(value, attr, data)
#         except ValidationError:
#             return datetime.min
# 
# Path: cdrouter/cdr_dictfield.py
# class DictField(fields.Field):
#     def __init__(self, key_field, nested_field, *args, **kwargs):
#         super(DictField, self).__init__(self, *args, **kwargs)
#         self.key_field = key_field
#         self.nested_field = nested_field
# 
#     def _deserialize(self, value, attr, data):
#         if not isinstance(value, collections.Mapping):
#             self.fail('invalid')
# 
#         ret = {}
#         for key, val in value.items():
#             k = self.key_field._deserialize(key, attr, data)
#             data, errors = self.nested_field.load(val)
#             if errors:
#                 raise ValidationError(errors, data=data)
#             v = data
#             ret[k] = v
# 
#         return ret
# 
#     def _serialize(self, value, attr, obj):
#         ret = {}
#         for key, val in value.items():
#             k = self.key_field._serialize(key, attr, obj)
#             data, errors = self.nested_field.dump(val)
#             if errors:
#                 raise ValidationError(errors, data=data)
#             v = data
#             ret[k] = v
#         return ret
# 
# Path: cdrouter/testresults.py
# class TestResultSchema(Schema):
#     id = fields.Int(as_string=True)
#     seq = fields.Int(as_string=True)
#     loop = fields.Int(as_string=True)
#     result = fields.Str()
#     alerts = fields.Int()
#     retries = fields.Int()
#     started = DateTime()
#     duration = fields.Int()
#     flagged = fields.Bool()
#     name = fields.Str()
#     description = fields.Str()
#     skip_name = fields.Str()
#     skip_reason = fields.Str()
#     log = fields.Str()
#     note = fields.Str()
# 
#     @post_load
#     def post_load(self, data):
#         return TestResult(**data)
# 
# Path: cdrouter/alerts.py
# class AlertSchema(Schema):
#     id = fields.Int(as_string=True)
#     idx = fields.Int(as_string=True)
#     created = DateTime()
#     updated = DateTime()
# 
#     seq = fields.Int(as_string=True)
#     loop = fields.Int(as_string=True)
#     test_name = fields.Str()
#     test_description = fields.Str()
# 
#     category = fields.Str()
#     description = fields.Str(missing=None)
#     dest_ip = fields.Str()
#     dest_port = fields.Int(as_string=True, missing=None)
#     interface = fields.Str()
#     payload = fields.Str(missing=None)
#     payload_ascii = fields.Str(missing=None)
#     payload_hex = fields.Str(missing=None)
#     proto = fields.Str()
#     references = fields.List(fields.Str(), missing=None)
#     rev = fields.Int(as_string=True)
#     rule = fields.Str()
#     rule_set = fields.Str()
#     severity = fields.Int(as_string=True)
#     sid = fields.Int(as_string=True)
#     signature = fields.Str()
#     src_ip = fields.Str()
#     src_port = fields.Int(as_string=True, missing=None)
# 
#     @post_load
#     def post_load(self, data):
#         return Alert(**data)


# Path: cdrouter/results.py
import collections
import io
from requests_toolbelt.downloadutils import stream
from marshmallow import Schema, fields, post_load
from marshmallow.exceptions import ValidationError
from .cdr_datetime import DateTime
from .cdr_dictfield import DictField
from .testresults import TestResultSchema
from .alerts import AlertSchema

class ResultSchema(Schema):
    id = fields.Int(as_string=True)
    created = DateTime()
    updated = DateTime()
    result = fields.Str()
    status = fields.Str()
    loops = fields.Int()
    tests = fields.Int()
    passed = fields.Int(attribute='pass', load_from='pass', dump_to='pass')
    fail = fields.Int()
    alerts = fields.Int()
    duration = fields.Int()
    size_on_disk = fields.Int()
    starred = fields.Bool()
    archived = fields.Bool()
    result_dir = fields.Str()
    agent_name = fields.Str()
    package_name = fields.Str()
    device_name = fields.Str()
    config_name = fields.Str()
    package_id = fields.Int(as_string=True)
    device_id = fields.Int(as_string=True)
    config_id = fields.Int(as_string=True)
    user_id = fields.Int(as_string=True)
    note = fields.Str()
    pause_message = fields.Str(missing=None)
    build_info = fields.Str(missing=None)
    tags = fields.List(fields.Str())
    testcases = fields.List(fields.Str(), missing=None)
    options = fields.Nested(OptionsSchema)

    features = DictField(fields.Str(), FeatureSchema())