INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Gets the resource representation for a cluster in a project.
def get_cluster( self, project_id, region, cluster_name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Gets the resource representation for a cluster in a project. ...
Lists all regions/ { region }/ clusters in a project.
def list_clusters( self, project_id, region, filter_=None, page_size=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Lists all regions/{region}/clusters in a pr...
Gets cluster diagnostic information. After the operation completes the Operation. response field contains DiagnoseClusterOutputLocation.
def diagnose_cluster( self, project_id, region, cluster_name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Gets cluster diagnostic information. After the operation complet...
Actually publish all of the messages on the active batch.
def commit(self): """Actually publish all of the messages on the active batch. .. note:: This method is non-blocking. It opens a new thread, which calls :meth:`_commit`, which does block. This synchronously sets the batch status to "starting", and then opens a ...
Actually publish all of the messages on the active batch.
def _commit(self): """Actually publish all of the messages on the active batch. This moves the batch out from being the active batch to an in progress batch on the publisher, and then the batch is discarded upon completion. .. note:: This method blocks. The :meth:`...
Commit this batch after sufficient time has elapsed.
def monitor(self): """Commit this batch after sufficient time has elapsed. This simply sleeps for ``self._settings.max_latency`` seconds, and then calls commit unless the batch has already been committed. """ # NOTE: This blocks; it is up to the calling code to call it #...
Publish a single message.
def publish(self, message): """Publish a single message. Add the given message to this object; this will cause it to be published once the batch either has enough messages or a sufficient period of time has elapsed. This method is called by :meth:`~.PublisherClient.publish`. ...
Factory: construct a change set given its API representation
def from_api_repr(cls, resource, zone): """Factory: construct a change set given its API representation :type resource: dict :param resource: change set representation returned from the API. :type zone: :class:`google.cloud.dns.zone.ManagedZone` :param zone: A zone which holds...
Helper method for: meth: from_api_repr: meth: create etc.
def _set_properties(self, resource): """Helper method for :meth:`from_api_repr`, :meth:`create`, etc. :type resource: dict :param resource: change set representation returned from the API. """ resource = resource.copy() self._additions = tuple( [ ...
URL path for change set APIs.
def path(self): """URL path for change set APIs. :rtype: str :returns: the path based on project, zone, and change set names. """ return "/projects/%s/managedZones/%s/changes/%s" % ( self.zone.project, self.zone.name, self.name, )
Update name of the change set.
def name(self, value): """Update name of the change set. :type value: str :param value: New name for the changeset. """ if not isinstance(value, six.string_types): raise ValueError("Pass a string") self._properties["id"] = value
Append a record set to the additions for the change set.
def add_record_set(self, record_set): """Append a record set to the 'additions' for the change set. :type record_set: :class:`google.cloud.dns.resource_record_set.ResourceRecordSet` :param record_set: the record set to append. :raises: ``ValueError`` if ``record_set`` is no...
Append a record set to the deletions for the change set.
def delete_record_set(self, record_set): """Append a record set to the 'deletions' for the change set. :type record_set: :class:`google.cloud.dns.resource_record_set.ResourceRecordSet` :param record_set: the record set to append. :raises: ``ValueError`` if ``record_set`` is...
Generate a resource for create.
def _build_resource(self): """Generate a resource for ``create``.""" additions = [ { "name": added.name, "type": added.record_type, "ttl": str(added.ttl), "rrdatas": added.rrdatas, } for added in self.add...
API call: create the change set via a POST request.
def create(self, client=None): """API call: create the change set via a POST request. See https://cloud.google.com/dns/api/v1/changes/create :type client: :class:`google.cloud.dns.client.Client` :param client: (Optional) the client to use. If not passed, falls bac...
Helper for logging - related API calls.
def logging_api(self): """Helper for logging-related API calls. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.logs """ if self._logging_api is None: if self._use_grpc...
Helper for log sink - related API calls.
def sinks_api(self): """Helper for log sink-related API calls. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks """ if self._sinks_api is None: if self._use_grpc: self._sinks_api = _gapic.make_sinks_api(self) e...
Helper for log metric - related API calls.
def metrics_api(self): """Helper for log metric-related API calls. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics """ if self._metrics_api is None: if self._use_grpc: self._metrics_api = _gapic.make_metrics_api(self) ...
Return a page of log entries.
def list_entries( self, projects=None, filter_=None, order_by=None, page_size=None, page_token=None, ): """Return a page of log entries. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list :type projects: list ...
Creates a sink bound to the current client.
def sink(self, name, filter_=None, destination=None): """Creates a sink bound to the current client. :type name: str :param name: the name of the sink to be constructed. :type filter_: str :param filter_: (optional) the advanced logs filter expression de...
List sinks for the project associated with this client.
def list_sinks(self, page_size=None, page_token=None): """List sinks for the project associated with this client. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/list :type page_size: int :param page_size: Optional. The maximum number o...
Creates a metric bound to the current client.
def metric(self, name, filter_=None, description=""): """Creates a metric bound to the current client. :type name: str :param name: the name of the metric to be constructed. :type filter_: str :param filter_: the advanced logs filter expression defining the ...
List metrics for the project associated with this client.
def list_metrics(self, page_size=None, page_token=None): """List metrics for the project associated with this client. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/list :type page_size: int :param page_size: Optional. The maximum nu...
Return the default logging handler based on the local environment.
def get_default_handler(self, **kw): """Return the default logging handler based on the local environment. :type kw: dict :param kw: keyword args passed to handler constructor :rtype: :class:`logging.Handler` :returns: The default log handler based on the environment ""...
Attach default Stackdriver logging handler to the root logger.
def setup_logging( self, log_level=logging.INFO, excluded_loggers=EXCLUDED_LOGGER_DEFAULTS, **kw ): """Attach default Stackdriver logging handler to the root logger. This method uses the default log handler, obtained by :meth:`~get_default_handler`, and attaches it to the root Pytho...
Return a fully - qualified key_ring string.
def key_ring_path(cls, project, location, key_ring): """Return a fully-qualified key_ring string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/keyRings/{key_ring}", project=project, location=location, key_ring=ke...
Return a fully - qualified crypto_key_path string.
def crypto_key_path_path(cls, project, location, key_ring, crypto_key_path): """Return a fully-qualified crypto_key_path string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key_path=**}", project=...
Return a fully - qualified crypto_key_version string.
def crypto_key_version_path( cls, project, location, key_ring, crypto_key, crypto_key_version ): """Return a fully-qualified crypto_key_version string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_...
Create a new KeyRing in a given Project and Location.
def create_key_ring( self, parent, key_ring_id, key_ring, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Create a new ``KeyRing`` in a given Project and Location. E...
Create a new CryptoKey within a KeyRing.
def create_crypto_key( self, parent, crypto_key_id, crypto_key, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Create a new ``CryptoKey`` within a ``KeyRing``. ``Cr...
Return a fully - qualified span string.
def span_path(cls, project, trace, span): """Return a fully-qualified span string.""" return google.api_core.path_template.expand( "projects/{project}/traces/{trace}/spans/{span}", project=project, trace=trace, span=span, )
Sends new spans to new or existing traces. You cannot update existing spans.
def batch_write_spans( self, name, spans, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Sends new spans to new or existing traces. You cannot update existing spans. ...
Creates a new span.
def create_span( self, name, span_id, display_name, start_time, end_time, parent_span_id=None, attributes=None, stack_trace=None, time_events=None, links=None, status=None, same_process_as_parent_span=None, c...
Wraps a user callback so that if an exception occurs the message is nacked.
def _wrap_callback_errors(callback, message): """Wraps a user callback so that if an exception occurs the message is nacked. Args: callback (Callable[None, Message]): The user callback. message (~Message): The Pub/Sub message. """ try: callback(message) except Exception:...
Return the current ack deadline based on historical time - to - ack.
def ack_deadline(self): """Return the current ack deadline based on historical time-to-ack. This method is "sticky". It will only perform the computations to check on the right ack deadline if the histogram has gained a significant amount of new information. Returns: ...
Return the current load.
def load(self): """Return the current load. The load is represented as a float, where 1.0 represents having hit one of the flow control limits, and values between 0.0 and 1.0 represent how close we are to them. (0.5 means we have exactly half of what the flow control setting all...
Check the current load and pause the consumer if needed.
def maybe_pause_consumer(self): """Check the current load and pause the consumer if needed.""" if self.load >= 1.0: if self._consumer is not None and not self._consumer.is_paused: _LOGGER.debug("Message backlog over load at %.2f, pausing.", self.load) self._co...
Check the current load and resume the consumer if needed.
def maybe_resume_consumer(self): """Check the current load and resume the consumer if needed.""" # If we have been paused by flow control, check and see if we are # back within our limits. # # In order to not thrash too much, require us to have passed below # the resume t...
Send a request using a separate unary request instead of over the stream.
def _send_unary_request(self, request): """Send a request using a separate unary request instead of over the stream. Args: request (types.StreamingPullRequest): The stream request to be mapped into unary requests. """ if request.ack_ids: s...
Queue a request to be sent to the RPC.
def send(self, request): """Queue a request to be sent to the RPC.""" if self._UNARY_REQUESTS: try: self._send_unary_request(request) except exceptions.GoogleAPICallError: _LOGGER.debug( "Exception while sending unary RPC. This ...
Sends an empty request over the streaming pull RPC.
def heartbeat(self): """Sends an empty request over the streaming pull RPC. This always sends over the stream, regardless of if ``self._UNARY_REQUESTS`` is set or not. """ if self._rpc is not None and self._rpc.is_active: self._rpc.send(types.StreamingPullRequest())
Begin consuming messages.
def open(self, callback): """Begin consuming messages. Args: callback (Callable[None, google.cloud.pubsub_v1.message.Messages]): A callback that will be called for each message received on the stream. """ if self.is_active: raise V...
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. This is pa...
Return the initial request for the RPC.
def _get_initial_request(self): """Return the initial request for the RPC. This defines the initial request that must always be sent to Pub/Sub immediately upon opening the subscription. Returns: google.cloud.pubsub_v1.types.StreamingPullRequest: A request suita...
Process all received Pub/ Sub messages.
def _on_response(self, response): """Process all received Pub/Sub messages. For each message, send a modified acknowledgment request to the server. This prevents expiration of the message due to buffering by gRPC or proxy/firewall. This makes the server and client expiration tim...
Determine if an error on the RPC stream should be recovered.
def _should_recover(self, exception): """Determine if an error on the RPC stream should be recovered. If the exception is one of the retryable exceptions, this will signal to the consumer thread that it should "recover" from the failure. This will cause the stream to exit when it retur...
Add a change to this batch to create a document.
def create(self, reference, document_data): """Add a "change" to this batch to create a document. If the document given by ``reference`` already exists, then this batch will fail when :meth:`commit`-ed. Args: reference (~.firestore_v1beta1.document.DocumentReference): A ...
Add a change to replace a document.
def set(self, reference, document_data, merge=False): """Add a "change" to replace a document. See :meth:`~.firestore_v1beta1.document.DocumentReference.set` for more information on how ``option`` determines how the change is applied. Args: reference (~.fire...
Add a change to update a document.
def update(self, reference, field_updates, option=None): """Add a "change" to update a document. See :meth:`~.firestore_v1beta1.document.DocumentReference.update` for more information on ``field_updates`` and ``option``. Args: reference (~.firestore_v1beta1.document...
Add a change to delete a document.
def delete(self, reference, option=None): """Add a "change" to delete a document. See :meth:`~.firestore_v1beta1.document.DocumentReference.delete` for more information on how ``option`` determines how the change is applied. Args: reference (~.firestore_v1be...
Commit the changes accumulated in this batch.
def commit(self): """Commit the changes accumulated in this batch. Returns: List[google.cloud.proto.firestore.v1beta1.\ write_pb2.WriteResult, ...]: The write results corresponding to the changes committed, returned in the same order as the changes we...
Ensures an input is a tuple or list.
def _ensure_tuple_or_list(arg_name, tuple_or_list): """Ensures an input is a tuple or list. This effectively reduces the iterable types allowed to a very short whitelist: list and tuple. :type arg_name: str :param arg_name: Name of argument to use in error message. :type tuple_or_list: sequen...
Convert non - none datetime to microseconds.
def _microseconds_from_datetime(value): """Convert non-none datetime to microseconds. :type value: :class:`datetime.datetime` :param value: The timestamp to convert. :rtype: int :returns: The timestamp, in microseconds. """ if not value.tzinfo: value = value.replace(tzinfo=UTC) ...
Convert a zoneless ISO8601 time string to naive datetime time
def _time_from_iso8601_time_naive(value): """Convert a zoneless ISO8601 time string to naive datetime time :type value: str :param value: The time string to convert :rtype: :class:`datetime.time` :returns: A datetime time object created from the string :raises ValueError: if the value does not...
Convert a microsecond - precision timestamp to a native datetime.
def _rfc3339_to_datetime(dt_str): """Convert a microsecond-precision timestamp to a native datetime. :type dt_str: str :param dt_str: The string to convert. :rtype: :class:`datetime.datetime` :returns: The datetime object created from the string. """ return datetime.datetime.strptime(dt_st...
Convert a nanosecond - precision timestamp to a native datetime.
def _rfc3339_nanos_to_datetime(dt_str): """Convert a nanosecond-precision timestamp to a native datetime. .. note:: Python datetimes do not support nanosecond precision; this function therefore truncates such values to microseconds. :type dt_str: str :param dt_str: The string to conver...
Convert a timestamp to a string.
def _datetime_to_rfc3339(value, ignore_zone=True): """Convert a timestamp to a string. :type value: :class:`datetime.datetime` :param value: The datetime object to be converted to a string. :type ignore_zone: bool :param ignore_zone: If True, then the timezone (if any) of the datetime ...
Converts a string value to bytes if necessary.
def _to_bytes(value, encoding="ascii"): """Converts a string value to bytes, if necessary. Unfortunately, ``six.b`` is insufficient for this task since in Python2 it does not modify ``unicode`` objects. :type value: str / bytes or unicode :param value: The string/bytes value to be converted. ...
Converts bytes to a unicode value if necessary.
def _bytes_to_unicode(value): """Converts bytes to a unicode value, if necessary. :type value: bytes :param value: bytes value to attempt string conversion on. :rtype: str :returns: The original value converted to unicode (if bytes) or as passed in if it started out as unicode. ...
Converts an Any protobuf to the specified message type
def _from_any_pb(pb_type, any_pb): """Converts an Any protobuf to the specified message type Args: pb_type (type): the type of the message that any_pb stores an instance of. any_pb (google.protobuf.any_pb2.Any): the object to be converted. Returns: pb_type: An instance ...
Convert a Timestamp protobuf to a datetime object.
def _pb_timestamp_to_datetime(timestamp_pb): """Convert a Timestamp protobuf to a datetime object. :type timestamp_pb: :class:`google.protobuf.timestamp_pb2.Timestamp` :param timestamp_pb: A Google returned timestamp protobuf. :rtype: :class:`datetime.datetime` :returns: A UTC datetime object conv...
Convert a datetime object to a Timestamp protobuf.
def _datetime_to_pb_timestamp(when): """Convert a datetime object to a Timestamp protobuf. :type when: :class:`datetime.datetime` :param when: the datetime to convert :rtype: :class:`google.protobuf.timestamp_pb2.Timestamp` :returns: A timestamp protobuf corresponding to the object. """ ms...
Convert a duration protobuf to a Python timedelta object.
def _duration_pb_to_timedelta(duration_pb): """Convert a duration protobuf to a Python timedelta object. .. note:: The Python timedelta has a granularity of microseconds while the protobuf duration type has a duration of nanoseconds. :type duration_pb: :class:`google.protobuf.duration_pb2...
Validate a URI path and get the leaf object s name.
def _name_from_project_path(path, project, template): """Validate a URI path and get the leaf object's name. :type path: str :param path: URI path containing the name. :type project: str :param project: (Optional) The project associated with the request. It is included for vali...
Makes a secure channel for an RPC service.
def make_secure_channel(credentials, user_agent, host, extra_options=()): """Makes a secure channel for an RPC service. Uses / depends on gRPC. :type credentials: :class:`google.auth.credentials.Credentials` :param credentials: The OAuth2 Credentials to use for creating access ...
Makes a secure stub for an RPC service.
def make_secure_stub(credentials, user_agent, stub_class, host, extra_options=()): """Makes a secure stub for an RPC service. Uses / depends on gRPC. :type credentials: :class:`google.auth.credentials.Credentials` :param credentials: The OAuth2 Credentials to use for creating a...
Makes an insecure stub for an RPC service.
def make_insecure_stub(stub_class, host, port=None): """Makes an insecure stub for an RPC service. Uses / depends on gRPC. :type stub_class: type :param stub_class: A gRPC stub type for a given service. :type host: str :param host: The host for the service. May also include the port ...
Convert a timestamp from ( naive ) UTC to this timezone.
def fromutc(self, dt): """Convert a timestamp from (naive) UTC to this timezone.""" if dt.tzinfo is None: return dt.replace(tzinfo=self) return super(_UTC, self).fromutc(dt)
Custom decorator intended for: class: ~vision. helpers. VisionHelpers.
def add_single_feature_methods(cls): """Custom decorator intended for :class:`~vision.helpers.VisionHelpers`. This metaclass adds a `{feature}` method for every feature defined on the Feature enum. """ # Sanity check: This only makes sense if we are building the GAPIC # subclass and have enums ...
Return a function that will detect a single feature.
def _create_single_feature_method(feature): """Return a function that will detect a single feature. Args: feature (enum): A specific feature defined as a member of :class:`~enums.Feature.Type`. Returns: function: A helper function to detect just that feature. """ # Defi...
Schedule the callback to be called asynchronously in a thread pool.
def schedule(self, callback, *args, **kwargs): """Schedule the callback to be called asynchronously in a thread pool. Args: callback (Callable): The function to call. args: Positional arguments passed to the function. kwargs: Key-word arguments passed to the function...
Shuts down the scheduler and immediately end all pending callbacks.
def shutdown(self): """Shuts down the scheduler and immediately end all pending callbacks. """ # Drop all pending item from the executor. Without this, the executor # will block until all pending items are complete, which is # undesirable. try: while True: ...
Lists the specified events.
def list_events( self, project_name, group_id, service_filter=None, time_range=None, page_size=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Lists the...
Deletes all error events of a given project.
def delete_events( self, project_name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Deletes all error events of a given project. Example: >>> from google.cloud import...
Convert Document resource to document ref.
def _item_to_document_ref(iterator, item): """Convert Document resource to document ref. Args: iterator (google.api_core.page_iterator.GRPCIterator): iterator response item (dict): document resource """ document_id = item.name.split(_helpers.DOCUMENT_PATH_DELIMITER)[-1] ...
Document that owns the current collection.
def parent(self): """Document that owns the current collection. Returns: Optional[~.firestore_v1beta1.document.DocumentReference]: The parent document, if the current collection is not a top-level collection. """ if len(self._path) == 1: r...
Create a sub - document underneath the current collection.
def document(self, document_id=None): """Create a sub-document underneath the current collection. Args: document_id (Optional[str]): The document identifier within the current collection. If not provided, will default to a random 20 character string composed ...
Get fully - qualified parent path and prefix for this collection.
def _parent_info(self): """Get fully-qualified parent path and prefix for this collection. Returns: Tuple[str, str]: Pair of * the fully-qualified (with database and project) path to the parent of this collection (will either be the database path or ...
Create a document in the Firestore database with the provided data.
def add(self, document_data, document_id=None): """Create a document in the Firestore database with the provided data. Args: document_data (dict): Property names and values to use for creating the document. document_id (Optional[str]): The document identifier wit...
List all subdocuments of the current collection.
def list_documents(self, page_size=None): """List all subdocuments of the current collection. Args: page_size (Optional[int]]): The maximum number of documents in each page of results from this request. Non-positive values are ignored. Defaults to a sensible value se...
Create a select query with this collection as parent.
def select(self, field_paths): """Create a "select" query with this collection as parent. See :meth:`~.firestore_v1beta1.query.Query.select` for more information on this method. Args: field_paths (Iterable[str, ...]): An iterable of field paths (``.`...
Create a where query with this collection as parent.
def where(self, field_path, op_string, value): """Create a "where" query with this collection as parent. See :meth:`~.firestore_v1beta1.query.Query.where` for more information on this method. Args: field_path (str): A field path (``.``-delimited list of ...
Create an order by query with this collection as parent.
def order_by(self, field_path, **kwargs): """Create an "order by" query with this collection as parent. See :meth:`~.firestore_v1beta1.query.Query.order_by` for more information on this method. Args: field_path (str): A field path (``.``-delimited list of ...
Create a limited query with this collection as parent.
def limit(self, count): """Create a limited query with this collection as parent. See :meth:`~.firestore_v1beta1.query.Query.limit` for more information on this method. Args: count (int): Maximum number of documents to return that match the query. ...
Skip to an offset in a query with this collection as parent.
def offset(self, num_to_skip): """Skip to an offset in a query with this collection as parent. See :meth:`~.firestore_v1beta1.query.Query.offset` for more information on this method. Args: num_to_skip (int): The number of results to skip at the beginning ...
Start query at a cursor with this collection as parent.
def start_at(self, document_fields): """Start query at a cursor with this collection as parent. See :meth:`~.firestore_v1beta1.query.Query.start_at` for more information on this method. Args: document_fields (Union[~.firestore_v1beta1.\ document.Docu...
Start query after a cursor with this collection as parent.
def start_after(self, document_fields): """Start query after a cursor with this collection as parent. See :meth:`~.firestore_v1beta1.query.Query.start_after` for more information on this method. Args: document_fields (Union[~.firestore_v1beta1.\ docu...
End query before a cursor with this collection as parent.
def end_before(self, document_fields): """End query before a cursor with this collection as parent. See :meth:`~.firestore_v1beta1.query.Query.end_before` for more information on this method. Args: document_fields (Union[~.firestore_v1beta1.\ documen...
End query at a cursor with this collection as parent.
def end_at(self, document_fields): """End query at a cursor with this collection as parent. See :meth:`~.firestore_v1beta1.query.Query.end_at` for more information on this method. Args: document_fields (Union[~.firestore_v1beta1.\ document.DocumentSn...
Read the documents in this collection.
def stream(self, transaction=None): """Read the documents in this collection. This sends a ``RunQuery`` RPC and then returns an iterator which consumes each document returned in the stream of ``RunQueryResponse`` messages. .. note:: The underlying stream of response...
Get list of supported languages for translation.
def get_languages(self, target_language=None): """Get list of supported languages for translation. Response See https://cloud.google.com/translate/docs/discovering-supported-languages :type target_language: str :param target_language: (Optional) The language used to lo...
Detect the language of a string or list of strings.
def detect_language(self, values): """Detect the language of a string or list of strings. See https://cloud.google.com/translate/docs/detecting-language :type values: str or list :param values: String or list of strings that will have language detected. ...
Translate a string or list of strings.
def translate( self, values, target_language=None, format_=None, source_language=None, customization_ids=(), model=None, ): """Translate a string or list of strings. See https://cloud.google.com/translate/docs/translating-text :type v...
Add messages to be managed by the leaser.
def add(self, items): """Add messages to be managed by the leaser.""" for item in items: # Add the ack ID to the set of managed ack IDs, and increment # the size counter. if item.ack_id not in self._leased_messages: self._leased_messages[item.ack_id] =...
Remove messages from lease management.
def remove(self, items): """Remove messages from lease management.""" # Remove the ack ID from lease management, and decrement the # byte counter. for item in items: if self._leased_messages.pop(item.ack_id, None) is not None: self._bytes -= item.byte_size ...
Maintain all of the leases being managed.
def maintain_leases(self): """Maintain all of the leases being managed. This method modifies the ack deadline for all of the managed ack IDs, then waits for most of that time (but with jitter), and repeats. """ while self._manager.is_active and not self._stop_event.is_se...
Create an instance of the gapic Logging API.
def make_report_error_api(client): """Create an instance of the gapic Logging API. :type client::class:`google.cloud.error_reporting.Client` :param client: Error Reporting client. :rtype: :class:_ErrorReportingGapicApi :returns: An Error Reporting API instance. """ gax_client = report_erro...
Uses the gapic client to report the error.
def report_error_event(self, error_report): """Uses the gapic client to report the error. :type error_report: dict :param error_report: payload of the error report formatted according to https://cloud.google.com/error-reporting/docs/formatting-error-messages ...
Return a fully - qualified table string.
def table_path(cls, project, instance, table): """Return a fully-qualified table string.""" return google.api_core.path_template.expand( "projects/{project}/instances/{instance}/tables/{table}", project=project, instance=instance, table=table, )
Streams back the contents of all requested rows in key order optionally applying the same Reader filter to each. Depending on their size rows and cells may be broken up across multiple responses but atomicity of each row will still be preserved. See the ReadRowsResponse documentation for details.
def read_rows( self, table_name, app_profile_id=None, rows=None, filter_=None, rows_limit=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Streams back t...