prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Can't create config object
  Much like https://github.com/docker/docker-py/issues/2025 the config model is failing to create a new object due to 'name' KeyError
  
  ```
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "docker\models\configs.py", line 10, in __repr__
      return f"<{self.__class__.__name__}: '{self.name}'>"
    File "docker\models\configs.py", line 14, in name
      return self.attrs['Spec']['Name']
  ```
  
  This https://github.com/docker/docker-py/pull/2793 appears to be the fix that was implemented and should likely be implements for configs as well (if not other models that might have this issue)
  
  --- 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/models/configs.py`
  Content:
  ```
  1 from ..api import APIClient
  2 from .resource import Model, Collection
  3 
  4 
  5 class Config(Model):
  6     """A config."""
  7     id_attribute = 'ID'
  8 
  9     def __repr__(self):
  10         return f"<{self.__class__.__name__}: '{self.name}'>"
  11 
  12     @property
  13     def name(self):
  14         return self.attrs['Spec']['Name']
  15 
  16     def remove(self):
  17         """
  18         Remove this config.
  19 
  20         Raises:
  21             :py:class:`docker.errors.APIError`
  22                 If config failed to remove.
  23         """
  24         return self.client.api.remove_config(self.id)
  25 
  26 
  27 class ConfigCollection(Collection):
  28     """Configs on the Docker server."""
  29     model = Config
  30 
  31     def create(self, **kwargs):
  32         obj = self.client.api.create_config(**kwargs)
  33         return self.prepare_model(obj)
  34     create.__doc__ = APIClient.create_config.__doc__
  35 
  36     def get(self, config_id):
  37         """
  38         Get a config.
  39 
  40         Args:
  41             config_id (str): Config ID.
  42 
  43         Returns:
  44             (:py:class:`Config`): The config.
  45 
  46         Raises:
  47             :py:class:`docker.errors.NotFound`
  48                 If the config does not exist.
  49             :py:class:`docker.errors.APIError`
  50                 If the server returns an error.
  51         """
  52         return self.prepare_model(self.client.api.inspect_config(config_id))
  53 
  54     def list(self, **kwargs):
  55         """
  56         List configs. Similar to the ``docker config ls`` command.
  57 
  58         Args:
  59             filters (dict): Server-side list filtering options.
  60 
  61         Returns:
  62             (list of :py:class:`Config`): The configs.
  63 
  64         Raises:
  65             :py:class:`docker.errors.APIError`
  66                 If the server returns an error.
  67         """
  68         resp = self.client.api.configs(**kwargs)
  69         return [self.prepare_model(obj) for obj in resp]
  70
  ```
  --- 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/models/configs.py b/docker/models/configs.py
  --- a/docker/models/configs.py
  +++ b/docker/models/configs.py
  @@ -30,6 +30,7 @@
   
       def create(self, **kwargs):
           obj = self.client.api.create_config(**kwargs)
  +        obj.setdefault("Spec", {})["Name"] = kwargs.get("name")
           return self.prepare_model(obj)
       create.__doc__ = APIClient.create_config.__doc__
  
verification_info: {"golden_diff": "diff --git a/docker/models/configs.py b/docker/models/configs.py\n--- a/docker/models/configs.py\n+++ b/docker/models/configs.py\n@@ -30,6 +30,7 @@\n \n     def create(self, **kwargs):\n         obj = self.client.api.create_config(**kwargs)\n+        obj.setdefault(\"Spec\", {})[\"Name\"] = kwargs.get(\"name\")\n         return self.prepare_model(obj)\n     create.__doc__ = APIClient.create_config.__doc__\n", "issue": "Can't create config object\nMuch like https://github.com/docker/docker-py/issues/2025 the config model is failing to create a new object due to 'name' KeyError\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"docker\\models\\configs.py\", line 10, in __repr__\r\n    return f\"<{self.__class__.__name__}: '{self.name}'>\"\r\n  File \"docker\\models\\configs.py\", line 14, in name\r\n    return self.attrs['Spec']['Name']\r\n```\r\n\r\nThis https://github.com/docker/docker-py/pull/2793 appears to be the fix that was implemented and should likely be implements for configs as well (if not other models that might have this issue)\n", "before_files": [{"content": "from ..api import APIClient\nfrom .resource import Model, Collection\n\n\nclass Config(Model):\n    \"\"\"A config.\"\"\"\n    id_attribute = 'ID'\n\n    def __repr__(self):\n        return f\"<{self.__class__.__name__}: '{self.name}'>\"\n\n    @property\n    def name(self):\n        return self.attrs['Spec']['Name']\n\n    def remove(self):\n        \"\"\"\n        Remove this config.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If config failed to remove.\n        \"\"\"\n        return self.client.api.remove_config(self.id)\n\n\nclass ConfigCollection(Collection):\n    \"\"\"Configs on the Docker server.\"\"\"\n    model = Config\n\n    def create(self, **kwargs):\n        obj = self.client.api.create_config(**kwargs)\n        return self.prepare_model(obj)\n    create.__doc__ = APIClient.create_config.__doc__\n\n    def get(self, config_id):\n        \"\"\"\n        Get a config.\n\n        Args:\n            config_id (str): Config ID.\n\n        Returns:\n            (:py:class:`Config`): The config.\n\n        Raises:\n            :py:class:`docker.errors.NotFound`\n                If the config does not exist.\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self.prepare_model(self.client.api.inspect_config(config_id))\n\n    def list(self, **kwargs):\n        \"\"\"\n        List configs. Similar to the ``docker config ls`` command.\n\n        Args:\n            filters (dict): Server-side list filtering options.\n\n        Returns:\n            (list of :py:class:`Config`): The configs.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        resp = self.client.api.configs(**kwargs)\n        return [self.prepare_model(obj) for obj in resp]\n", "path": "docker/models/configs.py"}], "after_files": [{"content": "from ..api import APIClient\nfrom .resource import Model, Collection\n\n\nclass Config(Model):\n    \"\"\"A config.\"\"\"\n    id_attribute = 'ID'\n\n    def __repr__(self):\n        return f\"<{self.__class__.__name__}: '{self.name}'>\"\n\n    @property\n    def name(self):\n        return self.attrs['Spec']['Name']\n\n    def remove(self):\n        \"\"\"\n        Remove this config.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If config failed to remove.\n        \"\"\"\n        return self.client.api.remove_config(self.id)\n\n\nclass ConfigCollection(Collection):\n    \"\"\"Configs on the Docker server.\"\"\"\n    model = Config\n\n    def create(self, **kwargs):\n        obj = self.client.api.create_config(**kwargs)\n        obj.setdefault(\"Spec\", {})[\"Name\"] = kwargs.get(\"name\")\n        return self.prepare_model(obj)\n    create.__doc__ = APIClient.create_config.__doc__\n\n    def get(self, config_id):\n        \"\"\"\n        Get a config.\n\n        Args:\n            config_id (str): Config ID.\n\n        Returns:\n            (:py:class:`Config`): The config.\n\n        Raises:\n            :py:class:`docker.errors.NotFound`\n                If the config does not exist.\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self.prepare_model(self.client.api.inspect_config(config_id))\n\n    def list(self, **kwargs):\n        \"\"\"\n        List configs. Similar to the ``docker config ls`` command.\n\n        Args:\n            filters (dict): Server-side list filtering options.\n\n        Returns:\n            (list of :py:class:`Config`): The configs.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        resp = self.client.api.configs(**kwargs)\n        return [self.prepare_model(obj) for obj in resp]\n", "path": "docker/models/configs.py"}]}