資料型別端點

資料型別在類別或結構描述欄位群組中的參考型別欄位使用方式,與基本常值欄位相同,主要差異在於資料型別可以定義多個子欄位。 雖然資料型別與欄位群組類似,因為其允許一致地使用多欄位結構,但資料型別較靈活,因為它們可以包含在架構結構中的任意位置,而欄位群組只能新增到根層級。 此 /datatypes 中的端點 Schema Registry API可讓您以程式設計方式管理體驗應用程式中的資料型別。

NOTE
如果欄位定義為特定資料型別,則無法在另一個結構描述中以不同的資料型別建立相同的欄位。 此限制適用於您組織的租使用者。

快速入門

本指南中使用的端點是 Schema Registry API. 在繼續之前,請檢閱 快速入門手冊 如需相關檔案的連結,請參閱本檔案範例API呼叫的指南,以及有關成功呼叫任何Experience PlatformAPI所需標題的重要資訊。

擷取資料型別清單 list

您可以列出底下的所有資料型別 globaltenant 向發出GET請求以建立容器 /global/datatypes/tenant/datatypes,依序輸入。

NOTE
列出資源時,結構描述登入將結果集限製為300個專案。 為了傳回超過此限制的資源,您必須使用分頁引數。 也建議您使用其他查詢引數來篩選結果並減少傳回的資源數量。 請參閱以下小節: 查詢引數 詳細資訊。

API格式

GET /{CONTAINER_ID}/datatypes?{QUERY_PARAMS}
參數
說明
{CONTAINER_ID}
您要從中擷取資料型別的容器: global (適用於Adobe建立的資料型別或 tenant 適用於貴組織擁有的資料型別。
{QUERY_PARAMS}
篩選結果的選用查詢引數。 請參閱 附錄檔案 以取得可用引數的清單。

要求

以下請求會從擷取資料型別清單 tenant 容器,使用 orderby 查詢引數,依其排序資料型別 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+json
傳回每個資源的簡短摘要。 這是列出資源的建議標頭。 (上限: 300)
application/vnd.adobe.xed+json
傳回每個資源的完整JSON資料型別,具有原始值 $refallOf 包含。 (上限: 300)

回應

上述要求使用 application/vnd.adobe.xed-id+json Accept 標題,因此回應僅包含 title$idmeta: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 針對Adobe建立的資料型別或 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
原始為 $refallOf,有標題和說明。
application/vnd.adobe.xed-full+json; version=1
$refallOf 已解決,具有標題和說明。
application/vnd.adobe.xed-notext+json; version=1
原始為 $refallOf,無標題或說明。
application/vnd.adobe.xed-full-notext+json; version=1
$refallOf 已解決,無標題或說明。
application/vnd.adobe.xed-full-desc+json; version=1
$refallOf 已解決,包含描述元。

回應

成功的回應會傳回資料型別的詳細資料。 傳回的欄位取決於 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

您可以在下定義自訂資料型別 tenant 容器建立POST要求。

API格式

POST /tenant/datatypes

要求

與欄位群組不同,定義資料型別不需要 meta:extendsmeta:intendedToExtend 欄位,也不需要巢狀化欄位來避免衝突。

定義資料型別本身的欄位結構時,您可以使用基本型別(例如 stringobject)或參考其他現有資料型別,方法如下: $ref 屬性。 請參閱以下指南: 在API中定義自訂XDM欄位 以取得不同XDM欄位型別之預期格式的詳細指引。

以下請求會建立具有子屬性的「屬性建構」物件資料型別 yearBuiltpropertyType、和 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 (已建立)以及包含新建立資料型別詳細資訊的裝載,包括 $idmeta:altId、和 version. 這三個值均為唯讀,並由 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要求至 列出所有資料型別 在租使用者容器中,現在將包含屬性詳細資料資料資料型別,或者您可以 執行查詢(GET)請求 使用URL編碼 $id URI以直接檢視新的資料型別。

更新資料型別 put

您可以透過PUT作業取代整個資料型別,基本上就是重新寫入資源。 透過PUT請求更新資料型別時,本文必須包含以下情況所需的所有欄位: 建立新資料型別 在POST要求中。

NOTE
如果您只想更新資料型別的一部分,而不是完全取代,請參閱 更新資料型別的一部分.

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 支援所有標準JSON修補程式操作,包括 addremove、和 replace. 如需JSON修補程式的詳細資訊,請參閱 API基礎指南.

NOTE
如果您想使用新值取代整個資源,而不是更新個別欄位,請參閱 使用PUT作業取代資料型別.

API格式

PATCH /tenant/data type/{DATA_TYPE_ID}
參數
說明
{DATA_TYPE_ID}
URL編碼 $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}
URL編碼 $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 (找不到),因為資料型別已從Schema Registry中移除。

recommendation-more-help
62e9ffd9-1c74-4cef-8f47-0d00af32fc07