# Path: acos_client/errors.py
# class RequiredAttributeNotSpecified(Exception):
# class ACOSException(Exception):
# class ACOSUnsupportedVersion(ACOSException):
# class ACOSUnknownError(ACOSException):
# class AddressSpecifiedIsInUse(ACOSException):
# class AuthenticationFailure(ACOSException):
# class InvalidSessionID(ACOSException):
# class Exists(ACOSException):
# class NotFound(ACOSException):
# class NoSuchServiceGroup(ACOSException):
# class NotImplemented(ACOSException):
# class InUse(ACOSException):
# class InvalidPartitionParameter(ACOSException):
# class MemoryFault(ACOSException):
# class InvalidParameter(ACOSException):
# class OutOfPartitions(ACOSException):
# class PartitionIdExists(ACOSException):
# class HMMissingHttpPassive(ACOSException):
# class AxapiJsonFormatError(ACOSException):
# class ConfigManagerNotReady(ACOSException):
# class DhcpAcquireFailed(ACOSException):
# class InvalidInteger(ACOSException):
# class CertificateParsingFailed(ACOSException):
# class KeyParsingFailed(ACOSException):
# class FeatureNotSupported(ACOSException):
# class ACOSSystemNotReady(ACOSException):
# class ACOSSystemIsBusy(ACOSException):
# class LicenseOptionNotAllowed(ACOSException):
#     def __init__(self, url, attribute, requires=[]):
#     def __init__(self, code=1, msg=''):
#     def __str__(self):


import ipaddress
import six
import time
from acos_client import errors as ae
from __future__ import absolute_import
from __future__ import unicode_literals




class BaseV30(object):

    def __init__(self, client):
        self.client = client
        self.http = client.http
        self.auth_header = {}

    def minimal_dict(self, my_dict, exclude=[]):
        return dict((k, v) for k, v in my_dict.items() if v is not None or k in exclude)

    def url(self, action):
        self.auth_header['Authorization'] = "A10 %s" % self.client.session.id
        return ("/axapi/v3" + action)

    def _request(self, method, action, params, retry_count=0, max_retries=None,
                 timeout=None, axapi_args=None, **kwargs):
        if retry_count > 24:
            raise ae.ACOSUnknownError()

        try:
            return self.client.http.request(method, self.url(action), params, self.auth_header,
                                            max_retries=max_retries, timeout=timeout,
                                            axapi_args=axapi_args, **kwargs)
        except (ae.InvalidSessionID, ae.ConfigManagerNotReady) as e:

# Path: acos_client/errors.py
# class RequiredAttributeNotSpecified(Exception):
# class ACOSException(Exception):
# class ACOSUnsupportedVersion(ACOSException):
# class ACOSUnknownError(ACOSException):
# class AddressSpecifiedIsInUse(ACOSException):
# class AuthenticationFailure(ACOSException):
# class InvalidSessionID(ACOSException):
# class Exists(ACOSException):
# class NotFound(ACOSException):
# class NoSuchServiceGroup(ACOSException):
# class NotImplemented(ACOSException):
# class InUse(ACOSException):
# class InvalidPartitionParameter(ACOSException):
# class MemoryFault(ACOSException):
# class InvalidParameter(ACOSException):
# class OutOfPartitions(ACOSException):
# class PartitionIdExists(ACOSException):
# class HMMissingHttpPassive(ACOSException):
# class AxapiJsonFormatError(ACOSException):
# class ConfigManagerNotReady(ACOSException):
# class DhcpAcquireFailed(ACOSException):
# class InvalidInteger(ACOSException):
# class CertificateParsingFailed(ACOSException):
# class KeyParsingFailed(ACOSException):
# class FeatureNotSupported(ACOSException):
# class ACOSSystemNotReady(ACOSException):
# class ACOSSystemIsBusy(ACOSException):
# class LicenseOptionNotAllowed(ACOSException):
#     def __init__(self, url, attribute, requires=[]):
#     def __init__(self, code=1, msg=''):
#     def __str__(self):


# Path: acos_client/v30/base.py
import ipaddress
import six
import time
from acos_client import errors as ae

from __future__ import absolute_import
from __future__ import unicode_literals




class BaseV30(object):

    def __init__(self, client):
        self.client = client
        self.http = client.http
        self.auth_header = {}

    def minimal_dict(self, my_dict, exclude=[]):
        return dict((k, v) for k, v in my_dict.items() if v is not None or k in exclude)

    def url(self, action):
        self.auth_header['Authorization'] = "A10 %s" % self.client.session.id
        return ("/axapi/v3" + action)

    def _request(self, method, action, params, retry_count=0, max_retries=None,
                 timeout=None, axapi_args=None, **kwargs):
        if retry_count > 24:
            raise ae.ACOSUnknownError()

        try:
            return self.client.http.request(method, self.url(action), params, self.auth_header,
                                            max_retries=max_retries, timeout=timeout,
                                            axapi_args=axapi_args, **kwargs)
        except (ae.InvalidSessionID, ae.ConfigManagerNotReady) as e:

            if type(e) == ae.ConfigManagerNotReady: