repo
stringclasses
85 values
path
stringlengths
8
121
func_name
stringlengths
1
82
original_string
stringlengths
112
65.5k
language
stringclasses
1 value
code
stringlengths
112
65.5k
code_tokens
listlengths
20
4.09k
docstring
stringlengths
3
46.3k
docstring_tokens
listlengths
1
564
sha
stringclasses
85 values
url
stringlengths
93
218
partition
stringclasses
1 value
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.add_lifecycle_delete_rule
def add_lifecycle_delete_rule(self, **kw): """Add a "delete" rule to lifestyle rules configured for this bucket. See https://cloud.google.com/storage/docs/lifecycle and https://cloud.google.com/storage/docs/json_api/v1/buckets .. literalinclude:: snippets.py :start-after...
python
def add_lifecycle_delete_rule(self, **kw): """Add a "delete" rule to lifestyle rules configured for this bucket. See https://cloud.google.com/storage/docs/lifecycle and https://cloud.google.com/storage/docs/json_api/v1/buckets .. literalinclude:: snippets.py :start-after...
[ "def", "add_lifecycle_delete_rule", "(", "self", ",", "*", "*", "kw", ")", ":", "rules", "=", "list", "(", "self", ".", "lifecycle_rules", ")", "rules", ".", "append", "(", "LifecycleRuleDelete", "(", "*", "*", "kw", ")", ")", "self", ".", "lifecycle_rul...
Add a "delete" rule to lifestyle rules configured for this bucket. See https://cloud.google.com/storage/docs/lifecycle and https://cloud.google.com/storage/docs/json_api/v1/buckets .. literalinclude:: snippets.py :start-after: [START add_lifecycle_delete_rule] :end-bef...
[ "Add", "a", "delete", "rule", "to", "lifestyle", "rules", "configured", "for", "this", "bucket", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1306-L1321
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.add_lifecycle_set_storage_class_rule
def add_lifecycle_set_storage_class_rule(self, storage_class, **kw): """Add a "delete" rule to lifestyle rules configured for this bucket. See https://cloud.google.com/storage/docs/lifecycle and https://cloud.google.com/storage/docs/json_api/v1/buckets .. literalinclude:: snippets...
python
def add_lifecycle_set_storage_class_rule(self, storage_class, **kw): """Add a "delete" rule to lifestyle rules configured for this bucket. See https://cloud.google.com/storage/docs/lifecycle and https://cloud.google.com/storage/docs/json_api/v1/buckets .. literalinclude:: snippets...
[ "def", "add_lifecycle_set_storage_class_rule", "(", "self", ",", "storage_class", ",", "*", "*", "kw", ")", ":", "rules", "=", "list", "(", "self", ".", "lifecycle_rules", ")", "rules", ".", "append", "(", "LifecycleRuleSetStorageClass", "(", "storage_class", ",...
Add a "delete" rule to lifestyle rules configured for this bucket. See https://cloud.google.com/storage/docs/lifecycle and https://cloud.google.com/storage/docs/json_api/v1/buckets .. literalinclude:: snippets.py :start-after: [START add_lifecycle_set_storage_class_rule] ...
[ "Add", "a", "delete", "rule", "to", "lifestyle", "rules", "configured", "for", "this", "bucket", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1323-L1341
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.location
def location(self, value): """(Deprecated) Set `Bucket.location` This can only be set at bucket **creation** time. See https://cloud.google.com/storage/docs/json_api/v1/buckets and https://cloud.google.com/storage/docs/bucket-locations .. warning:: Assignment to '...
python
def location(self, value): """(Deprecated) Set `Bucket.location` This can only be set at bucket **creation** time. See https://cloud.google.com/storage/docs/json_api/v1/buckets and https://cloud.google.com/storage/docs/bucket-locations .. warning:: Assignment to '...
[ "def", "location", "(", "self", ",", "value", ")", ":", "warnings", ".", "warn", "(", "_LOCATION_SETTER_MESSAGE", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ")", "self", ".", "_location", "=", "value" ]
(Deprecated) Set `Bucket.location` This can only be set at bucket **creation** time. See https://cloud.google.com/storage/docs/json_api/v1/buckets and https://cloud.google.com/storage/docs/bucket-locations .. warning:: Assignment to 'Bucket.location' is deprecated, as it ...
[ "(", "Deprecated", ")", "Set", "Bucket", ".", "location" ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1359-L1374
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.enable_logging
def enable_logging(self, bucket_name, object_prefix=""): """Enable access logging for this bucket. See https://cloud.google.com/storage/docs/access-logs :type bucket_name: str :param bucket_name: name of bucket in which to store access logs :type object_prefix: str :pa...
python
def enable_logging(self, bucket_name, object_prefix=""): """Enable access logging for this bucket. See https://cloud.google.com/storage/docs/access-logs :type bucket_name: str :param bucket_name: name of bucket in which to store access logs :type object_prefix: str :pa...
[ "def", "enable_logging", "(", "self", ",", "bucket_name", ",", "object_prefix", "=", "\"\"", ")", ":", "info", "=", "{", "\"logBucket\"", ":", "bucket_name", ",", "\"logObjectPrefix\"", ":", "object_prefix", "}", "self", ".", "_patch_property", "(", "\"logging\"...
Enable access logging for this bucket. See https://cloud.google.com/storage/docs/access-logs :type bucket_name: str :param bucket_name: name of bucket in which to store access logs :type object_prefix: str :param object_prefix: prefix for access log filenames
[ "Enable", "access", "logging", "for", "this", "bucket", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1388-L1400
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.retention_policy_effective_time
def retention_policy_effective_time(self): """Retrieve the effective time of the bucket's retention policy. :rtype: datetime.datetime or ``NoneType`` :returns: point-in time at which the bucket's retention policy is effective, or ``None`` if the property is not ...
python
def retention_policy_effective_time(self): """Retrieve the effective time of the bucket's retention policy. :rtype: datetime.datetime or ``NoneType`` :returns: point-in time at which the bucket's retention policy is effective, or ``None`` if the property is not ...
[ "def", "retention_policy_effective_time", "(", "self", ")", ":", "policy", "=", "self", ".", "_properties", ".", "get", "(", "\"retentionPolicy\"", ")", "if", "policy", "is", "not", "None", ":", "timestamp", "=", "policy", ".", "get", "(", "\"effectiveTime\"",...
Retrieve the effective time of the bucket's retention policy. :rtype: datetime.datetime or ``NoneType`` :returns: point-in time at which the bucket's retention policy is effective, or ``None`` if the property is not set locally.
[ "Retrieve", "the", "effective", "time", "of", "the", "bucket", "s", "retention", "policy", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1450-L1462
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.retention_period
def retention_period(self): """Retrieve or set the retention period for items in the bucket. :rtype: int or ``NoneType`` :returns: number of seconds to retain items after upload or release from event-based lock, or ``None`` if the property is not set locally....
python
def retention_period(self): """Retrieve or set the retention period for items in the bucket. :rtype: int or ``NoneType`` :returns: number of seconds to retain items after upload or release from event-based lock, or ``None`` if the property is not set locally....
[ "def", "retention_period", "(", "self", ")", ":", "policy", "=", "self", ".", "_properties", ".", "get", "(", "\"retentionPolicy\"", ")", "if", "policy", "is", "not", "None", ":", "period", "=", "policy", ".", "get", "(", "\"retentionPeriod\"", ")", "if", ...
Retrieve or set the retention period for items in the bucket. :rtype: int or ``NoneType`` :returns: number of seconds to retain items after upload or release from event-based lock, or ``None`` if the property is not set locally.
[ "Retrieve", "or", "set", "the", "retention", "period", "for", "items", "in", "the", "bucket", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1478-L1490
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.retention_period
def retention_period(self, value): """Set the retention period for items in the bucket. :type value: int :param value: number of seconds to retain items after upload or release from event-based lock. :raises ValueError: if the bucket's retention policy is locked...
python
def retention_period(self, value): """Set the retention period for items in the bucket. :type value: int :param value: number of seconds to retain items after upload or release from event-based lock. :raises ValueError: if the bucket's retention policy is locked...
[ "def", "retention_period", "(", "self", ",", "value", ")", ":", "policy", "=", "self", ".", "_properties", ".", "setdefault", "(", "\"retentionPolicy\"", ",", "{", "}", ")", "if", "value", "is", "not", "None", ":", "policy", "[", "\"retentionPeriod\"", "]"...
Set the retention period for items in the bucket. :type value: int :param value: number of seconds to retain items after upload or release from event-based lock. :raises ValueError: if the bucket's retention policy is locked.
[ "Set", "the", "retention", "period", "for", "items", "in", "the", "bucket", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1493-L1508
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.storage_class
def storage_class(self, value): """Set the storage class for the bucket. See https://cloud.google.com/storage/docs/storage-classes :type value: str :param value: one of "MULTI_REGIONAL", "REGIONAL", "NEARLINE", "COLDLINE", "STANDARD", or "DURABLE_REDUCED_AVAILABIL...
python
def storage_class(self, value): """Set the storage class for the bucket. See https://cloud.google.com/storage/docs/storage-classes :type value: str :param value: one of "MULTI_REGIONAL", "REGIONAL", "NEARLINE", "COLDLINE", "STANDARD", or "DURABLE_REDUCED_AVAILABIL...
[ "def", "storage_class", "(", "self", ",", "value", ")", ":", "if", "value", "not", "in", "self", ".", "_STORAGE_CLASSES", ":", "raise", "ValueError", "(", "\"Invalid storage class: %s\"", "%", "(", "value", ",", ")", ")", "self", ".", "_patch_property", "(",...
Set the storage class for the bucket. See https://cloud.google.com/storage/docs/storage-classes :type value: str :param value: one of "MULTI_REGIONAL", "REGIONAL", "NEARLINE", "COLDLINE", "STANDARD", or "DURABLE_REDUCED_AVAILABILITY"
[ "Set", "the", "storage", "class", "for", "the", "bucket", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1539-L1550
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.configure_website
def configure_website(self, main_page_suffix=None, not_found_page=None): """Configure website-related properties. See https://cloud.google.com/storage/docs/hosting-static-website .. note:: This (apparently) only works if your bucket name is a domain name (and to d...
python
def configure_website(self, main_page_suffix=None, not_found_page=None): """Configure website-related properties. See https://cloud.google.com/storage/docs/hosting-static-website .. note:: This (apparently) only works if your bucket name is a domain name (and to d...
[ "def", "configure_website", "(", "self", ",", "main_page_suffix", "=", "None", ",", "not_found_page", "=", "None", ")", ":", "data", "=", "{", "\"mainPageSuffix\"", ":", "main_page_suffix", ",", "\"notFoundPage\"", ":", "not_found_page", "}", "self", ".", "_patc...
Configure website-related properties. See https://cloud.google.com/storage/docs/hosting-static-website .. note:: This (apparently) only works if your bucket name is a domain name (and to do that, you need to get approved somehow...). If you want this bucket to ho...
[ "Configure", "website", "-", "related", "properties", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1624-L1660
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.get_iam_policy
def get_iam_policy(self, client=None): """Retrieve the IAM policy for the bucket. See https://cloud.google.com/storage/docs/json_api/v1/buckets/getIamPolicy If :attr:`user_project` is set, bills the API request to that project. :type client: :class:`~google.cloud.storage.clien...
python
def get_iam_policy(self, client=None): """Retrieve the IAM policy for the bucket. See https://cloud.google.com/storage/docs/json_api/v1/buckets/getIamPolicy If :attr:`user_project` is set, bills the API request to that project. :type client: :class:`~google.cloud.storage.clien...
[ "def", "get_iam_policy", "(", "self", ",", "client", "=", "None", ")", ":", "client", "=", "self", ".", "_require_client", "(", "client", ")", "query_params", "=", "{", "}", "if", "self", ".", "user_project", "is", "not", "None", ":", "query_params", "["...
Retrieve the IAM policy for the bucket. See https://cloud.google.com/storage/docs/json_api/v1/buckets/getIamPolicy If :attr:`user_project` is set, bills the API request to that project. :type client: :class:`~google.cloud.storage.client.Client` or ``NoneType`` ...
[ "Retrieve", "the", "IAM", "policy", "for", "the", "bucket", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1670-L1699
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.set_iam_policy
def set_iam_policy(self, policy, client=None): """Update the IAM policy for the bucket. See https://cloud.google.com/storage/docs/json_api/v1/buckets/setIamPolicy If :attr:`user_project` is set, bills the API request to that project. :type policy: :class:`google.api_core.iam.P...
python
def set_iam_policy(self, policy, client=None): """Update the IAM policy for the bucket. See https://cloud.google.com/storage/docs/json_api/v1/buckets/setIamPolicy If :attr:`user_project` is set, bills the API request to that project. :type policy: :class:`google.api_core.iam.P...
[ "def", "set_iam_policy", "(", "self", ",", "policy", ",", "client", "=", "None", ")", ":", "client", "=", "self", ".", "_require_client", "(", "client", ")", "query_params", "=", "{", "}", "if", "self", ".", "user_project", "is", "not", "None", ":", "q...
Update the IAM policy for the bucket. See https://cloud.google.com/storage/docs/json_api/v1/buckets/setIamPolicy If :attr:`user_project` is set, bills the API request to that project. :type policy: :class:`google.api_core.iam.Policy` :param policy: policy instance used to upda...
[ "Update", "the", "IAM", "policy", "for", "the", "bucket", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1701-L1736
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.make_private
def make_private(self, recursive=False, future=False, client=None): """Update bucket's ACL, revoking read access for anonymous users. :type recursive: bool :param recursive: If True, this will make all blobs inside the bucket private as well. :type future: boo...
python
def make_private(self, recursive=False, future=False, client=None): """Update bucket's ACL, revoking read access for anonymous users. :type recursive: bool :param recursive: If True, this will make all blobs inside the bucket private as well. :type future: boo...
[ "def", "make_private", "(", "self", ",", "recursive", "=", "False", ",", "future", "=", "False", ",", "client", "=", "None", ")", ":", "self", ".", "acl", ".", "all", "(", ")", ".", "revoke_read", "(", ")", "self", ".", "acl", ".", "save", "(", "...
Update bucket's ACL, revoking read access for anonymous users. :type recursive: bool :param recursive: If True, this will make all blobs inside the bucket private as well. :type future: bool :param future: If True, this will make all objects created in the ...
[ "Update", "bucket", "s", "ACL", "revoking", "read", "access", "for", "anonymous", "users", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1826-L1880
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.generate_upload_policy
def generate_upload_policy(self, conditions, expiration=None, client=None): """Create a signed upload policy for uploading objects. This method generates and signs a policy document. You can use `policy documents`_ to allow visitors to a website to upload files to Google Cloud Storage w...
python
def generate_upload_policy(self, conditions, expiration=None, client=None): """Create a signed upload policy for uploading objects. This method generates and signs a policy document. You can use `policy documents`_ to allow visitors to a website to upload files to Google Cloud Storage w...
[ "def", "generate_upload_policy", "(", "self", ",", "conditions", ",", "expiration", "=", "None", ",", "client", "=", "None", ")", ":", "client", "=", "self", ".", "_require_client", "(", "client", ")", "credentials", "=", "client", ".", "_base_connection", "...
Create a signed upload policy for uploading objects. This method generates and signs a policy document. You can use `policy documents`_ to allow visitors to a website to upload files to Google Cloud Storage without giving them direct write access. For example: .. literalinclud...
[ "Create", "a", "signed", "upload", "policy", "for", "uploading", "objects", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1882-L1942
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.lock_retention_policy
def lock_retention_policy(self, client=None): """Lock the bucket's retention policy. :raises ValueError: if the bucket has no metageneration (i.e., new or never reloaded); if the bucket has no retention policy assigned; if the bucket's retention policy is already loc...
python
def lock_retention_policy(self, client=None): """Lock the bucket's retention policy. :raises ValueError: if the bucket has no metageneration (i.e., new or never reloaded); if the bucket has no retention policy assigned; if the bucket's retention policy is already loc...
[ "def", "lock_retention_policy", "(", "self", ",", "client", "=", "None", ")", ":", "if", "\"metageneration\"", "not", "in", "self", ".", "_properties", ":", "raise", "ValueError", "(", "\"Bucket has no retention policy assigned: try 'reload'?\"", ")", "policy", "=", ...
Lock the bucket's retention policy. :raises ValueError: if the bucket has no metageneration (i.e., new or never reloaded); if the bucket has no retention policy assigned; if the bucket's retention policy is already locked.
[ "Lock", "the", "bucket", "s", "retention", "policy", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1944-L1974
train
googleapis/google-cloud-python
storage/google/cloud/storage/bucket.py
Bucket.generate_signed_url
def generate_signed_url( self, expiration=None, api_access_endpoint=_API_ACCESS_ENDPOINT, method="GET", headers=None, query_parameters=None, client=None, credentials=None, version=None, ): """Generates a signed URL for this bucket. ...
python
def generate_signed_url( self, expiration=None, api_access_endpoint=_API_ACCESS_ENDPOINT, method="GET", headers=None, query_parameters=None, client=None, credentials=None, version=None, ): """Generates a signed URL for this bucket. ...
[ "def", "generate_signed_url", "(", "self", ",", "expiration", "=", "None", ",", "api_access_endpoint", "=", "_API_ACCESS_ENDPOINT", ",", "method", "=", "\"GET\"", ",", "headers", "=", "None", ",", "query_parameters", "=", "None", ",", "client", "=", "None", ",...
Generates a signed URL for this bucket. .. note:: If you are on Google Compute Engine, you can't generate a signed URL using GCE service account. Follow `Issue 50`_ for updates on this. If you'd like to be able to generate a signed URL from GCE, you can use a st...
[ "Generates", "a", "signed", "URL", "for", "this", "bucket", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/bucket.py#L1976-L2080
train
googleapis/google-cloud-python
api_core/google/api_core/datetime_helpers.py
to_microseconds
def to_microseconds(value): """Convert a datetime to microseconds since the unix epoch. Args: value (datetime.datetime): The datetime to covert. Returns: int: Microseconds since the unix epoch. """ if not value.tzinfo: value = value.replace(tzinfo=pytz.utc) # Regardless...
python
def to_microseconds(value): """Convert a datetime to microseconds since the unix epoch. Args: value (datetime.datetime): The datetime to covert. Returns: int: Microseconds since the unix epoch. """ if not value.tzinfo: value = value.replace(tzinfo=pytz.utc) # Regardless...
[ "def", "to_microseconds", "(", "value", ")", ":", "if", "not", "value", ".", "tzinfo", ":", "value", "=", "value", ".", "replace", "(", "tzinfo", "=", "pytz", ".", "utc", ")", "# Regardless of what timezone is on the value, convert it to UTC.", "value", "=", "va...
Convert a datetime to microseconds since the unix epoch. Args: value (datetime.datetime): The datetime to covert. Returns: int: Microseconds since the unix epoch.
[ "Convert", "a", "datetime", "to", "microseconds", "since", "the", "unix", "epoch", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/api_core/google/api_core/datetime_helpers.py#L76-L90
train
googleapis/google-cloud-python
api_core/google/api_core/datetime_helpers.py
from_rfc3339
def from_rfc3339(value): """Convert a microsecond-precision timestamp to datetime. Args: value (str): The RFC3339 string to convert. Returns: datetime.datetime: The datetime object equivalent to the timestamp in UTC. """ return datetime.datetime.strptime(value, _RFC3339...
python
def from_rfc3339(value): """Convert a microsecond-precision timestamp to datetime. Args: value (str): The RFC3339 string to convert. Returns: datetime.datetime: The datetime object equivalent to the timestamp in UTC. """ return datetime.datetime.strptime(value, _RFC3339...
[ "def", "from_rfc3339", "(", "value", ")", ":", "return", "datetime", ".", "datetime", ".", "strptime", "(", "value", ",", "_RFC3339_MICROS", ")", ".", "replace", "(", "tzinfo", "=", "pytz", ".", "utc", ")" ]
Convert a microsecond-precision timestamp to datetime. Args: value (str): The RFC3339 string to convert. Returns: datetime.datetime: The datetime object equivalent to the timestamp in UTC.
[ "Convert", "a", "microsecond", "-", "precision", "timestamp", "to", "datetime", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/api_core/google/api_core/datetime_helpers.py#L117-L127
train
googleapis/google-cloud-python
api_core/google/api_core/datetime_helpers.py
from_rfc3339_nanos
def from_rfc3339_nanos(value): """Convert a nanosecond-precision timestamp to a native datetime. .. note:: Python datetimes do not support nanosecond precision; this function therefore truncates such values to microseconds. Args: value (str): The RFC3339 string to convert. Ret...
python
def from_rfc3339_nanos(value): """Convert a nanosecond-precision timestamp to a native datetime. .. note:: Python datetimes do not support nanosecond precision; this function therefore truncates such values to microseconds. Args: value (str): The RFC3339 string to convert. Ret...
[ "def", "from_rfc3339_nanos", "(", "value", ")", ":", "with_nanos", "=", "_RFC3339_NANOS", ".", "match", "(", "value", ")", "if", "with_nanos", "is", "None", ":", "raise", "ValueError", "(", "\"Timestamp: {!r}, does not match pattern: {!r}\"", ".", "format", "(", "...
Convert a nanosecond-precision timestamp to a native datetime. .. note:: Python datetimes do not support nanosecond precision; this function therefore truncates such values to microseconds. Args: value (str): The RFC3339 string to convert. Returns: datetime.datetime: The d...
[ "Convert", "a", "nanosecond", "-", "precision", "timestamp", "to", "a", "native", "datetime", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/api_core/google/api_core/datetime_helpers.py#L130-L169
train
googleapis/google-cloud-python
api_core/google/api_core/datetime_helpers.py
DatetimeWithNanoseconds.rfc3339
def rfc3339(self): """Return an RFC 3339-compliant timestamp. Returns: (str): Timestamp string according to RFC 3339 spec. """ if self._nanosecond == 0: return to_rfc3339(self) nanos = str(self._nanosecond).rjust(9, '0').rstrip("0") return "{}.{}Z...
python
def rfc3339(self): """Return an RFC 3339-compliant timestamp. Returns: (str): Timestamp string according to RFC 3339 spec. """ if self._nanosecond == 0: return to_rfc3339(self) nanos = str(self._nanosecond).rjust(9, '0').rstrip("0") return "{}.{}Z...
[ "def", "rfc3339", "(", "self", ")", ":", "if", "self", ".", "_nanosecond", "==", "0", ":", "return", "to_rfc3339", "(", "self", ")", "nanos", "=", "str", "(", "self", ".", "_nanosecond", ")", ".", "rjust", "(", "9", ",", "'0'", ")", ".", "rstrip", ...
Return an RFC 3339-compliant timestamp. Returns: (str): Timestamp string according to RFC 3339 spec.
[ "Return", "an", "RFC", "3339", "-", "compliant", "timestamp", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/api_core/google/api_core/datetime_helpers.py#L217-L226
train
googleapis/google-cloud-python
api_core/google/api_core/datetime_helpers.py
DatetimeWithNanoseconds.from_rfc3339
def from_rfc3339(cls, stamp): """Parse RFC 3339-compliant timestamp, preserving nanoseconds. Args: stamp (str): RFC 3339 stamp, with up to nanosecond precision Returns: :class:`DatetimeWithNanoseconds`: an instance matching the timestamp string ...
python
def from_rfc3339(cls, stamp): """Parse RFC 3339-compliant timestamp, preserving nanoseconds. Args: stamp (str): RFC 3339 stamp, with up to nanosecond precision Returns: :class:`DatetimeWithNanoseconds`: an instance matching the timestamp string ...
[ "def", "from_rfc3339", "(", "cls", ",", "stamp", ")", ":", "with_nanos", "=", "_RFC3339_NANOS", ".", "match", "(", "stamp", ")", "if", "with_nanos", "is", "None", ":", "raise", "ValueError", "(", "\"Timestamp: {}, does not match pattern: {}\"", ".", "format", "(...
Parse RFC 3339-compliant timestamp, preserving nanoseconds. Args: stamp (str): RFC 3339 stamp, with up to nanosecond precision Returns: :class:`DatetimeWithNanoseconds`: an instance matching the timestamp string Raises: ValueError: if `stamp...
[ "Parse", "RFC", "3339", "-", "compliant", "timestamp", "preserving", "nanoseconds", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/api_core/google/api_core/datetime_helpers.py#L229-L267
train
googleapis/google-cloud-python
api_core/google/api_core/datetime_helpers.py
DatetimeWithNanoseconds.timestamp_pb
def timestamp_pb(self): """Return a timestamp message. Returns: (:class:`~google.protobuf.timestamp_pb2.Timestamp`): Timestamp message """ inst = self if self.tzinfo is not None else self.replace(tzinfo=pytz.UTC) delta = inst - _UTC_EPOCH seconds = int(delta....
python
def timestamp_pb(self): """Return a timestamp message. Returns: (:class:`~google.protobuf.timestamp_pb2.Timestamp`): Timestamp message """ inst = self if self.tzinfo is not None else self.replace(tzinfo=pytz.UTC) delta = inst - _UTC_EPOCH seconds = int(delta....
[ "def", "timestamp_pb", "(", "self", ")", ":", "inst", "=", "self", "if", "self", ".", "tzinfo", "is", "not", "None", "else", "self", ".", "replace", "(", "tzinfo", "=", "pytz", ".", "UTC", ")", "delta", "=", "inst", "-", "_UTC_EPOCH", "seconds", "=",...
Return a timestamp message. Returns: (:class:`~google.protobuf.timestamp_pb2.Timestamp`): Timestamp message
[ "Return", "a", "timestamp", "message", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/api_core/google/api_core/datetime_helpers.py#L269-L279
train
googleapis/google-cloud-python
api_core/google/api_core/datetime_helpers.py
DatetimeWithNanoseconds.from_timestamp_pb
def from_timestamp_pb(cls, stamp): """Parse RFC 3339-compliant timestamp, preserving nanoseconds. Args: stamp (:class:`~google.protobuf.timestamp_pb2.Timestamp`): timestamp message Returns: :class:`DatetimeWithNanoseconds`: an instance matching the times...
python
def from_timestamp_pb(cls, stamp): """Parse RFC 3339-compliant timestamp, preserving nanoseconds. Args: stamp (:class:`~google.protobuf.timestamp_pb2.Timestamp`): timestamp message Returns: :class:`DatetimeWithNanoseconds`: an instance matching the times...
[ "def", "from_timestamp_pb", "(", "cls", ",", "stamp", ")", ":", "microseconds", "=", "int", "(", "stamp", ".", "seconds", "*", "1e6", ")", "bare", "=", "from_microseconds", "(", "microseconds", ")", "return", "cls", "(", "bare", ".", "year", ",", "bare",...
Parse RFC 3339-compliant timestamp, preserving nanoseconds. Args: stamp (:class:`~google.protobuf.timestamp_pb2.Timestamp`): timestamp message Returns: :class:`DatetimeWithNanoseconds`: an instance matching the timestamp message
[ "Parse", "RFC", "3339", "-", "compliant", "timestamp", "preserving", "nanoseconds", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/api_core/google/api_core/datetime_helpers.py#L282-L303
train
googleapis/google-cloud-python
dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py
ClusterControllerClient.create_cluster
def create_cluster( self, project_id, region, cluster, request_id=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Creates a cluster in a project. Examp...
python
def create_cluster( self, project_id, region, cluster, request_id=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Creates a cluster in a project. Examp...
[ "def", "create_cluster", "(", "self", ",", "project_id", ",", "region", ",", "cluster", ",", "request_id", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api...
Creates a cluster in a project. Example: >>> from google.cloud import dataproc_v1beta2 >>> >>> client = dataproc_v1beta2.ClusterControllerClient() >>> >>> # TODO: Initialize `project_id`: >>> project_id = '' >>> >>>...
[ "Creates", "a", "cluster", "in", "a", "project", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py#L180-L278
train
googleapis/google-cloud-python
dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py
ClusterControllerClient.delete_cluster
def delete_cluster( self, project_id, region, cluster_name, cluster_uuid=None, request_id=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Deletes a clus...
python
def delete_cluster( self, project_id, region, cluster_name, cluster_uuid=None, request_id=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Deletes a clus...
[ "def", "delete_cluster", "(", "self", ",", "project_id", ",", "region", ",", "cluster_name", ",", "cluster_uuid", "=", "None", ",", "request_id", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ","...
Deletes a cluster in a project. Example: >>> from google.cloud import dataproc_v1beta2 >>> >>> client = dataproc_v1beta2.ClusterControllerClient() >>> >>> # TODO: Initialize `project_id`: >>> project_id = '' >>> >>>...
[ "Deletes", "a", "cluster", "in", "a", "project", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py#L646-L748
train
googleapis/google-cloud-python
dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py
ClusterControllerClient.get_cluster
def get_cluster( self, project_id, region, cluster_name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Gets the resource representation for a cluster in a project. ...
python
def get_cluster( self, project_id, region, cluster_name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Gets the resource representation for a cluster in a project. ...
[ "def", "get_cluster", "(", "self", ",", "project_id", ",", "region", ",", "cluster_name", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", ...
Gets the resource representation for a cluster in a project. Example: >>> from google.cloud import dataproc_v1beta2 >>> >>> client = dataproc_v1beta2.ClusterControllerClient() >>> >>> # TODO: Initialize `project_id`: >>> project_id = '' ...
[ "Gets", "the", "resource", "representation", "for", "a", "cluster", "in", "a", "project", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py#L750-L818
train
googleapis/google-cloud-python
dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py
ClusterControllerClient.list_clusters
def list_clusters( self, project_id, region, filter_=None, page_size=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Lists all regions/{region}/clusters in a pr...
python
def list_clusters( self, project_id, region, filter_=None, page_size=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Lists all regions/{region}/clusters in a pr...
[ "def", "list_clusters", "(", "self", ",", "project_id", ",", "region", ",", "filter_", "=", "None", ",", "page_size", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google"...
Lists all regions/{region}/clusters in a project. Example: >>> from google.cloud import dataproc_v1beta2 >>> >>> client = dataproc_v1beta2.ClusterControllerClient() >>> >>> # TODO: Initialize `project_id`: >>> project_id = '' >...
[ "Lists", "all", "regions", "/", "{", "region", "}", "/", "clusters", "in", "a", "project", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py#L820-L936
train
googleapis/google-cloud-python
dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py
ClusterControllerClient.diagnose_cluster
def diagnose_cluster( self, project_id, region, cluster_name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Gets cluster diagnostic information. After the operation complet...
python
def diagnose_cluster( self, project_id, region, cluster_name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Gets cluster diagnostic information. After the operation complet...
[ "def", "diagnose_cluster", "(", "self", ",", "project_id", ",", "region", ",", "cluster_name", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", "....
Gets cluster diagnostic information. After the operation completes, the Operation.response field contains ``DiagnoseClusterOutputLocation``. Example: >>> from google.cloud import dataproc_v1beta2 >>> >>> client = dataproc_v1beta2.ClusterControllerClient() ...
[ "Gets", "cluster", "diagnostic", "information", ".", "After", "the", "operation", "completes", "the", "Operation", ".", "response", "field", "contains", "DiagnoseClusterOutputLocation", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py#L938-L1022
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Batch.commit
def commit(self): """Actually publish all of the messages on the active batch. .. note:: This method is non-blocking. It opens a new thread, which calls :meth:`_commit`, which does block. This synchronously sets the batch status to "starting", and then opens a ...
python
def commit(self): """Actually publish all of the messages on the active batch. .. note:: This method is non-blocking. It opens a new thread, which calls :meth:`_commit`, which does block. This synchronously sets the batch status to "starting", and then opens a ...
[ "def", "commit", "(", "self", ")", ":", "# Set the status to \"starting\" synchronously, to ensure that", "# this batch will necessarily not accept new messages.", "with", "self", ".", "_state_lock", ":", "if", "self", ".", "_status", "==", "base", ".", "BatchStatus", ".", ...
Actually publish all of the messages on the active batch. .. note:: This method is non-blocking. It opens a new thread, which calls :meth:`_commit`, which does block. This synchronously sets the batch status to "starting", and then opens a new thread, which handles act...
[ "Actually", "publish", "all", "of", "the", "messages", "on", "the", "active", "batch", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py#L140-L166
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Batch._commit
def _commit(self): """Actually publish all of the messages on the active batch. This moves the batch out from being the active batch to an in progress batch on the publisher, and then the batch is discarded upon completion. .. note:: This method blocks. The :meth:`...
python
def _commit(self): """Actually publish all of the messages on the active batch. This moves the batch out from being the active batch to an in progress batch on the publisher, and then the batch is discarded upon completion. .. note:: This method blocks. The :meth:`...
[ "def", "_commit", "(", "self", ")", ":", "with", "self", ".", "_state_lock", ":", "if", "self", ".", "_status", "in", "_CAN_COMMIT", ":", "self", ".", "_status", "=", "base", ".", "BatchStatus", ".", "IN_PROGRESS", "else", ":", "# If, in the intervening peri...
Actually publish all of the messages on the active batch. This moves the batch out from being the active batch to an in progress batch on the publisher, and then the batch is discarded upon completion. .. note:: This method blocks. The :meth:`commit` method is the non-bloc...
[ "Actually", "publish", "all", "of", "the", "messages", "on", "the", "active", "batch", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py#L168-L239
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Batch.monitor
def monitor(self): """Commit this batch after sufficient time has elapsed. This simply sleeps for ``self._settings.max_latency`` seconds, and then calls commit unless the batch has already been committed. """ # NOTE: This blocks; it is up to the calling code to call it #...
python
def monitor(self): """Commit this batch after sufficient time has elapsed. This simply sleeps for ``self._settings.max_latency`` seconds, and then calls commit unless the batch has already been committed. """ # NOTE: This blocks; it is up to the calling code to call it #...
[ "def", "monitor", "(", "self", ")", ":", "# NOTE: This blocks; it is up to the calling code to call it", "# in a separate thread.", "# Sleep for however long we should be waiting.", "time", ".", "sleep", "(", "self", ".", "_settings", ".", "max_latency", ")", "_LOGGER", ...
Commit this batch after sufficient time has elapsed. This simply sleeps for ``self._settings.max_latency`` seconds, and then calls commit unless the batch has already been committed.
[ "Commit", "this", "batch", "after", "sufficient", "time", "has", "elapsed", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py#L241-L254
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Batch.publish
def publish(self, message): """Publish a single message. Add the given message to this object; this will cause it to be published once the batch either has enough messages or a sufficient period of time has elapsed. This method is called by :meth:`~.PublisherClient.publish`. ...
python
def publish(self, message): """Publish a single message. Add the given message to this object; this will cause it to be published once the batch either has enough messages or a sufficient period of time has elapsed. This method is called by :meth:`~.PublisherClient.publish`. ...
[ "def", "publish", "(", "self", ",", "message", ")", ":", "# Coerce the type, just in case.", "if", "not", "isinstance", "(", "message", ",", "types", ".", "PubsubMessage", ")", ":", "message", "=", "types", ".", "PubsubMessage", "(", "*", "*", "message", ")"...
Publish a single message. Add the given message to this object; this will cause it to be published once the batch either has enough messages or a sufficient period of time has elapsed. This method is called by :meth:`~.PublisherClient.publish`. Args: message (~.pub...
[ "Publish", "a", "single", "message", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py#L256-L307
train
googleapis/google-cloud-python
dns/google/cloud/dns/changes.py
Changes.from_api_repr
def from_api_repr(cls, resource, zone): """Factory: construct a change set given its API representation :type resource: dict :param resource: change set representation returned from the API. :type zone: :class:`google.cloud.dns.zone.ManagedZone` :param zone: A zone which holds...
python
def from_api_repr(cls, resource, zone): """Factory: construct a change set given its API representation :type resource: dict :param resource: change set representation returned from the API. :type zone: :class:`google.cloud.dns.zone.ManagedZone` :param zone: A zone which holds...
[ "def", "from_api_repr", "(", "cls", ",", "resource", ",", "zone", ")", ":", "changes", "=", "cls", "(", "zone", "=", "zone", ")", "changes", ".", "_set_properties", "(", "resource", ")", "return", "changes" ]
Factory: construct a change set given its API representation :type resource: dict :param resource: change set representation returned from the API. :type zone: :class:`google.cloud.dns.zone.ManagedZone` :param zone: A zone which holds zero or more change sets. :rtype: :class:...
[ "Factory", ":", "construct", "a", "change", "set", "given", "its", "API", "representation" ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dns/google/cloud/dns/changes.py#L42-L56
train
googleapis/google-cloud-python
dns/google/cloud/dns/changes.py
Changes._set_properties
def _set_properties(self, resource): """Helper method for :meth:`from_api_repr`, :meth:`create`, etc. :type resource: dict :param resource: change set representation returned from the API. """ resource = resource.copy() self._additions = tuple( [ ...
python
def _set_properties(self, resource): """Helper method for :meth:`from_api_repr`, :meth:`create`, etc. :type resource: dict :param resource: change set representation returned from the API. """ resource = resource.copy() self._additions = tuple( [ ...
[ "def", "_set_properties", "(", "self", ",", "resource", ")", ":", "resource", "=", "resource", ".", "copy", "(", ")", "self", ".", "_additions", "=", "tuple", "(", "[", "ResourceRecordSet", ".", "from_api_repr", "(", "added_res", ",", "self", ".", "zone", ...
Helper method for :meth:`from_api_repr`, :meth:`create`, etc. :type resource: dict :param resource: change set representation returned from the API.
[ "Helper", "method", "for", ":", "meth", ":", "from_api_repr", ":", "meth", ":", "create", "etc", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dns/google/cloud/dns/changes.py#L58-L77
train
googleapis/google-cloud-python
dns/google/cloud/dns/changes.py
Changes.path
def path(self): """URL path for change set APIs. :rtype: str :returns: the path based on project, zone, and change set names. """ return "/projects/%s/managedZones/%s/changes/%s" % ( self.zone.project, self.zone.name, self.name, )
python
def path(self): """URL path for change set APIs. :rtype: str :returns: the path based on project, zone, and change set names. """ return "/projects/%s/managedZones/%s/changes/%s" % ( self.zone.project, self.zone.name, self.name, )
[ "def", "path", "(", "self", ")", ":", "return", "\"/projects/%s/managedZones/%s/changes/%s\"", "%", "(", "self", ".", "zone", ".", "project", ",", "self", ".", "zone", ".", "name", ",", "self", ".", "name", ",", ")" ]
URL path for change set APIs. :rtype: str :returns: the path based on project, zone, and change set names.
[ "URL", "path", "for", "change", "set", "APIs", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dns/google/cloud/dns/changes.py#L80-L90
train
googleapis/google-cloud-python
dns/google/cloud/dns/changes.py
Changes.name
def name(self, value): """Update name of the change set. :type value: str :param value: New name for the changeset. """ if not isinstance(value, six.string_types): raise ValueError("Pass a string") self._properties["id"] = value
python
def name(self, value): """Update name of the change set. :type value: str :param value: New name for the changeset. """ if not isinstance(value, six.string_types): raise ValueError("Pass a string") self._properties["id"] = value
[ "def", "name", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "raise", "ValueError", "(", "\"Pass a string\"", ")", "self", ".", "_properties", "[", "\"id\"", "]", "=", "value" ]
Update name of the change set. :type value: str :param value: New name for the changeset.
[ "Update", "name", "of", "the", "change", "set", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dns/google/cloud/dns/changes.py#L102-L110
train
googleapis/google-cloud-python
dns/google/cloud/dns/changes.py
Changes.add_record_set
def add_record_set(self, record_set): """Append a record set to the 'additions' for the change set. :type record_set: :class:`google.cloud.dns.resource_record_set.ResourceRecordSet` :param record_set: the record set to append. :raises: ``ValueError`` if ``record_set`` is no...
python
def add_record_set(self, record_set): """Append a record set to the 'additions' for the change set. :type record_set: :class:`google.cloud.dns.resource_record_set.ResourceRecordSet` :param record_set: the record set to append. :raises: ``ValueError`` if ``record_set`` is no...
[ "def", "add_record_set", "(", "self", ",", "record_set", ")", ":", "if", "not", "isinstance", "(", "record_set", ",", "ResourceRecordSet", ")", ":", "raise", "ValueError", "(", "\"Pass a ResourceRecordSet\"", ")", "self", ".", "_additions", "+=", "(", "record_se...
Append a record set to the 'additions' for the change set. :type record_set: :class:`google.cloud.dns.resource_record_set.ResourceRecordSet` :param record_set: the record set to append. :raises: ``ValueError`` if ``record_set`` is not of the required type.
[ "Append", "a", "record", "set", "to", "the", "additions", "for", "the", "change", "set", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dns/google/cloud/dns/changes.py#L152-L163
train
googleapis/google-cloud-python
dns/google/cloud/dns/changes.py
Changes.delete_record_set
def delete_record_set(self, record_set): """Append a record set to the 'deletions' for the change set. :type record_set: :class:`google.cloud.dns.resource_record_set.ResourceRecordSet` :param record_set: the record set to append. :raises: ``ValueError`` if ``record_set`` is...
python
def delete_record_set(self, record_set): """Append a record set to the 'deletions' for the change set. :type record_set: :class:`google.cloud.dns.resource_record_set.ResourceRecordSet` :param record_set: the record set to append. :raises: ``ValueError`` if ``record_set`` is...
[ "def", "delete_record_set", "(", "self", ",", "record_set", ")", ":", "if", "not", "isinstance", "(", "record_set", ",", "ResourceRecordSet", ")", ":", "raise", "ValueError", "(", "\"Pass a ResourceRecordSet\"", ")", "self", ".", "_deletions", "+=", "(", "record...
Append a record set to the 'deletions' for the change set. :type record_set: :class:`google.cloud.dns.resource_record_set.ResourceRecordSet` :param record_set: the record set to append. :raises: ``ValueError`` if ``record_set`` is not of the required type.
[ "Append", "a", "record", "set", "to", "the", "deletions", "for", "the", "change", "set", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dns/google/cloud/dns/changes.py#L165-L176
train
googleapis/google-cloud-python
dns/google/cloud/dns/changes.py
Changes._build_resource
def _build_resource(self): """Generate a resource for ``create``.""" additions = [ { "name": added.name, "type": added.record_type, "ttl": str(added.ttl), "rrdatas": added.rrdatas, } for added in self.add...
python
def _build_resource(self): """Generate a resource for ``create``.""" additions = [ { "name": added.name, "type": added.record_type, "ttl": str(added.ttl), "rrdatas": added.rrdatas, } for added in self.add...
[ "def", "_build_resource", "(", "self", ")", ":", "additions", "=", "[", "{", "\"name\"", ":", "added", ".", "name", ",", "\"type\"", ":", "added", ".", "record_type", ",", "\"ttl\"", ":", "str", "(", "added", ".", "ttl", ")", ",", "\"rrdatas\"", ":", ...
Generate a resource for ``create``.
[ "Generate", "a", "resource", "for", "create", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dns/google/cloud/dns/changes.py#L193-L215
train
googleapis/google-cloud-python
dns/google/cloud/dns/changes.py
Changes.create
def create(self, client=None): """API call: create the change set via a POST request. See https://cloud.google.com/dns/api/v1/changes/create :type client: :class:`google.cloud.dns.client.Client` :param client: (Optional) the client to use. If not passed, falls bac...
python
def create(self, client=None): """API call: create the change set via a POST request. See https://cloud.google.com/dns/api/v1/changes/create :type client: :class:`google.cloud.dns.client.Client` :param client: (Optional) the client to use. If not passed, falls bac...
[ "def", "create", "(", "self", ",", "client", "=", "None", ")", ":", "if", "len", "(", "self", ".", "additions", ")", "==", "0", "and", "len", "(", "self", ".", "deletions", ")", "==", "0", ":", "raise", "ValueError", "(", "\"No record sets added or del...
API call: create the change set via a POST request. See https://cloud.google.com/dns/api/v1/changes/create :type client: :class:`google.cloud.dns.client.Client` :param client: (Optional) the client to use. If not passed, falls back to the ``client`` stored on ...
[ "API", "call", ":", "create", "the", "change", "set", "via", "a", "POST", "request", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dns/google/cloud/dns/changes.py#L217-L238
train
googleapis/google-cloud-python
logging/google/cloud/logging/client.py
Client.logging_api
def logging_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 """ if self._logging_api is None: if self._use_grpc...
python
def logging_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 """ if self._logging_api is None: if self._use_grpc...
[ "def", "logging_api", "(", "self", ")", ":", "if", "self", ".", "_logging_api", "is", "None", ":", "if", "self", ".", "_use_grpc", ":", "self", ".", "_logging_api", "=", "_gapic", ".", "make_logging_api", "(", "self", ")", "else", ":", "self", ".", "_l...
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
[ "Helper", "for", "logging", "-", "related", "API", "calls", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging/client.py#L114-L126
train
googleapis/google-cloud-python
logging/google/cloud/logging/client.py
Client.sinks_api
def sinks_api(self): """Helper for log sink-related API calls. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks """ if self._sinks_api is None: if self._use_grpc: self._sinks_api = _gapic.make_sinks_api(self) e...
python
def sinks_api(self): """Helper for log sink-related API calls. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks """ if self._sinks_api is None: if self._use_grpc: self._sinks_api = _gapic.make_sinks_api(self) e...
[ "def", "sinks_api", "(", "self", ")", ":", "if", "self", ".", "_sinks_api", "is", "None", ":", "if", "self", ".", "_use_grpc", ":", "self", ".", "_sinks_api", "=", "_gapic", ".", "make_sinks_api", "(", "self", ")", "else", ":", "self", ".", "_sinks_api...
Helper for log sink-related API calls. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks
[ "Helper", "for", "log", "sink", "-", "related", "API", "calls", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging/client.py#L129-L140
train
googleapis/google-cloud-python
logging/google/cloud/logging/client.py
Client.metrics_api
def metrics_api(self): """Helper for log metric-related API calls. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics """ if self._metrics_api is None: if self._use_grpc: self._metrics_api = _gapic.make_metrics_api(self) ...
python
def metrics_api(self): """Helper for log metric-related API calls. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics """ if self._metrics_api is None: if self._use_grpc: self._metrics_api = _gapic.make_metrics_api(self) ...
[ "def", "metrics_api", "(", "self", ")", ":", "if", "self", ".", "_metrics_api", "is", "None", ":", "if", "self", ".", "_use_grpc", ":", "self", ".", "_metrics_api", "=", "_gapic", ".", "make_metrics_api", "(", "self", ")", "else", ":", "self", ".", "_m...
Helper for log metric-related API calls. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics
[ "Helper", "for", "log", "metric", "-", "related", "API", "calls", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging/client.py#L143-L154
train
googleapis/google-cloud-python
logging/google/cloud/logging/client.py
Client.list_entries
def list_entries( self, projects=None, filter_=None, order_by=None, page_size=None, page_token=None, ): """Return a page of log entries. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list :type projects: list ...
python
def list_entries( self, projects=None, filter_=None, order_by=None, page_size=None, page_token=None, ): """Return a page of log entries. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list :type projects: list ...
[ "def", "list_entries", "(", "self", ",", "projects", "=", "None", ",", "filter_", "=", "None", ",", "order_by", "=", "None", ",", "page_size", "=", "None", ",", "page_token", "=", "None", ",", ")", ":", "if", "projects", "is", "None", ":", "projects", ...
Return a page of log entries. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list :type projects: list of strings :param projects: project IDs to include. If not passed, defaults to the project bound to the client. :type filt...
[ "Return", "a", "page", "of", "log", "entries", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging/client.py#L167-L220
train
googleapis/google-cloud-python
logging/google/cloud/logging/client.py
Client.sink
def sink(self, name, filter_=None, destination=None): """Creates a sink bound to the current client. :type name: str :param name: the name of the sink to be constructed. :type filter_: str :param filter_: (optional) the advanced logs filter expression de...
python
def sink(self, name, filter_=None, destination=None): """Creates a sink bound to the current client. :type name: str :param name: the name of the sink to be constructed. :type filter_: str :param filter_: (optional) the advanced logs filter expression de...
[ "def", "sink", "(", "self", ",", "name", ",", "filter_", "=", "None", ",", "destination", "=", "None", ")", ":", "return", "Sink", "(", "name", ",", "filter_", ",", "destination", ",", "client", "=", "self", ")" ]
Creates a sink bound to the current client. :type name: str :param name: the name of the sink to be constructed. :type filter_: str :param filter_: (optional) the advanced logs filter expression defining the entries exported by the sink. If not ...
[ "Creates", "a", "sink", "bound", "to", "the", "current", "client", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging/client.py#L222-L243
train
googleapis/google-cloud-python
logging/google/cloud/logging/client.py
Client.list_sinks
def list_sinks(self, page_size=None, page_token=None): """List sinks for the project associated with this client. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/list :type page_size: int :param page_size: Optional. The maximum number o...
python
def list_sinks(self, page_size=None, page_token=None): """List sinks for the project associated with this client. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/list :type page_size: int :param page_size: Optional. The maximum number o...
[ "def", "list_sinks", "(", "self", ",", "page_size", "=", "None", ",", "page_token", "=", "None", ")", ":", "return", "self", ".", "sinks_api", ".", "list_sinks", "(", "self", ".", "project", ",", "page_size", ",", "page_token", ")" ]
List sinks for the project associated with this client. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/list :type page_size: int :param page_size: Optional. The maximum number of sinks in each page of results from this request. Non...
[ "List", "sinks", "for", "the", "project", "associated", "with", "this", "client", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging/client.py#L245-L270
train
googleapis/google-cloud-python
logging/google/cloud/logging/client.py
Client.metric
def metric(self, name, filter_=None, description=""): """Creates a metric bound to the current client. :type name: str :param name: the name of the metric to be constructed. :type filter_: str :param filter_: the advanced logs filter expression defining the ...
python
def metric(self, name, filter_=None, description=""): """Creates a metric bound to the current client. :type name: str :param name: the name of the metric to be constructed. :type filter_: str :param filter_: the advanced logs filter expression defining the ...
[ "def", "metric", "(", "self", ",", "name", ",", "filter_", "=", "None", ",", "description", "=", "\"\"", ")", ":", "return", "Metric", "(", "name", ",", "filter_", ",", "client", "=", "self", ",", "description", "=", "description", ")" ]
Creates a metric bound to the current client. :type name: str :param name: the name of the metric to be constructed. :type filter_: str :param filter_: the advanced logs filter expression defining the entries tracked by the metric. If not ...
[ "Creates", "a", "metric", "bound", "to", "the", "current", "client", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging/client.py#L272-L292
train
googleapis/google-cloud-python
logging/google/cloud/logging/client.py
Client.list_metrics
def list_metrics(self, page_size=None, page_token=None): """List metrics for the project associated with this client. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/list :type page_size: int :param page_size: Optional. The maximum nu...
python
def list_metrics(self, page_size=None, page_token=None): """List metrics for the project associated with this client. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/list :type page_size: int :param page_size: Optional. The maximum nu...
[ "def", "list_metrics", "(", "self", ",", "page_size", "=", "None", ",", "page_token", "=", "None", ")", ":", "return", "self", ".", "metrics_api", ".", "list_metrics", "(", "self", ".", "project", ",", "page_size", ",", "page_token", ")" ]
List metrics for the project associated with this client. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/list :type page_size: int :param page_size: Optional. The maximum number of metrics in each page of results from this reques...
[ "List", "metrics", "for", "the", "project", "associated", "with", "this", "client", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging/client.py#L294-L318
train
googleapis/google-cloud-python
logging/google/cloud/logging/client.py
Client.get_default_handler
def get_default_handler(self, **kw): """Return the default logging handler based on the local environment. :type kw: dict :param kw: keyword args passed to handler constructor :rtype: :class:`logging.Handler` :returns: The default log handler based on the environment ""...
python
def get_default_handler(self, **kw): """Return the default logging handler based on the local environment. :type kw: dict :param kw: keyword args passed to handler constructor :rtype: :class:`logging.Handler` :returns: The default log handler based on the environment ""...
[ "def", "get_default_handler", "(", "self", ",", "*", "*", "kw", ")", ":", "gke_cluster_name", "=", "retrieve_metadata_server", "(", "_GKE_CLUSTER_NAME", ")", "if", "(", "_APPENGINE_FLEXIBLE_ENV_VM", "in", "os", ".", "environ", "or", "_APPENGINE_INSTANCE_ID", "in", ...
Return the default logging handler based on the local environment. :type kw: dict :param kw: keyword args passed to handler constructor :rtype: :class:`logging.Handler` :returns: The default log handler based on the environment
[ "Return", "the", "default", "logging", "handler", "based", "on", "the", "local", "environment", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging/client.py#L320-L339
train
googleapis/google-cloud-python
logging/google/cloud/logging/client.py
Client.setup_logging
def setup_logging( self, log_level=logging.INFO, excluded_loggers=EXCLUDED_LOGGER_DEFAULTS, **kw ): """Attach default Stackdriver logging handler to the root logger. This method uses the default log handler, obtained by :meth:`~get_default_handler`, and attaches it to the root Pytho...
python
def setup_logging( self, log_level=logging.INFO, excluded_loggers=EXCLUDED_LOGGER_DEFAULTS, **kw ): """Attach default Stackdriver logging handler to the root logger. This method uses the default log handler, obtained by :meth:`~get_default_handler`, and attaches it to the root Pytho...
[ "def", "setup_logging", "(", "self", ",", "log_level", "=", "logging", ".", "INFO", ",", "excluded_loggers", "=", "EXCLUDED_LOGGER_DEFAULTS", ",", "*", "*", "kw", ")", ":", "handler", "=", "self", ".", "get_default_handler", "(", "*", "*", "kw", ")", "setu...
Attach default Stackdriver logging handler to the root logger. This method uses the default log handler, obtained by :meth:`~get_default_handler`, and attaches it to the root Python logger, so that a call such as ``logging.warn``, as well as all child loggers, will report to Stackdriver...
[ "Attach", "default", "Stackdriver", "logging", "handler", "to", "the", "root", "logger", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging/client.py#L341-L365
train
googleapis/google-cloud-python
kms/google/cloud/kms_v1/gapic/key_management_service_client.py
KeyManagementServiceClient.key_ring_path
def key_ring_path(cls, project, location, key_ring): """Return a fully-qualified key_ring string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/keyRings/{key_ring}", project=project, location=location, key_ring=ke...
python
def key_ring_path(cls, project, location, key_ring): """Return a fully-qualified key_ring string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/keyRings/{key_ring}", project=project, location=location, key_ring=ke...
[ "def", "key_ring_path", "(", "cls", ",", "project", ",", "location", ",", "key_ring", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "\"projects/{project}/locations/{location}/keyRings/{key_ring}\"", ",", "project", "=", "pr...
Return a fully-qualified key_ring string.
[ "Return", "a", "fully", "-", "qualified", "key_ring", "string", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/kms/google/cloud/kms_v1/gapic/key_management_service_client.py#L88-L95
train
googleapis/google-cloud-python
kms/google/cloud/kms_v1/gapic/key_management_service_client.py
KeyManagementServiceClient.crypto_key_path_path
def crypto_key_path_path(cls, project, location, key_ring, crypto_key_path): """Return a fully-qualified crypto_key_path string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key_path=**}", project=...
python
def crypto_key_path_path(cls, project, location, key_ring, crypto_key_path): """Return a fully-qualified crypto_key_path string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key_path=**}", project=...
[ "def", "crypto_key_path_path", "(", "cls", ",", "project", ",", "location", ",", "key_ring", ",", "crypto_key_path", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "\"projects/{project}/locations/{location}/keyRings/{key_ring}/c...
Return a fully-qualified crypto_key_path string.
[ "Return", "a", "fully", "-", "qualified", "crypto_key_path", "string", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/kms/google/cloud/kms_v1/gapic/key_management_service_client.py#L98-L106
train
googleapis/google-cloud-python
kms/google/cloud/kms_v1/gapic/key_management_service_client.py
KeyManagementServiceClient.crypto_key_version_path
def crypto_key_version_path( cls, project, location, key_ring, crypto_key, crypto_key_version ): """Return a fully-qualified crypto_key_version string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_...
python
def crypto_key_version_path( cls, project, location, key_ring, crypto_key, crypto_key_version ): """Return a fully-qualified crypto_key_version string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_...
[ "def", "crypto_key_version_path", "(", "cls", ",", "project", ",", "location", ",", "key_ring", ",", "crypto_key", ",", "crypto_key_version", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "\"projects/{project}/locations/{lo...
Return a fully-qualified crypto_key_version string.
[ "Return", "a", "fully", "-", "qualified", "crypto_key_version", "string", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/kms/google/cloud/kms_v1/gapic/key_management_service_client.py#L129-L140
train
googleapis/google-cloud-python
kms/google/cloud/kms_v1/gapic/key_management_service_client.py
KeyManagementServiceClient.create_key_ring
def create_key_ring( self, parent, key_ring_id, key_ring, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Create a new ``KeyRing`` in a given Project and Location. E...
python
def create_key_ring( self, parent, key_ring_id, key_ring, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Create a new ``KeyRing`` in a given Project and Location. E...
[ "def", "create_key_ring", "(", "self", ",", "parent", ",", "key_ring_id", ",", "key_ring", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", ...
Create a new ``KeyRing`` in a given Project and Location. Example: >>> from google.cloud import kms_v1 >>> >>> client = kms_v1.KeyManagementServiceClient() >>> >>> parent = client.location_path('[PROJECT]', '[LOCATION]') >>> >>...
[ "Create", "a", "new", "KeyRing", "in", "a", "given", "Project", "and", "Location", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/kms/google/cloud/kms_v1/gapic/key_management_service_client.py#L763-L847
train
googleapis/google-cloud-python
kms/google/cloud/kms_v1/gapic/key_management_service_client.py
KeyManagementServiceClient.create_crypto_key
def create_crypto_key( self, parent, crypto_key_id, crypto_key, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Create a new ``CryptoKey`` within a ``KeyRing``. ``Cr...
python
def create_crypto_key( self, parent, crypto_key_id, crypto_key, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Create a new ``CryptoKey`` within a ``KeyRing``. ``Cr...
[ "def", "create_crypto_key", "(", "self", ",", "parent", ",", "crypto_key_id", ",", "crypto_key", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ...
Create a new ``CryptoKey`` within a ``KeyRing``. ``CryptoKey.purpose`` and ``CryptoKey.version_template.algorithm`` are required. Example: >>> from google.cloud import kms_v1 >>> from google.cloud.kms_v1 import enums >>> >>> client = kms_v1.KeyMa...
[ "Create", "a", "new", "CryptoKey", "within", "a", "KeyRing", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/kms/google/cloud/kms_v1/gapic/key_management_service_client.py#L849-L938
train
googleapis/google-cloud-python
trace/google/cloud/trace_v2/gapic/trace_service_client.py
TraceServiceClient.span_path
def span_path(cls, project, trace, span): """Return a fully-qualified span string.""" return google.api_core.path_template.expand( "projects/{project}/traces/{trace}/spans/{span}", project=project, trace=trace, span=span, )
python
def span_path(cls, project, trace, span): """Return a fully-qualified span string.""" return google.api_core.path_template.expand( "projects/{project}/traces/{trace}/spans/{span}", project=project, trace=trace, span=span, )
[ "def", "span_path", "(", "cls", ",", "project", ",", "trace", ",", "span", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "\"projects/{project}/traces/{trace}/spans/{span}\"", ",", "project", "=", "project", ",", "trace"...
Return a fully-qualified span string.
[ "Return", "a", "fully", "-", "qualified", "span", "string", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/trace/google/cloud/trace_v2/gapic/trace_service_client.py#L88-L95
train
googleapis/google-cloud-python
trace/google/cloud/trace_v2/gapic/trace_service_client.py
TraceServiceClient.batch_write_spans
def batch_write_spans( self, name, spans, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Sends new spans to new or existing traces. You cannot update existing spans. ...
python
def batch_write_spans( self, name, spans, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Sends new spans to new or existing traces. You cannot update existing spans. ...
[ "def", "batch_write_spans", "(", "self", ",", "name", ",", "spans", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAUL...
Sends new spans to new or existing traces. You cannot update existing spans. Example: >>> from google.cloud import trace_v2 >>> >>> client = trace_v2.TraceServiceClient() >>> >>> name = client.project_path('[PROJECT]') >>> ...
[ "Sends", "new", "spans", "to", "new", "or", "existing", "traces", ".", "You", "cannot", "update", "existing", "spans", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/trace/google/cloud/trace_v2/gapic/trace_service_client.py#L196-L271
train
googleapis/google-cloud-python
trace/google/cloud/trace_v2/gapic/trace_service_client.py
TraceServiceClient.create_span
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...
python
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", "create_span", "(", "self", ",", "name", ",", "span_id", ",", "display_name", ",", "start_time", ",", "end_time", ",", "parent_span_id", "=", "None", ",", "attributes", "=", "None", ",", "stack_trace", "=", "None", ",", "time_events", "=", "None", "...
Creates a new span. Example: >>> from google.cloud import trace_v2 >>> >>> client = trace_v2.TraceServiceClient() >>> >>> name = client.span_path('[PROJECT]', '[TRACE]', '[SPAN]') >>> >>> # TODO: Initialize `span_id`: ...
[ "Creates", "a", "new", "span", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/trace/google/cloud/trace_v2/gapic/trace_service_client.py#L273-L447
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
_wrap_callback_errors
def _wrap_callback_errors(callback, message): """Wraps a user callback so that if an exception occurs the message is nacked. Args: callback (Callable[None, Message]): The user callback. message (~Message): The Pub/Sub message. """ try: callback(message) except Exception:...
python
def _wrap_callback_errors(callback, message): """Wraps a user callback so that if an exception occurs the message is nacked. Args: callback (Callable[None, Message]): The user callback. message (~Message): The Pub/Sub message. """ try: callback(message) except Exception:...
[ "def", "_wrap_callback_errors", "(", "callback", ",", "message", ")", ":", "try", ":", "callback", "(", "message", ")", "except", "Exception", ":", "# Note: the likelihood of this failing is extremely low. This just adds", "# a message to a queue, so if this doesn't work the worl...
Wraps a user callback so that if an exception occurs the message is nacked. Args: callback (Callable[None, Message]): The user callback. message (~Message): The Pub/Sub message.
[ "Wraps", "a", "user", "callback", "so", "that", "if", "an", "exception", "occurs", "the", "message", "is", "nacked", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L55-L72
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
StreamingPullManager.ack_deadline
def ack_deadline(self): """Return the current ack deadline based on historical time-to-ack. This method is "sticky". It will only perform the computations to check on the right ack deadline if the histogram has gained a significant amount of new information. Returns: ...
python
def ack_deadline(self): """Return the current ack deadline based on historical time-to-ack. This method is "sticky". It will only perform the computations to check on the right ack deadline if the histogram has gained a significant amount of new information. Returns: ...
[ "def", "ack_deadline", "(", "self", ")", ":", "target", "=", "min", "(", "[", "self", ".", "_last_histogram_size", "*", "2", ",", "self", ".", "_last_histogram_size", "+", "100", "]", ")", "if", "len", "(", "self", ".", "ack_histogram", ")", ">", "targ...
Return the current ack deadline based on historical time-to-ack. This method is "sticky". It will only perform the computations to check on the right ack deadline if the histogram has gained a significant amount of new information. Returns: int: The ack deadline.
[ "Return", "the", "current", "ack", "deadline", "based", "on", "historical", "time", "-", "to", "-", "ack", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L161-L174
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
StreamingPullManager.load
def load(self): """Return the current load. The load is represented as a float, where 1.0 represents having hit one of the flow control limits, and values between 0.0 and 1.0 represent how close we are to them. (0.5 means we have exactly half of what the flow control setting all...
python
def load(self): """Return the current load. The load is represented as a float, where 1.0 represents having hit one of the flow control limits, and values between 0.0 and 1.0 represent how close we are to them. (0.5 means we have exactly half of what the flow control setting all...
[ "def", "load", "(", "self", ")", ":", "if", "self", ".", "_leaser", "is", "None", ":", "return", "0", "return", "max", "(", "[", "self", ".", "_leaser", ".", "message_count", "/", "self", ".", "_flow_control", ".", "max_messages", ",", "self", ".", "...
Return the current load. The load is represented as a float, where 1.0 represents having hit one of the flow control limits, and values between 0.0 and 1.0 represent how close we are to them. (0.5 means we have exactly half of what the flow control setting allows, for example.) ...
[ "Return", "the", "current", "load", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L177-L201
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
StreamingPullManager.maybe_pause_consumer
def maybe_pause_consumer(self): """Check the current load and pause the consumer if needed.""" if self.load >= 1.0: if self._consumer is not None and not self._consumer.is_paused: _LOGGER.debug("Message backlog over load at %.2f, pausing.", self.load) self._co...
python
def maybe_pause_consumer(self): """Check the current load and pause the consumer if needed.""" if self.load >= 1.0: if self._consumer is not None and not self._consumer.is_paused: _LOGGER.debug("Message backlog over load at %.2f, pausing.", self.load) self._co...
[ "def", "maybe_pause_consumer", "(", "self", ")", ":", "if", "self", ".", "load", ">=", "1.0", ":", "if", "self", ".", "_consumer", "is", "not", "None", "and", "not", "self", ".", "_consumer", ".", "is_paused", ":", "_LOGGER", ".", "debug", "(", "\"Mess...
Check the current load and pause the consumer if needed.
[ "Check", "the", "current", "load", "and", "pause", "the", "consumer", "if", "needed", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L211-L216
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
StreamingPullManager.maybe_resume_consumer
def maybe_resume_consumer(self): """Check the current load and resume the consumer if needed.""" # If we have been paused by flow control, check and see if we are # back within our limits. # # In order to not thrash too much, require us to have passed below # the resume t...
python
def maybe_resume_consumer(self): """Check the current load and resume the consumer if needed.""" # If we have been paused by flow control, check and see if we are # back within our limits. # # In order to not thrash too much, require us to have passed below # the resume t...
[ "def", "maybe_resume_consumer", "(", "self", ")", ":", "# If we have been paused by flow control, check and see if we are", "# back within our limits.", "#", "# In order to not thrash too much, require us to have passed below", "# the resume threshold (80% by default) of each flow control settin...
Check the current load and resume the consumer if needed.
[ "Check", "the", "current", "load", "and", "resume", "the", "consumer", "if", "needed", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L218-L232
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
StreamingPullManager._send_unary_request
def _send_unary_request(self, request): """Send a request using a separate unary request instead of over the stream. Args: request (types.StreamingPullRequest): The stream request to be mapped into unary requests. """ if request.ack_ids: s...
python
def _send_unary_request(self, request): """Send a request using a separate unary request instead of over the stream. Args: request (types.StreamingPullRequest): The stream request to be mapped into unary requests. """ if request.ack_ids: s...
[ "def", "_send_unary_request", "(", "self", ",", "request", ")", ":", "if", "request", ".", "ack_ids", ":", "self", ".", "_client", ".", "acknowledge", "(", "subscription", "=", "self", ".", "_subscription", ",", "ack_ids", "=", "list", "(", "request", ".",...
Send a request using a separate unary request instead of over the stream. Args: request (types.StreamingPullRequest): The stream request to be mapped into unary requests.
[ "Send", "a", "request", "using", "a", "separate", "unary", "request", "instead", "of", "over", "the", "stream", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L234-L262
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
StreamingPullManager.send
def send(self, request): """Queue a request to be sent to the RPC.""" if self._UNARY_REQUESTS: try: self._send_unary_request(request) except exceptions.GoogleAPICallError: _LOGGER.debug( "Exception while sending unary RPC. This ...
python
def send(self, request): """Queue a request to be sent to the RPC.""" if self._UNARY_REQUESTS: try: self._send_unary_request(request) except exceptions.GoogleAPICallError: _LOGGER.debug( "Exception while sending unary RPC. This ...
[ "def", "send", "(", "self", ",", "request", ")", ":", "if", "self", ".", "_UNARY_REQUESTS", ":", "try", ":", "self", ".", "_send_unary_request", "(", "request", ")", "except", "exceptions", ".", "GoogleAPICallError", ":", "_LOGGER", ".", "debug", "(", "\"E...
Queue a request to be sent to the RPC.
[ "Queue", "a", "request", "to", "be", "sent", "to", "the", "RPC", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L264-L276
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
StreamingPullManager.heartbeat
def heartbeat(self): """Sends an empty request over the streaming pull RPC. This always sends over the stream, regardless of if ``self._UNARY_REQUESTS`` is set or not. """ if self._rpc is not None and self._rpc.is_active: self._rpc.send(types.StreamingPullRequest())
python
def heartbeat(self): """Sends an empty request over the streaming pull RPC. This always sends over the stream, regardless of if ``self._UNARY_REQUESTS`` is set or not. """ if self._rpc is not None and self._rpc.is_active: self._rpc.send(types.StreamingPullRequest())
[ "def", "heartbeat", "(", "self", ")", ":", "if", "self", ".", "_rpc", "is", "not", "None", "and", "self", ".", "_rpc", ".", "is_active", ":", "self", ".", "_rpc", ".", "send", "(", "types", ".", "StreamingPullRequest", "(", ")", ")" ]
Sends an empty request over the streaming pull RPC. This always sends over the stream, regardless of if ``self._UNARY_REQUESTS`` is set or not.
[ "Sends", "an", "empty", "request", "over", "the", "streaming", "pull", "RPC", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L278-L285
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
StreamingPullManager.open
def open(self, callback): """Begin consuming messages. Args: callback (Callable[None, google.cloud.pubsub_v1.message.Messages]): A callback that will be called for each message received on the stream. """ if self.is_active: raise V...
python
def open(self, callback): """Begin consuming messages. Args: callback (Callable[None, google.cloud.pubsub_v1.message.Messages]): A callback that will be called for each message received on the stream. """ if self.is_active: raise V...
[ "def", "open", "(", "self", ",", "callback", ")", ":", "if", "self", ".", "is_active", ":", "raise", "ValueError", "(", "\"This manager is already open.\"", ")", "if", "self", ".", "_closed", ":", "raise", "ValueError", "(", "\"This manager has been closed and can...
Begin consuming messages. Args: callback (Callable[None, google.cloud.pubsub_v1.message.Messages]): A callback that will be called for each message received on the stream.
[ "Begin", "consuming", "messages", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L287-L327
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
StreamingPullManager.close
def close(self, reason=None): """Stop consuming messages and shutdown all helper threads. This method is idempotent. Additional calls will have no effect. Args: reason (Any): The reason to close this. If None, this is considered an "intentional" shutdown. This is pa...
python
def close(self, reason=None): """Stop consuming messages and shutdown all helper threads. This method is idempotent. Additional calls will have no effect. Args: reason (Any): The reason to close this. If None, this is considered an "intentional" shutdown. This is pa...
[ "def", "close", "(", "self", ",", "reason", "=", "None", ")", ":", "with", "self", ".", "_closing", ":", "if", "self", ".", "_closed", ":", "return", "# Stop consuming messages.", "if", "self", ".", "is_active", ":", "_LOGGER", ".", "debug", "(", "\"Stop...
Stop consuming messages and shutdown all helper threads. This method is idempotent. Additional calls will have no effect. Args: reason (Any): The reason to close this. If None, this is considered an "intentional" shutdown. This is passed to the callbacks spe...
[ "Stop", "consuming", "messages", "and", "shutdown", "all", "helper", "threads", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L329-L368
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
StreamingPullManager._get_initial_request
def _get_initial_request(self): """Return the initial request for the RPC. This defines the initial request that must always be sent to Pub/Sub immediately upon opening the subscription. Returns: google.cloud.pubsub_v1.types.StreamingPullRequest: A request suita...
python
def _get_initial_request(self): """Return the initial request for the RPC. This defines the initial request that must always be sent to Pub/Sub immediately upon opening the subscription. Returns: google.cloud.pubsub_v1.types.StreamingPullRequest: A request suita...
[ "def", "_get_initial_request", "(", "self", ")", ":", "# Any ack IDs that are under lease management need to have their", "# deadline extended immediately.", "if", "self", ".", "_leaser", "is", "not", "None", ":", "# Explicitly copy the list, as it could be modified by another", "#...
Return the initial request for the RPC. This defines the initial request that must always be sent to Pub/Sub immediately upon opening the subscription. Returns: google.cloud.pubsub_v1.types.StreamingPullRequest: A request suitable for being the first request on the stre...
[ "Return", "the", "initial", "request", "for", "the", "RPC", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L370-L399
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
StreamingPullManager._on_response
def _on_response(self, response): """Process all received Pub/Sub messages. For each message, send a modified acknowledgment request to the server. This prevents expiration of the message due to buffering by gRPC or proxy/firewall. This makes the server and client expiration tim...
python
def _on_response(self, response): """Process all received Pub/Sub messages. For each message, send a modified acknowledgment request to the server. This prevents expiration of the message due to buffering by gRPC or proxy/firewall. This makes the server and client expiration tim...
[ "def", "_on_response", "(", "self", ",", "response", ")", ":", "_LOGGER", ".", "debug", "(", "\"Scheduling callbacks for %s messages.\"", ",", "len", "(", "response", ".", "received_messages", ")", ")", "# Immediately modack the messages we received, as this tells the serve...
Process all received Pub/Sub messages. For each message, send a modified acknowledgment request to the server. This prevents expiration of the message due to buffering by gRPC or proxy/firewall. This makes the server and client expiration timer closer to each other thus preventing the m...
[ "Process", "all", "received", "Pub", "/", "Sub", "messages", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L401-L430
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py
StreamingPullManager._should_recover
def _should_recover(self, exception): """Determine if an error on the RPC stream should be recovered. If the exception is one of the retryable exceptions, this will signal to the consumer thread that it should "recover" from the failure. This will cause the stream to exit when it retur...
python
def _should_recover(self, exception): """Determine if an error on the RPC stream should be recovered. If the exception is one of the retryable exceptions, this will signal to the consumer thread that it should "recover" from the failure. This will cause the stream to exit when it retur...
[ "def", "_should_recover", "(", "self", ",", "exception", ")", ":", "exception", "=", "_maybe_wrap_exception", "(", "exception", ")", "# If this is in the list of idempotent exceptions, then we want to", "# recover.", "if", "isinstance", "(", "exception", ",", "_RETRYABLE_ST...
Determine if an error on the RPC stream should be recovered. If the exception is one of the retryable exceptions, this will signal to the consumer thread that it should "recover" from the failure. This will cause the stream to exit when it returns :data:`False`. Returns: b...
[ "Determine", "if", "an", "error", "on", "the", "RPC", "stream", "should", "be", "recovered", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py#L432-L452
train
googleapis/google-cloud-python
firestore/google/cloud/firestore_v1beta1/batch.py
WriteBatch.create
def create(self, reference, document_data): """Add a "change" to this batch to create a document. If the document given by ``reference`` already exists, then this batch will fail when :meth:`commit`-ed. Args: reference (~.firestore_v1beta1.document.DocumentReference): A ...
python
def create(self, reference, document_data): """Add a "change" to this batch to create a document. If the document given by ``reference`` already exists, then this batch will fail when :meth:`commit`-ed. Args: reference (~.firestore_v1beta1.document.DocumentReference): A ...
[ "def", "create", "(", "self", ",", "reference", ",", "document_data", ")", ":", "write_pbs", "=", "_helpers", ".", "pbs_for_create", "(", "reference", ".", "_document_path", ",", "document_data", ")", "self", ".", "_add_write_pbs", "(", "write_pbs", ")" ]
Add a "change" to this batch to create a document. If the document given by ``reference`` already exists, then this batch will fail when :meth:`commit`-ed. Args: reference (~.firestore_v1beta1.document.DocumentReference): A document reference to be created in this b...
[ "Add", "a", "change", "to", "this", "batch", "to", "create", "a", "document", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/firestore/google/cloud/firestore_v1beta1/batch.py#L50-L63
train
googleapis/google-cloud-python
firestore/google/cloud/firestore_v1beta1/batch.py
WriteBatch.set
def set(self, reference, document_data, merge=False): """Add a "change" to replace a document. See :meth:`~.firestore_v1beta1.document.DocumentReference.set` for more information on how ``option`` determines how the change is applied. Args: reference (~.fire...
python
def set(self, reference, document_data, merge=False): """Add a "change" to replace a document. See :meth:`~.firestore_v1beta1.document.DocumentReference.set` for more information on how ``option`` determines how the change is applied. Args: reference (~.fire...
[ "def", "set", "(", "self", ",", "reference", ",", "document_data", ",", "merge", "=", "False", ")", ":", "if", "merge", "is", "not", "False", ":", "write_pbs", "=", "_helpers", ".", "pbs_for_set_with_merge", "(", "reference", ".", "_document_path", ",", "d...
Add a "change" to replace a document. See :meth:`~.firestore_v1beta1.document.DocumentReference.set` for more information on how ``option`` determines how the change is applied. Args: reference (~.firestore_v1beta1.document.DocumentReference): A docu...
[ "Add", "a", "change", "to", "replace", "a", "document", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/firestore/google/cloud/firestore_v1beta1/batch.py#L65-L91
train
googleapis/google-cloud-python
firestore/google/cloud/firestore_v1beta1/batch.py
WriteBatch.update
def update(self, reference, field_updates, option=None): """Add a "change" to update a document. See :meth:`~.firestore_v1beta1.document.DocumentReference.update` for more information on ``field_updates`` and ``option``. Args: reference (~.firestore_v1beta1.document...
python
def update(self, reference, field_updates, option=None): """Add a "change" to update a document. See :meth:`~.firestore_v1beta1.document.DocumentReference.update` for more information on ``field_updates`` and ``option``. Args: reference (~.firestore_v1beta1.document...
[ "def", "update", "(", "self", ",", "reference", ",", "field_updates", ",", "option", "=", "None", ")", ":", "if", "option", ".", "__class__", ".", "__name__", "==", "\"ExistsOption\"", ":", "raise", "ValueError", "(", "\"you must not pass an explicit write option ...
Add a "change" to update a document. See :meth:`~.firestore_v1beta1.document.DocumentReference.update` for more information on ``field_updates`` and ``option``. Args: reference (~.firestore_v1beta1.document.DocumentReference): A document reference that will b...
[ "Add", "a", "change", "to", "update", "a", "document", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/firestore/google/cloud/firestore_v1beta1/batch.py#L93-L114
train
googleapis/google-cloud-python
firestore/google/cloud/firestore_v1beta1/batch.py
WriteBatch.delete
def delete(self, reference, option=None): """Add a "change" to delete a document. See :meth:`~.firestore_v1beta1.document.DocumentReference.delete` for more information on how ``option`` determines how the change is applied. Args: reference (~.firestore_v1be...
python
def delete(self, reference, option=None): """Add a "change" to delete a document. See :meth:`~.firestore_v1beta1.document.DocumentReference.delete` for more information on how ``option`` determines how the change is applied. Args: reference (~.firestore_v1be...
[ "def", "delete", "(", "self", ",", "reference", ",", "option", "=", "None", ")", ":", "write_pb", "=", "_helpers", ".", "pb_for_delete", "(", "reference", ".", "_document_path", ",", "option", ")", "self", ".", "_add_write_pbs", "(", "[", "write_pb", "]", ...
Add a "change" to delete a document. See :meth:`~.firestore_v1beta1.document.DocumentReference.delete` for more information on how ``option`` determines how the change is applied. Args: reference (~.firestore_v1beta1.document.DocumentReference): A doc...
[ "Add", "a", "change", "to", "delete", "a", "document", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/firestore/google/cloud/firestore_v1beta1/batch.py#L116-L132
train
googleapis/google-cloud-python
firestore/google/cloud/firestore_v1beta1/batch.py
WriteBatch.commit
def commit(self): """Commit the changes accumulated in this batch. Returns: List[google.cloud.proto.firestore.v1beta1.\ write_pb2.WriteResult, ...]: The write results corresponding to the changes committed, returned in the same order as the changes we...
python
def commit(self): """Commit the changes accumulated in this batch. Returns: List[google.cloud.proto.firestore.v1beta1.\ write_pb2.WriteResult, ...]: The write results corresponding to the changes committed, returned in the same order as the changes we...
[ "def", "commit", "(", "self", ")", ":", "commit_response", "=", "self", ".", "_client", ".", "_firestore_api", ".", "commit", "(", "self", ".", "_client", ".", "_database_string", ",", "self", ".", "_write_pbs", ",", "transaction", "=", "None", ",", "metad...
Commit the changes accumulated in this batch. Returns: List[google.cloud.proto.firestore.v1beta1.\ write_pb2.WriteResult, ...]: The write results corresponding to the changes committed, returned in the same order as the changes were applied to this batch. A w...
[ "Commit", "the", "changes", "accumulated", "in", "this", "batch", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/firestore/google/cloud/firestore_v1beta1/batch.py#L134-L154
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
_ensure_tuple_or_list
def _ensure_tuple_or_list(arg_name, tuple_or_list): """Ensures an input is a tuple or list. This effectively reduces the iterable types allowed to a very short whitelist: list and tuple. :type arg_name: str :param arg_name: Name of argument to use in error message. :type tuple_or_list: sequen...
python
def _ensure_tuple_or_list(arg_name, tuple_or_list): """Ensures an input is a tuple or list. This effectively reduces the iterable types allowed to a very short whitelist: list and tuple. :type arg_name: str :param arg_name: Name of argument to use in error message. :type tuple_or_list: sequen...
[ "def", "_ensure_tuple_or_list", "(", "arg_name", ",", "tuple_or_list", ")", ":", "if", "not", "isinstance", "(", "tuple_or_list", ",", "(", "tuple", ",", "list", ")", ")", ":", "raise", "TypeError", "(", "\"Expected %s to be a tuple or list. \"", "\"Received %r\"", ...
Ensures an input is a tuple or list. This effectively reduces the iterable types allowed to a very short whitelist: list and tuple. :type arg_name: str :param arg_name: Name of argument to use in error message. :type tuple_or_list: sequence of str :param tuple_or_list: Sequence to be verified...
[ "Ensures", "an", "input", "is", "a", "tuple", "or", "list", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L149-L170
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
_microseconds_from_datetime
def _microseconds_from_datetime(value): """Convert non-none datetime to microseconds. :type value: :class:`datetime.datetime` :param value: The timestamp to convert. :rtype: int :returns: The timestamp, in microseconds. """ if not value.tzinfo: value = value.replace(tzinfo=UTC) ...
python
def _microseconds_from_datetime(value): """Convert non-none datetime to microseconds. :type value: :class:`datetime.datetime` :param value: The timestamp to convert. :rtype: int :returns: The timestamp, in microseconds. """ if not value.tzinfo: value = value.replace(tzinfo=UTC) ...
[ "def", "_microseconds_from_datetime", "(", "value", ")", ":", "if", "not", "value", ".", "tzinfo", ":", "value", "=", "value", ".", "replace", "(", "tzinfo", "=", "UTC", ")", "# Regardless of what timezone is on the value, convert it to UTC.", "value", "=", "value",...
Convert non-none datetime to microseconds. :type value: :class:`datetime.datetime` :param value: The timestamp to convert. :rtype: int :returns: The timestamp, in microseconds.
[ "Convert", "non", "-", "none", "datetime", "to", "microseconds", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L215-L229
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
_time_from_iso8601_time_naive
def _time_from_iso8601_time_naive(value): """Convert a zoneless ISO8601 time string to naive datetime time :type value: str :param value: The time string to convert :rtype: :class:`datetime.time` :returns: A datetime time object created from the string :raises ValueError: if the value does not...
python
def _time_from_iso8601_time_naive(value): """Convert a zoneless ISO8601 time string to naive datetime time :type value: str :param value: The time string to convert :rtype: :class:`datetime.time` :returns: A datetime time object created from the string :raises ValueError: if the value does not...
[ "def", "_time_from_iso8601_time_naive", "(", "value", ")", ":", "if", "len", "(", "value", ")", "==", "8", ":", "# HH:MM:SS", "fmt", "=", "_TIMEONLY_NO_FRACTION", "elif", "len", "(", "value", ")", "==", "15", ":", "# HH:MM:SS.micros", "fmt", "=", "_TIMEONLY_...
Convert a zoneless ISO8601 time string to naive datetime time :type value: str :param value: The time string to convert :rtype: :class:`datetime.time` :returns: A datetime time object created from the string :raises ValueError: if the value does not match a known format.
[ "Convert", "a", "zoneless", "ISO8601", "time", "string", "to", "naive", "datetime", "time" ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L258-L274
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
_rfc3339_to_datetime
def _rfc3339_to_datetime(dt_str): """Convert a microsecond-precision timestamp to a native datetime. :type dt_str: str :param dt_str: The string to convert. :rtype: :class:`datetime.datetime` :returns: The datetime object created from the string. """ return datetime.datetime.strptime(dt_st...
python
def _rfc3339_to_datetime(dt_str): """Convert a microsecond-precision timestamp to a native datetime. :type dt_str: str :param dt_str: The string to convert. :rtype: :class:`datetime.datetime` :returns: The datetime object created from the string. """ return datetime.datetime.strptime(dt_st...
[ "def", "_rfc3339_to_datetime", "(", "dt_str", ")", ":", "return", "datetime", ".", "datetime", ".", "strptime", "(", "dt_str", ",", "_RFC3339_MICROS", ")", ".", "replace", "(", "tzinfo", "=", "UTC", ")" ]
Convert a microsecond-precision timestamp to a native datetime. :type dt_str: str :param dt_str: The string to convert. :rtype: :class:`datetime.datetime` :returns: The datetime object created from the string.
[ "Convert", "a", "microsecond", "-", "precision", "timestamp", "to", "a", "native", "datetime", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L277-L286
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
_rfc3339_nanos_to_datetime
def _rfc3339_nanos_to_datetime(dt_str): """Convert a nanosecond-precision timestamp to a native datetime. .. note:: Python datetimes do not support nanosecond precision; this function therefore truncates such values to microseconds. :type dt_str: str :param dt_str: The string to conver...
python
def _rfc3339_nanos_to_datetime(dt_str): """Convert a nanosecond-precision timestamp to a native datetime. .. note:: Python datetimes do not support nanosecond precision; this function therefore truncates such values to microseconds. :type dt_str: str :param dt_str: The string to conver...
[ "def", "_rfc3339_nanos_to_datetime", "(", "dt_str", ")", ":", "with_nanos", "=", "_RFC3339_NANOS", ".", "match", "(", "dt_str", ")", "if", "with_nanos", "is", "None", ":", "raise", "ValueError", "(", "\"Timestamp: %r, does not match pattern: %r\"", "%", "(", "dt_str...
Convert a nanosecond-precision timestamp to a native datetime. .. note:: Python datetimes do not support nanosecond precision; this function therefore truncates such values to microseconds. :type dt_str: str :param dt_str: The string to convert. :rtype: :class:`datetime.datetime` ...
[ "Convert", "a", "nanosecond", "-", "precision", "timestamp", "to", "a", "native", "datetime", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L289-L321
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
_datetime_to_rfc3339
def _datetime_to_rfc3339(value, ignore_zone=True): """Convert a timestamp to a string. :type value: :class:`datetime.datetime` :param value: The datetime object to be converted to a string. :type ignore_zone: bool :param ignore_zone: If True, then the timezone (if any) of the datetime ...
python
def _datetime_to_rfc3339(value, ignore_zone=True): """Convert a timestamp to a string. :type value: :class:`datetime.datetime` :param value: The datetime object to be converted to a string. :type ignore_zone: bool :param ignore_zone: If True, then the timezone (if any) of the datetime ...
[ "def", "_datetime_to_rfc3339", "(", "value", ",", "ignore_zone", "=", "True", ")", ":", "if", "not", "ignore_zone", "and", "value", ".", "tzinfo", "is", "not", "None", ":", "# Convert to UTC and remove the time zone info.", "value", "=", "value", ".", "replace", ...
Convert a timestamp to a string. :type value: :class:`datetime.datetime` :param value: The datetime object to be converted to a string. :type ignore_zone: bool :param ignore_zone: If True, then the timezone (if any) of the datetime object is ignored. :rtype: str :retur...
[ "Convert", "a", "timestamp", "to", "a", "string", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L324-L341
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
_to_bytes
def _to_bytes(value, encoding="ascii"): """Converts a string value to bytes, if necessary. Unfortunately, ``six.b`` is insufficient for this task since in Python2 it does not modify ``unicode`` objects. :type value: str / bytes or unicode :param value: The string/bytes value to be converted. ...
python
def _to_bytes(value, encoding="ascii"): """Converts a string value to bytes, if necessary. Unfortunately, ``six.b`` is insufficient for this task since in Python2 it does not modify ``unicode`` objects. :type value: str / bytes or unicode :param value: The string/bytes value to be converted. ...
[ "def", "_to_bytes", "(", "value", ",", "encoding", "=", "\"ascii\"", ")", ":", "result", "=", "value", ".", "encode", "(", "encoding", ")", "if", "isinstance", "(", "value", ",", "six", ".", "text_type", ")", "else", "value", "if", "isinstance", "(", "...
Converts a string value to bytes, if necessary. Unfortunately, ``six.b`` is insufficient for this task since in Python2 it does not modify ``unicode`` objects. :type value: str / bytes or unicode :param value: The string/bytes value to be converted. :type encoding: str :param encoding: The en...
[ "Converts", "a", "string", "value", "to", "bytes", "if", "necessary", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L344-L370
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
_bytes_to_unicode
def _bytes_to_unicode(value): """Converts bytes to a unicode value, if necessary. :type value: bytes :param value: bytes value to attempt string conversion on. :rtype: str :returns: The original value converted to unicode (if bytes) or as passed in if it started out as unicode. ...
python
def _bytes_to_unicode(value): """Converts bytes to a unicode value, if necessary. :type value: bytes :param value: bytes value to attempt string conversion on. :rtype: str :returns: The original value converted to unicode (if bytes) or as passed in if it started out as unicode. ...
[ "def", "_bytes_to_unicode", "(", "value", ")", ":", "result", "=", "value", ".", "decode", "(", "\"utf-8\"", ")", "if", "isinstance", "(", "value", ",", "six", ".", "binary_type", ")", "else", "value", "if", "isinstance", "(", "result", ",", "six", ".", ...
Converts bytes to a unicode value, if necessary. :type value: bytes :param value: bytes value to attempt string conversion on. :rtype: str :returns: The original value converted to unicode (if bytes) or as passed in if it started out as unicode. :raises ValueError: if the value coul...
[ "Converts", "bytes", "to", "a", "unicode", "value", "if", "necessary", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L373-L389
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
_from_any_pb
def _from_any_pb(pb_type, any_pb): """Converts an Any protobuf to the specified message type Args: pb_type (type): the type of the message that any_pb stores an instance of. any_pb (google.protobuf.any_pb2.Any): the object to be converted. Returns: pb_type: An instance ...
python
def _from_any_pb(pb_type, any_pb): """Converts an Any protobuf to the specified message type Args: pb_type (type): the type of the message that any_pb stores an instance of. any_pb (google.protobuf.any_pb2.Any): the object to be converted. Returns: pb_type: An instance ...
[ "def", "_from_any_pb", "(", "pb_type", ",", "any_pb", ")", ":", "msg", "=", "pb_type", "(", ")", "if", "not", "any_pb", ".", "Unpack", "(", "msg", ")", ":", "raise", "TypeError", "(", "\"Could not convert {} to {}\"", ".", "format", "(", "any_pb", ".", "...
Converts an Any protobuf to the specified message type Args: pb_type (type): the type of the message that any_pb stores an instance of. any_pb (google.protobuf.any_pb2.Any): the object to be converted. Returns: pb_type: An instance of the pb_type message. Raises: ...
[ "Converts", "an", "Any", "protobuf", "to", "the", "specified", "message", "type" ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L392-L414
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
_pb_timestamp_to_datetime
def _pb_timestamp_to_datetime(timestamp_pb): """Convert a Timestamp protobuf to a datetime object. :type timestamp_pb: :class:`google.protobuf.timestamp_pb2.Timestamp` :param timestamp_pb: A Google returned timestamp protobuf. :rtype: :class:`datetime.datetime` :returns: A UTC datetime object conv...
python
def _pb_timestamp_to_datetime(timestamp_pb): """Convert a Timestamp protobuf to a datetime object. :type timestamp_pb: :class:`google.protobuf.timestamp_pb2.Timestamp` :param timestamp_pb: A Google returned timestamp protobuf. :rtype: :class:`datetime.datetime` :returns: A UTC datetime object conv...
[ "def", "_pb_timestamp_to_datetime", "(", "timestamp_pb", ")", ":", "return", "_EPOCH", "+", "datetime", ".", "timedelta", "(", "seconds", "=", "timestamp_pb", ".", "seconds", ",", "microseconds", "=", "(", "timestamp_pb", ".", "nanos", "/", "1000.0", ")", ")" ...
Convert a Timestamp protobuf to a datetime object. :type timestamp_pb: :class:`google.protobuf.timestamp_pb2.Timestamp` :param timestamp_pb: A Google returned timestamp protobuf. :rtype: :class:`datetime.datetime` :returns: A UTC datetime object converted from a protobuf timestamp.
[ "Convert", "a", "Timestamp", "protobuf", "to", "a", "datetime", "object", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L417-L428
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
_datetime_to_pb_timestamp
def _datetime_to_pb_timestamp(when): """Convert a datetime object to a Timestamp protobuf. :type when: :class:`datetime.datetime` :param when: the datetime to convert :rtype: :class:`google.protobuf.timestamp_pb2.Timestamp` :returns: A timestamp protobuf corresponding to the object. """ ms...
python
def _datetime_to_pb_timestamp(when): """Convert a datetime object to a Timestamp protobuf. :type when: :class:`datetime.datetime` :param when: the datetime to convert :rtype: :class:`google.protobuf.timestamp_pb2.Timestamp` :returns: A timestamp protobuf corresponding to the object. """ ms...
[ "def", "_datetime_to_pb_timestamp", "(", "when", ")", ":", "ms_value", "=", "_microseconds_from_datetime", "(", "when", ")", "seconds", ",", "micros", "=", "divmod", "(", "ms_value", ",", "10", "**", "6", ")", "nanos", "=", "micros", "*", "10", "**", "3", ...
Convert a datetime object to a Timestamp protobuf. :type when: :class:`datetime.datetime` :param when: the datetime to convert :rtype: :class:`google.protobuf.timestamp_pb2.Timestamp` :returns: A timestamp protobuf corresponding to the object.
[ "Convert", "a", "datetime", "object", "to", "a", "Timestamp", "protobuf", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L444-L456
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
_duration_pb_to_timedelta
def _duration_pb_to_timedelta(duration_pb): """Convert a duration protobuf to a Python timedelta object. .. note:: The Python timedelta has a granularity of microseconds while the protobuf duration type has a duration of nanoseconds. :type duration_pb: :class:`google.protobuf.duration_pb2...
python
def _duration_pb_to_timedelta(duration_pb): """Convert a duration protobuf to a Python timedelta object. .. note:: The Python timedelta has a granularity of microseconds while the protobuf duration type has a duration of nanoseconds. :type duration_pb: :class:`google.protobuf.duration_pb2...
[ "def", "_duration_pb_to_timedelta", "(", "duration_pb", ")", ":", "return", "datetime", ".", "timedelta", "(", "seconds", "=", "duration_pb", ".", "seconds", ",", "microseconds", "=", "(", "duration_pb", ".", "nanos", "/", "1000.0", ")", ")" ]
Convert a duration protobuf to a Python timedelta object. .. note:: The Python timedelta has a granularity of microseconds while the protobuf duration type has a duration of nanoseconds. :type duration_pb: :class:`google.protobuf.duration_pb2.Duration` :param duration_pb: A protobuf durat...
[ "Convert", "a", "duration", "protobuf", "to", "a", "Python", "timedelta", "object", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L478-L494
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
_name_from_project_path
def _name_from_project_path(path, project, template): """Validate a URI path and get the leaf object's name. :type path: str :param path: URI path containing the name. :type project: str :param project: (Optional) The project associated with the request. It is included for vali...
python
def _name_from_project_path(path, project, template): """Validate a URI path and get the leaf object's name. :type path: str :param path: URI path containing the name. :type project: str :param project: (Optional) The project associated with the request. It is included for vali...
[ "def", "_name_from_project_path", "(", "path", ",", "project", ",", "template", ")", ":", "if", "isinstance", "(", "template", ",", "str", ")", ":", "template", "=", "re", ".", "compile", "(", "template", ")", "match", "=", "template", ".", "match", "(",...
Validate a URI path and get the leaf object's name. :type path: str :param path: URI path containing the name. :type project: str :param project: (Optional) The project associated with the request. It is included for validation purposes. If passed as None, disa...
[ "Validate", "a", "URI", "path", "and", "get", "the", "leaf", "object", "s", "name", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L497-L537
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
make_secure_channel
def make_secure_channel(credentials, user_agent, host, extra_options=()): """Makes a secure channel for an RPC service. Uses / depends on gRPC. :type credentials: :class:`google.auth.credentials.Credentials` :param credentials: The OAuth2 Credentials to use for creating access ...
python
def make_secure_channel(credentials, user_agent, host, extra_options=()): """Makes a secure channel for an RPC service. Uses / depends on gRPC. :type credentials: :class:`google.auth.credentials.Credentials` :param credentials: The OAuth2 Credentials to use for creating access ...
[ "def", "make_secure_channel", "(", "credentials", ",", "user_agent", ",", "host", ",", "extra_options", "=", "(", ")", ")", ":", "target", "=", "\"%s:%d\"", "%", "(", "host", ",", "http_client", ".", "HTTPS_PORT", ")", "http_request", "=", "google", ".", "...
Makes a secure channel for an RPC service. Uses / depends on gRPC. :type credentials: :class:`google.auth.credentials.Credentials` :param credentials: The OAuth2 Credentials to use for creating access tokens. :type user_agent: str :param user_agent: The user agent to be us...
[ "Makes", "a", "secure", "channel", "for", "an", "RPC", "service", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L540-L569
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
make_secure_stub
def make_secure_stub(credentials, user_agent, stub_class, host, extra_options=()): """Makes a secure stub for an RPC service. Uses / depends on gRPC. :type credentials: :class:`google.auth.credentials.Credentials` :param credentials: The OAuth2 Credentials to use for creating a...
python
def make_secure_stub(credentials, user_agent, stub_class, host, extra_options=()): """Makes a secure stub for an RPC service. Uses / depends on gRPC. :type credentials: :class:`google.auth.credentials.Credentials` :param credentials: The OAuth2 Credentials to use for creating a...
[ "def", "make_secure_stub", "(", "credentials", ",", "user_agent", ",", "stub_class", ",", "host", ",", "extra_options", "=", "(", ")", ")", ":", "channel", "=", "make_secure_channel", "(", "credentials", ",", "user_agent", ",", "host", ",", "extra_options", "=...
Makes a secure stub for an RPC service. Uses / depends on gRPC. :type credentials: :class:`google.auth.credentials.Credentials` :param credentials: The OAuth2 Credentials to use for creating access tokens. :type user_agent: str :param user_agent: The user agent to be used ...
[ "Makes", "a", "secure", "stub", "for", "an", "RPC", "service", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L572-L600
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
make_insecure_stub
def make_insecure_stub(stub_class, host, port=None): """Makes an insecure stub for an RPC service. Uses / depends on gRPC. :type stub_class: type :param stub_class: A gRPC stub type for a given service. :type host: str :param host: The host for the service. May also include the port ...
python
def make_insecure_stub(stub_class, host, port=None): """Makes an insecure stub for an RPC service. Uses / depends on gRPC. :type stub_class: type :param stub_class: A gRPC stub type for a given service. :type host: str :param host: The host for the service. May also include the port ...
[ "def", "make_insecure_stub", "(", "stub_class", ",", "host", ",", "port", "=", "None", ")", ":", "if", "port", "is", "None", ":", "target", "=", "host", "else", ":", "# NOTE: This assumes port != http_client.HTTPS_PORT:", "target", "=", "\"%s:%d\"", "%", "(", ...
Makes an insecure stub for an RPC service. Uses / depends on gRPC. :type stub_class: type :param stub_class: A gRPC stub type for a given service. :type host: str :param host: The host for the service. May also include the port if ``port`` is unspecified. :type port: int ...
[ "Makes", "an", "insecure", "stub", "for", "an", "RPC", "service", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L603-L627
train
googleapis/google-cloud-python
core/google/cloud/_helpers.py
_UTC.fromutc
def fromutc(self, dt): """Convert a timestamp from (naive) UTC to this timezone.""" if dt.tzinfo is None: return dt.replace(tzinfo=self) return super(_UTC, self).fromutc(dt)
python
def fromutc(self, dt): """Convert a timestamp from (naive) UTC to this timezone.""" if dt.tzinfo is None: return dt.replace(tzinfo=self) return super(_UTC, self).fromutc(dt)
[ "def", "fromutc", "(", "self", ",", "dt", ")", ":", "if", "dt", ".", "tzinfo", "is", "None", ":", "return", "dt", ".", "replace", "(", "tzinfo", "=", "self", ")", "return", "super", "(", "_UTC", ",", "self", ")", ".", "fromutc", "(", "dt", ")" ]
Convert a timestamp from (naive) UTC to this timezone.
[ "Convert", "a", "timestamp", "from", "(", "naive", ")", "UTC", "to", "this", "timezone", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/_helpers.py#L128-L132
train
googleapis/google-cloud-python
vision/google/cloud/vision_helpers/decorators.py
add_single_feature_methods
def add_single_feature_methods(cls): """Custom decorator intended for :class:`~vision.helpers.VisionHelpers`. This metaclass adds a `{feature}` method for every feature defined on the Feature enum. """ # Sanity check: This only makes sense if we are building the GAPIC # subclass and have enums ...
python
def add_single_feature_methods(cls): """Custom decorator intended for :class:`~vision.helpers.VisionHelpers`. This metaclass adds a `{feature}` method for every feature defined on the Feature enum. """ # Sanity check: This only makes sense if we are building the GAPIC # subclass and have enums ...
[ "def", "add_single_feature_methods", "(", "cls", ")", ":", "# Sanity check: This only makes sense if we are building the GAPIC", "# subclass and have enums already attached.", "if", "not", "hasattr", "(", "cls", ",", "\"enums\"", ")", ":", "return", "cls", "# Add each single-fe...
Custom decorator intended for :class:`~vision.helpers.VisionHelpers`. This metaclass adds a `{feature}` method for every feature defined on the Feature enum.
[ "Custom", "decorator", "intended", "for", ":", "class", ":", "~vision", ".", "helpers", ".", "VisionHelpers", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/vision/google/cloud/vision_helpers/decorators.py#L18-L49
train
googleapis/google-cloud-python
vision/google/cloud/vision_helpers/decorators.py
_create_single_feature_method
def _create_single_feature_method(feature): """Return a function that will detect a single feature. Args: feature (enum): A specific feature defined as a member of :class:`~enums.Feature.Type`. Returns: function: A helper function to detect just that feature. """ # Defi...
python
def _create_single_feature_method(feature): """Return a function that will detect a single feature. Args: feature (enum): A specific feature defined as a member of :class:`~enums.Feature.Type`. Returns: function: A helper function to detect just that feature. """ # Defi...
[ "def", "_create_single_feature_method", "(", "feature", ")", ":", "# Define the function properties.", "fx_name", "=", "feature", ".", "name", ".", "lower", "(", ")", "if", "\"detection\"", "in", "fx_name", ":", "fx_doc", "=", "\"Perform {0}.\"", ".", "format", "(...
Return a function that will detect a single feature. Args: feature (enum): A specific feature defined as a member of :class:`~enums.Feature.Type`. Returns: function: A helper function to detect just that feature.
[ "Return", "a", "function", "that", "will", "detect", "a", "single", "feature", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/vision/google/cloud/vision_helpers/decorators.py#L52-L109
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/scheduler.py
ThreadScheduler.schedule
def schedule(self, callback, *args, **kwargs): """Schedule the callback to be called asynchronously in a thread pool. Args: callback (Callable): The function to call. args: Positional arguments passed to the function. kwargs: Key-word arguments passed to the function...
python
def schedule(self, callback, *args, **kwargs): """Schedule the callback to be called asynchronously in a thread pool. Args: callback (Callable): The function to call. args: Positional arguments passed to the function. kwargs: Key-word arguments passed to the function...
[ "def", "schedule", "(", "self", ",", "callback", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_executor", ".", "submit", "(", "callback", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Schedule the callback to be called asynchronously in a thread pool. Args: callback (Callable): The function to call. args: Positional arguments passed to the function. kwargs: Key-word arguments passed to the function. Returns: None
[ "Schedule", "the", "callback", "to", "be", "called", "asynchronously", "in", "a", "thread", "pool", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/scheduler.py#L99-L110
train
googleapis/google-cloud-python
pubsub/google/cloud/pubsub_v1/subscriber/scheduler.py
ThreadScheduler.shutdown
def shutdown(self): """Shuts down the scheduler and immediately end all pending callbacks. """ # Drop all pending item from the executor. Without this, the executor # will block until all pending items are complete, which is # undesirable. try: while True: ...
python
def shutdown(self): """Shuts down the scheduler and immediately end all pending callbacks. """ # Drop all pending item from the executor. Without this, the executor # will block until all pending items are complete, which is # undesirable. try: while True: ...
[ "def", "shutdown", "(", "self", ")", ":", "# Drop all pending item from the executor. Without this, the executor", "# will block until all pending items are complete, which is", "# undesirable.", "try", ":", "while", "True", ":", "self", ".", "_executor", ".", "_work_queue", "....
Shuts down the scheduler and immediately end all pending callbacks.
[ "Shuts", "down", "the", "scheduler", "and", "immediately", "end", "all", "pending", "callbacks", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/pubsub/google/cloud/pubsub_v1/subscriber/scheduler.py#L112-L123
train
googleapis/google-cloud-python
error_reporting/google/cloud/errorreporting_v1beta1/gapic/error_stats_service_client.py
ErrorStatsServiceClient.list_events
def list_events( self, project_name, group_id, service_filter=None, time_range=None, page_size=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Lists the...
python
def list_events( self, project_name, group_id, service_filter=None, time_range=None, page_size=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Lists the...
[ "def", "list_events", "(", "self", ",", "project_name", ",", "group_id", ",", "service_filter", "=", "None", ",", "time_range", "=", "None", ",", "page_size", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", ...
Lists the specified events. Example: >>> from google.cloud import errorreporting_v1beta1 >>> >>> client = errorreporting_v1beta1.ErrorStatsServiceClient() >>> >>> project_name = client.project_path('[PROJECT]') >>> >>> # TODO: ...
[ "Lists", "the", "specified", "events", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/error_reporting/google/cloud/errorreporting_v1beta1/gapic/error_stats_service_client.py#L343-L470
train
googleapis/google-cloud-python
error_reporting/google/cloud/errorreporting_v1beta1/gapic/error_stats_service_client.py
ErrorStatsServiceClient.delete_events
def delete_events( self, project_name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Deletes all error events of a given project. Example: >>> from google.cloud import...
python
def delete_events( self, project_name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Deletes all error events of a given project. Example: >>> from google.cloud import...
[ "def", "delete_events", "(", "self", ",", "project_name", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "...
Deletes all error events of a given project. Example: >>> from google.cloud import errorreporting_v1beta1 >>> >>> client = errorreporting_v1beta1.ErrorStatsServiceClient() >>> >>> project_name = client.project_path('[PROJECT]') >>> ...
[ "Deletes", "all", "error", "events", "of", "a", "given", "project", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/error_reporting/google/cloud/errorreporting_v1beta1/gapic/error_stats_service_client.py#L472-L542
train
googleapis/google-cloud-python
firestore/google/cloud/firestore_v1beta1/collection.py
_item_to_document_ref
def _item_to_document_ref(iterator, item): """Convert Document resource to document ref. Args: iterator (google.api_core.page_iterator.GRPCIterator): iterator response item (dict): document resource """ document_id = item.name.split(_helpers.DOCUMENT_PATH_DELIMITER)[-1] ...
python
def _item_to_document_ref(iterator, item): """Convert Document resource to document ref. Args: iterator (google.api_core.page_iterator.GRPCIterator): iterator response item (dict): document resource """ document_id = item.name.split(_helpers.DOCUMENT_PATH_DELIMITER)[-1] ...
[ "def", "_item_to_document_ref", "(", "iterator", ",", "item", ")", ":", "document_id", "=", "item", ".", "name", ".", "split", "(", "_helpers", ".", "DOCUMENT_PATH_DELIMITER", ")", "[", "-", "1", "]", "return", "iterator", ".", "collection", ".", "document",...
Convert Document resource to document ref. Args: iterator (google.api_core.page_iterator.GRPCIterator): iterator response item (dict): document resource
[ "Convert", "Document", "resource", "to", "document", "ref", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/firestore/google/cloud/firestore_v1beta1/collection.py#L468-L477
train
googleapis/google-cloud-python
firestore/google/cloud/firestore_v1beta1/collection.py
CollectionReference.parent
def parent(self): """Document that owns the current collection. Returns: Optional[~.firestore_v1beta1.document.DocumentReference]: The parent document, if the current collection is not a top-level collection. """ if len(self._path) == 1: r...
python
def parent(self): """Document that owns the current collection. Returns: Optional[~.firestore_v1beta1.document.DocumentReference]: The parent document, if the current collection is not a top-level collection. """ if len(self._path) == 1: r...
[ "def", "parent", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_path", ")", "==", "1", ":", "return", "None", "else", ":", "parent_path", "=", "self", ".", "_path", "[", ":", "-", "1", "]", "return", "self", ".", "_client", ".", "documen...
Document that owns the current collection. Returns: Optional[~.firestore_v1beta1.document.DocumentReference]: The parent document, if the current collection is not a top-level collection.
[ "Document", "that", "owns", "the", "current", "collection", "." ]
85e80125a59cb10f8cb105f25ecc099e4b940b50
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/firestore/google/cloud/firestore_v1beta1/collection.py#L80-L92
train