データタイプエンドポイント
データタイプは、基本リテラルフィールドと同じ方法で、クラスまたはスキーマフィールドグループの参照型フィールドとして使用されます。主な違いは、データタイプが複数のサブフィールドを定義できることです。 複数フィールド構造を一貫して使用できるという点でフィールドグループと似ていますが、データタイプは、スキーマ構造のどこにでも含めることができるのに対し、フィールドグループはルートレベルでのみ追加できるため、より柔軟です。 Schema Registry APIの/datatypes エンドポイントを使用すると、エクスペリエンスアプリケーション内のデータタイプをプログラムで管理できます。
はじめに
このガイドで使用されているエンドポイントは、Schema Registry APIの一部です。 先に進む前に、はじめる前にを参照し、関連ドキュメントへのリンク、このドキュメントのサンプル API 呼び出しを読み取るためのガイドおよび任意の Experience Platform API を正常に呼び出すために必要なヘッダーに関する重要な情報を確認してください。
データタイプのリストの取得 list
globalまたはtenant コンテナの下にあるすべてのデータタイプを一覧表示するには、それぞれ/global/datatypesまたは/tenant/datatypesにGET リクエストを行います。
API 形式
GET /{CONTAINER_ID}/datatypes?{QUERY_PARAMS}
{CONTAINER_ID}globalまたは自社が所有するデータタイプのtenantからデータタイプを取得するコンテナ。{QUERY_PARAMS}リクエスト
次のリクエストは、orderby クエリパラメーターを使用して、tenant コンテナからデータタイプのリストを取得し、データタイプをtitle属性で並べ替えます。
curl -X GET \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/datatypes?orderby=title \
-H 'Accept: application/vnd.adobe.xed-id+json' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
応答の形式は、リクエストで送信されたAccept ヘッダーによって異なります。 データ型の一覧表示には、次のAccept ヘッダーを使用できます。
Accept ヘッダーapplication/vnd.adobe.xed-id+jsonapplication/vnd.adobe.xed+json$refとallOfが含まれている各リソースの完全なJSON データタイプを返します。 (上限:300)応答
上記のリクエストではapplication/vnd.adobe.xed-id+json Accept ヘッダーが使用されていたため、応答には、各データタイプのtitle、$id、meta:altIdおよびversion属性のみが含まれています。 他のAccept ヘッダー(application/vnd.adobe.xed+json)を使用すると、各データタイプのすべての属性が返されます。 応答に必要な情報に応じて、適切なAccept ヘッダーを選択します。
{
"results": [
{
"$id": "https://ns.adobe.com/{TENANT_ID}/datatypes/78570e371092c032260714dd8bfd6d44",
"meta:altId": "_{TENANT_ID}.datatypes.78570e371092c032260714dd8bfd6d44",
"version": "1.0",
"title": "Loyalty"
},
{
"$id": "https://ns.adobe.com/{TENANT_ID}/datatypes/4b0329b5573cbb7cb757db667d7fdf66",
"meta:altId": "_{TENANT_ID}.datatypes.4b0329b5573cbb7cb757db667d7fdf66",
"version": "1.0",
"title": "Property Details"
}
],
"_page": {
"orderby": "title",
"next": null,
"count": 2
},
"_links": {
"next": null,
"global_schemas": {
"href": "https://platform.adobe.io/data/foundation/schemaregistry/global/datatypes?orderby=title"
}
}
}
データタイプの検索 lookup
GET リクエストのパスにデータタイプのIDを含めることで、特定のデータタイプを検索できます。
API 形式
GET /{CONTAINER_ID}/datatypes/{DATA_TYPE_ID}
{CONTAINER_ID}global、または組織が所有するデータ型のtenant。{DATA_TYPE_ID}meta:altIdまたはURL エンコードされた$idです。リクエスト
次のリクエストは、パスで指定されたmeta:altId値でデータタイプを取得します。
curl -X GET \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/datatypes/_{TENANT_ID}.datatypes.78570e371092c032260714dd8bfd6d44 \
-H 'Accept: application/vnd.adobe.xed+json' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
応答の形式は、リクエストで送信されたAccept ヘッダーによって異なります。 すべてのルックアップリクエストでは、versionをAccept ヘッダーに含める必要があります。 次のAccept ヘッダーを使用できます。
Accept ヘッダーapplication/vnd.adobe.xed+json; version=1$ref および allOf で生、タイトルと説明を含むapplication/vnd.adobe.xed-full+json; version=1$ref および allOf を解決、タイトルと説明を含むapplication/vnd.adobe.xed-notext+json; version=1$ref および allOf で生、タイトルや説明なしapplication/vnd.adobe.xed-full-notext+json; version=1$ref および allOf で解決、タイトルや説明なしapplication/vnd.adobe.xed-full-desc+json; version=1$ref および allOf で解決、説明を含む応答
応答が成功すると、データタイプの詳細が返されます。 返されるフィールドは、リクエストで送信されたAccept ヘッダーによって異なります。 様々なAccept ヘッダーを試して、回答を比較し、どのヘッダーがユースケースに最適かを判断します。
{
"$id": "https://ns.adobe.com/{TENANT_ID}/datatypes/78570e371092c032260714dd8bfd6d44",
"meta:altId": "_{TENANT_ID}.datatypes.78570e371092c032260714dd8bfd6d44",
"meta:resourceType": "datatypes",
"version": "1.0",
"title": "Loyalty",
"type": "object",
"description": "Loyalty object containing loyalty-specific fields.",
"definitions": {
"customFields": {
"properties": {
"loyaltyId": {
"title": "Loyalty ID",
"description": "Unique loyalty program member ID. Should be in the format of an email address.",
"type": "string",
"meta:xdmType": "string"
},
"memberSince": {
"title": "Member Since",
"description": "Date person joined loyalty program.",
"type": "string",
"format": "date",
"meta:xdmType": "date"
},
"points": {
"title": "Points",
"description": "Accumulated loyalty points",
"type": "integer",
"meta:xdmType": "int"
},
"loyaltyLevel": {
"title": "Loyalty Level",
"description": "The current loyalty program level to which the individual member belongs.",
"type": "string",
"enum": [
"platinum",
"gold",
"silver",
"bronze"
],
"meta:enum": {
"platinum": "Platinum",
"gold": "Gold",
"silver": "Silver",
"bronze": "Bronze"
},
"meta:xdmType": "string"
}
},
"type": "object",
"meta:xdmType": "object"
}
},
"allOf": [
{
"$ref": "#/definitions/customFields"
}
],
"imsOrg": "{ORG_ID}",
"meta:extensible": true,
"meta:abstract": true,
"meta:xdmType": "object",
"meta:registryMetadata": {
"repo:createdDate": 1557529442681,
"repo:lastModifiedDate": 1557529442681,
"xdm:createdClientId": "{CLIENT_ID}",
"xdm:lastModifiedClientId": "{CLIENT_ID}",
"xdm:lastModifiedUserId": "{USER_ID}",
"eTag": "50b8008b588e911314f9685240dd4c23a247f37179a6d9ff6ba3877dc11ca504",
"meta:globalLibVersion": "1.15.4"
},
"meta:containerId": "tenant",
"meta:tenantNamespace": "_{TENANT_ID}"
}
データタイプの作成 create
POST リクエストを行うことで、tenant コンテナの下にカスタムデータタイプを定義できます。
API 形式
POST /tenant/datatypes
リクエスト
フィールドグループとは異なり、データタイプを定義するためにmeta:extendsまたはmeta:intendedToExtend フィールドを必要とせず、またフィールドをネストして競合を回避する必要もありません。
データ型自体のフィールド構造を定義する場合は、プリミティブ型(stringやobjectなど)を使用するか、$ref属性を使用して他の既存のデータ型を参照できます。 さまざまなXDM フィールドタイプに想定される形式について詳しくは、APIでのカスタム XDM フィールドの定義に関するガイドを参照してください。
次のリクエストは、サブプロパティ yearBuilt、propertyTypeおよびlocationを含む「プロパティ構築」オブジェクトデータタイプを作成します。
curl -X POST \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/datatypes \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'Content-Type: application/json' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-d '{
"title": "Property Construction",
"description": "Information related to the property construction",
"type": "object",
"properties": {
"yearBuilt": {
"type": "integer",
"title": "Year Built",
"description": "The year the property was constructed."
},
"propertyType": {
"type": "string",
"title": "Property Type",
"description": "Type of building or structure in which the property exists.",
"enum": [
"freeStanding",
"mall",
"shoppingCenter"
],
"meta:enum": {
"freeStanding": "Free Standing Building",
"mall": "Mall Space",
"shoppingCenter": "Shopping Center"
}
},
"location": {
"title": "Location",
"description": "The physical location of the property.",
"$ref": "https://ns.adobe.com/xdm/common/address"
}
}
}'
応答
正常な応答は、HTTP ステータス 201(作成済み)と、新しく作成されたデータタイプの詳細($id、meta:altId、versionを含む)を含むペイロードを返します。 これらの3つの値は読み取り専用で、Schema Registryによって割り当てられます。
{
"$id": "https://ns.adobe.com/{TENANT_ID}/datatypes/669ffcc61cf5e94e8640dbe6a15f0f24eb3cd1ddbbfb6b36",
"meta:altId": "_{TENANT_ID}.datatypes.669ffcc61cf5e94e8640dbe6a15f0f24eb3cd1ddbbfb6b36",
"meta:resourceType": "datatypes",
"version": "1.0",
"title": "Property Construction",
"type": "object",
"description": "Information related to the property construction",
"properties": {
"yearBuilt": {
"type": "integer",
"title": "Year Built",
"description": "The year the property was constructed.",
"meta:xdmType": "int"
},
"propertyType": {
"type": "string",
"title": "Property Type",
"description": "Type of building or structure in which the property exists.",
"enum": [
"freeStanding",
"mall",
"shoppingCenter"
],
"meta:enum": {
"freeStanding": "Free Standing Building",
"mall": "Mall Space",
"shoppingCenter": "Shopping Center"
},
"meta:xdmType": "string"
},
"location": {
"title": "Location",
"description": "The physical location of the property.",
"$ref": "https://ns.adobe.com/xdm/common/address",
"type": "object",
"meta:xdmType": "object"
}
},
"refs": [
"https://ns.adobe.com/xdm/common/address"
],
"imsOrg": "{ORG_ID}",
"meta:extensible": true,
"meta:abstract": true,
"meta:xdmType": "object",
"meta:registryMetadata": {
"repo:createdDate": 1670885230789,
"repo:lastModifiedDate": 1670885230789,
"xdm:createdClientId": "{CLIENT_ID}",
"xdm:lastModifiedClientId": "{CLIENT_ID}",
"xdm:createdUserId": "{USER_ID}",
"xdm:lastModifiedUserId": "{USER_ID}",
"eTag": "d3cc803a1f8daa06b7c150d882bd337d88f4d5d5f08d36cfc4c2849dc0255f7e",
"meta:globalLibVersion": "1.38.3.1"
},
"meta:containerId": "tenant",
"meta:sandboxId": "1bd86660-c5da-11e9-93d4-6d5fc3a66a8e",
"meta:sandboxType": "production",
"meta:tenantNamespace": "_{TENANT_ID}"
}
テナントコンテナ内のすべてのデータタイプ 🔗を リストにGET リクエストを実行すると、プロパティの詳細データタイプが含まれるようになり、URL エンコードされた$id URIを使用してルックアップ (GET) リクエスト を実行して、新しいデータタイプを直接表示できるようになりました。
データタイプの更新 put
PUT操作を通じてデータタイプ全体を置き換え、基本的にリソースを書き換えることができます。 PUT リクエストを通じてデータタイプを更新する場合、本文には、POST リクエストで新しいデータタイプ を作成するときに必要なすべてのフィールドを含める必要があります。
API 形式
PUT /tenant/datatypes/{DATA_TYPE_ID}
{DATA_TYPE_ID}meta:altIdまたはURL エンコードされた$id。リクエスト
次のリクエストは、既存のデータタイプを書き換え、新しいfloorSize フィールドを追加します。
curl -X PUT \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/datatypes/_{TENANT_ID}.datatypes.7602bc6e97e5786a31c95d9e6531a1596687433451d97bc1 \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'Content-Type: application/json' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-d '{
"title": "Property Construction",
"description": "Information related to the property construction",
"type": "object",
"properties": {
"yearBuilt": {
"type": "integer",
"title": "Year Built",
"description": "The year the property was constructed."
},
"propertyType": {
"type": "string",
"title": "Property Type",
"description": "Type of building or structure in which the property exists.",
"enum": [
"freeStanding",
"mall",
"shoppingCenter"
],
"meta:enum": {
"freeStanding": "Free Standing Building",
"mall": "Mall Space",
"shoppingCenter": "Shopping Center"
}
},
"floorSize" {
"type": "integer",
"title": "Floor Size",
"description": "The floor size of the property, in square feet."
}
}
}'
応答
応答が成功すると、更新されたデータタイプの詳細が返されます。
{
"$id": "https://ns.adobe.com/{TENANT_ID}/datatypes/7602bc6e97e5786a31c95d9e6531a1596687433451d97bc1",
"meta:altId": "_{TENANT_ID}.datatypes.7602bc6e97e5786a31c95d9e6531a1596687433451d97bc1",
"meta:resourceType": "datatypes",
"version": "1.0",
"title": "Property Construction",
"type": "object",
"description": "Information related to the property construction",
"properties": {
"yearBuilt": {
"type": "integer",
"title": "Year Built",
"description": "The year the property was constructed.",
"meta:xdmType": "int"
},
"propertyType": {
"type": "string",
"title": "Property Type",
"description": "Type of building or structure in which the property exists.",
"enum": [
"freeStanding",
"mall",
"shoppingCenter"
],
"meta:enum": {
"freeStanding": "Free Standing Building",
"mall": "Mall Space",
"shoppingCenter": "Shopping Center"
},
"meta:xdmType": "string"
},
"floorSize" {
"type": "integer",
"title": "Floor Size",
"description": "The floor size of the property, in square feet.",
"meta:xdmType": "int"
}
},
"refs": [],
"imsOrg": "{ORG_ID}",
"meta:extensible": true,
"meta:abstract": true,
"meta:xdmType": "object",
"meta:registryMetadata": {
"repo:createdDate": 1604524729435,
"repo:lastModifiedDate": 1604524729435,
"xdm:createdClientId": "{CLIENT_ID}",
"xdm:lastModifiedClientId": "{CLIENT_ID}",
"xdm:createdUserId": "{USER_ID}",
"xdm:lastModifiedUserId": "{USER_ID}",
"eTag": "1c838764342756868ca1297869f582a38d15f03ed0acfc97fda7532d22e942c7",
"meta:globalLibVersion": "1.15.4"
},
"meta:containerId": "tenant",
"meta:sandboxId": "ff0f6870-c46d-11e9-8ca3-036939a64204",
"meta:sandboxType": "production",
"meta:tenantNamespace": "_{TENANT_ID}"
}
データタイプの一部を更新する patch
PATCH リクエストを使用すると、データタイプの一部を更新できます。 Schema Registryは、add、removeおよびreplaceを含むすべての標準JSON パッチ操作をサポートしています。 JSON パッチについて詳しくは、API の基本ガイドを参照してください。
API 形式
PATCH /tenant/data type/{DATA_TYPE_ID}
{DATA_TYPE_ID}$id URIまたはmeta:altId。リクエスト
以下のリクエスト例は、既存のデータタイプのdescriptionを更新し、新しいfloorSize フィールドを追加します。
リクエスト本文は配列の形式を取り、各リストオブジェクトは個々のフィールドに対する特定の変更を表します。 各オブジェクトには、実行する操作(op)、操作を実行するフィールド(path)、その操作(value)に含める情報が含まれます。
curl -X PATCH \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/datatypes/_{TENANT_ID}.datatypes.8779fd45d6e4eb074300023a439862bbba359b60d451627a \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'content-type: application/json' \
-d '[
{
"op": "replace",
"path": "/description",
"value": "Construction-related information for a company-operated property."
},
{
"op": "add",
"path": "/properties/floorSize",
"value": {
"type": "integer",
"title": "Floor Size",
"description": "The floor size of the property, in square feet."
}
}
]'
応答
応答には、両方の操作が正常に実行されたことが示されます。 descriptionが更新され、floorSizeがdefinitionsの下に追加されました。
{
"$id": "https://ns.adobe.com/{TENANT_ID}/datatypes/8779fd45d6e4eb074300023a439862bbba359b60d451627a",
"meta:altId": "_{TENANT_ID}.datatypes.8779fd45d6e4eb074300023a439862bbba359b60d451627a",
"meta:resourceType": "datatypes",
"version": "1.2",
"title": "Property Details",
"type": "object",
"description": "Details relating to a property operated by the company.",
"definitions": {
"property": {
"properties": {
"_{TENANT_ID}": {
"type": "object",
"properties": {
"propertyName": {
"type": "string",
"title": "Property Name",
"description": "Name of the property"
},
"propertyCity": {
"title": "Property City",
"description": "City where the property is located.",
"type": "string"
},
"propertyCountry": {
"title": "Property Country",
"description": "Country where the property is located.",
"type": "string"
},
"phoneNumber": {
"title": "Phone Number",
"description": "Primary phone number for the property.",
"type": "string"
},
"propertyType": {
"type": "string",
"title": "Property Type",
"description": "Type and primary use of property.",
"enum": [
"retail",
"yoga",
"fitness"
],
"meta:enum": {
"retail": "Retail Store",
"yoga": "Yoga Studio",
"fitness": "Fitness Center"
}
},
"propertyConstruction": {
"$ref": "https://ns.adobe.com/{TENANT_ID}/datatypes/24c643f618647344606222c494bd0102"
}
}
}
}
}
},
"allOf": [
{
"$ref": "#/definitions/customFields",
"type": "object",
"meta:xdmType": "object"
}
],
"imsOrg": "{ORG_ID}",
"meta:extensible": true,
"meta:abstract": true,
"meta:intendedToExtend": [
"https://ns.adobe.com/xdm/context/profile"
],
"meta:xdmType": "object",
"meta:registryMetadata": {
"repo:createdDate": 1594941263588,
"repo:lastModifiedDate": 1594941538433,
"xdm:createdClientId": "{CLIENT_ID}",
"xdm:lastModifiedClientId": "{CLIENT_ID}",
"xdm:createdUserId": "{USER_ID}",
"xdm:lastModifiedUserId": "{USER_ID}",
"eTag": "5e8a5e508eb2ed344c08cb23ed27cfb60c841bec59a2f7513deda0f7af903021",
"meta:globalLibVersion": "1.15.4"
},
"meta:containerId": "tenant",
"meta:tenantNamespace": "_{TENANT_ID}"
}
データタイプの削除 delete
スキーマレジストリからデータタイプを削除する必要がある場合があります。 これは、パスで指定されたデータタイプ IDを使用してDELETE リクエストを実行することによって実行されます。
API 形式
DELETE /tenant/datatypes/{DATA_TYPE_ID}
{DATA_TYPE_ID}$id URIまたはmeta:altId。リクエスト
curl -X DELETE \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/datatypes/_{TENANT_ID}.datatypes.d5cc04eb8d50190001287e4c869ebe67 \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
応答
正常な応答の場合は、空白の本文とともに HTTP ステータス 204 (コンテンツなし)が返されます。
データ型に ルックアップ (GET) リクエスト を試みることで、削除を確認できます。 リクエストにAccept ヘッダーを含める必要がありますが、データタイプがスキーマレジストリから削除されたため、HTTP ステータス 404 (見つかりません)を受け取る必要があります。