Skip to content

Instantly share code, notes, and snippets.

@noahcrowley
Last active November 26, 2018 15:15
Show Gist options
  • Save noahcrowley/363884f2bc6082c10716ecd972909e5f to your computer and use it in GitHub Desktop.
Save noahcrowley/363884f2bc6082c10716ecd972909e5f to your computer and use it in GitHub Desktop.
openapi: 3.0.0
info:
title: Influx API Service
version: 0.1.0
servers:
- url: /v1
paths:
/ping:
servers:
- url: /
get:
tags:
- Health
summary: Report if service is running
responses:
'204':
description: Server is healthy
default:
description: Any response other than 204 is an internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/authorizations:
get:
tags:
- Authorizations
summary: List all authorizations
parameters:
- in: query
name: userID
schema:
type: string
description: filter authorizations belonging to a user id
- in: query
name: user
schema:
type: string
description: filter authorizations belonging to a user name
responses:
'200':
description: A list of authorizations
content:
application/json:
schema:
$ref: '#/components/schemas/Authorizations'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
tags:
- Authorizations
summary: Create an authorization
requestBody:
description: authorization to create
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Authorization'
responses:
'201':
description: authorization created
content:
application/json:
schema:
$ref: '#/components/schemas/Authorization'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'/authorizations/{authId}':
get:
tags:
- Authorizations
summary: Retrieve an authorization
parameters:
- in: path
name: authId
schema:
type: string
required: true
description: ID of authorization to get
responses:
'200':
description: authorization details
content:
application/json:
schema:
$ref: '#/components/schemas/Authorization'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
tags:
- Authorizations
summary: Delete a authorization
parameters:
- in: path
name: authId
schema:
type: string
required: true
description: ID of authorization to delete
responses:
'204':
description: authorization deleted
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/query:
servers:
- url: /
get:
tags:
- Query
- InfluxQL
summary: Executes InfluxQL to retrieve time-series data
parameters:
- in: query
name: q
required: true
schema:
type: string
description: URL-encoded InfluxQL query to execute
- in: query
name: db
schema:
type: string
description: the database has been renamed to bucket.
- in: query
name: rp
schema:
type: string
description: optional retention policy to query (> 1.6.0)
- in: query
name: bucket
schema:
type: string
description: bucket is the query and write destination store
- in: query
name: precision
description: precision rounds the timestamp to the nearest unit
schema:
type: string
description: precision define the time units returned in the query
enum:
- 'n'
- u
- ms
- s
- m
- h
- in: query
name: epoch
description: override default RFC3339 time format with unix epoch at a precision; epoch rounds the timestamp to the nearest unit
schema:
type: string
description: acceptable epochs define the time units returned in the query
enum:
- 'n'
- u
- ms
- s
- m
- h
- in: query
name: chunked
description: return results in streamed batches rather than as a single response
schema:
type: boolean
- in: query
name: chunk_size
description: 'responses will be chunked by series or by every chunk_size points, whichever occurs first.'
schema:
type: integer
default: 10000
- in: query
name: pretty
description: format JSON response onto multiple lines and tab indention.
schema:
type: boolean
- in: header
name: Content-Encoding
description: optional gzip encoding of query results
schema:
type: string
enum:
- gzip
- in: header
name: X-Request-Id
description: specifies correlating requests across services
schema:
type: string
format: uuid
responses:
'200':
description: query executed successfully
headers:
X-Request-Id:
description: request correlation id
schema:
type: string
format: uuid
content:
application/json:
schema:
$ref: '#/components/schemas/InfluxQLResults'
'400':
description: error during query execution
headers:
X-InfluxDB-Error:
description: Error message describing error resason
schema:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/InfluxqlQueryError'
'403':
description: Not authorized to execute query
headers:
WWW-Authenticate:
description: WWW-Authenticate response header defines the authentication method that should be used to gain access to a resource.
schema:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/InfluxqlQueryError'
default:
description: unexpected error
headers:
X-InfluxDB-Error:
description: Error message describing error resason
schema:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/InfluxqlQueryError'
post:
tags:
- Query
- flux
summary: query influx with flux
parameters:
- in: header
name: Accept
description: specifies the return content format. Each response content type will have its own dialect options.
schema:
type: string
description: return format of either CSV or Arrow buffers
default: text/csv
enum:
- text/csv
- application/vnd.influx.arrow
- in: header
name: Content-Type
schema:
type: string
enum:
- application/json
- in: query
name: query
description: flux query string to execute; used if there is no POST body.
schema:
type: string
requestBody:
description: flux query or specification to execute
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Query'
- $ref: '#/components/schemas/QuerySpecification'
responses:
'200':
description: query results
content:
text/csv:
schema:
type: string
example: |
result,table,_start,_stop,_time,region,host,_value mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43 mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25 mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62
application/vnd.influx.arrow:
schema:
type: string
format: binary
'400':
description: error processing query
headers:
X-Influx-Error:
description: error string describing the problem
schema:
type: string
X-Influx-Reference:
description: reference code unique to the error type
schema:
type: integer
content:
text/csv:
schema:
type: string
example: |
error,reference Failed to parse query,897
application/vnd.influx.arrow:
schema:
type: string
format: binary
default:
description: internal server error
headers:
X-Influx-Error:
description: error string describing the problem
schema:
type: string
X-Influx-Reference:
description: reference code unique to the error type
schema:
type: integer
content:
text/csv:
schema:
type: string
example: |
error,reference Failed to parse query,897
application/vnd.influx.arrow:
schema:
type: string
format: binary
/buckets:
get:
tags:
- Buckets
summary: List all buckets
responses:
'200':
description: a list of buckets
content:
application/json:
schema:
$ref: '#/components/schemas/Buckets'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
tags:
- Buckets
summary: Create a bucket
requestBody:
description: bucket to create
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Bucket'
responses:
'201':
description: Bucket created
content:
application/json:
schema:
$ref: '#/components/schemas/Bucket'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'/buckets/{bucketId}':
get:
tags:
- Buckets
summary: Retrieve a bucket
parameters:
- in: path
name: bucketId
schema:
type: string
required: true
description: ID of bucket to get
responses:
'200':
description: bucket details
content:
application/json:
schema:
$ref: '#/components/schemas/Bucket'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
patch:
tags:
- Buckets
summary: Update a bucket
requestBody:
description: bucket update to apply
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Bucket'
parameters:
- in: path
name: bucketId
schema:
type: string
required: true
description: ID of bucket to update
responses:
'200':
description: An updated bucket
content:
application/json:
schema:
$ref: '#/components/schemas/Bucket'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/orgs:
get:
tags:
- Organizations
summary: List all organizations
responses:
'200':
description: A list of organizations
content:
application/json:
schema:
$ref: '#/components/schemas/Organizations'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
tags:
- Organizations
summary: Create an organization
requestBody:
description: organization to create
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Organization'
responses:
'201':
description: organization created
content:
application/json:
schema:
$ref: '#/components/schemas/Organization'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'/orgs/{orgId}':
get:
tags:
- Organizations
summary: Retrieve an organization
parameters:
- in: path
name: orgId
schema:
type: string
required: true
description: ID of organization to get
responses:
'200':
description: organization details
content:
application/json:
schema:
$ref: '#/components/schemas/Organization'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
patch:
tags:
- Organizations
summary: Update an organization
requestBody:
description: organization update to apply
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Organization'
parameters:
- in: path
name: orgId
schema:
type: string
required: true
description: ID of organization to get
responses:
'200':
description: organization updated
content:
application/json:
schema:
$ref: '#/components/schemas/Organization'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/tasks:
get:
tags:
- Tasks
summary: List tasks.
description: 'Lists tasks, limit 100'
parameters:
- in: query
name: after
schema:
type: string
description: returns tasks after specified ID
- in: query
name: user
schema:
type: string
description: filter tasks to a specific user id
- in: query
name: organization
schema:
type: string
description: filter tasks to a specific organization id
responses:
'200':
description: A list of tasks
content:
application/json:
schema:
type: object
properties:
runs:
type: array
items:
$ref: '#/components/schemas/Tasks'
links:
$ref: '#/components/schemas/Links'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
tags:
- Tasks
summary: Create a new task
requestBody:
description: task to create
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Task'
responses:
'201':
description: Task created
content:
application/json:
schema:
$ref: '#/components/schemas/Task'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'/tasks/{taskId}':
get:
tags:
- Tasks
summary: Retrieve an task
parameters:
- in: path
name: taskId
schema:
type: string
required: true
description: ID of task to get
responses:
'200':
description: task details
content:
application/json:
schema:
$ref: '#/components/schemas/Task'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
patch:
tags:
- Tasks
summary: Update a task
description: Update a task. This will cancel all queued runs.
requestBody:
description: task update to apply
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Task'
parameters:
- in: path
name: taskId
schema:
type: string
required: true
description: ID of task to get
responses:
'200':
description: task updated
content:
application/json:
schema:
$ref: '#/components/schemas/Task'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
tags:
- Tasks
summary: Delete a task
description: Deletes a task and all associated records
parameters:
- in: path
name: taskId
schema:
type: string
required: true
description: ID of task to delete
responses:
'204':
description: task deleted
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'/tasks/{taskId}/runs':
get:
tags:
- Tasks
summary: Retrieve list of run records for a task
parameters:
- in: path
name: taskId
schema:
type: string
required: true
description: ID of task to get runs for
- in: query
name: after
schema:
type: string
description: returns runs after specified ID
- in: query
name: limit
schema:
type: integer
minimum: 1
maximum: 100
default: 20
description: the number of runs to return
- in: query
name: afterTime
schema:
type: string
format: date-time
description: filter runs to those queued after this time
- in: query
name: beforeTime
schema:
type: string
format: date-time
description: filter runs to those queued before this time
responses:
'200':
description: a list of task runs
content:
application/json:
schema:
type: object
properties:
runs:
type: array
items:
$ref: '#/components/schemas/Run'
links:
$ref: '#/components/schemas/Links'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'/tasks/{taskId}/runs/{runId}':
get:
tags:
- Tasks
summary: Retrieve a single run record for a task
parameters:
- in: path
name: taskId
schema:
type: string
required: true
description: task ID
- in: path
name: runId
schema:
type: string
required: true
description: run ID
responses:
'200':
description: The run record
content:
application/json:
schema:
$ref: '#/components/schemas/Run'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'/tasks/{taskId}/runs/{runId}/retry':
post:
tags:
- Tasks
summary: Retry a task run
parameters:
- in: path
name: taskId
schema:
type: string
required: true
description: task ID
- in: path
name: runId
schema:
type: string
required: true
description: run ID
responses:
'200':
description: The newly created retry run
content:
application/json:
schema:
$ref: '#/components/schemas/Run'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'/tasks/{taskId}/logs':
get:
tags:
- Tasks
summary: Retrieve all logs for a task
parameters:
- in: path
name: taskId
schema:
type: string
required: true
description: ID of task to get logs for
responses:
'200':
description: all logs for a task
content:
application/json:
schema:
type: object
properties:
logs:
type: array
items:
$ref: '#/components/schemas/Link'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'/tasks/{taskId}/runs/{runId}/logs':
get:
tags:
- Tasks
summary: Retrieve all logs for a run
parameters:
- in: path
name: taskId
schema:
type: string
required: true
description: ID of task to get logs for.
- in: path
name: runId
schema:
type: string
required: true
description: ID of run to get logs for.
responses:
'200':
description: all logs for a run
content:
application/json:
schema:
type: object
properties:
logs:
type: array
items:
$ref: '#/components/schemas/Link'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/users:
get:
tags:
- Users
summary: List all users
responses:
'200':
description: a list of users
content:
application/json:
schema:
$ref: '#/components/schemas/Users'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
tags:
- Users
summary: Create a user
requestBody:
description: user to create
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/User'
responses:
'201':
description: user created
content:
application/json:
schema:
$ref: '#/components/schemas/User'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'/users/{userId}':
get:
tags:
- Users
summary: Retrieve a user
parameters:
- in: path
name: userId
schema:
type: string
required: true
description: ID of user to get
responses:
'200':
description: user details
content:
application/json:
schema:
$ref: '#/components/schemas/User'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
patch:
tags:
- Users
summary: Update a user
requestBody:
description: user update to apply
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/User'
parameters:
- in: path
name: userId
schema:
type: string
required: true
description: ID of user to update
responses:
'200':
description: user updated
content:
application/json:
schema:
$ref: '#/components/schemas/User'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
Query:
description: query influx with specified return formatting.
type: object
properties:
query:
description: query script to execute
type: string
type:
description: type of query
type: string
default: flux
enum:
- flux
dialect:
$ref: '#/components/schemas/Dialect'
QuerySpecification:
description: consists of a set of operations and a set of edges between those operations to instruct the query engine to operate.
type: object
properties:
spec:
type: object
properties:
operations:
type: array
items:
type: object
properties:
kind:
description: name of the operation to perform
type: string
id:
description: identifier for this operation; it must be unique per query specification; used in edges
type: string
spec:
description: set of properties that specify details of the operation. These vary by the kind of operation.
type: object
edges:
description: list of declaring a parent child id relationship between operations
type: array
items:
type: object
properties:
parent:
description: id of parent node of child within graph of opertions
type: string
child:
description: id of child node of parent within the graph of operations
type: string
resources:
description: optional set of contraints on the resources the query can consume
type: object
properties:
priority:
description: priority of the query
oneOf:
- type: string
description: lower value will move to the front of the priority queue
pattern: ^\d+$
- type: string
description: constants to represent the extreme high and low priorities; high is effectively 0.
enum:
- high
- low
concurrency_quota:
description: number of concurrent workers allowed to process this query; 0 indicates the planner can pick the optimal concurrency.
type: integer
default: 0
memory_bytes_quota:
description: number of bytes of RAM this query may consume; 0 means unlimited.
type: integer
default: 0
dialect:
$ref: '#/components/schemas/Dialect'
Dialect:
description: 'dialect are options to change the default CSV output format; https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#dialect-descriptions'
type: object
properties:
header:
description: 'if true, the results will contain a header row'
type: boolean
default: true
delimiter:
description: 'separator between cells; the default is ,'
type: string
default: ','
maxLength: 1
quoteChar:
description: set the quoting char for strings; cannot be the same as delimiter
type: string
default: '\"'
maxLength: 1
annotations:
description: 'https://www.w3.org/TR/2015/REC-tabular-data-model-20151217/#columns'
type: array
default: []
items:
type: string
default: 'default'
enum:
- 'group'
- 'datatype'
- 'default'
uniqueItems: true
commentPrefix:
description: character prefixed to comment strings
type: string
default: '\#'
maxLength: 1
dateTimeFormat:
description: format of timestamps
type: string
default: 'RFC3339'
enum:
- 'RFC3339'
- 'RFC3339Nano'
Authorization:
properties:
id:
readOnly: true
type: string
token:
readOnly: true
type: string
owner:
$ref: '#/components/schemas/Owners'
required:
- userID
Authorizations:
type: array
items:
$ref: '#/components/schemas/Authorization'
Bucket:
properties:
id:
readOnly: true
type: string
owners:
$ref: '#/components/schemas/Owners'
name:
type: string
retentionPeriod:
type: integer
format: int64
required:
- organizationId
- name
- retentionPeriod
Buckets:
type: array
items:
$ref: '#/components/schemas/Bucket'
Link:
type: object
readOnly: true
description: URI of resource.
properties:
href:
type: string
format: url
required:
- href
Links:
type: object
properties:
next:
$ref: '#/components/schemas/Link'
self:
$ref: '#/components/schemas/Link'
prev:
$ref: '#/components/schemas/Link'
required:
- self
Organization:
properties:
id:
readOnly: true
type: string
name:
type: string
owners:
$ref: '#/components/schemas/Owners'
required:
- name
Organizations:
type: array
items:
$ref: '#/components/schemas/Organization'
Owners:
properties:
users:
$ref: '#/components/schemas/Users'
organizations:
$ref: '#/components/schemas/Organizations'
Run:
properties:
id:
readOnly: true
type: string
status:
type: string
enum:
- queued
- executing
- failed
- success
queuedAt:
readOnly: true
type: string
format: date-time
startTime:
readOnly: true
type: string
format: date-time
endTime:
readOnly: true
type: string
format: date-time
error:
$ref: '#/components/schemas/Error'
log:
readOnly: true
description: A url to a relevant log.
type: string
required:
- queuedAt
- status
Task:
properties:
id:
readOnly: true
type: string
organization:
description: The ID of the organization that owns this Task.
type: string
name:
description: A modifiable description of the task.
type: string
status:
description: 'The current status of the task. When updated to ''disabled'', cancels all queued jobs of this task.'
type: string
enum:
- enabled
- disabled
owners:
$ref: '#/components/schemas/Owners'
flux:
description: The Flux script to run for this task.
type: string
every:
readOnly: true
description: A simple task repetition schedule; parsed from Flux.
type: string
cron:
readOnly: true
description: A task repetition schedule in the form '* * * * * *'; parsed from Flux.
type: string
last:
$ref: '#/components/schemas/Run'
required:
- name
- organization
- flux
Tasks:
type: array
items:
$ref: '#/components/schemas/Task'
User:
properties:
id:
readOnly: true
type: string
name:
type: string
required:
- name
Users:
type: array
items:
$ref: '#/components/schemas/User'
Error:
properties:
code:
readOnly: true
type: integer
format: int32
message:
readOnly: true
type: string
required:
- code
- message
InfluxQLResults:
properties:
error:
description: error during processing of the message
type: string
results:
type: array
description: result for each query
items:
type: object
properties:
error:
type: string
description: error during processing of the message
partial:
type: boolean
description: 'If a max row limit has been placed in the configuration file and the number of returned values is larger, this will be set to true and values truncated.'
statement_id:
type: integer
description: statement's position in the query.
series:
description: 'The collection of data in InfluxDB’s data structure that share a measurement, tag set, and retention policy.'
type: array
items:
type: object
description: values for a unique series
properties:
name:
description: The part of InfluxDB’s structure that describes the data stored in the associated fields. Measurements are strings.
type: string
tags:
description: The key-value pairs in InfluxDB’s data structure that records metadata.
type: object
columns:
description: list of columns describing the content of a single value array
type: array
items:
type: string
values:
description: array of arrays of the values return from the query
type: array
items:
type: array
description: single row of results in the order of the columns field.
items:
oneOf:
- type: string
- type: number
- type: integer
partial:
type: boolean
messages:
type: array
description: represents a user-facing message to be included with the result.
items:
type: object
properties:
level:
type: string
text:
type: string
InfluxqlQueryError:
properties:
error:
description: message describing why the query was rejected
readOnly: true
type: string
required:
- error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment