Commit c1c2ca61 authored by Lionel Walter's avatar Lionel Walter
Browse files

Make read from Drupal available as an endpoint

parent cdfe0ced
......@@ -11,6 +11,7 @@ from import_api_app.resources.KafkaTopics import KafkaTopics
# from import_api_app.resources.ReadJobOptionsFromDrupal import ReadJobOptionsFromDrupal
import import_api_app.configuration
from import_api_app.resources.WriteJobResultsToDrupal import WriteJobResultToDrupal
from import_api_app.resources.ReadJobOptionsFromDrupal import ReadJobOptionsFromDrupal
import os
......@@ -63,8 +64,8 @@ def create_app(test_config=None):
api.add_resource(JobStop, '/v1/job/<process_id>/<job_name>/stop')
api.add_resource(Job, '/v1/job/<process_id>/<job_name>')
api.add_resource(WriteJobResultToDrupal, '/v1/drupal/<job_drupal_uuid>/<report>')
# api.add_resource(ReadJobOptionsFromDrupal, '/v1/fromDrupal/<job_drupal_uuid>')
api.add_resource(WriteJobResultToDrupal, '/v1/drupal/<job_log_drupal_uuid>/<report>')
api.add_resource(ReadJobOptionsFromDrupal, '/v1/drupal/<job_name>/<job_drupal_uuid>')
api.add_resource(KafkaTopics, '/v1/kafka/topics')
api.add_resource(JobReport, '/v1/job/<topic_name>/report')
from flask_restful import Resource
from flask_restful import Resource, current_app
import jsonapi_requests
class ReadJobOptionsFromDrupal(Resource):
def get(self, job_drupal_uuid):
def get(self, job_name, job_drupal_uuid):
Read the options from Drupal based on a job uuid
Read the options from Drupal based on a job uuid and transform it to camel case
- Drupal
- in: path
type: string
name: job_name
default: table-data-transform
enum: ['text-file-validation', 'table-data-transform', 'mapper-service']
required: true
- in: path
type: string
name: job_drupal_uuid
description: The drupal uuid of the paragraph describing this job
default: 481790a3-8ba2-4fd7-95b4-c3a17f08d7d1
description: The job data
id: jobs
type: object
$ref: '#/definitions/job'
description: The job parameters
api = jsonapi_requests.Api.config({
'API_ROOT': 'http://localhost:8080/jsonapi',
'API_ROOT': current_app.config['DRUPAL_API_URL'],
# 'AUTH': ('basic_auth_login', 'basic_auth_password'),
# in drupal job names have underscores instead of -
job_name = job_name.replace("-", "_")
endpoint = api.endpoint(
response = endpoint.get()
......@@ -4,7 +4,7 @@ import json
class WriteJobResultToDrupal(Resource):
def post(self, job_drupal_uuid, report):
def post(self, job_log_drupal_uuid, report):
Write the job summary to Drupal job log (in field_summary)
......@@ -12,7 +12,7 @@ class WriteJobResultToDrupal(Resource):
- Drupal
- in: path
name: job_drupal_uuid
name: job_log_drupal_uuid
required: true
description: job log uuid
default: 2b07341f-3b99-408c-a729-6e18dd77c6d5
......@@ -38,7 +38,7 @@ class WriteJobResultToDrupal(Resource):
data = {
"data": {
"id": job_drupal_uuid,
"id": job_log_drupal_uuid,
"type": "paragraph--job_log_result",
"attributes": {
"field_summary": report
......@@ -47,7 +47,7 @@ class WriteJobResultToDrupal(Resource):
url = current_app.config['DRUPAL_API_URL'] + \
'/paragraph/job_log_result/' + job_drupal_uuid
'/paragraph/job_log_result/' + job_log_drupal_uuid
response = requests.patch(
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