기술 자료

지원

Cloud Code

Cloud Code

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>
를 base64로 인코딩하여 해당 값을
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
    : 트리거 구성 이름입니다.
  • projectId
    : 연결된 프로젝트 ID입니다.
  • environmentId
    : 연결된 환경 ID입니다.
  • eventType
    : 트리거 구성을 트리거하는 이벤트 유형입니다.
  • actionType
    : 트리거가 발동할 때 실행할 작업 유형입니다. 현재
    cloud-code
    만 지원됩니다.
  • actionUrn
    : 트리거가 발동할 때 호출할 항목을 정의합니다. 예를 들어,
    urn:ugs:cloud-code:TestScript
    TestScript
    Cloud Code 스크립트를 호출하고,
    urn:ugs:cloud-code:TestModule/TestFunction
    TestModule
    Cloud Code 모듈의
    TestFunction
    함수를 호출합니다.
  • filter
    : 트리거가 실행되기 위해 충족되어야 하는 조건을 정의하는 선택 사항 필드입니다. 조건이 충족되지 않으면 트리거가 실행되지 않습니다. 자세한 내용은 필터를 참고하십시오.
id
를 사용하여 트리거를 삭제할 수 있습니다.
트리거를 기존 Cloud Code 스크립트나 모듈과 연결한 경우, 지정된
eventType
으로 이벤트를 발생시키면 트리거가 발동하여 연결된 Cloud Code 스크립트 또는 모듈이 실행됩니다.

트리거 검색

트리거 구성을 확인하려면 다음 요청을 보냅니다.
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>'
빈 응답은 삭제에 성공했음을 나타냅니다.