FaaS側のアプリケーションは下記の仕様に従って作成してください。
- エンドポイント
- POST {任意のURL}
- Request (application/json)
- Headers
- x-api-key: {任意のAPIキー}
- Content-Type: application/json
- Attributes
- 任意の属性
- Headers
- Response 200 (application/json)
- 任意のレスポンス
- Response 400 (application/json)
- 任意のレスポンス
- 制約
- 処理完了時に処理状況更新APIにアクセスし、ActRecipeに処理が成功/失敗したことを通知すること
- 処理時間は14分以内とすること
Pythonによるサンプルコード
import json
import requests
url = 'https://external.prod.actrecipe.com/process/update-result'
headers = {
'Content-Type': 'application/json',
'x-api-key': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
# 「FaaS間連携」レシピのAPIキーは「レシピ説明」に記載しております
}
def handler(event, context):
try:
args = json.loads(event['body'])
# TODO implement
# Processing time should not exceed 14 minutes.
body_data = {
'execution_id': args['execution_id'],
'result': True,
"artifact": {
"service_name": "actrecipe",
"files": [
{
"FileUrl": "https://xxxxxxxxxxxxxxxxxxxxxxxxx",
"file_name": "契約書サンプル.pdf"
}
]
},
'message': "Success.",
}
# TODO Request to Processing Status Update API
# Save 'success' to tracking
res = requests.post(url, json=body_data, headers=headers)
return {
'statusCode': 200,
'body': json.dumps(body_data)
}
except Exception as err:
body_data = {
'execution_id': args['execution_id'],
'result': False,
'message': 'failed.',
'error': str(err)
}
# TODO Request to Processing Status Update API
# Save 'failed' to tracking
res = requests.post(url, json=body_data, headers=headers)
return {
"statusCode": 400,
"body": json.dumps(body_data)
}
FaaS側のアプリケーションからActRecipeに処理状況を返すには下記のドキュメントを参照してください。
■関連