Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def key_from_protobuf(pb): path_args = [] for element in pb.path: path_args.append(element.kind) if element.id: # Simple field (int64) path_args.append(element.id) # This is safe: we expect proto objects returned will only ha...
[ "Factory method for creating a key based on a protobuf.\n\n The protobuf should be one returned from the Cloud Datastore\n Protobuf API.\n\n :type pb: :class:`.entity_pb2.Key`\n :param pb: The Protobuf representing the key.\n\n :rtype: :class:`google.cloud.datastore.key.Key`\n :returns: a new `Key...
Please provide a description of the function:def _pb_attr_value(val): if isinstance(val, datetime.datetime): name = "timestamp" value = _datetime_to_pb_timestamp(val) elif isinstance(val, Key): name, value = "key", val.to_protobuf() elif isinstance(val, bool): name, val...
[ "Given a value, return the protobuf attribute name and proper value.\n\n The Protobuf API uses different attribute names based on value types\n rather than inferring the type. This function simply determines the\n proper attribute name based on the type of the value provided and\n returns the attribute...
Please provide a description of the function:def _get_value_from_value_pb(value_pb): value_type = value_pb.WhichOneof("value_type") if value_type == "timestamp_value": result = _pb_timestamp_to_datetime(value_pb.timestamp_value) elif value_type == "key_value": result = key_from_protob...
[ "Given a protobuf for a Value, get the correct value.\n\n The Cloud Datastore Protobuf API returns a Property Protobuf which\n has one value set and the rest blank. This function retrieves the\n the one value provided.\n\n Some work is done to coerce the return value into a more useful type\n (parti...
Please provide a description of the function:def _set_protobuf_value(value_pb, val): attr, val = _pb_attr_value(val) if attr == "key_value": value_pb.key_value.CopyFrom(val) elif attr == "timestamp_value": value_pb.timestamp_value.CopyFrom(val) elif attr == "entity_value": e...
[ "Assign 'val' to the correct subfield of 'value_pb'.\n\n The Protobuf API uses different attribute names based on value types\n rather than inferring the type.\n\n Some value types (entities, keys, lists) cannot be directly\n assigned; this function handles them correctly.\n\n :type value_pb: :class:...
Please provide a description of the function:def to_protobuf(self): return latlng_pb2.LatLng(latitude=self.latitude, longitude=self.longitude)
[ "Convert the current object to protobuf.\n\n :rtype: :class:`google.type.latlng_pb2.LatLng`.\n :returns: The current point as a protobuf.\n " ]
Please provide a description of the function:def from_api_repr(cls, resource, client, loggers=None): if loggers is None: loggers = {} logger_fullname = resource["logName"] logger = loggers.get(logger_fullname) if logger is None: logger_name = logger_name_...
[ "Factory: construct an entry given its API representation\n\n :type resource: dict\n :param resource: text entry resource representation returned from\n the API\n\n :type client: :class:`google.cloud.logging.client.Client`\n :param client: Client which holds cred...
Please provide a description of the function:def to_api_repr(self): info = {} if self.log_name is not None: info["logName"] = self.log_name if self.resource is not None: info["resource"] = self.resource._to_dict() if self.labels is not None: i...
[ "API repr (JSON format) for entry.\n " ]
Please provide a description of the function:def to_api_repr(self): info = super(TextEntry, self).to_api_repr() info["textPayload"] = self.payload return info
[ "API repr (JSON format) for entry.\n " ]
Please provide a description of the function:def to_api_repr(self): info = super(StructEntry, self).to_api_repr() info["jsonPayload"] = self.payload return info
[ "API repr (JSON format) for entry.\n " ]
Please provide a description of the function:def to_api_repr(self): info = super(ProtobufEntry, self).to_api_repr() info["protoPayload"] = MessageToDict(self.payload) return info
[ "API repr (JSON format) for entry.\n " ]
Please provide a description of the function:def TimeFromTicks(ticks, tz=None): dt = datetime.datetime.fromtimestamp(ticks, tz=tz) return dt.timetz()
[ "Construct a DB-API time value from the given ticks value.\n\n :type ticks: float\n :param ticks:\n a number of seconds since the epoch; see the documentation of the\n standard Python time module for details.\n\n :type tz: :class:`datetime.tzinfo`\n :param tz: (Optional) time zone to use f...
Please provide a description of the function:def registry_path(cls, project, location, registry): return google.api_core.path_template.expand( "projects/{project}/locations/{location}/registries/{registry}", project=project, location=location, registry=re...
[ "Return a fully-qualified registry string." ]
Please provide a description of the function:def device_path(cls, project, location, registry, device): return google.api_core.path_template.expand( "projects/{project}/locations/{location}/registries/{registry}/devices/{device}", project=project, location=location, ...
[ "Return a fully-qualified device string." ]
Please provide a description of the function:def create_device( self, parent, device, 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 timeou...
[ "\n Creates a device in a device registry.\n\n Example:\n >>> from google.cloud import iot_v1\n >>>\n >>> client = iot_v1.DeviceManagerClient()\n >>>\n >>> parent = client.registry_path('[PROJECT]', '[LOCATION]', '[REGISTRY]')\n >>>\n ...
Please provide a description of the function:def set_iam_policy( self, resource, policy, 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 tim...
[ "\n Sets the access control policy on the specified resource. Replaces any\n existing policy.\n\n Example:\n >>> from google.cloud import iot_v1\n >>>\n >>> client = iot_v1.DeviceManagerClient()\n >>>\n >>> resource = client.registry_path('...
Please provide a description of the function:def bind_device_to_gateway( self, parent, gateway_id, device_id, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transpor...
[ "\n Associates the device with the gateway.\n\n Example:\n >>> from google.cloud import iot_v1\n >>>\n >>> client = iot_v1.DeviceManagerClient()\n >>>\n >>> parent = client.registry_path('[PROJECT]', '[LOCATION]', '[REGISTRY]')\n >>>\n ...
Please provide a description of the function:def queue_path(cls, project, location, queue): return google.api_core.path_template.expand( "projects/{project}/locations/{location}/queues/{queue}", project=project, location=location, queue=queue, )
[ "Return a fully-qualified queue string." ]
Please provide a description of the function:def task_path(cls, project, location, queue, task): return google.api_core.path_template.expand( "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}", project=project, location=location, queue=...
[ "Return a fully-qualified task string." ]
Please provide a description of the function:def create_queue( self, parent, queue, 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 ...
[ "\n Creates a queue.\n\n Queues created with this method allow tasks to live for a maximum of 31\n days. After a task is 31 days old, the task will be deleted regardless\n of whether it was dispatched or not.\n\n WARNING: Using this method may have unintended side effects if you a...
Please provide a description of the function:def create_task( self, parent, task, response_view=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method...
[ "\n Creates a task and adds it to a queue.\n\n Tasks cannot be updated after creation; there is no UpdateTask command.\n\n - For ``App Engine queues``, the maximum task size is 100KB.\n\n Example:\n >>> from google.cloud import tasks_v2\n >>>\n >>> clien...
Please provide a description of the function:def _exponential_timeout_generator(initial, maximum, multiplier, deadline): if deadline is not None: deadline_datetime = datetime_helpers.utcnow() + datetime.timedelta( seconds=deadline ) else: deadline_datetime = datetime.dat...
[ "A generator that yields exponential timeout values.\n\n Args:\n initial (float): The initial timeout.\n maximum (float): The maximum timeout.\n multiplier (float): The multiplier applied to the timeout.\n deadline (float): The overall deadline across all invocations.\n\n Yields:\n...
Please provide a description of the function:def _format_operation_list(operation, parameters): formatted_params = ["?" for _ in parameters] try: return operation % tuple(formatted_params) except TypeError as exc: raise exceptions.ProgrammingError(exc)
[ "Formats parameters in operation in the way BigQuery expects.\n\n The input operation will be a query like ``SELECT %s`` and the output\n will be a query like ``SELECT ?``.\n\n :type operation: str\n :param operation: A Google BigQuery query string.\n\n :type parameters: Sequence[Any]\n :param par...
Please provide a description of the function:def _format_operation_dict(operation, parameters): formatted_params = {} for name in parameters: escaped_name = name.replace("`", r"\`") formatted_params[name] = "@`{}`".format(escaped_name) try: return operation % formatted_params ...
[ "Formats parameters in operation in the way BigQuery expects.\n\n The input operation will be a query like ``SELECT %(namedparam)s`` and\n the output will be a query like ``SELECT @namedparam``.\n\n :type operation: str\n :param operation: A Google BigQuery query string.\n\n :type parameters: Mapping...
Please provide a description of the function:def _format_operation(operation, parameters=None): if parameters is None: return operation if isinstance(parameters, collections_abc.Mapping): return _format_operation_dict(operation, parameters) return _format_operation_list(operation, par...
[ "Formats parameters in operation in way BigQuery expects.\n\n :type: str\n :param operation: A Google BigQuery query string.\n\n :type: Mapping[str, Any] or Sequence[Any]\n :param parameters: Optional parameter values.\n\n :rtype: str\n :returns: A formatted query string.\n :raises: :class:`~go...
Please provide a description of the function:def _set_description(self, schema): if schema is None: self.description = None return self.description = tuple( [ Column( name=field.name, type_code=field.fi...
[ "Set description from schema.\n\n :type schema: Sequence[google.cloud.bigquery.schema.SchemaField]\n :param schema: A description of fields in the schema.\n " ]
Please provide a description of the function:def _set_rowcount(self, query_results): total_rows = 0 num_dml_affected_rows = query_results.num_dml_affected_rows if query_results.total_rows is not None and query_results.total_rows > 0: total_rows = query_results.total_rows ...
[ "Set the rowcount from query results.\n\n Normally, this sets rowcount to the number of rows returned by the\n query, but if it was a DML statement, it sets rowcount to the number\n of modified rows.\n\n :type query_results:\n :class:`~google.cloud.bigquery.query._QueryResults...
Please provide a description of the function:def execute(self, operation, parameters=None, job_id=None): self._query_data = None self._query_job = None client = self.connection._client # The DB-API uses the pyformat formatting, since the way BigQuery does # query parame...
[ "Prepare and execute a database operation.\n\n .. note::\n When setting query parameters, values which are \"text\"\n (``unicode`` in Python2, ``str`` in Python3) will use\n the 'STRING' BigQuery type. Values which are \"bytes\" (``str`` in\n Python2, ``bytes`` in ...
Please provide a description of the function:def _try_fetch(self, size=None): if self._query_job is None: raise exceptions.InterfaceError( "No query results: execute() must be called before fetch." ) is_dml = ( self._query_job.statement_type ...
[ "Try to start fetching data, if not yet started.\n\n Mutates self to indicate that iteration has started.\n " ]
Please provide a description of the function:def fetchmany(self, size=None): if size is None: size = self.arraysize self._try_fetch(size=size) rows = [] for row in self._query_data: rows.append(row) if len(rows) >= size: brea...
[ "Fetch multiple results from the last ``execute*()`` call.\n\n .. note::\n The size parameter is not used for the request/response size.\n Set the ``arraysize`` attribute before calling ``execute()`` to\n set the batch size.\n\n :type size: int\n :param size:\n ...
Please provide a description of the function:def create_channel(cls, address="spanner.googleapis.com:443", credentials=None): grpc_gcp_config = grpc_gcp.api_config_from_text_pb( pkg_resources.resource_string(__name__, _SPANNER_GRPC_CONFIG) ) options = [(grpc_gcp.API_CONFIG_C...
[ "Create and return a gRPC channel object.\n\n Args:\n address (str): The host for the channel to use.\n credentials (~.Credentials): The\n authorization credentials to attach to requests. These\n credentials identify this application to the service. If\n ...
Please provide a description of the function:def _update_from_api_repr(self, resource): self.destination = resource["destination"] self.filter_ = resource.get("filter") self._writer_identity = resource.get("writerIdentity")
[ "Helper for API methods returning sink resources." ]
Please provide a description of the function:def from_api_repr(cls, resource, client): sink_name = resource["name"] instance = cls(sink_name, client=client) instance._update_from_api_repr(resource) return instance
[ "Factory: construct a sink given its API representation\n\n :type resource: dict\n :param resource: sink resource representation returned from the API\n\n :type client: :class:`google.cloud.logging.client.Client`\n :param client: Client which holds credentials and project\n ...
Please provide a description of the function:def create(self, client=None, unique_writer_identity=False): client = self._require_client(client) resource = client.sinks_api.sink_create( self.project, self.name, self.filter_, self.destination, ...
[ "API call: create the sink via a PUT request\n\n See\n https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/create\n\n :type client: :class:`~google.cloud.logging.client.Client` or\n ``NoneType``\n :param client: the client to use. If not passe...
Please provide a description of the function:def exists(self, client=None): client = self._require_client(client) try: client.sinks_api.sink_get(self.project, self.name) except NotFound: return False else: return True
[ "API call: test for the existence of the sink via a GET request\n\n See\n https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get\n\n :type client: :class:`~google.cloud.logging.client.Client` or\n ``NoneType``\n :param client: the client to us...
Please provide a description of the function:def reload(self, client=None): client = self._require_client(client) resource = client.sinks_api.sink_get(self.project, self.name) self._update_from_api_repr(resource)
[ "API call: sync local sink configuration via a GET request\n\n See\n https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get\n\n :type client: :class:`~google.cloud.logging.client.Client` or\n ``NoneType``\n :param client: the client to use. I...
Please provide a description of the function:def update(self, client=None, unique_writer_identity=False): client = self._require_client(client) resource = client.sinks_api.sink_update( self.project, self.name, self.filter_, self.destination, ...
[ "API call: update sink configuration via a PUT request\n\n See\n https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/update\n\n :type client: :class:`~google.cloud.logging.client.Client` or\n ``NoneType``\n :param client: the client to use. If...
Please provide a description of the function:def delete(self, client=None): client = self._require_client(client) client.sinks_api.sink_delete(self.project, self.name)
[ "API call: delete a sink via a DELETE request\n\n See\n https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/delete\n\n :type client: :class:`~google.cloud.logging.client.Client` or\n ``NoneType``\n :param client: the client to use. If not pass...
Please provide a description of the function:def _merge_float64(lhs, rhs, type_): # pylint: disable=unused-argument lhs_kind = lhs.WhichOneof("kind") if lhs_kind == "string_value": return Value(string_value=lhs.string_value + rhs.string_value) rhs_kind = rhs.WhichOneof("kind") array_contin...
[ "Helper for '_merge_by_type'." ]
Please provide a description of the function:def _merge_string(lhs, rhs, type_): # pylint: disable=unused-argument return Value(string_value=lhs.string_value + rhs.string_value)
[ "Helper for '_merge_by_type'." ]
Please provide a description of the function:def _merge_array(lhs, rhs, type_): element_type = type_.array_element_type if element_type.code in _UNMERGEABLE_TYPES: # Individual values cannot be merged, just concatenate lhs.list_value.values.extend(rhs.list_value.values) return lhs ...
[ "Helper for '_merge_by_type'." ]
Please provide a description of the function:def _merge_struct(lhs, rhs, type_): fields = type_.struct_type.fields lhs, rhs = list(lhs.list_value.values), list(rhs.list_value.values) candidate_type = fields[len(lhs) - 1].type first = rhs.pop(0) if first.HasField("null_value") or candidate_type....
[ "Helper for '_merge_by_type'." ]
Please provide a description of the function:def _merge_by_type(lhs, rhs, type_): merger = _MERGE_BY_TYPE[type_.code] return merger(lhs, rhs, type_)
[ "Helper for '_merge_chunk'." ]
Please provide a description of the function:def _merge_chunk(self, value): current_column = len(self._current_row) field = self.fields[current_column] merged = _merge_by_type(self._pending_chunk, value, field.type) self._pending_chunk = None return merged
[ "Merge pending chunk with next value.\n\n :type value: :class:`~google.protobuf.struct_pb2.Value`\n :param value: continuation of chunked value from previous\n partial result set.\n\n :rtype: :class:`~google.protobuf.struct_pb2.Value`\n :returns: the merged value\n ...
Please provide a description of the function:def _merge_values(self, values): width = len(self.fields) for value in values: index = len(self._current_row) field = self.fields[index] self._current_row.append(_parse_value_pb(value, field.type)) if l...
[ "Merge values into rows.\n\n :type values: list of :class:`~google.protobuf.struct_pb2.Value`\n :param values: non-chunked values from partial result set.\n " ]
Please provide a description of the function:def _consume_next(self): response = six.next(self._response_iterator) self._counter += 1 if self._metadata is None: # first response metadata = self._metadata = response.metadata source = self._source if...
[ "Consume the next partial result set from the stream.\n\n Parse the result set into new/existing rows in :attr:`_rows`\n " ]
Please provide a description of the function:def one_or_none(self): # Sanity check: Has consumption of this query already started? # If it has, then this is an exception. if self._metadata is not None: raise RuntimeError( "Can not call `.one` or `.one_or_none...
[ "Return exactly one result, or None if there are no results.\n\n :raises: :exc:`ValueError`: If there are multiple results.\n :raises: :exc:`RuntimeError`: If consumption has already occurred,\n in whole or in part.\n " ]
Please provide a description of the function:def product_set_path(cls, project, location, product_set): return google.api_core.path_template.expand( "projects/{project}/locations/{location}/productSets/{product_set}", project=project, location=location, p...
[ "Return a fully-qualified product_set string." ]
Please provide a description of the function:def product_path(cls, project, location, product): return google.api_core.path_template.expand( "projects/{project}/locations/{location}/products/{product}", project=project, location=location, product=product,...
[ "Return a fully-qualified product string." ]
Please provide a description of the function:def reference_image_path(cls, project, location, product, reference_image): return google.api_core.path_template.expand( "projects/{project}/locations/{location}/products/{product}/referenceImages/{reference_image}", project=project, ...
[ "Return a fully-qualified reference_image string." ]
Please provide a description of the function:def create_product_set( self, parent, product_set, product_set_id, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transp...
[ "\n Creates and returns a new ProductSet resource.\n\n Possible errors:\n\n - Returns INVALID\\_ARGUMENT if display\\_name is missing, or is longer\n than 4096 characters.\n\n Example:\n >>> from google.cloud import vision_v1p3beta1\n >>>\n >>>...
Please provide a description of the function:def create_reference_image( self, parent, reference_image, reference_image_id, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wra...
[ "\n Creates and returns a new ReferenceImage resource.\n\n The ``bounding_poly`` field is optional. If ``bounding_poly`` is not\n specified, the system will try to detect regions of interest in the\n image that are compatible with the product\\_category on the parent\n product. If...
Please provide a description of the function:def import_product_sets( self, parent, input_config, 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 Asynchronous API that imports a list of reference images to specified\n product sets based on a list of image information.\n\n The ``google.longrunning.Operation`` API can be used to keep track of\n the progress and results of the request. ``Operation.metadata`` contains\n ``B...
Please provide a description of the function:def _parse_log_entry(entry_pb): try: return MessageToDict(entry_pb) except TypeError: if entry_pb.HasField("proto_payload"): proto_payload = entry_pb.proto_payload entry_pb.ClearField("proto_payload") entry_map...
[ "Special helper to parse ``LogEntry`` protobuf into a dictionary.\n\n The ``proto_payload`` field in ``LogEntry`` is of type ``Any``. This\n can be problematic if the type URL in the payload isn't in the\n ``google.protobuf`` registry. To help with parsing unregistered types,\n this function will remove...
Please provide a description of the function:def _item_to_entry(iterator, entry_pb, loggers): resource = _parse_log_entry(entry_pb) return entry_from_resource(resource, iterator.client, loggers)
[ "Convert a log entry protobuf to the native object.\n\n .. note::\n\n This method does not have the correct signature to be used as\n the ``item_to_value`` argument to\n :class:`~google.api_core.page_iterator.Iterator`. It is intended to be\n patched with a mutable ``loggers`` argumen...
Please provide a description of the function:def _item_to_sink(iterator, log_sink_pb): # NOTE: LogSink message type does not have an ``Any`` field # so `MessageToDict`` can safely be used. resource = MessageToDict(log_sink_pb) return Sink.from_api_repr(resource, iterator.client)
[ "Convert a sink protobuf to the native object.\n\n :type iterator: :class:`~google.api_core.page_iterator.Iterator`\n :param iterator: The iterator that is currently in use.\n\n :type log_sink_pb:\n :class:`.logging_config_pb2.LogSink`\n :param log_sink_pb: Sink protobuf returned from the API.\n\...
Please provide a description of the function:def _item_to_metric(iterator, log_metric_pb): # NOTE: LogMetric message type does not have an ``Any`` field # so `MessageToDict`` can safely be used. resource = MessageToDict(log_metric_pb) return Metric.from_api_repr(resource, iterator.client)
[ "Convert a metric protobuf to the native object.\n\n :type iterator: :class:`~google.api_core.page_iterator.Iterator`\n :param iterator: The iterator that is currently in use.\n\n :type log_metric_pb:\n :class:`.logging_metrics_pb2.LogMetric`\n :param log_metric_pb: Metric protobuf returned from ...
Please provide a description of the function:def make_logging_api(client): generated = LoggingServiceV2Client( credentials=client._credentials, client_info=_CLIENT_INFO ) return _LoggingAPI(generated, client)
[ "Create an instance of the Logging API adapter.\n\n :type client: :class:`~google.cloud.logging.client.Client`\n :param client: The client that holds configuration details.\n\n :rtype: :class:`_LoggingAPI`\n :returns: A metrics API instance with the proper credentials.\n " ]
Please provide a description of the function:def make_metrics_api(client): generated = MetricsServiceV2Client( credentials=client._credentials, client_info=_CLIENT_INFO ) return _MetricsAPI(generated, client)
[ "Create an instance of the Metrics API adapter.\n\n :type client: :class:`~google.cloud.logging.client.Client`\n :param client: The client that holds configuration details.\n\n :rtype: :class:`_MetricsAPI`\n :returns: A metrics API instance with the proper credentials.\n " ]
Please provide a description of the function:def make_sinks_api(client): generated = ConfigServiceV2Client( credentials=client._credentials, client_info=_CLIENT_INFO ) return _SinksAPI(generated, client)
[ "Create an instance of the Sinks API adapter.\n\n :type client: :class:`~google.cloud.logging.client.Client`\n :param client: The client that holds configuration details.\n\n :rtype: :class:`_SinksAPI`\n :returns: A metrics API instance with the proper credentials.\n " ]
Please provide a description of the function:def list_entries( self, projects, filter_="", order_by="", page_size=0, page_token=None ): page_iter = self._gapic_api.list_log_entries( [], project_ids=projects, filter_=filter_, order_by=order_by,...
[ "Return a page of log entry resources.\n\n :type projects: list of strings\n :param projects: project IDs to include. If not passed,\n defaults to the project bound to the API's client.\n\n :type filter_: str\n :param filter_:\n a filter expression. See...
Please provide a description of the function:def write_entries(self, entries, logger_name=None, resource=None, labels=None): partial_success = False entry_pbs = [_log_entry_mapping_to_pb(entry) for entry in entries] self._gapic_api.write_log_entries( entry_pbs, l...
[ "API call: log an entry resource via a POST request\n\n :type entries: sequence of mapping\n :param entries: the log entry resources to log.\n\n :type logger_name: str\n :param logger_name: name of default logger to which to log the entries;\n individual entri...
Please provide a description of the function:def logger_delete(self, project, logger_name): path = "projects/%s/logs/%s" % (project, logger_name) self._gapic_api.delete_log(path)
[ "API call: delete all entries in a logger via a DELETE request\n\n :type project: str\n :param project: ID of project containing the log entries to delete\n\n :type logger_name: str\n :param logger_name: name of logger containing the log entries to delete\n " ]
Please provide a description of the function:def list_sinks(self, project, page_size=0, page_token=None): path = "projects/%s" % (project,) page_iter = self._gapic_api.list_sinks(path, page_size=page_size) page_iter.client = self._client page_iter.next_page_token = page_token ...
[ "List sinks for the project associated with this client.\n\n :type project: str\n :param project: ID of the project whose sinks are to be listed.\n\n :type page_size: int\n :param page_size: maximum number of sinks to return, If not passed,\n defaults to a value ...
Please provide a description of the function:def sink_create( self, project, sink_name, filter_, destination, unique_writer_identity=False ): parent = "projects/%s" % (project,) sink_pb = LogSink(name=sink_name, filter=filter_, destination=destination) created_pb = self._gap...
[ "API call: create a sink resource.\n\n See\n https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/create\n\n :type project: str\n :param project: ID of the project in which to create the sink.\n\n :type sink_name: str\n :param sink_name: the name of th...
Please provide a description of the function:def sink_get(self, project, sink_name): path = "projects/%s/sinks/%s" % (project, sink_name) sink_pb = self._gapic_api.get_sink(path) # NOTE: LogSink message type does not have an ``Any`` field # so `MessageToDict`` can safely b...
[ "API call: retrieve a sink resource.\n\n :type project: str\n :param project: ID of the project containing the sink.\n\n :type sink_name: str\n :param sink_name: the name of the sink\n\n :rtype: dict\n :returns: The sink object returned from the API (converted from a\n ...
Please provide a description of the function:def sink_update( self, project, sink_name, filter_, destination, unique_writer_identity=False ): path = "projects/%s/sinks/%s" % (project, sink_name) sink_pb = LogSink(name=path, filter=filter_, destination=destination) sink_pb = ...
[ "API call: update a sink resource.\n\n :type project: str\n :param project: ID of the project containing the sink.\n\n :type sink_name: str\n :param sink_name: the name of the sink\n\n :type filter_: str\n :param filter_: the advanced logs filter expression defining the\n ...
Please provide a description of the function:def sink_delete(self, project, sink_name): path = "projects/%s/sinks/%s" % (project, sink_name) self._gapic_api.delete_sink(path)
[ "API call: delete a sink resource.\n\n :type project: str\n :param project: ID of the project containing the sink.\n\n :type sink_name: str\n :param sink_name: the name of the sink\n " ]
Please provide a description of the function:def list_metrics(self, project, page_size=0, page_token=None): path = "projects/%s" % (project,) page_iter = self._gapic_api.list_log_metrics(path, page_size=page_size) page_iter.client = self._client page_iter.next_page_token = page_...
[ "List metrics for the project associated with this client.\n\n :type project: str\n :param project: ID of the project whose metrics are to be listed.\n\n :type page_size: int\n :param page_size: maximum number of metrics to return, If not passed,\n defaults to a ...
Please provide a description of the function:def metric_create(self, project, metric_name, filter_, description): parent = "projects/%s" % (project,) metric_pb = LogMetric(name=metric_name, filter=filter_, description=description) self._gapic_api.create_log_metric(parent, metric_pb)
[ "API call: create a metric resource.\n\n See\n https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/create\n\n :type project: str\n :param project: ID of the project in which to create the metric.\n\n :type metric_name: str\n :param metric_name: the ...
Please provide a description of the function:def metric_get(self, project, metric_name): path = "projects/%s/metrics/%s" % (project, metric_name) metric_pb = self._gapic_api.get_log_metric(path) # NOTE: LogMetric message type does not have an ``Any`` field # so `MessageToD...
[ "API call: retrieve a metric resource.\n\n :type project: str\n :param project: ID of the project containing the metric.\n\n :type metric_name: str\n :param metric_name: the name of the metric\n\n :rtype: dict\n :returns: The metric object returned from the API (converted ...
Please provide a description of the function:def metric_update(self, project, metric_name, filter_, description): path = "projects/%s/metrics/%s" % (project, metric_name) metric_pb = LogMetric(name=path, filter=filter_, description=description) metric_pb = self._gapic_api.update_log_met...
[ "API call: update a metric resource.\n\n :type project: str\n :param project: ID of the project containing the metric.\n\n :type metric_name: str\n :param metric_name: the name of the metric\n\n :type filter_: str\n :param filter_: the advanced logs filter expression defin...
Please provide a description of the function:def metric_delete(self, project, metric_name): path = "projects/%s/metrics/%s" % (project, metric_name) self._gapic_api.delete_log_metric(path)
[ "API call: delete a metric resource.\n\n :type project: str\n :param project: ID of the project containing the metric.\n\n :type metric_name: str\n :param metric_name: the name of the metric\n " ]
Please provide a description of the function:def tenant_path(cls, project, tenant): return google.api_core.path_template.expand( "projects/{project}/tenants/{tenant}", project=project, tenant=tenant )
[ "Return a fully-qualified tenant string." ]
Please provide a description of the function:def create_tenant( self, parent, tenant, 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 timeou...
[ "\n Creates a new tenant entity.\n\n Example:\n >>> from google.cloud import talent_v4beta1\n >>>\n >>> client = talent_v4beta1.TenantServiceClient()\n >>>\n >>> parent = client.project_path('[PROJECT]')\n >>>\n >>> # TODO: I...
Please provide a description of the function:def get_tenant( 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. if "...
[ "\n Retrieves specified tenant.\n\n Example:\n >>> from google.cloud import talent_v4beta1\n >>>\n >>> client = talent_v4beta1.TenantServiceClient()\n >>>\n >>> name = client.tenant_path('[PROJECT]', '[TENANT]')\n >>>\n >>> r...
Please provide a description of the function:def update_tenant( self, tenant, 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 retry ...
[ "\n Updates specified tenant.\n\n Example:\n >>> from google.cloud import talent_v4beta1\n >>>\n >>> client = talent_v4beta1.TenantServiceClient()\n >>>\n >>> # TODO: Initialize `tenant`:\n >>> tenant = {}\n >>>\n ...
Please provide a description of the function:def _apply_decorators(func, decorators): decorators = filter(_is_not_none_or_false, reversed(decorators)) for decorator in decorators: func = decorator(func) return func
[ "Apply a list of decorators to a given function.\n\n ``decorators`` may contain items that are ``None`` or ``False`` which will\n be ignored.\n " ]
Please provide a description of the function:def _determine_timeout(default_timeout, specified_timeout, retry): if specified_timeout is DEFAULT: specified_timeout = default_timeout if specified_timeout is default_timeout: # If timeout is the default and the default timeout is exponential a...
[ "Determines how timeout should be applied to a wrapped method.\n\n Args:\n default_timeout (Optional[Timeout]): The default timeout specified\n at method creation time.\n specified_timeout (Optional[Timeout]): The timeout specified at\n invocation time. If :attr:`DEFAULT`, thi...
Please provide a description of the function:def wrap_method( func, default_retry=None, default_timeout=None, client_info=client_info.DEFAULT_CLIENT_INFO, ): func = grpc_helpers.wrap_errors(func) if client_info is not None: user_agent_metadata = [client_info.to_grpc_metadata()] ...
[ "Wrap an RPC method with common behavior.\n\n This applies common error wrapping, retry, and timeout behavior a function.\n The wrapped function will take optional ``retry`` and ``timeout``\n arguments.\n\n For example::\n\n import google.api_core.gapic_v1.method\n from google.api_core imp...
Please provide a description of the function:def _validate_name(name): if name is None: return # The first and las characters must be alphanumeric. if not all([name[0].isalnum(), name[-1].isalnum()]): raise ValueError("Bucket names must start and end with a number or letter.") retu...
[ "Pre-flight ``Bucket`` name validation.\n\n :type name: str or :data:`NoneType`\n :param name: Proposed bucket name.\n\n :rtype: str or :data:`NoneType`\n :returns: ``name`` if valid.\n " ]
Please provide a description of the function:def _scalar_property(fieldname): def _getter(self): return self._properties.get(fieldname) def _setter(self, value): self._patch_property(fieldname, value) return property(_getter, _setter)
[ "Create a property descriptor around the :class:`_PropertyMixin` helpers.\n ", "Scalar property getter.", "Scalar property setter." ]
Please provide a description of the function:def _write_buffer_to_hash(buffer_object, hash_obj, digest_block_size=8192): block = buffer_object.read(digest_block_size) while len(block) > 0: hash_obj.update(block) # Update the block for the next iteration. block = buffer_object.read(...
[ "Read blocks from a buffer and update a hash with them.\n\n :type buffer_object: bytes buffer\n :param buffer_object: Buffer containing bytes used to update a hash object.\n\n :type hash_obj: object that implements update\n :param hash_obj: A hash object (MD5 or CRC32-C).\n\n :type digest_block_size:...
Please provide a description of the function:def _base64_md5hash(buffer_object): hash_obj = md5() _write_buffer_to_hash(buffer_object, hash_obj) digest_bytes = hash_obj.digest() return base64.b64encode(digest_bytes)
[ "Get MD5 hash of bytes (as base64).\n\n :type buffer_object: bytes buffer\n :param buffer_object: Buffer containing bytes used to compute an MD5\n hash (as base64).\n\n :rtype: str\n :returns: A base64 encoded digest of the MD5 hash.\n " ]
Please provide a description of the function:def reload(self, client=None): client = self._require_client(client) query_params = self._query_params # Pass only '?projection=noAcl' here because 'acl' and related # are handled via custom endpoints. query_params["projection...
[ "Reload properties from Cloud Storage.\n\n If :attr:`user_project` is set, bills the API request to that project.\n\n :type client: :class:`~google.cloud.storage.client.Client` or\n ``NoneType``\n :param client: the client to use. If not passed, falls back to the\n ...
Please provide a description of the function:def _patch_property(self, name, value): self._changes.add(name) self._properties[name] = value
[ "Update field of this object's properties.\n\n This method will only update the field provided and will not\n touch the other fields.\n\n It **will not** reload the properties from the server. The behavior is\n local only and syncing occurs via :meth:`patch`.\n\n :type name: str\n...
Please provide a description of the function:def patch(self, client=None): client = self._require_client(client) query_params = self._query_params # Pass '?projection=full' here because 'PATCH' documented not # to work properly w/ 'noAcl'. query_params["projection"] = "f...
[ "Sends all changed properties in a PATCH request.\n\n Updates the ``_properties`` with the response from the backend.\n\n If :attr:`user_project` is set, bills the API request to that project.\n\n :type client: :class:`~google.cloud.storage.client.Client` or\n ``NoneType``\...
Please provide a description of the function:def update(self, client=None): client = self._require_client(client) query_params = self._query_params query_params["projection"] = "full" api_response = client._connection.api_request( method="PUT", path=self....
[ "Sends all properties in a PUT request.\n\n Updates the ``_properties`` with the response from the backend.\n\n If :attr:`user_project` is set, bills the API request to that project.\n\n :type client: :class:`~google.cloud.storage.client.Client` or\n ``NoneType``\n :...
Please provide a description of the function:def start(self): with self._operational_lock: if self._thread is not None: raise ValueError("Dispatcher is already running.") flow_control = self._manager.flow_control worker = helper_threads.QueueCallback...
[ "Start a thread to dispatch requests queued up by callbacks.\n Spawns a thread to run :meth:`dispatch_callback`.\n " ]
Please provide a description of the function:def dispatch_callback(self, items): if not self._manager.is_active: return batched_commands = collections.defaultdict(list) for item in items: batched_commands[item.__class__].append(item) _LOGGER.debug("Han...
[ "Map the callback request to the appropriate gRPC request.\n\n Args:\n action (str): The method to be invoked.\n kwargs (Dict[str, Any]): The keyword arguments for the method\n specified by ``action``.\n\n Raises:\n ValueError: If ``action`` isn't one of...
Please provide a description of the function:def ack(self, items): # If we got timing information, add it to the histogram. for item in items: time_to_ack = item.time_to_ack if time_to_ack is not None: self._manager.ack_histogram.add(time_to_ack) ...
[ "Acknowledge the given messages.\n\n Args:\n items(Sequence[AckRequest]): The items to acknowledge.\n " ]
Please provide a description of the function:def drop(self, items): self._manager.leaser.remove(items) self._manager.maybe_resume_consumer()
[ "Remove the given messages from lease management.\n\n Args:\n items(Sequence[DropRequest]): The items to drop.\n " ]
Please provide a description of the function:def lease(self, items): self._manager.leaser.add(items) self._manager.maybe_pause_consumer()
[ "Add the given messages to lease management.\n\n Args:\n items(Sequence[LeaseRequest]): The items to lease.\n " ]
Please provide a description of the function:def modify_ack_deadline(self, items): ack_ids = [item.ack_id for item in items] seconds = [item.seconds for item in items] request = types.StreamingPullRequest( modify_deadline_ack_ids=ack_ids, modify_deadline_seconds=seconds ...
[ "Modify the ack deadline for the given messages.\n\n Args:\n items(Sequence[ModAckRequest]): The items to modify.\n " ]
Please provide a description of the function:def nack(self, items): self.modify_ack_deadline( [requests.ModAckRequest(ack_id=item.ack_id, seconds=0) for item in items] ) self.drop([requests.DropRequest(*item) for item in items])
[ "Explicitly deny receipt of messages.\n\n Args:\n items(Sequence[NackRequest]): The items to deny.\n " ]
Please provide a description of the function:def submit_job( self, project_id, region, job, request_id=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the t...
[ "\n Submits a job to a cluster.\n\n Example:\n >>> from google.cloud import dataproc_v1beta2\n >>>\n >>> client = dataproc_v1beta2.JobControllerClient()\n >>>\n >>> # TODO: Initialize `project_id`:\n >>> project_id = ''\n >>>...
Please provide a description of the function:def update_job( self, project_id, region, job_id, job, update_mask, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): ...
[ "\n Updates a job in a project.\n\n Example:\n >>> from google.cloud import dataproc_v1beta2\n >>>\n >>> client = dataproc_v1beta2.JobControllerClient()\n >>>\n >>> # TODO: Initialize `project_id`:\n >>> project_id = ''\n >>>...
Please provide a description of the function:def cancel_job( self, project_id, region, job_id, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): # Wrap the transport method to add...
[ "\n Starts a job cancellation request. To access the job resource after\n cancellation, call\n `regions/{region}/jobs.list <https://cloud.google.com/dataproc/docs/reference/rest/v1beta2/projects.regions.jobs/list>`__\n or\n `regions/{region}/jobs.get <https://cloud.google.com/data...
Please provide a description of the function:def instance_path(cls, project, instance): return google.api_core.path_template.expand( "projects/{project}/instances/{instance}", project=project, instance=instance, )
[ "Return a fully-qualified instance string." ]
Please provide a description of the function:def app_profile_path(cls, project, instance, app_profile): return google.api_core.path_template.expand( "projects/{project}/instances/{instance}/appProfiles/{app_profile}", project=project, instance=instance, a...
[ "Return a fully-qualified app_profile string." ]
Please provide a description of the function:def cluster_path(cls, project, instance, cluster): return google.api_core.path_template.expand( "projects/{project}/instances/{instance}/clusters/{cluster}", project=project, instance=instance, cluster=cluster,...
[ "Return a fully-qualified cluster string." ]