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 butview
orroutine
are set, arole
is also required.role
is omitted forview
androutine
, because they 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 theentity_type
isview
orroutine
.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’ or ‘routine’, 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 }
- Raises
ValueError – If the
entity_type
is not amongENTITY_TYPES
, or if aview
or aroutine
hasrole
set, or a nonview
and nonroutine
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, 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
Construct the API resource representation of this access entry
Attributes
Allowed entity types.
The entity_id of the entry.
The entity_type of the entry.
The role of the entry.
-
ENTITY_TYPES
= frozenset({'domain', 'groupByEmail', 'iamMember', 'routine', 'specialGroup', 'userByEmail', 'view'})¶ Allowed entity types.
-
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
- Raises
ValueError – If the resource has more keys than
role
and one additional key.