prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Support create volume Labels options
  First, check the remote API:
  https://docs.docker.com/engine/reference/api/docker_remote_api_v1.23/
  
  ```
   {
    "Name": "tardis",
    "Labels": {
      "com.example.some-label": "some-value",
      "com.example.some-other-label": "some-other-value"
    },
  }
  ```
  
  It provides `Labels` options. But docker-py doesn't support it right not.
  
  Second, in docker-py's document give the following example:
  
  ```
  volume = cli.create_volume(
    name='foobar', driver='local', driver_opts={'foo': 'bar', 'baz': 'false'}
  
  docker.errors.APIError: 500 Server Error: Internal Server Error ("create foobar: invalid option key: "foo"")
  ```
  
  But driver_opts is not working. What kinds of driver_opts can we use?
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `docker/api/volume.py`
  Content:
  ```
  1 from .. import utils
  2 
  3 
  4 class VolumeApiMixin(object):
  5     @utils.minimum_version('1.21')
  6     def volumes(self, filters=None):
  7         params = {
  8             'filters': utils.convert_filters(filters) if filters else None
  9         }
  10         url = self._url('/volumes')
  11         return self._result(self._get(url, params=params), True)
  12 
  13     @utils.minimum_version('1.21')
  14     def create_volume(self, name, driver=None, driver_opts=None):
  15         url = self._url('/volumes/create')
  16         if driver_opts is not None and not isinstance(driver_opts, dict):
  17             raise TypeError('driver_opts must be a dictionary')
  18 
  19         data = {
  20             'Name': name,
  21             'Driver': driver,
  22             'DriverOpts': driver_opts,
  23         }
  24         return self._result(self._post_json(url, data=data), True)
  25 
  26     @utils.minimum_version('1.21')
  27     def inspect_volume(self, name):
  28         url = self._url('/volumes/{0}', name)
  29         return self._result(self._get(url), True)
  30 
  31     @utils.minimum_version('1.21')
  32     def remove_volume(self, name):
  33         url = self._url('/volumes/{0}', name)
  34         resp = self._delete(url)
  35         self._raise_for_status(resp)
  36
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/docker/api/volume.py b/docker/api/volume.py
  --- a/docker/api/volume.py
  +++ b/docker/api/volume.py
  @@ -1,3 +1,4 @@
  +from .. import errors
   from .. import utils
   
   
  @@ -11,7 +12,7 @@
           return self._result(self._get(url, params=params), True)
   
       @utils.minimum_version('1.21')
  -    def create_volume(self, name, driver=None, driver_opts=None):
  +    def create_volume(self, name, driver=None, driver_opts=None, labels=None):
           url = self._url('/volumes/create')
           if driver_opts is not None and not isinstance(driver_opts, dict):
               raise TypeError('driver_opts must be a dictionary')
  @@ -21,6 +22,16 @@
               'Driver': driver,
               'DriverOpts': driver_opts,
           }
  +
  +        if labels is not None:
  +            if utils.compare_version('1.23', self._version) < 0:
  +                raise errors.InvalidVersion(
  +                    'volume labels were introduced in API 1.23'
  +                )
  +            if not isinstance(labels, dict):
  +                raise TypeError('labels must be a dictionary')
  +            data["Labels"] = labels
  +
           return self._result(self._post_json(url, data=data), True)
   
       @utils.minimum_version('1.21')
  
verification_info: {"golden_diff": "diff --git a/docker/api/volume.py b/docker/api/volume.py\n--- a/docker/api/volume.py\n+++ b/docker/api/volume.py\n@@ -1,3 +1,4 @@\n+from .. import errors\n from .. import utils\n \n \n@@ -11,7 +12,7 @@\n         return self._result(self._get(url, params=params), True)\n \n     @utils.minimum_version('1.21')\n-    def create_volume(self, name, driver=None, driver_opts=None):\n+    def create_volume(self, name, driver=None, driver_opts=None, labels=None):\n         url = self._url('/volumes/create')\n         if driver_opts is not None and not isinstance(driver_opts, dict):\n             raise TypeError('driver_opts must be a dictionary')\n@@ -21,6 +22,16 @@\n             'Driver': driver,\n             'DriverOpts': driver_opts,\n         }\n+\n+        if labels is not None:\n+            if utils.compare_version('1.23', self._version) < 0:\n+                raise errors.InvalidVersion(\n+                    'volume labels were introduced in API 1.23'\n+                )\n+            if not isinstance(labels, dict):\n+                raise TypeError('labels must be a dictionary')\n+            data[\"Labels\"] = labels\n+\n         return self._result(self._post_json(url, data=data), True)\n \n     @utils.minimum_version('1.21')\n", "issue": "Support create volume Labels options\nFirst, check the remote API:\nhttps://docs.docker.com/engine/reference/api/docker_remote_api_v1.23/\n\n```\n {\n  \"Name\": \"tardis\",\n  \"Labels\": {\n    \"com.example.some-label\": \"some-value\",\n    \"com.example.some-other-label\": \"some-other-value\"\n  },\n}\n```\n\nIt provides `Labels` options. But docker-py doesn't support it right not.\n\nSecond, in docker-py's document give the following example:\n\n```\nvolume = cli.create_volume(\n  name='foobar', driver='local', driver_opts={'foo': 'bar', 'baz': 'false'}\n\ndocker.errors.APIError: 500 Server Error: Internal Server Error (\"create foobar: invalid option key: \"foo\"\")\n```\n\nBut driver_opts is not working. What kinds of driver_opts can we use?\n\n", "before_files": [{"content": "from .. import utils\n\n\nclass VolumeApiMixin(object):\n    @utils.minimum_version('1.21')\n    def volumes(self, filters=None):\n        params = {\n            'filters': utils.convert_filters(filters) if filters else None\n        }\n        url = self._url('/volumes')\n        return self._result(self._get(url, params=params), True)\n\n    @utils.minimum_version('1.21')\n    def create_volume(self, name, driver=None, driver_opts=None):\n        url = self._url('/volumes/create')\n        if driver_opts is not None and not isinstance(driver_opts, dict):\n            raise TypeError('driver_opts must be a dictionary')\n\n        data = {\n            'Name': name,\n            'Driver': driver,\n            'DriverOpts': driver_opts,\n        }\n        return self._result(self._post_json(url, data=data), True)\n\n    @utils.minimum_version('1.21')\n    def inspect_volume(self, name):\n        url = self._url('/volumes/{0}', name)\n        return self._result(self._get(url), True)\n\n    @utils.minimum_version('1.21')\n    def remove_volume(self, name):\n        url = self._url('/volumes/{0}', name)\n        resp = self._delete(url)\n        self._raise_for_status(resp)\n", "path": "docker/api/volume.py"}], "after_files": [{"content": "from .. import errors\nfrom .. import utils\n\n\nclass VolumeApiMixin(object):\n    @utils.minimum_version('1.21')\n    def volumes(self, filters=None):\n        params = {\n            'filters': utils.convert_filters(filters) if filters else None\n        }\n        url = self._url('/volumes')\n        return self._result(self._get(url, params=params), True)\n\n    @utils.minimum_version('1.21')\n    def create_volume(self, name, driver=None, driver_opts=None, labels=None):\n        url = self._url('/volumes/create')\n        if driver_opts is not None and not isinstance(driver_opts, dict):\n            raise TypeError('driver_opts must be a dictionary')\n\n        data = {\n            'Name': name,\n            'Driver': driver,\n            'DriverOpts': driver_opts,\n        }\n\n        if labels is not None:\n            if utils.compare_version('1.23', self._version) < 0:\n                raise errors.InvalidVersion(\n                    'volume labels were introduced in API 1.23'\n                )\n            if not isinstance(labels, dict):\n                raise TypeError('labels must be a dictionary')\n            data[\"Labels\"] = labels\n\n        return self._result(self._post_json(url, data=data), True)\n\n    @utils.minimum_version('1.21')\n    def inspect_volume(self, name):\n        url = self._url('/volumes/{0}', name)\n        return self._result(self._get(url), True)\n\n    @utils.minimum_version('1.21')\n    def remove_volume(self, name):\n        url = self._url('/volumes/{0}', name)\n        resp = self._delete(url)\n        self._raise_for_status(resp)\n", "path": "docker/api/volume.py"}]}