def __init__(self, docs):
    '\n        Initialize from database documents.\n\n        :param docs: Database document.\n        :type docs: list[dict]\n        '
    self._rules = list()
    max_index = (len(docs) - 1)
    for (index, proxy_rule) in enumerate(docs):
        if (index < max_index):
            location = 'proxy rule #{}'.format((index + 1))
            if (proxy_rule.get('pattern', '').strip() == ''):
                _invalid('Pattern is required', location)
            try:
                pattern_re = re.compile(proxy_rule['pattern'])
            except:
                _invalid('Invalid regular expression', location)
            try:
                match = (proxy_rule['match'] == 'MATCHES')
            except KeyError:
                _invalid('Match selector is required', location)
            proxy_url = proxy_rule.get('proxy_url', '')
            if (proxy_url == ''):
                _invalid('Proxy URL is required', location)
        else:
            location = 'last proxy rule'
            if ('pattern' in proxy_rule):
                _invalid('Pattern is not allowed', location)
            if ('match' in proxy_rule):
                _invalid('Pattern is not allowed', location)
            pattern_re = None
            match = None
            proxy_type = None
            proxy_url = proxy_rule.get('proxy_url')
        if (proxy_url is None):
            proxy_type = None
        else:
            try:
                parsed = URL(proxy_url)
                proxy_type = parsed.scheme
                if (proxy_type not in self.PROXY_SCHEMES):
                    raise ValueError()
            except:
                schemes = ', '.join(self.PROXY_SCHEMES)
                _invalid(f'Must have a valid URL with one of the following schemes: {schemes}', location)
        self._rules.append((pattern_re, match, proxy_type, proxy_url))
Initialize from database documents.

:param docs: Database document.
:type docs: list[dict]
def __init__(self, docs):
    '\n        Initialize from database documents.\n\n        :param docs: Database document.\n        :type docs: list[dict]\n        '
    self._rules = list()
    max_index = (len(docs) - 1)
    for (index, proxy_rule) in enumerate(docs):
        if (index < max_index):
            location = 'proxy rule #{}'.format((index + 1))
            if (proxy_rule.get('pattern', ).strip() == ):
                _invalid('Pattern is required', location)
            try:
                pattern_re = re.compile(proxy_rule['pattern'])
            except:
                _invalid('Invalid regular expression', location)
            try:
                match = (proxy_rule['match'] == 'MATCHES')
            except KeyError:
                _invalid('Match selector is required', location)
            proxy_url = proxy_rule.get('proxy_url', )
            if (proxy_url == ):
                _invalid('Proxy URL is required', location)
        else:
            location = 'last proxy rule'
            if ('pattern' in proxy_rule):
                _invalid('Pattern is not allowed', location)
            if ('match' in proxy_rule):
                _invalid('Pattern is not allowed', location)
            pattern_re = None
            match = None
            proxy_type = None
            proxy_url = proxy_rule.get('proxy_url')
        if (proxy_url is None):
            proxy_type = None
        else:
            try:
                parsed = URL(proxy_url)
                proxy_type = parsed.scheme
                if (proxy_type not in self.PROXY_SCHEMES):
                    raise ValueError()
            except:
                schemes = ', '.join(self.PROXY_SCHEMES)
                _invalid(f'Must have a valid URL with one of the following schemes: {schemes}', location)
        self._rules.append((pattern_re, match, proxy_type, proxy_url))