diff --git a/samples/appengine/flexible/tasks/create_app_engine_queue_task.py b/samples/appengine/flexible/tasks/create_app_engine_queue_task.py index 150ec60a..b08e694e 100644 --- a/samples/appengine/flexible/tasks/create_app_engine_queue_task.py +++ b/samples/appengine/flexible/tasks/create_app_engine_queue_task.py @@ -30,12 +30,12 @@ def create_task(project, queue, location, payload=None, in_seconds=None): client = googleapiclient.discovery.build('cloudtasks', 'v2beta2') # Construct the request body. - url = '/log_payload' + url = '/example_task_handler' body = { 'task': { - 'app_engine_http_request': { # Specify the type of request. - 'http_method': 'POST', - 'relative_url': url + 'appEngineHttpRequest': { # Specify the type of request. + 'httpMethod': 'POST', + 'relativeUrl': url } } } @@ -50,7 +50,7 @@ def create_task(project, queue, location, payload=None, in_seconds=None): converted_payload = base64_encoded_payload.decode() # Add the payload to the request. - body['task']['app_engine_http_request']['payload'] = converted_payload + body['task']['appEngineHttpRequest']['payload'] = converted_payload if in_seconds is not None: # Convert "seconds from now" into an rfc3339 datetime string. @@ -58,7 +58,7 @@ def create_task(project, queue, location, payload=None, in_seconds=None): scheduled_time = d.isoformat('T') + 'Z' # Add the rfc3339 datetime string to the request. - body['task']['schedule_time'] = scheduled_time + body['task']['scheduleTime'] = scheduled_time # Construct the fully qualified queue name. queue_name = 'projects/{}/locations/{}/queues/{}'.format( @@ -104,7 +104,7 @@ def create_task(project, queue, location, payload=None, in_seconds=None): ) parser.add_argument( - '--in_seconds', + '--in_seconds', type=int, help='The number of seconds from now to schedule task attempt.' ) diff --git a/samples/appengine/flexible/tasks/main.py b/samples/appengine/flexible/tasks/main.py index 174e8a3f..8b6c666d 100644 --- a/samples/appengine/flexible/tasks/main.py +++ b/samples/appengine/flexible/tasks/main.py @@ -20,8 +20,8 @@ app = Flask(__name__) -@app.route('/log_payload', methods=['POST']) -def log_payload(): +@app.route('/example_task_handler', methods=['POST']) +def example_task_handler(): """Log the request payload.""" payload = request.get_data(as_text=True) or '(empty payload)' print('Received task with payload: {}'.format(payload)) diff --git a/samples/appengine/flexible/tasks/main_test.py b/samples/appengine/flexible/tasks/main_test.py index 18bf93e5..d47072d1 100644 --- a/samples/appengine/flexible/tasks/main_test.py +++ b/samples/appengine/flexible/tasks/main_test.py @@ -30,7 +30,7 @@ def test_index(app): def test_log_payload(capsys, app): payload = 'test_payload' - r = app.post('/log_payload', data=payload) + r = app.post('/example_task_handler', data=payload) assert r.status_code == 200 out, _ = capsys.readouterr() @@ -38,7 +38,7 @@ def test_log_payload(capsys, app): def test_empty_payload(capsys, app): - r = app.post('/log_payload') + r = app.post('/example_task_handler') assert r.status_code == 200 out, _ = capsys.readouterr()