This commit is contained in:
Wolfgang Hottgenroth 2021-05-05 18:02:45 +02:00
commit c98243d39b
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
4 changed files with 77 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
__pycache__
*~
.*.sw?
.*~
ENV

20
Entries.py Normal file
View File

@ -0,0 +1,20 @@
import _typeshed
import logging
import werkzeug
from flask import request
import json
class Entry(object):
def __init__(self, ts, freq):
self.ts = ts
self.freq = freq
def insert(**args):
try:
body = request.json
logging.info("JSON Body: {}".format(body))
return "200"
except KeyError as e:
raise werkzeug.exceptions.InternalServerError("Key Error: {}".format(e))

43
openapi.yaml Normal file
View File

@ -0,0 +1,43 @@
openapi: 3.0.3
info:
title: SinkConvert2
version: "0.0.1"
paths:
/sc2/v1/entry:
post:
tags: [ "entry" ]
operationId: Entries.insert
summary: Insert one or more entries into the database
requestBody:
description: List of entries
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/entry"
responses:
201:
description: One or more entries has been inserted
401:
description: Unauthorized
404:
description: Not found
components:
schemas:
entry:
description: Entry with timestamp and frequency
type: object
properties:
timestamp:
description: Synchronized timestamp in RFC3339 format in timezone UTC
type: string
format: date-time
frequency:
description: Frequency in mHz
type: integer

8
server.py Normal file
View File

@ -0,0 +1,8 @@
import connexion
import logging
logging.basicConfig(level=logging.INFO)
app = connexion.App('SinkConvert2')
app.add_api('./openapi.yaml')
app.run(port=8080)