Skip to content

Commit 1d88cdc

Browse files
authored
Move 'unique_writer_identity' from LogSink ctor to 'create' (#4706)
Preps support for passing it to 'update' as well. See: googleapis/google-cloud-python#4703 (comment)
1 parent 9866c25 commit 1d88cdc

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

google/cloud/logging/sink.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,12 @@ class Sink(object):
3838
:type client: :class:`google.cloud.logging.client.Client`
3939
:param client: A client which holds credentials and project configuration
4040
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.
4641
"""
47-
def __init__(self, name, filter_=None, destination=None, client=None,
48-
unique_writer_identity=False):
42+
def __init__(self, name, filter_=None, destination=None, client=None):
4943
self.name = name
5044
self.filter_ = filter_
5145
self.destination = destination
5246
self._client = client
53-
self._unique_writer_identity = unique_writer_identity
5447
self._writer_identity = None
5548

5649
@property
@@ -117,7 +110,7 @@ def _require_client(self, client):
117110
client = self._client
118111
return client
119112

120-
def create(self, client=None):
113+
def create(self, client=None, unique_writer_identity=False):
121114
"""API call: create the sink via a PUT request
122115
123116
See
@@ -127,11 +120,16 @@ def create(self, client=None):
127120
``NoneType``
128121
:param client: the client to use. If not passed, falls back to the
129122
``client`` stored on the current sink.
123+
124+
:type unique_writer_identity: bool
125+
:param unique_writer_identity: (Optional) determines the kind of
126+
IAM identity returned as
127+
writer_identity in the new sink.
130128
"""
131129
client = self._require_client(client)
132130
client.sinks_api.sink_create(
133131
self.project, self.name, self.filter_, self.destination,
134-
unique_writer_identity=self._unique_writer_identity,
132+
unique_writer_identity=unique_writer_identity,
135133
)
136134

137135
def exists(self, client=None):

tests/unit/test_sink.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def test_create_w_alternate_client(self):
122122
client=client1)
123123
api = client2.sinks_api = _DummySinksAPI()
124124

125-
sink.create(client=client2)
125+
sink.create(client=client2, unique_writer_identity=True)
126126

127127
self.assertEqual(
128128
api._sink_create_called_with,
@@ -131,7 +131,7 @@ def test_create_w_alternate_client(self):
131131
self.SINK_NAME,
132132
self.FILTER,
133133
self.DESTINATION_URI,
134-
False,
134+
True,
135135
),
136136
)
137137

0 commit comments

Comments
 (0)