アクション管理
mindzieStudioプロジェクト内のアクションを管理するための完全なCRUD操作。アクションは、ワークフローの構成要素で、自動化タスクを実行するために利用されます。
API エンドポイント
| メソッド | エンドポイント | 説明 |
|---|---|---|
| GET | /api/{tenantId}/{projectId}/action |
すべてのアクションの一覧取得 |
| GET | /api/{tenantId}/{projectId}/action/{actionId} |
アクションの詳細取得 |
| POST | /api/{tenantId}/{projectId}/action |
アクションの作成 |
| PUT | /api/{tenantId}/{projectId}/action/{actionId} |
アクションの更新 |
| DELETE | /api/{tenantId}/{projectId}/action/{actionId} |
アクションの削除 |
| POST | /api/{tenantId}/{projectId}/action/{actionId}/enable |
アクションの有効化 |
| POST | /api/{tenantId}/{projectId}/action/{actionId}/disable |
アクションの無効化 |
すべてのアクション一覧取得
GET /api/{tenantId}/{projectId}/action
プロジェクトに設定されているすべてのアクションを取得します。
パスパラメータ
| パラメータ | 種類 | 必須 | 説明 |
|---|---|---|---|
tenantId |
GUID | はい | テナントID |
projectId |
GUID | はい | プロジェクトID |
レスポンス (200 OK)
{
"actions": [
{
"actionId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"projectId": "87654321-4321-4321-4321-210987654321",
"name": "Daily Data Refresh",
"description": "Refreshes data from source systems daily",
"isEnabled": true,
"maxRunTime": 3600,
"actionStatus": "Idle",
"nextRunTime": "2024-01-16T06:00:00Z",
"lastRunTime": "2024-01-15T06:00:00Z",
"lastRunResult": "Success",
"dateCreated": "2024-01-01T10:00:00Z",
"dateModified": "2024-01-15T14:30:00Z",
"createdBy": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"modifiedBy": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"triggers": [...],
"steps": [...]
}
],
"totalCount": 1
}
アクション詳細取得
GET /api/{tenantId}/{projectId}/action/{actionId}
特定のアクションの詳細情報を取得します。
パスパラメータ
| パラメータ | 種類 | 必須 | 説明 |
|---|---|---|---|
tenantId |
GUID | はい | テナントID |
projectId |
GUID | はい | プロジェクトID |
actionId |
GUID | はい | 取得対象のアクションID |
レスポンス (200 OK)
{
"actionId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"projectId": "87654321-4321-4321-4321-210987654321",
"name": "Daily Data Refresh",
"description": "Refreshes data from source systems daily",
"isEnabled": true,
"maxRunTime": 3600,
"actionStatus": "Idle",
"nextRunTime": "2024-01-16T06:00:00Z",
"lastRunTime": "2024-01-15T06:00:00Z",
"lastRunResult": "Success",
"dateCreated": "2024-01-01T10:00:00Z",
"dateModified": "2024-01-15T14:30:00Z",
"createdBy": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"modifiedBy": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"triggers": [
{
"triggerId": "11111111-1111-1111-1111-111111111111",
"actionId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"triggerType": "DailyScheduler",
"settings": "{}",
"frequency": 1,
"eventName": null,
"startDate": "2024-01-01",
"dateCreated": "2024-01-01T10:00:00Z"
}
],
"steps": [
{
"stepId": "22222222-2222-2222-2222-222222222222",
"actionId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"stepNumber": 1,
"stepType": "Python",
"description": "Execute data refresh script",
"settings": "{\"script\": \"refresh_data.py\"}",
"dateCreated": "2024-01-01T10:00:00Z"
}
]
}
レスポンスフィールド
| フィールド | 種類 | 説明 |
|---|---|---|
actionId |
GUID | アクションの一意識別子 |
projectId |
GUID | アクションが属するプロジェクト |
name |
string | 表示名 |
description |
string | アクションの説明 |
isEnabled |
boolean | アクションが有効かどうか |
maxRunTime |
integer | 最大実行時間(秒単位) |
actionStatus |
string | 現在の状態(Idle, Runningなど) |
nextRunTime |
datetime | 次回実行予定時刻 |
lastRunTime |
datetime | 最終実行時刻 |
lastRunResult |
string | 最終実行結果 |
triggers |
array | トリガー設定 |
steps |
array | アクションのステップ定義 |
アクション作成
POST /api/{tenantId}/{projectId}/action
プロジェクト内に新しいアクションを作成します。
パスパラメータ
| パラメータ | 種類 | 必須 | 説明 |
|---|---|---|---|
tenantId |
GUID | はい | テナントID |
projectId |
GUID | はい | プロジェクトID |
リクエストボディ
{
"name": "Weekly Report",
"description": "Generate weekly analysis report",
"isEnabled": true,
"maxRunTime": 1800,
"steps": [
{
"stepNumber": 1,
"stepType": "Python",
"description": "Generate report",
"settings": "{\"script\": \"generate_report.py\"}"
},
{
"stepNumber": 2,
"stepType": "Email",
"description": "Send report via email",
"settings": "{\"recipients\": [\"team@company.com\"]}"
}
],
"triggers": [
{
"triggerType": "WeeklyScheduler",
"frequency": 1,
"startDate": "2024-01-08"
}
]
}
リクエストフィールド
| フィールド | 種類 | 必須 | 説明 |
|---|---|---|---|
name |
string | はい | アクション名(プロジェクト内で一意である必要があります) |
description |
string | いいえ | アクションの説明 |
isEnabled |
boolean | いいえ | アクションの有効状態(デフォルト:true) |
maxRunTime |
integer | いいえ | 最大実行時間(秒単位、デフォルト:3600) |
steps |
array | はい | 少なくとも1つのステップが必要 |
triggers |
array | いいえ | 任意のトリガー設定 |
ステップオブジェクト
| フィールド | 種類 | 必須 | 説明 |
|---|---|---|---|
stepNumber |
integer | いいえ | 実行順序(指定しない場合は自動割当) |
stepType |
string | はい | 種類:Python、Email、Webhookなど |
description |
string | いいえ | ステップの説明 |
settings |
string | はい | ステップのJSON設定 |
トリガーオブジェクト
| フィールド | 種類 | 必須 | 説明 |
|---|---|---|---|
triggerType |
string | はい | 種類:HourlyScheduler、DailyScheduler、WeeklyScheduler、MonthlyScheduler、EventTrigger |
frequency |
integer | いいえ | 実行頻度の乗数 |
startDate |
date | いいえ | スケジュール開始日 |
eventName |
string | いいえ | イベント名(EventTrigger用) |
settings |
string | いいえ | その他トリガー設定 |
レスポンス (201 Created)
作成されたアクション(割り当てられたID付き)を返します。
エラー応答
Conflict (409) - 重複する名前
{
"Error": "An action with this name already exists in the project"
}
アクション更新
PUT /api/{tenantId}/{projectId}/action/{actionId}
既存のアクションを更新します。
パスパラメータ
| パラメータ | 種類 | 必須 | 説明 |
|---|---|---|---|
tenantId |
GUID | はい | テナントID |
projectId |
GUID | はい | プロジェクトID |
actionId |
GUID | はい | 更新対象のアクションID |
リクエストボディ
{
"name": "Updated Weekly Report",
"description": "Updated description",
"isEnabled": true,
"maxRunTime": 2400,
"steps": [
{
"stepId": "22222222-2222-2222-2222-222222222222",
"stepNumber": 1,
"stepType": "Python",
"description": "Updated step",
"settings": "{\"script\": \"updated_report.py\"}"
}
],
"triggers": [
{
"triggerId": "11111111-1111-1111-1111-111111111111",
"triggerType": "DailyScheduler",
"frequency": 1,
"startDate": "2024-02-01"
}
]
}
すべてのフィールドは任意で、指定されたフィールドのみが更新されます。
レスポンス (200 OK)
更新されたアクションを返します。
アクション削除
DELETE /api/{tenantId}/{projectId}/action/{actionId}
アクションを完全に削除します。
パスパラメータ
| パラメータ | 種類 | 必須 | 説明 |
|---|---|---|---|
tenantId |
GUID | はい | テナントID |
projectId |
GUID | はい | プロジェクトID |
actionId |
GUID | はい | 削除対象のアクションID |
レスポンス (204 No Content)
成功時は空のレスポンス。
アクション有効化
POST /api/{tenantId}/{projectId}/action/{actionId}/enable
無効化されたアクションを有効化します。
レスポンス (200 OK)
isEnabled: true の更新済みアクションを返します。
アクション無効化
POST /api/{tenantId}/{projectId}/action/{actionId}/disable
アクションを無効化します。
レスポンス (200 OK)
isEnabled: false の更新済みアクションを返します。
実装例
cURL
# すべてのアクション一覧取得
curl -X GET "https://your-mindzie-instance.com/api/{tenantId}/{projectId}/action" \
-H "Authorization: Bearer YOUR_API_KEY"
# アクションの作成
curl -X POST "https://your-mindzie-instance.com/api/{tenantId}/{projectId}/action" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Daily Report",
"description": "Generate daily report",
"isEnabled": true,
"steps": [
{
"stepNumber": 1,
"stepType": "Python",
"description": "Run report script",
"settings": "{\"script\": \"daily_report.py\"}"
}
],
"triggers": [
{
"triggerType": "DailyScheduler",
"frequency": 1,
"startDate": "2024-01-15"
}
]
}'
# アクションの更新
curl -X PUT "https://your-mindzie-instance.com/api/{tenantId}/{projectId}/action/{actionId}" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Updated Daily Report"}'
# アクションの削除
curl -X DELETE "https://your-mindzie-instance.com/api/{tenantId}/{projectId}/action/{actionId}" \
-H "Authorization: Bearer YOUR_API_KEY"
# アクションの有効化/無効化
curl -X POST "https://your-mindzie-instance.com/api/{tenantId}/{projectId}/action/{actionId}/enable" \
-H "Authorization: Bearer YOUR_API_KEY"
curl -X POST "https://your-mindzie-instance.com/api/{tenantId}/{projectId}/action/{actionId}/disable" \
-H "Authorization: Bearer YOUR_API_KEY"
Python
import requests
BASE_URL = 'https://your-mindzie-instance.com'
TENANT_ID = '12345678-1234-1234-1234-123456789012'
PROJECT_ID = '87654321-4321-4321-4321-210987654321'
class ActionManager:
def __init__(self, api_key):
self.headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
def list_actions(self):
"""すべてのアクションを一覧取得します。"""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action'
response = requests.get(url, headers=self.headers)
response.raise_for_status()
return response.json()
def get_action(self, action_id):
"""アクションの詳細を取得します。"""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action/{action_id}'
response = requests.get(url, headers=self.headers)
response.raise_for_status()
return response.json()
def create_action(self, name, steps, description=None, triggers=None):
"""新しいアクションを作成します。"""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action'
data = {
'name': name,
'description': description,
'isEnabled': True,
'steps': steps,
'triggers': triggers or []
}
response = requests.post(url, json=data, headers=self.headers)
response.raise_for_status()
return response.json()
def update_action(self, action_id, **kwargs):
"""アクションを更新します。"""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action/{action_id}'
response = requests.put(url, json=kwargs, headers=self.headers)
response.raise_for_status()
return response.json()
def delete_action(self, action_id):
"""アクションを削除します。"""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action/{action_id}'
response = requests.delete(url, headers=self.headers)
response.raise_for_status()
def enable_action(self, action_id):
"""アクションを有効化します。"""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action/{action_id}/enable'
response = requests.post(url, headers=self.headers)
response.raise_for_status()
return response.json()
def disable_action(self, action_id):
"""アクションを無効化します。"""
url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action/{action_id}/disable'
response = requests.post(url, headers=self.headers)
response.raise_for_status()
return response.json()
# 使用例
manager = ActionManager('your-api-key')
# アクションの作成
action = manager.create_action(
name='Daily Report',
description='Generate daily analysis report',
steps=[
{
'stepNumber': 1,
'stepType': 'Python',
'description': 'Generate report',
'settings': '{"script": "daily_report.py"}'
}
],
triggers=[
{
'triggerType': 'DailyScheduler',
'frequency': 1,
'startDate': '2024-01-15'
}
]
)
print(f"作成されたアクション: {action['actionId']}")
# 無効化してから有効化
manager.disable_action(action['actionId'])
print("アクションが無効化されました")
manager.enable_action(action['actionId'])
print("アクションが有効化されました")
# アクションの更新
updated = manager.update_action(action['actionId'], name='Updated Daily Report')
# アクションの削除
manager.delete_action(action['actionId'])
print("アクションが削除されました")
JavaScript/Node.js
const BASE_URL = 'https://your-mindzie-instance.com';
const TENANT_ID = '12345678-1234-1234-1234-123456789012';
const PROJECT_ID = '87654321-4321-4321-4321-210987654321';
class ActionManager {
constructor(apiKey) {
this.headers = {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
};
}
async listActions() {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/action`;
const response = await fetch(url, { headers: this.headers });
if (!response.ok) throw new Error(`Failed: ${response.status}`);
return response.json();
}
async createAction(name, steps, description = null, triggers = []) {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/action`;
const response = await fetch(url, {
method: 'POST',
headers: this.headers,
body: JSON.stringify({ name, description, isEnabled: true, steps, triggers })
});
if (!response.ok) throw new Error(`Failed: ${response.status}`);
return response.json();
}
async updateAction(actionId, updates) {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/action/${actionId}`;
const response = await fetch(url, {
method: 'PUT',
headers: this.headers,
body: JSON.stringify(updates)
});
if (!response.ok) throw new Error(`Failed: ${response.status}`);
return response.json();
}
async deleteAction(actionId) {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/action/${actionId}`;
const response = await fetch(url, {
method: 'DELETE',
headers: this.headers
});
if (!response.ok) throw new Error(`Failed: ${response.status}`);
}
async enableAction(actionId) {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/action/${actionId}/enable`;
const response = await fetch(url, { method: 'POST', headers: this.headers });
if (!response.ok) throw new Error(`Failed: ${response.status}`);
return response.json();
}
async disableAction(actionId) {
const url = `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/action/${actionId}/disable`;
const response = await fetch(url, { method: 'POST', headers: this.headers });
if (!response.ok) throw new Error(`Failed: ${response.status}`);
return response.json();
}
}
// 使用例
const manager = new ActionManager('your-api-key');
// アクションの作成
const action = await manager.createAction(
'Daily Report',
[{ stepNumber: 1, stepType: 'Python', description: 'Run script', settings: '{}' }],
'Generate daily report',
[{ triggerType: 'DailyScheduler', frequency: 1, startDate: '2024-01-15' }]
);
// 有効化/無効化 の切り替え
await manager.disableAction(action.actionId);
await manager.enableAction(action.actionId);
// 削除
await manager.deleteAction(action.actionId);
ベストプラクティス
- ユニークな名前:アクション名はプロジェクト内で一意である必要があります
- ステップ順序:ステップは
stepNumberの順に実行されます - 有効化/無効化:削除と再作成ではなく、有効化/無効化APIを使用してください
- トリガー:スケジューリングに適切なトリガータイプを使用してください
- 最大実行時間:異常終了を防ぐために適切なタイムアウトを設定してください