アクション実行履歴
アクションの実行履歴を追跡・監視し、結果パッケージをダウンロードします。
概要
Action Execution APIは、アクション実行履歴の追跡、状態の監視、実行結果のダウンロードのためのエンドポイントを提供します。このAPIはメインのActions APIとは別のコントローラーを使用しています。
基本URL: /api/{tenantId}/{projectId}/actionexecution
アクションの実行履歴を取得
GET /api/{tenantId}/{projectId}/actionexecution/action/{actionId}
特定のアクションのすべての実行履歴を取得します。
リクエスト
GET https://your-mindzie-instance.com/api/{tenantId}/{projectId}/actionexecution/action/{actionId}
Authorization: Bearer {your-access-token}
パスパラメータ
| パラメータ | タイプ | 必須 | 説明 |
|---|---|---|---|
tenantId |
GUID | はい | テナント識別子 |
projectId |
GUID | はい | プロジェクト識別子 |
actionId |
GUID | はい | 実行履歴を取得するアクション |
レスポンス
成功 (200 OK):
{
"items": [
{
"actionId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"actionExecutionId": "11111111-2222-3333-4444-555555555555",
"dateStarted": "2024-01-15T10:30:00Z",
"dateEnded": "2024-01-15T10:32:15Z",
"status": "Completed",
"notes": null
},
{
"actionId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"actionExecutionId": "22222222-3333-4444-5555-666666666666",
"dateStarted": "2024-01-14T10:30:00Z",
"dateEnded": "2024-01-14T10:31:45Z",
"status": "Completed",
"notes": null
}
]
}
アクションの最新実行を取得
GET /api/{tenantId}/{projectId}/actionexecution/lastaction/{actionId}
特定のアクションの最新実行を取得します。
リクエスト
GET https://your-mindzie-instance.com/api/{tenantId}/{projectId}/actionexecution/lastaction/{actionId}
Authorization: Bearer {your-access-token}
パスパラメータ
| パラメータ | タイプ | 必須 | 説明 |
|---|---|---|---|
tenantId |
GUID | はい | テナント識別子 |
projectId |
GUID | はい | プロジェクト識別子 |
actionId |
GUID | はい | 最新実行を取得するアクション |
レスポンス
成功 (200 OK):
{
"actionId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"actionExecutionId": "11111111-2222-3333-4444-555555555555",
"dateStarted": "2024-01-15T10:30:00Z",
"dateEnded": "2024-01-15T10:32:15Z",
"status": "Completed",
"notes": null
}
未検出 (404):
{
"error": "Can't find action",
"actionId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
}
特定の実行詳細を取得
GET /api/{tenantId}/{projectId}/actionexecution/{executionId}
実行IDで特定の実行の詳細を取得します。
リクエスト
GET https://your-mindzie-instance.com/api/{tenantId}/{projectId}/actionexecution/{executionId}
Authorization: Bearer {your-access-token}
パスパラメータ
| パラメータ | タイプ | 必須 | 説明 |
|---|---|---|---|
tenantId |
GUID | はい | テナント識別子 |
projectId |
GUID | はい | プロジェクト識別子 |
executionId |
GUID | はい | 取得する実行 |
レスポンス
成功 (200 OK):
{
"actionId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"actionExecutionId": "11111111-2222-3333-4444-555555555555",
"dateStarted": "2024-01-15T10:30:00Z",
"dateEnded": "2024-01-15T10:32:15Z",
"status": "Completed",
"notes": null
}
未検出 (404):
{
"error": "Can't find action",
"executionId": "11111111-2222-3333-4444-555555555555"
}
実行パッケージをダウンロード
GET /api/{tenantId}/{projectId}/actionexecution/downloadpackage/{executionId}
完了した実行の結果パッケージ(ZIPファイル)をダウンロードします。
リクエスト
GET https://your-mindzie-instance.com/api/{tenantId}/{projectId}/actionexecution/downloadpackage/{executionId}
Authorization: Bearer {your-access-token}
パスパラメータ
| パラメータ | タイプ | 必須 | 説明 |
|---|---|---|---|
tenantId |
GUID | はい | テナント識別子 |
projectId |
GUID | はい | プロジェクト識別子 |
executionId |
GUID | はい | 結果をダウンロードする実行 |
レスポンス
成功 (200 OK):
実行結果、レポート、成果物を含むZIPファイルのダウンロードを返します。
HTTP/1.1 200 OK
Content-Type: application/zip
Content-Disposition: attachment; filename="{executionId}.zip"
[binary ZIP file content]
未検出 (404):
{
"error": "Execution not found",
"executionId": "11111111-2222-3333-4444-555555555555"
}
{
"error": "Zip file not found",
"executionId": "11111111-2222-3333-4444-555555555555"
}
実行レスポンスフィールド
| フィールド | タイプ | 説明 |
|---|---|---|
actionId |
GUID | 実行されたアクション |
actionExecutionId |
GUID | この実行の一意識別子 |
dateStarted |
datetime | 実行開始時刻 |
dateEnded |
datetime | 実行完了時刻(実行中はnull) |
status |
string | 現在の実行ステータス |
notes |
string | 実行メモまたはエラーメッセージ |
実行ステータスの値
| ステータス | 説明 |
|---|---|
| Queued | 実行がキューに入り開始待ち |
| Running | 実行中 |
| Completed | 実行が正常終了 |
| Failed | 実行にエラー発生 |
実装例
cURL
# アクションの実行履歴を取得
curl -X GET "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/actionexecution/action/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
# 最新の実行を取得
curl -X GET "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/actionexecution/lastaction/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
# 特定の実行を取得
curl -X GET "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/actionexecution/11111111-2222-3333-4444-555555555555" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
# 実行パッケージをダウンロード
curl -X GET "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/actionexecution/downloadpackage/11111111-2222-3333-4444-555555555555" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-o execution_results.zip
JavaScript/Node.js
const TENANT_ID = '12345678-1234-1234-1234-123456789012';
const PROJECT_ID = '87654321-4321-4321-4321-210987654321';
const BASE_URL = 'https://your-mindzie-instance.com';
// アクションの実行履歴を取得
const getExecutionHistory = async (actionId, token) => {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/actionexecution/action/${actionId}`;
const response = await fetch(url, {
headers: { 'Authorization': `Bearer ${token}` }
});
if (response.ok) {
const result = await response.json();
return result.items;
}
throw new Error(`Failed: ${response.status}`);
};
// 最新の実行を取得
const getLastExecution = async (actionId, token) => {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/actionexecution/lastaction/${actionId}`;
const response = await fetch(url, {
headers: { 'Authorization': `Bearer ${token}` }
});
if (response.ok) {
return await response.json();
} else if (response.status === 404) {
return null;
}
throw new Error(`Failed: ${response.status}`);
};
// 特定の実行詳細を取得
const getExecution = async (executionId, token) => {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/actionexecution/${executionId}`;
const response = await fetch(url, {
headers: { 'Authorization': `Bearer ${token}` }
});
if (response.ok) {
return await response.json();
}
throw new Error(`Failed: ${response.status}`);
};
// 実行パッケージをダウンロード
const downloadPackage = async (executionId, token) => {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/actionexecution/downloadpackage/${executionId}`;
const response = await fetch(url, {
headers: { 'Authorization': `Bearer ${token}` }
});
if (response.ok) {
const blob = await response.blob();
// ZIPファイルの保存または処理
return blob;
}
throw new Error(`Failed: ${response.status}`);
};
Python
import requests
TENANT_ID = '12345678-1234-1234-1234-123456789012'
PROJECT_ID = '87654321-4321-4321-4321-210987654321'
BASE_URL = 'https://your-mindzie-instance.com'
def get_execution_history(action_id, token):
"""アクションのすべての実行を取得します。"""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/actionexecution/action/{action_id}'
headers = {'Authorization': f'Bearer {token}'}
response = requests.get(url, headers=headers)
response.raise_for_status()
return response.json()['items']
def get_last_execution(action_id, token):
"""アクションの最新の実行を取得します。"""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/actionexecution/lastaction/{action_id}'
headers = {'Authorization': f'Bearer {token}'}
response = requests.get(url, headers=headers)
if response.status_code == 404:
return None
response.raise_for_status()
return response.json()
def get_execution(execution_id, token):
"""特定の実行の詳細を取得します。"""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/actionexecution/{execution_id}'
headers = {'Authorization': f'Bearer {token}'}
response = requests.get(url, headers=headers)
response.raise_for_status()
return response.json()
def download_package(execution_id, token, output_path):
"""実行結果パッケージをダウンロードします。"""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/actionexecution/downloadpackage/{execution_id}'
headers = {'Authorization': f'Bearer {token}'}
response = requests.get(url, headers=headers)
response.raise_for_status()
with open(output_path, 'wb') as f:
f.write(response.content)
return output_path
# 例:完了まで実行を監視する
def wait_for_completion(execution_id, token, max_wait_seconds=300):
import time
start_time = time.time()
while time.time() - start_time < max_wait_seconds:
execution = get_execution(execution_id, token)
status = execution['status']
if status == 'Completed':
print(f'Execution completed successfully')
return execution
elif status == 'Failed':
print(f'Execution failed: {execution.get("notes", "Unknown error")}')
return execution
else:
print(f'Status: {status}, waiting...')
time.sleep(5)
raise TimeoutError('Execution did not complete within timeout')
ベストプラクティス
- ステータスのポーリング: アクション実行後は実行エンドポイントをポーリングして進行状況を監視する
- 長時間実行の対応: 完了待ち時には適切なタイムアウトを設定する
- 結果のダウンロード: 出力があるアクションは完了後にパッケージをダウンロードする
- エラー処理: ステータスが「Failed」の場合は
notesフィールドで詳細を確認する - 実行履歴の利用: 監査やデバッグのために履歴エンドポイントを利用する