INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Convert a scalar value into a query parameter.
def scalar_to_query_parameter(value, name=None): """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.Scala...
Converts a dictionary of parameter values into query parameters.
def to_query_parameters_dict(parameters): """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 que...
Converts DB - API parameter values into query parameters.
def to_query_parameters(parameters): """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 ...
Refresh an operation using a JSON/ HTTP client.
def _refresh_http(api_request, operation_name): """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 n...
Cancel an operation using a JSON/ HTTP client.
def _cancel_http(api_request, operation_name): """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 nam...
Create an operation future using a HTTP/ JSON client.
def from_http_json(operation, api_request, result_type, **kwargs): """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/\ ...
Refresh an operation using a gRPC client.
def _refresh_grpc(operations_stub, operation_name): """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.longrunn...
Cancel an operation using a gRPC client.
def _cancel_grpc(operations_stub, operation_name): """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. """ request_pb = operations_pb2...
Create an operation future using a gRPC client.
def from_grpc(operation, operations_stub, result_type, **kwargs): """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/\ 050400df0fdb...
Create an operation future from a gapic client.
def from_gapic(operation, operations_client, result_type, **kwargs): """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/\ ...
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.metadata )
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 # at the same time. with self._completion_lock: ...
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: self._operation = self._refresh() s...
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.
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: self.roles.remove(role)
Ensures predefined is in list of predefined json values
def validate_predefined(cls, predefined): """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: `ValueEr...
Build an _ACLEntity object from a dictionary of data.
def entity_from_dict(self, entity_dict): """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:...
Gets an entity object from the ACL.
def get_entity(self, entity, default=None): """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 ...
Add an entity to the 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_loaded() self.entities[str(entity)] = entity
Factory method for creating an Entity.
def entity(self, entity_type, identifier=None): """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 th...
Reload the ACL data from Cloud Storage.
def reload(self, client=None): """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. ...
Helper for: meth: save and: meth: save_predefined.
def _save(self, acl, predefined, client): """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 predef...
Save this ACL for the current bucket.
def save(self, acl=None, client=None): """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 s...
Save this ACL for the current bucket using a predefined ACL.
def save_predefined(self, predefined, client=None): """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 ...
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, incident=incident, ...
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, incident=incident, artifact=a...
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}", project=project, inciden...
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}", project=project, incident=incident, ...
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, tag=tag, )
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.
def create_annotation( self, parent, annotation, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Creates an annotation on an existing incident. Only 'text/plain' and 'text/ma...
Escalates an incident.
def escalate_incident( self, incident, update_mask=None, subscriptions=None, tags=None, roles=None, artifacts=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): ...
Sends a summary of the shift for oncall handoff.
def send_shift_handoff( self, parent, recipients, subject, cc=None, notes_content_type=None, notes_content=None, incidents=None, preview_only=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.meth...
Access to bigtable. admin role memebers
def bigtable_admins(self): """Access to bigtable.admin role memebers For example: .. literalinclude:: snippets.py :start-after: [START bigtable_admins_policy] :end-before: [END bigtable_admins_policy] """ result = set() for member in self._bindin...
Access to bigtable. reader role memebers
def bigtable_readers(self): """Access to bigtable.reader role memebers For example: .. literalinclude:: snippets.py :start-after: [START bigtable_readers_policy] :end-before: [END bigtable_readers_policy] """ result = set() for member in self._bi...
Access to bigtable. user role memebers
def bigtable_users(self): """Access to bigtable.user role memebers For example: .. literalinclude:: snippets.py :start-after: [START bigtable_users_policy] :end-before: [END bigtable_users_policy] """ result = set() for member in self._bindings.g...
Access to bigtable. viewer role memebers
def bigtable_viewers(self): """Access to bigtable.viewer role memebers For example: .. literalinclude:: snippets.py :start-after: [START bigtable_viewers_policy] :end-before: [END bigtable_viewers_policy] """ result = set() for member in self._bi...
Factory: create a policy from a protobuf message.
def from_pb(cls, policy_pb): """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 """ policy = cls(po...
Render a protobuf message.
def to_pb(self): """Render a protobuf message. Returns: google.iam.policy_pb2.Policy: a message to be passed to the ``set_iam_policy`` gRPC API. """ return policy_pb2.Policy( etag=self.etag, version=self.version or 0, bindings...
Factory: create a policy from a JSON resource.
def from_api_repr(cls, resource): """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: :cla...
Render a JSON policy resource.
def to_api_repr(self): """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. """ ...
Validate DDL Statements used to define database schema.
def _check_ddl_statements(value): """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 ...
Creates an instance of this class from a protobuf.
def from_pb(cls, database_pb, instance, pool=None): """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....
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 = credentials.with_scopes((SPANNER_DATA_SCOPE,...
Create this database within its instance
def create(self): """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 :rt...
Test whether this database exists.
def exists(self): """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. """ ...
Reload this database.
def reload(self): """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 data...
Update DDL for this database.
def update_ddl(self, ddl_statements, operation_id=""): """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.UpdateData...
Drop this database.
def drop(self): """Drop this database. See https://cloud.google.com/spanner/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase """ api = self._instance._client.database_admin_api metadata = _metadata_with_prefix(sel...
Execute a partitionable DML statement.
def execute_partitioned_dml(self, dml, params=None, param_types=None): """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 ...
Return an object which wraps a batch read/ query.
def batch_snapshot(self, read_timestamp=None, exact_staleness=None): """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...
Perform a unit of work in a transaction retrying on abort.
def run_in_transaction(self, func, *args, **kw): """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 ...
Reconstruct an instance from a mapping.
def from_dict(cls, database, mapping): """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:`B...
Return state as a dictionary.
def to_dict(self): """Return state as a dictionary. Result can be used to serialize the instance and reconstitute it later using :meth:`from_dict`. :rtype: dict """ session = self._get_session() snapshot = self._get_snapshot() return { "sessi...
Create session as needed.
def _get_session(self): """Create session as needed. .. note:: Caller is responsible for cleaning up the session after all partitions have been processed. """ if self._session is None: session = self._session = self._database.session() sess...
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_use=True, ) ...
Start a partitioned batch read operation.
def generate_read_batches( self, table, columns, keyset, index="", partition_size_bytes=None, max_partitions=None, ): """Start a partitioned batch read operation. Uses the ``PartitionRead`` API request to initiate the partitioned read....
Process a single partitioned read.
def process_read_batch(self, batch): """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...
Start a partitioned query operation.
def generate_query_batches( self, sql, params=None, param_types=None, partition_size_bytes=None, max_partitions=None, ): """Start a partitioned query operation. Uses the ``PartitionQuery`` API request to start a partitioned query operation. R...
Process a single partitioned query or read.
def process(self, batch): """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`...
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=location, model=model, )
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}/modelEvaluations/{model_evaluation}", project=p...
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}/annotationSpecs/{annotation_spec}", project=...
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}", project=project, loca...
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/{table_spec}/columnSpecs/{column_spec}", ...
Creates a dataset.
def create_dataset( self, parent, dataset, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Creates a dataset. Example: >>> from google.cloud import automl_v1beta...
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.
def delete_dataset( self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Deletes a dataset and all of its contents. Returns empty response in the ``response`` field when it co...
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.
def create_model( self, parent, model, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Creates a model. Returns a Model in the ``response`` field when it completes. When you ...
Generates sleep intervals based on the exponential back - off algorithm.
def exponential_sleep_generator(initial, maximum, multiplier=_DEFAULT_DELAY_MULTIPLIER): """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/d...
Call a function and retry if it fails.
def retry_target(target, predicate, sleep_generator, deadline, on_error=None): """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 ...
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._start_rpc(iter(reques...
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.
def send(self, request): """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. """ if self.call is None: raise ValueError...
Wraps a method to recover the stream and retry on error.
def _recoverable(self, method, *args, **kwargs): """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...
Start the background thread and begin consuming the thread.
def start(self): """Start the background thread and begin consuming the thread.""" with self._operational_lock: ready = threading.Event() thread = threading.Thread( name=_BIDIRECTIONAL_CONSUMER_NAME, target=self._thread_main, args=(...
Stop consuming the stream and shutdown the background thread.
def stop(self): """Stop consuming the stream and shutdown the background thread.""" with self._operational_lock: self._bidi_rpc.close() if self._thread is not None: # Resume the thread to wake it up in case it is sleeping. self.resume() ...
Resumes the response stream.
def resume(self): """Resumes the response stream.""" with self._wake: self._paused = False self._wake.notifyAll()
Return a fully - qualified project string.
def project_path(cls, user, project): """Return a fully-qualified project string.""" return google.api_core.path_template.expand( "users/{user}/projects/{project}", user=user, project=project )
Return a fully - qualified fingerprint string.
def fingerprint_path(cls, user, fingerprint): """Return a fully-qualified fingerprint string.""" return google.api_core.path_template.expand( "users/{user}/sshPublicKeys/{fingerprint}", user=user, fingerprint=fingerprint, )
Deletes a POSIX account.
def delete_posix_account( self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Deletes a POSIX account. Example: >>> from google.cloud import oslogin_v1 ...
Adds an SSH public key and returns the profile information. Default POSIX account information is set when no username and UID exist as part of the login profile.
def import_ssh_public_key( self, parent, ssh_public_key, project_id=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Adds an SSH public key and returns the profile infor...
Updates an SSH public key and returns the profile information. This method supports patch semantics.
def update_ssh_public_key( self, name, ssh_public_key, update_mask=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Updates an SSH public key and returns the profile inf...
Convert a protobuf GC rule to a native object.
def _gc_rule_from_pb(gc_rule_pb): """Convert a protobuf GC rule to a native object. :type gc_rule_pb: :class:`.table_v2_pb2.GcRule` :param gc_rule_pb: The GC rule to convert. :rtype: :class:`GarbageCollectionRule` or :data:`NoneType <types.NoneType>` :returns: An instance of one of the native rule...
Converts the garbage collection rule to a protobuf.
def to_pb(self): """Converts the garbage collection rule to a protobuf. :rtype: :class:`.table_v2_pb2.GcRule` :returns: The converted current object. """ max_age = _helpers._timedelta_to_duration_pb(self.max_age) return table_v2_pb2.GcRule(max_age=max_age)
Converts the union into a single GC rule as a protobuf.
def to_pb(self): """Converts the union into a single GC rule as a protobuf. :rtype: :class:`.table_v2_pb2.GcRule` :returns: The converted current object. """ union = table_v2_pb2.GcRule.Union(rules=[rule.to_pb() for rule in self.rules]) return table_v2_pb2.GcRule(union=u...
Converts the intersection into a single GC rule as a protobuf.
def to_pb(self): """Converts the intersection into a single GC rule as a protobuf. :rtype: :class:`.table_v2_pb2.GcRule` :returns: The converted current object. """ intersection = table_v2_pb2.GcRule.Intersection( rules=[rule.to_pb() for rule in self.rules] )...
Converts the column family to a protobuf.
def to_pb(self): """Converts the column family to a protobuf. :rtype: :class:`.table_v2_pb2.ColumnFamily` :returns: The converted current object. """ if self.gc_rule is None: return table_v2_pb2.ColumnFamily() else: return table_v2_pb2.ColumnFamil...
Create this column family.
def create(self): """Create this column family. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_create_column_family] :end-before: [END bigtable_create_column_family] """ column_family = self.to_pb() modification...
Delete this column family.
def delete(self): """Delete this column family. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_delete_column_family] :end-before: [END bigtable_delete_column_family] """ modification = table_admin_v2_pb2.ModifyColumnFam...
Wraps a gRPC exception class if needed.
def _maybe_wrap_exception(exception): """Wraps a gRPC exception class, if needed.""" if isinstance(exception, grpc.RpcError): return exceptions.from_grpc_error(exception) return exception
Stop consuming messages and shutdown all helper threads.
def close(self, reason=None): """Stop consuming messages and shutdown all helper threads. This method is idempotent. Additional calls will have no effect. Args: reason (Any): The reason to close this. If None, this is considered an "intentional" shutdown. ""...
Triggered whenever the underlying RPC terminates without recovery.
def _on_rpc_done(self, future): """Triggered whenever the underlying RPC terminates without recovery. This is typically triggered from one of two threads: the background consumer thread (when calling ``recv()`` produces a non-recoverable error) or the grpc management thread (when cancel...
Creates a watch snapshot listener for a document. snapshot_callback receives a DocumentChange object but may also start to get targetChange and such soon
def for_document( cls, document_ref, snapshot_callback, snapshot_class_instance, reference_class_instance, ): """ Creates a watch snapshot listener for a document. snapshot_callback receives a DocumentChange object, but may also start to get ta...
Called everytime there is a response from listen. Collect changes and push the changes in a batch to the customer when we receive current from the listen response.
def on_snapshot(self, proto): """ Called everytime there is a response from listen. Collect changes and 'push' the changes in a batch to the customer when we receive 'current' from the listen response. Args: listen_response(`google.cloud.firestore_v1beta1.types.Liste...
Assembles a new snapshot from the current set of changes and invokes the user s callback. Clears the current changes on completion.
def push(self, read_time, next_resume_token): """ Assembles a new snapshot from the current set of changes and invokes the user's callback. Clears the current changes on completion. """ deletes, adds, updates = Watch._extract_changes( self.doc_map, self.change_map, re...
Returns the current count of all documents including the changes from the current changeMap.
def _current_size(self): """ Returns the current count of all documents, including the changes from the current changeMap. """ deletes, adds, _ = Watch._extract_changes(self.doc_map, self.change_map, None) return len(self.doc_map) + len(adds) - len(deletes)
Helper to clear the docs on RESET or filter mismatch.
def _reset_docs(self): """ Helper to clear the docs on RESET or filter mismatch. """ _LOGGER.debug("resetting documents") self.change_map.clear() self.resume_token = None # Mark each document as deleted. If documents are not deleted # they will be sent ag...
Construct an API url given a few components some optional.
def build_api_url( cls, path, query_params=None, api_base_url=None, api_version=None ): """Construct an API url given a few components, some optional. Typically, you shouldn't need to use this method. :type path: str :param path: The path to the resource (ie, ``'/b/bucket-n...