Skip to content

Commit

Permalink
Add endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jamespfennell committed Mar 7, 2020
1 parent 5ba0652 commit 3e79646
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions transiter/http/endpoints/feedendpoints.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from flask import Blueprint

from transiter import models
from transiter.http.httpmanager import (
http_endpoint,
link_target,
Expand Down Expand Up @@ -29,16 +30,26 @@ def get_in_system_by_id(system_id, feed_id):
return feedservice.get_in_system_by_id(system_id, feed_id)


@http_endpoint(
feed_endpoints, "/<feed_id>", method=HttpMethod.POST,
)
@http_endpoint(feed_endpoints, "/<feed_id>", method=HttpMethod.POST)
@requires_permissions(PermissionsLevel.ALL)
def create_feed_update(system_id, feed_id):
return _create_feed_update_helper(
system_id, feed_id, models.FeedUpdate.Type.REGULAR
)


@http_endpoint(feed_endpoints, "/<feed_id>/flush", method=HttpMethod.POST)
@requires_permissions(PermissionsLevel.ALL)
def create_feed_update_flush(system_id, feed_id):
return _create_feed_update_helper(system_id, feed_id, models.FeedUpdate.Type.FLUSH)


def _create_feed_update_helper(system_id, feed_id, update_type):
"""Create a new feed update."""
request_args = get_request_args(["sync"])
sync = request_args["sync"] == "true"
feed_update_pk = feedservice.create_and_execute_feed_update(
system_id, feed_id, execute_async=not sync
system_id, feed_id, execute_async=not sync, update_type=update_type
)
return (
feedservice.get_update_in_feed_by_pk(system_id, feed_id, feed_update_pk),
Expand Down

0 comments on commit 3e79646

Please sign in to comment.