Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize on CamelCase, reword confusing endpoint name #1288

Merged
merged 1 commit into from
Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions appengine/flexible/tasks/create_app_engine_queue_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand All @@ -50,15 +50,15 @@ 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.
d = datetime.datetime.utcnow() + datetime.timedelta(seconds=in_seconds)
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(
Expand Down Expand Up @@ -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.'
)

Expand Down
4 changes: 2 additions & 2 deletions appengine/flexible/tasks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions appengine/flexible/tasks/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ 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()
assert payload in out


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()
Expand Down
4 changes: 2 additions & 2 deletions tasks/pull_queue_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def create_task(project, queue, location):
# Construct the request body.
task = {
'task': {
'pull_message': {
'pullMessage': {
'payload': converted_payload
}
}
Expand Down Expand Up @@ -77,7 +77,7 @@ def pull_task(project, queue, location):

duration_seconds = '600s'
pull_options = {
'max_tasks': 1,
'maxTasks': 1,
'leaseDuration': duration_seconds,
'responseView': 'FULL'
}
Expand Down