prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Pubsub message getting wrong attribute for publishTime
  According the [REST docs](https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage), a `PubsubMessage` has the field `publishTime`
  
  In [message.py](https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/pubsub/google/cloud/pubsub/message.py), `from_api_repr` is getting the field `publishTimestamp` below:
  
  ```
  instance._service_timestamp = api_repr.get('publishTimestamp')
  ```
  
  The current tests are self-confirming of this issue as they simply set up the api_repr with `publishTimestamp`
  
  A quick fix seems to adjust the following:
  **message.py**
  
  ``` python
      @classmethod
      def from_api_repr(cls, api_repr):
          """Factory:  construct message from API representation.
  
          :type api_repr: dict or None
          :param api_repr: The API representation of the message
  
          :rtype: :class:`Message`
          :returns: The message created from the response.
          """
          data = base64.b64decode(api_repr.get('data', b''))
          instance = cls(
              data=data, message_id=api_repr['messageId'],
              attributes=api_repr.get('attributes'))
          instance._service_timestamp = api_repr.get('publishTime')
          return instance
  ```
  
  **test_message.py**
  
  ``` python
      def test_from_api_repr_no_attributes(self):
          from base64 import b64encode as b64
          DATA = b'DEADBEEF'
          B64_DATA = b64(DATA)
          MESSAGE_ID = '12345'
          TIMESTAMP = '2016-03-18-19:38:22.001393427Z'
          api_repr = {
              'data': B64_DATA,
              'messageId': MESSAGE_ID,
              'publishTime': TIMESTAMP,
          }
          message = self._getTargetClass().from_api_repr(api_repr)
          self.assertEqual(message.data, DATA)
          self.assertEqual(message.message_id, MESSAGE_ID)
          self.assertEqual(message.attributes, {})
          self.assertEqual(message.service_timestamp, TIMESTAMP)
  
      def test_from_api_repr_w_attributes(self):
          from base64 import b64encode as b64
          DATA = b'DEADBEEF'
          B64_DATA = b64(DATA)
          MESSAGE_ID = '12345'
          ATTRS = {'a': 'b'}
          TIMESTAMP = '2016-03-18-19:38:22.001393427Z'
          api_repr = {
              'data': B64_DATA,
              'messageId': MESSAGE_ID,
              'publishTime': TIMESTAMP,
              'attributes': ATTRS,
          }
          message = self._getTargetClass().from_api_repr(api_repr)
          self.assertEqual(message.data, DATA)
          self.assertEqual(message.message_id, MESSAGE_ID)
          self.assertEqual(message.service_timestamp, TIMESTAMP)
          self.assertEqual(message.attributes, ATTRS)
  ```
  
  I don't currently have a contributor license signed, but will work on that.  In the meantime, hoping that someone can pick this up.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pubsub/google/cloud/pubsub/message.py`
  Content:
  ```
  1 # Copyright 2015 Google Inc.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 """Define API Topics."""
  16 
  17 import base64
  18 
  19 from google.cloud._helpers import _rfc3339_to_datetime
  20 
  21 
  22 class Message(object):
  23     """Messages can be published to a topic and received by subscribers.
  24 
  25     See:
  26     https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage
  27 
  28     :type data: bytes
  29     :param data: the payload of the message.
  30 
  31     :type message_id: string
  32     :param message_id: An ID assigned to the message by the API.
  33 
  34     :type attributes: dict or None
  35     :param attributes: Extra metadata associated by the publisher with the
  36                        message.
  37     """
  38     _service_timestamp = None
  39 
  40     def __init__(self, data, message_id, attributes=None):
  41         self.data = data
  42         self.message_id = message_id
  43         self._attributes = attributes
  44 
  45     @property
  46     def attributes(self):
  47         """Lazily-constructed attribute dictionary."""
  48         if self._attributes is None:
  49             self._attributes = {}
  50         return self._attributes
  51 
  52     @property
  53     def timestamp(self):
  54         """Return sortable timestamp from attributes, if passed.
  55 
  56         Allows sorting messages in publication order (assuming consistent
  57         clocks across all publishers).
  58 
  59         :rtype: :class:`datetime.datetime`
  60         :returns: timestamp (in UTC timezone) parsed from RFC 3339 timestamp
  61         :raises: ValueError if timestamp not in ``attributes``, or if it does
  62                  not match the RFC 3339 format.
  63         """
  64         stamp = self.attributes.get('timestamp')
  65         if stamp is None:
  66             raise ValueError('No timestamp')
  67         return _rfc3339_to_datetime(stamp)
  68 
  69     @property
  70     def service_timestamp(self):
  71         """Return server-set timestamp.
  72 
  73         :rtype: string
  74         :returns: timestamp (in UTC timezone) in RFC 3339 format
  75         """
  76         return self._service_timestamp
  77 
  78     @classmethod
  79     def from_api_repr(cls, api_repr):
  80         """Factory:  construct message from API representation.
  81 
  82         :type api_repr: dict or None
  83         :param api_repr: The API representation of the message
  84 
  85         :rtype: :class:`Message`
  86         :returns: The message created from the response.
  87         """
  88         data = base64.b64decode(api_repr.get('data', b''))
  89         instance = cls(
  90             data=data, message_id=api_repr['messageId'],
  91             attributes=api_repr.get('attributes'))
  92         instance._service_timestamp = api_repr.get('publishTimestamp')
  93         return instance
  94
  ```
  --- 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/pubsub/google/cloud/pubsub/message.py b/pubsub/google/cloud/pubsub/message.py
  --- a/pubsub/google/cloud/pubsub/message.py
  +++ b/pubsub/google/cloud/pubsub/message.py
  @@ -89,5 +89,5 @@
           instance = cls(
               data=data, message_id=api_repr['messageId'],
               attributes=api_repr.get('attributes'))
  -        instance._service_timestamp = api_repr.get('publishTimestamp')
  +        instance._service_timestamp = api_repr.get('publishTime')
           return instance
  
verification_info: {"golden_diff": "diff --git a/pubsub/google/cloud/pubsub/message.py b/pubsub/google/cloud/pubsub/message.py\n--- a/pubsub/google/cloud/pubsub/message.py\n+++ b/pubsub/google/cloud/pubsub/message.py\n@@ -89,5 +89,5 @@\n         instance = cls(\n             data=data, message_id=api_repr['messageId'],\n             attributes=api_repr.get('attributes'))\n-        instance._service_timestamp = api_repr.get('publishTimestamp')\n+        instance._service_timestamp = api_repr.get('publishTime')\n         return instance\n", "issue": "Pubsub message getting wrong attribute for publishTime\nAccording the [REST docs](https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage), a `PubsubMessage` has the field `publishTime`\n\nIn [message.py](https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/pubsub/google/cloud/pubsub/message.py), `from_api_repr` is getting the field `publishTimestamp` below:\n\n```\ninstance._service_timestamp = api_repr.get('publishTimestamp')\n```\n\nThe current tests are self-confirming of this issue as they simply set up the api_repr with `publishTimestamp`\n\nA quick fix seems to adjust the following:\n**message.py**\n\n``` python\n    @classmethod\n    def from_api_repr(cls, api_repr):\n        \"\"\"Factory:  construct message from API representation.\n\n        :type api_repr: dict or None\n        :param api_repr: The API representation of the message\n\n        :rtype: :class:`Message`\n        :returns: The message created from the response.\n        \"\"\"\n        data = base64.b64decode(api_repr.get('data', b''))\n        instance = cls(\n            data=data, message_id=api_repr['messageId'],\n            attributes=api_repr.get('attributes'))\n        instance._service_timestamp = api_repr.get('publishTime')\n        return instance\n```\n\n**test_message.py**\n\n``` python\n    def test_from_api_repr_no_attributes(self):\n        from base64 import b64encode as b64\n        DATA = b'DEADBEEF'\n        B64_DATA = b64(DATA)\n        MESSAGE_ID = '12345'\n        TIMESTAMP = '2016-03-18-19:38:22.001393427Z'\n        api_repr = {\n            'data': B64_DATA,\n            'messageId': MESSAGE_ID,\n            'publishTime': TIMESTAMP,\n        }\n        message = self._getTargetClass().from_api_repr(api_repr)\n        self.assertEqual(message.data, DATA)\n        self.assertEqual(message.message_id, MESSAGE_ID)\n        self.assertEqual(message.attributes, {})\n        self.assertEqual(message.service_timestamp, TIMESTAMP)\n\n    def test_from_api_repr_w_attributes(self):\n        from base64 import b64encode as b64\n        DATA = b'DEADBEEF'\n        B64_DATA = b64(DATA)\n        MESSAGE_ID = '12345'\n        ATTRS = {'a': 'b'}\n        TIMESTAMP = '2016-03-18-19:38:22.001393427Z'\n        api_repr = {\n            'data': B64_DATA,\n            'messageId': MESSAGE_ID,\n            'publishTime': TIMESTAMP,\n            'attributes': ATTRS,\n        }\n        message = self._getTargetClass().from_api_repr(api_repr)\n        self.assertEqual(message.data, DATA)\n        self.assertEqual(message.message_id, MESSAGE_ID)\n        self.assertEqual(message.service_timestamp, TIMESTAMP)\n        self.assertEqual(message.attributes, ATTRS)\n```\n\nI don't currently have a contributor license signed, but will work on that.  In the meantime, hoping that someone can pick this up.\n\n", "before_files": [{"content": "# Copyright 2015 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Define API Topics.\"\"\"\n\nimport base64\n\nfrom google.cloud._helpers import _rfc3339_to_datetime\n\n\nclass Message(object):\n    \"\"\"Messages can be published to a topic and received by subscribers.\n\n    See:\n    https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage\n\n    :type data: bytes\n    :param data: the payload of the message.\n\n    :type message_id: string\n    :param message_id: An ID assigned to the message by the API.\n\n    :type attributes: dict or None\n    :param attributes: Extra metadata associated by the publisher with the\n                       message.\n    \"\"\"\n    _service_timestamp = None\n\n    def __init__(self, data, message_id, attributes=None):\n        self.data = data\n        self.message_id = message_id\n        self._attributes = attributes\n\n    @property\n    def attributes(self):\n        \"\"\"Lazily-constructed attribute dictionary.\"\"\"\n        if self._attributes is None:\n            self._attributes = {}\n        return self._attributes\n\n    @property\n    def timestamp(self):\n        \"\"\"Return sortable timestamp from attributes, if passed.\n\n        Allows sorting messages in publication order (assuming consistent\n        clocks across all publishers).\n\n        :rtype: :class:`datetime.datetime`\n        :returns: timestamp (in UTC timezone) parsed from RFC 3339 timestamp\n        :raises: ValueError if timestamp not in ``attributes``, or if it does\n                 not match the RFC 3339 format.\n        \"\"\"\n        stamp = self.attributes.get('timestamp')\n        if stamp is None:\n            raise ValueError('No timestamp')\n        return _rfc3339_to_datetime(stamp)\n\n    @property\n    def service_timestamp(self):\n        \"\"\"Return server-set timestamp.\n\n        :rtype: string\n        :returns: timestamp (in UTC timezone) in RFC 3339 format\n        \"\"\"\n        return self._service_timestamp\n\n    @classmethod\n    def from_api_repr(cls, api_repr):\n        \"\"\"Factory:  construct message from API representation.\n\n        :type api_repr: dict or None\n        :param api_repr: The API representation of the message\n\n        :rtype: :class:`Message`\n        :returns: The message created from the response.\n        \"\"\"\n        data = base64.b64decode(api_repr.get('data', b''))\n        instance = cls(\n            data=data, message_id=api_repr['messageId'],\n            attributes=api_repr.get('attributes'))\n        instance._service_timestamp = api_repr.get('publishTimestamp')\n        return instance\n", "path": "pubsub/google/cloud/pubsub/message.py"}], "after_files": [{"content": "# Copyright 2015 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Define API Topics.\"\"\"\n\nimport base64\n\nfrom google.cloud._helpers import _rfc3339_to_datetime\n\n\nclass Message(object):\n    \"\"\"Messages can be published to a topic and received by subscribers.\n\n    See:\n    https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage\n\n    :type data: bytes\n    :param data: the payload of the message.\n\n    :type message_id: string\n    :param message_id: An ID assigned to the message by the API.\n\n    :type attributes: dict or None\n    :param attributes: Extra metadata associated by the publisher with the\n                       message.\n    \"\"\"\n    _service_timestamp = None\n\n    def __init__(self, data, message_id, attributes=None):\n        self.data = data\n        self.message_id = message_id\n        self._attributes = attributes\n\n    @property\n    def attributes(self):\n        \"\"\"Lazily-constructed attribute dictionary.\"\"\"\n        if self._attributes is None:\n            self._attributes = {}\n        return self._attributes\n\n    @property\n    def timestamp(self):\n        \"\"\"Return sortable timestamp from attributes, if passed.\n\n        Allows sorting messages in publication order (assuming consistent\n        clocks across all publishers).\n\n        :rtype: :class:`datetime.datetime`\n        :returns: timestamp (in UTC timezone) parsed from RFC 3339 timestamp\n        :raises: ValueError if timestamp not in ``attributes``, or if it does\n                 not match the RFC 3339 format.\n        \"\"\"\n        stamp = self.attributes.get('timestamp')\n        if stamp is None:\n            raise ValueError('No timestamp')\n        return _rfc3339_to_datetime(stamp)\n\n    @property\n    def service_timestamp(self):\n        \"\"\"Return server-set timestamp.\n\n        :rtype: string\n        :returns: timestamp (in UTC timezone) in RFC 3339 format\n        \"\"\"\n        return self._service_timestamp\n\n    @classmethod\n    def from_api_repr(cls, api_repr):\n        \"\"\"Factory:  construct message from API representation.\n\n        :type api_repr: dict or None\n        :param api_repr: The API representation of the message\n\n        :rtype: :class:`Message`\n        :returns: The message created from the response.\n        \"\"\"\n        data = base64.b64decode(api_repr.get('data', b''))\n        instance = cls(\n            data=data, message_id=api_repr['messageId'],\n            attributes=api_repr.get('attributes'))\n        instance._service_timestamp = api_repr.get('publishTime')\n        return instance\n", "path": "pubsub/google/cloud/pubsub/message.py"}]}