We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Logging: Can't retrieve the writerIdentity for a logging sink
In #4578 , support was added for creating a sink with a unique writerIdentity. It would appear that only the uniqueWriterIdentity boolean for logging.sinks.create was implemented; but retrieving the writerIdentity for an existing sink is not possible.

## API response (via gcloud)
```
$ gcloud logging sinks list --project xxxx --log-http
[...]
-- body start --
{
  "sinks": [
    {
      "name": "xxxx",
      "destination": "storage.googleapis.com/xxxx",
      "filter": "xxxx",
      "outputVersionFormt": "V2",
      "writerIdentity": "serviceAccount:xxxx@logging-xxxx.iam.gserviceaccount.com"
    }
  ]
}

-- body end --
```

## Simplified example code
```
from google.cloud import logging

logging_client = logging.Client(project_id)
sink = logging_client.sink(sink_name)
sink.reload()
```

## Resulting object
```
(Pdb) sink.
sink.__class__(         sink.__hash__(          sink.__setattr__(       sink.destination
sink.__delattr__(       sink.__init__(          sink.__sizeof__(        sink.exists(
sink.__dict__           sink.__le__(            sink.__str__(           sink.filter_
sink.__dir__(           sink.__lt__(            sink.__subclasshook__(  sink.from_api_repr(
sink.__doc__            sink.__module__         sink.__weakref__        sink.full_name
sink.__eq__(            sink.__ne__(            sink._client            sink.name
sink.__format__(        sink.__new__(           sink._require_client(   sink.path
sink.__ge__(            sink.__reduce__(        sink.client             sink.project
sink.__getattribute__(  sink.__reduce_ex__(     sink.create(            sink.reload(
sink.__gt__(            sink.__repr__(          sink.delete(            sink.update(

(Pdb) sink.__dict__
{'destination': 'storage.googleapis.com/logs-00006913-fake-customer', '_client': <google.cloud.logging.client.Client object at 0x7f1d2728e860>, 'name': 'asdf1234', 'filter_': '*'}
```



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `logging/google/cloud/logging/sink.py`
Content:
```
1 # Copyright 2016 Google LLC
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 Stackdriver Logging API Sinks."""
16 
17 from google.cloud.exceptions import NotFound
18 
19 
20 class Sink(object):
21     """Sinks represent filtered exports for log entries.
22 
23     See
24     https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks
25 
26     :type name: str
27     :param name: the name of the sink
28 
29     :type filter_: str
30     :param filter_: (optional) the advanced logs filter expression defining
31                     the entries exported by the sink.
32 
33     :type destination: str
34     :param destination: destination URI for the entries exported by the sink.
35                         If not passed, the instance should already exist, to
36                         be refreshed via :meth:`reload`.
37 
38     :type client: :class:`google.cloud.logging.client.Client`
39     :param client: A client which holds credentials and project configuration
40                    for the sink (which requires a project).
41 
42     :type unique_writer_identity: bool
43     :param unique_writer_identity: (Optional) determines the kind of
44                                    IAM identity returned as
45                                    writer_identity in the new sink.
46     """
47     def __init__(self, name, filter_=None, destination=None, client=None,
48                  unique_writer_identity=False):
49         self.name = name
50         self.filter_ = filter_
51         self.destination = destination
52         self._client = client
53         self._unique_writer_identity = unique_writer_identity
54 
55     @property
56     def client(self):
57         """Client bound to the sink."""
58         return self._client
59 
60     @property
61     def project(self):
62         """Project bound to the sink."""
63         return self._client.project
64 
65     @property
66     def full_name(self):
67         """Fully-qualified name used in sink APIs"""
68         return 'projects/%s/sinks/%s' % (self.project, self.name)
69 
70     @property
71     def path(self):
72         """URL path for the sink's APIs"""
73         return '/%s' % (self.full_name)
74 
75     @classmethod
76     def from_api_repr(cls, resource, client):
77         """Factory:  construct a sink given its API representation
78 
79         :type resource: dict
80         :param resource: sink resource representation returned from the API
81 
82         :type client: :class:`google.cloud.logging.client.Client`
83         :param client: Client which holds credentials and project
84                        configuration for the sink.
85 
86         :rtype: :class:`google.cloud.logging.sink.Sink`
87         :returns: Sink parsed from ``resource``.
88         :raises: :class:`ValueError` if ``client`` is not ``None`` and the
89                  project from the resource does not agree with the project
90                  from the client.
91         """
92         sink_name = resource['name']
93         destination = resource['destination']
94         filter_ = resource.get('filter')
95         return cls(sink_name, filter_, destination, client=client)
96 
97     def _require_client(self, client):
98         """Check client or verify over-ride.
99 
100         :type client: :class:`~google.cloud.logging.client.Client` or
101                       ``NoneType``
102         :param client: the client to use.  If not passed, falls back to the
103                        ``client`` stored on the current sink.
104 
105         :rtype: :class:`google.cloud.logging.client.Client`
106         :returns: The client passed in or the currently bound client.
107         """
108         if client is None:
109             client = self._client
110         return client
111 
112     def create(self, client=None):
113         """API call:  create the sink via a PUT request
114 
115         See
116         https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/create
117 
118         :type client: :class:`~google.cloud.logging.client.Client` or
119                       ``NoneType``
120         :param client: the client to use.  If not passed, falls back to the
121                        ``client`` stored on the current sink.
122         """
123         client = self._require_client(client)
124         client.sinks_api.sink_create(
125             self.project, self.name, self.filter_, self.destination,
126             unique_writer_identity=self._unique_writer_identity,
127         )
128 
129     def exists(self, client=None):
130         """API call:  test for the existence of the sink via a GET request
131 
132         See
133         https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get
134 
135         :type client: :class:`~google.cloud.logging.client.Client` or
136                       ``NoneType``
137         :param client: the client to use.  If not passed, falls back to the
138                        ``client`` stored on the current sink.
139 
140         :rtype: bool
141         :returns: Boolean indicating existence of the sink.
142         """
143         client = self._require_client(client)
144 
145         try:
146             client.sinks_api.sink_get(self.project, self.name)
147         except NotFound:
148             return False
149         else:
150             return True
151 
152     def reload(self, client=None):
153         """API call:  sync local sink configuration via a GET request
154 
155         See
156         https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get
157 
158         :type client: :class:`~google.cloud.logging.client.Client` or
159                       ``NoneType``
160         :param client: the client to use.  If not passed, falls back to the
161                        ``client`` stored on the current sink.
162         """
163         client = self._require_client(client)
164         data = client.sinks_api.sink_get(self.project, self.name)
165         self.destination = data['destination']
166         self.filter_ = data.get('filter')
167 
168     def update(self, client=None):
169         """API call:  update sink configuration via a PUT request
170 
171         See
172         https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/update
173 
174         :type client: :class:`~google.cloud.logging.client.Client` or
175                       ``NoneType``
176         :param client: the client to use.  If not passed, falls back to the
177                        ``client`` stored on the current sink.
178         """
179         client = self._require_client(client)
180         client.sinks_api.sink_update(
181             self.project, self.name, self.filter_, self.destination)
182 
183     def delete(self, client=None):
184         """API call:  delete a sink via a DELETE request
185 
186         See
187         https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/delete
188 
189         :type client: :class:`~google.cloud.logging.client.Client` or
190                       ``NoneType``
191         :param client: the client to use.  If not passed, falls back to the
192                        ``client`` stored on the current sink.
193         """
194         client = self._require_client(client)
195         client.sinks_api.sink_delete(self.project, self.name)
196
```
--- 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()

```

diff --git a/logging/google/cloud/logging/sink.py b/logging/google/cloud/logging/sink.py
--- a/logging/google/cloud/logging/sink.py
+++ b/logging/google/cloud/logging/sink.py
@@ -51,6 +51,7 @@
         self.destination = destination
         self._client = client
         self._unique_writer_identity = unique_writer_identity
+        self._writer_identity = None
 
     @property
     def client(self):
@@ -72,6 +73,11 @@
         """URL path for the sink's APIs"""
         return '/%s' % (self.full_name)
 
+    @property
+    def writer_identity(self):
+        """Identity used for exports via the sink"""
+        return self._writer_identity
+
     @classmethod
     def from_api_repr(cls, resource, client):
         """Factory:  construct a sink given its API representation
@@ -92,7 +98,9 @@
         sink_name = resource['name']
         destination = resource['destination']
         filter_ = resource.get('filter')
-        return cls(sink_name, filter_, destination, client=client)
+        instance = cls(sink_name, filter_, destination, client=client)
+        instance._writer_identity = resource.get('writerIdentity')
+        return instance
 
     def _require_client(self, client):
         """Check client or verify over-ride.
@@ -161,9 +169,10 @@
                        ``client`` stored on the current sink.
         """
         client = self._require_client(client)
-        data = client.sinks_api.sink_get(self.project, self.name)
-        self.destination = data['destination']
-        self.filter_ = data.get('filter')
+        resource = client.sinks_api.sink_get(self.project, self.name)
+        self.destination = resource['destination']
+        self.filter_ = resource.get('filter')
+        self._writer_identity = resource.get('writerIdentity')
 
     def update(self, client=None):
         """API call:  update sink configuration via a PUT request

{"golden_diff": "diff --git a/logging/google/cloud/logging/sink.py b/logging/google/cloud/logging/sink.py\n--- a/logging/google/cloud/logging/sink.py\n+++ b/logging/google/cloud/logging/sink.py\n@@ -51,6 +51,7 @@\n         self.destination = destination\n         self._client = client\n         self._unique_writer_identity = unique_writer_identity\n+        self._writer_identity = None\n \n     @property\n     def client(self):\n@@ -72,6 +73,11 @@\n         \"\"\"URL path for the sink's APIs\"\"\"\n         return '/%s' % (self.full_name)\n \n+    @property\n+    def writer_identity(self):\n+        \"\"\"Identity used for exports via the sink\"\"\"\n+        return self._writer_identity\n+\n     @classmethod\n     def from_api_repr(cls, resource, client):\n         \"\"\"Factory:  construct a sink given its API representation\n@@ -92,7 +98,9 @@\n         sink_name = resource['name']\n         destination = resource['destination']\n         filter_ = resource.get('filter')\n-        return cls(sink_name, filter_, destination, client=client)\n+        instance = cls(sink_name, filter_, destination, client=client)\n+        instance._writer_identity = resource.get('writerIdentity')\n+        return instance\n \n     def _require_client(self, client):\n         \"\"\"Check client or verify over-ride.\n@@ -161,9 +169,10 @@\n                        ``client`` stored on the current sink.\n         \"\"\"\n         client = self._require_client(client)\n-        data = client.sinks_api.sink_get(self.project, self.name)\n-        self.destination = data['destination']\n-        self.filter_ = data.get('filter')\n+        resource = client.sinks_api.sink_get(self.project, self.name)\n+        self.destination = resource['destination']\n+        self.filter_ = resource.get('filter')\n+        self._writer_identity = resource.get('writerIdentity')\n \n     def update(self, client=None):\n         \"\"\"API call:  update sink configuration via a PUT request\n", "issue": "Logging: Can't retrieve the writerIdentity for a logging sink\nIn #4578 , support was added for creating a sink with a unique writerIdentity. It would appear that only the uniqueWriterIdentity boolean for logging.sinks.create was implemented; but retrieving the writerIdentity for an existing sink is not possible.\r\n\r\n## API response (via gcloud)\r\n```\r\n$ gcloud logging sinks list --project xxxx --log-http\r\n[...]\r\n-- body start --\r\n{\r\n  \"sinks\": [\r\n    {\r\n      \"name\": \"xxxx\",\r\n      \"destination\": \"storage.googleapis.com/xxxx\",\r\n      \"filter\": \"xxxx\",\r\n      \"outputVersionFormt\": \"V2\",\r\n      \"writerIdentity\": \"serviceAccount:xxxx@logging-xxxx.iam.gserviceaccount.com\"\r\n    }\r\n  ]\r\n}\r\n\r\n-- body end --\r\n```\r\n\r\n## Simplified example code\r\n```\r\nfrom google.cloud import logging\r\n\r\nlogging_client = logging.Client(project_id)\r\nsink = logging_client.sink(sink_name)\r\nsink.reload()\r\n```\r\n\r\n## Resulting object\r\n```\r\n(Pdb) sink.\r\nsink.__class__(         sink.__hash__(          sink.__setattr__(       sink.destination\r\nsink.__delattr__(       sink.__init__(          sink.__sizeof__(        sink.exists(\r\nsink.__dict__           sink.__le__(            sink.__str__(           sink.filter_\r\nsink.__dir__(           sink.__lt__(            sink.__subclasshook__(  sink.from_api_repr(\r\nsink.__doc__            sink.__module__         sink.__weakref__        sink.full_name\r\nsink.__eq__(            sink.__ne__(            sink._client            sink.name\r\nsink.__format__(        sink.__new__(           sink._require_client(   sink.path\r\nsink.__ge__(            sink.__reduce__(        sink.client             sink.project\r\nsink.__getattribute__(  sink.__reduce_ex__(     sink.create(            sink.reload(\r\nsink.__gt__(            sink.__repr__(          sink.delete(            sink.update(\r\n\r\n(Pdb) sink.__dict__\r\n{'destination': 'storage.googleapis.com/logs-00006913-fake-customer', '_client': <google.cloud.logging.client.Client object at 0x7f1d2728e860>, 'name': 'asdf1234', 'filter_': '*'}\r\n```\r\n\r\n\n", "before_files": [{"content": "# Copyright 2016 Google LLC\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 Stackdriver Logging API Sinks.\"\"\"\n\nfrom google.cloud.exceptions import NotFound\n\n\nclass Sink(object):\n    \"\"\"Sinks represent filtered exports for log entries.\n\n    See\n    https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks\n\n    :type name: str\n    :param name: the name of the sink\n\n    :type filter_: str\n    :param filter_: (optional) the advanced logs filter expression defining\n                    the entries exported by the sink.\n\n    :type destination: str\n    :param destination: destination URI for the entries exported by the sink.\n                        If not passed, the instance should already exist, to\n                        be refreshed via :meth:`reload`.\n\n    :type client: :class:`google.cloud.logging.client.Client`\n    :param client: A client which holds credentials and project configuration\n                   for the sink (which requires a project).\n\n    :type unique_writer_identity: bool\n    :param unique_writer_identity: (Optional) determines the kind of\n                                   IAM identity returned as\n                                   writer_identity in the new sink.\n    \"\"\"\n    def __init__(self, name, filter_=None, destination=None, client=None,\n                 unique_writer_identity=False):\n        self.name = name\n        self.filter_ = filter_\n        self.destination = destination\n        self._client = client\n        self._unique_writer_identity = unique_writer_identity\n\n    @property\n    def client(self):\n        \"\"\"Client bound to the sink.\"\"\"\n        return self._client\n\n    @property\n    def project(self):\n        \"\"\"Project bound to the sink.\"\"\"\n        return self._client.project\n\n    @property\n    def full_name(self):\n        \"\"\"Fully-qualified name used in sink APIs\"\"\"\n        return 'projects/%s/sinks/%s' % (self.project, self.name)\n\n    @property\n    def path(self):\n        \"\"\"URL path for the sink's APIs\"\"\"\n        return '/%s' % (self.full_name)\n\n    @classmethod\n    def from_api_repr(cls, resource, client):\n        \"\"\"Factory:  construct a sink given its API representation\n\n        :type resource: dict\n        :param resource: sink resource representation returned from the API\n\n        :type client: :class:`google.cloud.logging.client.Client`\n        :param client: Client which holds credentials and project\n                       configuration for the sink.\n\n        :rtype: :class:`google.cloud.logging.sink.Sink`\n        :returns: Sink parsed from ``resource``.\n        :raises: :class:`ValueError` if ``client`` is not ``None`` and the\n                 project from the resource does not agree with the project\n                 from the client.\n        \"\"\"\n        sink_name = resource['name']\n        destination = resource['destination']\n        filter_ = resource.get('filter')\n        return cls(sink_name, filter_, destination, client=client)\n\n    def _require_client(self, client):\n        \"\"\"Check client or verify over-ride.\n\n        :type client: :class:`~google.cloud.logging.client.Client` or\n                      ``NoneType``\n        :param client: the client to use.  If not passed, falls back to the\n                       ``client`` stored on the current sink.\n\n        :rtype: :class:`google.cloud.logging.client.Client`\n        :returns: The client passed in or the currently bound client.\n        \"\"\"\n        if client is None:\n            client = self._client\n        return client\n\n    def create(self, client=None):\n        \"\"\"API call:  create the sink via a PUT request\n\n        See\n        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/create\n\n        :type client: :class:`~google.cloud.logging.client.Client` or\n                      ``NoneType``\n        :param client: the client to use.  If not passed, falls back to the\n                       ``client`` stored on the current sink.\n        \"\"\"\n        client = self._require_client(client)\n        client.sinks_api.sink_create(\n            self.project, self.name, self.filter_, self.destination,\n            unique_writer_identity=self._unique_writer_identity,\n        )\n\n    def exists(self, client=None):\n        \"\"\"API call:  test for the existence of the sink via a GET request\n\n        See\n        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get\n\n        :type client: :class:`~google.cloud.logging.client.Client` or\n                      ``NoneType``\n        :param client: the client to use.  If not passed, falls back to the\n                       ``client`` stored on the current sink.\n\n        :rtype: bool\n        :returns: Boolean indicating existence of the sink.\n        \"\"\"\n        client = self._require_client(client)\n\n        try:\n            client.sinks_api.sink_get(self.project, self.name)\n        except NotFound:\n            return False\n        else:\n            return True\n\n    def reload(self, client=None):\n        \"\"\"API call:  sync local sink configuration via a GET request\n\n        See\n        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get\n\n        :type client: :class:`~google.cloud.logging.client.Client` or\n                      ``NoneType``\n        :param client: the client to use.  If not passed, falls back to the\n                       ``client`` stored on the current sink.\n        \"\"\"\n        client = self._require_client(client)\n        data = client.sinks_api.sink_get(self.project, self.name)\n        self.destination = data['destination']\n        self.filter_ = data.get('filter')\n\n    def update(self, client=None):\n        \"\"\"API call:  update sink configuration via a PUT request\n\n        See\n        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/update\n\n        :type client: :class:`~google.cloud.logging.client.Client` or\n                      ``NoneType``\n        :param client: the client to use.  If not passed, falls back to the\n                       ``client`` stored on the current sink.\n        \"\"\"\n        client = self._require_client(client)\n        client.sinks_api.sink_update(\n            self.project, self.name, self.filter_, self.destination)\n\n    def delete(self, client=None):\n        \"\"\"API call:  delete a sink via a DELETE request\n\n        See\n        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/delete\n\n        :type client: :class:`~google.cloud.logging.client.Client` or\n                      ``NoneType``\n        :param client: the client to use.  If not passed, falls back to the\n                       ``client`` stored on the current sink.\n        \"\"\"\n        client = self._require_client(client)\n        client.sinks_api.sink_delete(self.project, self.name)\n", "path": "logging/google/cloud/logging/sink.py"}], "after_files": [{"content": "# Copyright 2016 Google LLC\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 Stackdriver Logging API Sinks.\"\"\"\n\nfrom google.cloud.exceptions import NotFound\n\n\nclass Sink(object):\n    \"\"\"Sinks represent filtered exports for log entries.\n\n    See\n    https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks\n\n    :type name: str\n    :param name: the name of the sink\n\n    :type filter_: str\n    :param filter_: (optional) the advanced logs filter expression defining\n                    the entries exported by the sink.\n\n    :type destination: str\n    :param destination: destination URI for the entries exported by the sink.\n                        If not passed, the instance should already exist, to\n                        be refreshed via :meth:`reload`.\n\n    :type client: :class:`google.cloud.logging.client.Client`\n    :param client: A client which holds credentials and project configuration\n                   for the sink (which requires a project).\n\n    :type unique_writer_identity: bool\n    :param unique_writer_identity: (Optional) determines the kind of\n                                   IAM identity returned as\n                                   writer_identity in the new sink.\n    \"\"\"\n    def __init__(self, name, filter_=None, destination=None, client=None,\n                 unique_writer_identity=False):\n        self.name = name\n        self.filter_ = filter_\n        self.destination = destination\n        self._client = client\n        self._unique_writer_identity = unique_writer_identity\n        self._writer_identity = None\n\n    @property\n    def client(self):\n        \"\"\"Client bound to the sink.\"\"\"\n        return self._client\n\n    @property\n    def project(self):\n        \"\"\"Project bound to the sink.\"\"\"\n        return self._client.project\n\n    @property\n    def full_name(self):\n        \"\"\"Fully-qualified name used in sink APIs\"\"\"\n        return 'projects/%s/sinks/%s' % (self.project, self.name)\n\n    @property\n    def path(self):\n        \"\"\"URL path for the sink's APIs\"\"\"\n        return '/%s' % (self.full_name)\n\n    @property\n    def writer_identity(self):\n        \"\"\"Identity used for exports via the sink\"\"\"\n        return self._writer_identity\n\n    @classmethod\n    def from_api_repr(cls, resource, client):\n        \"\"\"Factory:  construct a sink given its API representation\n\n        :type resource: dict\n        :param resource: sink resource representation returned from the API\n\n        :type client: :class:`google.cloud.logging.client.Client`\n        :param client: Client which holds credentials and project\n                       configuration for the sink.\n\n        :rtype: :class:`google.cloud.logging.sink.Sink`\n        :returns: Sink parsed from ``resource``.\n        :raises: :class:`ValueError` if ``client`` is not ``None`` and the\n                 project from the resource does not agree with the project\n                 from the client.\n        \"\"\"\n        sink_name = resource['name']\n        destination = resource['destination']\n        filter_ = resource.get('filter')\n        instance = cls(sink_name, filter_, destination, client=client)\n        instance._writer_identity = resource.get('writerIdentity')\n        return instance\n\n    def _require_client(self, client):\n        \"\"\"Check client or verify over-ride.\n\n        :type client: :class:`~google.cloud.logging.client.Client` or\n                      ``NoneType``\n        :param client: the client to use.  If not passed, falls back to the\n                       ``client`` stored on the current sink.\n\n        :rtype: :class:`google.cloud.logging.client.Client`\n        :returns: The client passed in or the currently bound client.\n        \"\"\"\n        if client is None:\n            client = self._client\n        return client\n\n    def create(self, client=None):\n        \"\"\"API call:  create the sink via a PUT request\n\n        See\n        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/create\n\n        :type client: :class:`~google.cloud.logging.client.Client` or\n                      ``NoneType``\n        :param client: the client to use.  If not passed, falls back to the\n                       ``client`` stored on the current sink.\n        \"\"\"\n        client = self._require_client(client)\n        client.sinks_api.sink_create(\n            self.project, self.name, self.filter_, self.destination,\n            unique_writer_identity=self._unique_writer_identity,\n        )\n\n    def exists(self, client=None):\n        \"\"\"API call:  test for the existence of the sink via a GET request\n\n        See\n        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get\n\n        :type client: :class:`~google.cloud.logging.client.Client` or\n                      ``NoneType``\n        :param client: the client to use.  If not passed, falls back to the\n                       ``client`` stored on the current sink.\n\n        :rtype: bool\n        :returns: Boolean indicating existence of the sink.\n        \"\"\"\n        client = self._require_client(client)\n\n        try:\n            client.sinks_api.sink_get(self.project, self.name)\n        except NotFound:\n            return False\n        else:\n            return True\n\n    def reload(self, client=None):\n        \"\"\"API call:  sync local sink configuration via a GET request\n\n        See\n        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get\n\n        :type client: :class:`~google.cloud.logging.client.Client` or\n                      ``NoneType``\n        :param client: the client to use.  If not passed, falls back to the\n                       ``client`` stored on the current sink.\n        \"\"\"\n        client = self._require_client(client)\n        resource = client.sinks_api.sink_get(self.project, self.name)\n        self.destination = resource['destination']\n        self.filter_ = resource.get('filter')\n        self._writer_identity = resource.get('writerIdentity')\n\n    def update(self, client=None):\n        \"\"\"API call:  update sink configuration via a PUT request\n\n        See\n        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/update\n\n        :type client: :class:`~google.cloud.logging.client.Client` or\n                      ``NoneType``\n        :param client: the client to use.  If not passed, falls back to the\n                       ``client`` stored on the current sink.\n        \"\"\"\n        client = self._require_client(client)\n        client.sinks_api.sink_update(\n            self.project, self.name, self.filter_, self.destination)\n\n    def delete(self, client=None):\n        \"\"\"API call:  delete a sink via a DELETE request\n\n        See\n        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/delete\n\n        :type client: :class:`~google.cloud.logging.client.Client` or\n                      ``NoneType``\n        :param client: the client to use.  If not passed, falls back to the\n                       ``client`` stored on the current sink.\n        \"\"\"\n        client = self._require_client(client)\n        client.sinks_api.sink_delete(self.project, self.name)\n", "path": "logging/google/cloud/logging/sink.py"}]}