Commit a4d43462 authored by Alexander's avatar Alexander

added support for posting multiple locations at once

parent 62768e5d
......@@ -57,8 +57,27 @@ paths:
200:
description: "Successful operation"
schema:
$ref: "#/definitions/Location"
$ref: "#/definitions/LocationCollection"
/location-collections:
post:
operationId: "rest.location.post_many"
tags:
- "Locations"
summary: "Add new location data collection"
parameters:
- in: body
name: "Locations"
description: "The location data collection to be added"
required: true
schema:
$ref: "#/definitions/LocationCollection"
responses:
201:
description: "Successful operation"
400:
description: "Invalid input"
/clusters:
get:
operationId: "rest.cluster.get"
......@@ -70,7 +89,7 @@ paths:
200:
description: "Successful operation"
schema:
$ref: "#/definitions/UserCluster"
$ref: "#/definitions/UserClusterCollection"
/clusters/cluster.png:
get:
......@@ -96,7 +115,7 @@ paths:
200:
description: "Successful operation"
schema:
$ref: "#/definitions/UserCluster"
$ref: "#/definitions/UserClusterCollection"
/agi/clusters/cluster.png:
get:
......@@ -117,7 +136,7 @@ definitions:
properties:
id:
type: string
username:
user:
type: "string"
latitude:
type: "number"
......@@ -128,6 +147,11 @@ definitions:
timestamp:
type: "number"
LocationCollection:
type: array
items:
$ref: "#/definitions/Location"
UserCluster:
type: "object"
properties:
......@@ -145,4 +169,8 @@ definitions:
type: string
example:
0: [1dc61b1a0602de0eaee9dba7eece9279c2844202, b4b31bbe5e12f55737e3a910827c81595fbca3eb]
\ No newline at end of file
UserClusterCollection:
type: array
items:
$ref: "#/definitions/UserCluster"
\ No newline at end of file
......@@ -6,8 +6,17 @@ repo = Repository()
def post():
body = request.json
repo.add_location(Location(body))
insert_location(body)
return Response(status=201)
def post_many():
body = request.json
for location in body:
insert_location(location)
return Response(status=201)
def get():
return [l.to_serializable_dict() for l in repo.get_locations()]
def insert_location(location_data: dict):
repo.add_location(Location(location_data))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment