Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

여러 데이터셋의 스키마 조회(Get Schema Datasets Batch) (V2)

최대 1,000개 데이터셋의 스키마를 한 요청에서 조회합니다. 데이터셋이 없거나 사용자에게 접근 권한이 없으면 해당 항목을 응답에서 생략합니다. 입력한 모든 RID가 응답에 반드시 존재하지는 않습니다.

경로 및 쿼리 매개변수는 없습니다. 필수 본문은 GetSchemaDatasetsBatchRequestElement 객체들의 JSON 배열입니다.

요청 배열 항목

필드자료형필수 여부의미
datasetRidstring필수조회할 데이터셋 RID
branchNamestring선택브랜치 이름
endTransactionRidstring선택끝 트랜잭션 RID. 생략하면 최신 커밋 트랜잭션
versionIdstring선택스키마 버전. 생략하면 최신 버전

응답

GetSchemaDatasetsBatchResponse.data는 선택적인 map<DatasetRid, GetDatasetSchemaResponse>입니다. 키는 데이터셋 RID이며 값은 해당 데이터셋의 스키마 응답입니다.

각 값에는 branchName, endTransactionRid, schema, versionId가 필수로 포함됩니다. schema.fieldSchemaList의 각 DatasetFieldSchema에는 type과 nullable이 필수이고, 이름과 유형별 중첩 필드는 해당 조건에 따라 지정합니다. 전체 정의는 스키마 자료형에 있습니다.

HTTP 요청

POST /api/v2/datasets/getSchemaBatch

작업 식별자는 v2.getSchemaDatasetsBatch입니다. Authorization: Bearer <접근 토큰> 헤더로 인증합니다. OAuth 클라이언트에는 api:datasets-read 권한 범위가 필요합니다.

JSON 요청 예시

가상 데이터셋을 대상으로 하는 요청 본문 예시입니다.

[
  {
    "endTransactionRid": "ri.foundry.main.transaction.0a0207cb-26b7-415b-bc80-66a3aa3933f4",
    "datasetRid": "ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da",
    "versionId": "0000000d-2acf-537c-a228-3a9fe3cdc523",
    "branchName": "master"
  }
]

JSON 응답 예시

가상 데이터셋의 응답 예시입니다.

{
  "data": {
    "ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da": {
      "endTransactionRid": "ri.foundry.main.transaction.0a0207cb-26b7-415b-bc80-66a3aa3933f4",
      "schema": {
        "fieldSchemaList": [
          {
            "name": "id",
            "type": "LONG",
            "nullable": false,
            "customMetadata": {
              "description": "Primary key"
            }
          },
          {
            "name": "event_time",
            "type": "TIMESTAMP",
            "nullable": false
          },
          {
            "name": "price",
            "type": "DECIMAL",
            "precision": 10,
            "scale": 2,
            "nullable": true
          },
          {
            "name": "tags",
            "type": "ARRAY",
            "nullable": true,
            "arraySubtype": {
              "type": "STRING",
              "nullable": false
            }
          },
          {
            "name": "metrics",
            "type": "STRUCT",
            "nullable": true,
            "subSchemas": [
              {
                "name": "temperature",
                "type": "DOUBLE",
                "nullable": true
              },
              {
                "name": "humidity",
                "type": "DOUBLE",
                "nullable": true
              }
            ]
          }
        ]
      },
      "versionId": "0000000d-2acf-537c-a228-3a9fe3cdc523",
      "branchName": "master"
    }
  }
}

오류

실패 응답은 공통 API 오류의 형식으로 처리합니다.

요청 예제

FOUNDRY_HOST에는 https://를 제외한 Foundry 호스트를, FOUNDRY_TOKEN에는 유효한 토큰을 환경 변수로 제공합니다. 아래 RID, 이름과 파일 경로는 예시이며 실제 작업 대상으로 바꾸어야 합니다.

cURL

curl -X POST \
	-H "Content-type: application/json" \
	-H "Authorization: Bearer ${FOUNDRY_TOKEN}" \
	"https://${FOUNDRY_HOST}/api/v2/datasets/getSchemaBatch" \
	-d '[{"endTransactionRid":"ri.foundry.main.transaction.0a0207cb-26b7-415b-bc80-66a3aa3933f4","datasetRid":"ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da","versionId":"0000000d-2acf-537c-a228-3a9fe3cdc523","branchName":"master"}]'

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 = [
    {
        "endTransactionRid": "ri.foundry.main.transaction.0a0207cb-26b7-415b-bc80-66a3aa3933f4",
        "datasetRid": "ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da",
        "versionId": "0000000d-2acf-537c-a228-3a9fe3cdc523",
        "branchName": "master"
    }
]

response = requests.post('https://{}/api/v2/datasets/getSchemaBatch'.format(HOSTNAME), headers=headers, json=request_body)
print(response)

Java

Apache HttpClient 4.5 API와 try-with-resources를 사용하는 예제입니다. 클래스 이름에 맞는 GetSchemaDatasetsBatchExample.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 GetSchemaDatasetsBatchExample {
    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/datasets/getSchemaBatch");
            request.addHeader("content-type", "application/json");
            request.addHeader("authorization", String.format("Bearer %s", TOKEN));
            request.setEntity(new StringEntity("[{\"endTransactionRid\":\"ri.foundry.main.transaction.0a0207cb-26b7-415b-bc80-66a3aa3933f4\",\"datasetRid\":\"ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da\",\"versionId\":\"0000000d-2acf-537c-a228-3a9fe3cdc523\",\"branchName\":\"master\"}]", 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/datasets/getSchemaBatch`, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${TOKEN}`,
    },
    body: '[{"endTransactionRid":"ri.foundry.main.transaction.0a0207cb-26b7-415b-bc80-66a3aa3933f4","datasetRid":"ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da","versionId":"0000000d-2acf-537c-a228-3a9fe3cdc523","branchName":"master"}]'
}).then((response) => {
    console.log(response)
});

PowerShell

$TOKEN = $env:FOUNDRY_TOKEN
$HOSTNAME = $env:FOUNDRY_HOST

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

$response = Invoke-WebRequest -Uri "https://$HOSTNAME/api/v2/datasets/getSchemaBatch" `
	-Method Post `
	-Headers $headers `
	-ContentType application/json `
	-Body "[{`"endTransactionRid`":`"ri.foundry.main.transaction.0a0207cb-26b7-415b-bc80-66a3aa3933f4`",`"datasetRid`":`"ri.foundry.main.dataset.c26f11c8-cdb3-4f44-9f5d-9816ea1c82da`",`"versionId`":`"0000000d-2acf-537c-a228-3a9fe3cdc523`",`"branchName`":`"master`"}]"

$response.content