# 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
    :param result: (optional) Metric result as a string.
    :param interface_1: (optional) First interface as a string.
    :param interface_2: (optional) Second interface as a string.
    :param streams: (optional) Stream count as an int.
    :param protocol: (optional) Protocol as a string.
    :param direction: (optional) Direction as a string.
    :param value_2: (optional) Second metric value as a float.
    :param units_2: (optional) Second metric units as a string.
    :param device_1: (optional) First device as a string.
    :param device_2: (optional) Second device as a string.
    """
    def __init__(self, **kwargs):
        self.log_file = kwargs.get('log_file', None)
        self.timestamp = kwargs.get('timestamp', None)
        self.metric = kwargs.get('metric', None)
        self.value = kwargs.get('value', None)
        self.units = kwargs.get('units', None)
        self.result = kwargs.get('result', None)
        self.interface_1 = kwargs.get('interface_1', None)
        self.interface_2 = kwargs.get('interface_2', None)
        self.streams = kwargs.get('streams', None)
        self.protocol = kwargs.get('protocol', None)
        self.direction = kwargs.get('direction', None)
        self.value_2 = kwargs.get('value_2', None)
        self.units_2 = kwargs.get('units_2', None)
        self.device_1 = kwargs.get('device_1', None)
        self.device_2 = kwargs.get('device_2', None)

class MetricSchema(Schema):
    log_file = fields.Str()

# 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

    :param result: (optional) Metric result as a string.
    :param interface_1: (optional) First interface as a string.
    :param interface_2: (optional) Second interface as a string.
    :param streams: (optional) Stream count as an int.
    :param protocol: (optional) Protocol as a string.
    :param direction: (optional) Direction as a string.
    :param value_2: (optional) Second metric value as a float.
    :param units_2: (optional) Second metric units as a string.
    :param device_1: (optional) First device as a string.
    :param device_2: (optional) Second device as a string.
    """
    def __init__(self, **kwargs):
        self.log_file = kwargs.get('log_file', None)
        self.timestamp = kwargs.get('timestamp', None)
        self.metric = kwargs.get('metric', None)
        self.value = kwargs.get('value', None)
        self.units = kwargs.get('units', None)
        self.result = kwargs.get('result', None)
        self.interface_1 = kwargs.get('interface_1', None)
        self.interface_2 = kwargs.get('interface_2', None)
        self.streams = kwargs.get('streams', None)
        self.protocol = kwargs.get('protocol', None)
        self.direction = kwargs.get('direction', None)
        self.value_2 = kwargs.get('value_2', None)
        self.units_2 = kwargs.get('units_2', None)
        self.device_1 = kwargs.get('device_1', None)
        self.device_2 = kwargs.get('device_2', None)

class MetricSchema(Schema):
    log_file = fields.Str()

    timestamp = DateTime()