棄用API中的XDM欄位
在Experience Data Model (XDM)中,您可以使用結構描述登入API來取代結構描述或自訂資源中的欄位。 棄用欄位會使其在下游UI (例如設定檔工作區和Customer Journey Analytics)中隱藏,但這是不中斷的變更,不會對現有資料流程造成負面影響。
本文介紹如何為不同的XDM資源棄用欄位。 如需在Experience Platform使用者介面中使用「結構描述編輯器」來取代XDM欄位的步驟,請參閱有關取代UI中的XDM欄位的教學課程。
快速入門
本教學課程需要呼叫Schema Registry API。 請檢閱開發人員指南,以取得進行這些API呼叫所需瞭解的重要資訊。 這包括您的{TENANT_ID}
、「容器」的概念以及發出要求所需的標頭(特別注意Accept
標頭及其可能的值)。
棄用自訂欄位 custom
若要棄用自訂類別、欄位群組或資料型別中的欄位,請透過PUT或PATCH要求更新自訂資源,並將屬性meta:status: deprecated
新增到相關欄位。
以下範例API呼叫會淘汰自訂資料型別中的欄位。
API格式
PATCH /tenant/datatypes/{DATA_TYPE_ID}
要求
下列要求會針對描述不動產屬性的資料型別,取代expansionArea
欄位。
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: {IMS_ORG}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'content-type: application/json' \
-d '[
{
"op": "add",
"path": "/properties/expansionArea/meta:status",
"value": "deprecated"
}
]'
回應
成功的回應會傳回自訂資源的更新詳細資料,且已棄用的欄位包含meta:status
值deprecated
。 以下範例回應已截斷空格。
{
"$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 real-estate property operated by the company.",
"definitions": {
"property": {
"properties": {
"_{TENANT_ID}": {
"type":"object",
"properties": {
"expansionArea": {
"title": "Expansion Area",
"description": "Square footage for renovated additions to the property.",
"type": "integer",
"meta:status": "deprecated",
},
"propertyName": {
"title": "Property Name",
"description": "Name of the property",
"type": "string"
},
"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"
},
"squareFeet": {
"title": "Expansion Area",
"description": "Square footage for renovated additions to the property.",
"type": "integer",
}
}
}
}
}
},
"allOf": [
{
"$ref": "#/definitions/customFields",
"type": "object",
"meta:xdmType": "object"
}
],
"imsOrg": "{IMS_ORG}",
"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}"
}
棄用結構描述中的標準欄位 standard
標準類別、欄位群組和資料型別中的欄位無法直接棄用。 反之,您可以在採用這些標準資源的個別結構描述中,使用描述項來取代標準資源。
建立欄位取代描述項 create-descriptor
若要為您要棄用的結構描述欄位建立描述項,請對/tenant/descriptors
端點發出POST要求。
API格式
POST /tenant/descriptors
要求
curl -X POST \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/descriptors \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Content-Type: application/json' \
-d '{
"@type": "xdm:descriptorDeprecated",
"xdm:sourceSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/c65ddf08cf2d4a2fe94bd06113bf4bc4c855e12a936410d5",
"xdm:sourceVersion": 1,
"xdm:sourceProperty": "/faxPhone"
}'
@type
xdm:descriptorDeprecated
。xdm:sourceSchema
$id
。xdm:sourceVersion
1
。xdm:sourceProperty
["/firstName", "/lastName"]
)。回應
{
"@id": "d882b1202bac0ac71f1e31fbcd9afbcc37f364270186b4b3",
"@type": "xdm:descriptorDeprecated",
"xdm:sourceSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/c65ddf08cf2d4a2fe94bd06113bf4bc4c855e12a936410d5",
"xdm:sourceVersion": 1,
"xdm:sourceProperty": "/faxPhone",
"imsOrg": "{IMS_ORG}",
"version": "1",
"meta:containerId": "tenant",
"meta:sandboxId": "28e74200-e3de-11e9-8f5d-7f27416c5f0d",
"meta:sandboxType": "production"
}
驗證已棄用的欄位 verify-deprecation
在套用描述項後,您可以在使用適當的Accept
標頭時查詢相關結構描述,以驗證欄位是否已過時。
API格式
GET /tenant/schemas
要求
若要在API回應中包含已棄用欄位的相關資訊,您必須將Accept
標題設定為application/vnd.adobe.xed-deprecatefield+json; version=1
。
curl -X GET \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/schemas/_{TENANT_ID}.schemas.c65ddf08cf2d4a2fe94bd06113bf4bc4c855e12a936410d5 \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {IMS_ORG}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Accept: application/vnd.adobe.xed-deprecatefield+json; version=1'
回應
成功的回應會傳回結構描述的詳細資料,已棄用的欄位包含meta:status
值deprecated
。 以下範例回應已截斷空格。
"faxPhone": {
"title": "Fax phone",
"description": "Fax phone number.",
"type": "object",
"meta:xdmType": "object",
"properties": {},
"meta:referencedFrom": "https://ns.adobe.com/xdm/context/phonenumber",
"meta:xdmField": "xdm:faxPhone",
"meta:status": "deprecated"
}
後續步驟
本檔案說明如何使用結構描述登入API來棄用XDM欄位。 如需設定自訂資源欄位的詳細資訊,請參閱在API中定義XDM欄位的指南。 如需有關管理描述元的詳細資訊,請參閱描述元端點指南。