Commit a89f5913 authored by Alexander Lercher's avatar Alexander Lercher

Added Trace Retrieval microservice

parents
**/__pycache__
FROM python:3
LABEL maintainer="Alexander Lercher"
ENV http_proxy http://proxy.uni-klu.ac.at:3128/
ENV https_proxy http://proxy.uni-klu.ac.at:3128/
RUN apt-get update
RUN pip install flask
RUN pip install connexion[swagger-ui]
EXPOSE 5000
WORKDIR /app
COPY app/ /app/
RUN chmod a+x main.py
CMD ["python", "./main.py"]
\ No newline at end of file
# Trace Retrieval Microservice
The trace retrieval microservice is used as an interface to the blockchain component (TIC). It receives and preprocesses all available traces.
## Technologies
- Python 3.x
- Python module Flask
- Python module Connexion with Swagger
- Docker
- Kubernetes
\ No newline at end of file
from flask import request, Response
def receive():
# print(request.json)
return Response(status=201)
swagger: "2.0"
info:
title: Trace Retrieval microservice
description: This is the documentation for the trace retrieval microservice.
version: "1.0.0"
consumes:
- "application/json"
produces:
- "application/json"
basePath: "/api"
# Paths supported by the server application
paths:
/debug:
post:
operationId: "debug.echo"
tags:
- "Echo"
summary: "Echo function for debugging purposes"
description: "Echoes the input back to the caller."
parameters:
- in: body
name: "Object"
required: true
schema:
type: object
responses:
200:
description: "Successful echo of request data"
/trace:
post:
operationId: "blockchain_trace.receive"
tags:
- "Blockchain Trace"
summary: "Add a new blockchain trace to SMART"
description: "Receives a new blockchain trace to store in SMART."
parameters:
- in: body
name: "BlockchainTrace"
description: "The trace to be added"
required: true
schema:
$ref: "#/definitions/BlockchainTrace"
responses:
201:
description: "Successful operation"
400:
description: "Invalid input"
definitions:
BlockchainTrace:
type: "object"
properties:
TransactionId:
type: string
format: uuid
Timestamp:
type: "string"
format: "date-time"
ApplicationType:
type: "string"
TransactionFrom:
type: "string"
format: "uuid"
TransactionTo:
type: "string"
format: "uuid"
TransferredAsset:
type: "string"
ResourceIds:
type: "string"
ResourceMd5:
type: "string"
ResourceState:
type: "string"
Metadata:
type: "string"
\ No newline at end of file
from flask import request
def echo():
return request.json
\ No newline at end of file
import connexion
# load swagger config
app = connexion.App(__name__, specification_dir='configs/')
app.add_api('swagger.yml')
@app.route('/', methods=['GET'])
def api_root():
return 'Endpoint of trace-retrieval-microservice!'
# start app
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)
apiVersion: apps/v1
kind: Deployment
metadata:
name: trace-retrieval
spec:
replicas: 2
selector:
matchLabels:
app: trace-retrieval
template:
metadata:
labels:
app: trace-retrieval
spec:
containers:
- name: trace-retrieval
image: 172.16.1.20:5000/trace-retrieval-microservice
ports:
- containerPort: 5000
\ No newline at end of file
apiVersion: v1
kind: Service
metadata:
name: trace-retrieval-endpoint
spec:
type: LoadBalancer
externalIPs:
- 143.205.173.36
selector:
app: trace-retrieval
ports:
- name: http
port: 80
targetPort: 5000
nodePort: 30001
protocol: TCP
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment