Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

스케줄 생성(Create Schedule) (V2)

새 스케줄의 액션, 트리거와 실행 범위를 구성합니다. action은 필수이며 그 안의 target으로 빌드 대상을 지정합니다.

사용자 범위에서는 연결된 사용자가 접근할 수 있는 리소스를 기준으로 출력 대상을 찾습니다. 사용자의 권한이 바뀌면 빌드 대상이 달라지거나 실행이 실패할 수 있으므로 프로젝트 범위를 검토합니다.

이 엔드포인트는 미리보기 기능이며 언제든 변경되거나 제거될 수 있습니다. 사용하려면 preview=true를 지정합니다.

HTTP 요청

POST /api/v2/orchestration/schedules

작업 식별자는 v2.createSchedule입니다. OAuth2로 호출하는 타사 애플리케이션에는 api:orchestration-write 권한 범위가 필요합니다. 각 요청에 Authorization: Bearer <접근 토큰>을 전달합니다.

경로 매개변수

지정할 경로 매개변수가 없습니다.

쿼리 매개변수

이름자료형필수 여부의미와 조건예시 값
previewboolean선택미리보기 기능 사용을 활성화합니다.true

요청 본문

본문 형식은 CreateScheduleRequest이며 필수입니다.

이름자료형필수 여부의미와 조건예시 값
displayNamestring선택My Daily Schedule
descriptionstring선택Run all the transforms at midnight
actionobject필수본문 예시 참조
triggerunion선택스케줄을 실행할 조건입니다.본문 예시 참조
scopeModeunion<project, user>선택스케줄이 빌드할 수 있는 범위입니다.본문 예시 참조

action의 구조

모든 설정 필드와 입력의 필수 여부는 스케줄 액션을 따릅니다.

trigger의 구조

11가지 분기와 조합 조건은 트리거 참조를 따릅니다.

scopeMode의 구조

프로젝트 및 사용자 모드의 전체 필드는 실행 범위를 따릅니다.

다음은 스케줄의 액션, 트리거와 실행 범위를 지정하는 요청 본문 예시입니다.

{
  "displayName": "My Daily Schedule",
  "description": "Run all the transforms at midnight",
  "action": {
    "abortOnFailure": false,
    "forceBuild": false,
    "retryBackoffDuration": {
      "unit": "SECONDS",
      "value": 30
    },
    "retryCount": 1,
    "fallbackBranches": [],
    "branchName": "master",
    "notificationsEnabled": false,
    "target": {
      "type": "manual",
      "targetRids": [
        "ri.foundry.main.dataset.b737e24d-6b19-43aa-93d5-da9fc4073f6e",
        "ri.foundry.main.dataset.d2452a94-a755-4778-8bfc-a315ab52fc43"
      ]
    }
  },
  "trigger": {
    "type": "time",
    "cronExpression": "0 0 * * *",
    "timeZone": "UTC"
  },
  "scopeMode": {
    "type": "user"
  }
}

응답

응답 형식은 Schedule입니다.

반환된 스케줄입니다.

전체 필드는 Schedule 모델을 따릅니다.

새로 만든 스케줄의 응답 예시입니다.

{
  "updatedTime": "2024-09-25T17:29:35.974Z",
  "paused": false,
  "updatedBy": "f05f8da4-b84c-4fca-9c77-8af0b13d11de",
  "createdBy": "f05f8da4-b84c-4fca-9c77-8af0b13d11de",
  "displayName": "My Daily Schedule",
  "currentVersionRid": "ri.scheduler.main.schedule-version.4d1eb55f-6c13-411c-a911-5d84e08d8017",
  "description": "Run all the transforms at midnight",
  "createdTime": "2024-09-25T17:29:35.974Z",
  "action": {
    "abortOnFailure": false,
    "forceBuild": false,
    "retryBackoffDuration": {
      "unit": "SECONDS",
      "value": 30
    },
    "retryCount": 1,
    "fallbackBranches": [],
    "branchName": "master",
    "notificationsEnabled": false,
    "target": {
      "type": "manual",
      "targetRids": [
        "ri.foundry.main.dataset.b737e24d-6b19-43aa-93d5-da9fc4073f6e",
        "ri.foundry.main.dataset.d2452a94-a755-4778-8bfc-a315ab52fc43"
      ]
    }
  },
  "trigger": {
    "type": "time",
    "cronExpression": "0 0 * * *",
    "timeZone": "UTC"
  },
  "rid": "ri.scheduler.main.schedule.5ad5c340-59f3-4a60-9fc6-161bb984f871",
  "scopeMode": {
    "type": "user"
  }
}

개별 오류

오류 이름오류 코드HTTP의미와 조건추가 매개변수
CreateSchedulePermissionDeniedPERMISSION_DENIED403스케줄을 생성할 권한이 없습니다.

요청 예제

FOUNDRY_HOST에는 https://를 제외한 Foundry 호스트를, FOUNDRY_TOKEN에는 유효한 토큰을 환경 변수로 제공합니다. 예시 식별자와 매개변수 값은 실제 작업 대상에 맞게 바꿉니다.

대상 두 개를 UTC 자정에 빌드하는 사용자 범위 예제입니다. 0 0 * * *는 분, 시, 일, 월, 요일 순서이며 notificationsEnabled는 false입니다. 실제 대상과 범위를 검토하여 사용합니다. 요청은 새 스케줄을 만듭니다.

cURL

curl -X POST \
	-H "Content-type: application/json" \
	-H "Authorization: Bearer ${FOUNDRY_TOKEN}" \
	"https://${FOUNDRY_HOST}/api/v2/orchestration/schedules?preview=true" \
	-d '{"displayName":"My Daily Schedule","description":"Run all the transforms at midnight","action":{"abortOnFailure":false,"forceBuild":false,"retryBackoffDuration":{"unit":"SECONDS","value":30},"retryCount":1,"fallbackBranches":[],"branchName":"master","notificationsEnabled":false,"target":{"type":"manual","targetRids":["ri.foundry.main.dataset.b737e24d-6b19-43aa-93d5-da9fc4073f6e","ri.foundry.main.dataset.d2452a94-a755-4778-8bfc-a315ab52fc43"]}},"trigger":{"type":"time","cronExpression":"0 0 * * *","timeZone":"UTC"},"scopeMode":{"type":"user"}}'

Python

Requests 라이브러리가 설치된 Python 환경에서 사용합니다.

import os
import requests

HOSTNAME = os.environ["FOUNDRY_HOST"]
TOKEN = os.environ["FOUNDRY_TOKEN"]
headers = {
    "content-type": "application/json",
    "authorization": "Bearer {}".format(TOKEN)
}
request_body = {
    "displayName": "My Daily Schedule",
    "description": "Run all the transforms at midnight",
    "action": {
        "abortOnFailure": False,
        "forceBuild": False,
        "retryBackoffDuration": {
            "unit": "SECONDS",
            "value": 30
        },
        "retryCount": 1,
        "fallbackBranches": [],
        "branchName": "master",
        "notificationsEnabled": False,
        "target": {
            "type": "manual",
            "targetRids": [
                "ri.foundry.main.dataset.b737e24d-6b19-43aa-93d5-da9fc4073f6e",
                "ri.foundry.main.dataset.d2452a94-a755-4778-8bfc-a315ab52fc43"
            ]
        }
    },
    "trigger": {
        "type": "time",
        "cronExpression": "0 0 * * *",
        "timeZone": "UTC"
    },
    "scopeMode": {
        "type": "user"
    }
}

response = requests.post('https://{}/api/v2/orchestration/schedules?preview=true'.format(HOSTNAME), headers=headers, json=request_body)
print(response)

Java

Apache HttpClient 4.5 API와 try-with-resources를 사용합니다. 클래스 이름에 맞는 CreateScheduleExample.java 파일에서 사용합니다.

import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;

public class CreateScheduleExample {
    public static void main(String[] args) throws Exception {
        String HOSTNAME = System.getenv("FOUNDRY_HOST");
        String TOKEN = System.getenv("FOUNDRY_TOKEN");

        try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
            HttpPost request = new HttpPost("https://" + HOSTNAME + "/api/v2/orchestration/schedules?preview=true");
            request.addHeader("content-type", "application/json");
            request.addHeader("authorization", String.format("Bearer %s", TOKEN));
            request.setEntity(new StringEntity("{\"displayName\":\"My Daily Schedule\",\"description\":\"Run all the transforms at midnight\",\"action\":{\"abortOnFailure\":false,\"forceBuild\":false,\"retryBackoffDuration\":{\"unit\":\"SECONDS\",\"value\":30},\"retryCount\":1,\"fallbackBranches\":[],\"branchName\":\"master\",\"notificationsEnabled\":false,\"target\":{\"type\":\"manual\",\"targetRids\":[\"ri.foundry.main.dataset.b737e24d-6b19-43aa-93d5-da9fc4073f6e\",\"ri.foundry.main.dataset.d2452a94-a755-4778-8bfc-a315ab52fc43\"]}},\"trigger\":{\"type\":\"time\",\"cronExpression\":\"0 0 * * *\",\"timeZone\":\"UTC\"},\"scopeMode\":{\"type\":\"user\"}}", ContentType.APPLICATION_JSON));
            try (CloseableHttpResponse response = httpClient.execute(request)) {
                System.out.println(response);
            }
        }
    }
}

JavaScript

fetch를 제공하는 Node.js 환경에서 사용합니다. 서비스 사용자 토큰을 브라우저로 전달하지 않습니다.

const HOSTNAME = process.env.FOUNDRY_HOST;
const TOKEN = process.env.FOUNDRY_TOKEN;

fetch(`https://${HOSTNAME}/api/v2/orchestration/schedules?preview=true`, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${TOKEN}`,
    },
    body: '{"displayName":"My Daily Schedule","description":"Run all the transforms at midnight","action":{"abortOnFailure":false,"forceBuild":false,"retryBackoffDuration":{"unit":"SECONDS","value":30},"retryCount":1,"fallbackBranches":[],"branchName":"master","notificationsEnabled":false,"target":{"type":"manual","targetRids":["ri.foundry.main.dataset.b737e24d-6b19-43aa-93d5-da9fc4073f6e","ri.foundry.main.dataset.d2452a94-a755-4778-8bfc-a315ab52fc43"]}},"trigger":{"type":"time","cronExpression":"0 0 * * *","timeZone":"UTC"},"scopeMode":{"type":"user"}}'
}).then((response) => {
    console.log(response)
});

PowerShell

$ErrorActionPreference = 'Stop'
$TOKEN = $env:FOUNDRY_TOKEN
$HOSTNAME = $env:FOUNDRY_HOST

$headers = @{
    "authorization" = "Bearer $TOKEN"
}

$response = Invoke-WebRequest -Uri "https://$HOSTNAME/api/v2/orchestration/schedules?preview=true" `
	-Method Post `
	-Headers $headers `
	-ContentType application/json `
	-Body "{`"displayName`":`"My Daily Schedule`",`"description`":`"Run all the transforms at midnight`",`"action`":{`"abortOnFailure`":false,`"forceBuild`":false,`"retryBackoffDuration`":{`"unit`":`"SECONDS`",`"value`":30},`"retryCount`":1,`"fallbackBranches`":[],`"branchName`":`"master`",`"notificationsEnabled`":false,`"target`":{`"type`":`"manual`",`"targetRids`":[`"ri.foundry.main.dataset.b737e24d-6b19-43aa-93d5-da9fc4073f6e`",`"ri.foundry.main.dataset.d2452a94-a755-4778-8bfc-a315ab52fc43`"]}},`"trigger`":{`"type`":`"time`",`"cronExpression`":`"0 0 * * *`",`"timeZone`":`"UTC`"},`"scopeMode`":{`"type`":`"user`"}}"

$response.content