Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swagger files for the servers #1

Merged
merged 3 commits into from
Dec 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 189 additions & 0 deletions swagger/control/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
swagger: '2.0'
info:
title: Control API
description: |
API for managing the channels.
version: "1.0.0"
schemes:
- https
basePath: /
tags:
- name: "control"
paths:
/api/channel:
put:
operationId: put_channel
tags:
- control
description: |
updates the channel uniquely identified by a descriptor.

If there is already a channel associated with the descriptor, the old channel is overwritten with the new one.
parameters:
- name: channel
in: body
schema:
$ref: "#/definitions/Channel"
required: true
consumes:
- application/json
responses:
200:
description: signals that the channel update was accepted.
default:
description: contains an unexpected error.
delete:
operationId: delete_channel
tags:
- control
description: |
removes the channel associated with the descriptor.
parameters:
- name: descriptor
in: body
schema:
$ref: "#/definitions/Descriptor"
required: true
consumes:
- application/json
responses:
200:
description: signals that the channel was correctly erased.
404:
description: signals that no channel associated to the given descriptor was found.
default:
description: contains an unexpected error.

/api/list_channels:
get:
operationId: list_channels
tags:
- control
description: lists the available channels information.
parameters:
- name: page
in: query
description: specifies the index of a page. The default is 1 (first page).
type: integer
format: int32
- name: per_page
in: query
description: specifies a desired number of items per page. The default is 100.
type: integer
format: int32
consumes:
- application/json
produces:
- application/json
responses:
200:
description: serves the channel information list.
schema:
$ref: "#/definitions/ChannelsPage"
default:
description: contains an unexpected error.

TeodoroFilippini marked this conversation as resolved.
Show resolved Hide resolved
definitions:
Token:
description: is a string authenticating the sender of an HTTP request.
type: string
example: RBbPYhmPXurT8nM5TAJpPOcHMaFkJblA62mr6MCvpF4oVa6cy

Descriptor:
description: identifies a channel.
type: string
example: client-1/pipeline-3

Entity:
description: contains the email address and optionally the name of an entity.
type: object
properties:
email:
type: string
example: name@domain.com
name:
type: string
example: John Doe
required:
- email

Channel:
description: defines the messaging channel.
type: object
properties:
descriptor:
$ref: "#/definitions/Descriptor"
token:
$ref: "#/definitions/Token"
sender:
$ref: "#/definitions/Entity"
recipients:
type: array
items:
$ref: "#/definitions/Entity"
cc:
type: array
items:
$ref: "#/definitions/Entity"
bcc:
type: array
items:
$ref: "#/definitions/Entity"
TeodoroFilippini marked this conversation as resolved.
Show resolved Hide resolved
TeodoroFilippini marked this conversation as resolved.
Show resolved Hide resolved
min_period:
description: is the minimum push period frequency for a channel, in seconds.
type: number
format: float
max_size:
description: indicates the maximum allowed size of the request, in bytes.
type: integer
format: int64
required:
- descriptor
- token
- sender
- recipients
- min_period
- max_size

OptionalRel:
description: defines the link relation information about a page that might not exist.
type: object
properties:
href:
description: contains a URL.
type: string

ChannelsPage:
description: lists channels in a paginated manner.
type: object
properties:
page:
description: specifies the index of the page.
type: integer
format: int32
page_count:
description: specifies the number of pages available.
type: integer
format: int32
per_page:
description: specifies the number of items per page.
type: integer
format: int32
channels:
description: contains the channel data.
type: array
items:
$ref: "#/definitions/Channel"
prev:
$ref: "#/definitions/OptionalRel"
next:
$ref: "#/definitions/OptionalRel"
required:
- page
- page_count
- per_page
- channels
- prev
Copy link
Contributor

@mristin mristin Dec 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you already added page_count, I think that prev and next are now obsolete since the client needs to iterate over page_count specifying the page parameter in list_channels endpoint.

- next


79 changes: 79 additions & 0 deletions swagger/relay/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
swagger: '2.0'
info:
title: Relay Server API
description: |
relays messages coming from multiple message channels to a single Mailgun email channel.

The clients need to authenticate by basic auth specifying the channel descriptor as the
user name and the assigned API token as the password.
version: "1.0.0"
schemes:
- https
basePath: /
tags:
- name: "relay"
paths:
/api/message:
post:
operationId: put_message
tags:
- relay
description: |
sends a message to the server, which relays it to the MailGun API.

The given (descriptor, token) pair are authenticated first.
The message's metadata is determined by the channel information from the Control server.
parameters:
- name: X-descriptor
in: header
schema:
$ref: "#/definitions/Descriptor"
required: true
- name: X-token
in: header
schema:
$ref: "#/definitions/Token"
required: true
- name: message
in: body
schema:
$ref: "#/definitions/Message"
required: true
consumes:
- application/json
responses:
200:
description: signals that the message was correctly relayed to MailGun.
401:
description: signals that the request token is invalid.
404:
description: signals that the descriptor is unknown.
default:
description: contains an unexpected error.

definitions:
Token:
description: is a string authenticating the sender of an HTTP request.
type: string
example: RBbPYhmPXurT8nM5TAJpPOcHMaFkJblA62mr6MCvpF4oVa6cy

Descriptor:
description: identifies a channel.
type: string
example: client-1/pipeline-3

Message:
description: represents a message to be relayed.
type: object
properties:
subject:
description: contains the text to be used as the email's subject.
type: string
example: "broken pipeline observed"
content:
description: contains the text to be used as the email's content.
type: string
example: "A broken pipeline was observed the 10/12/2018 at 14:37. Please contact the system operator."
required:
- subject
- content