prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Couldn't create secret object
  I couldn't create secret object, the problem seemed to boil down to the way that a secret was being created from the docker daemon response. 
  
  https://github.com/docker/docker-py/blob/467cacb00d8dce68aa8ff2bdacc85acecd2d1207/docker/models/secrets.py#L31-L33
  
  Docker version 18.03.1-ce and python version 3.5 had the following error:
  
  ````
  File "docker/models/secrets.py", line 10 in __repr__
  return "<%s: %s'>" % (self.__class__.__name__, self.name)
  File "docker/models/secrets.py", line 14 in name
  return self.attrs['Spec']['Name']
  KeyError: 'Spec'
  
  ````
  
  When calling: 
  
  ````
  import docker
  
  client -docker.from_env()
  mySecret = client.secrets.create(name='randomName', data='platform_node_requirements.md')
  
  ````
  
  Changing the code to the following seemed to fix it. 
  ````
  obj = self.client.api.create_secret(**kwargs)
  secret = self.client.secrets.get(obj.get('ID'))
  return self.prepare_model(secret)
  ````
  
  
  
  
  </issue>
  <code>
  [start of docker/models/secrets.py]
  1 from ..api import APIClient
  2 from .resource import Model, Collection
  3 
  4 
  5 class Secret(Model):
  6     """A secret."""
  7     id_attribute = 'ID'
  8 
  9     def __repr__(self):
  10         return "<%s: '%s'>" % (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 secret.
  19 
  20         Raises:
  21             :py:class:`docker.errors.APIError`
  22                 If secret failed to remove.
  23         """
  24         return self.client.api.remove_secret(self.id)
  25 
  26 
  27 class SecretCollection(Collection):
  28     """Secrets on the Docker server."""
  29     model = Secret
  30 
  31     def create(self, **kwargs):
  32         obj = self.client.api.create_secret(**kwargs)
  33         return self.prepare_model(obj)
  34     create.__doc__ = APIClient.create_secret.__doc__
  35 
  36     def get(self, secret_id):
  37         """
  38         Get a secret.
  39 
  40         Args:
  41             secret_id (str): Secret ID.
  42 
  43         Returns:
  44             (:py:class:`Secret`): The secret.
  45 
  46         Raises:
  47             :py:class:`docker.errors.NotFound`
  48                 If the secret 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_secret(secret_id))
  53 
  54     def list(self, **kwargs):
  55         """
  56         List secrets. Similar to the ``docker secret ls`` command.
  57 
  58         Args:
  59             filters (dict): Server-side list filtering options.
  60 
  61         Returns:
  62             (list of :py:class:`Secret`): The secrets.
  63 
  64         Raises:
  65             :py:class:`docker.errors.APIError`
  66                 If the server returns an error.
  67         """
  68         resp = self.client.api.secrets(**kwargs)
  69         return [self.prepare_model(obj) for obj in resp]
  70
  [end of docker/models/secrets.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/docker/models/secrets.py b/docker/models/secrets.py
  --- a/docker/models/secrets.py
  +++ b/docker/models/secrets.py
  @@ -30,6 +30,7 @@
   
       def create(self, **kwargs):
           obj = self.client.api.create_secret(**kwargs)
  +        obj.setdefault("Spec", {})["Name"] = kwargs.get("name")
           return self.prepare_model(obj)
       create.__doc__ = APIClient.create_secret.__doc__
  
verification_info: {"golden_diff": "diff --git a/docker/models/secrets.py b/docker/models/secrets.py\n--- a/docker/models/secrets.py\n+++ b/docker/models/secrets.py\n@@ -30,6 +30,7 @@\n \n     def create(self, **kwargs):\n         obj = self.client.api.create_secret(**kwargs)\n+        obj.setdefault(\"Spec\", {})[\"Name\"] = kwargs.get(\"name\")\n         return self.prepare_model(obj)\n     create.__doc__ = APIClient.create_secret.__doc__\n", "issue": "Couldn't create secret object\nI couldn't create secret object, the problem seemed to boil down to the way that a secret was being created from the docker daemon response. \r\n\r\nhttps://github.com/docker/docker-py/blob/467cacb00d8dce68aa8ff2bdacc85acecd2d1207/docker/models/secrets.py#L31-L33\r\n\r\nDocker version 18.03.1-ce and python version 3.5 had the following error:\r\n\r\n````\r\nFile \"docker/models/secrets.py\", line 10 in __repr__\r\nreturn \"<%s: %s'>\" % (self.__class__.__name__, self.name)\r\nFile \"docker/models/secrets.py\", line 14 in name\r\nreturn self.attrs['Spec']['Name']\r\nKeyError: 'Spec'\r\n\r\n````\r\n\r\nWhen calling: \r\n\r\n````\r\nimport docker\r\n\r\nclient -docker.from_env()\r\nmySecret = client.secrets.create(name='randomName', data='platform_node_requirements.md')\r\n\r\n````\r\n\r\nChanging the code to the following seemed to fix it. \r\n````\r\nobj = self.client.api.create_secret(**kwargs)\r\nsecret = self.client.secrets.get(obj.get('ID'))\r\nreturn self.prepare_model(secret)\r\n````\r\n\r\n\r\n\n", "before_files": [{"content": "from ..api import APIClient\nfrom .resource import Model, Collection\n\n\nclass Secret(Model):\n    \"\"\"A secret.\"\"\"\n    id_attribute = 'ID'\n\n    def __repr__(self):\n        return \"<%s: '%s'>\" % (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 secret.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If secret failed to remove.\n        \"\"\"\n        return self.client.api.remove_secret(self.id)\n\n\nclass SecretCollection(Collection):\n    \"\"\"Secrets on the Docker server.\"\"\"\n    model = Secret\n\n    def create(self, **kwargs):\n        obj = self.client.api.create_secret(**kwargs)\n        return self.prepare_model(obj)\n    create.__doc__ = APIClient.create_secret.__doc__\n\n    def get(self, secret_id):\n        \"\"\"\n        Get a secret.\n\n        Args:\n            secret_id (str): Secret ID.\n\n        Returns:\n            (:py:class:`Secret`): The secret.\n\n        Raises:\n            :py:class:`docker.errors.NotFound`\n                If the secret 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_secret(secret_id))\n\n    def list(self, **kwargs):\n        \"\"\"\n        List secrets. Similar to the ``docker secret ls`` command.\n\n        Args:\n            filters (dict): Server-side list filtering options.\n\n        Returns:\n            (list of :py:class:`Secret`): The secrets.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        resp = self.client.api.secrets(**kwargs)\n        return [self.prepare_model(obj) for obj in resp]\n", "path": "docker/models/secrets.py"}]}