@@ -882,6 +882,35 @@ def get_iam_policy(
882882 retry : retries .Retry = DEFAULT_RETRY ,
883883 timeout : TimeoutType = DEFAULT_TIMEOUT ,
884884 ) -> Policy :
885+ """Return the access control policy for a table resource.
886+
887+ Args:
888+ table (Union[ \
889+ google.cloud.bigquery.table.Table, \
890+ google.cloud.bigquery.table.TableReference, \
891+ google.cloud.bigquery.table.TableListItem, \
892+ str, \
893+ ]):
894+ The table to get the access control policy for.
895+ If a string is passed in, this method attempts to create a
896+ table reference from a string using
897+ :func:`~google.cloud.bigquery.table.TableReference.from_string`.
898+ requested_policy_version (int):
899+ Optional. The maximum policy version that will be used to format the policy.
900+
901+ Only version ``1`` is currently supported.
902+
903+ See: https://cloud.google.com/bigquery/docs/reference/rest/v2/GetPolicyOptions
904+ retry (Optional[google.api_core.retry.Retry]):
905+ How to retry the RPC.
906+ timeout (Optional[float]):
907+ The number of seconds to wait for the underlying HTTP transport
908+ before using ``retry``.
909+
910+ Returns:
911+ google.api_core.iam.Policy:
912+ The access control policy.
913+ """
885914 table = _table_arg_to_table_ref (table , default_project = self .project )
886915
887916 if requested_policy_version != 1 :
@@ -910,16 +939,62 @@ def set_iam_policy(
910939 updateMask : Optional [str ] = None ,
911940 retry : retries .Retry = DEFAULT_RETRY ,
912941 timeout : TimeoutType = DEFAULT_TIMEOUT ,
942+ * ,
943+ fields : Sequence [str ] = (),
913944 ) -> Policy :
945+ """Return the access control policy for a table resource.
946+
947+ Args:
948+ table (Union[ \
949+ google.cloud.bigquery.table.Table, \
950+ google.cloud.bigquery.table.TableReference, \
951+ google.cloud.bigquery.table.TableListItem, \
952+ str, \
953+ ]):
954+ The table to get the access control policy for.
955+ If a string is passed in, this method attempts to create a
956+ table reference from a string using
957+ :func:`~google.cloud.bigquery.table.TableReference.from_string`.
958+ policy (google.api_core.iam.Policy):
959+ The access control policy to set.
960+ updateMask (Optional[str]):
961+ Mask as defined by
962+ https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/setIamPolicy#body.request_body.FIELDS.update_mask
963+
964+ Incompatible with ``fields``.
965+ retry (Optional[google.api_core.retry.Retry]):
966+ How to retry the RPC.
967+ timeout (Optional[float]):
968+ The number of seconds to wait for the underlying HTTP transport
969+ before using ``retry``.
970+ fields (Sequence[str]):
971+ Which properties to set on the policy. See:
972+ https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/setIamPolicy#body.request_body.FIELDS.update_mask
973+
974+ Incompatible with ``updateMask``.
975+
976+ Returns:
977+ google.api_core.iam.Policy:
978+ The updated access control policy.
979+ """
980+ if updateMask is not None and not fields :
981+ update_mask = updateMask
982+ elif updateMask is not None and fields :
983+ raise ValueError ("Cannot set both fields and updateMask" )
984+ elif fields :
985+ update_mask = "," .join (fields )
986+ else :
987+ update_mask = None
988+
914989 table = _table_arg_to_table_ref (table , default_project = self .project )
915990
916991 if not isinstance (policy , (Policy )):
917992 raise TypeError ("policy must be a Policy" )
918993
919994 body = {"policy" : policy .to_api_repr ()}
920995
921- if updateMask is not None :
922- body ["updateMask" ] = updateMask
996+ if update_mask is not None :
997+ body ["updateMask" ] = update_mask
923998
924999 path = "{}:setIamPolicy" .format (table .path )
9251000 span_attributes = {"path" : path }
0 commit comments