Skip to content

Commit

Permalink
docs(openapi): Add basic openapi structure
Browse files Browse the repository at this point in the history
Create basic openapi sctructure for future contributions

Relates moira-alert#44
  • Loading branch information
litleleprikon authored and idoqo committed May 13, 2020
1 parent b2cd1c6 commit 124001b
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 0 deletions.
15 changes: 15 additions & 0 deletions api/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
openapi: 3.0.0
info:
description: "This is an API description for Moira Alert project. Please check https://github.com/moira-alert"
version: "2.5.1"
title: "Moira Alert"
# contact:
# link: "https://t.me/moira_alert"
license:
name: "MIT"
servers:
- url: http://localhost:8080/api
description: Localhost server
paths:
/trigger:
$ref: ./triggers/methods.yml
11 changes: 11 additions & 0 deletions api/triggers/methods.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
put:
summary: "Create new trigger"
description: ""
requestBody:
required: true
content:
application/json:
schema:
$ref: ./schemas/req_put.yml
responses:
$ref: ./responses/put.yml
12 changes: 12 additions & 0 deletions api/triggers/responses/put.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
200:
description: "Trigger created"
content:
application/json:
schema:
$ref: ../schemas/res_put.yml#/200
400:
description: "Invalid input"
content:
application/json:
schema:
$ref: ../schemas/res_put.yml#/400
89 changes: 89 additions & 0 deletions api/triggers/schemas/req_put.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
$schema: "http://json-schema.org/draft-04/schema#"
properties:
desc:
type: string
description: Trigger description
example: Dice roll trigger
error_value:
type: number
description: Target value at which error will be fired
example: 7
expression:
type: string
description: Expression that will be evaluated
example: "t1 > 6 ? ERROR : (t1 > 4)? WARN : OK"
id:
type: string
is_remote:
type: boolean
description: Which storage to use local or remote
example: false
mute_new_metrics:
type: boolean
example: true
name:
type: string
description: Trigger name
example: Dice Roll
patterns:
items:
type: string
type: array
example:
- local.dice.roll
description: Array of possible patterns to check values in simple mode
sched:
$schema: "http://json-schema.org/draft-04/schema#"
$ref: "#/definitions/ScheduleData"
tags:
items:
type: string
type: array
description: Array of tags associated with this trigger
example:
- test
targets:
items:
type: string
type: array
description: Array of targets associated with this trigger
throttling:
type: integer
description: Quantity of events before throttling will be enabled
trigger_type:
type: string
enum: ["rising", "falling", "expression"]
ttl:
type: integer
ttl_state:
type: string
warn_value:
type: number
description: Target value at which warning will be fired
example: 5
additionalProperties: false
type: object
definitions:
ScheduleData:
properties:
days:
items:
$schema: "http://json-schema.org/draft-04/schema#"
$ref: "#/definitions/ScheduleDataDay"
type: array
endOffset:
type: integer
startOffset:
type: integer
tzOffset:
type: integer
additionalProperties: false
type: object
ScheduleDataDay:
properties:
enabled:
type: boolean
name:
type: string
additionalProperties: false
type: object
18 changes: 18 additions & 0 deletions api/triggers/schemas/res_put.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
200:
type: object
properties:
id:
type: string
example: trigger_id
message:
type: string
example: trigger created
400:
type: object
properties:
status:
type: string
example: Invalid request
error:
type: string
example: error_value is equal to warn_value, please set exactly one value

0 comments on commit 124001b

Please sign in to comment.