Search is not available for this dataset
text
stringlengths
75
104k
def report_errors_api(self): """Helper for logging-related API calls. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.logs :rtype: :class:`_gapic._ErrorReportingGapicApi` ...
def _build_error_report( self, message, report_location=None, http_context=None, user=None ): """Builds the Error Reporting object to report. This builds the object according to https://cloud.google.com/error-reporting/docs/formatting-error-messages :type message: str ...
def _send_error_report( self, message, report_location=None, http_context=None, user=None ): """Makes the call to the Error Reporting API. This is the lower-level interface to build and send the payload, generally users will use either report() or report_exception() to autom...
def report(self, message, http_context=None, user=None): """ Reports a message to Stackdriver Error Reporting https://cloud.google.com/error-reporting/docs/formatting-error-messages :type message: str :param message: A user-supplied message to report :type http_context: :class...
def report_exception(self, http_context=None, user=None): """ Reports the details of the latest exceptions to Stackdriver Error Reporting. :type http_context: :class`google.cloud.error_reporting.HTTPContext` :param http_context: The HTTP request which was processed when the ...
def current(self): """Return the topmost transaction. .. note:: If the topmost element on the stack is not a transaction, returns None. :rtype: :class:`google.cloud.datastore.transaction.Transaction` or None :returns: The current transaction (if any are active)...
def begin(self): """Begins a transaction. This method is called automatically when entering a with statement, however it can be called explicitly if you don't want to use a context manager. :raises: :class:`~exceptions.ValueError` if the transaction has already...
def rollback(self): """Rolls back the current transaction. This method has necessary side-effects: - Sets the current transaction's ID to None. """ try: # No need to use the response it contains nothing. self._client._datastore_api.rollback(self.project,...
def put(self, entity): """Adds an entity to be committed. Ensures the transaction is not marked readonly. Please see documentation at :meth:`~google.cloud.datastore.batch.Batch.put` :type entity: :class:`~google.cloud.datastore.entity.Entity` :param entity: the entity t...
def list_findings( self, parent, filter_=None, order_by=None, read_time=None, field_mask=None, page_size=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """...
def from_api_repr(cls, resource, client): """Factory: construct a metric given its API representation :type resource: dict :param resource: metric resource representation returned from the API :type client: :class:`google.cloud.logging.client.Client` :param client: Client whic...
def create(self, client=None): """API call: create the metric via a PUT request See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/create :type client: :class:`~google.cloud.logging.client.Client` or ``NoneType`` :param client...
def exists(self, client=None): """API call: test for the existence of the metric via a GET request See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/get :type client: :class:`~google.cloud.logging.client.Client` or ``NoneType`` ...
def reload(self, client=None): """API call: sync local metric configuration via a GET request See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/get :type client: :class:`~google.cloud.logging.client.Client` or ``NoneType`` :p...
def update(self, client=None): """API call: update metric configuration via a PUT request See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/update :type client: :class:`~google.cloud.logging.client.Client` or ``NoneType`` :pa...
def delete(self, client=None): """API call: delete a metric via a DELETE request See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/delete :type client: :class:`~google.cloud.logging.client.Client` or ``NoneType`` :param clien...
def _dict_mapping_to_pb(mapping, proto_type): """ Convert a dict to protobuf. Args: mapping (dict): A dict that needs to be converted to protobuf. proto_type (str): The type of the Protobuf. Returns: An instance of the specified protobuf. """ converted_pb = getattr(trac...
def _span_attrs_to_pb(span_attr, proto_type): """ Convert a span attribute dict to protobuf, including Links, Attributes, TimeEvents. Args: span_attr (dict): A dict that needs to be converted to protobuf. proto_type (str): The type of the Protobuf. Returns: An instance of t...
def _value_to_pb(value, proto_type): """ Convert a value to protobuf. e.g. BoolValue, Int32Value. Args: value (dict): A dict that needs to be converted to protobuf. proto_type (str): The type of the Protobuf. Returns: An instance of the specified protobuf. """ data_type...
def batch_write_spans( self, name, spans, retry=method.DEFAULT, timeout=method.DEFAULT ): """ 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. At...
def create_span( self, name, span_id, display_name, start_time, end_time, parent_span_id=None, attributes=None, stack_trace=None, time_events=None, links=None, status=None, same_process_as_parent_span=None, c...
def from_pb(cls, cluster_pb, instance): """Creates an cluster instance from a protobuf. For example: .. literalinclude:: snippets.py :start-after: [START bigtable_cluster_from_pb] :end-before: [END bigtable_cluster_from_pb] :type cluster_pb: :class:`instance_pb...
def _update_from_pb(self, cluster_pb): """Refresh self from the server-provided protobuf. Helper for :meth:`from_pb` and :meth:`reload`. """ self.location_id = cluster_pb.location.split("/")[-1] self.serve_nodes = cluster_pb.serve_nodes self.default_storage_type = cluste...
def name(self): """Cluster name used in requests. .. note:: This property will not change if ``_instance`` and ``cluster_id`` do not, but the return value is not cached. For example: .. literalinclude:: snippets.py :start-after: [START bigtable_cluster_...
def reload(self): """Reload the metadata for this cluster. For example: .. literalinclude:: snippets.py :start-after: [START bigtable_reload_cluster] :end-before: [END bigtable_reload_cluster] """ cluster_pb = self._instance._client.instance_admin_client...
def exists(self): """Check whether the cluster already exists. For example: .. literalinclude:: snippets.py :start-after: [START bigtable_check_cluster_exists] :end-before: [END bigtable_check_cluster_exists] :rtype: bool :returns: True if the table exi...
def create(self): """Create this cluster. For example: .. literalinclude:: snippets.py :start-after: [START bigtable_create_cluster] :end-before: [END bigtable_create_cluster] .. note:: Uses the ``project``, ``instance`` and ``cluster_id`` on the ...
def update(self): """Update this cluster. For example: .. literalinclude:: snippets.py :start-after: [START bigtable_update_cluster] :end-before: [END bigtable_update_cluster] .. note:: Updates the ``serve_nodes``. If you'd like to chan...
def delete(self): """Delete this cluster. For example: .. literalinclude:: snippets.py :start-after: [START bigtable_delete_cluster] :end-before: [END bigtable_delete_cluster] Marks a cluster and all of its tables for permanent deletion in 7 days. Imme...
def _to_pb(self): """ Create cluster proto buff message for API calls """ client = self._instance._client location = client.instance_admin_client.location_path( client.project, self.location_id ) cluster_pb = instance_pb2.Cluster( location=location, ...
def from_pb(cls, cell_pb): """Create a new cell from a Cell protobuf. :type cell_pb: :class:`._generated.data_pb2.Cell` :param cell_pb: The protobuf to convert. :rtype: :class:`Cell` :returns: The cell corresponding to the protobuf. """ if cell_pb.labels: ...
def to_dict(self): """Convert the cells to a dictionary. This is intended to be used with HappyBase, so the column family and column qualiers are combined (with ``:``). :rtype: dict :returns: Dictionary containing all the data in the cells of this row. """ resul...
def find_cells(self, column_family_id, column): """Get a time series of cells stored on this instance. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_row_find_cells] :end-before: [END bigtable_row_find_cells] Args: ...
def cell_value(self, column_family_id, column, index=0): """Get a single cell value stored on this instance. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_row_cell_value] :end-before: [END bigtable_row_cell_value] Args: ...
def cell_values(self, column_family_id, column, max_count=None): """Get a time series of cells stored on this instance. For example: .. literalinclude:: snippets_table.py :start-after: [START bigtable_row_cell_values] :end-before: [END bigtable_row_cell_values] ...
def consume_all(self, max_loops=None): """Consume the streamed responses until there are no more. .. warning:: This method will be removed in future releases. Please use this class as a generator instead. :type max_loops: int :param max_loops: (Optional) Maximum ...
def _create_retry_request(self): """Helper for :meth:`__iter__`.""" req_manager = _ReadRowsRequestManager( self.request, self.last_scanned_row_key, self._counter ) return req_manager.build_updated_request()
def _on_error(self, exc): """Helper for :meth:`__iter__`.""" # restart the read scan from AFTER the last successfully read row retry_request = self.request if self.last_scanned_row_key: retry_request = self._create_retry_request() self.response_iterator = self.read_m...
def _save_current_cell(self): """Helper for :meth:`consume_next`.""" row, cell = self._row, self._cell family = row._cells.setdefault(cell.family_name, {}) qualified = family.setdefault(cell.qualifier, []) complete = Cell.from_pb(cell) qualified.append(complete) s...
def _copy_from_previous(self, cell): """Helper for :meth:`consume_next`.""" previous = self._previous_cell if previous is not None: if not cell.row_key: cell.row_key = previous.row_key if not cell.family_name: cell.family_name = pre...
def build_updated_request(self): """ Updates the given message request as per last scanned key """ r_kwargs = { "table_name": self.message.table_name, "filter": self.message.filter, } if self.message.rows_limit != 0: r_kwargs["rows_limit"] = m...
def _filter_rows_keys(self): """ Helper for :meth:`build_updated_request`""" return [ row_key for row_key in self.message.rows.row_keys if row_key > self.last_scanned_key ]
def _filter_row_ranges(self): """ Helper for :meth:`build_updated_request`""" new_row_ranges = [] for row_range in self.message.rows.row_ranges: # if current end_key (open or closed) is set, return its value, # if not, set to empty string (''). # NOTE: Empty ...
def patch_traces( self, project_id, traces, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a t...
def get_trace( self, project_id, trace_id, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Gets a single trace by its ID. Example: >>> from google.cloud import t...
def list_traces( self, project_id, view=None, page_size=None, start_time=None, end_time=None, filter_=None, order_by=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None...
def get_instance( self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Gets the details of a specific Redis instance. Example: >>> from google.cloud import redis_...
def update_instance( self, update_mask, instance, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Updates the metadata and configuration of a specific Redis instance. Comple...
def delete_instance( self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Deletes a specific Redis instance. Instance stops serving and data is deleted. Example: ...
def recognize( self, config, audio, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Performs synchronous speech recognition: receive results after all audio has been sent and...
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, ): """ Performs asynchronous speech recognition: receive results via the google.long...
def region_path(cls, project, region): """Return a fully-qualified region string.""" return google.api_core.path_template.expand( "projects/{project}/regions/{region}", project=project, region=region )
def workflow_template_path(cls, project, region, workflow_template): """Return a fully-qualified workflow_template string.""" return google.api_core.path_template.expand( "projects/{project}/regions/{region}/workflowTemplates/{workflow_template}", project=project, reg...
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, ): """ Creates new workflow template. Example: >>> from google.clo...
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, ): """ Retrieves the latest workflow template. Can retrieve previously instanti...
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, metadata=None, ): """ ...
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, ): """ Instantiates a te...
def _parse_schema_resource(info): """Parse a resource fragment into a schema field. Args: info: (Mapping[str->dict]): should contain a "fields" key to be parsed Returns: (Union[Sequence[:class:`google.cloud.bigquery.schema.SchemaField`],None]) a list of parsed fields, or ``None...
def from_api_repr(cls, api_repr): """Return a ``SchemaField`` object deserialized from a dictionary. Args: api_repr (Mapping[str, str]): The serialized representation of the SchemaField, such as what is output by :meth:`to_api_repr`. Returns: ...
def to_api_repr(self): """Return a dictionary representing this schema field. Returns: dict: A dictionary representing the SchemaField in a serialized form. """ # Put together the basic representation. See http://bit.ly/2hOAT5u. answer = { ...
def _key(self): """A tuple key that uniquely describes this field. Used to compute this instance's hashcode and evaluate equality. Returns: tuple: The contents of this :class:`~google.cloud.bigquery.schema.SchemaField`. """ return ( se...
def parse_options(): """Parses 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', default...
def open_database(parameters): """Opens a database specified by the parameters from parse_options().""" spanner_client = spanner.Client() instance_id = parameters['cloudspanner.instance'] instance = spanner_client.instance(instance_id) database_id = parameters['cloudspanner.database'] pool = spa...
def load_keys(database, parameters): """Loads keys from database.""" 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
def read(database, table, key): """Does a single read operation.""" 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 in range(...
def update(database, table, key): """Does a single update operation.""" 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), values=[(key...
def do_operation(database, keys, table, operation, latencies_ms): """Does a single operation and records latency.""" key = random.choice(keys) start = timeit.default_timer() if operation == 'read': read(database, table, key) elif operation == 'update': update(database, table, key) ...
def aggregate_metrics(latencies_ms, duration_ms, num_bucket): """Aggregates metrics.""" 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.itervalues()]) print('[O...
def run_workload(database, keys, parameters): """Runs workload against the database.""" total_weight = 0.0 weights = [] operations = [] latencies_ms = {} for operation in OPERATIONS: weight = float(parameters[operation]) if weight <= 0.0: continue total_weight...
def run(self): """Run a single thread of the workload.""" 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)): ...
def add_methods(source_class, blacklist=()): """Add wrapped versions of the `api` member's methods to the class. Any methods passed in `blacklist` are not added. Additionally, any methods explicitly defined on the wrapped class are not added. """ def wrap(wrapped_fx): """Wrap a GAPIC m...
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, ): """ Creates and returns a new product resource. Possible erro...
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, ): """ Makes changes to a Product resource. Only the ``display_name``, ``descrip...
def _assign_entity_to_pb(entity_pb, entity): """Copy ``entity`` into ``entity_pb``. Helper method for ``Batch.put``. :type entity_pb: :class:`.entity_pb2.Entity` :param entity_pb: The entity owned by a mutation. :type entity: :class:`google.cloud.datastore.entity.Entity` :param entity: The en...
def _parse_commit_response(commit_response_pb): """Extract response data from a commit response. :type commit_response_pb: :class:`.datastore_pb2.CommitResponse` :param commit_response_pb: The protobuf response from a commit request. :rtype: tuple :returns: The pair of the number of index updates ...
def _add_partial_key_entity_pb(self): """Adds a new mutation for an entity with a partial key. :rtype: :class:`.entity_pb2.Entity` :returns: The newly created entity protobuf that will be updated and sent with a commit. """ new_mutation = _datastore_pb2.Mutatio...
def _add_complete_key_entity_pb(self): """Adds a new mutation for an entity with a completed key. :rtype: :class:`.entity_pb2.Entity` :returns: The newly created entity protobuf that will be updated and sent with a commit. """ # We use ``upsert`` for entities w...
def _add_delete_key_pb(self): """Adds a new mutation for a key to be deleted. :rtype: :class:`.entity_pb2.Key` :returns: The newly created key protobuf that will be deleted when sent with a commit. """ new_mutation = _datastore_pb2.Mutation() self._muta...
def put(self, entity): """Remember an entity's state to be saved during :meth:`commit`. .. note:: Any existing properties for the entity will be replaced by those currently set on this instance. Already-stored properties which do not correspond to keys set on this inst...
def delete(self, key): """Remember a key to be deleted during :meth:`commit`. :type key: :class:`google.cloud.datastore.key.Key` :param key: the key to be deleted. :raises: :class:`~exceptions.ValueError` if the batch is not in progress, if key is not complete, or if t...
def begin(self): """Begins a batch. This method is called automatically when entering a with statement, however it can be called explicitly if you don't want to use a context manager. Overridden by :class:`google.cloud.datastore.transaction.Transaction`. :raises: :clas...
def _commit(self): """Commits the batch. This is called by :meth:`commit`. """ if self._id is None: mode = _datastore_pb2.CommitRequest.NON_TRANSACTIONAL else: mode = _datastore_pb2.CommitRequest.TRANSACTIONAL commit_response_pb = self._client._d...
def commit(self): """Commits the batch. This is called automatically upon exiting a with statement, however it can be called explicitly if you don't want to use a context manager. :raises: :class:`~exceptions.ValueError` if the batch is not in progress. ...
def rollback(self): """Rolls back the current batch. Marks the batch as aborted (can't be used again). Overridden by :class:`google.cloud.datastore.transaction.Transaction`. :raises: :class:`~exceptions.ValueError` if the batch is not in progress. """ ...
def snapshot_path(cls, project, instance, cluster, snapshot): """Return a fully-qualified snapshot string.""" return google.api_core.path_template.expand( "projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}", project=project, instance=inst...
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, ): """ Creates a new table in the specified instance. ...
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, ): """ Creates a new table from the specified snapshot. The ...
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, ): """ Permanently drop/delete a row range from...
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, ): """ Creates a new snapshot in the spe...
def company_path(cls, project, company): """Return a fully-qualified company string.""" return google.api_core.path_template.expand( "projects/{project}/companies/{company}", project=project, company=company )
def create_company( self, parent, company, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Creates a new company entity. Example: >>> from google.cloud import ta...
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, ): """ Updates specified company. Example: >>> from google.cloud im...
def delete_company( self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Deletes specified company. Prerequisite: The company has no jobs associated with it. Example:...
def quotas(self): """Return DNS quotas for the project associated with this client. See https://cloud.google.com/dns/api/v1/projects/get :rtype: mapping :returns: keys for the mapping correspond to those of the ``quota`` sub-mapping of the project resource. ...
def list_zones(self, max_results=None, page_token=None): """List zones for the project associated with this client. See https://cloud.google.com/dns/api/v1/managedZones/list :type max_results: int :param max_results: maximum number of zones to return, If not ...
def zone(self, name, dns_name=None, description=None): """Construct a zone bound to this client. :type name: str :param name: Name of the zone. :type dns_name: str :param dns_name: (Optional) DNS name of the zone. If not passed, then calls to :meth:`zon...
def patch_traces(self, traces, project_id=None): """Sends new traces to Stackdriver Trace or updates existing traces. Args: traces (dict): Required. The traces to be patched in the API call. project_id (Optional[str]): ID of the Cloud project where the trace dat...
def get_trace(self, trace_id, project_id=None): """ Gets a single trace by its ID. Args: trace_id (str): ID of the trace to return. project_id (str): Required. ID of the Cloud project where the trace data is stored. Returns: A Trace ...
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, ): """ Returns of a list of traces that match the filter conditions. Args:...
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, ): """ Parses a resume i...