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, entity_type, entity_id)[source]

Represents grant of an access role to an entity.

An entry must have exactly one of the allowed ENTITY_TYPES. If anything but view is set, a role is also required. role is omitted for a view, because view s are always read-only.

See https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets.

Parameters
  • role (str) – 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.

  • entity_type (str) – Type of entity being granted the role. One of ENTITY_TYPES.

  • entity_id (Union[str, Dict[str, str]]) –

    If the entity_type is not ‘view’, the entity_id is the str ID of the entity being granted the role. If the entity_type is ‘view’, the entity_id is a dict representing the view from a different dataset to grant access to in the following format:

    {
        'projectId': string,
        'datasetId': string,
        'tableId': string
    }
    

Raises

ValueError – If the entity_type is not among ENTITY_TYPES, or if a view has role set, or a non view 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, entity_type, entity_id)[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

ENTITY_TYPES

Allowed entity types.

entity_id

The entity_id of the entry.

entity_type

The entity_type of the entry.

role

The role of the entry.

ENTITY_TYPES = frozenset({'domain', 'groupByEmail', 'iamMember', 'specialGroup', 'userByEmail', 'view'})

Allowed entity types.

property entity_id

The entity_id of the entry.

Type

str

property entity_type

The entity_type of the entry.

Type

str

classmethod from_api_repr(resource)[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 role

The role of the entry.

Type

str

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]