描述項端點
結構描述會定義資料實體的結構,但不會指定從這些結構描述建立的任何資料集如何彼此關聯。 在Adobe Experience Platform中,您可以使用描述元來說明這些關係,並將解譯性中繼資料新增到結構描述。
描述項是套用至Adobe Experience Platform中結構描述的租使用者層級中繼資料物件。 它們定義結構關係、索引鍵和行為欄位(例如時間戳記或版本設定),這些欄位會影響到下游資料的驗證、連結或解譯方式。
結構描述可以有一或多個描述項。 每個描述項都定義了@type
以及它適用的sourceSchema
。 描述項會自動套用至從該結構描述建立的所有資料集。
在Adobe Experience Platform中,描述項是將行為規則或結構含義新增到結構描述的中繼資料。
描述項有多種型別,包括:
/descriptors
API中的Schema Registry端點可讓您以程式設計方式管理體驗應用程式中的描述項。
快速入門
本指南中使用的端點是Schema Registry API的一部分。 在繼續之前,請先檢閱快速入門手冊,以取得相關檔案的連結、閱讀本檔案中範例API呼叫的手冊,以及有關成功呼叫任何Experience Platform API所需必要標題的重要資訊。
除了標準描述項之外,Schema Registry還支援模型架構的描述項型別,例如 主索引鍵、版本 和 時間戳記。 這些會強制唯一性、控制版本化,並在架構層級定義時間序列欄位。 如果您不熟悉以模型為基礎的結構描述,請先檢閱Data Mirror概觀和以模型為基礎的結構描述技術參考,然後再繼續。
擷取描述項清單 list
您可以藉由向/tenant/descriptors
發出GET要求,列出貴組織已定義的所有描述項。
API格式
GET /tenant/descriptors
要求
curl -X GET \
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: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Accept: application/vnd.adobe.xdm-link+json'
回應格式取決於請求中傳送的Accept
標頭。 請注意,/descriptors
端點使用與Accept
API中所有其他端點不同的Schema Registry標頭。
Accept
取代xed
的唯一的xdm
標頭,並提供描述項唯一的link
選項。 以下範例呼叫中已包含適當的Accept
標頭,但請特別注意,以確保在使用描述項時使用正確的標頭。Accept
標題application/vnd.adobe.xdm-id+json
application/vnd.adobe.xdm-link+json
application/vnd.adobe.xdm+json
application/vnd.adobe.xdm-v2+json
Accept
標頭必須使用分頁功能。回應
此回應包括已定義描述元的每個描述項型別的陣列。 換言之,如果沒有定義特定@type
的描述項,登入將不會傳回該描述項型別的空白陣列。
使用link
Accept
標頭時,每個描述項都會以格式/{CONTAINER}/descriptors/{DESCRIPTOR_ID}
顯示為陣列專案
{
"xdm:alternateDisplayInfo": [
"/tenant/descriptors/85dc1bc8b91516ac41163365318e38a9f1e4f351",
"/tenant/descriptors/49bd5abb5a1310ee80ebc1848eb508d383a462cf",
"/tenant/descriptors/b3b3e548f1c653326bcf5459ceac4140fc0b9e08"
],
"xdm:descriptorIdentity": [
"/tenant/descriptors/f7a4bc25429496c4740f8f9a7a49ba96862c5379"
],
"xdm:descriptorOneToOne": [
"/tenant/descriptors/cb509fd6f8ab6304e346905441a34b58a0cd481a"
]
}
查詢描述項 lookup
若要檢視特定描述項的詳細資料,請使用其@id
傳送GET要求。
API格式
GET /tenant/descriptors/{DESCRIPTOR_ID}
{DESCRIPTOR_ID}
@id
。要求
下列要求會依據其@id
值擷取描述項。 描述項未建立版本,因此查詢請求中不需要標頭Accept
。
curl -X GET \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/descriptors/f3a1dfa38a4871cf4442a33074c1f9406a593407 \
-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}'
回應
成功的回應會傳回描述項的詳細資料,包括其@type
和sourceSchema
,以及視描述項型別而異的其他資訊。 傳回的@id
應該符合要求中提供的描述項@id
。
{
"@type": "xdm:descriptorIdentity",
"xdm:sourceSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/fbc52b243d04b5d4f41eaa72a8ba58be",
"xdm:sourceVersion": 1,
"xdm:sourceProperty": "/personalEmail/address",
"xdm:namespace": "Email",
"xdm:property": "xdm:code",
"xdm:isPrimary": false,
"createdUser": "{CREATED_USER}",
"imsOrg": "{ORG_ID}",
"createdClient": "{CREATED_CLIENT}",
"updatedUser": "{UPDATED_USER}",
"created": 1548899346989,
"updated": 1548899346989,
"meta:containerId": "tenant",
"@id": "f3a1dfa38a4871cf4442a33074c1f9406a593407"
}
建立描述項 create
您可以對/tenant/descriptors
端點發出POST要求,以建立新的描述項。
API格式
POST /tenant/descriptors
要求
以下請求在範例結構描述中的「電子郵件地址」欄位上定義身分描述項。 這會告訴Experience Platform使用電子郵件地址做為識別碼,以協助彙整個人的資訊。
curl -X POST \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/descriptors \
-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 '
{
"@type": "xdm:descriptorIdentity",
"xdm:sourceSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/fbc52b243d04b5d4f41eaa72a8ba58be",
"xdm:sourceVersion": 1,
"xdm:sourceProperty": "/personalEmail/address",
"xdm:namespace": "Email",
"xdm:property": "xdm:code",
"xdm:isPrimary": false
}'
回應
成功的回應會傳回HTTP狀態201 (已建立)和新建立之描述項的詳細資料,包括其@id
。 @id
是由Schema Registry指派的唯讀欄位,用於參考API中的描述項。
{
"@type": "xdm:descriptorIdentity",
"xdm:sourceSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/fbc52b243d04b5d4f41eaa72a8ba58be",
"xdm:sourceVersion": 1,
"xdm:sourceProperty": "/personalEmail/address",
"xdm:namespace": "Email",
"xdm:property": "xdm:code",
"xdm:isPrimary": false,
"meta:containerId": "tenant",
"@id": "f3a1dfa38a4871cf4442a33074c1f9406a593407"
}
更新描述項 put
您可以在PUT要求的路徑中包含描述項的@id
以更新描述項。
API格式
PUT /tenant/descriptors/{DESCRIPTOR_ID}
{DESCRIPTOR_ID}
@id
。要求
此請求基本上會重寫描述項,因此請求內文必須包含定義該型別描述項所需的所有欄位。 換句話說,更新(PUT)描述項的要求承載與建立相同型別(POST)描述項的承載相同。
下列範例會更新身分描述項以參考其他xdm:sourceProperty
(mobile phone
),並將xdm:namespace
變更為Phone
。
curl -X PUT \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/descriptors/f3a1dfa38a4871cf4442a33074c1f9406a593407 \
-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 '{
"@type": "xdm:descriptorIdentity",
"xdm:sourceSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/fbc52b243d04b5d4f41eaa72a8ba58be",
"xdm:sourceVersion": 1,
"xdm:sourceProperty": "/mobilePhone/number",
"xdm:namespace": "Phone",
"xdm:property": "xdm:code",
"xdm:isPrimary": false
}'
回應
成功的回應會傳回HTTP狀態201 (已建立)和更新描述項的@id
(應該符合要求中傳送的@id
)。
{
"@id": "f3a1dfa38a4871cf4442a33074c1f9406a593407"
}
執行查詢(GET)要求以檢視描述項,會顯示欄位現已更新,以反映PUT要求中傳送的變更。
刪除描述項 delete
有時您可能需要從Schema Registry中移除已定義的描述項。 這可透過發出DELETE請求來完成,該請求會參考您要移除之描述項的@id
。
API格式
DELETE /tenant/descriptors/{DESCRIPTOR_ID}
{DESCRIPTOR_ID}
@id
。要求
curl -X DELETE \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/descriptors/ca921946fb5281cbdb8ba5e07087486ce531a1f2 \
-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 (無內容)和空白內文。
若要確認描述項已刪除,您可以對描述項執行查詢要求@id
。 回應傳回HTTP狀態404 (找不到),因為描述項已從Schema Registry中移除。
附錄 appendix
下節提供有關在Schema Registry API中使用描述項的其他資訊。
定義描述項 defining-descriptors
以下小節提供可用描述項型別的概觀,包括定義每種型別的描述項所需的欄位。
身分描述項 identity-descriptor
身分描述項會指出「sourceSchema」的「sourceProperty」是IdentityExperience Platform Identity Service所說明的欄位。
{
"@type": "xdm:descriptorIdentity",
"xdm:sourceSchema":
"https://ns.adobe.com/{TENANT_ID}/schemas/fbc52b243d04b5d4f41eaa72a8ba58be",
"xdm:sourceVersion": 1,
"xdm:sourceProperty": "/personalEmail/address",
"xdm:namespace": "Email",
"xdm:property": "xdm:code",
"xdm:isPrimary": false
}
@type
xdm:descriptorIdentity
。xdm:sourceSchema
$id
URI。xdm:sourceVersion
xdm:sourceProperty
xdm:namespace
xdm:property
xdm:id
而定,xdm:code
或xdm:namespace
。xdm:isPrimary
易記名稱描述項 friendly-name
好記名稱描述元可讓使用者修改核心程式庫結構描述欄位的title
、description
和meta:enum
值。 在使用「eVars」和您希望標示為包含組織特定資訊的其他「一般」欄位時,這個功能特別實用。 UI可利用這些來顯示更好記的名稱,或只顯示具有更好記名稱的欄位。
{
"@type": "xdm:alternateDisplayInfo",
"xdm:sourceSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/274f17bc5807ff307a046bab1489fb18",
"xdm:sourceVersion": 1,
"xdm:sourceProperty": "/xdm:eventType",
"xdm:title": {
"en_us": "Event Type"
},
"xdm:description": {
"en_us": "The type of experience event detected by the system."
},
"meta:enum": {
"click": "Mouse Click",
"addCart": "Add to Cart",
"checkout": "Cart Checkout"
},
"xdm:excludeMetaEnum": {
"web.formFilledOut": "Web Form Filled Out",
"media.ping": "Media ping"
}
}
@type
xdm:alternateDisplayInfo
。xdm:sourceSchema
$id
URI。xdm:sourceVersion
xdm:sourceProperty
/
)開頭,而不是以一個結尾。 不要在路徑中包含properties
(例如,使用/personalEmail/address
而非/properties/personalEmail/properties/address
)。xdm:title
xdm:description
meta:enum
xdm:sourceProperty
指示的欄位是字串欄位,則可以使用meta:enum
在分段UI中為欄位新增建議值。 請務必注意,meta:enum
不會宣告分項清單或為XDM欄位提供任何資料驗證。這僅能用於Adobe定義的核心XDM欄位。 如果來源屬性是您的組織定義的自訂欄位,您應該直接透過欄位父級資源的PATCH請求來編輯欄位的
meta:enum
屬性。meta:excludeMetaEnum
xdm:sourceProperty
所指示的欄位是字串欄位,其在meta:enum
欄位下提供了現有的建議值,您可以在易記名稱描述項中加入此物件,以從分段中排除這些值的部分或全部。 每個專案的索引鍵和值都必須與欄位原始meta:enum
中包含的專案相符,才能排除該專案。關係描述項 relationship-descriptor
關聯性描述項描述兩個不同結構描述之間的關係,以xdm:sourceProperty
和xdm:destinationProperty
中描述的屬性作為索引鍵。 如需詳細資訊,請參閱有關定義兩個結構描述之間關係的教學課程。
使用這些屬性來宣告來源欄位(外部索引鍵)與目的地欄位(主索引鍵或候選索引鍵)的關聯方式。
xdm:sourceProperty
定義),它參考另一個結構描述中的索引鍵欄位。 候選索引鍵 是目的地結構描述中唯一識別記錄的任何欄位(或欄位集),可用來取代主索引鍵。API支援兩種模式:
xdm:descriptorOneToOne
:標準1:1關聯性。xdm:descriptorRelationship
:新工作和模型型結構描述的一般模式(支援基數、命名和非主索引鍵目標)。
一對一關係(標準結構描述)
在維護已依賴xdm:descriptorOneToOne
的現有標準結構描述整合時,請使用此專案。
{
"@type": "xdm:descriptorOneToOne",
"xdm:sourceSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/{SOURCE_SCHEMA_ID}",
"xdm:sourceVersion": 1,
"xdm:sourceProperty": "/parentField/subField",
"xdm:destinationSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/{DEST_SCHEMA_ID}",
"xdm:destinationVersion": 1,
"xdm:destinationProperty": "/parentField/subField"
}
下表說明定義一對一關係描述項所需的欄位。
@type
xdm:descriptorOneToOne
。 使用B2B edition時,您可以選擇使用xdm:descriptorOneToOne
或xdm:descriptorRelationship
。xdm:sourceSchema
$id
URI。xdm:sourceVersion
xdm:sourceProperty
xdm:destinationSchema
$id
URI。xdm:destinationVersion
xdm:destinationProperty
一般關係(以模型為基礎的結構描述,以及新專案的建議使用)
請將此描述項用於所有新實作和模型型結構描述。 它可讓您定義關係的基數(例如一對一或多對一)、指定關係名稱,以及連結至非主索引鍵(非主索引鍵)的目的地欄位。
下列範例顯示如何定義一般關係描述項。
最小範例:
這個最小範例僅包含定義兩個結構描述之間多對一關係的必填欄位。
{
"@type": "xdm:descriptorRelationship",
"xdm:sourceSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/{SOURCE_SCHEMA_ID}",
"xdm:sourceProperty": "/customer_ref",
"xdm:sourceVersion": 1,
"xdm:destinationSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/{DEST_SCHEMA_ID}",
"xdm:cardinality": "M:1"
}
所有選擇性欄位的範例:
此範例包含所有選擇性欄位,例如關係名稱、顯示標題和明確的非主索引鍵目的地欄位。
{
"@type": "xdm:descriptorRelationship",
"xdm:sourceSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/{SOURCE_SCHEMA_ID}",
"xdm:sourceVersion": 1,
"xdm:sourceProperty": "/customer_ref",
"xdm:destinationSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/{DEST_SCHEMA_ID}",
"xdm:destinationProperty": "/customer_id",
"xdm:sourceToDestinationName": "CampaignToCustomer",
"xdm:destinationToSourceName": "CustomerToCampaign",
"xdm:sourceToDestinationTitle": "Customer campaigns",
"xdm:destinationToSourceTitle": "Campaign customers",
"xdm:cardinality": "M:1"
}
選擇關係描述項
使用下列准則來決定要套用的關係描述項:
xdm:descriptorRelationship
xdm:descriptorOneToOne
,除非您只需要xdm:descriptorRelationship
支援的功能。1:1
, 1:0
, M:1
, M:0
)xdm:descriptorRelationship
xdm:descriptorRelationship
xdm:descriptorRelationship
xdm:descriptorOneToOne
描述項,除非您需要非主要身分目的地目標、自訂命名或擴充基數選項等功能,否則請繼續使用它們。功能比較
下表比較兩種描述項型別的功能:
xdm:descriptorOneToOne
xdm:descriptorRelationship
xdm:destinationProperty
的非主索引鍵xdm:sourceToDestinationName
、xdm:destinationToSourceName
和標題限制和驗證
定義一般關係描述項時,請遵循下列需求和建議:
- 對於以模型為基礎的結構描述,請將來源欄位(外部索引鍵)放置在根層級。 這是目前擷取的技術限制,並非最佳實務建議。
- 確保來源和目的地欄位的資料型別相容(數值、日期、布林值、字串)。
- 請記住,基數僅供參考;儲存不會強制執行。 以
<source>:<destination>
格式指定基數。 接受的值為:1:1
、1:0
、M:1
或M:0
。
主索引鍵描述項 primary-key-descriptor
主索引鍵描述項(xdm:descriptorPrimaryKey
)在結構描述中的一或多個欄位上強制唯一性和非null限制。
{
"@type": "xdm:descriptorPrimaryKey",
"xdm:sourceSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/{SCHEMA_ID}",
"xdm:sourceProperty": ["/orderId", "/orderLineId"]
}
@type
xdm:descriptorPrimaryKey
。xdm:sourceSchema
$id
URI。xdm:sourceProperty
版本描述項 version-descriptor
版本描述項(xdm:descriptorVersion
)會指定一個欄位,以偵測並防止順序錯亂的變更事件發生衝突。
{
"@type": "xdm:descriptorVersion",
"xdm:sourceSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/{SCHEMA_ID}",
"xdm:sourceProperty": "/versionNumber"
}
@type
xdm:descriptorVersion
。xdm:sourceSchema
$id
URI。xdm:sourceProperty
required
。時間戳記描述項 timestamp-descriptor
時間戳記描述項(xdm:descriptorTimestamp
)指定日期 — 時間欄位做為具有"meta:behaviorType": "time-series"
的結構描述的時間戳記。
{
"@type": "xdm:descriptorTimestamp",
"xdm:sourceSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/{SCHEMA_ID}",
"xdm:sourceProperty": "/eventTime"
}
@type
xdm:descriptorTimestamp
。xdm:sourceSchema
$id
URI。xdm:sourceProperty
required
且型別為date-time
。B2B關係描述項 B2B-relationship-descriptor
Real-Time CDP B2B edition引進了定義結構描述之間關係的替代方式,其允許多對一關係。 此新關聯性必須具有@type: xdm:descriptorRelationship
型別,而且裝載必須包含比@type: xdm:descriptorOneToOne
關聯性更多的欄位。 如需詳細資訊,請參閱有關定義B2B edition的結構描述關係的教學課程。
{
"@type": "xdm:descriptorRelationship",
"xdm:sourceSchema" : "https://ns.adobe.com/{TENANT_ID}/schemas/9f2b2f225ac642570a110d8fd70800ac0c0573d52974fa9a",
"xdm:sourceVersion" : 1,
"xdm:sourceProperty" : "/person-ref",
"xdm:destinationSchema" : "https://ns.adobe.com/{TENANT_ID/schemas/628427680e6b09f1f5a8f63ba302ee5ce12afba8de31acd7",
"xdm:destinationVersion" : 1,
"xdm:destinationProperty": "/personId",
"xdm:destinationNamespace" : "People",
"xdm:destinationToSourceTitle" : "Opportunity Roles",
"xdm:sourceToDestinationTitle" : "People",
"xdm:cardinality": "M:1"
}
@type
xdm:descriptorRelationship
。 如需其他型別的詳細資訊,請參閱關聯性描述元區段。xdm:sourceSchema
$id
URI。xdm:sourceVersion
xdm:sourceProperty
xdm:destinationSchema
$id
URI。xdm:destinationVersion
xdm:destinationProperty
xdm:sourceProperty
。 如果省略,此關係可能無法如預期運作。xdm:destinationNamespace
xdm:destinationToSourceTitle
xdm:sourceToDestinationTitle
xdm:cardinality
M:1
,表示多對一關係。參考身分描述項
參考身分描述項提供結構描述欄位主要身分的參考內容,讓其他結構描述中的欄位可參考內容。 參考結構描述必須先定義主要身分欄位,其他結構描述才能透過此描述項參考它。
{
"@type": "xdm:descriptorReferenceIdentity",
"xdm:sourceSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/78bab6346b9c5102b60591e15e75d254",
"xdm:sourceVersion": 1,
"xdm:sourceProperty": "/parentField/subField",
"xdm:identityNamespace": "Email"
}
@type
xdm:descriptorReferenceIdentity
。xdm:sourceSchema
$id
URI。xdm:sourceVersion
xdm:sourceProperty
/personalEmail/address
而非/properties/personalEmail/properties/address
)。xdm:identityNamespace
已棄用的欄位描述項
您可以將設定為的屬性新增至有問題的欄位,以meta:status
棄用自訂XDM資源deprecated
中的欄位。 不過,如果您想要取代結構描述中標準XDM資源提供的欄位,您可以將取代的欄位描述項指派給相關結構描述,以取得相同的效果。 使用正確的Accept
標頭,您就可以在API中查詢結構描述時,檢視該結構描述已棄用的標準欄位。
{
"@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"]
)。