def callback(): payload = request.get_json() # Retreive original payload # .. # Call 'srm2local' service stage_endpoint = f'{proxy_host}/api/v1/function/srm2local/execute' response = post(stage_endpoint, json=payload) result = {} return json_respone(result, HTTPStatus.OK)
def lta2hpc(): payload = request.get_json() # Save original payload # ... # Overwrite webhook payload['webhook']['url'] = main_host + '/callback' # Call 'lofar-stage' service stage_endpoint = f'{proxy_host}/api/v1/function/lofar/stage' response = post(stage_endpoint, json=payload) # Save correlation id # ... result = {} return json_respone(result, HTTPStatus.ACCEPTED)
def execute(): payload = request.get_json() # Extract payload identifier = payload['id'] command = payload['cmd'] webhook = payload['webhook'] # Determine appropriate container to run if command['type'] == 'stage' and command['subtype'] == 'lofar': container = LofarStage(identifier, command, webhook) if command['type'] == 'copy' and command['subtype'] == 'srm2hpc': container = Srm2Hpc(identifier, command, webhook) # Run container response = container.run() return json_respone({ 'identifier': identifier, 'response': response }, 202)
def callback(): payload = request.get_json() result, status = functions.get('callback')(payload, db) return json_respone(result, status)
def status(identifier): payload = {'identifier': identifier} result, status = functions.get('status')(payload, db) return json_respone(result, status)
def index(): return json_respone({}, 200)
def stage(): payload = request.get_json() result, status = functions.get('stage')(payload) return json_respone(result, status)