"""
DO NOT EDIT THIS FILE!!
This file is automatically generated by the process_schemas.py program
in the scripts directory. It is not intended to be edited directly. If
you need to update the GEL protocol classes, please run the script
on the appropriate schema version.
"""
from protocols.protocol import ProtocolElement
from protocols.protocol import SearchRequest
from protocols.protocol import SearchResponse
from protocols.protocol import avro_parse

import avro.schema

version = '0.1.0'


class API(ProtocolElement):
    """
    Represents the contract of API dependency (either REST or OTHER)
    """
    _schemaSource = """
{"type": "record", "name": "API", "namespace": "org.gel.models.system.avro", "doc": "", "fields":
[{"name": "type", "type": {"type": "enum", "name": "APIType", "symbols": ["REST", "MONGODB",
"OTHER"]}}, {"name": "description", "type": "string"}, {"name": "url", "type": {"type": "array",
"items": "string"}}, {"name": "status", "type": {"type": "enum", "name": "Status", "doc": "",
"symbols": ["OK", "DOWN"]}}, {"name": "additionalProperties", "type": ["null", {"type": "map",
"values": "string"}]}]}
"""
    schema = avro_parse(_schemaSource)
    requiredFields = {
        "additionalProperties",
        "description",
        "status",
        "type",
        "url",
    }

    @classmethod
    def isEmbeddedType(cls, fieldName):
        embeddedTypes = {}
        return fieldName in embeddedTypes

    @classmethod
    def getEmbeddedType(cls, fieldName):
        embeddedTypes = {}

        return embeddedTypes[fieldName]

    __slots__ = [
        'additionalProperties', 'description', 'status', 'type', 'url'
    ]

    def __init__(self, **kwargs):
        self.additionalProperties = kwargs.get(
            'additionalProperties', None)
        self.description = kwargs.get(
            'description', None)
        self.status = kwargs.get(
            'status', None)
        self.type = kwargs.get(
            'type', None)
        self.url = kwargs.get(
            'url', None)


class APIType(object):
    """
    No documentation
    """
    REST = "REST"
    MONGODB = "MONGODB"
    OTHER = "OTHER"

    def __hash__(self):
        return str(self).__hash__()


class DataStore(ProtocolElement):
    """
    Represents the contract of DataStore. Type of the datastore can be
    mongodb, postgres, etc
    """
    _schemaSource = """
{"type": "record", "name": "DataStore", "namespace": "org.gel.models.system.avro", "doc": "",
"fields": [{"name": "type", "type": "string"}, {"name": "description", "type": "string"}, {"name":
"url", "type": {"type": "array", "items": "string"}}, {"name": "status", "type": {"type": "enum",
"name": "Status", "doc": "", "symbols": ["OK", "DOWN"]}}, {"name": "additionalProperties", "type":
["null", {"type": "map", "values": "string"}]}]}
"""
    schema = avro_parse(_schemaSource)
    requiredFields = {
        "additionalProperties",
        "description",
        "status",
        "type",
        "url",
    }

    @classmethod
    def isEmbeddedType(cls, fieldName):
        embeddedTypes = {}
        return fieldName in embeddedTypes

    @classmethod
    def getEmbeddedType(cls, fieldName):
        embeddedTypes = {}

        return embeddedTypes[fieldName]

    __slots__ = [
        'additionalProperties', 'description', 'status', 'type', 'url'
    ]

    def __init__(self, **kwargs):
        self.additionalProperties = kwargs.get(
            'additionalProperties', None)
        self.description = kwargs.get(
            'description', None)
        self.status = kwargs.get(
            'status', None)
        self.type = kwargs.get(
            'type', None)
        self.url = kwargs.get(
            'url', None)


class Dependencies(ProtocolElement):
    """
    Represents contract of all dependencies for a service
    """
    _schemaSource = """
{"type": "record", "name": "Dependencies", "namespace": "org.gel.models.system.avro", "doc": "",
"fields": [{"name": "datastores", "type": {"type": "array", "items": {"type": "record", "name":
"DataStore", "doc": "", "fields": [{"name": "type", "type": "string"}, {"name": "description",
"type": "string"}, {"name": "url", "type": {"type": "array", "items": "string"}}, {"name": "status",
"type": {"type": "enum", "name": "Status", "doc": "", "symbols": ["OK", "DOWN"]}}, {"name":
"additionalProperties", "type": ["null", {"type": "map", "values": "string"}]}]}}}, {"name": "apis",
"type": {"type": "array", "items": {"type": "record", "name": "API", "doc": "", "fields": [{"name":
"type", "type": {"type": "enum", "name": "APIType", "symbols": ["REST", "MONGODB", "OTHER"]}},
{"name": "description", "type": "string"}, {"name": "url", "type": {"type": "array", "items":
"string"}}, {"name": "status", "type": "Status"}, {"name": "additionalProperties", "type": ["null",
{"type": "map", "values": "string"}]}]}}}]}
"""
    schema = avro_parse(_schemaSource)
    requiredFields = {
        "apis",
        "datastores",
    }

    @classmethod
    def isEmbeddedType(cls, fieldName):
        embeddedTypes = {
            'apis': API,
            'datastores': DataStore,
        }
        return fieldName in embeddedTypes

    @classmethod
    def getEmbeddedType(cls, fieldName):
        embeddedTypes = {
            'apis': API,
            'datastores': DataStore,
        }

        return embeddedTypes[fieldName]

    __slots__ = [
        'apis', 'datastores'
    ]

    def __init__(self, **kwargs):
        self.apis = kwargs.get(
            'apis', None)
        self.datastores = kwargs.get(
            'datastores', None)


class ServiceHealth(ProtocolElement):
    """
    No documentation
    """
    _schemaSource = """
{"type": "record", "name": "ServiceHealth", "namespace": "org.gel.models.system.avro", "fields":
[{"name": "serviceName", "type": "string"}, {"name": "requestUrl", "type": "string"}, {"name":
"datetime", "type": "string"}, {"name": "status", "type": {"type": "enum", "name": "Status", "doc":
"", "symbols": ["OK", "DOWN"]}}, {"name": "dependencies", "type": {"type": "record", "name":
"Dependencies", "doc": "", "fields": [{"name": "datastores", "type": {"type": "array", "items":
{"type": "record", "name": "DataStore", "doc": "", "fields": [{"name": "type", "type": "string"},
{"name": "description", "type": "string"}, {"name": "url", "type": {"type": "array", "items":
"string"}}, {"name": "status", "type": "Status"}, {"name": "additionalProperties", "type": ["null",
{"type": "map", "values": "string"}]}]}}}, {"name": "apis", "type": {"type": "array", "items":
{"type": "record", "name": "API", "doc": "", "fields": [{"name": "type", "type": {"type": "enum",
"name": "APIType", "symbols": ["REST", "MONGODB", "OTHER"]}}, {"name": "description", "type":
"string"}, {"name": "url", "type": {"type": "array", "items": "string"}}, {"name": "status", "type":
"Status"}, {"name": "additionalProperties", "type": ["null", {"type": "map", "values":
"string"}]}]}}}]}}]}
"""
    schema = avro_parse(_schemaSource)
    requiredFields = {
        "datetime",
        "dependencies",
        "requestUrl",
        "serviceName",
        "status",
    }

    @classmethod
    def isEmbeddedType(cls, fieldName):
        embeddedTypes = {
            'dependencies': Dependencies,
        }
        return fieldName in embeddedTypes

    @classmethod
    def getEmbeddedType(cls, fieldName):
        embeddedTypes = {
            'dependencies': Dependencies,
        }

        return embeddedTypes[fieldName]

    __slots__ = [
        'datetime', 'dependencies', 'requestUrl', 'serviceName',
        'status'
    ]

    def __init__(self, **kwargs):
        self.datetime = kwargs.get(
            'datetime', None)
        self.dependencies = kwargs.get(
            'dependencies', Dependencies())
        self.requestUrl = kwargs.get(
            'requestUrl', None)
        self.serviceName = kwargs.get(
            'serviceName', None)
        self.status = kwargs.get(
            'status', None)


class Status(object):
    """
    Represents the contract of service status
    """
    OK = "OK"
    DOWN = "DOWN"

    def __hash__(self):
        return str(self).__hash__()
