@@ -90,13 +90,23 @@ class InvalidOperationException(Exception):
9090class Policy (collections_abc .MutableMapping ):
9191 """IAM Policy
9292
93- See
94- https://cloud.google.com/iam/reference/rest/v1/Policy
95-
9693 Args:
9794 etag (Optional[str]): ETag used to identify a unique of the policy
9895 version (Optional[int]): The syntax schema version of the policy.
9996
97+ Note:
98+ Using conditions in bindings requires the policy's version to be set
99+ to `3` or greater, depending on the versions that are currently supported.
100+
101+ Accessing the policy using dict operations will raise InvalidOperationException
102+ when the policy's version is set to 3.
103+
104+ Use the policy.bindings getter/setter to retrieve and modify the policy's bindings.
105+
106+ See:
107+ IAM Policy https://cloud.google.com/iam/reference/rest/v1/Policy
108+ Policy versions https://cloud.google.com/iam/docs/policies#versions
109+ Conditions overview https://cloud.google.com/iam/docs/conditions-overview.
100110 """
101111
102112 _OWNER_ROLES = (OWNER_ROLE ,)
@@ -146,7 +156,7 @@ def __delitem__(self, key):
146156 raise KeyError (key )
147157
148158 def __check_version__ (self ):
149- """Raise InvalidOperationException if version is greater than 1."""
159+ """Raise InvalidOperationException if version is greater than 1 or policy contains conditions ."""
150160 raise_version = self .version is not None and self .version > 1
151161
152162 if raise_version or self ._contains_conditions ():
@@ -171,15 +181,6 @@ def bindings(self):
171181 description (:obj:str, optional): Description of the condition.
172182 expression: A CEL expression.
173183
174- Note:
175- Using conditions in bindings requires the policy's version to be set
176- to `3` or greater, depending on the versions that are currently supported.
177-
178- Accessing the policy using dict operations will raise InvalidOperationException
179- when the policy's version is set to 3.
180-
181- Use the policy.bindings getter/setter to retrieve and modify the policy's bindings.
182-
183184 See:
184185 Policy versions https://cloud.google.com/iam/docs/policies#versions
185186 Conditions overview https://cloud.google.com/iam/docs/conditions-overview.
@@ -216,6 +217,8 @@ def bindings(self, bindings):
216217 def owners (self ):
217218 """Legacy access to owner role.
218219
220+ Raise InvalidOperationException if version is greater than 1 or policy contains conditions.
221+
219222 DEPRECATED: use `policy.bindings` to access bindings instead.
220223 """
221224 result = set ()
@@ -228,6 +231,8 @@ def owners(self):
228231 def owners (self , value ):
229232 """Update owners.
230233
234+ Raise InvalidOperationException if version is greater than 1 or policy contains conditions.
235+
231236 DEPRECATED: use `policy.bindings` to access bindings instead.
232237 """
233238 warnings .warn (
@@ -239,6 +244,8 @@ def owners(self, value):
239244 def editors (self ):
240245 """Legacy access to editor role.
241246
247+ Raise InvalidOperationException if version is greater than 1 or policy contains conditions.
248+
242249 DEPRECATED: use `policy.bindings` to access bindings instead.
243250 """
244251 result = set ()
@@ -251,6 +258,8 @@ def editors(self):
251258 def editors (self , value ):
252259 """Update editors.
253260
261+ Raise InvalidOperationException if version is greater than 1 or policy contains conditions.
262+
254263 DEPRECATED: use `policy.bindings` to modify bindings instead.
255264 """
256265 warnings .warn (
@@ -263,6 +272,8 @@ def editors(self, value):
263272 def viewers (self ):
264273 """Legacy access to viewer role.
265274
275+ Raise InvalidOperationException if version is greater than 1 or policy contains conditions.
276+
266277 DEPRECATED: use `policy.bindings` to modify bindings instead.
267278 """
268279 result = set ()
@@ -275,6 +286,8 @@ def viewers(self):
275286 def viewers (self , value ):
276287 """Update viewers.
277288
289+ Raise InvalidOperationException if version is greater than 1 or policy contains conditions.
290+
278291 DEPRECATED: use `policy.bindings` to modify bindings instead.
279292 """
280293 warnings .warn (
0 commit comments