# Path: lambda_src/runcmd/docker/errors.py
# class InvalidVersion(DockerException):
#     pass
# 
# Path: lambda_src/runcmd/docker/utils/decorators.py
# def check_resource(f):
#     @functools.wraps(f)
#     def wrapped(self, resource_id=None, *args, **kwargs):
#         if resource_id is None:
#             if kwargs.get('container'):
#                 resource_id = kwargs.pop('container')
#             elif kwargs.get('image'):
#                 resource_id = kwargs.pop('image')
#         if isinstance(resource_id, dict):
#             resource_id = resource_id.get('Id', resource_id.get('ID'))
#         if not resource_id:
#             raise errors.NullResource(
#                 'image or container param is undefined'
#             )
#         return f(self, resource_id, *args, **kwargs)
#     return wrapped
# 
# def minimum_version(version):
#     def decorator(f):
#         @functools.wraps(f)
#         def wrapper(self, *args, **kwargs):
#             if utils.version_lt(self._version, version):
#                 raise errors.InvalidVersion(
#                     '{0} is not available for version < {1}'.format(
#                         f.__name__, version
#                     )
#                 )
#             return f(self, *args, **kwargs)
#         return wrapper
#     return decorator
# 
# Path: lambda_src/runcmd/docker/utils/utils.py
# def version_lt(v1, v2):
#     return compare_version(v1, v2) > 0


import json
from ..errors import InvalidVersion
from ..utils import check_resource, minimum_version
from ..utils import version_lt

        if internal:
            if version_lt(self._version, '1.22'):
                raise InvalidVersion('Internal networks are not '
                                     'supported in API version < 1.22')
            data['Internal'] = True

        if attachable is not None:
            if version_lt(self._version, '1.24'):
                raise InvalidVersion(
                    'attachable is not supported in API version < 1.24'
                )
            data['Attachable'] = attachable

        url = self._url("/networks/create")
        res = self._post_json(url, data=data)
        return self._result(res, json=True)

    @minimum_version('1.21')
    def remove_network(self, net_id):
        """
        Remove a network. Similar to the ``docker network rm`` command.

        Args:
            net_id (str): The network's id
        """
        url = self._url("/networks/{0}", net_id)
        res = self._delete(url)
        self._raise_for_status(res)


# Path: lambda_src/runcmd/docker/errors.py
# class InvalidVersion(DockerException):
#     pass
# 
# Path: lambda_src/runcmd/docker/utils/decorators.py
# def check_resource(f):
#     @functools.wraps(f)
#     def wrapped(self, resource_id=None, *args, **kwargs):
#         if resource_id is None:
#             if kwargs.get('container'):
#                 resource_id = kwargs.pop('container')
#             elif kwargs.get('image'):
#                 resource_id = kwargs.pop('image')
#         if isinstance(resource_id, dict):
#             resource_id = resource_id.get('Id', resource_id.get('ID'))
#         if not resource_id:
#             raise errors.NullResource(
#                 'image or container param is undefined'
#             )
#         return f(self, resource_id, *args, **kwargs)
#     return wrapped
# 
# def minimum_version(version):
#     def decorator(f):
#         @functools.wraps(f)
#         def wrapper(self, *args, **kwargs):
#             if utils.version_lt(self._version, version):
#                 raise errors.InvalidVersion(
#                     '{0} is not available for version < {1}'.format(
#                         f.__name__, version
#                     )
#                 )
#             return f(self, *args, **kwargs)
#         return wrapper
#     return decorator
# 
# Path: lambda_src/runcmd/docker/utils/utils.py
# def version_lt(v1, v2):
#     return compare_version(v1, v2) > 0


# Path: lambda_src/runcmd/docker/api/network.py
import json
from ..errors import InvalidVersion
from ..utils import check_resource, minimum_version
from ..utils import version_lt


        if internal:
            if version_lt(self._version, '1.22'):
                raise InvalidVersion('Internal networks are not '
                                     'supported in API version < 1.22')
            data['Internal'] = True

        if attachable is not None:
            if version_lt(self._version, '1.24'):
                raise InvalidVersion(
                    'attachable is not supported in API version < 1.24'
                )
            data['Attachable'] = attachable

        url = self._url("/networks/create")
        res = self._post_json(url, data=data)
        return self._result(res, json=True)

    @minimum_version('1.21')
    def remove_network(self, net_id):
        """
        Remove a network. Similar to the ``docker network rm`` command.

        Args:
            net_id (str): The network's id
        """
        url = self._url("/networks/{0}", net_id)
        res = self._delete(url)
        self._raise_for_status(res)


    @minimum_version('1.21')