As of January 1, 2020 this library no longer supports Python 2 on the latest released version. Library versions released prior to that date will continue to be available. For more information please visit Python 2 support on Google Cloud.

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 but view, routine, or dataset are set, a role is also required. role is omitted for view, 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 the entity_type is view, routine, or dataset.

  • 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’, the entity_id is the str ID of the entity being granted the role. If the entity_type is ‘view’ or ‘routine’, the entity_id is a dict 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’, the entity_id is a dict that includes a ‘dataset’ field with a dict representing the dataset and a ‘target_types’ field with a str value of the dataset’s resource type:

    {
        'dataset': {
            'projectId': string,
            'datasetId': string,
        },
        'target_types: 'VIEWS'
    }
    

Raises

ValueError – If a view, routine, or dataset has role set, or a non view, non routine, and non dataset does not have a role 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

to_api_repr()

Construct the API resource representation of this access entry

Attributes

dataset

API resource representation of a dataset reference.

dataset_target_types

Which resources that the dataset in this entry applies to.

domain

A domain to grant access to.

entity_id

The entity_id of the entry.

entity_type

The entity_type of the entry.

group_by_email

An email address of a Google Group to grant access to.

role

The role of the entry.

routine

API resource representation of a routine reference.

special_group

A special group to grant access to.

user_by_email

An email address of a user to grant access to.

view

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

google.cloud.bigquery.dataset.AccessEntry

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.

to_api_repr()[source]

Construct the API resource representation of this access entry

Returns

Access entry represented as an API resource

Return type

Dict[str, object]

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.