#
#  BEGIN LICENSE
#  Copyright (c) Blue Mind SAS, 2012-2016
#
#  This file is part of BlueMind. BlueMind is a messaging and collaborative
#  solution.
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of either the GNU Affero General Public License as
#  published by the Free Software Foundation (version 3 of the License).
#
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
#  See LICENSE.txt
#  END LICENSE
#
import requests
from netbluemind.python import serder
from enum import Enum


class ErrorCode(Enum):
    UNKNOWN = 'UNKNOWN'
    PERMISSION_DENIED = 'PERMISSION_DENIED'
    FAILURE = 'FAILURE'
    INVALID_ID = 'INVALID_ID'
    INVALID_PARAMETER = 'INVALID_PARAMETER'
    AUTHENTICATION_FAIL = 'AUTHENTICATION_FAIL'
    SQL_ERROR = 'SQL_ERROR'
    NOT_FOUND = 'NOT_FOUND'
    ALREADY_EXISTS = 'ALREADY_EXISTS'
    FORBIDDEN = 'FORBIDDEN'
    ENTITY_TOO_LARGE = 'ENTITY_TOO_LARGE'
    INVALID_QUERY = 'INVALID_QUERY'
    INVALID_XML_RECEIVED = 'INVALID_XML_RECEIVED'
    CHILD_GROUP_MUST_EXIST = 'CHILD_GROUP_MUST_EXIST'
    CANT_DELETE_MYSELF = 'CANT_DELETE_MYSELF'
    DELEGATION_RESTRICTION = 'DELEGATION_RESTRICTION'
    INVALID_PASSWORD = 'INVALID_PASSWORD'
    LOGIN_ALREADY_USED = 'LOGIN_ALREADY_USED'
    INVALID_LOGIN = 'INVALID_LOGIN'
    EMPTY_LASTNAME = 'EMPTY_LASTNAME'
    EMPTY_VACATION_MESSAGE = 'EMPTY_VACATION_MESSAGE'
    VACATION_WITHOUT_MAILBOX = 'VACATION_WITHOUT_MAILBOX'
    FORWARDING_WITHOUT_MAILBOX = 'FORWARDING_WITHOUT_MAILBOX'
    FORWARDING_INVALID_EMAIL = 'FORWARDING_INVALID_EMAIL'
    INVALID_MAIL_SERVER = 'INVALID_MAIL_SERVER'
    INVALID_GROUP_NAME = 'INVALID_GROUP_NAME'
    FORWARDING_TO_OWN_MAILBOX = 'FORWARDING_TO_OWN_MAILBOX'
    SAME_PARENT_AND_CHILD_GROUP = 'SAME_PARENT_AND_CHILD_GROUP'
    INCLUSION_GROUP_LOOP = 'INCLUSION_GROUP_LOOP'
    EMAIL_ALREADY_USED = 'EMAIL_ALREADY_USED'
    INVALID_EMAIL = 'INVALID_EMAIL'
    MAIL_QUOTA_OVER_DOMAIN_LIMIT = 'MAIL_QUOTA_OVER_DOMAIN_LIMIT'
    NOT_GLOBAL_ADMIN = 'NOT_GLOBAL_ADMIN'
    DOMAIN_NAME_ALREADY_USED = 'DOMAIN_NAME_ALREADY_USED'
    INVALID_MAILSHARE_NAME = 'INVALID_MAILSHARE_NAME'
    INVALID_RESOURCE_NAME = 'INVALID_RESOURCE_NAME'
    OLD_PASSWORD_WRONG = 'OLD_PASSWORD_WRONG'
    OLD_PASSWORD_SAME_AS_NEW = 'OLD_PASSWORD_SAME_AS_NEW'
    IP_ADDRESS_ALREADY_USED = 'IP_ADDRESS_ALREADY_USED'
    MBOX_RENAME_FAILED = 'MBOX_RENAME_FAILED'
    INVALID_HOST_NAME = 'INVALID_HOST_NAME'
    EMPTY_EVENT_TITLE = 'EMPTY_EVENT_TITLE'
    NO_DURATION_EVENT = 'NO_DURATION_EVENT'
    NO_EVENT_DATE = 'NO_EVENT_DATE'
    NO_EVENT_TYPE = 'NO_EVENT_TYPE'
    EVENT_PRIVACY_INVALID = 'EVENT_PRIVACY_INVALID'
    EVENT_ERROR = 'EVENT_ERROR'
    CALENDAR_AUTHORISATION_ERROR = 'CALENDAR_AUTHORISATION_ERROR'
    CONTACT_DOMAIN_FORBIDDEN = 'CONTACT_DOMAIN_FORBIDDEN'
    EVENT_ENDREPEAT_PRIOR_TO_EVENT_DATE = 'EVENT_ENDREPEAT_PRIOR_TO_EVENT_DATE'
    INVALID_DOMAIN_NAME = 'INVALID_DOMAIN_NAME'
    GROUP_NAME_ALREADY_USED = 'GROUP_NAME_ALREADY_USED'
    INVALID_VACATION_RANGE = 'INVALID_VACATION_RANGE'
    EMPTY_DLIST_LABEL = 'EMPTY_DLIST_LABEL'
    EMPTY_DLIST_FOLDER = 'EMPTY_DLIST_FOLDER'
    DLIST_LOOP = 'DLIST_LOOP'
    CANT_UPDATE_ACL_IMPLICIT_RIGHTS = 'CANT_UPDATE_ACL_IMPLICIT_RIGHTS'
    USER_SPLIT_REQUIRES_SPLIT_DOMAIN = 'USER_SPLIT_REQUIRES_SPLIT_DOMAIN'
    SLAVE_RELAY_REQUIRES_SPLIT_DOMAIN = 'SLAVE_RELAY_REQUIRES_SPLIT_DOMAIN'
    INVALID_USER_LDAP_FILTER = 'INVALID_USER_LDAP_FILTER'
    SEC_GROUP_RM = 'SEC_GROUP_RM'
    NOT_IN_GLOBAL_DOMAIN = 'NOT_IN_GLOBAL_DOMAIN'
    NO_BACKUP_SERVER_FOUND = 'NO_BACKUP_SERVER_FOUND'
    OPERATION_ALREADY_RUNNING = 'OPERATION_ALREADY_RUNNING'
    INVALID_AD_HOST_NAME = 'INVALID_AD_HOST_NAME'
    JOB_FINISHED = 'JOB_FINISHED'
    INVALID_LICENSE = 'INVALID_LICENSE'
    HSM_MISSING_POLICY = 'HSM_MISSING_POLICY'
    INCOMPATIBLE_SMTP_TAGS = 'INCOMPATIBLE_SMTP_TAGS'
    INVALID_MAILBOX_NAME = 'INVALID_MAILBOX_NAME'
    TAG_ALREADY_EXIST = 'TAG_ALREADY_EXIST'
    INVALID_LINKED_MAILSHARE = 'INVALID_LINKED_MAILSHARE'
    MAILSHARE_GROUP_LINKED = 'MAILSHARE_GROUP_LINKED'
    SERVER_NOT_FOUND = 'SERVER_NOT_FOUND'
    DEPRECATED = 'DEPRECATED'
    INVALID_GROUP_MEMBER = 'INVALID_GROUP_MEMBER'
    EMPTY_EVENT_ATTACHMENT_VALUE = 'EMPTY_EVENT_ATTACHMENT_VALUE'
    TIMEOUT = 'TIMEOUT'
    VERSION_HAS_CHANGED = 'VERSION_HAS_CHANGED'
    MULTIPLE_EVENT_COUNTERS = 'MULTIPLE_EVENT_COUNTERS'
    EVENT_ACCEPTS_NO_COUNTERS = 'EVENT_ACCEPTS_NO_COUNTERS'
    EVENT_WEEKDAY_INVALID = 'EVENT_WEEKDAY_INVALID'
    EVENT_DUPLICATED_RECURID = 'EVENT_DUPLICATED_RECURID'
    MAX_ITEM_COUNT = 'MAX_ITEM_COUNT'


class __ErrorCodeSerDer__:
    def __init__(self):
        pass

    def parse(self, value):
        if (value == None):
            return None
        instance = ErrorCode[value]
        return instance

    def encode(self, value):
        if (value == None):
            return None
        instance = value.value
        return instance
