Skip to content

Commit f478b36

Browse files
feat(tasks): undeprecate resource helper methods; add py2 deprecation warning; change default timeouts; add 3.8 tests; edit docstrings (via synth)(#10074)
1 parent 13d8a87 commit f478b36

18 files changed

+161
-200
lines changed

tasks/google/cloud/tasks_v2/__init__.py

+11
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,23 @@
1616

1717

1818
from __future__ import absolute_import
19+
import sys
20+
import warnings
1921

2022
from google.cloud.tasks_v2 import types
2123
from google.cloud.tasks_v2.gapic import cloud_tasks_client
2224
from google.cloud.tasks_v2.gapic import enums
2325

2426

27+
if sys.version_info[:2] == (2, 7):
28+
message = (
29+
"A future version of this library will drop support for Python 2.7."
30+
"More details about Python 2 support for Google Cloud Client Libraries"
31+
"can be found at https://cloud.google.com/python/docs/python2-sunset/"
32+
)
33+
warnings.warn(message, DeprecationWarning)
34+
35+
2536
class CloudTasksClient(cloud_tasks_client.CloudTasksClient):
2637
__doc__ = cloud_tasks_client.CloudTasksClient.__doc__
2738
enums = enums

tasks/google/cloud/tasks_v2/gapic/cloud_tasks_client.py

+9-33
Original file line numberDiff line numberDiff line change
@@ -83,38 +83,16 @@ def from_service_account_file(cls, filename, *args, **kwargs):
8383

8484
@classmethod
8585
def location_path(cls, project, location):
86-
"""DEPRECATED. Return a fully-qualified location string."""
87-
warnings.warn(
88-
"Resource name helper functions are deprecated.",
89-
PendingDeprecationWarning,
90-
stacklevel=1,
91-
)
86+
"""Return a fully-qualified location string."""
9287
return google.api_core.path_template.expand(
9388
"projects/{project}/locations/{location}",
9489
project=project,
9590
location=location,
9691
)
9792

98-
@classmethod
99-
def project_path(cls, project):
100-
"""DEPRECATED. Return a fully-qualified project string."""
101-
warnings.warn(
102-
"Resource name helper functions are deprecated.",
103-
PendingDeprecationWarning,
104-
stacklevel=1,
105-
)
106-
return google.api_core.path_template.expand(
107-
"projects/{project}", project=project
108-
)
109-
11093
@classmethod
11194
def queue_path(cls, project, location, queue):
112-
"""DEPRECATED. Return a fully-qualified queue string."""
113-
warnings.warn(
114-
"Resource name helper functions are deprecated.",
115-
PendingDeprecationWarning,
116-
stacklevel=1,
117-
)
95+
"""Return a fully-qualified queue string."""
11896
return google.api_core.path_template.expand(
11997
"projects/{project}/locations/{location}/queues/{queue}",
12098
project=project,
@@ -124,12 +102,7 @@ def queue_path(cls, project, location, queue):
124102

125103
@classmethod
126104
def task_path(cls, project, location, queue, task):
127-
"""DEPRECATED. Return a fully-qualified task string."""
128-
warnings.warn(
129-
"Resource name helper functions are deprecated.",
130-
PendingDeprecationWarning,
131-
stacklevel=1,
132-
)
105+
"""Return a fully-qualified task string."""
133106
return google.api_core.path_template.expand(
134107
"projects/{project}/locations/{location}/queues/{queue}/tasks/{task}",
135108
project=project,
@@ -961,7 +934,8 @@ def get_iam_policy(
961934
>>>
962935
>>> client = tasks_v2.CloudTasksClient()
963936
>>>
964-
>>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]')
937+
>>> # TODO: Initialize `resource`:
938+
>>> resource = ''
965939
>>>
966940
>>> response = client.get_iam_policy(resource)
967941
@@ -1049,7 +1023,8 @@ def set_iam_policy(
10491023
>>>
10501024
>>> client = tasks_v2.CloudTasksClient()
10511025
>>>
1052-
>>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]')
1026+
>>> # TODO: Initialize `resource`:
1027+
>>> resource = ''
10531028
>>>
10541029
>>> # TODO: Initialize `policy`:
10551030
>>> policy = {}
@@ -1136,7 +1111,8 @@ def test_iam_permissions(
11361111
>>>
11371112
>>> client = tasks_v2.CloudTasksClient()
11381113
>>>
1139-
>>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]')
1114+
>>> # TODO: Initialize `resource`:
1115+
>>> resource = ''
11401116
>>>
11411117
>>> # TODO: Initialize `permissions`:
11421118
>>> permissions = []

tasks/google/cloud/tasks_v2/gapic/cloud_tasks_client_config.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -23,77 +23,77 @@
2323
"retry_params_name": "default",
2424
},
2525
"GetQueue": {
26-
"timeout_millis": 10000,
26+
"timeout_millis": 60000,
2727
"retry_codes_name": "idempotent",
2828
"retry_params_name": "default",
2929
},
3030
"CreateQueue": {
31-
"timeout_millis": 10000,
31+
"timeout_millis": 60000,
3232
"retry_codes_name": "non_idempotent",
3333
"retry_params_name": "default",
3434
},
3535
"UpdateQueue": {
36-
"timeout_millis": 10000,
36+
"timeout_millis": 60000,
3737
"retry_codes_name": "non_idempotent",
3838
"retry_params_name": "default",
3939
},
4040
"DeleteQueue": {
41-
"timeout_millis": 10000,
42-
"retry_codes_name": "idempotent",
41+
"timeout_millis": 60000,
42+
"retry_codes_name": "non_idempotent",
4343
"retry_params_name": "default",
4444
},
4545
"PurgeQueue": {
46-
"timeout_millis": 10000,
46+
"timeout_millis": 60000,
4747
"retry_codes_name": "non_idempotent",
4848
"retry_params_name": "default",
4949
},
5050
"PauseQueue": {
51-
"timeout_millis": 10000,
51+
"timeout_millis": 60000,
5252
"retry_codes_name": "non_idempotent",
5353
"retry_params_name": "default",
5454
},
5555
"ResumeQueue": {
56-
"timeout_millis": 10000,
56+
"timeout_millis": 60000,
5757
"retry_codes_name": "non_idempotent",
5858
"retry_params_name": "default",
5959
},
6060
"GetIamPolicy": {
61-
"timeout_millis": 10000,
62-
"retry_codes_name": "idempotent",
61+
"timeout_millis": 60000,
62+
"retry_codes_name": "non_idempotent",
6363
"retry_params_name": "default",
6464
},
6565
"SetIamPolicy": {
66-
"timeout_millis": 10000,
66+
"timeout_millis": 60000,
6767
"retry_codes_name": "non_idempotent",
6868
"retry_params_name": "default",
6969
},
7070
"TestIamPermissions": {
71-
"timeout_millis": 10000,
72-
"retry_codes_name": "idempotent",
71+
"timeout_millis": 60000,
72+
"retry_codes_name": "non_idempotent",
7373
"retry_params_name": "default",
7474
},
7575
"ListTasks": {
76-
"timeout_millis": 10000,
76+
"timeout_millis": 60000,
7777
"retry_codes_name": "idempotent",
7878
"retry_params_name": "default",
7979
},
8080
"GetTask": {
81-
"timeout_millis": 10000,
81+
"timeout_millis": 60000,
8282
"retry_codes_name": "idempotent",
8383
"retry_params_name": "default",
8484
},
8585
"CreateTask": {
86-
"timeout_millis": 10000,
86+
"timeout_millis": 60000,
8787
"retry_codes_name": "non_idempotent",
8888
"retry_params_name": "default",
8989
},
9090
"DeleteTask": {
91-
"timeout_millis": 10000,
92-
"retry_codes_name": "idempotent",
91+
"timeout_millis": 60000,
92+
"retry_codes_name": "non_idempotent",
9393
"retry_params_name": "default",
9494
},
9595
"RunTask": {
96-
"timeout_millis": 10000,
96+
"timeout_millis": 60000,
9797
"retry_codes_name": "non_idempotent",
9898
"retry_params_name": "default",
9999
},

tasks/google/cloud/tasks_v2/proto/target.proto

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ option java_package = "com.google.cloud.tasks.v2";
2929
//
3030
// The task will be pushed to the worker as an HTTP request. If the worker
3131
// or the redirected worker acknowledges the task by returning a successful HTTP
32-
// response code ([`200` - `299`]), the task will removed from the queue. If
32+
// response code ([`200` - `299`]), the task will be removed from the queue. If
3333
// any other HTTP response code is returned or no response is received, the
3434
// task will be retried according to the following:
3535
//
@@ -48,7 +48,7 @@ option java_package = "com.google.cloud.tasks.v2";
4848
// errors is high, Cloud Tasks will use a higher backoff rate. The retry
4949
// specified in the `Retry-After` HTTP response header is considered.
5050
//
51-
// * To prevent traffic spikes and to smooth sudden large traffic spikes,
51+
// * To prevent traffic spikes and to smooth sudden increases in traffic,
5252
// dispatches ramp up slowly when the queue is newly created or idle and
5353
// if large numbers of tasks suddenly become available to dispatch (due to
5454
// spikes in create task rates, the queue being unpaused, or many tasks
@@ -256,7 +256,7 @@ message AppEngineHttpRequest {
256256
// In addition, Cloud Tasks sets some headers when the task is dispatched,
257257
// such as headers containing information about the task; see
258258
// [request
259-
// headers](https://cloud.google.com/appengine/docs/python/taskqueue/push/creating-handlers#reading_request_headers).
259+
// headers](https://cloud.google.com/tasks/docs/creating-appengine-handlers#reading_request_headers).
260260
// These headers are set only when the task is dispatched, so they are not
261261
// visible when the task is returned in a Cloud Tasks response.
262262
//

tasks/google/cloud/tasks_v2/proto/target_pb2.py

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tasks/google/cloud/tasks_v2beta2/__init__.py

+11
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,23 @@
1616

1717

1818
from __future__ import absolute_import
19+
import sys
20+
import warnings
1921

2022
from google.cloud.tasks_v2beta2 import types
2123
from google.cloud.tasks_v2beta2.gapic import cloud_tasks_client
2224
from google.cloud.tasks_v2beta2.gapic import enums
2325

2426

27+
if sys.version_info[:2] == (2, 7):
28+
message = (
29+
"A future version of this library will drop support for Python 2.7."
30+
"More details about Python 2 support for Google Cloud Client Libraries"
31+
"can be found at https://cloud.google.com/python/docs/python2-sunset/"
32+
)
33+
warnings.warn(message, DeprecationWarning)
34+
35+
2536
class CloudTasksClient(cloud_tasks_client.CloudTasksClient):
2637
__doc__ = cloud_tasks_client.CloudTasksClient.__doc__
2738
enums = enums

tasks/google/cloud/tasks_v2beta2/gapic/cloud_tasks_client.py

+9-33
Original file line numberDiff line numberDiff line change
@@ -85,38 +85,16 @@ def from_service_account_file(cls, filename, *args, **kwargs):
8585

8686
@classmethod
8787
def location_path(cls, project, location):
88-
"""DEPRECATED. Return a fully-qualified location string."""
89-
warnings.warn(
90-
"Resource name helper functions are deprecated.",
91-
PendingDeprecationWarning,
92-
stacklevel=1,
93-
)
88+
"""Return a fully-qualified location string."""
9489
return google.api_core.path_template.expand(
9590
"projects/{project}/locations/{location}",
9691
project=project,
9792
location=location,
9893
)
9994

100-
@classmethod
101-
def project_path(cls, project):
102-
"""DEPRECATED. Return a fully-qualified project string."""
103-
warnings.warn(
104-
"Resource name helper functions are deprecated.",
105-
PendingDeprecationWarning,
106-
stacklevel=1,
107-
)
108-
return google.api_core.path_template.expand(
109-
"projects/{project}", project=project
110-
)
111-
11295
@classmethod
11396
def queue_path(cls, project, location, queue):
114-
"""DEPRECATED. Return a fully-qualified queue string."""
115-
warnings.warn(
116-
"Resource name helper functions are deprecated.",
117-
PendingDeprecationWarning,
118-
stacklevel=1,
119-
)
97+
"""Return a fully-qualified queue string."""
12098
return google.api_core.path_template.expand(
12199
"projects/{project}/locations/{location}/queues/{queue}",
122100
project=project,
@@ -126,12 +104,7 @@ def queue_path(cls, project, location, queue):
126104

127105
@classmethod
128106
def task_path(cls, project, location, queue, task):
129-
"""DEPRECATED. Return a fully-qualified task string."""
130-
warnings.warn(
131-
"Resource name helper functions are deprecated.",
132-
PendingDeprecationWarning,
133-
stacklevel=1,
134-
)
107+
"""Return a fully-qualified task string."""
135108
return google.api_core.path_template.expand(
136109
"projects/{project}/locations/{location}/queues/{queue}/tasks/{task}",
137110
project=project,
@@ -963,7 +936,8 @@ def get_iam_policy(
963936
>>>
964937
>>> client = tasks_v2beta2.CloudTasksClient()
965938
>>>
966-
>>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]')
939+
>>> # TODO: Initialize `resource`:
940+
>>> resource = ''
967941
>>>
968942
>>> response = client.get_iam_policy(resource)
969943
@@ -1051,7 +1025,8 @@ def set_iam_policy(
10511025
>>>
10521026
>>> client = tasks_v2beta2.CloudTasksClient()
10531027
>>>
1054-
>>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]')
1028+
>>> # TODO: Initialize `resource`:
1029+
>>> resource = ''
10551030
>>>
10561031
>>> # TODO: Initialize `policy`:
10571032
>>> policy = {}
@@ -1138,7 +1113,8 @@ def test_iam_permissions(
11381113
>>>
11391114
>>> client = tasks_v2beta2.CloudTasksClient()
11401115
>>>
1141-
>>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]')
1116+
>>> # TODO: Initialize `resource`:
1117+
>>> resource = ''
11421118
>>>
11431119
>>> # TODO: Initialize `permissions`:
11441120
>>> permissions = []

0 commit comments

Comments
 (0)