Files
fn-serverless/docs/swagger_v2.yml
Tom Coupland 3ebff051a4 Add support for Function and Trigger domain objects (#1060)
Vast commit, includes:

 * Introduces the Trigger domain entity.
 * Introduces the Fns domain entity.
 * V2 of the API for interacting with the new entities in swaggerv2.yml
 * Adds v2 end points for Apps to support PUT updates.
 * Rewrites the datastore level tests into a new pattern.
 * V2 routes use entity ID over name as the path parameter.
2018-06-25 15:37:06 +01:00

647 lines
17 KiB
YAML

swagger: '2.0'
info:
title: fn
description: The open source serverless platform.
version: "2.0.0"
# the domain of the service
host: "127.0.0.1:8080"
# array of all schemes that your API supports
schemes:
- https
- http
# will be prefixed to all paths
basePath: /v2
consumes:
- application/json
produces:
- application/json
paths:
/apps:
get:
operationId: "ListApps"
summary: "Get applications"
description: "Get a filtered applications returned in alphabetical order."
tags:
- Apps
parameters:
- $ref: '#/parameters/cursor'
- $ref: '#/parameters/perPage'
- name: name
in: query
description: Application name to filter by
required: false
type: string
responses:
200:
description: List of apps.
schema:
$ref: '#/definitions/AppList'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
post:
operationId: "CreateApp"
summary: "Post new app"
description: "Insert a new app"
tags:
- Apps
parameters:
- name: body
in: body
description: App to modify.
required: true
schema:
$ref: '#/definitions/App'
responses:
200:
description: App details and stats.
schema:
$ref: '#/definitions/App'
400:
description: Parameters are missing or invalid.
schema:
$ref: '#/definitions/Error'
409:
description: App already exists.
schema:
$ref: '#/definitions/Error'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
/apps/{appID}:
delete:
operationId: "DeleteApp"
summary: "Delete an app."
description: "Delete an app."
tags:
- Apps
parameters:
- $ref: '#/parameters/AppID'
responses:
200:
description: Apps successfully deleted.
404:
description: App does not exist.
schema:
$ref: '#/definitions/Error'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
get:
operationId: "GetApp"
summary: "Get information for a app."
description: "This gives more details about a app, such as statistics."
tags:
- Apps
parameters:
- $ref: '#/parameters/AppID'
responses:
200:
description: App details and stats.
schema:
$ref: '#/definitions/App'
404:
description: App does not exist.
schema:
$ref: '#/definitions/Error'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
put:
operationId: "UpdateApp"
summary: "Update an app."
description: "Updates and application."
tags:
- Apps
parameters:
- $ref: '#/parameters/AppID'
- name: body
in: body
description: App to modify.
required: true
schema:
$ref: '#/definitions/App'
responses:
200:
description: App details and stats.
schema:
$ref: '#/definitions/App'
404:
description: App does not exist.
schema:
$ref: '#/definitions/Error'
400:
description: Parameters are missing or invalid.
schema:
$ref: '#/definitions/Error'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
/fns:
get:
operationId: "ListFns"
summary: "Get all fns"
description: "Get a list of all the Functions in alphabetical order."
tags:
- Fns
parameters:
- $ref: '#/parameters/AppIDQuery'
- $ref: '#/parameters/cursor'
- $ref: '#/parameters/perPage'
- name: name
in: query
description: Function name to filter by
required: false
type: string
responses:
200:
description: List of fns.
schema:
$ref: '#/definitions/FnList'
default:
description: Error
schema:
$ref: '#/definitions/Error'
post:
operationId: "CreateFn"
summary: "Create a fn"
description: "Creates a new Function, returning the complete entity."
tags:
- Fns
parameters:
- name: body
in: body
description: Fn to upsert
required: true
schema:
$ref: '#/definitions/Fn'
responses:
200:
description: Fn.
schema:
$ref: '#/definitions/Fn'
409:
description: Fn with name already exists.
schema:
$ref: '#/definitions/Error'
400:
description: Invalid Fn
schema:
$ref: '#/definitions/Error'
default:
description: Error
schema:
$ref: '#/definitions/Error'
/fns/{fnID}:
get:
operationId: "GetFn"
summary: "Get definition for a function"
description: "Get definition for a function."
tags:
- Fns
parameters:
- $ref: '#/parameters/FnID'
responses:
200:
description: Function definition
schema:
$ref: '#/definitions/Fn'
404:
description: Function does not exist.
schema:
$ref: '#/definitions/Error'
default:
description: Error
schema:
$ref: '#/definitions/Error'
put:
operationId: "UpdateFn"
summary: "Updates a fn"
description: "Updates a Function via merging the provided values."
tags:
- Fns
parameters:
- $ref: '#/parameters/FnID'
- name: body
in: body
description: Fn data to merge with current value
required: true
schema:
$ref: '#/definitions/Fn'
responses:
200:
description: Fn metadata
schema:
$ref: '#/definitions/Fn'
404:
description: Fn does not exist.
schema:
$ref: '#/definitions/Error'
400:
description: Parameters are missing or invalid.
schema:
$ref: '#/definitions/Error'
default:
description: Error
schema:
$ref: '#/definitions/Error'
delete:
operationId: "DeleteFn"
summary: "Delete a fn"
description: "Delete a function."
tags:
- Fns
parameters:
- $ref: '#/parameters/FnID'
responses:
204:
description: Fn successfully deleted
404:
description: Fn does not exist.
schema:
$ref: '#/definitions/Error'
default:
description: Error
schema:
$ref: '#/definitions/Error'
/triggers:
get:
operationId: "ListTriggers"
summary: List triggers associated with app
description: This will list all Triggers for a particular Application, returned in name alphabetical order.
tags:
- Triggers
parameters:
- $ref: '#/parameters/AppIDQuery'
- $ref: '#/parameters/FnIDQuery'
- name: name
in: query
description: Trigger name to filter by
required: false
type: string
- $ref: '#/parameters/cursor'
- $ref: '#/parameters/perPage'
responses:
200:
description: Trigger data
schema:
$ref: '#/definitions/TriggerList'
default:
description: Error
schema:
$ref: '#/definitions/Error'
post:
operationId: "CreateTrigger"
summary: Create a Trigger.
description: Creates a Trigger.
tags:
- Triggers
parameters:
- name: body
in: body
description: Trigger to create.
required: true
schema:
$ref: '#/definitions/Trigger'
responses:
200:
description: Created Triggers data
schema:
$ref: '#/definitions/Trigger'
409:
description: Trigger with name already exists.
schema:
$ref: '#/definitions/Error'
400:
description: Invalid Trigger
schema:
$ref: '#/definitions/Error'
default:
description: Error
schema:
$ref: '#/definitions/Error'
/triggers/{triggerID}:
get:
operationId: "GetTrigger"
summary: Gets Trigger by ID
description: Gets a Trigger by ID.
tags:
- Triggers
parameters:
- $ref: '#/parameters/TriggerID'
responses:
200:
description: Trigger information
schema:
$ref: '#/definitions/Trigger'
404:
description: Trigger does not exist.
schema:
$ref: '#/definitions/Error'
default:
description: Error
schema:
$ref: '#/definitions/Error'
put:
operationId: "UpdateTrigger"
summary: Update a Trigger
description: Updates a Trigger by merging the provided values.
tags:
- Triggers
parameters:
- $ref: '#/parameters/TriggerID'
- name: body
in: body
description: Trigger values to merge into current value.
required: true
schema:
$ref: '#/definitions/Trigger'
responses:
200:
description: Created Triggers data
schema:
$ref: '#/definitions/Trigger'
404:
description: Trigger does not exist.
schema:
$ref: '#/definitions/Error'
400:
description: Parameters are missing or invalid.
schema:
$ref: '#/definitions/Error'
default:
description: Error
schema:
$ref: '#/definitions/Error'
delete:
operationId: "DeleteTrigger"
summary: Deletes the Trigger
description: Deletes the Trigger.
tags:
- Triggers
parameters:
- $ref: '#/parameters/TriggerID'
responses:
404:
description: Trigger does not exist.
schema:
$ref: '#/definitions/Error'
204:
description: Trigger successfully deleted.
default:
description: Error
schema:
$ref: '#/definitions/Error'
definitions:
App:
type: object
properties:
id:
type: string
description: App ID
readOnly: true
name:
type: string
description: "Name of this app. Must be different than the image name. Can ony contain alphanumeric, -, and _."
readOnly: true
config:
type: object
description: Application function configuration, applied to all routes.
additionalProperties:
type: string
annotations:
type: object
description: Application annotations - this is a map of annotations attached to this app, keys must not exceed 128 bytes and must consist of non-whitespace printable ascii characters, and the seralized representation of individual values must not exeed 512 bytes
additionalProperties:
type: object
syslog_url:
type: string
description: A comma separated list of syslog urls to send all function logs to. supports tls, udp or tcp. e.g. tls://logs.papertrailapp.com:1
created_at:
type: string
format: date-time
description: Time when app was created. Always in UTC.
readOnly: true
updated_at:
type: string
format: date-time
description: Most recent time that app was updated. Always in UTC.
readOnly: true
Fn:
type: object
properties:
id:
type: string
description: Unique identifier
readOnly: true
name:
type: string
description: unique name for this function.
app_id:
type: string
description: App ID.
image:
type: string
description: "full container image name, e.g. hub.docker.com/fnproject/yo or fnproject/yo (default registry: hub.docker.com)"
mem:
type: integer
format: uint64
description: Max usable memory given to function (MiB).
timeout:
type: integer
default: 30
format: int32
description: Timeout for executions of a function. Value in Seconds
idle_timeout:
type: integer
default: 30
format: int32
description: Hot functions idle timeout before container termination. Value in Seconds
config:
type: object
description: Func configuration key values
additionalProperties:
type: string
format:
enum:
- default
- http
- json
- cloudevent
description: Payload format sent into function.
type: string
annotations:
type: object
description: Func annotations - this is a map of annotations attached to this func, keys must not exceed 128 bytes and must consist of non-whitespace printable ascii characters, and the seralized representation of individual values must not exeed 512 bytes
additionalProperties:
type: object
created_at:
type: string
format: date-time
description: Time when function was created. Always in UTC RFC3339.
readOnly: true
updated_at:
type: string
format: date-time
description: Most recent time that function was updated. Always in UTC RFC3339.
readOnly: true
FnList:
type: object
required:
- items
properties:
next_cursor:
type: string
description: cursor to send with subsequent request to receive the next page, if non-empty
readOnly: true
items:
type: array
items:
$ref: '#/definitions/Fn'
Trigger:
type: object
properties:
id:
type: string
description: Unique trigger identifier
readOnly: true
name:
type: string
description: unique name for this trigger, used to identify this trigger
type:
type: string
description: class of trigger, e.g. schedule, http, queue
source:
type: string
description: uri path for this trigger. e.g. `sayHello`, `say/hello`
fn_id:
type: string
description: opaque, unique function identifier
readOnly: true
app_id:
type: string
description: opaque, unique application identifier
readOnly: true
annotations:
type: object
description: Trigger annotations - this is a map of annotations attached to this trigger, keys must not exceed 128 bytes and must consist of non-whitespace printable ascii characters, and the seralized representation of individual values must not exeed 512 bytes
additionalProperties:
type: object
created_at:
type: string
format: date-time
description: Time when trigger was created. Always in UTC.
readOnly: true
updated_at:
type: string
format: date-time
description: Most recent time that trigger was updated. Always in UTC.
readOnly: true
TriggerList:
type: object
required:
- items
properties:
next_cursor:
type: string
description: cursor to send with subsequent request to receive the next page, if non-empty
readOnly: true
items:
type: array
items:
$ref: '#/definitions/Trigger'
AppList:
type: object
required:
- items
properties:
next_cursor:
type: string
description: cursor to send with subsequent request to receive the next page, if non-empty
readOnly: true
items:
type: array
items:
$ref: '#/definitions/App'
ErrorBody:
type: object
properties:
message:
type: string
readOnly: true
fields:
type: string
readOnly: true
Error:
type: object
properties:
error:
$ref: '#/definitions/ErrorBody'
parameters:
cursor:
name: cursor
description: Cursor from previous response.next_cursor to begin results after, if any.
required: false
type: string
in: query
perPage:
name: per_page
description: Number of results to return, defaults to 30. Max of 100.
required: false
type: integer
in: query
AppID:
name: appID
in: path
description: Opaque Unique application ID
required: true
type: string
FnID:
name: fnID
in: path
description: Function ID.
required: true
type: string
TriggerID:
name: triggerID
in: path
description: Trigger ID.
required: true
type: string
FnIDQuery:
name: fn_id
in: query
description: Function ID.
required: false
type: string
AppIDQuery:
name: app_id
in: query
description: Function ID.
required: false
type: string