結構描述端點
結構描述可視為您要擷取至Adobe Experience Platform的資料的藍圖。 每個結構描述都由一個類別和零個或多個結構描述欄位群組組成。 /schemas API中的Schema Registry端點可讓您以程式設計方式管理體驗應用程式中的結構描述。
快速入門
本指南中使用的API端點是Schema Registry API的一部分。 在繼續之前,請先檢閱快速入門手冊,以取得相關檔案的連結、閱讀本檔案中範例API呼叫的手冊,以及有關成功呼叫任何Experience Platform API所需必要標題的重要資訊。
擷取結構描述清單 list
您可以分別向global或tenant發出GET要求,列出/global/schemas或/tenant/schemas容器下的所有結構描述。
API格式
GET /{CONTAINER_ID}/schemas?{QUERY_PARAMS}
{CONTAINER_ID}global用於Adobe建立的結構描述,或tenant用於您組織擁有的結構描述。{QUERY_PARAMS}要求
下列要求會使用tenant查詢引數,依結果的orderby屬性排序結果,從title容器擷取結構描述清單。
curl -X GET \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/schemas?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。 (上限: 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}/schemas/0238be93d3e7a06aec5e0655955901ec",
"meta:altId": "_{TENANT_ID}.schemas.0238be93d3e7a06aec5e0655955901ec",
"version": "1.4",
"title": "Hotels"
},
{
"$id": "https://ns.adobe.com/{TENANT_ID}/schemas/0ef4ce0d390f0809fad490802f53d30b",
"meta:altId": "_{TENANT_ID}.schemas.0ef4ce0d390f0809fad490802f53d30b",
"version": "1.0",
"title": "Loyalty Members"
}
],
"_page": {
"orderby": "title",
"next": null,
"count": 2
},
"_links": {
"next": null,
"global_schemas": {
"href": "https://platform.adobe.io/data/foundation/schemaregistry/global/schemas"
}
}
}
查詢結構描述 lookup
您可以發出GET請求,在路徑中包含結構描述的ID,藉此查詢特定的結構描述。
API格式
GET /{CONTAINER_ID}/schemas/{SCHEMA_ID}
{CONTAINER_ID}global用於Adobe建立的結構描述,或tenant用於您組織擁有的結構描述。{SCHEMA_ID}meta:altId或URL編碼的$id。要求
下列要求會擷取由路徑中meta:altId值所指定的結構描述。
curl -X GET \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/schemas/_{TENANT_ID}.schemas.f579a0b5f992c69458ea408ec36571f7da9de15901bab116 \
-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,包含描述元。application/vnd.adobe.xed-deprecatefield+json; version=1$ref和allOf已解決,有標題和說明。 已棄用的欄位以meta:status的deprecated屬性表示。回應
成功的回應會傳回結構的詳細資料。 傳回的欄位取決於請求中傳送的Accept標頭。 嘗試使用不同的Accept標頭來比較回應,並決定哪個標頭最適合您的使用案例。
{
"$id": "https://ns.adobe.com/{TENANT_ID}/schemas/20af3f1d4b175f27ba59529d1b51a0c79fc25df454117c80",
"meta:altId": "_{TENANT_ID}.schemas.20af3f1d4b175f27ba59529d1b51a0c79fc25df454117c80",
"meta:resourceType": "schemas",
"version": "1.1",
"title": "Example schema",
"type": "object",
"description": "An example schema created within the tenant container.",
"allOf": [
{
"$ref": "https://ns.adobe.com/xdm/context/profile",
"type": "object",
"meta:xdmType": "object"
},
{
"$ref": "https://ns.adobe.com/{TENANT_ID}/mixins/443fe51457047d958f4a97853e64e0eca93ef34d7990583b",
"type": "object",
"meta:xdmType": "object"
}
],
"imsOrg": "{ORG_ID}",
"meta:extensible": false,
"meta:abstract": false,
"meta:extends": [
"https://ns.adobe.com/{TENANT_ID}/mixins/443fe51457047d958f4a97853e64e0eca93ef34d7990583b",
"https://ns.adobe.com/xdm/common/auditable",
"https://ns.adobe.com/xdm/data/record",
"https://ns.adobe.com/xdm/context/profile"
],
"meta:xdmType": "object",
"meta:registryMetadata": {
"repo:createdDate": 1602872911226,
"repo:lastModifiedDate": 1603381419889,
"xdm:createdClientId": "{CLIENT_ID}",
"xdm:lastModifiedClientId": "{CLIENT_ID}",
"xdm:createdUserId": "{USER_ID}",
"xdm:lastModifiedUserId": "{USER_ID}",
"eTag": "84b4da79b7445a4bf1c59269e718065effddb983c492f48e223d49c049c6d589",
"meta:globalLibVersion": "1.15.4"
},
"meta:class": "https://ns.adobe.com/xdm/context/profile",
"meta:containerId": "tenant",
"meta:sandboxId": "ff0f6870-c46d-11e9-8ca3-036939a64204",
"meta:sandboxType": "production",
"meta:tenantNamespace": "_{TENANT_ID}"
}
建立結構描述 create
架構構成程式從指派類別開始。 類別會定義資料的主要行為方面(記錄或時間序列),以及描述將擷取之資料所需的最少欄位。
如需有關建立不含類別或欄位群組的結構描述(稱為關聯式結構描述)的指示,請參閱建立關聯式結構描述區段。
API格式
POST /tenant/schemas
要求
要求必須包含參考類別allOf的$id屬性。 此屬性會定義結構描述將實作的「基底類別」。 在此範例中,基底類別是先前建立的「屬性資訊」類別。
curl -X POST \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/schemas \
-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 Information",
"description": "Property-related information.",
"type": "object",
"allOf": [
{
"$ref": "https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590"
}
]
}'
allOf$ref),其值代表新結構描述將實作的類別或欄位群組的$id。 必須提供一個類別,具有零個或多個額外的欄位群組。 在上述範例中,allOf陣列中的單一物件是結構描述的類別。回應
成功的回應會傳回HTTP狀態201 (已建立)以及包含新建立之結構描述詳細資料的承載,包括$id、meta:altId和version。 這些值是唯讀的,並由Schema Registry指派。
{
"title": "Property Information",
"description": "Property-related information.",
"type": "object",
"allOf": [
{
"$ref": "https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590"
}
],
"meta:class": "https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590",
"meta:abstract": false,
"meta:extensible": false,
"meta:extends": [
"https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590",
"https://ns.adobe.com/xdm/data/record"
],
"meta:containerId": "tenant",
"imsOrg": "{ORG_ID}",
"meta:altId": "_{TENANT_ID}.schemas.d5cc04eb8d50190001287e4c869ebe67",
"meta:xdmType": "object",
"$id": "https://ns.adobe.com/{TENANT_ID}/schemas/d5cc04eb8d50190001287e4c869ebe67",
"version": "1.0",
"meta:resourceType": "schemas",
"meta:registryMetadata": {
"repo:createDate": 1552088461236,
"repo:lastModifiedDate": 1552088461236,
"xdm:createdClientId": "{CREATED_CLIENT}",
"xdm:repositoryCreatedBy": "{CREATED_BY}"
}
}
執行GET要求以列出租使用者容器中的所有結構描述現在將包含新的結構描述。 您可以使用URL編碼的 URI執行查詢(GET)要求$id,以直接檢視新的結構描述。
若要將其他欄位新增至結構描述,您可以執行PATCH作業,將欄位群組新增至結構描述的allOf和meta:extends陣列。
建立關聯式結構描述 create-relational-schema
對/schemas端點發出POST要求,以建立關聯式結構描述。 關聯式結構描述儲存結構化的關聯式樣式資料 ,但不含 類別或欄位群組。 直接在結構描述上定義欄位,並使用邏輯行為標籤將結構描述識別為關聯式。
meta:extends設定為"https://ns.adobe.com/xdm/data/adhoc-v2"。 這是邏輯行為識別碼 (不是實體行為或類別)。 在 中 不allOf參考類別或欄位群組,並且 不 在meta:extends中包含類別或欄位群組。請先使用POST /tenant/schemas建立結構描述。 然後使用描述項API (POST /tenant/descriptors)新增必要的描述項:
union標籤套用至meta:immutableTags。 UI已封鎖此設定,但API目前並未封鎖此設定。 如需聯合結構描述行為的詳細資訊,請參閱聯合端點指南。API格式
POST /tenant/schemas
要求
curl --request POST \
--url https://platform.adobe.io/data/foundation/schemaregistry/tenant/schemas \
-H 'Accept: application/vnd.adobe.xed+json' \
-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": "marketing.customers",
"type": "object",
"description": "Schema of the Marketing Customers table.",
"definitions": {
"customFields": {
"type": "object",
"properties": {
"customer_id": {
"title": "Customer ID",
"description": "Primary key of the customer table.",
"type": "string",
"minLength": 1
},
"name": {
"title": "Name",
"description": "Name of the customer.",
"type": "string"
},
"email": {
"title": "Email",
"description": "Email of the customer.",
"type": "string",
"format": "email",
"minLength": 1
}
},
"required": ["customer_id"]
}
},
"allOf": [
{
"$ref": "#/definitions/customFields",
"meta:xdmType": "object"
}
],
"meta:extends": ["https://ns.adobe.com/xdm/data/adhoc-v2"],
"meta:behaviorType": "record"
}
'
要求內文屬性
titledescriptiontype"object"。definitionsdefinitions.<name>.propertiesallOf#/definitions/marketing_customers)。meta:extends"https://ns.adobe.com/xdm/data/adhoc-v2",才能將結構描述識別為關聯式。meta:behaviorType"record"。 只有在啟用且適當的情況下才使用"time-series"。回應
成功的要求傳回 HTTP 201 (已建立) 和已建立的結構描述。
範例回應
{
"$id": "https://ns.adobe.com/<TENANT_ID>/schemas/<SCHEMA_UUID>",
"meta:altId": "_<SCHEMA_ALT_ID>",
"meta:resourceType": "schemas",
"version": "1.0",
"title": "marketing.customers",
"description": "Schema of the Marketing Customers table.",
"type": "object",
"definitions": {
"marketing_customers": {
"type": "object",
"properties": {
"customer_id": {
"title": "Customer ID",
"description": "Primary key of the customer table.",
"type": "string",
"minLength": 1
},
"name": {
"title": "Name",
"description": "Name of the customer.",
"type": "string"
},
"email": {
"title": "Email",
"description": "Email of the customer.",
"type": "string",
"format": "email",
"minLength": 1
}
},
"required": ["customer_id"]
}
},
"allOf": [
{ "$ref": "#/definitions/marketing_customers" }
],
"meta:extends": ["https://ns.adobe.com/xdm/data/adhoc-v2"],
"meta:behaviorType": "record",
"meta:containerId": "tenant"
}
回應內文屬性
$idmeta:altIdmeta:resourceType"schemas")。versiontitledescriptiontypedefinitionsallOf陣列中參考以定義結構描述根。allOf#/definitions/marketing_customers)來指定結構描述的根物件。meta:extendsadhoc-v2)。meta:behaviorTyperecord或time-series,啟用時)。meta:containerIdtenant)。若要在關聯式結構描述建立後新增欄位,請發出PATCH要求。 關聯式結構描述不會繼承或自動演化。 只有在未將資料擷取到資料集時,才允許重新命名或刪除欄位等結構變更。 一旦資料存在,則僅支援加總變更 (例如新增欄位)。
您可以新增根級欄位(在根定義或根properties內),但無法移除、重新命名或變更現有欄位的型別。
更新結構 put
您可以透過PUT作業取代整個結構描述,基本上就是重新寫入資源。 透過PUT要求更新結構描述時,本文必須包含在POST要求中建立新結構描述時所需的所有欄位。
API格式
PUT /tenant/schemas/{SCHEMA_ID}
{SCHEMA_ID}meta:altId或URL編碼的$id。要求
下列要求會取代現有結構描述,變更其title、description和allOf屬性。
curl -X PUT \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/schemas/_{TENANT_ID}.schemas.d5cc04eb8d50190001287e4c869ebe67 \
-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":"Commercial Property Information",
"description": "Information related to commercial properties.",
"type": "object",
"allOf": [
{
"$ref": "https://ns.adobe.com/{TENANT_ID}/classes/01b7b1745e8ac4ed1e8784ec91b6afa7"
}
]
}'
回應
成功的回應會傳回已更新結構的詳細資料。
{
"title":"Commercial Property Information",
"description": "Information related to commercial properties.",
"type": "object",
"allOf": [
{
"$ref": "https://ns.adobe.com/{TENANT_ID}/classes/01b7b1745e8ac4ed1e8784ec91b6afa7"
}
],
"meta:class": "https://ns.adobe.com/{TENANT_ID}/classes/01b7b1745e8ac4ed1e8784ec91b6afa7",
"meta:abstract": false,
"meta:extensible": false,
"meta:extends": [
"https://ns.adobe.com/{TENANT_ID}/classes/01b7b1745e8ac4ed1e8784ec91b6afa7",
"https://ns.adobe.com/xdm/data/record"
],
"meta:containerId": "tenant",
"imsOrg": "{ORG_ID}",
"meta:altId": "_{TENANT_ID}.schemas.d5cc04eb8d50190001287e4c869ebe67",
"meta:xdmType": "object",
"$id": "https://ns.adobe.com/{TENANT_ID}/schemas/d5cc04eb8d50190001287e4c869ebe67",
"version": "1.0",
"meta:resourceType": "schemas",
"meta:registryMetadata": {
"repo:createDate": 1552088461236,
"repo:lastModifiedDate": 1552088470592,
"xdm:createdClientId": "{CREATED_CLIENT}",
"xdm:repositoryCreatedBy": "{CREATED_BY}"
}
}
更新結構描述的一部分 patch
您可以使用PATCH請求更新結構描述的一部分。 Schema Registry支援所有標準JSON修補程式操作,包括add、remove和replace。 如需JSON修補程式的詳細資訊,請參閱API基礎指南。
PATCH最常見的操作之一,是將先前定義的欄位群組新增到結構描述,如下列範例所示。
API格式
PATCH /tenant/schemas/{SCHEMA_ID}
{SCHEMA_ID}$id URI或您要更新的結構描述meta:altId。要求
下列範例要求將新欄位群組新增至結構描述,方法是將該欄位群組的$id值新增至meta:extends和allOf陣列。
請求內文採用陣列形式,每個列出的物件代表個別欄位的特定變更。 每個物件都包含要執行的作業(op)、應在哪個欄位上執行該作業(path),以及該作業中應包含哪些資訊(value)。
curl -X PATCH\
https://platform.adobe.io/data/foundation/schemaregistry/tenant/schemas/_{TENANT_ID}.schemas.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}' \
-H 'content-type: application/json' \
-d '[
{
"op": "add",
"path": "/meta:extends/-",
"value": "https://ns.adobe.com/{TENANT_ID}/mixins/e49cbb2eec33618f686b8344b4597ecf"
},
{
"op": "add",
"path": "/allOf/-",
"value": {
"$ref": "https://ns.adobe.com/{TENANT_ID}/mixins/e49cbb2eec33618f686b8344b4597ecf"
}
}
]'
回應
回應顯示兩個作業都已成功執行。 欄位群組$id已新增至meta:extends陣列,而且欄位群組$ref的參考($id)現在出現在allOf陣列中。
{
"title": "Property Information",
"description": "Property-related information.",
"type": "object",
"allOf": [
{
"$ref": "https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590"
},
{
"$ref": "https://ns.adobe.com/{TENANT_ID}/mixins/e49cbb2eec33618f686b8344b4597ecf"
}
],
"meta:class": "https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590",
"meta:abstract": false,
"meta:extensible": false,
"meta:extends": [
"https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590",
"https://ns.adobe.com/xdm/data/record",
"https://ns.adobe.com/{TENANT_ID}/mixins/e49cbb2eec33618f686b8344b4597ecf"
],
"meta:containerId": "tenant",
"imsOrg": "{ORG_ID}",
"meta:altId": "_{TENANT_ID}.schemas.d5cc04eb8d50190001287e4c869ebe67",
"meta:xdmType": "object",
"$id": "https://ns.adobe.com/{TENANT_ID}/schemas/d5cc04eb8d50190001287e4c869ebe67",
"version": "1.1",
"meta:resourceType": "schemas",
"meta:registryMetadata": {
"repo:createDate": 1552088461236,
"repo:lastModifiedDate": 1552088649634,
"xdm:createdClientId": "{CREATED_CLIENT}",
"xdm:repositoryCreatedBy": "{CREATED_BY}"
}
}
啟用結構以用於Real-Time Customer Profile union
為了讓結構描述參與即時客戶設定檔,您必須將union標籤新增至結構描述的meta:immutableTags陣列。 您可以向相關結構描述發出PATCH要求來達到此目的。
API格式
PATCH /tenant/schemas/{SCHEMA_ID}
{SCHEMA_ID}$id URI或您要啟用之結構描述的meta:altId。要求
下列範例要求將meta:immutableTags陣列新增至現有結構描述,給予該陣列單一字串值union以啟用它以用於設定檔中。
curl -X PATCH\
https://platform.adobe.io/data/foundation/schemaregistry/tenant/schemas/_{TENANT_ID}.schemas.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}' \
-H 'content-type: application/json' \
-d '[
{
"op": "add",
"path": "/meta:immutableTags",
"value": ["union"]
}
]'
回應
成功的回應會傳回已更新結構描述的詳細資料,顯示meta:immutableTags陣列已新增。
{
"title": "Property Information",
"description": "Property-related information.",
"type": "object",
"allOf": [
{
"$ref": "https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590"
},
{
"$ref": "https://ns.adobe.com/{TENANT_ID}/mixins/e49cbb2eec33618f686b8344b4597ecf"
}
],
"meta:class": "https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590",
"meta:abstract": false,
"meta:extensible": false,
"meta:extends": [
"https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590",
"https://ns.adobe.com/xdm/data/record",
"https://ns.adobe.com/{TENANT_ID}/mixins/e49cbb2eec33618f686b8344b4597ecf"
],
"meta:containerId": "tenant",
"imsOrg": "{ORG_ID}",
"meta:altId": "_{TENANT_ID}.schemas.d5cc04eb8d50190001287e4c869ebe67",
"meta:xdmType": "object",
"$id": "https://ns.adobe.com/{TENANT_ID}/schemas/d5cc04eb8d50190001287e4c869ebe67",
"version": "1.1",
"meta:resourceType": "schemas",
"meta:registryMetadata": {
"repo:createDate": 1552088461236,
"repo:lastModifiedDate": 1552088649634,
"xdm:createdClientId": "{CREATED_CLIENT}",
"xdm:repositoryCreatedBy": "{CREATED_BY}"
},
"meta:immutableTags": [
"union"
]
}
您現在可以檢視此結構描述類別的聯合,以確認表示結構描述的欄位。 如需詳細資訊,請參閱聯合端點指南。
刪除結構描述 delete
有時可能需要從結構描述登入中移除結構描述。 若要這麼做,請使用路徑中提供的結構ID執行DELETE要求。
API格式
DELETE /tenant/schemas/{SCHEMA_ID}
{SCHEMA_ID}$id URI或您要刪除的結構描述meta:altId。要求
curl -X DELETE \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/schemas/_{TENANT_ID}.schemas.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 (找不到),因為結構描述已從結構描述登入中移除。