Files
mercator_service/static/api/v0.2.yaml

974 lines
25 KiB
YAML

swagger: "2.0"
info:
title: Spatial Search Backend API Documentation
description: API Documentation for the spatial search backend.
termsOfService: "" #urn:tos FIXME: Describe ToS?
contact: {}
license:
name: The MIT License
url: https://opensource.org/licenses/MIT
version: "0.2"
host: 127.0.0.1:8888
basePath: /spatial-search
schemes:
- http
tags:
- name: Actions
description: General Database actions.
- name: Spaces
description: Operations on Reference Spaces.
- name: Cores
description: Operations on Cores.
- name: Spatial Objects
description: Operations on Spatial Objects.
paths:
#--------------------------------------------------------------------
# GENERAL ACTIONS ON THE SYSTEM
#--------------------------------------------------------------------
/health:
get:
tags: [Actions]
summary: >
Health check of the service.
description: >
Please note that making anything but a **GET** call is a bad request, and will return a 405.
operationId: get_health_check
responses:
'200':
$ref: '#/responses/Standard200'
default:
$ref: '#/responses/Standard405'
/queries:
post:
tags: [Actions]
summary: >
Execute an arbitrary query.
#description: >
# This is a POST operation, as it "creates" and execute a query, and it is not idempotent as the same query re-run multiple times might have different results, depending on the state of the database.
operationId: query
parameters:
- $ref: '#/parameters/Query'
responses:
'200':
$ref: '#/responses/Query200'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard405'
#--------------------------------------------------------------------
# SPACES QUERIES
#--------------------------------------------------------------------
/spaces:
post:
tags: [Spaces]
summary: >
Retrieve a list of space definition names.
operationId: post_spaces
parameters:
- $ref: '#/parameters/Filters'
responses:
'200':
$ref: '#/responses/ArrayOfStrings'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
put:
tags: [Spaces]
summary: >
Create or update multiple spaces at a time.
operationId: put_spaces
parameters:
- $ref: '#/parameters/Spaces'
responses:
'200':
$ref: '#/responses/Standard200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
patch:
tags: [Spaces]
summary: >
Update multiple spaces at a time.
operationId: patch_spaces
parameters:
- $ref: '#/parameters/SpacePartial'
responses:
'200':
$ref: '#/responses/Standard200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
delete:
tags: [Spaces]
summary: >
Delete multiple spaces at a time.
Each reference space can only be removed if and only if there
are no spatial objects left referencing it.
operationId: delete_spaces
parameters:
- $ref: '#/parameters/SpaceNames'
responses:
'200':
$ref: '#/responses/Standard200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
/spaces/{name}:
parameters:
- $ref: '#/parameters/SpaceName'
put:
tags: [Spaces]
summary: >
Create or update a space `name` in the database
operationId: put_space
parameters:
- $ref: '#/parameters/Space'
responses:
'200':
$ref: '#/responses/SpaceUpdated200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
patch:
tags: [Spaces]
summary: >
Update the space `name`.
operationId: patch_space
parameters:
- $ref: '#/parameters/SpacePartial'
responses:
'200':
$ref: '#/responses/SpaceUpdated200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
get:
tags: [Spaces]
summary: >
Retrieve the space `name`.
operationId: get_space
responses:
'200':
$ref: '#/responses/Space200'
'404':
$ref: '#/responses/Standard404'
default:
$ref: '#/responses/Standard400'
delete:
tags: [Spaces]
summary: >
Remove the space `name`. This operation is authorized if and
only if there is no references to the space being removed.
operationId: delete_space
responses:
'200':
$ref: '#/responses/Space200'
'404':
$ref: '#/responses/Standard404'
default:
$ref: '#/responses/Standard400'
#--------------------------------------------------------------------
# CORE QUERIES
#--------------------------------------------------------------------
/cores:
post:
tags: [Cores]
summary: >
Retrieve a list of core names.
operationId: post_cores
parameters:
- $ref: '#/parameters/Filters'
responses:
'200':
$ref: '#/responses/ArrayOfStrings'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
put:
tags: [Cores]
summary: >
Create or update multiple Cores at a time.
operationId: put_cores
parameters:
- $ref: '#/parameters/Cores'
responses:
'200':
$ref: '#/responses/Standard200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
patch:
tags: [Cores]
summary: >
Update multiple Cores at a time.
operationId: patch_cores
parameters:
- $ref: '#/parameters/CorePartial'
responses:
'200':
$ref: '#/responses/Standard200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
delete:
tags: [Cores]
summary: >
Delete multiple Cores at a time. This also removes all the
Spatial Objects tied to these cores.
operationId: delete_cores
parameters:
- $ref: '#/parameters/CoreNames'
responses:
'200':
$ref: '#/responses/Standard200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
/cores/{name}:
parameters:
- $ref: '#/parameters/CoreName'
put:
tags: [Cores]
summary: >
Create or update a core `name` in the database.
operationId: put_Core
parameters:
- $ref: '#/parameters/Core'
responses:
'200':
$ref: '#/responses/CoreUpdated200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
patch:
tags: [Cores]
summary: >
Update the properties of the core `name`.
operationId: patch_Core
parameters:
- $ref: '#/parameters/CorePartial'
responses:
'200':
$ref: '#/responses/CoreUpdated200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
get:
tags: [Cores]
summary: >
Retrieve the core `name` properties. This does not include
the SpatialObjects contained in this Core.
operationId: get_Core
responses:
'200':
$ref: '#/responses/Core200'
'404':
$ref: '#/responses/Standard404'
default:
$ref: '#/responses/Standard400'
delete:
tags: [Cores]
summary: >
Remove the core `name`. This also removes all the Spatial
Objects stored as part of that core.
operationId: delete_Core
responses:
'200':
$ref: '#/responses/Core200'
'404':
$ref: '#/responses/Standard404'
default:
$ref: '#/responses/Standard400'
/cores/{name}/index:
parameters:
- $ref: '#/parameters/CoreName'
put:
tags: [Cores]
summary: >
Rebuild the index of core `name`.
operationId: put_Core_index
responses:
'200':
description: OK
'404':
$ref: '#/responses/Standard404'
default:
$ref: '#/responses/Standard400'
#--------------------------------------------------------------------
# SPATIAL_OBJECTS QUERIES
#--------------------------------------------------------------------
/cores/{name}/spatial_objects:
parameters:
- $ref: '#/parameters/CoreName'
post:
tags: [Spatial Objects]
summary: >
Retrieve a list of spatial object.
operationId: post_spatial_objects
parameters:
- $ref: '#/parameters/Filters'
responses:
'200':
$ref: '#/responses/ArrayOfStrings'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
put:
tags: [Spatial Objects]
summary: >
Create or update multiple spatial objects at a time.
operationId: put_spatial_objects
parameters:
- $ref: '#/parameters/SpatialObjects'
responses:
'200':
$ref: '#/responses/Standard200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
patch:
tags: [Spatial Objects]
summary: >
Update multiple spatial objects at a time.
operationId: patch_spatial_objects
parameters:
- $ref: '#/parameters/SpatialObjectPartial'
responses:
'200':
$ref: '#/responses/Standard200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
delete:
tags: [Spatial Objects]
summary: >
Delete multiple spatial objects at a time.
operationId: delete_spatial_objects
parameters:
- $ref: '#/parameters/SpatialObjectIds'
responses:
'200':
$ref: '#/responses/Standard200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
/cores/{name}/spatial_objects/{id}:
parameters:
- $ref: '#/parameters/CoreName'
- $ref: '#/parameters/SpatialObjectId'
put:
tags: [Spatial Objects]
summary: >
Create or update a spatial object `id` in the core `name`.
operationId: put_spatial_object
parameters:
- $ref: '#/parameters/SpatialObject'
responses:
'200':
$ref: '#/responses/SpatialObjectUpdated200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
patch:
tags: [Spatial Objects]
summary: >
Update the spatial object `id` of the core `name`.
operationId: patch_spatial_object
parameters:
- $ref: '#/parameters/SpatialObjectPartial'
responses:
'200':
$ref: '#/responses/SpatialObjectUpdated200'
'404':
$ref: '#/responses/Standard404'
'422':
$ref: '#/responses/Standard422'
default:
$ref: '#/responses/Standard400'
get:
tags: [Spatial Objects]
summary: >
Retrieve the spatial object `id` of the core `name`.
operationId: get_spatial_object
responses:
'200':
$ref: '#/responses/SpatialObject200'
'404':
$ref: '#/responses/Standard404'
default:
$ref: '#/responses/Standard400'
delete:
tags: [Spatial Objects]
summary: >
Remove the spatial object `id` of the core `name`.
operationId: delete_spatial_object
responses:
'200':
$ref: '#/responses/SpatialObject200'
'404':
$ref: '#/responses/Standard404'
default:
$ref: '#/responses/Standard400'
parameters:
Space:
name: spaces
in: body
required: true
schema:
$ref: '#/definitions/Space'
Spaces:
name: spaces
in: body
required: true
schema:
type: object
properties:
list:
type: array
items:
$ref: '#/definitions/Space'
SpaceName:
name: name
in: path
required: true
description: >
Name of the reference space
type: string
SpaceNames:
name: spaces
in: body
required: true
schema:
type: object
properties:
list:
type: array
items:
type: string
SpacePartial:
name: partial_update
in: body
required: true
schema:
type: array
items:
type: object
properties:
name:
description: >
Identifier or name of the instance to update.
type: string
attribute:
description: >
Valid selector / attribute name of the instance.
type: string
enum:
- "name"
- "axes"
value:
description: >
JSON-serialized value to use to replace the value of the selected attribute.
type: string
Core:
name: cores
in: body
required: true
schema:
$ref: '#/definitions/Core'
Cores:
name: cores
in: body
required: true
schema:
type: object
properties:
list:
type: array
items:
$ref: '#/definitions/Core'
CoreName:
name: name
in: path
required: true
description: >
Name of the core
type: string
CoreNames:
name: cores
in: body
required: true
schema:
type: object
properties:
list:
type: array
items:
type: string
CorePartial:
name: partial_update
in: body
required: true
schema:
type: array
items:
type: object
properties:
name:
description: >
Identifier or name of the instance to update.
type: string
attribute:
description: >
Valid selector / attribute name of the instance.
type: string
enum:
- "name"
- "version"
- "scales"
value:
description: >
JSON-serialized value to use to replace the value of the selected attribute.
type: string
SpatialObject:
name: spatial_objects
in: body
required: true
schema:
$ref: '#/definitions/SpatialObject'
SpatialObjects:
name: spatial_objects
in: body
required: true
schema:
type: object
properties:
list:
type: array
items:
$ref: '#/definitions/SpatialObject'
SpatialObjectId:
name: id
in: path
required: true
description: >
Id of the spatial object
type: string
SpatialObjectIds:
name: spatial_objects
in: body
required: true
schema:
type: object
properties:
list:
type: array
items:
type: string
SpatialObjectPartial:
name: partial_update
in: body
required: true
schema:
type: array
items:
type: object
properties:
id:
description: >
Identifier or name of the instance to update.
type: string
attribute:
description: >
Valid selector / attribute name of the instance.
type: string
enum:
- "shape"
- "shape.type"
- "shape.vertices"
- "shape.space"
- "properties"
- "properties.id"
- "properties.type"
value:
description: >
JSON-serialized value to use to replace the value of the selected attribute.
type: string
Filters:
name: filters
in: body
required: true
description: >
Filter string to use to select the data.
For more about the filter syntax, please refer to `FIXME: URL` http://repo/filters.g4.
If **ids_only** is true, then a list of **unique identifiers** is returned, instead of the whole, distinct, objects for the selected objects.
schema:
type: object
properties:
filter:
type: string
ids_only:
type: boolean
default: false
space:
type: string
resolution:
type: array
items:
type: number
minimum: 0
format: int32
view_port:
type: array
items:
type: array
items:
type: number
Query:
name: query
in: body
required: true
description: >
For more about the query syntax, please refer to `FIXME: URL` http://repo/queries.g4.
schema:
type: object
properties:
query:
type: string
resolution:
type: array
items:
type: number
minimum: 0
format: int32
view_port:
type: array
items:
type: array
items:
type: number
responses:
Space200:
description: OK
schema:
$ref: '#/definitions/Space'
SpaceUpdated200:
description: OK
schema:
type: object
properties:
previous:
$ref: '#/definitions/Space'
current:
$ref: '#/definitions/Space'
SpatialObject200:
description: OK
schema:
$ref: '#/definitions/SpatialObject'
SpatialObjectUpdated200:
description: OK
schema:
type: object
properties:
previous:
$ref: '#/definitions/SpatialObject'
current:
$ref: '#/definitions/SpatialObject'
Core200:
description: OK
schema:
$ref: '#/definitions/Core'
CoreUpdated200:
description: OK
schema:
type: object
properties:
previous:
$ref: '#/definitions/Core'
current:
$ref: '#/definitions/Core'
Query200:
description: OK
ArrayOfStrings:
description: OK
schema:
type: array
items:
type: string
Standard422:
description: >
Unprocessable Entity
Standard405:
description: >
Invalid Method
Standard404:
description: >
Object not found
Standard400:
description: >
Invalid or malformed request
Standard200:
description: >
OK
definitions:
#--------------------------------------------------------------------
# Types returned / accepted by the API
#--------------------------------------------------------------------
Space:
title: Reference Space
description: >
Definition of a space, in which objects are described.
type: object
properties:
name:
description: >
Unique Id for the space, which can also be used to generate a
link to the user documentation describing the space,
explaining the semantic meaning of the values stored, as
well as the definitions of the axes.
type: string
origin:
type: array
items:
# Expressed in the universe / common coordinate system
$ref: '#/definitions/Point'
axes:
description: >
The order of the axes matter and MUST be kept, as this is
also linked to the definition found in the documentation.
Coordinate of a point MUST always be expressed using the
same order as defined here.
type: array
items:
$ref: '#/definitions/Axis'
SpatialObject:
title: Spatial Object
description: >
Collection of positions in a space, which share a common set of
properties.
type: object
properties:
properties:
$ref: '#/definitions/Properties'
shapes:
description: >
List of shapes, overlapping or not, which define the whole
space covered by this spatial object.
type: array
items:
$ref: '#/definitions/Shape'
Core:
title: Core
description: >
Collection of Spatial Objects, stored in one or more Reference
Spaces.
type: object
properties:
name:
type: string
version:
type: string
scales:
title: Scale Vectors
description: >
Scale factors used to generate less precise, coarser indexes
in order to speed up queries over large volumes of the
space.
Values are expressed as powers of two, in the range [0;n].
For each scale, a whole vector providing values for each
axis MUST be provided.
Values, which are equal, and whose coordinates gets merged
are merged as well, to reduce the number of results.
Distinct values whose coordinates are merged are recorded,
thus allowing the user to move from one scale factor to
another, with a finer resolution smoothly.
type: array
items:
type: array
items:
type: number
minimum: 0
format: int32
#--------------------------------------------------------------------
# Helper types
#--------------------------------------------------------------------
Point:
title: Multi-Dimensional point
description: >
One valid value for each axes of the reference space this point
is used in.
type: array
items:
type: number
Axis:
title: Coordinate Axis
description: >
Defines the properties of an axis. The origin and unit vectors
or defined within the universe space, but this does NOT imply
a linear conversion is possible, this only provide anchoring
of the axis as well as its absolute direction.
type: object
properties:
measurement_unit:
title: Unit used on this axis
description: >
Unit of the values, on this axis, for example [mm], [s],
[um].
type: string
graduation:
title: Valid numbers on this axis
description: >
Definition of the valid coordinate values which can be used
on this axis.
type: object
properties:
set:
description: >
Valid numbers as defined by the usual mathematical sets,
for example N=Natural, Z=Integers, Q=Rational, R=Real.
type: string
# Decision: For now we leave it at strictly numbers, no
# categories until actually needed.
enum: [N, Z, Q, R]
minimum:
type: number
format: float
maximum:
type: number
format: float
steps:
type: number
format: integer
unit_vector:
# Expressed in the universe / common coordinate system
type: array
items:
$ref: '#/definitions/Point'
Shape:
title: Geometric shape
description: >
Geometric shape defined in a reference space.
type: object
properties:
type:
description: >
Name of the shape class described by the vertices, this can
be used for specific types to reduce the number of
vertices required to define the shape.
type: string
enum: [Point, Hyperrectangle, Hypersphere]
space:
description: >
Name of a valid reference space. This is the space in which
the vertices are defined
type: string
vertices:
description: >
List of vertices composing the contour of the shape.
type: array
items:
$ref: '#/definitions/Point'
Properties:
description: >
Properties tied to a shape, in other words properties valid for
the whole content of the shape.
type: object
properties:
type:
description: >
Label defining the kind of the spatial object.
type: string
id:
type: string