Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

여러 쿼리 함수를 RID로 조회(Get By RID Queries Batch) (V2)

최대 100개의 쿼리 함수를 RID로 조회합니다. 항목마다 버전과 사전 릴리스 포함 여부를 지정할 수 있으며 버전이 없으면 최신 버전을 선택합니다. 존재하지 않거나 토큰에 필요한 권한이 없는 쿼리는 응답에서 제외됩니다.

결과는 Query 목록입니다. 요청 위치만으로 대응시키지 않고 반환된 RID와 버전을 확인합니다.

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

HTTP 요청

POST /api/v2/functions/queries/getByRidBatch

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

경로 매개변수

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

쿼리 매개변수

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

요청 본문

본문 형식은 list<GetByRidQueriesBatchRequestElement>이며 필수입니다.

배열 항목은 GetByRidQueriesBatchRequestElement이며 자료형은 object입니다.

이름자료형필수 여부의미와 조건예시 값
includePrereleaseboolean선택버전을 지정하지 않은 경우 true이면 사전 릴리스도 최신 버전 후보에 포함하고, false이면 안정 버전만 고려합니다. 기본값은 false입니다.
ridstring필수함수의 고유 리소스 식별자이며 다른 Foundry API와 연계할 때 사용합니다.ri.function-registry.main.function.8cb2d957-f0e6-4e0c-81de-e701bd54b18c
versionstring선택함수 버전은 <major>.<minor>.<patch>-<tag> 형식이며 -<tag>는 생략할 수 있습니다. 예: 1.2.3, 1.2.3-rc1.1.2.3

다음 본문의 식별자와 값은 가상 예시입니다.

[
  {
    "rid": "ri.function-registry.main.function.8cb2d957-f0e6-4e0c-81de-e701bd54b18c",
    "version": "1.2.3"
  }
]

응답

응답 형식은 GetByRidQueriesBatchResponse입니다.

이름자료형필수 여부의미와 조건예시 값
datalist<Query>선택

data의 구조

배열 항목은 Query이며 자료형은 object입니다.

이름자료형필수 여부의미와 조건예시 값
apiNamestring필수쿼리 함수의 API 이름입니다.myQueryFunction
descriptionstring선택
displayNamestring선택표시 이름입니다.
parametersmap<ParameterId, Parameter>선택
outputQueryDataType필수쿼리 매개변수와 출력의 자료형을 구분합니다.
ridstring필수함수의 고유 리소스 식별자이며 다른 Foundry API와 연계할 때 사용합니다.ri.function-registry.main.function.8cb2d957-f0e6-4e0c-81de-e701bd54b18c
versionstring필수함수 버전은 <major>.<minor>.<patch>-<tag> 형식이며 -<tag>는 생략할 수 있습니다. 예: 1.2.3, 1.2.3-rc1.1.2.3
typeReferencesmap<TypeReferenceIdentifier, QueryDataType>선택
parameters의 구조

맵의 키는 ParameterId(string), 값은 Parameter(object)입니다.

키: 액션이나 쿼리 입력에 사용하는 매개변수의 고유 ID입니다. 매개변수는 Ontology Manager에서 확인하고 관리할 수 있습니다.

쿼리 매개변수의 설명과 자료형 및 필수 여부입니다.

이름자료형필수 여부의미와 조건예시 값
descriptionstring선택
dataTypeQueryDataType필수쿼리 매개변수와 출력의 자료형을 구분합니다.
requiredboolean필수
dataType의 구조

22가지 분기와 중첩 필드, 집계 및 유형 참조의 조건은 QueryDataType을 따릅니다.

output의 구조

22가지 분기와 중첩 필드, 집계 및 유형 참조의 조건은 QueryDataType을 따릅니다.

typeReferences의 구조

맵의 키는 TypeReferenceIdentifier(string), 값은 QueryDataType(union<date, struct, set, void, string, double, integer, threeDimensionalAggregation, union, float, geoshape, long, boolean, unsupported, attachment, mediaReference, null, array, twoDimensionalAggregation, valueTypeReference, typeReference, timestamp>)입니다.

키: 현재 Query의 typeReferences 맵에서 자료형 정의를 찾을 식별자입니다.

쿼리 매개변수와 출력의 자료형을 구분합니다.

22가지 분기와 중첩 필드, 집계 및 유형 참조의 조건은 QueryDataType을 따릅니다.

가상 쿼리 함수 배치의 응답 예시입니다.

{
  "data": [
    {
      "output": {
        "type": "double"
      },
      "apiName": "myQueryFunction",
      "displayName": "My Entity",
      "rid": "ri.function-registry.main.function.8cb2d957-f0e6-4e0c-81de-e701bd54b18c",
      "typeReferences": {
        "MyTypeReference": {
          "type": "integer"
        }
      },
      "parameters": {
        "price": {
          "dataType": {
            "type": "double"
          },
          "required": true
        }
      },
      "version": "1.2.3"
    }
  ]
}

개별 오류

오류 응답 처리는 공통 API 오류 계약을 따릅니다.

요청 예제

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

cURL

curl -X POST \
	-H "Content-type: application/json" \
	-H "Authorization: Bearer ${FOUNDRY_TOKEN}" \
	"https://${FOUNDRY_HOST}/api/v2/functions/queries/getByRidBatch?preview=true" \
	-d '[{"rid":"ri.function-registry.main.function.8cb2d957-f0e6-4e0c-81de-e701bd54b18c","version":"1.2.3"}]'

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 = [
    {
        "rid": "ri.function-registry.main.function.8cb2d957-f0e6-4e0c-81de-e701bd54b18c",
        "version": "1.2.3"
    }
]

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

Java

Apache HttpClient 4.5 API와 try-with-resources를 사용합니다. 클래스 이름에 맞는 GetByRidQueriesBatchExample.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 GetByRidQueriesBatchExample {
    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/functions/queries/getByRidBatch?preview=true");
            request.addHeader("content-type", "application/json");
            request.addHeader("authorization", String.format("Bearer %s", TOKEN));
            request.setEntity(new StringEntity("[{\"rid\":\"ri.function-registry.main.function.8cb2d957-f0e6-4e0c-81de-e701bd54b18c\",\"version\":\"1.2.3\"}]", 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/functions/queries/getByRidBatch?preview=true`, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${TOKEN}`,
    },
    body: '[{"rid":"ri.function-registry.main.function.8cb2d957-f0e6-4e0c-81de-e701bd54b18c","version":"1.2.3"}]'
}).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/functions/queries/getByRidBatch?preview=true" `
	-Method Post `
	-Headers $headers `
	-ContentType application/json `
	-Body "[{`"rid`":`"ri.function-registry.main.function.8cb2d957-f0e6-4e0c-81de-e701bd54b18c`",`"version`":`"1.2.3`"}]"

$response.content