Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
feat(tasks): undeprecate resource helper methods; add py2 deprecation…
Browse files Browse the repository at this point in the history
… warning; change default timeouts; add 3.8 tests; edit docstrings (via synth)(#10074)
  • Loading branch information
yoshi-automation committed Jan 29, 2020
1 parent ccf2cab commit 5577817
Show file tree
Hide file tree
Showing 18 changed files with 161 additions and 200 deletions.
11 changes: 11 additions & 0 deletions google/cloud/tasks_v2/__init__.py
Expand Up @@ -16,12 +16,23 @@


from __future__ import absolute_import
import sys
import warnings

from google.cloud.tasks_v2 import types
from google.cloud.tasks_v2.gapic import cloud_tasks_client
from google.cloud.tasks_v2.gapic import enums


if sys.version_info[:2] == (2, 7):
message = (
"A future version of this library will drop support for Python 2.7."
"More details about Python 2 support for Google Cloud Client Libraries"
"can be found at https://cloud.google.com/python/docs/python2-sunset/"
)
warnings.warn(message, DeprecationWarning)


class CloudTasksClient(cloud_tasks_client.CloudTasksClient):
__doc__ = cloud_tasks_client.CloudTasksClient.__doc__
enums = enums
Expand Down
42 changes: 9 additions & 33 deletions google/cloud/tasks_v2/gapic/cloud_tasks_client.py
Expand Up @@ -83,38 +83,16 @@ def from_service_account_file(cls, filename, *args, **kwargs):

@classmethod
def location_path(cls, project, location):
"""DEPRECATED. Return a fully-qualified location string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified location string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}",
project=project,
location=location,
)

@classmethod
def project_path(cls, project):
"""DEPRECATED. Return a fully-qualified project string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
return google.api_core.path_template.expand(
"projects/{project}", project=project
)

@classmethod
def queue_path(cls, project, location, queue):
"""DEPRECATED. Return a fully-qualified queue string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified queue string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/queues/{queue}",
project=project,
Expand All @@ -124,12 +102,7 @@ def queue_path(cls, project, location, queue):

@classmethod
def task_path(cls, project, location, queue, task):
"""DEPRECATED. Return a fully-qualified task string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified task string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/queues/{queue}/tasks/{task}",
project=project,
Expand Down Expand Up @@ -961,7 +934,8 @@ def get_iam_policy(
>>>
>>> client = tasks_v2.CloudTasksClient()
>>>
>>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]')
>>> # TODO: Initialize `resource`:
>>> resource = ''
>>>
>>> response = client.get_iam_policy(resource)
Expand Down Expand Up @@ -1049,7 +1023,8 @@ def set_iam_policy(
>>>
>>> client = tasks_v2.CloudTasksClient()
>>>
>>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]')
>>> # TODO: Initialize `resource`:
>>> resource = ''
>>>
>>> # TODO: Initialize `policy`:
>>> policy = {}
Expand Down Expand Up @@ -1136,7 +1111,8 @@ def test_iam_permissions(
>>>
>>> client = tasks_v2.CloudTasksClient()
>>>
>>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]')
>>> # TODO: Initialize `resource`:
>>> resource = ''
>>>
>>> # TODO: Initialize `permissions`:
>>> permissions = []
Expand Down
38 changes: 19 additions & 19 deletions google/cloud/tasks_v2/gapic/cloud_tasks_client_config.py
Expand Up @@ -23,77 +23,77 @@
"retry_params_name": "default",
},
"GetQueue": {
"timeout_millis": 10000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"CreateQueue": {
"timeout_millis": 10000,
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"UpdateQueue": {
"timeout_millis": 10000,
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"DeleteQueue": {
"timeout_millis": 10000,
"retry_codes_name": "idempotent",
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"PurgeQueue": {
"timeout_millis": 10000,
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"PauseQueue": {
"timeout_millis": 10000,
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"ResumeQueue": {
"timeout_millis": 10000,
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"GetIamPolicy": {
"timeout_millis": 10000,
"retry_codes_name": "idempotent",
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"SetIamPolicy": {
"timeout_millis": 10000,
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"TestIamPermissions": {
"timeout_millis": 10000,
"retry_codes_name": "idempotent",
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"ListTasks": {
"timeout_millis": 10000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"GetTask": {
"timeout_millis": 10000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"CreateTask": {
"timeout_millis": 10000,
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"DeleteTask": {
"timeout_millis": 10000,
"retry_codes_name": "idempotent",
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"RunTask": {
"timeout_millis": 10000,
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
Expand Down
6 changes: 3 additions & 3 deletions google/cloud/tasks_v2/proto/target.proto
Expand Up @@ -29,7 +29,7 @@ option java_package = "com.google.cloud.tasks.v2";
//
// The task will be pushed to the worker as an HTTP request. If the worker
// or the redirected worker acknowledges the task by returning a successful HTTP
// response code ([`200` - `299`]), the task will removed from the queue. If
// response code ([`200` - `299`]), the task will be removed from the queue. If
// any other HTTP response code is returned or no response is received, the
// task will be retried according to the following:
//
Expand All @@ -48,7 +48,7 @@ option java_package = "com.google.cloud.tasks.v2";
// errors is high, Cloud Tasks will use a higher backoff rate. The retry
// specified in the `Retry-After` HTTP response header is considered.
//
// * To prevent traffic spikes and to smooth sudden large traffic spikes,
// * To prevent traffic spikes and to smooth sudden increases in traffic,
// dispatches ramp up slowly when the queue is newly created or idle and
// if large numbers of tasks suddenly become available to dispatch (due to
// spikes in create task rates, the queue being unpaused, or many tasks
Expand Down Expand Up @@ -256,7 +256,7 @@ message AppEngineHttpRequest {
// In addition, Cloud Tasks sets some headers when the task is dispatched,
// such as headers containing information about the task; see
// [request
// headers](https://cloud.google.com/appengine/docs/python/taskqueue/push/creating-handlers#reading_request_headers).
// headers](https://cloud.google.com/tasks/docs/creating-appengine-handlers#reading_request_headers).
// These headers are set only when the task is dispatched, so they are not
// visible when the task is returned in a Cloud Tasks response.
//
Expand Down
10 changes: 5 additions & 5 deletions google/cloud/tasks_v2/proto/target_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions google/cloud/tasks_v2beta2/__init__.py
Expand Up @@ -16,12 +16,23 @@


from __future__ import absolute_import
import sys
import warnings

from google.cloud.tasks_v2beta2 import types
from google.cloud.tasks_v2beta2.gapic import cloud_tasks_client
from google.cloud.tasks_v2beta2.gapic import enums


if sys.version_info[:2] == (2, 7):
message = (
"A future version of this library will drop support for Python 2.7."
"More details about Python 2 support for Google Cloud Client Libraries"
"can be found at https://cloud.google.com/python/docs/python2-sunset/"
)
warnings.warn(message, DeprecationWarning)


class CloudTasksClient(cloud_tasks_client.CloudTasksClient):
__doc__ = cloud_tasks_client.CloudTasksClient.__doc__
enums = enums
Expand Down
42 changes: 9 additions & 33 deletions google/cloud/tasks_v2beta2/gapic/cloud_tasks_client.py
Expand Up @@ -85,38 +85,16 @@ def from_service_account_file(cls, filename, *args, **kwargs):

@classmethod
def location_path(cls, project, location):
"""DEPRECATED. Return a fully-qualified location string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified location string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}",
project=project,
location=location,
)

@classmethod
def project_path(cls, project):
"""DEPRECATED. Return a fully-qualified project string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
return google.api_core.path_template.expand(
"projects/{project}", project=project
)

@classmethod
def queue_path(cls, project, location, queue):
"""DEPRECATED. Return a fully-qualified queue string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified queue string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/queues/{queue}",
project=project,
Expand All @@ -126,12 +104,7 @@ def queue_path(cls, project, location, queue):

@classmethod
def task_path(cls, project, location, queue, task):
"""DEPRECATED. Return a fully-qualified task string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified task string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/queues/{queue}/tasks/{task}",
project=project,
Expand Down Expand Up @@ -963,7 +936,8 @@ def get_iam_policy(
>>>
>>> client = tasks_v2beta2.CloudTasksClient()
>>>
>>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]')
>>> # TODO: Initialize `resource`:
>>> resource = ''
>>>
>>> response = client.get_iam_policy(resource)
Expand Down Expand Up @@ -1051,7 +1025,8 @@ def set_iam_policy(
>>>
>>> client = tasks_v2beta2.CloudTasksClient()
>>>
>>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]')
>>> # TODO: Initialize `resource`:
>>> resource = ''
>>>
>>> # TODO: Initialize `policy`:
>>> policy = {}
Expand Down Expand Up @@ -1138,7 +1113,8 @@ def test_iam_permissions(
>>>
>>> client = tasks_v2beta2.CloudTasksClient()
>>>
>>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]')
>>> # TODO: Initialize `resource`:
>>> resource = ''
>>>
>>> # TODO: Initialize `permissions`:
>>> permissions = []
Expand Down

0 comments on commit 5577817

Please sign in to comment.