text
stringlengths
81
112k
Set a value into a document for a field_path def set_field_value(document_data, field_path, value): """Set a value into a document for a field_path""" current = document_data for element in field_path.parts[:-1]: current = current.setdefault(element, {}) if value is _EmptyDict: value = ...
Make ``Write`` protobufs for ``create()`` methods. Args: document_path (str): A fully-qualified document path. document_data (dict): Property names and values to use for creating a document. Returns: List[google.cloud.firestore_v1beta1.types.Write]: One or two ``Wri...
Make ``Write`` protobufs for ``set()`` methods. Args: document_path (str): A fully-qualified document path. document_data (dict): Property names and values to use for replacing a document. Returns: List[google.cloud.firestore_v1beta1.types.Write]: One or two ``Write...
Make ``Write`` protobufs for ``set()`` methods. Args: document_path (str): A fully-qualified document path. document_data (dict): Property names and values to use for replacing a document. merge (Optional[bool] or Optional[List<apispec>]): If True, merge all fields; ...
Make ``Write`` protobufs for ``update()`` methods. Args: document_path (str): A fully-qualified document path. field_updates (dict): Field names or paths to update and values to update with. option (optional[~.firestore_v1beta1.client.WriteOption]): A write option to ...
Make a ``Write`` protobuf for ``delete()`` methods. Args: document_path (str): A fully-qualified document path. option (optional[~.firestore_v1beta1.client.WriteOption]): A write option to make assertions / preconditions on the server state of the document before applying chan...
Get the transaction ID from a ``Transaction`` object. Args: transaction (Optional[~.firestore_v1beta1.transaction.\ Transaction]): An existing transaction that this query will run in. read_operation (Optional[bool]): Indicates if the transaction ID will be used i...
Modify a ``Write`` protobuf based on the state of this write option. The ``last_update_time`` is added to ``write_pb`` as an "update time" precondition. When set, the target document must exist and have been last updated at that time. Args: write_pb (google.cloud.firestore_...
Modify a ``Write`` protobuf based on the state of this write option. If: * ``exists=True``, adds a precondition that requires existence * ``exists=False``, adds a precondition that requires non-existence Args: write_pb (google.cloud.firestore_v1beta1.types.Write): A ...
Return a fully-qualified uptime_check_config string. def uptime_check_config_path(cls, project, uptime_check_config): """Return a fully-qualified uptime_check_config string.""" return google.api_core.path_template.expand( "projects/{project}/uptimeCheckConfigs/{uptime_check_config}", ...
Creates a new uptime check configuration. Example: >>> from google.cloud import monitoring_v3 >>> >>> client = monitoring_v3.UptimeCheckServiceClient() >>> >>> parent = client.project_path('[PROJECT]') >>> >>> # TODO: Initializ...
Performs asynchronous video annotation. Progress and results can be retrieved through the ``google.longrunning.Operations`` interface. ``Operation.metadata`` contains ``AnnotateVideoProgress`` (progress). ``Operation.response`` contains ``AnnotateVideoResponse`` (results). Example: ...
Legacy access to owner role. DEPRECATED: use ``policy["roles/owners"]`` instead. def owners(self): """Legacy access to owner role. DEPRECATED: use ``policy["roles/owners"]`` instead.""" result = set() for role in self._OWNER_ROLES: for member in self._bindings.ge...
Update owners. DEPRECATED: use ``policy["roles/owners"] = value`` instead. def owners(self, value): """Update owners. DEPRECATED: use ``policy["roles/owners"] = value`` instead.""" warnings.warn( _ASSIGNMENT_DEPRECATED_MSG.format("owners", OWNER_ROLE), DeprecationWarning...
Legacy access to editor role. DEPRECATED: use ``policy["roles/editors"]`` instead. def editors(self): """Legacy access to editor role. DEPRECATED: use ``policy["roles/editors"]`` instead.""" result = set() for role in self._EDITOR_ROLES: for member in self._bindi...
Update editors. DEPRECATED: use ``policy["roles/editors"] = value`` instead. def editors(self, value): """Update editors. DEPRECATED: use ``policy["roles/editors"] = value`` instead.""" warnings.warn( _ASSIGNMENT_DEPRECATED_MSG.format("editors", EDITOR_ROLE), ...
Legacy access to viewer role. DEPRECATED: use ``policy["roles/viewers"]`` instead def viewers(self): """Legacy access to viewer role. DEPRECATED: use ``policy["roles/viewers"]`` instead """ result = set() for role in self._VIEWER_ROLES: for member in self...
Update viewers. DEPRECATED: use ``policy["roles/viewers"] = value`` instead. def viewers(self, value): """Update viewers. DEPRECATED: use ``policy["roles/viewers"] = value`` instead. """ warnings.warn( _ASSIGNMENT_DEPRECATED_MSG.format("viewers", VIEWER_ROLE), ...
Factory: create a policy from a JSON resource. Args: resource (dict): policy resource returned by ``getIamPolicy`` API. Returns: :class:`Policy`: the parsed policy def from_api_repr(cls, resource): """Factory: create a policy from a JSON resource. Args: ...
Render a JSON policy resource. Returns: dict: a resource to be passed to the ``setIamPolicy`` API. def to_api_repr(self): """Render a JSON policy resource. Returns: dict: a resource to be passed to the ``setIamPolicy`` API. """ resource = {} if...
Get information about document references. Helper for :meth:`~.firestore_v1beta1.client.Client.get_all`. Args: references (List[.DocumentReference, ...]): Iterable of document references. Returns: Tuple[List[str, ...], Dict[str, .DocumentReference]]: A two-tuple of * ...
Get a document reference from a dictionary. This just wraps a simple dictionary look-up with a helpful error that is specific to :meth:`~.firestore.client.Client.get_all`, the **public** caller of this function. Args: document_path (str): A fully-qualified document path. reference_map ...
Parse a `BatchGetDocumentsResponse` protobuf. Args: get_doc_response (~google.cloud.proto.firestore.v1beta1.\ firestore_pb2.BatchGetDocumentsResponse): A single response (from a stream) containing the "get" response for a document. reference_map (Dict[str, .DocumentReference...
Lazy-loading getter GAPIC Firestore API. Returns: ~.gapic.firestore.v1beta1.firestore_client.FirestoreClient: The GAPIC client with the credentials of the current client. def _firestore_api(self): """Lazy-loading getter GAPIC Firestore API. Returns: ~.gapic...
The database string corresponding to this client's project. This value is lazy-loaded and cached. Will be of the form ``projects/{project_id}/databases/{database_id}`` but ``database_id == '(default)'`` for the time being. Returns: str: The fully-qualified da...
The RPC metadata for this client's associated database. Returns: Sequence[Tuple(str, str)]: RPC metadata with resource prefix for the database associated with this client. def _rpc_metadata(self): """The RPC metadata for this client's associated database. Returns: ...
Get a reference to a collection. For a top-level collection: .. code-block:: python >>> client.collection('top') For a sub-collection: .. code-block:: python >>> client.collection('mydocs/doc/subcol') >>> # is the same as >>> client.c...
Get a reference to a document in a collection. For a top-level document: .. code-block:: python >>> client.document('collek/shun') >>> # is the same as >>> client.document('collek', 'shun') For a document in a sub-collection: .. code-block:: pytho...
Create a write option for write operations. Write operations include :meth:`~.DocumentReference.set`, :meth:`~.DocumentReference.update` and :meth:`~.DocumentReference.delete`. One of the following keyword arguments must be provided: * ``last_update_time`` (:class:`google.prot...
Retrieve a batch of documents. .. note:: Documents returned by this method are not guaranteed to be returned in the same order that they are given in ``references``. .. note:: If multiple ``references`` refer to the same document, the server will only retu...
List top-level collections of the client's database. Returns: Sequence[~.firestore_v1beta1.collection.CollectionReference]: iterator of subcollections of the current document. def collections(self): """List top-level collections of the client's database. Returns: ...
Helper for :meth:`commit` et al. :raises: :exc:`ValueError` if the object's state is invalid for making API requests. def _check_state(self): """Helper for :meth:`commit` et al. :raises: :exc:`ValueError` if the object's state is invalid for making API reques...
Begin a transaction on the database. :rtype: bytes :returns: the ID for the newly-begun transaction. :raises ValueError: if the transaction is already begun, committed, or rolled back. def begin(self): """Begin a transaction on the database. :rtype: bytes :...
Roll back a transaction on the database. def rollback(self): """Roll back a transaction on the database.""" self._check_state() database = self._session._database api = database.spanner_api metadata = _metadata_with_prefix(database.name) api.rollback(self._session.name, ...
Commit mutations to the database. :rtype: datetime :returns: timestamp of the committed changes. :raises ValueError: if there are no mutations to commit. def commit(self): """Commit mutations to the database. :rtype: datetime :returns: timestamp of the committed change...
Helper for :meth:`execute_update`. :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[dict, .types.Type]] :param param_types: (Opt...
Perform an ``ExecuteSql`` API request with DML. :type dml: str :param dml: SQL 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[st...
Perform a batch of DML statements via an ``ExecuteBatchDml`` request. :type statements: Sequence[Union[ str, Tuple[str, Dict[str, Any], Dict[str, Union[dict, .types.Type]]]]] :param statements: List of DML statements, with optional params / param types. If passed, '...
Converts the :class:`TimestampRange` to a protobuf. :rtype: :class:`.data_v2_pb2.TimestampRange` :returns: The converted current object. def to_pb(self): """Converts the :class:`TimestampRange` to a protobuf. :rtype: :class:`.data_v2_pb2.TimestampRange` :returns: The converted...
Converts the row filter to a protobuf. First converts to a :class:`.data_v2_pb2.ColumnRange` and then uses it in the ``column_range_filter`` field. :rtype: :class:`.data_v2_pb2.RowFilter` :returns: The converted current object. def to_pb(self): """Converts the row filter to a ...
Converts the row filter to a protobuf. First converts to a :class:`.data_v2_pb2.ValueRange` and then uses it to create a row filter protobuf. :rtype: :class:`.data_v2_pb2.RowFilter` :returns: The converted current object. def to_pb(self): """Converts the row filter to a protob...
Converts the row filter to a protobuf. :rtype: :class:`.data_v2_pb2.RowFilter` :returns: The converted current object. def to_pb(self): """Converts the row filter to a protobuf. :rtype: :class:`.data_v2_pb2.RowFilter` :returns: The converted current object. """ ...
Converts the row filter to a protobuf. :rtype: :class:`.data_v2_pb2.RowFilter` :returns: The converted current object. def to_pb(self): """Converts the row filter to a protobuf. :rtype: :class:`.data_v2_pb2.RowFilter` :returns: The converted current object. """ ...
Converts the row filter to a protobuf. :rtype: :class:`.data_v2_pb2.RowFilter` :returns: The converted current object. def to_pb(self): """Converts the row filter to a protobuf. :rtype: :class:`.data_v2_pb2.RowFilter` :returns: The converted current object. """ ...
Return a fully-qualified organization_deidentify_template string. def organization_deidentify_template_path(cls, organization, deidentify_template): """Return a fully-qualified organization_deidentify_template string.""" return google.api_core.path_template.expand( "organizations/{organizat...
Return a fully-qualified project_deidentify_template string. def project_deidentify_template_path(cls, project, deidentify_template): """Return a fully-qualified project_deidentify_template string.""" return google.api_core.path_template.expand( "projects/{project}/deidentifyTemplates/{deid...
Return a fully-qualified organization_inspect_template string. def organization_inspect_template_path(cls, organization, inspect_template): """Return a fully-qualified organization_inspect_template string.""" return google.api_core.path_template.expand( "organizations/{organization}/inspect...
Return a fully-qualified project_inspect_template string. def project_inspect_template_path(cls, project, inspect_template): """Return a fully-qualified project_inspect_template string.""" return google.api_core.path_template.expand( "projects/{project}/inspectTemplates/{inspect_template}",...
Return a fully-qualified project_job_trigger string. def project_job_trigger_path(cls, project, job_trigger): """Return a fully-qualified project_job_trigger string.""" return google.api_core.path_template.expand( "projects/{project}/jobTriggers/{job_trigger}", project=project, ...
Return a fully-qualified dlp_job string. def dlp_job_path(cls, project, dlp_job): """Return a fully-qualified dlp_job string.""" return google.api_core.path_template.expand( "projects/{project}/dlpJobs/{dlp_job}", project=project, dlp_job=dlp_job )
Return a fully-qualified organization_stored_info_type string. def organization_stored_info_type_path(cls, organization, stored_info_type): """Return a fully-qualified organization_stored_info_type string.""" return google.api_core.path_template.expand( "organizations/{organization}/storedI...
Return a fully-qualified project_stored_info_type string. def project_stored_info_type_path(cls, project, stored_info_type): """Return a fully-qualified project_stored_info_type string.""" return google.api_core.path_template.expand( "projects/{project}/storedInfoTypes/{stored_info_type}", ...
Redacts potentially sensitive info from an image. This method has limits on input size, processing time, and output size. See https://cloud.google.com/dlp/docs/redacting-sensitive-data-images to learn more. When no InfoTypes or CustomInfoTypes are specified in this request, the ...
Re-identifies content that has been de-identified. See https://cloud.google.com/dlp/docs/pseudonymization#re-identification\_in\_free\_text\_code\_example to learn more. Example: >>> from google.cloud import dlp_v2 >>> >>> client = dlp_v2.DlpServiceClient() ...
Returns a list of the sensitive information types that the DLP API supports. See https://cloud.google.com/dlp/docs/infotypes-reference to learn more. Example: >>> from google.cloud import dlp_v2 >>> >>> client = dlp_v2.DlpServiceClient() >>> ...
Creates an InspectTemplate for re-using frequently used configuration for inspecting content, images, and storage. See https://cloud.google.com/dlp/docs/creating-templates to learn more. Example: >>> from google.cloud import dlp_v2 >>> >>> client = dlp_v2.Dlp...
Creates a new job to inspect storage or calculate risk metrics. See https://cloud.google.com/dlp/docs/inspecting-storage and https://cloud.google.com/dlp/docs/compute-risk-analysis to learn more. When no InfoTypes or CustomInfoTypes are specified in inspect jobs, the system will automat...
Creates a job trigger to run DLP actions such as scanning storage for sensitive information on a set schedule. See https://cloud.google.com/dlp/docs/creating-job-triggers to learn more. Example: >>> from google.cloud import dlp_v2 >>> >>> client = dlp_v2.DlpS...
Creates a pre-built stored infoType to be used for inspection. See https://cloud.google.com/dlp/docs/creating-stored-infotypes to learn more. Example: >>> from google.cloud import dlp_v2 >>> >>> client = dlp_v2.DlpServiceClient() >>> >...
Helper for trace-related API calls. See https://cloud.google.com/trace/docs/reference/v2/rpc/google.devtools. cloudtrace.v2 def trace_api(self): """ Helper for trace-related API calls. See https://cloud.google.com/trace/docs/reference/v2/rpc/google.devtools. ...
Sends new spans to Stackdriver Trace or updates existing traces. If the name of a trace that you send matches that of an existing trace, new spans are added to the existing trace. Attempt to update existing spans results undefined behavior. If the name does not match, a new trace is crea...
Creates a new Span. Example: >>> from google.cloud import trace_v2 >>> >>> client = trace_v2.Client() >>> >>> name = 'projects/{project}/traces/{trace_id}/spans/{span_id}'. format('[PROJECT]', '[TRACE_ID]', '[SPAN_ID]') ...
Report error payload. :type error_report: dict :param: error_report: dict payload of the error report formatted according to https://cloud.google.com/error-reporting/docs/formatting-error-messages This object should be built using :meth:~`google.cloud.err...
Returns a routing header string for the given request parameters. Args: params (Mapping[str, Any]): A dictionary containing the request parameters used for routing. Returns: str: The routing header string. def to_routing_header(params): """Returns a routing header string for t...
Construct a field description protobuf. :type name: str :param name: the name of the field :type field_type: :class:`type_pb2.Type` :param field_type: the type of the field :rtype: :class:`type_pb2.StructType.Field` :returns: the appropriate struct-field-type protobuf def StructField(name, f...
Construct a struct parameter type description protobuf. :type fields: list of :class:`type_pb2.StructType.Field` :param fields: the fields of the struct :rtype: :class:`type_pb2.Type` :returns: the appropriate struct-type protobuf def Struct(fields): # pylint: disable=invalid-name """Construct a...
Perform bi-directional speech recognition. This method allows you to receive results while sending audio; it is only available via. gRPC (not REST). .. warning:: This method is EXPERIMENTAL. Its interface might change in the future. Example: >>> from...
A generator that yields the config followed by the requests. Args: config (~.speech_v1.types.StreamingRecognitionConfig): The configuration to use for the stream. requests (Iterable[~.speech_v1.types.StreamingRecognizeRequest]): The input objects. ...
Return a fully-qualified project_data_source string. def project_data_source_path(cls, project, data_source): """Return a fully-qualified project_data_source string.""" return google.api_core.path_template.expand( "projects/{project}/dataSources/{data_source}", project=project, ...
Return a fully-qualified project_transfer_config string. def project_transfer_config_path(cls, project, transfer_config): """Return a fully-qualified project_transfer_config string.""" return google.api_core.path_template.expand( "projects/{project}/transferConfigs/{transfer_config}", ...
Return a fully-qualified project_run string. def project_run_path(cls, project, transfer_config, run): """Return a fully-qualified project_run string.""" return google.api_core.path_template.expand( "projects/{project}/transferConfigs/{transfer_config}/runs/{run}", project=proje...
Creates a new data transfer configuration. Example: >>> from google.cloud import bigquery_datatransfer_v1 >>> >>> client = bigquery_datatransfer_v1.DataTransferServiceClient() >>> >>> parent = client.project_path('[PROJECT]') >>> ...
Updates a data transfer configuration. All fields must be set, even if they are not updated. Example: >>> from google.cloud import bigquery_datatransfer_v1 >>> >>> client = bigquery_datatransfer_v1.DataTransferServiceClient() >>> >>> # TODO: I...
Creates transfer runs for a time range [start\_time, end\_time]. For each date - or whatever granularity the data source supports - in the range, one transfer run is created. Note that runs are created per UTC time in the time range. Example: >>> from google.cloud import big...
Gets the most recent threat list diffs. Example: >>> from google.cloud import webrisk_v1beta1 >>> from google.cloud.webrisk_v1beta1 import enums >>> >>> client = webrisk_v1beta1.WebRiskServiceV1Beta1Client() >>> >>> # TODO: Initialize `thr...
This method is used to check whether a URI is on a given threatList. Example: >>> from google.cloud import webrisk_v1beta1 >>> from google.cloud.webrisk_v1beta1 import enums >>> >>> client = webrisk_v1beta1.WebRiskServiceV1Beta1Client() >>> ...
Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in a threatList and there is a match. The client side threatList only holds partial hashes so the client must query this method to determine if there is a full hash match of a threat....
Return a fully-qualified asset string. def asset_path(cls, organization, asset): """Return a fully-qualified asset string.""" return google.api_core.path_template.expand( "organizations/{organization}/assets/{asset}", organization=organization, asset=asset, )
Return a fully-qualified asset_security_marks string. def asset_security_marks_path(cls, organization, asset): """Return a fully-qualified asset_security_marks string.""" return google.api_core.path_template.expand( "organizations/{organization}/assets/{asset}/securityMarks", or...
Return a fully-qualified source string. def source_path(cls, organization, source): """Return a fully-qualified source string.""" return google.api_core.path_template.expand( "organizations/{organization}/sources/{source}", organization=organization, source=source, ...
Return a fully-qualified finding string. def finding_path(cls, organization, source, finding): """Return a fully-qualified finding string.""" return google.api_core.path_template.expand( "organizations/{organization}/sources/{source}/findings/{finding}", organization=organizatio...
Creates a source. Example: >>> from google.cloud import securitycenter_v1 >>> >>> client = securitycenter_v1.SecurityCenterClient() >>> >>> parent = client.organization_path('[ORGANIZATION]') >>> >>> # TODO: Initialize `source`...
Creates a finding. The corresponding source must exist for finding creation to succeed. Example: >>> from google.cloud import securitycenter_v1 >>> >>> client = securitycenter_v1.SecurityCenterClient() >>> >>> parent = client.source_path('[ORG...
Runs asset discovery. The discovery is tracked with a long-running operation. This API can only be called with limited frequency for an organization. If it is called too frequently the caller will receive a TOO\_MANY\_REQUESTS error. Example: >>> from google.cloud i...
Updates security marks. Example: >>> from google.cloud import securitycenter_v1 >>> >>> client = securitycenter_v1.SecurityCenterClient() >>> >>> # TODO: Initialize `security_marks`: >>> security_marks = {} >>> >>> ...
Return a page of log entry resources. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list :type projects: list of strings :param projects: project IDs to include. If not passed, defaults to the project bound to the client. :t...
API call: log an entry resource via a POST request See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/write :type entries: sequence of mapping :param entries: the log entry resources to log. :type logger_name: str :param logger_name: name of defaul...
API call: delete all entries in a logger via a DELETE request See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.logs/delete :type project: str :param project: ID of project containing the log entries to delete :type logger_name: str :param logger...
List sinks for the project associated with this client. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/list :type project: str :param project: ID of the project whose sinks are to be listed. :type page_size: int :param page_size: maximum ...
API call: retrieve a sink resource. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get :type project: str :param project: ID of the project containing the sink. :type sink_name: str :param sink_name: the name of the sink :rtype:...
API call: update a sink resource. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/update :type project: str :param project: ID of the project containing the sink. :type sink_name: str :param sink_name: the name of the sink :type ...
API call: delete a sink resource. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/delete :type project: str :param project: ID of the project containing the sink. :type sink_name: str :param sink_name: the name of the sink def sink_delet...
List metrics for the project associated with this client. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/list :type project: str :param project: ID of the project whose metrics are to be listed. :type page_size: int :param page_size: ma...
API call: create a metric resource. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/create :type project: str :param project: ID of the project in which to create the metric. :type metric_name: str :param metric_name: the name of the me...
API call: retrieve a metric resource. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/get :type project: str :param project: ID of the project containing the metric. :type metric_name: str :param metric_name: the name of the metric ...
API call: delete a metric resource. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/delete :type project: str :param project: ID of the project containing the metric. :type metric_name: str :param metric_name: the name of the metric. d...
Add row range to row_ranges list from the row keys For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_row_range_from_keys] :end-before: [END bigtable_row_range_from_keys] :type start_key: bytes :param start_key: (Optional) Start ke...
Add row keys and row range to given request message :type message: class:`data_messages_v2_pb2.ReadRowsRequest` :param message: The ``ReadRowsRequest`` protobuf def _update_message_request(self, message): """Add row keys and row range to given request message :type message: class:`dat...
A tuple key that uniquely describes this field. Used to compute this instance's hashcode and evaluate equality. Returns: Tuple[str]: The contents of this :class:`.RowRange`. def _key(self): """A tuple key that uniquely describes this field. Used to compute this instance's...
Convert row range object to dict which can be passed to google.bigtable.v2.RowRange add method. def get_range_kwargs(self): """ Convert row range object to dict which can be passed to google.bigtable.v2.RowRange add method. """ range_kwargs = {} if self.start_key is not ...