google.cloud.bigquery.dataset.AccessEntry¶
- class google.cloud.bigquery.dataset.AccessEntry(role: Optional[str] = None, entity_type: Optional[str] = None, entity_id: Optional[Union[Dict[str, Any], str]] = None)[source]¶
Represents grant of an access role to an entity.
An entry must have exactly one of the allowed
google.cloud.bigquery.enums.EntityTypes
. If anything butview
,routine
, ordataset
are set, arole
is also required.role
is omitted forview
,routine
,dataset
, because they are always read-only.See https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets.
- Parameters
role – Role granted to the entity. The following string values are supported: ‘READER’, ‘WRITER’, ‘OWNER’. It may also be
None
if theentity_type
isview
,routine
, ordataset
.entity_type – Type of entity being granted the role. See
google.cloud.bigquery.enums.EntityTypes
for supported types.entity_id –
If the
entity_type
is not ‘view’, ‘routine’, or ‘dataset’, theentity_id
is thestr
ID of the entity being granted the role. If theentity_type
is ‘view’ or ‘routine’, theentity_id
is adict
representing the view or routine from a different dataset to grant access to in the following format for views:{ 'projectId': string, 'datasetId': string, 'tableId': string }
For routines:
{ 'projectId': string, 'datasetId': string, 'routineId': string }
If the
entity_type
is ‘dataset’, theentity_id
is adict
that includes a ‘dataset’ field with adict
representing the dataset and a ‘target_types’ field with astr
value of the dataset’s resource type:{ 'dataset': { 'projectId': string, 'datasetId': string, }, 'target_types: 'VIEWS' }
- Raises
ValueError – If a
view
,routine
, ordataset
hasrole
set, or a nonview
, nonroutine
, and nondataset
does not have arole
set.
Examples
>>> entry = AccessEntry('OWNER', 'userByEmail', 'user@example.com')
>>> view = { ... 'projectId': 'my-project', ... 'datasetId': 'my_dataset', ... 'tableId': 'my_table' ... } >>> entry = AccessEntry(None, 'view', view)
- __init__(role: Optional[str] = None, entity_type: Optional[str] = None, entity_id: Optional[Union[Dict[str, Any], str]] = None)[source]¶
Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
([role, entity_type, entity_id])Initialize self.
from_api_repr
(resource)Factory: construct an access entry given its API representation
Construct the API resource representation of this access entry
Attributes
API resource representation of a dataset reference.
Which resources that the dataset in this entry applies to.
A domain to grant access to.
The entity_id of the entry.
The entity_type of the entry.
An email address of a Google Group to grant access to.
The role of the entry.
API resource representation of a routine reference.
A special group to grant access to.
An email address of a user to grant access to.
API resource representation of a view reference.
- property dataset: Optional[google.cloud.bigquery.dataset.DatasetReference]¶
API resource representation of a dataset reference.
- property dataset_target_types: Optional[List[str]]¶
Which resources that the dataset in this entry applies to.
- property domain: Optional[str]¶
A domain to grant access to.
- property entity_id: Optional[Union[Dict[str, Any], str]]¶
The entity_id of the entry.
- property entity_type: Optional[str]¶
The entity_type of the entry.
- classmethod from_api_repr(resource: dict) → google.cloud.bigquery.dataset.AccessEntry[source]¶
Factory: construct an access entry given its API representation
- Parameters
resource (Dict[str, object]) – Access entry resource representation returned from the API
- Returns
Access entry parsed from
resource
.- Return type
- Raises
ValueError – If the resource has more keys than
role
and one additional key.
- property group_by_email: Optional[str]¶
An email address of a Google Group to grant access to.
- property role: Optional[str]¶
The role of the entry.
- property routine: Optional[google.cloud.bigquery.routine.routine.RoutineReference]¶
API resource representation of a routine reference.
- property special_group: Optional[str]¶
A special group to grant access to.
- property user_by_email: Optional[str]¶
An email address of a user to grant access to.
- property view: Optional[google.cloud.bigquery.table.TableReference]¶
API resource representation of a view reference.