text
stringlengths
81
112k
Construct JSON API representation for the parameter. :rtype: dict :returns: JSON mapping def to_api_repr(self): """Construct JSON API representation for the parameter. :rtype: dict :returns: JSON mapping """ value = self.value converter = _SCALAR_VALUE_...
Factory: construct parameter from JSON resource. :type resource: dict :param resource: JSON mapping of parameter :rtype: :class:`~google.cloud.bigquery.query.ArrayQueryParameter` :returns: instance def from_api_repr(cls, resource): """Factory: construct parameter from JSON res...
Construct JSON API representation for the parameter. :rtype: dict :returns: JSON mapping def to_api_repr(self): """Construct JSON API representation for the parameter. :rtype: dict :returns: JSON mapping """ values = self.values if self.array_type == "R...
Factory: construct parameter from JSON resource. :type resource: dict :param resource: JSON mapping of parameter :rtype: :class:`~google.cloud.bigquery.query.StructQueryParameter` :returns: instance def from_api_repr(cls, resource): """Factory: construct parameter from JSON re...
Construct JSON API representation for the parameter. :rtype: dict :returns: JSON mapping def to_api_repr(self): """Construct JSON API representation for the parameter. :rtype: dict :returns: JSON mapping """ s_types = {} values = {} for name, va...
Update properties from resource in body of ``api_response`` :type api_response: dict :param api_response: response returned from an API call def _set_properties(self, api_response): """Update properties from resource in body of ``api_response`` :type api_response: dict :param ...
Format the message into JSON expected by fluentd. :type record: :class:`~logging.LogRecord` :param record: the log record :rtype: str :returns: A JSON string formatted for GKE fluentd. def format(self, record): """Format the message into JSON expected by fluentd. :typ...
Analyzes the sentiment of the provided text. Example: >>> from google.cloud import language_v1 >>> >>> client = language_v1.LanguageServiceClient() >>> >>> # TODO: Initialize `document`: >>> document = {} >>> >>> re...
Call ``Commit`` on the GAPIC client with retry / sleep. Retries the ``Commit`` RPC on Unavailable. Usually this RPC-level retry is handled by the underlying GAPICd client, but in this case it doesn't because ``Commit`` is not always idempotent. But here we know it is "idempotent"-like because it has a ...
Sleep and produce a new sleep time. .. _Exponential Backoff And Jitter: https://www.awsarchitectureblog.com/\ 2015/03/backoff.html Select a duration between zero and ``current_sleep``. It might seem counterintuitive to have so much jitter, but `Exponential Backo...
Add `Write`` protobufs to this transaction. Args: write_pbs (List[google.cloud.proto.firestore.v1beta1.\ write_pb2.Write]): A list of write protobufs to be added. Raises: ValueError: If this transaction is read-only. def _add_write_pbs(self, write_pbs): ...
Convert the current object to protobuf. The ``retry_id`` value is used when retrying a transaction that failed (e.g. due to contention). It is intended to be the "first" transaction that failed (i.e. if multiple retries are needed). Args: retry_id (Union[bytes, NoneType]): ...
Begin the transaction. Args: retry_id (Optional[bytes]): Transaction ID of a transaction to be retried. Raises: ValueError: If the current transaction has already begun. def _begin(self, retry_id=None): """Begin the transaction. Args: ...
Roll back the transaction. Raises: ValueError: If no transaction is in progress. def _rollback(self): """Roll back the transaction. Raises: ValueError: If no transaction is in progress. """ if not self.in_progress: raise ValueError(_CANT_ROL...
Transactionally commit the changes accumulated. 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 were applied to this transact...
Begin transaction and call the wrapped callable. If the callable raises an exception, the transaction will be rolled back. If not, the transaction will be "ready" for ``Commit`` (i.e. it will have staged writes). Args: transaction (~.firestore_v1beta1.transaction.Transactio...
Try to commit the transaction. If the transaction is read-write and the ``Commit`` fails with the ``ABORTED`` status code, it will be retried. Any other failure will not be caught. Args: transaction (~.firestore_v1beta1.transaction.Transaction): The transact...
Return a fully-qualified profile string. def profile_path(cls, project, tenant, profile): """Return a fully-qualified profile string.""" return google.api_core.path_template.expand( "projects/{project}/tenants/{tenant}/profiles/{profile}", project=project, tenant=ten...
Creates and returns a new profile. Example: >>> from google.cloud import talent_v4beta1 >>> >>> client = talent_v4beta1.ProfileServiceClient() >>> >>> parent = client.tenant_path('[PROJECT]', '[TENANT]') >>> >>> # TODO: Initial...
Gets the specified profile. Example: >>> from google.cloud import talent_v4beta1 >>> >>> client = talent_v4beta1.ProfileServiceClient() >>> >>> name = client.profile_path('[PROJECT]', '[TENANT]', '[PROFILE]') >>> >>> response =...
Updates the specified profile and returns the updated result. Example: >>> from google.cloud import talent_v4beta1 >>> >>> client = talent_v4beta1.ProfileServiceClient() >>> >>> # TODO: Initialize `profile`: >>> profile = {} >>...
Searches for profiles within a tenant. For example, search by raw queries "software engineer in Mountain View" or search by structured filters (location filter, education filter, etc.). See ``SearchProfilesRequest`` for more information. Example: >>> from google.cl...
Perform an online prediction. The prediction result will be directly returned in the response. Available for following ML problems, and their expected request payloads: - Image Classification - Image in .JPEG, .GIF or .PNG format, image\_bytes up to 30MB. - Image Object Det...
Perform a batch prediction. Unlike the online ``Predict``, batch prediction result won't be immediately available in the response. Instead, a long running operation object is returned. User can poll the operation result via ``GetOperation`` method. Once the operation is done, ``BatchPred...
Factory to retrieve JSON credentials while creating client. :type json_credentials_path: str :param json_credentials_path: The path to a private key file (this file was given to you when you created the service account). This f...
Getter for object used for HTTP transport. :rtype: :class:`~requests.Session` :returns: An HTTP object. def _http(self): """Getter for object used for HTTP transport. :rtype: :class:`~requests.Session` :returns: An HTTP object. """ if self._http_internal is Non...
Return a fully-qualified alert_policy string. def alert_policy_path(cls, project, alert_policy): """Return a fully-qualified alert_policy string.""" return google.api_core.path_template.expand( "projects/{project}/alertPolicies/{alert_policy}", project=project, alert...
Return a fully-qualified alert_policy_condition string. def alert_policy_condition_path(cls, project, alert_policy, condition): """Return a fully-qualified alert_policy_condition string.""" return google.api_core.path_template.expand( "projects/{project}/alertPolicies/{alert_policy}/conditi...
Get multiple items from a Queue. Gets at least one (blocking) and at most ``max_items`` items (non-blocking) from a given Queue. Does not mark the items as done. Args: queue_ (~queue.Queue`): The Queue to get items from. max_items (int): The maximum number of items to get. If ``None``, the...
Maps BigQuery error reasons to an exception. The reasons and their matching HTTP status codes are documented on the `troubleshooting errors`_ page. .. _troubleshooting errors: https://cloud.google.com/bigquery\ /troubleshooting-errors :type error_result: Mapping[str, str] :param error_res...
Returns a job reference for an API resource representation. def _from_api_repr(cls, resource): """Returns a job reference for an API resource representation.""" job_id = resource.get("jobId") project = resource.get("projectId") location = resource.get("location") job_ref = cls(j...
Datetime at which the job was created. :rtype: ``datetime.datetime``, or ``NoneType`` :returns: the creation time (None until set from the server). def created(self): """Datetime at which the job was created. :rtype: ``datetime.datetime``, or ``NoneType`` :returns: the creatio...
Datetime at which the job was started. :rtype: ``datetime.datetime``, or ``NoneType`` :returns: the start time (None until set from the server). def started(self): """Datetime at which the job was started. :rtype: ``datetime.datetime``, or ``NoneType`` :returns: the start time...
Datetime at which the job finished. :rtype: ``datetime.datetime``, or ``NoneType`` :returns: the end time (None until set from the server). def ended(self): """Datetime at which the job finished. :rtype: ``datetime.datetime``, or ``NoneType`` :returns: the end time (None until...
Helper for job-type specific statistics-based properties. def _job_statistics(self): """Helper for job-type specific statistics-based properties.""" statistics = self._properties.get("statistics", {}) return statistics.get(self._JOB_TYPE, {})
Update properties from resource in body of ``api_response`` :type api_response: dict :param api_response: response returned from an API call def _set_properties(self, api_response): """Update properties from resource in body of ``api_response`` :type api_response: dict :param ...
Helper for :meth:`from_api_repr` :type resource: dict :param resource: resource for the job :rtype: dict :returns: tuple (string, dict), where the first element is the job ID and the second contains job-specific configuration. :raises: :class:`KeyError` if the...
API call: begin the job via a POST request See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/insert :type client: :class:`~google.cloud.bigquery.client.Client` or ``NoneType`` :param client: the client to use. If not passed, falls back to the ...
API call: test for the existence of the job via a GET request See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get :type client: :class:`~google.cloud.bigquery.client.Client` or ``NoneType`` :param client: the client to use. If not passed, falls...
API call: refresh job properties via a GET request. See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get :type client: :class:`~google.cloud.bigquery.client.Client` or ``NoneType`` :param client: the client to use. If not passed, falls back to t...
API call: cancel job via a POST request See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/cancel :type client: :class:`~google.cloud.bigquery.client.Client` or ``NoneType`` :param client: the client to use. If not passed, falls back to the ...
Set the result or exception from the job if it is complete. def _set_future_result(self): """Set the result or exception from the job 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 sam...
Refresh the job and checks if it is complete. :type retry: :class:`google.api_core.retry.Retry` :param retry: (Optional) How to retry the RPC. :rtype: bool :returns: True if the job is complete, False otherwise. def done(self, retry=DEFAULT_RETRY): """Refresh the job and check...
Start the job and wait for it to complete and get the result. :type timeout: float :param timeout: How long (in seconds) to wait for job to complete before raising a :class:`concurrent.futures.TimeoutError`. :type retry: :class:`google.api_core.retry.Retry` :par...
Get a value in the ``self._properties[self._job_type]`` dictionary. Most job properties are inside the dictionary related to the job type (e.g. 'copy', 'extract', 'load', 'query'). Use this method to access those properties:: self._get_sub_prop('destinationTable') This is ...
Set a value in the ``self._properties[self._job_type]`` dictionary. Most job properties are inside the dictionary related to the job type (e.g. 'copy', 'extract', 'load', 'query'). Use this method to set those properties:: self._set_sub_prop('useLegacySql', False) This is ...
Remove ``key`` from the ``self._properties[self._job_type]`` dict. Most job properties are inside the dictionary related to the job type (e.g. 'copy', 'extract', 'load', 'query'). Use this method to clear those properties:: self._del_sub_prop('useLegacySql') This is equiva...
Merge this job config with a default job config. The keys in this object take precedence over the keys in the default config. The merge is done at the top-level as well as for keys one level below the job type. Arguments: default_job_config (google.cloud.bigquery.job._JobCo...
Factory: construct a job configuration given its API representation :type resource: dict :param resource: An extract job configuration in the same representation as is returned from the API. :rtype: :class:`google.cloud.bigquery.job._JobConfig` :returns: Configu...
google.cloud.bigquery.table.EncryptionConfiguration: Custom encryption configuration for the destination table. Custom encryption configuration (e.g., Cloud KMS keys) or :data:`None` if using default encryption. See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#...
List[google.cloud.bigquery.schema.SchemaField]: Schema of the destination table. See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.schema def schema(self): """List[google.cloud.bigquery.schema.SchemaField]: Schema of the destination table. ...
google.cloud.bigquery.table.TimePartitioning: Specifies time-based partitioning for the destination table. def time_partitioning(self): """google.cloud.bigquery.table.TimePartitioning: Specifies time-based partitioning for the destination table. """ prop = self._get_sub_prop("ti...
Generate a resource for :meth:`_begin`. def to_api_repr(self): """Generate a resource for :meth:`_begin`.""" configuration = self._configuration.to_api_repr() if self.source_uris is not None: _helpers._set_sub_prop( configuration, ["load", "sourceUris"], self.source_...
Factory: construct a job given its API representation .. note: This method assumes that the project found in the resource matches the client's project. :type resource: dict :param resource: dataset job representation returned from the API :type client: :class:`...
Generate a resource for :meth:`_begin`. def to_api_repr(self): """Generate a resource for :meth:`_begin`.""" source_refs = [ { "projectId": table.project, "datasetId": table.dataset_id, "tableId": table.table_id, } for...
Factory: construct a job given its API representation .. note: This method assumes that the project found in the resource matches the client's project. :type resource: dict :param resource: dataset job representation returned from the API :type client: :class:`...
Return file counts from job statistics, if present. See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.extract.destinationUriFileCounts Returns: a list of integer counts, each representing the number of files per destination URI or URI pattern...
Generate a resource for :meth:`_begin`. def to_api_repr(self): """Generate a resource for :meth:`_begin`.""" source_ref = { "projectId": self.source.project, "datasetId": self.source.dataset_id, "tableId": self.source.table_id, } configuration = sel...
Factory: construct a job given its API representation .. note: This method assumes that the project found in the resource matches the client's project. :type resource: dict :param resource: dataset job representation returned from the API :type client: :class:`...
google.cloud.bigquery.dataset.DatasetReference: the default dataset to use for unqualified table names in the query or :data:`None` if not set. The ``default_dataset`` setter accepts: - a :class:`~google.cloud.bigquery.dataset.Dataset`, or - a :class:`~google.cloud.bigquery.dat...
google.cloud.bigquery.table.TableReference: table where results are written or :data:`None` if not set. The ``destination`` setter accepts: - a :class:`~google.cloud.bigquery.table.Table`, or - a :class:`~google.cloud.bigquery.table.TableReference`, or - a :class:`str` of the f...
Dict[str, google.cloud.bigquery.external_config.ExternalConfig]: Definitions for external tables or :data:`None` if not set. See https://g.co/cloud/bigquery/docs/reference/rest/v2/jobs#configuration.query.tableDefinitions def table_definitions(self): """Dict[str, google.cloud.bigquery....
Build an API representation of the query job config. Returns: dict: A dictionary in the format used by the BigQuery API. def to_api_repr(self): """Build an API representation of the query job config. Returns: dict: A dictionary in the format used by the BigQuery API. ...
Generate a resource for :meth:`_begin`. def to_api_repr(self): """Generate a resource for :meth:`_begin`.""" configuration = self._configuration.to_api_repr() resource = { "jobReference": self._properties["jobReference"], "configuration": configuration, } ...
Factory: construct a job given its API representation :type resource: dict :param resource: dataset job representation returned from the API :type client: :class:`google.cloud.bigquery.client.Client` :param client: Client which holds credentials and project conf...
Return query plan from job statistics, if present. See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.queryPlan :rtype: list of :class:`QueryPlanEntry` :returns: mappings describing the query plan, or an empty list if the query has not...
List(TimelineEntry): Return the query execution timeline from job statistics. def timeline(self): """List(TimelineEntry): Return the query execution timeline from job statistics. """ raw = self._job_statistics().get("timeline", ()) return [TimelineEntry.from_api_repr(ent...
Return total bytes processed from job statistics, if present. See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.totalBytesProcessed :rtype: int or None :returns: total bytes processed by the job, or None if job is not yet complete. d...
Return total bytes billed from job statistics, if present. See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.totalBytesBilled :rtype: int or None :returns: total bytes processed by the job, or None if job is not yet complete. def tot...
Optional[TableReference]: Return the DDL target table, present for CREATE/DROP TABLE/VIEW queries. See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.ddlTargetTable def ddl_target_table(self): """Optional[TableReference]: Return the DDL target table...
Return the number of DML rows affected by the job. See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.numDmlAffectedRows :rtype: int or None :returns: number of DML rows affected by the job, or None if job is not yet complete. def num...
Return referenced tables from job statistics, if present. See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.referencedTables :rtype: list of dict :returns: mappings describing the query plan, or an empty list if the query has not yet ...
Return undeclared query parameters from job statistics, if present. See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.undeclaredQueryParameters :rtype: list of :class:`~google.cloud.bigquery.ArrayQueryParameter`, :class:`~go...
Return the estimated number of bytes processed by the query. See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.query.estimatedBytesProcessed :rtype: int or None :returns: number of DML rows affected by the job, or None if job is not yet com...
Refresh the job and checks if it is complete. :rtype: bool :returns: True if the job is complete, False otherwise. def done(self, retry=DEFAULT_RETRY): """Refresh the job and checks if it is complete. :rtype: bool :returns: True if the job is complete, False otherwise. ...
Start the job and wait for it to complete and get the result. :type timeout: float :param timeout: How long (in seconds) to wait for job to complete before raising a :class:`concurrent.futures.TimeoutError`. :type retry: :class:`google.api_core.retry.Retry` :par...
Return a pandas DataFrame from a QueryJob Args: bqstorage_client ( \ google.cloud.bigquery_storage_v1beta1.BigQueryStorageClient \ ): **Alpha Feature** Optional. A BigQuery Storage API client. If supplied, use the faster BigQuery Storage A...
Factory: construct instance from the JSON repr. :type resource: dict :param resource: JSON representation of the entry :rtype: :class:`QueryPlanEntryStep` :return: new instance built from the resource def from_api_repr(cls, resource): """Factory: construct instance from the JS...
Union[Datetime, None]: Datetime when the stage started. def start(self): """Union[Datetime, None]: Datetime when the stage started.""" if self._properties.get("startMs") is None: return None return _helpers._datetime_from_microseconds( int(self._properties.get("startMs")...
Union[Datetime, None]: Datetime when the stage ended. def end(self): """Union[Datetime, None]: Datetime when the stage ended.""" if self._properties.get("endMs") is None: return None return _helpers._datetime_from_microseconds( int(self._properties.get("endMs")) * 1000.0...
List(int): Entry IDs for stages that were inputs for this stage. def input_stages(self): """List(int): Entry IDs for stages that were inputs for this stage.""" if self._properties.get("inputStages") is None: return [] return [ _helpers._int_or_none(entry) for...
Construct an UnknownJob from the JSON representation. Args: resource (dict): JSON representation of a job. client (google.cloud.bigquery.client.Client): Client connected to BigQuery API. Returns: UnknownJob: Job corresponding to the resource. def fr...
Factory: construct a zone given its API representation :type resource: dict :param resource: zone resource representation returned from the API :type client: :class:`google.cloud.dns.client.Client` :param client: Client which holds credentials and project config...
Update description of the zone. :type value: str :param value: (Optional) new description :raises: ValueError for invalid value types. def description(self, value): """Update description of the zone. :type value: str :param value: (Optional) new description :...
Update named set of DNS name servers. :type value: str :param value: (Optional) new title :raises: ValueError for invalid value types. def name_server_set(self, value): """Update named set of DNS name servers. :type value: str :param value: (Optional) new title ...
Construct a resource record set bound to this zone. :type name: str :param name: Name of the record set. :type record_type: str :param record_type: RR type :type ttl: int :param ttl: TTL for the RR, in seconds :type rrdatas: list of string :param rrdat...
Update properties from resource in body of ``api_response`` :type api_response: dict :param api_response: response returned from an API call def _set_properties(self, api_response): """Update properties from resource in body of ``api_response`` :type api_response: dict :param ...
Generate a resource for ``create`` or ``update``. def _build_resource(self): """Generate a resource for ``create`` or ``update``.""" resource = {"name": self.name} if self.dns_name is not None: resource["dnsName"] = self.dns_name if self.description is not None: ...
API call: create the zone via a PUT request See https://cloud.google.com/dns/api/v1/managedZones/create :type client: :class:`google.cloud.dns.client.Client` :param client: (Optional) the client to use. If not passed, falls back to the ``client`` stored on the...
API call: delete the zone via a DELETE request See https://cloud.google.com/dns/api/v1/managedZones/delete :type client: :class:`google.cloud.dns.client.Client` :param client: (Optional) the client to use. If not passed, falls back to the ``client`` stored on ...
List resource record sets for this zone. See https://cloud.google.com/dns/api/v1/resourceRecordSets/list :type max_results: int :param max_results: Optional. The maximum number of resource record sets to return. Defaults to a sensible value ...
Run image detection and annotation for an image. Example: >>> from google.cloud.vision_v1 import ImageAnnotatorClient >>> client = ImageAnnotatorClient() >>> request = { ... 'image': { ... 'source': {'image_uri': 'https://foo.com/image.jpg...
Sample ID: go/samples-tracker/1534 def delete_model(client, model_id): """Sample ID: go/samples-tracker/1534""" # [START bigquery_delete_model] from google.cloud import bigquery # TODO(developer): Construct a BigQuery client object. # client = bigquery.Client() # TODO(developer): Set model_i...
Sample ID: go/samples-tracker/1512 def list_models(client, dataset_id): """Sample ID: go/samples-tracker/1512""" # [START bigquery_list_models] from google.cloud import bigquery # TODO(developer): Construct a BigQuery client object. # client = bigquery.Client() # TODO(developer): Set dataset...
Return a fully-qualified job string. def job_path(cls, project, jobs): """Return a fully-qualified job string.""" return google.api_core.path_template.expand( "projects/{project}/jobs/{jobs}", project=project, jobs=jobs )
Creates a new job. Typically, the job becomes searchable within 10 seconds, but it may take up to 5 minutes. Example: >>> from google.cloud import talent_v4beta1 >>> >>> client = talent_v4beta1.JobServiceClient() >>> >>> parent = clie...
Retrieves the specified job, whose status is OPEN or recently EXPIRED within the last 90 days. Example: >>> from google.cloud import talent_v4beta1 >>> >>> client = talent_v4beta1.JobServiceClient() >>> >>> name = client.job_path('[PROJECT]', ...
Deletes a list of ``Job``\ s by filter. Example: >>> from google.cloud import talent_v4beta1 >>> >>> client = talent_v4beta1.JobServiceClient() >>> >>> parent = client.project_path('[PROJECT]') >>> >>> # TODO: Initialize `filte...
Searches for jobs using the provided ``SearchJobsRequest``. This call constrains the ``visibility`` of jobs present in the database, and only returns jobs that the caller has permission to search against. Example: >>> from google.cloud import talent_v4beta1 >>> ...
Compute a type URL for a klass. :type klass: type :param klass: class to be used as a factory for the given type :type prefix: str :param prefix: URL prefix for the type :rtype: str :returns: the URL, prefixed as appropriate def _compute_type_url(klass, prefix=_GOOGLE_APIS_PREFIX): """Co...