所有体验数据模型(XDM)架构都必须基于类。 类确定基于该类的所有架构都必须包含的通用属性的基本结构,以及哪些架构字段组有资格在这些架构中使用。 此外,架构的类还确定架构将包含的数据的行为方面,其中有两种类型:
有关数据行为类如何影响模式组成的详细信息,请参阅 架构组合基础知识.
的 /classes
的端点 Schema Registry API允许您以编程方式管理体验应用程序中的类。
本指南中使用的端点是 Schema Registry API. 在继续之前,请查看 入门指南 有关相关文档的链接,请参阅本文档中的API调用示例指南,以及有关成功调用任何Experience PlatformAPI所需标头的重要信息。
可以在 global
或 tenant
容器,方法是向 /global/classes
或 /tenant/classes
,分别为。
列出资源时,方案注册表将结果集限制为300个项目。 要返回超出此限制的资源,您必须使用分页参数。 还建议您使用其他查询参数来筛选结果并减少返回的资源数。 请参阅 查询参数 ,以了解详细信息。
API格式
GET /{CONTAINER_ID}/classes?{QUERY_PARAMS}
参数 | 描述 |
---|---|
{CONTAINER_ID} |
要从以下位置检索类的容器: global 对于Adobe创建的类或 tenant 适用于贵组织拥有的类。 |
{QUERY_PARAMS} |
用于按筛选结果的可选查询参数。 请参阅 附录文档 ,以获取可用参数列表。 |
请求
以下请求从 tenant
容器,使用 orderby
查询参数来按类的 title
属性。
curl -X GET \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/classes?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类(原始) $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}/classes/01b7b1745e8ac4ed1e8784ec91b6afa7",
"meta:altId": "_{TENANT_ID}.classes.01b7b1745e8ac4ed1e8784ec91b6afa7",
"version": "1.0",
"title": "Hotel"
},
{
"$id": "https://ns.adobe.com/{TENANT_ID}/classes/d43b86253676af50da3f671ecdd26ff9",
"meta:altId": "_{TENANT_ID}.classes.d43b86253676af50da3f671ecdd26ff9",
"version": "1.1",
"title": "Property"
},
{
"$id": "https://ns.adobe.com/{TENANT_ID}/classes/366f015dbfea802455fbc46c3b27f771",
"meta:altId": "_{TENANT_ID}.classes.366f015dbfea802455fbc46c3b27f771",
"version": "1.0",
"title": "Subscription"
}
],
"_page": {
"orderby": "title",
"next": null,
"count": 3
},
"_links": {
"next": null,
"global_schemas": {
"href": "https://platform.adobe.io/data/foundation/schemaregistry/global/classes"
}
}
}
您可以通过在GET请求的路径中包含类的ID来查找特定类。
API格式
GET /{CONTAINER_ID}/classes/{CLASS_ID}
参数 | 描述 |
---|---|
{CONTAINER_ID} |
存放要检索的类的容器: global 对于Adobe创建的类或 tenant 您组织拥有的类。 |
{CLASS_ID} |
的 meta:altId 或URL编码 $id 你想查的那门课。 |
请求
以下请求通过 meta:altId
值。
curl -X GET \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/classes/_{TENANT_ID}.classes.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 已解析,包含描述符。 |
响应
成功的响应会返回类的详细信息。 返回的字段取决于 Accept
请求中发送的标头。 试验 Accept
标头来比较响应并确定最适合您的用例的标头。
{
"$id":"https://ns.adobe.com/{TENANT_ID}/classes/f8bbdc3c49d49eae62d1c17e867230ac3de6b5b63b0615ce",
"meta:altId":"_{TENANT_ID}.classes.f8bbdc3c49d49eae62d1c17e867230ac3de6b5b63b0615ce",
"meta:resourceType":"classes",
"version":"1.1",
"title":"Hotel",
"type":"object",
"description":"Base class for the Hotels schema",
"definitions":{
"customFields":{
"type":"object",
"properties":{
"_{TENANT_ID}":{
"type":"object",
"properties":{
"Address":{
"title":"Address",
"description":"",
"isRequired":false,
"$ref":"https://ns.adobe.com/xdm/common/address",
"type":"object",
"meta:xdmType":"object"
},
"phoneNumber":{
"title":"Phone Number",
"description":"",
"isRequired":false,
"$ref":"https://ns.adobe.com/xdm/context/phonenumber",
"type":"object",
"meta:xdmType":"object"
},
"brand":{
"title":"Brand",
"description":"",
"type":"string",
"isRequired":false,
"meta:xdmType":"string"
},
"hotelId":{
"title":"Hotel ID",
"description":"",
"type":"string",
"isRequired":false,
"meta:xdmType":"string"
}
},
"meta:xdmType":"object"
}
},
"meta:xdmType":"object"
}
},
"allOf":[
{
"$ref":"https://ns.adobe.com/xdm/data/record",
"type":"object",
"meta:xdmType":"object"
},
{
"$ref":"#/definitions/customFields",
"type":"object",
"meta:xdmType":"object"
}
],
"imsOrg":"{ORG_ID}",
"meta:extensible":true,
"meta:abstract":true,
"meta:extends":[
"https://ns.adobe.com/xdm/data/record"
],
"meta:xdmType":"object",
"meta:registryMetadata":{
"repo:createdDate":1593643258779,
"repo:lastModifiedDate":1597246362579,
"xdm:createdClientId":"{CLIENT_ID}",
"xdm:lastModifiedClientId":"{CLIENT_ID}",
"xdm:createdUserId":"{USER_ID}",
"xdm:lastModifiedUserId":"{USER_ID}",
"eTag":"502f89ee16b8ab2e6b4ea09ecf0ab1e5614907db755051c1f3c65a273001d725",
"meta:globalLibVersion":"1.15.4"
},
"meta:containerId":"tenant",
"meta:tenantNamespace":"_{TENANT_ID}"
}
您可以在 tenant
容器,方法是发出POST请求。
在基于您定义的自定义类合成架构时,您将无法使用标准字段组。 每个字段组定义它们在 meta:intendedToExtend
属性。 开始定义与新类兼容的字段组后(使用 $id
你新班的 meta:intendedToExtend
字段),则每次定义用于实现所定义类的架构时,都可以重用这些字段组。 请参阅 创建字段组 和 创建模式 ,以了解更多信息。
如果您计划在实时客户资料中使用基于自定义类的架构,则还请记住,合并架构仅基于共享同一类的架构来构建。 如果要在并集中包含其他类(如 XDM个人配置文件 或 XDM ExperienceEvent,则必须与使用该类的其他架构建立关系。 请参阅 在API中两个架构之间建立关系 以了解更多信息。
API格式
POST /tenant/classes
请求
创建(POST)类的请求必须包括 allOf
包含属性 $ref
值之一: https://ns.adobe.com/xdm/data/record
或 https://ns.adobe.com/xdm/data/time-series
. 这些值表示类所基于的行为(分别为记录或时间序列)。 有关记录数据与时间序列数据之间差异的更多信息,请参阅 架构组合基础知识.
在定义类时,还可以在类定义中包含字段组或自定义字段。 这会导致添加的字段组和字段包含在实现类的所有架构中。 以下示例请求定义了一个名为“Property”的类,该类可捕获有关公司拥有和运营的不同属性的信息。 它包括 propertyId
字段。
curl -X POST \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/classes \
-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",
"description":"Properties owned and operated by the company.",
"type":"object",
"definitions": {
"property": {
"properties": {
"_{TENANT_ID}": {
"type": "object",
"properties": {
"property": {
"title": "Property Information",
"type": "object",
"description": "Information about different owned and operated properties.",
"properties": {
"propertyId": {
"title": "Property Identification Number",
"type": "string",
"description": "Unique Property identification number"
}
}
}
}
}
},
"type": "object"
}
},
"allOf": [
{
"$ref": "https://ns.adobe.com/xdm/data/record"
},
{
"$ref": "#/definitions/property"
}
]
}'
属性 | 描述 |
---|---|
_{TENANT_ID} |
的 TENANT_ID 命名空间。 贵组织创建的所有资源都必须包含此属性,以避免与 Schema Registry. |
allOf |
要由新类继承其属性的资源列表。 其中一个 $ref 数组中的对象定义类的行为。 在本例中,类会继承“record”行为。 |
响应
成功响应会返回HTTP状态201(已创建)和包含新创建类详细信息(包括 $id
, meta:altId
和 version
. 这三个值是只读的,由 Schema Registry.
{
"title": "Property",
"description": "Properties owned and operated by the company.",
"type": "object",
"definitions": {
"property": {
"properties": {
"_{TENANT_ID}": {
"type": "object",
"properties": {
"property": {
"title": "Property Information",
"type": "object",
"description": "Information about different owned and operated properties.",
"properties": {
"propertyId": {
"title": "Property Identification Number",
"type": "string",
"description": "Unique Property identification number",
"meta:xdmType": "string"
}
},
"meta:xdmType": "object"
}
},
"meta:xdmType": "object"
}
},
"type": "object",
"meta:xdmType": "object"
}
},
"allOf": [
{
"$ref": "https://ns.adobe.com/xdm/data/record"
},
{
"$ref": "#/definitions/property"
}
],
"meta:abstract": true,
"meta:extensible": true,
"meta:extends": [
"https://ns.adobe.com/xdm/data/record"
],
"meta:containerId": "tenant",
"imsOrg": "{ORG_ID}",
"meta:altId": "_{TENANT_ID}.classes.19e1d8b5098a7a76e2c10a81cbc99590",
"meta:xdmType": "object",
"$id": "https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590",
"version": "1.0",
"meta:resourceType": "classes",
"meta:registryMetadata": {
"repo:createDate": 1552086405448,
"repo:lastModifiedDate": 1552086405448,
"xdm:createdClientId": "{CREATED_CLIENT}",
"xdm:repositoryCreatedBy": "{CREATED_BY}"
}
}
执行GET请求 列出所有类 在 tenant
容器现在将包含Property类。 您还可以 执行查找(GET)请求 使用URL编码 $id
以直接查看新类。
您可以通过PUT操作替换整个类,实质上重写资源。 通过PUT请求更新类时,主体必须包含在 创建新类 POST请求中。
如果只想更新类的一部分而不想完全替换它,请参阅 更新类的一部分.
API格式
PUT /tenant/classes/{CLASS_ID}
参数 | 描述 |
---|---|
{CLASS_ID} |
的 meta:altId 或URL编码 $id 你想重写的那门课。 |
请求
以下请求会重写现有类,并更改其 description
和 title
其中一个领域。
curl -X PUT \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/classes/_{TENANT_ID}.classes.19e1d8b5098a7a76e2c10a81cbc99590 \
-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",
"description": "Base class for properties operated by a company.",
"type": "object",
"definitions": {
"property": {
"properties": {
"_{TENANT_ID}": {
"type": "object",
"properties": {
"property": {
"title": "Property Information",
"type": "object",
"description": "Information about different owned and operated properties.",
"properties": {
"propertyId": {
"title": "Property ID",
"type": "string",
"description": "Unique Property ID string."
}
}
}
}
}
},
"type": "object"
}
},
"allOf": [
{
"$ref": "https://ns.adobe.com/xdm/data/record"
},
{
"$ref": "#/definitions/property"
}
]
}'
响应
成功的响应会返回更新类的详细信息。
{
"title": "Property",
"description": "Base class for properties operated by a company.",
"type": "object",
"definitions": {
"property": {
"properties": {
"_{TENANT_ID}": {
"type": "object",
"properties": {
"property": {
"title": "Property Information",
"type": "object",
"description": "Information about different owned and operated properties.",
"properties": {
"propertyId": {
"title": "Property ID",
"type": "string",
"description": "Unique Property ID string",
"meta:xdmType": "string"
}
},
"meta:xdmType": "object"
}
},
"meta:xdmType": "object"
}
},
"type": "object",
"meta:xdmType": "object"
}
},
"allOf": [
{
"$ref": "https://ns.adobe.com/xdm/data/record"
},
{
"$ref": "#/definitions/property"
}
],
"meta:abstract": true,
"meta:extensible": true,
"meta:extends": [
"https://ns.adobe.com/xdm/data/record"
],
"meta:containerId": "tenant",
"imsOrg": "{ORG_ID}",
"meta:altId": "_{TENANT_ID}.classes.19e1d8b5098a7a76e2c10a81cbc99590",
"meta:xdmType": "object",
"$id": "https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590",
"version": "1.0",
"meta:resourceType": "classes",
"meta:registryMetadata": {
"repo:createDate": 1552086405448,
"repo:lastModifiedDate": 1552086405448,
"xdm:createdClientId": "{CREATED_CLIENT}",
"xdm:repositoryCreatedBy": "{CREATED_BY}"
}
}
您可以使用PATCH请求更新类的一部分。 的 Schema Registry 支持所有标准JSON修补程序操作,包括 add
, remove
和 replace
. 有关JSON修补程序的更多信息,请参阅 API基础知识指南.
如果要使用新值而不是更新单个字段替换整个资源,请参阅 使用PUT操作替换类.
API格式
PATCH /tenant/class/{CLASS_ID}
参数 | 描述 |
---|---|
{CLASS_ID} |
URL编码 $id URI或 meta:altId 要更新的类。 |
请求
以下示例请求更新了 description
现有课程, title
其中一个领域。
请求正文采用数组的形式,每个列出的对象都表示对单个字段的特定更改。 每个对象都包括要执行的操作(op
),应对(path
),以及该操作中应包含哪些信息(value
)。
curl -X PATCH \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/classes/_{TENANT_ID}.classes.19e1d8b5098a7a76e2c10a81cbc99590 \
-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": "Base class for properties operated by a company."},
{ "op": "replace", "path": "/definitions/property/properties/_{TENANT_ID}/properties/property/properties/propertyId/title", "value": "Unique Property ID string" }
]'
响应
响应显示两个操作均已成功执行。 的 description
已更新,以及 title
的 propertyId
字段。
{
"title": "Property",
"description": "Base class for properties operated by a company.",
"type": "object",
"definitions": {
"property": {
"properties": {
"_{TENANT_ID}": {
"type": "object",
"properties": {
"property": {
"title": "Property Information",
"type": "object",
"description": "Information about different owned and operated properties.",
"properties": {
"propertyId": {
"title": "Property ID",
"type": "string",
"description": "Unique Property ID string",
"meta:xdmType": "string"
}
},
"meta:xdmType": "object"
}
},
"meta:xdmType": "object"
}
},
"type": "object",
"meta:xdmType": "object"
}
},
"allOf": [
{
"$ref": "https://ns.adobe.com/xdm/data/record"
},
{
"$ref": "#/definitions/property"
}
],
"meta:abstract": true,
"meta:extensible": true,
"meta:extends": [
"https://ns.adobe.com/xdm/data/record"
],
"meta:containerId": "tenant",
"imsOrg": "{ORG_ID}",
"meta:altId": "_{TENANT_ID}.classes.19e1d8b5098a7a76e2c10a81cbc99590",
"meta:xdmType": "object",
"$id": "https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590",
"version": "1.0",
"meta:resourceType": "classes",
"meta:registryMetadata": {
"repo:createDate": 1552086405448,
"repo:lastModifiedDate": 1552086405448,
"xdm:createdClientId": "{CREATED_CLIENT}",
"xdm:repositoryCreatedBy": "{CREATED_BY}"
}
}
有时可能需要从架构注册表中删除类。 这是通过使用路径中提供的类ID执行DELETE请求来完成的。
API格式
DELETE /tenant/classes/{CLASS_ID}
参数 | 描述 |
---|---|
{CLASS_ID} |
URL编码 $id URI或 meta:altId 的子类。 |
请求
curl -X DELETE \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/classes/_{TENANT_ID}.classes.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(未找到),因为类已从架构注册表中删除。