Commit 3f31e332 authored by Lionel Walter's avatar Lionel Walter
Browse files

Make the method a get instead of a post, update swagger description

parent 60f333d0
......@@ -54,7 +54,7 @@ def create_app(test_config=None):
api.add_resource(JobList, '/v1/jobs')
api.add_resource(JobStart, '/v1/job/<job_id>/start')
api.add_resource(JobStop, '/v1/job/<job_id>/stop')
api.add_resource(JobReport, '/v1/job/<topicName>/report')
api.add_resource(JobReport, '/v1/job/<topic_name>/report')
api.add_resource(Job, '/v1/job/<job_id>')
# TODO : maybe take that to a configuration (development vs pod running in
......
......@@ -6,21 +6,19 @@ import json
class JobReport(Resource):
# Todo write/correct comment for swagger
def post(self, topicName):
# Todo validate requests
# @swag.validate('job-parameters')
def get(self, topic_name):
"""
Get report form a job
Get report from a job
---
tags:
- Job Report
parameters:
- in: path
name: job_id
name: topic_name
required: true
description: The ID of the job. Must be lowercase
and contains only letters, numbers and -.
example: j0001
description: The name of the kafka topic for which we collect
the job summary
example: 025-text-file-validation-reporting
type: string
responses:
200:
......@@ -31,17 +29,16 @@ class JobReport(Resource):
status:
type: string
example: success/error
enum: ['success', 'error']
message:
enum: ['SUCCESS', 'FAILURE']
report:
type: string
example: 'NAME: j0001. LAST DEPLOYED: Thu May 14 16:15 2020.
NAMESPACE: memobase. STATUS: deployed.
REVISION: 1. TEST SUITE: None.'
example: 'institutionXYZ-235323B: something failed!\n
institutionXYZ-235323C: that one went totally wrong'
job_id:
type: string
example: j0001
422:
description: No entry found in the kafka-topic for the given job
500:
description: Impossible to get results
schema:
$ref: '#/definitions/helm-result'
......@@ -51,7 +48,7 @@ class JobReport(Resource):
try: # read from kafka topic and generate report from it:
report = ''
consumer = KafkaConsumer(
topicName,
topic_name,
value_deserializer=lambda m: json.loads(m.decode('utf8')),
bootstrap_servers=current_app.config['kafka-broker-url'],
auto_offset_reset='earliest',
......@@ -62,7 +59,7 @@ class JobReport(Resource):
return {'error': 'Unexpected Kafka error'}, 500
try: # read job-reporting messages from kafka
topic_partition = TopicPartition(topic=topicName, partition=0)
topic_partition = TopicPartition(topic=topic_name, partition=0)
jobMessages = consumer.poll(1000, 1000)
processed = succeeded = 0
if jobMessages:
......
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