HTTP API
Manage trigger configurations using raw HTTP APIs and the Triggers Admin API.
읽는 시간 2분최근 업데이트: 한 달 전
원시 HTTP API를 사용하여 트리거 구성을 관리할 수 있습니다.
API 사용
Triggers 관리자 API 기술 자료에는 트리거 생성, 읽기, 삭제 등의 관리자 작업이 자세히 설명되어 있습니다. 기술 자료는 인증, 엔드포인트, 요청 및 응답 형식에 대한 정보와 예시를 소개합니다. OpenAPI 포맷으로 기술 자료를 다운로드하여 직접 자동화를 설정하는 데 활용할 수 있습니다. API를 사용하려면 서비스 계정을 사용하여 인증해야 합니다.인증 헤더
요청을 인증하려면 기본 인증을 사용합니다. 서비스 계정을 생성하고<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>'
쿼리 파라미터를 설정하여 페이지를 지정할 수도 있습니다. 예를 들어, 처음 두 개의 구성을 가져오려면 다음 요청을 전송하면 됩니다.{ "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>'