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

Commit a6fa0fd

Browse files
authored
Standardize on CamelCase, reword confusing endpoint name [(#1288)](GoogleCloudPlatform/python-docs-samples#1288)
1 parent e07a260 commit a6fa0fd

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

samples/appengine/flexible/tasks/create_app_engine_queue_task.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ def create_task(project, queue, location, payload=None, in_seconds=None):
3030
client = googleapiclient.discovery.build('cloudtasks', 'v2beta2')
3131

3232
# Construct the request body.
33-
url = '/log_payload'
33+
url = '/example_task_handler'
3434
body = {
3535
'task': {
36-
'app_engine_http_request': { # Specify the type of request.
37-
'http_method': 'POST',
38-
'relative_url': url
36+
'appEngineHttpRequest': { # Specify the type of request.
37+
'httpMethod': 'POST',
38+
'relativeUrl': url
3939
}
4040
}
4141
}
@@ -50,15 +50,15 @@ def create_task(project, queue, location, payload=None, in_seconds=None):
5050
converted_payload = base64_encoded_payload.decode()
5151

5252
# Add the payload to the request.
53-
body['task']['app_engine_http_request']['payload'] = converted_payload
53+
body['task']['appEngineHttpRequest']['payload'] = converted_payload
5454

5555
if in_seconds is not None:
5656
# Convert "seconds from now" into an rfc3339 datetime string.
5757
d = datetime.datetime.utcnow() + datetime.timedelta(seconds=in_seconds)
5858
scheduled_time = d.isoformat('T') + 'Z'
5959

6060
# Add the rfc3339 datetime string to the request.
61-
body['task']['schedule_time'] = scheduled_time
61+
body['task']['scheduleTime'] = scheduled_time
6262

6363
# Construct the fully qualified queue name.
6464
queue_name = 'projects/{}/locations/{}/queues/{}'.format(
@@ -104,7 +104,7 @@ def create_task(project, queue, location, payload=None, in_seconds=None):
104104
)
105105

106106
parser.add_argument(
107-
'--in_seconds',
107+
'--in_seconds', type=int,
108108
help='The number of seconds from now to schedule task attempt.'
109109
)
110110

samples/appengine/flexible/tasks/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
app = Flask(__name__)
2121

2222

23-
@app.route('/log_payload', methods=['POST'])
24-
def log_payload():
23+
@app.route('/example_task_handler', methods=['POST'])
24+
def example_task_handler():
2525
"""Log the request payload."""
2626
payload = request.get_data(as_text=True) or '(empty payload)'
2727
print('Received task with payload: {}'.format(payload))

samples/appengine/flexible/tasks/main_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ def test_index(app):
3030
def test_log_payload(capsys, app):
3131
payload = 'test_payload'
3232

33-
r = app.post('/log_payload', data=payload)
33+
r = app.post('/example_task_handler', data=payload)
3434
assert r.status_code == 200
3535

3636
out, _ = capsys.readouterr()
3737
assert payload in out
3838

3939

4040
def test_empty_payload(capsys, app):
41-
r = app.post('/log_payload')
41+
r = app.post('/example_task_handler')
4242
assert r.status_code == 200
4343

4444
out, _ = capsys.readouterr()

0 commit comments

Comments
 (0)