HTTP API
Manage trigger configurations using raw HTTP APIs and the Triggers Admin API.
読み終わるまでの所要時間 3 分最終更新 23日前
Raw HTTP API を使用して、トリガー設定を管理できます。
API の使用
Triggers Admin API のドキュメントには、トリガーの作成、読み取り、削除などの管理操作の詳細な説明が記載されています。 ドキュメントには、認証、エンドポイント、およびリクエストとレスポンスの形式に関する情報が、例とともに記載されています。これらを OpenAPI 形式でダウンロードし、独自の自動化を設定するために使用できます。 API を使用するには、サービスアカウント を使用して認証します。Authorization ヘッダー
リクエストを認証するには、Basic 認証 を使用します。サービスアカウントと base64 エンコード<KEY_ID>:<SECRET_KEY>Authorization--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>' \
トリガーのデプロイ
以下のリクエストを送信することで、トリガー設定を設定できます。正常なレスポンスには、トリガー設定に関する情報が含まれます。例を次に示します。curl 'https://services.api.unity.com/triggers/v1/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/configs' \--header 'Content-Type: application/json' \--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>' \--data '{ "name": "example-trigger-name", "eventType": "com.unity.services.scheduler.example-event.v1", "actionType": "cloud-code", "actionUrn": "urn:ugs:cloud-code:MyTestScript" "filter": "data[\"parameter\"] == \"value\""}'
{ "id": "12675a97-5166-4a7e-bee4-6c3a856026a8", "createdAt": "2023-08-25T14:01:16Z", "updatedAt": "2023-08-25T14:01:16Z", "name": "example-trigger-name", "projectId": "0ea7b997-b8bc-4125-97f9-e082e0cbf355", "environmentId": "de4504b7-70ca-475a-8862-00b5150f1d56", "eventType": "com.unity.services.scheduler.example-event.v1", "actionType": "cloud-code", "actionUrn": "urn:ugs:cloud-code:MyTestScript", "filter": "data['parameter'] == 'value'"}
- : トリガー設定 ID。
id - : トリガー設定が作成された日時。
createdAt - : トリガー設定の最終更新日時。
updatedAt - : トリガー設定名。
name - : 関連付けられているプロジェクト ID。
projectId - : 関連付けられている環境 ID。
environmentId - : トリガー設定をトリガーするイベントタイプ。
eventType - : トリガーが発生したときに実行されるアクションのタイプ。現在、
actionTypeのみがサポートされています。cloud-code - : トリガーが発生したときに呼び出す必要のあるものを定義します。例えば、
actionUrnはurn:ugs:cloud-code:TestScriptCloud Code スクリプトを呼び出し、TestScriptはurn:ugs:cloud-code:TestModule/TestFunctionCloud Code モジュール内のTestModule関数を呼び出します。TestFunction - : トリガーが起動するために満たす必要がある条件を定義する任意のフィールド。条件が満たされない場合、トリガーは起動しません。詳細については、フィルター を参照してください。
filter
ideventTypeトリガーの取得
トリガーの設定を調べるには、以下のリクエストを送信します。レスポンスは以下のようになります:curl 'https://services.api.unity.com/triggers/v1/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/configs/<CONFIG_ID>' \--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>'
デプロイしたすべてのトリガーをプレビューするには、以下のリクエストを送信します。{ "id": "ad06a027-d0e6-47d9-bf84-ad7d20ed5a66", "createdAt": "2024-07-30T15:59:08Z", "updatedAt": "2024-07-30T15:59:08Z", "name": "test-leaderboard-trigger", "projectId": "0ea7b997-b8bc-4125-97f9-e082e0cbf355", "environmentId": "c9acf5d7-d53b-4bc7-b622-7b63c1ee6dc7", "eventType": "com.unity.services.leaderboards.score-submitted.v1", "actionType": "cloud-code", "actionUrn": "urn:ugs:cloud-code:test-score-script", "filter": "data['score'] > 1000 || data['score'] > 56"}
レスポンスは以下のようになります:curl 'https://services.api.unity.com/triggers/v1/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/configs' \--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>'
クエリパラメーターを設定してページ処理を使用することもできます。例えば、最初の 2 つの設定を取得するには、以下のリクエストを送信します。{ "configs": [ { "id": "c5cc255e-93e5-4ac8-9b9a-f16a94892fff", "createdAt": "2023-08-25T14:07:56Z", "updatedAt": "2023-08-25T14:07:56Z", "name": "example-trigger-name-3", "eventType": "com.unity.services.scheduler.other-event.v1", "actionType": "cloud-code", "actionUrn": "urn:ugs:cloud-code:TestModule/TestEndpoint" }, { "id": "acf63347-4523-427b-937b-d73943d542dd", "createdAt": "2023-08-25T14:07:31Z", "updatedAt": "2023-08-25T14:07:31Z", "name": "example-trigger-name-2", "eventType": "com.unity.services.authentication.signed-up.v1", "actionType": "cloud-code", "actionUrn": "urn:ugs:cloud-code:TestModule/TestEndpoint" }, { "id": "12675a97-5166-4a7e-bee4-6c3a856026a8", "createdAt": "2023-08-25T14:01:16Z", "updatedAt": "2023-08-25T14:01:16Z", "name": "example-trigger-name", "eventType": "com.unity.services.scheduler.example-event.v1", "actionType": "cloud-code", "actionUrn": "urn:ugs:cloud-code:MyTestScript", "filter": "data['parameter'] == 'value'" } ], "limit": 100, "after": ""}
レスポンスは以下のようになります。curl 'https://services.api.unity.com/triggers/v1/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/configs?limit=2' \--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>'
{ "configs": [ { "id": "c5cc255e-93e5-4ac8-9b9a-f16a94892fff", "createdAt": "2023-08-25T14:07:56Z", "updatedAt": "2023-08-25T14:07:56Z", "name": "example-trigger-name-3", "eventType": "com.unity.services.scheduler.other-event.v1", "actionType": "cloud-code", "actionUrn": "urn:ugs:cloud-code:TestModule/TestEndpoint" }, { "id": "acf63347-4523-427b-937b-d73943d542dd", "createdAt": "2023-08-25T14:07:31Z", "updatedAt": "2023-08-25T14:07:31Z", "name": "example-trigger-name-2", "eventType": "com.unity.services.scheduler.another-event.v1", "actionType": "cloud-code", "actionUrn": "urn:ugs:cloud-code:TestModule/TestEndpoint" } ], "limit": 2, "after": "<TOKEN>"}
after最後のトリガーが返されます。curl 'https://services.api.unity.com/triggers/v1/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/configs?limit=2&after=<TOKEN>' \--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>'
{ "configs": [ { "id": "12675a97-5166-4a7e-bee4-6c3a856026a8", "createdAt": "2023-08-25T14:01:16Z", "updatedAt": "2023-08-25T14:01:16Z", "name": "example-trigger-name", "eventType": "com.unity.services.scheduler.example-event.v1", "actionType": "cloud-code", "actionUrn": "urn:ugs:cloud-code:MyTestScript", "filter": "data['parameter'] == 'value'" } ], "limit": 2, "after": ""}
トリガーの削除
以下のリクエストを送信することで、トリガー設定を削除できます。空のレスポンスは削除に成功したことを示します。curl --request DELETE 'https://services.api.unity.com/triggers/v1/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/configs/<CONFIG_ID>' \--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>'