text
stringlengths
81
112k
Perform a ``beginTransaction`` request. :type project_id: str :param project_id: The project to connect to. This is usually your project name in the cloud console. :type transaction_options: ~.datastore_v1.types.TransactionOptions :param transaction_options: ...
Perform a ``commit`` request. :type project_id: str :param project_id: The project to connect to. This is usually your project name in the cloud console. :type mode: :class:`.gapic.datastore.v1.enums.CommitRequest.Mode` :param mode: The type of commit to perf...
Perform a ``rollback`` request. :type project_id: str :param project_id: The project to connect to. This is usually your project name in the cloud console. :type transaction: bytes :param transaction: The transaction ID to rollback. :rtype: :class:`....
Perform an ``allocateIds`` request. :type project_id: str :param project_id: The project to connect to. This is usually your project name in the cloud console. :type keys: List[.entity_pb2.Key] :param keys: The keys for which the backend should allocate IDs. ...
Creates a request to read rows in a table. :type table_name: str :param table_name: The name of the table to read from. :type start_key: bytes :param start_key: (Optional) The beginning of a range of row keys to read from. The range will include ``start_key``. If ...
Creates a request to mutate rows in a table. :type table_name: str :param table_name: The name of the table to write to. :type rows: list :param rows: List or other iterable of :class:`.DirectRow` instances. :type: app_profile_id: str :param app_profile_id: (Optional) The unique name of the A...
Checks that a row belongs to a table. :type table_name: str :param table_name: The name of the table. :type row: :class:`~google.cloud.bigtable.row.Row` :param row: An instance of :class:`~google.cloud.bigtable.row.Row` subclasses. :raises: :exc:`~.table.TableMismatchError` if the...
Table name used in requests. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_table_name] :end-before: [END bigtable_table_name] .. note:: This property will not change if ``table_id`` does not, but the return value ...
Factory to create a row associated with this table. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_table_row] :end-before: [END bigtable_table_row] .. warning:: At most one of ``filter_`` and ``append`` can be used in a ...
Creates this table. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_create_table] :end-before: [END bigtable_create_table] .. note:: A create request returns a :class:`._generated.table_pb2.Table` but we don't u...
Check whether the table exists. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_check_table_exists] :end-before: [END bigtable_check_table_exists] :rtype: bool :returns: True if the table exists, else False. def exists(self): ...
Delete this table. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_delete_table] :end-before: [END bigtable_delete_table] def delete(self): """Delete this table. For example: .. literalinclude:: snippets_table.py ...
List the column families owned by this table. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_list_column_families] :end-before: [END bigtable_list_column_families] :rtype: dict :returns: Dictionary of column families attached t...
List the cluster states owned by this table. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_get_cluster_states] :end-before: [END bigtable_get_cluster_states] :rtype: dict :returns: Dictionary of cluster states for this table. ...
Read a single row from this table. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_read_row] :end-before: [END bigtable_read_row] :type row_key: bytes :param row_key: The key of the row to read from. :type filter_: :cla...
Read rows from this table. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_read_rows] :end-before: [END bigtable_read_rows] :type start_key: bytes :param start_key: (Optional) The beginning of a range of row keys to ...
Read rows from this table. .. warning:: This method will be removed in future releases. Please use ``read_rows`` instead. :type start_key: bytes :param start_key: (Optional) The beginning of a range of row keys to read from. The range will inclu...
Mutates multiple rows in bulk. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_mutate_rows] :end-before: [END bigtable_mutate_rows] The method tries to update all specified rows. If some of the rows weren't updated, it would not...
Read a sample of row keys in the table. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_sample_row_keys] :end-before: [END bigtable_sample_row_keys] The returned row keys will delimit contiguous sections of the table of approxim...
Truncate the table For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_truncate_table] :end-before: [END bigtable_truncate_table] :type timeout: float :param timeout: (Optional) The amount of time, in seconds, to wait ...
Factory to create a mutation batcher associated with this instance. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_mutations_batcher] :end-before: [END bigtable_mutations_batcher] :type table: class :param table: class:`~google...
Mutate all the rows that are eligible for retry. A row is eligible for retry if it has not been tried or if it resulted in a transient error in a previous call. :rtype: list :return: The responses statuses, which is a list of :class:`~google.rpc.status_pb2.Status`. ...
Periodically send heartbeats. def heartbeat(self): """Periodically send heartbeats.""" while self._manager.is_active and not self._stop_event.is_set(): self._manager.heartbeat() _LOGGER.debug("Sent heartbeat.") self._stop_event.wait(timeout=self._period) _LO...
Report an individual error event. Example: >>> from google.cloud import errorreporting_v1beta1 >>> >>> client = errorreporting_v1beta1.ReportErrorsServiceClient() >>> >>> project_name = client.project_path('[PROJECT]') >>> >>> ...
Convert a scalar value into a query parameter. :type value: any :param value: A scalar value to convert into a query parameter. :type name: str :param name: (Optional) Name of the query parameter. :rtype: :class:`~google.cloud.bigquery.ScalarQueryParameter` :returns: A query parameter...
Converts a dictionary of parameter values into query parameters. :type parameters: Mapping[str, Any] :param parameters: Dictionary of query parameter values. :rtype: List[google.cloud.bigquery.query._AbstractQueryParameter] :returns: A list of named query parameters. def to_query_parameters_dict(para...
Converts DB-API parameter values into query parameters. :type parameters: Mapping[str, Any] or Sequence[Any] :param parameters: A dictionary or sequence of query parameter values. :rtype: List[google.cloud.bigquery.query._AbstractQueryParameter] :returns: A list of query parameters. def to_query_para...
Refresh an operation using a JSON/HTTP client. Args: api_request (Callable): A callable used to make an API request. This should generally be :meth:`google.cloud._http.Connection.api_request`. operation_name (str): The name of the operation. Returns: google.long...
Cancel an operation using a JSON/HTTP client. Args: api_request (Callable): A callable used to make an API request. This should generally be :meth:`google.cloud._http.Connection.api_request`. operation_name (str): The name of the operation. def _cancel_http(api_request, ope...
Create an operation future using a HTTP/JSON client. This interacts with the long-running operations `service`_ (specific to a given API) via `HTTP/JSON`_. .. _HTTP/JSON: https://cloud.google.com/speech/reference/rest/\ v1beta1/operations#Operation Args: operation (dict): Operatio...
Refresh an operation using a gRPC client. Args: operations_stub (google.longrunning.operations_pb2.OperationsStub): The gRPC operations stub. operation_name (str): The name of the operation. Returns: google.longrunning.operations_pb2.Operation: The operation. def _refresh_...
Cancel an operation using a gRPC client. Args: operations_stub (google.longrunning.operations_pb2.OperationsStub): The gRPC operations stub. operation_name (str): The name of the operation. def _cancel_grpc(operations_stub, operation_name): """Cancel an operation using a gRPC clien...
Create an operation future using a gRPC client. This interacts with the long-running operations `service`_ (specific to a given API) via gRPC. .. _service: https://github.com/googleapis/googleapis/blob/\ 050400df0fdb16f63b63e9dee53819044bffc857/\ google/longrunning/operat...
Create an operation future from a gapic client. This interacts with the long-running operations `service`_ (specific to a given API) via a gapic client. .. _service: https://github.com/googleapis/googleapis/blob/\ 050400df0fdb16f63b63e9dee53819044bffc857/\ google/longrunn...
google.protobuf.Message: the current operation metadata. def metadata(self): """google.protobuf.Message: the current operation metadata.""" if not self._operation.HasField("metadata"): return None return protobuf_helpers.from_any_pb( self._metadata_type, self._operation...
Set the result or exception from the operation if it is complete. def _set_result_from_operation(self): """Set the result or exception from the operation if it is complete.""" # This must be done in a lock to prevent the polling thread # and main thread from both executing the completion logic ...
Refresh the operation and update the result if needed. def _refresh_and_update(self): """Refresh the operation and update the result if needed.""" # If the currently cached operation is done, no need to make another # RPC as it will not change once done. if not self._operation.done: ...
True if the operation was cancelled. def cancelled(self): """True if the operation was cancelled.""" self._refresh_and_update() return ( self._operation.HasField("error") and self._operation.error.code == code_pb2.CANCELLED )
Remove a role from the entity. :type role: str :param role: The role to remove from the entity. def revoke(self, role): """Remove a role from the entity. :type role: str :param role: The role to remove from the entity. """ if role in self.roles: sel...
Ensures predefined is in list of predefined json values :type predefined: str :param predefined: name of a predefined acl :type predefined: str :param predefined: validated JSON name of predefined acl :raises: :exc: `ValueError`: If predefined is not a valid acl def validate_...
Build an _ACLEntity object from a dictionary of data. An entity is a mutable object that represents a list of roles belonging to either a user or group or the special types for all users and all authenticated users. :type entity_dict: dict :param entity_dict: Dictionary full of...
Gets an entity object from the ACL. :type entity: :class:`_ACLEntity` or string :param entity: The entity to get lookup in the ACL. :type default: anything :param default: This value will be returned if the entity doesn't exist. :rtype: :class:`_ACLEnti...
Add an entity to the ACL. :type entity: :class:`_ACLEntity` :param entity: The entity to add to this ACL. def add_entity(self, entity): """Add an entity to the ACL. :type entity: :class:`_ACLEntity` :param entity: The entity to add to this ACL. """ self._ensure...
Factory method for creating an Entity. If an entity with the same type and identifier already exists, this will return a reference to that entity. If not, it will create a new one and add it to the list of known entities for this ACL. :type entity_type: str :param enti...
Reload the ACL data from Cloud Storage. If :attr:`user_project` is set, bills the API request to that project. :type client: :class:`~google.cloud.storage.client.Client` or ``NoneType`` :param client: Optional. The client to use. If not passed, falls back ...
Helper for :meth:`save` and :meth:`save_predefined`. :type acl: :class:`google.cloud.storage.acl.ACL`, or a compatible list. :param acl: The ACL object to save. If left blank, this will save current entries. :type predefined: str :param predefined: (Opt...
Save this ACL for the current bucket. If :attr:`user_project` is set, bills the API request to that project. :type acl: :class:`google.cloud.storage.acl.ACL`, or a compatible list. :param acl: The ACL object to save. If left blank, this will save current entries. ...
Save this ACL for the current bucket using a predefined ACL. If :attr:`user_project` is set, bills the API request to that project. :type predefined: str :param predefined: An identifier for a predefined ACL. Must be one of the keys in :attr:`PREDEFINED_JSON_ACLS` ...
Return a fully-qualified incident string. def incident_path(cls, project, incident): """Return a fully-qualified incident string.""" return google.api_core.path_template.expand( "projects/{project}/incidents/{incident}", project=project, incident=incident, )
Return a fully-qualified annotation string. def annotation_path(cls, project, incident, annotation): """Return a fully-qualified annotation string.""" return google.api_core.path_template.expand( "projects/{project}/incidents/{incident}/annotations/{annotation}", project=project...
Return a fully-qualified artifact string. def artifact_path(cls, project, incident, artifact): """Return a fully-qualified artifact string.""" return google.api_core.path_template.expand( "projects/{project}/incidents/{incident}/artifacts/{artifact}", project=project, ...
Return a fully-qualified role_assignment string. def role_assignment_path(cls, project, incident, role_assignment): """Return a fully-qualified role_assignment string.""" return google.api_core.path_template.expand( "projects/{project}/incidents/{incident}/roleAssignments/{role_assignment}"...
Return a fully-qualified subscription string. def subscription_path(cls, project, incident, subscription): """Return a fully-qualified subscription string.""" return google.api_core.path_template.expand( "projects/{project}/incidents/{incident}/subscriptions/{subscription}", pro...
Return a fully-qualified tag string. def tag_path(cls, project, incident, tag): """Return a fully-qualified tag string.""" return google.api_core.path_template.expand( "projects/{project}/incidents/{incident}/tags/{tag}", project=project, incident=incident, ...
Return a fully-qualified signal string. def signal_path(cls, project, signal): """Return a fully-qualified signal string.""" return google.api_core.path_template.expand( "projects/{project}/signals/{signal}", project=project, signal=signal )
Creates an annotation on an existing incident. Only 'text/plain' and 'text/markdown' annotations can be created via this method. Example: >>> from google.cloud import irm_v1alpha2 >>> >>> client = irm_v1alpha2.IncidentServiceClient() >>> >>> p...
Escalates an incident. Example: >>> from google.cloud import irm_v1alpha2 >>> >>> client = irm_v1alpha2.IncidentServiceClient() >>> >>> # TODO: Initialize `incident`: >>> incident = {} >>> >>> response = client.esca...
Sends a summary of the shift for oncall handoff. Example: >>> from google.cloud import irm_v1alpha2 >>> >>> client = irm_v1alpha2.IncidentServiceClient() >>> >>> parent = client.project_path('[PROJECT]') >>> >>> # TODO: Initial...
Access to bigtable.admin role memebers For example: .. literalinclude:: snippets.py :start-after: [START bigtable_admins_policy] :end-before: [END bigtable_admins_policy] def bigtable_admins(self): """Access to bigtable.admin role memebers For example: ...
Access to bigtable.reader role memebers For example: .. literalinclude:: snippets.py :start-after: [START bigtable_readers_policy] :end-before: [END bigtable_readers_policy] def bigtable_readers(self): """Access to bigtable.reader role memebers For example: ...
Access to bigtable.user role memebers For example: .. literalinclude:: snippets.py :start-after: [START bigtable_users_policy] :end-before: [END bigtable_users_policy] def bigtable_users(self): """Access to bigtable.user role memebers For example: .. ...
Access to bigtable.viewer role memebers For example: .. literalinclude:: snippets.py :start-after: [START bigtable_viewers_policy] :end-before: [END bigtable_viewers_policy] def bigtable_viewers(self): """Access to bigtable.viewer role memebers For example: ...
Factory: create a policy from a protobuf message. Args: policy_pb (google.iam.policy_pb2.Policy): message returned by ``get_iam_policy`` gRPC API. Returns: :class:`Policy`: the parsed policy def from_pb(cls, policy_pb): """Factory: create a policy from a pr...
Render a protobuf message. Returns: google.iam.policy_pb2.Policy: a message to be passed to the ``set_iam_policy`` gRPC API. def to_pb(self): """Render a protobuf message. Returns: google.iam.policy_pb2.Policy: a message to be passed to the ``se...
Factory: create a policy from a JSON resource. Overrides the base class version to store :attr:`etag` as bytes. Args: resource (dict): JSON policy resource returned by the ``getIamPolicy`` REST API. Returns: :class:`Policy`: the parsed policy def from_api_...
Render a JSON policy resource. Overrides the base class version to convert :attr:`etag` from bytes to JSON-compatible base64-encoded text. Returns: dict: a JSON resource to be passed to the ``setIamPolicy`` REST API. def to_api_repr(self): """Render a JSON poli...
Validate DDL Statements used to define database schema. See https://cloud.google.com/spanner/docs/data-definition-language :type value: list of string :param value: DDL statements, excluding the 'CREATE DATABSE' statement :rtype: tuple :returns: tuple of validated DDL statement strings. :...
Creates an instance of this class from a protobuf. :type database_pb: :class:`google.spanner.v2.spanner_instance_admin_pb2.Instance` :param database_pb: A instance protobuf object. :type instance: :class:`~google.cloud.spanner_v1.instance.Instance` :param instance: The inst...
Helper for session-related API calls. def spanner_api(self): """Helper for session-related API calls.""" if self._spanner_api is None: credentials = self._instance._client.credentials if isinstance(credentials, google.auth.credentials.Scoped): credentials = crede...
Create this database within its instance Inclues any configured schema assigned to :attr:`ddl_statements`. See https://cloud.google.com/spanner/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase :rtype: :class:`~google.api_core...
Test whether this database exists. See https://cloud.google.com/spanner/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDDL :rtype: bool :returns: True if the database exists, else false. def exists(self): """Test whethe...
Reload this database. Refresh any configured schema into :attr:`ddl_statements`. See https://cloud.google.com/spanner/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDDL :raises NotFound: if the database does not exist def relo...
Update DDL for this database. Apply any configured schema from :attr:`ddl_statements`. See https://cloud.google.com/spanner/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabase :type ddl_statements: Sequence[str] :param d...
Drop this database. See https://cloud.google.com/spanner/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase def drop(self): """Drop this database. See https://cloud.google.com/spanner/reference/rpc/google.spanner.admin.da...
Execute a partitionable DML statement. :type dml: str :param dml: DML statement :type params: dict, {str -> column value} :param params: values for parameter replacement. Keys must match the names used in ``dml``. :type param_types: dict[str -> Union[di...
Return an object which wraps a batch read / query. :type read_timestamp: :class:`datetime.datetime` :param read_timestamp: Execute all reads at the given timestamp. :type exact_staleness: :class:`datetime.timedelta` :param exact_staleness: Execute all reads at a timestamp that is ...
Perform a unit of work in a transaction, retrying on abort. :type func: callable :param func: takes a required positional argument, the transaction, and additional positional / keyword arguments as supplied by the caller. :type args: tuple :par...
Reconstruct an instance from a mapping. :type database: :class:`~google.cloud.spanner.database.Database` :param database: database to use :type mapping: mapping :param mapping: serialized state of the instance :rtype: :class:`BatchSnapshot` def from_dict(cls, database, mappin...
Return state as a dictionary. Result can be used to serialize the instance and reconstitute it later using :meth:`from_dict`. :rtype: dict def to_dict(self): """Return state as a dictionary. Result can be used to serialize the instance and reconstitute it later using ...
Create session as needed. .. note:: Caller is responsible for cleaning up the session after all partitions have been processed. def _get_session(self): """Create session as needed. .. note:: Caller is responsible for cleaning up the session after ...
Create snapshot if needed. def _get_snapshot(self): """Create snapshot if needed.""" if self._snapshot is None: self._snapshot = self._get_session().snapshot( read_timestamp=self._read_timestamp, exact_staleness=self._exact_staleness, multi_us...
Start a partitioned batch read operation. Uses the ``PartitionRead`` API request to initiate the partitioned read. Returns a list of batch information needed to perform the actual reads. :type table: str :param table: name of the table from which to fetch data :type c...
Process a single, partitioned read. :type batch: mapping :param batch: one of the mappings returned from an earlier call to :meth:`generate_read_batches`. :rtype: :class:`~google.cloud.spanner_v1.streamed.StreamedResultSet` :returns: a result set instance which ...
Start a partitioned query operation. Uses the ``PartitionQuery`` API request to start a partitioned query operation. Returns a list of batch information needed to peform the actual queries. :type sql: str :param sql: SQL query statement :type params: dict, {str -> col...
Process a single, partitioned query or read. :type batch: mapping :param batch: one of the mappings returned from an earlier call to :meth:`generate_query_batches`. :rtype: :class:`~google.cloud.spanner_v1.streamed.StreamedResultSet` :returns: a result set insta...
Return a fully-qualified location string. def location_path(cls, project, location): """Return a fully-qualified location string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}", project=project, location=location, )
Return a fully-qualified model string. def model_path(cls, project, location, model): """Return a fully-qualified model string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/models/{model}", project=project, location=locatio...
Return a fully-qualified model_evaluation string. def model_evaluation_path(cls, project, location, model, model_evaluation): """Return a fully-qualified model_evaluation string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/models/{model}/modelEva...
Return a fully-qualified annotation_spec string. def annotation_spec_path(cls, project, location, dataset, annotation_spec): """Return a fully-qualified annotation_spec string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/datasets/{dataset}/annota...
Return a fully-qualified table_spec string. def table_spec_path(cls, project, location, dataset, table_spec): """Return a fully-qualified table_spec string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/datasets/{dataset}/tableSpecs/{table_spec}", ...
Return a fully-qualified column_spec string. def column_spec_path(cls, project, location, dataset, table_spec, column_spec): """Return a fully-qualified column_spec string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/datasets/{dataset}/tableSpecs...
Creates a dataset. Example: >>> from google.cloud import automl_v1beta1 >>> >>> client = automl_v1beta1.AutoMlClient() >>> >>> parent = client.location_path('[PROJECT]', '[LOCATION]') >>> >>> # TODO: Initialize `dataset`: ...
Deletes a dataset and all of its contents. Returns empty response in the ``response`` field when it completes, and ``delete_details`` in the ``metadata`` field. Example: >>> from google.cloud import automl_v1beta1 >>> >>> client = automl_v1beta1.AutoMlClient(...
Creates a model. Returns a Model in the ``response`` field when it completes. When you create a model, several model evaluations are created for it: a global evaluation, and one evaluation for each annotation spec. Example: >>> from google.cloud import automl_v1beta1 ...
Generates sleep intervals based on the exponential back-off algorithm. This implements the `Truncated Exponential Back-off`_ algorithm. .. _Truncated Exponential Back-off: https://cloud.google.com/storage/docs/exponential-backoff Args: initial (float): The minimum about of time to delay. ...
Call a function and retry if it fails. This is the lowest-level retry helper. Generally, you'll use the higher-level retry helper :class:`Retry`. Args: target(Callable): The function to call and retry. This must be a nullary function - apply arguments with `functools.partial`. ...
Opens the stream. def open(self): """Opens the stream.""" if self.is_active: raise ValueError("Can not open an already open stream.") request_generator = _RequestQueueGenerator( self._request_queue, initial_request=self._initial_request ) call = self._st...
Closes the stream. def close(self): """Closes the stream.""" if self.call is None: return self._request_queue.put(None) self.call.cancel() self._request_generator = None
Queue a message to be sent on the stream. Send is non-blocking. If the underlying RPC has been closed, this will raise. Args: request (protobuf.Message): The request to send. def send(self, request): """Queue a message to be sent on the stream. Send is non-blocki...
Wraps a method to recover the stream and retry on error. If a retryable error occurs while making the call, then the stream will be re-opened and the method will be retried. This happens indefinitely so long as the error is a retryable one. If an error occurs while re-opening the stream...