Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def delete_instance( self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to add retry and timeout logic. ...
[ "\n Deletes a specific Redis instance. Instance stops serving and data is\n deleted.\n\n Example:\n >>> from google.cloud import redis_v1beta1\n >>>\n >>> client = redis_v1beta1.CloudRedisClient()\n >>>\n >>> name = client.instance_path('[...
Please provide a description of the function:def recognize( self, config, audio, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to add retry and timeout log...
[ "\n Performs synchronous speech recognition: receive results after all audio\n has been sent and processed.\n\n Example:\n >>> from google.cloud import speech_v1p1beta1\n >>> from google.cloud.speech_v1p1beta1 import enums\n >>>\n >>> client = speech_...
Please provide a description of the function:def long_running_recognize( self, config, audio, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to add retry an...
[ "\n Performs asynchronous speech recognition: receive results via the\n google.longrunning.Operations interface. Returns either an\n ``Operation.error`` or an ``Operation.response`` which contains a\n ``LongRunningRecognizeResponse`` message.\n\n Example:\n >>> from goo...
Please provide a description of the function:def region_path(cls, project, region): return google.api_core.path_template.expand( "projects/{project}/regions/{region}", project=project, region=region )
[ "Return a fully-qualified region string." ]
Please provide a description of the function:def workflow_template_path(cls, project, region, workflow_template): return google.api_core.path_template.expand( "projects/{project}/regions/{region}/workflowTemplates/{workflow_template}", project=project, region=region,...
[ "Return a fully-qualified workflow_template string." ]
Please provide a description of the function:def create_workflow_template( self, parent, template, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to add ret...
[ "\n Creates new workflow template.\n\n Example:\n >>> from google.cloud import dataproc_v1beta2\n >>>\n >>> client = dataproc_v1beta2.WorkflowTemplateServiceClient()\n >>>\n >>> parent = client.region_path('[PROJECT]', '[REGION]')\n >>>...
Please provide a description of the function:def get_workflow_template( self, name, version=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to add retr...
[ "\n Retrieves the latest workflow template.\n\n Can retrieve previously instantiated template by specifying optional\n version parameter.\n\n Example:\n >>> from google.cloud import dataproc_v1beta2\n >>>\n >>> client = dataproc_v1beta2.WorkflowTemplateSe...
Please provide a description of the function:def instantiate_workflow_template( self, name, version=None, instance_id=None, request_id=None, parameters=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, ...
[ "\n Instantiates a template and begins execution.\n\n The returned Operation can be used to track execution of workflow by\n polling ``operations.get``. The Operation will complete when entire\n workflow is finished.\n\n The running workflow can be aborted via ``operations.cancel`...
Please provide a description of the function:def instantiate_inline_workflow_template( self, parent, template, instance_id=None, request_id=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None,...
[ "\n Instantiates a template and begins execution.\n\n This method is equivalent to executing the sequence\n ``CreateWorkflowTemplate``, ``InstantiateWorkflowTemplate``,\n ``DeleteWorkflowTemplate``.\n\n The returned Operation can be used to track execution of workflow by\n ...
Please provide a description of the function:def _parse_schema_resource(info): if "fields" not in info: return () schema = [] for r_field in info["fields"]: name = r_field["name"] field_type = r_field["type"] mode = r_field.get("mode", "NULLABLE") description = ...
[ "Parse a resource fragment into a schema field.\n\n Args:\n info: (Mapping[str->dict]): should contain a \"fields\" key to be parsed\n\n Returns:\n (Union[Sequence[:class:`google.cloud.bigquery.schema.SchemaField`],None])\n a list of parsed fields, or ``None`` if no \"fields\" key fou...
Please provide a description of the function:def from_api_repr(cls, api_repr): # Handle optional properties with default values mode = api_repr.get("mode", "NULLABLE") description = api_repr.get("description") fields = api_repr.get("fields", ()) return cls( f...
[ "Return a ``SchemaField`` object deserialized from a dictionary.\n\n Args:\n api_repr (Mapping[str, str]): The serialized representation\n of the SchemaField, such as what is output by\n :meth:`to_api_repr`.\n\n Returns:\n google.cloud.biquery.schema...
Please provide a description of the function:def to_api_repr(self): # Put together the basic representation. See http://bit.ly/2hOAT5u. answer = { "mode": self.mode.upper(), "name": self.name, "type": self.field_type.upper(), "description": self.d...
[ "Return a dictionary representing this schema field.\n\n Returns:\n dict: A dictionary representing the SchemaField in a serialized\n form.\n " ]
Please provide a description of the function:def _key(self): return ( self._name, self._field_type.upper(), self._mode.upper(), self._description, self._fields, )
[ "A tuple key that uniquely describes this field.\n\n Used to compute this instance's hashcode and evaluate equality.\n\n Returns:\n tuple: The contents of this\n :class:`~google.cloud.bigquery.schema.SchemaField`.\n " ]
Please provide a description of the function:def parse_options(): parser = argparse.ArgumentParser() parser.add_argument('command', help='The YCSB command.') parser.add_argument('benchmark', help='The YCSB benchmark.') parser.add_argument('-P', '--workload', action='store', dest='workload', ...
[ "Parses options." ]
Please provide a description of the function:def open_database(parameters): spanner_client = spanner.Client() instance_id = parameters['cloudspanner.instance'] instance = spanner_client.instance(instance_id) database_id = parameters['cloudspanner.database'] pool = spanner.BurstyPool(int(paramet...
[ "Opens a database specified by the parameters from parse_options()." ]
Please provide a description of the function:def load_keys(database, parameters): keys = [] with database.snapshot() as snapshot: results = snapshot.execute_sql( 'SELECT u.id FROM %s u' % parameters['table']) for row in results: keys.append(row[0]) return keys
[ "Loads keys from database." ]
Please provide a description of the function:def read(database, table, key): with database.snapshot() as snapshot: result = snapshot.execute_sql('SELECT u.* FROM %s u WHERE u.id="%s"' % (table, key)) for row in result: key = row[0] for i...
[ "Does a single read operation." ]
Please provide a description of the function:def update(database, table, key): field = random.randrange(10) value = ''.join(random.choice(string.printable) for i in range(100)) with database.batch() as batch: batch.update(table=table, columns=('id', 'field%d' % field), valu...
[ "Does a single update operation." ]
Please provide a description of the function:def do_operation(database, keys, table, operation, latencies_ms): key = random.choice(keys) start = timeit.default_timer() if operation == 'read': read(database, table, key) elif operation == 'update': update(database, table, key) el...
[ "Does a single operation and records latency." ]
Please provide a description of the function:def aggregate_metrics(latencies_ms, duration_ms, num_bucket): overall_op_count = 0 op_counts = {operation : len(latency) for operation, latency in latencies_ms.iteritems()} overall_op_count = sum([op_count for op_count in op_counts.itervalue...
[ "Aggregates metrics." ]
Please provide a description of the function:def run_workload(database, keys, parameters): total_weight = 0.0 weights = [] operations = [] latencies_ms = {} for operation in OPERATIONS: weight = float(parameters[operation]) if weight <= 0.0: continue total_we...
[ "Runs workload against the database." ]
Please provide a description of the function:def run(self): i = 0 operation_count = int(self._parameters['operationcount']) while i < operation_count: i += 1 weight = random.uniform(0, self._total_weight) for j in range(len(self._weights)): ...
[ "Run a single thread of the workload." ]
Please provide a description of the function:def add_methods(source_class, blacklist=()): def wrap(wrapped_fx): # If this is a static or class method, then we need to *not* # send self as the first argument. # # Similarly, for instance methods, we need to send self.api...
[ "Add wrapped versions of the `api` member's methods to the class.\n\n Any methods passed in `blacklist` are not added.\n Additionally, any methods explicitly defined on the wrapped class are\n not added.\n ", "Wrap a GAPIC method; preserve its name and docstring." ]
Please provide a description of the function:def create_product( self, parent, product, product_id=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport met...
[ "\n Creates and returns a new product resource.\n\n Possible errors:\n\n - Returns INVALID\\_ARGUMENT if display\\_name is missing or longer than\n 4096 characters.\n - Returns INVALID\\_ARGUMENT if description is longer than 4096\n characters.\n - Returns I...
Please provide a description of the function:def update_product( self, product, update_mask=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to add retr...
[ "\n Makes changes to a Product resource. Only the ``display_name``,\n ``description``, and ``labels`` fields can be updated right now.\n\n If labels are updated, the change will not be reflected in queries until\n the next index time.\n\n Possible errors:\n\n - Returns NOT...
Please provide a description of the function:def _assign_entity_to_pb(entity_pb, entity): bare_entity_pb = helpers.entity_to_protobuf(entity) bare_entity_pb.key.CopyFrom(bare_entity_pb.key) entity_pb.CopyFrom(bare_entity_pb)
[ "Copy ``entity`` into ``entity_pb``.\n\n Helper method for ``Batch.put``.\n\n :type entity_pb: :class:`.entity_pb2.Entity`\n :param entity_pb: The entity owned by a mutation.\n\n :type entity: :class:`google.cloud.datastore.entity.Entity`\n :param entity: The entity being updated within the batch / t...
Please provide a description of the function:def _parse_commit_response(commit_response_pb): mut_results = commit_response_pb.mutation_results index_updates = commit_response_pb.index_updates completed_keys = [ mut_result.key for mut_result in mut_results if mut_result.HasField("key") ] # ...
[ "Extract response data from a commit response.\n\n :type commit_response_pb: :class:`.datastore_pb2.CommitResponse`\n :param commit_response_pb: The protobuf response from a commit request.\n\n :rtype: tuple\n :returns: The pair of the number of index updates and a list of\n :class:`.entity...
Please provide a description of the function:def _add_partial_key_entity_pb(self): new_mutation = _datastore_pb2.Mutation() self._mutations.append(new_mutation) return new_mutation.insert
[ "Adds a new mutation for an entity with a partial key.\n\n :rtype: :class:`.entity_pb2.Entity`\n :returns: The newly created entity protobuf that will be\n updated and sent with a commit.\n " ]
Please provide a description of the function:def _add_complete_key_entity_pb(self): # We use ``upsert`` for entities with completed keys, rather than # ``insert`` or ``update``, in order not to create race conditions # based on prior existence / removal of the entity. new_mutati...
[ "Adds a new mutation for an entity with a completed key.\n\n :rtype: :class:`.entity_pb2.Entity`\n :returns: The newly created entity protobuf that will be\n updated and sent with a commit.\n " ]
Please provide a description of the function:def _add_delete_key_pb(self): new_mutation = _datastore_pb2.Mutation() self._mutations.append(new_mutation) return new_mutation.delete
[ "Adds a new mutation for a key to be deleted.\n\n :rtype: :class:`.entity_pb2.Key`\n :returns: The newly created key protobuf that will be\n deleted when sent with a commit.\n " ]
Please provide a description of the function:def put(self, entity): if self._status != self._IN_PROGRESS: raise ValueError("Batch must be in progress to put()") if entity.key is None: raise ValueError("Entity must have a key") if self.project != entity.key.proj...
[ "Remember an entity's state to be saved during :meth:`commit`.\n\n .. note::\n Any existing properties for the entity will be replaced by those\n currently set on this instance. Already-stored properties which do\n not correspond to keys set on this instance will be removed fro...
Please provide a description of the function:def delete(self, key): if self._status != self._IN_PROGRESS: raise ValueError("Batch must be in progress to delete()") if key.is_partial: raise ValueError("Key must be complete") if self.project != key.project: ...
[ "Remember a key to be deleted during :meth:`commit`.\n\n :type key: :class:`google.cloud.datastore.key.Key`\n :param key: the key to be deleted.\n\n :raises: :class:`~exceptions.ValueError` if the batch is not in\n progress, if key is not complete, or if the key's\n ...
Please provide a description of the function:def begin(self): if self._status != self._INITIAL: raise ValueError("Batch already started previously.") self._status = self._IN_PROGRESS
[ "Begins a batch.\n\n This method is called automatically when entering a with\n statement, however it can be called explicitly if you don't want\n to use a context manager.\n\n Overridden by :class:`google.cloud.datastore.transaction.Transaction`.\n\n :raises: :class:`ValueError` ...
Please provide a description of the function:def _commit(self): if self._id is None: mode = _datastore_pb2.CommitRequest.NON_TRANSACTIONAL else: mode = _datastore_pb2.CommitRequest.TRANSACTIONAL commit_response_pb = self._client._datastore_api.commit( ...
[ "Commits the batch.\n\n This is called by :meth:`commit`.\n " ]
Please provide a description of the function:def commit(self): if self._status != self._IN_PROGRESS: raise ValueError("Batch must be in progress to commit()") try: self._commit() finally: self._status = self._FINISHED
[ "Commits the batch.\n\n This is called automatically upon exiting a with statement,\n however it can be called explicitly if you don't want to use a\n context manager.\n\n :raises: :class:`~exceptions.ValueError` if the batch is not\n in progress.\n " ]
Please provide a description of the function:def rollback(self): if self._status != self._IN_PROGRESS: raise ValueError("Batch must be in progress to rollback()") self._status = self._ABORTED
[ "Rolls back the current batch.\n\n Marks the batch as aborted (can't be used again).\n\n Overridden by :class:`google.cloud.datastore.transaction.Transaction`.\n\n :raises: :class:`~exceptions.ValueError` if the batch is not\n in progress.\n " ]
Please provide a description of the function:def snapshot_path(cls, project, instance, cluster, snapshot): return google.api_core.path_template.expand( "projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}", project=project, instance=instan...
[ "Return a fully-qualified snapshot string." ]
Please provide a description of the function:def create_table( self, parent, table_id, table, initial_splits=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap...
[ "\n Creates a new table in the specified instance.\n The table can be created with a full set of initial column families,\n specified in the request.\n\n Example:\n >>> from google.cloud import bigtable_admin_v2\n >>>\n >>> client = bigtable_admin_v2.Bigt...
Please provide a description of the function:def create_table_from_snapshot( self, parent, table_id, source_snapshot, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the ...
[ "\n Creates a new table from the specified snapshot. The target table must\n not exist. The snapshot and the table must be in the same instance.\n\n Note: This is a private alpha release of Cloud Bigtable snapshots. This\n feature is not currently available to most Cloud Bigtable custome...
Please provide a description of the function:def drop_row_range( self, name, row_key_prefix=None, delete_all_data_from_table=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): ...
[ "\n Permanently drop/delete a row range from a specified table. The request can\n specify whether to delete all rows in a table, or only those that match a\n particular prefix.\n\n Example:\n >>> from google.cloud import bigtable_admin_v2\n >>>\n >>> clie...
Please provide a description of the function:def snapshot_table( self, name, cluster, snapshot_id, description, ttl=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): ...
[ "\n Creates a new snapshot in the specified cluster from the specified\n source table. The cluster and the table must be in the same instance.\n\n Note: This is a private alpha release of Cloud Bigtable snapshots. This\n feature is not currently available to most Cloud Bigtable customers...
Please provide a description of the function:def company_path(cls, project, company): return google.api_core.path_template.expand( "projects/{project}/companies/{company}", project=project, company=company )
[ "Return a fully-qualified company string." ]
Please provide a description of the function:def create_company( self, parent, company, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to add retry and time...
[ "\n Creates a new company entity.\n\n Example:\n >>> from google.cloud import talent_v4beta1\n >>>\n >>> client = talent_v4beta1.CompanyServiceClient()\n >>>\n >>> parent = client.project_path('[PROJECT]')\n >>>\n >>> # TODO:...
Please provide a description of the function:def update_company( self, company, update_mask=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to add retr...
[ "\n Updates specified company.\n\n Example:\n >>> from google.cloud import talent_v4beta1\n >>>\n >>> client = talent_v4beta1.CompanyServiceClient()\n >>>\n >>> # TODO: Initialize `company`:\n >>> company = {}\n >>>\n ...
Please provide a description of the function:def delete_company( self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to add retry and timeout logic. ...
[ "\n Deletes specified company.\n Prerequisite: The company has no jobs associated with it.\n\n Example:\n >>> from google.cloud import talent_v4beta1\n >>>\n >>> client = talent_v4beta1.CompanyServiceClient()\n >>>\n >>> name = client.compa...
Please provide a description of the function:def quotas(self): path = "/projects/%s" % (self.project,) resp = self._connection.api_request(method="GET", path=path) return { key: int(value) for key, value in resp["quota"].items() if key != "kind" }
[ "Return DNS quotas for the project associated with this client.\n\n See\n https://cloud.google.com/dns/api/v1/projects/get\n\n :rtype: mapping\n :returns: keys for the mapping correspond to those of the ``quota``\n sub-mapping of the project resource.\n " ]
Please provide a description of the function:def list_zones(self, max_results=None, page_token=None): path = "/projects/%s/managedZones" % (self.project,) return page_iterator.HTTPIterator( client=self, api_request=self._connection.api_request, path=path, ...
[ "List zones for the project associated with this client.\n\n See\n https://cloud.google.com/dns/api/v1/managedZones/list\n\n :type max_results: int\n :param max_results: maximum number of zones to return, If not\n passed, defaults to a value set by the API.\n\n...
Please provide a description of the function:def zone(self, name, dns_name=None, description=None): return ManagedZone(name, dns_name, client=self, description=description)
[ "Construct a zone bound to this client.\n\n :type name: str\n :param name: Name of the zone.\n\n :type dns_name: str\n :param dns_name:\n (Optional) DNS name of the zone. If not passed, then calls to\n :meth:`zone.create` will fail.\n\n :type description: st...
Please provide a description of the function:def patch_traces(self, traces, project_id=None): if project_id is None: project_id = self.project self.trace_api.patch_traces(project_id=project_id, traces=traces)
[ "Sends new traces to Stackdriver Trace or updates existing traces.\n\n Args:\n traces (dict): Required. The traces to be patched in the API call.\n\n project_id (Optional[str]): ID of the Cloud project where the trace\n data is stored.\n " ]
Please provide a description of the function:def get_trace(self, trace_id, project_id=None): if project_id is None: project_id = self.project return self.trace_api.get_trace(project_id=project_id, trace_id=trace_id)
[ "\n Gets a single trace by its ID.\n\n Args:\n trace_id (str): ID of the trace to return.\n\n project_id (str): Required. ID of the Cloud project where the trace\n data is stored.\n\n Returns:\n A Trace dict.\n " ]
Please provide a description of the function:def list_traces( self, project_id=None, view=None, page_size=None, start_time=None, end_time=None, filter_=None, order_by=None, page_token=None, ): if project_id is None: ...
[ "\n Returns of a list of traces that match the filter conditions.\n\n Args:\n project_id (Optional[str]): ID of the Cloud project where the trace\n data is stored.\n\n view (Optional[~google.cloud.trace_v1.gapic.enums.\n ListTracesRequest.ViewType]):...
Please provide a description of the function:def parse_resume( self, parent, resume, region_code=None, language_code=None, options_=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None,...
[ "\n Parses a resume into a ``Profile``. The API attempts to fill out the\n following profile fields if present within the resume:\n\n - personNames\n - addresses\n - emailAddress\n - phoneNumbers\n - personalUris\n - employmentRecords\n - educati...
Please provide a description of the function:def update_model(client, model_id): # [START bigquery_update_model_description] from google.cloud import bigquery # TODO(developer): Construct a BigQuery client object. # client = bigquery.Client() # TODO(developer): Set model_id to the ID of the ...
[ "Sample ID: go/samples-tracker/1533" ]
Please provide a description of the function:def _pb_from_query(query): pb = query_pb2.Query() for projection_name in query.projection: pb.projection.add().property.name = projection_name if query.kind: pb.kind.add().name = query.kind composite_filter = pb.filter.composite_filter...
[ "Convert a Query instance to the corresponding protobuf.\n\n :type query: :class:`Query`\n :param query: The source query.\n\n :rtype: :class:`.query_pb2.Query`\n :returns: A protobuf that can be sent to the protobuf API. N.b. that\n it does not contain \"in-flight\" fields for ongoing que...
Please provide a description of the function:def namespace(self, value): if not isinstance(value, str): raise ValueError("Namespace must be a string") self._namespace = value
[ "Update the query's namespace.\n\n :type value: str\n " ]
Please provide a description of the function:def kind(self, value): if not isinstance(value, str): raise TypeError("Kind must be a string") self._kind = value
[ "Update the Kind of the Query.\n\n :type value: str\n :param value: updated kind for the query.\n\n .. note::\n\n The protobuf specification allows for ``kind`` to be repeated,\n but the current implementation returns an error if more than\n one value is passed. I...
Please provide a description of the function:def ancestor(self, value): if not isinstance(value, Key): raise TypeError("Ancestor must be a Key") self._ancestor = value
[ "Set the ancestor for the query\n\n :type value: :class:`~google.cloud.datastore.key.Key`\n :param value: the new ancestor key\n " ]
Please provide a description of the function:def add_filter(self, property_name, operator, value): if self.OPERATORS.get(operator) is None: error_message = 'Invalid expression: "%s"' % (operator,) choices_message = "Please use one of: =, <, <=, >, >=." raise ValueErr...
[ "Filter the query based on a property name, operator and a value.\n\n Expressions take the form of::\n\n .add_filter('<property>', '<operator>', <value>)\n\n where property is a property stored on the entity in the datastore\n and operator is one of ``OPERATORS``\n (ie, ``=``, `...
Please provide a description of the function:def projection(self, projection): if isinstance(projection, str): projection = [projection] self._projection[:] = projection
[ "Set the fields returned the query.\n\n :type projection: str or sequence of strings\n :param projection: Each value is a string giving the name of a\n property to be included in the projection query.\n " ]
Please provide a description of the function:def order(self, value): if isinstance(value, str): value = [value] self._order[:] = value
[ "Set the fields used to sort query results.\n\n Sort fields will be applied in the order specified.\n\n :type value: str or sequence of strings\n :param value: Each value is a string giving the name of the\n property on which to sort, optionally preceded by a\n ...
Please provide a description of the function:def distinct_on(self, value): if isinstance(value, str): value = [value] self._distinct_on[:] = value
[ "Set fields used to group query results.\n\n :type value: str or sequence of strings\n :param value: Each value is a string giving the name of a\n property to use to group results together.\n " ]
Please provide a description of the function:def fetch( self, limit=None, offset=0, start_cursor=None, end_cursor=None, client=None, eventual=False, ): if client is None: client = self._client return Iterator( ...
[ "Execute the Query; return an iterator for the matching entities.\n\n For example::\n\n >>> from google.cloud import datastore\n >>> client = datastore.Client()\n >>> query = client.query(kind='Person')\n >>> query.add_filter('name', '=', 'Sally')\n >>> list(query...
Please provide a description of the function:def _build_protobuf(self): pb = _pb_from_query(self._query) start_cursor = self.next_page_token if start_cursor is not None: pb.start_cursor = base64.urlsafe_b64decode(start_cursor) end_cursor = self._end_cursor ...
[ "Build a query protobuf.\n\n Relies on the current state of the iterator.\n\n :rtype:\n :class:`.query_pb2.Query`\n :returns: The query protobuf object for the current\n state of the iterator.\n " ]
Please provide a description of the function:def _process_query_results(self, response_pb): self._skipped_results = response_pb.batch.skipped_results if response_pb.batch.more_results == _NO_MORE_RESULTS: self.next_page_token = None else: self.next_page_token = ...
[ "Process the response from a datastore query.\n\n :type response_pb: :class:`.datastore_pb2.RunQueryResponse`\n :param response_pb: The protobuf response from a ``runQuery`` request.\n\n :rtype: iterable\n :returns: The next page of entity results.\n :raises ValueError: If ``more_...
Please provide a description of the function:def _next_page(self): if not self._more_results: return None query_pb = self._build_protobuf() transaction = self.client.current_transaction if transaction is None: transaction_id = None else: ...
[ "Get the next page in the iterator.\n\n :rtype: :class:`~google.cloud.iterator.Page`\n :returns: The next page in the iterator (or :data:`None` if\n there are no pages left).\n " ]
Please provide a description of the function:def _make_write_pb(table, columns, values): return Mutation.Write( table=table, columns=columns, values=_make_list_value_pbs(values) )
[ "Helper for :meth:`Batch.insert` et aliae.\n\n :type table: str\n :param table: Name of the table to be modified.\n\n :type columns: list of str\n :param columns: Name of the table columns to be modified.\n\n :type values: list of lists\n :param values: Values to be modified.\n\n :rtype: :class...
Please provide a description of the function:def update(self, table, columns, values): self._mutations.append(Mutation(update=_make_write_pb(table, columns, values)))
[ "Update one or more existing table rows.\n\n :type table: str\n :param table: Name of the table to be modified.\n\n :type columns: list of str\n :param columns: Name of the table columns to be modified.\n\n :type values: list of lists\n :param values: Values to be modified....
Please provide a description of the function:def delete(self, table, keyset): delete = Mutation.Delete(table=table, key_set=keyset._to_pb()) self._mutations.append(Mutation(delete=delete))
[ "Delete one or more table rows.\n\n :type table: str\n :param table: Name of the table to be modified.\n\n :type keyset: :class:`~google.cloud.spanner_v1.keyset.Keyset`\n :param keyset: Keys/ranges identifying rows to delete.\n " ]
Please provide a description of the function:def commit(self): self._check_state() database = self._session._database api = database.spanner_api metadata = _metadata_with_prefix(database.name) txn_options = TransactionOptions(read_write=TransactionOptions.ReadWrite()) ...
[ "Commit mutations to the database.\n\n :rtype: datetime\n :returns: timestamp of the committed changes.\n " ]
Please provide a description of the function:def dataset_exists(client, dataset_reference): from google.cloud.exceptions import NotFound try: client.get_dataset(dataset_reference) return True except NotFound: return False
[ "Return if a dataset exists.\n\n Args:\n client (google.cloud.bigquery.client.Client):\n A client to connect to the BigQuery API.\n dataset_reference (google.cloud.bigquery.dataset.DatasetReference):\n A reference to the dataset to look for.\n\n Returns:\n bool: ``Tr...
Please provide a description of the function:def table_exists(client, table_reference): from google.cloud.exceptions import NotFound try: client.get_table(table_reference) return True except NotFound: return False
[ "Return if a table exists.\n\n Args:\n client (google.cloud.bigquery.client.Client):\n A client to connect to the BigQuery API.\n table_reference (google.cloud.bigquery.table.TableReference):\n A reference to the table to look for.\n\n Returns:\n bool: ``True`` if th...
Please provide a description of the function:def run_query( self, project_id, partition_id, read_options=None, query=None, gql_query=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None...
[ "\n Queries for entities.\n\n Example:\n >>> from google.cloud import datastore_v1\n >>>\n >>> client = datastore_v1.DatastoreClient()\n >>>\n >>> # TODO: Initialize `project_id`:\n >>> project_id = ''\n >>>\n >>> ...
Please provide a description of the function:def commit( self, project_id, mode, mutations, transaction=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the ...
[ "\n Commits a transaction, optionally creating, deleting or modifying some\n entities.\n\n Example:\n >>> from google.cloud import datastore_v1\n >>> from google.cloud.datastore_v1 import enums\n >>>\n >>> client = datastore_v1.DatastoreClient()\n ...
Please provide a description of the function:def get_gae_resource(self): gae_resource = Resource( type="gae_app", labels={ "project_id": self.project_id, "module_id": self.module_id, "version_id": self.version_id, }, ...
[ "Return the GAE resource using the environment variables.\n\n :rtype: :class:`~google.cloud.logging.resource.Resource`\n :returns: Monitored resource for GAE.\n " ]
Please provide a description of the function:def get_gae_labels(self): gae_labels = {} trace_id = get_trace_id() if trace_id is not None: gae_labels[_TRACE_ID_LABEL] = trace_id return gae_labels
[ "Return the labels for GAE app.\n\n If the trace ID can be detected, it will be included as a label.\n Currently, no other labels are included.\n\n :rtype: dict\n :returns: Labels for GAE app.\n " ]
Please provide a description of the function:def emit(self, record): message = super(AppEngineHandler, self).format(record) gae_labels = self.get_gae_labels() trace_id = ( "projects/%s/traces/%s" % (self.project_id, gae_labels[_TRACE_ID_LABEL]) if _TRACE_ID_LABEL...
[ "Actually log the specified logging record.\n\n Overrides the default emit behavior of ``StreamHandler``.\n\n See https://docs.python.org/2/library/logging.html#handler-objects\n\n :type record: :class:`logging.LogRecord`\n :param record: The record to be logged.\n " ]
Please provide a description of the function:def service_account_path(cls, project, service_account): return google.api_core.path_template.expand( "projects/{project}/serviceAccounts/{service_account}", project=project, service_account=service_account, )
[ "Return a fully-qualified service_account string." ]
Please provide a description of the function:def generate_access_token( self, name, scope, delegates=None, lifetime=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): ...
[ "\n Generates an OAuth 2.0 access token for a service account.\n\n Example:\n >>> from google.cloud import iam_credentials_v1\n >>>\n >>> client = iam_credentials_v1.IAMCredentialsClient()\n >>>\n >>> name = client.service_account_path('[PROJECT]'...
Please provide a description of the function:def generate_id_token( self, name, audience, delegates=None, include_email=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): ...
[ "\n Generates an OpenID Connect ID token for a service account.\n\n Example:\n >>> from google.cloud import iam_credentials_v1\n >>>\n >>> client = iam_credentials_v1.IAMCredentialsClient()\n >>>\n >>> name = client.service_account_path('[PROJECT]...
Please provide a description of the function:def sign_blob( self, name, payload, delegates=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to a...
[ "\n Signs a blob using a service account's system-managed private key.\n\n Example:\n >>> from google.cloud import iam_credentials_v1\n >>>\n >>> client = iam_credentials_v1.IAMCredentialsClient()\n >>>\n >>> name = client.service_account_path('[P...
Please provide a description of the function:def generate_identity_binding_access_token( self, name, scope, jwt, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the trans...
[ "\n Exchange a JWT signed by third party identity provider to an OAuth 2.0\n access token\n\n Example:\n >>> from google.cloud import iam_credentials_v1\n >>>\n >>> client = iam_credentials_v1.IAMCredentialsClient()\n >>>\n >>> name = clien...
Please provide a description of the function:def entry_path(cls, project, location, entry_group, entry): return google.api_core.path_template.expand( "projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}", project=project, location=locati...
[ "Return a fully-qualified entry string." ]
Please provide a description of the function:def lookup_entry( self, linked_resource=None, sql_resource=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method...
[ "\n Get an entry by target resource name. This method allows clients to use\n the resource name from the source Google Cloud Platform service to get the\n Cloud Data Catalog Entry.\n\n Example:\n >>> from google.cloud import datacatalog_v1beta1\n >>>\n >>...
Please provide a description of the function:def _get_document_path(client, path): parts = (client._database_string, "documents") + path return _helpers.DOCUMENT_PATH_DELIMITER.join(parts)
[ "Convert a path tuple into a full path string.\n\n Of the form:\n\n ``projects/{project_id}/databases/{database_id}/...\n documents/{document_path}``\n\n Args:\n client (~.firestore_v1beta1.client.Client): The client that holds\n configuration details and a GAPIC client o...
Please provide a description of the function:def _consume_single_get(response_iterator): # Calling ``list()`` consumes the entire iterator. all_responses = list(response_iterator) if len(all_responses) != 1: raise ValueError( "Unexpected response from `BatchGetDocumentsResponse`", ...
[ "Consume a gRPC stream that should contain a single response.\n\n The stream will correspond to a ``BatchGetDocuments`` request made\n for a single document.\n\n Args:\n response_iterator (~google.cloud.exceptions.GrpcRendezvous): A\n streaming iterator returned from a ``BatchGetDocuments...
Please provide a description of the function:def _document_path(self): if self._document_path_internal is None: if self._client is None: raise ValueError("A document reference requires a `client`.") self._document_path_internal = _get_document_path(self._client, ...
[ "Create and cache the full path for this document.\n\n Of the form:\n\n ``projects/{project_id}/databases/{database_id}/...\n documents/{document_path}``\n\n Returns:\n str: The full document path.\n\n Raises:\n ValueError: If the current docume...
Please provide a description of the function:def collection(self, collection_id): child_path = self._path + (collection_id,) return self._client.collection(*child_path)
[ "Create a sub-collection underneath the current document.\n\n Args:\n collection_id (str): The sub-collection identifier (sometimes\n referred to as the \"kind\").\n\n Returns:\n ~.firestore_v1beta1.collection.CollectionReference: The\n child collection....
Please provide a description of the function:def create(self, document_data): batch = self._client.batch() batch.create(self, document_data) write_results = batch.commit() return _first_write_result(write_results)
[ "Create the current document in the Firestore database.\n\n Args:\n document_data (dict): Property names and values to use for\n creating a document.\n\n Returns:\n google.cloud.firestore_v1beta1.types.WriteResult: The\n write result corresponding to the...
Please provide a description of the function:def set(self, document_data, merge=False): batch = self._client.batch() batch.set(self, document_data, merge=merge) write_results = batch.commit() return _first_write_result(write_results)
[ "Replace the current document in the Firestore database.\n\n A write ``option`` can be specified to indicate preconditions of\n the \"set\" operation. If no ``option`` is specified and this document\n doesn't exist yet, this method will create it.\n\n Overwrites all content for the docum...
Please provide a description of the function:def update(self, field_updates, option=None): batch = self._client.batch() batch.update(self, field_updates, option=option) write_results = batch.commit() return _first_write_result(write_results)
[ "Update an existing document in the Firestore database.\n\n By default, this method verifies that the document exists on the\n server before making updates. A write ``option`` can be specified to\n override these preconditions.\n\n Each key in ``field_updates`` can either be a field name...
Please provide a description of the function:def delete(self, option=None): write_pb = _helpers.pb_for_delete(self._document_path, option) commit_response = self._client._firestore_api.commit( self._client._database_string, [write_pb], transaction=None, ...
[ "Delete the current document in the Firestore database.\n\n Args:\n option (Optional[~.firestore_v1beta1.client.WriteOption]): A\n write option to make assertions / preconditions on the server\n state of the document before applying changes.\n\n Returns:\n ...
Please provide a description of the function:def get(self, field_paths=None, transaction=None): if isinstance(field_paths, six.string_types): raise ValueError("'field_paths' must be a sequence of paths, not a string.") if field_paths is not None: mask = common_pb2.Docum...
[ "Retrieve a snapshot of the current document.\n\n See :meth:`~.firestore_v1beta1.client.Client.field_path` for\n more information on **field paths**.\n\n If a ``transaction`` is used and it already has write operations\n added, this method cannot be used (i.e. read-after-write is not\n ...
Please provide a description of the function:def collections(self, page_size=None): iterator = self._client._firestore_api.list_collection_ids( self._document_path, page_size=page_size, metadata=self._client._rpc_metadata, ) iterator.document = self ...
[ "List subcollections of the current document.\n\n Args:\n page_size (Optional[int]]): The maximum number of collections\n in each page of results from this request. Non-positive values\n are ignored. Defaults to a sensible value set by the API.\n\n Returns:\n ...
Please provide a description of the function:def get(self, field_path): if not self._exists: return None nested_data = field_path_module.get_nested_value(field_path, self._data) return copy.deepcopy(nested_data)
[ "Get a value from the snapshot data.\n\n If the data is nested, for example:\n\n .. code-block:: python\n\n >>> snapshot.to_dict()\n {\n 'top1': {\n 'middle2': {\n 'bottom3': 20,\n 'bottom4': 22,\n ...
Please provide a description of the function:def _delay_until_retry(exc, deadline): cause = exc.errors[0] now = time.time() if now >= deadline: raise delay = _get_retry_delay(cause) if delay is not None: if now + delay > deadline: raise time.sleep(delay)
[ "Helper for :meth:`Session.run_in_transaction`.\n\n Detect retryable abort, and impose server-supplied delay.\n\n :type exc: :class:`google.api_core.exceptions.Aborted`\n :param exc: exception for aborted transaction\n\n :type deadline: float\n :param deadline: maximum timestamp to continue retrying ...
Please provide a description of the function:def _get_retry_delay(cause): metadata = dict(cause.trailing_metadata()) retry_info_pb = metadata.get("google.rpc.retryinfo-bin") if retry_info_pb is not None: retry_info = RetryInfo() retry_info.ParseFromString(retry_info_pb) nanos = ...
[ "Helper for :func:`_delay_until_retry`.\n\n :type exc: :class:`grpc.Call`\n :param exc: exception for aborted transaction\n\n :rtype: float\n :returns: seconds to wait before retrying the transaction.\n " ]
Please provide a description of the function:def database_path(cls, project, instance, database): return google.api_core.path_template.expand( "projects/{project}/instances/{instance}/databases/{database}", project=project, instance=instance, database=dat...
[ "Return a fully-qualified database string." ]
Please provide a description of the function:def create_database( self, parent, create_statement, extra_statements=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap t...
[ "\n Creates a new Cloud Spanner database and starts to prepare it for\n serving. The returned ``long-running operation`` will have a name of the\n format ``<database_name>/operations/<operation_id>`` and can be used to\n track preparation of the database. The ``metadata`` field type is\n...
Please provide a description of the function:def update_database_ddl( self, database, statements, operation_id=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the t...
[ "\n Updates the schema of a Cloud Spanner database by\n creating/altering/dropping tables, columns, indexes, etc. The returned\n ``long-running operation`` will have a name of the format\n ``<database_name>/operations/<operation_id>`` and can be used to track\n execution of the sc...
Please provide a description of the function:def _get_scopes(self): if self._read_only: scopes = (READ_ONLY_SCOPE,) else: scopes = (DATA_SCOPE,) if self._admin: scopes += (ADMIN_SCOPE,) return scopes
[ "Get the scopes corresponding to admin / read-only state.\n\n Returns:\n Tuple[str, ...]: The tuple of scopes.\n " ]