架构字段组是可重复使用的组件,用于定义表示特定概念的一个或多个字段,例如个人、邮寄地址或Web浏览器环境。 字段组旨在作为实现兼容类的架构的一部分包含,具体取决于它们表示的数据的行为(记录或时间序列)。 此 /fieldgroups
中的端点 Schema Registry API允许您以编程方式管理体验应用程序中的字段组。
本指南中使用的端点是 Schema Registry API. 在继续之前,请查看 快速入门指南 有关相关文档的链接,请参阅本文档中的示例API调用指南,以及有关成功调用任何Experience PlatformAPI所需的所需标头的重要信息。
您可以列出所有字段组在 global
或 tenant
通过向发出GET请求来容器 /global/fieldgroups
或 /tenant/fieldgroups
,则不会显示任何内容。
在列出资源时,架构注册表将结果集限制为300个项目。 要返回超出此限制的资源,必须使用分页参数。 还建议使用其他查询参数来筛选结果并减少返回的资源数。 请参阅以下部分: 查询参数 详细信息,请参阅附录文档。
API格式
GET /{CONTAINER_ID}/fieldgroups?{QUERY_PARAMS}
参数 | 描述 |
---|---|
{CONTAINER_ID} |
要从中检索字段组的容器: global 对于Adobe创建的字段组或 tenant 对于您组织拥有的字段组。 |
{QUERY_PARAMS} |
用于筛选结果的可选查询参数。 请参阅 附录文档 以获取可用参数的列表。 |
请求
以下请求从 tenant
容器,使用 orderby
用于按字段组对字段组进行排序的查询参数 title
属性。
curl -X GET \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/fieldgroups?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}/mixins/6ece98e9842907c78c651f5b249d9f09",
"meta:altId": "_{TENANT_ID}.mixins.6ece98e9842907c78c651f5b249d9f09",
"version": "1.0",
"title": "CRM Data"
},
{
"$id": "https://ns.adobe.com/{TENANT_ID}/mixins/6386ee478a30914964c6e676ad55603c",
"meta:altId": "_{TENANT_ID}.mixins.6386ee478a30914964c6e676ad55603c",
"version": "1.9",
"title": "Loyalty Member Details"
},
{
"$id": "https://ns.adobe.com/{TENANT_ID}/mixins/67626b2830db3d3ea6c8f9d007aa5797",
"meta:altId": "_{TENANT_ID}.mixins.67626b2830db3d3ea6c8f9d007aa5797",
"version": "1.0",
"title": "Restaurant"
},
{
"$id": "https://ns.adobe.com/{TENANT_ID}/mixins/2583b25b613fec704da6ef70cf527688",
"meta:altId": "_{TENANT_ID}.mixins.2583b25b613fec704da6ef70cf527688",
"version": "1.1",
"title": "Retail Customer Preferences"
},
],
"_page": {
"orderby": "title",
"next": null,
"count": 3
},
"_links": {
"next": null,
"global_schemas": {
"href": "https://platform.adobe.io/data/foundation/schemaregistry/global/fieldgroups"
}
}
}
您可以通过在GET请求的路径中包含字段组的ID来查找特定字段组。
API格式
GET /{CONTAINER_ID}/fieldgroups/{FIELD_GROUP_ID}
参数 | 描述 |
---|---|
{CONTAINER_ID} |
存放要检索的字段组的容器: global 对于Adobe创建的字段组或 tenant 对于您组织拥有的字段组。 |
{FIELD_GROUP_ID} |
此 meta:altId 或URL编码 $id 要查找的字段组的。 |
请求
以下请求检索按其设置的字段组 meta:altId
路径中提供的值。
curl -X GET \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/fieldgroups/_{TENANT_ID}.mixins.8779fd45d6e4eb074300023a439862bbba359b60d451627a \
-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={MAJOR_VERSION} |
原始,替换为 $ref 和 allOf ,具有标题和描述。 |
application/vnd.adobe.xed-full+json; version={MAJOR_VERSION} |
$ref 和 allOf 已解决,具有标题和描述。 |
application/vnd.adobe.xed-notext+json; version={MAJOR_VERSION} |
原始,替换为 $ref 和 allOf ,无标题或描述。 |
application/vnd.adobe.xed-full-notext+json; version={MAJOR_VERSION} |
$ref 和 allOf 已解决,无标题或描述。 |
application/vnd.adobe.xed-full-desc+json; version={MAJOR_VERSION} |
$ref 和 allOf 已解决,包含描述符。 |
响应
成功响应将返回字段组的详细信息。 返回的字段取决于 Accept
标头在请求中发送。 试验不同的 Accept
标头,用于比较响应并确定哪个标头最适合您的用例。
{
"$id": "https://ns.adobe.com/{TENANT_ID}/mixins/8779fd45d6e4eb074300023a439862bbba359b60d451627a",
"meta:altId": "_{TENANT_ID}.mixins.8779fd45d6e4eb074300023a439862bbba359b60d451627a",
"meta:resourceType": "mixins",
"version": "1.2",
"title": "Favorite Hotel",
"type": "object",
"description": "",
"definitions": {
"customFields": {
"type": "object",
"properties": {
"_{TENANT_ID}": {
"type": "object",
"properties": {
"favoriteHotel": {
"title": "Favorite Hotel",
"description": "Reference field for hotel schema.",
"type": "string",
"isRequired": false,
"meta:xdmType": "string"
}
},
"meta:xdmType": "object"
}
},
"meta:xdmType": "object"
}
},
"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}"
}
您可以在下定义自定义字段组 tenant
POST的容器。
API格式
POST /tenant/fieldgroups
请求
定义新字段组时,必须包括 meta:intendedToExtend
属性,列出 $id
与字段组兼容的类的ID。 在此示例中,字段组与 Property
之前定义的类。 自定义字段必须嵌套在 _{TENANT_ID}
(如示例中所示)以避免与类和其他字段组提供的相似字段发生任何冲突。
有关如何定义要包含在字段组中的不同字段类型的详细信息,请参阅以下指南: 在API中定义自定义字段.
curl -X POST \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/fieldgroups \
-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 Details",
"description":"Detailed information related to the properties owned and operated by the company.",
"type":"object",
"meta:intendedToExtend":["https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590"],
"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"
},
"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/property"
}
]
}'
响应
成功的响应会返回HTTP状态201(已创建)以及包含新创建的字段组详情的有效负载,包括 $id
, meta:altId
、和 version
. 这些值是只读的,由 Schema Registry.
{
"$id": "https://ns.adobe.com/{TENANT_ID}/mixins/8779fd45d6e4eb074300023a439862bbba359b60d451627a",
"meta:altId": "_{TENANT_ID}.mixins.8779fd45d6e4eb074300023a439862bbba359b60d451627a",
"meta:resourceType": "mixins",
"version": "1.2",
"title": "Property Details",
"type": "object",
"description": "Detailed information related to the properties owned and 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"
},
"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}"
}
执行GET请求至 列出所有字段组 租户容器中的资产详细信息字段组,或者您可以 执行查找(GET)请求 使用URL编码 $id
URI直接查看新字段组。
您可以通过PUT操作替换整个字段组,基本上是重写资源。 通过PUT请求更新字段组时,正文必须包括以下情况下所需的所有字段: 创建新字段组 在POST请求中。
如果只想更新字段组的一部分而不是完全替换它,请参阅 更新字段组的一部分.
API格式
PUT /tenant/fieldgroups/{FIELD_GROUP_ID}
参数 | 描述 |
---|---|
{FIELD_GROUP_ID} |
此 meta:altId 或URL编码 $id 要重写的字段组的。 |
请求
以下请求重写现有字段组,添加新的 propertyCountry
字段。
curl -X PUT \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/fieldgroups/_{TENANT_ID}.mixins.8779fd45d6e4eb074300023a439862bbba359b60d451627a \
-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 Details",
"description": "Detailed information related to the properties owned and operated by the company.",
"type": "object",
"meta:intendedToExtend": ["https://ns.adobe.com/{TENANT_ID}/classes/19e1d8b5098a7a76e2c10a81cbc99590"],
"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/property"
}
]
}'
响应
成功响应将返回已更新字段组的详细信息。
{
"$id": "https://ns.adobe.com/{TENANT_ID}/mixins/8779fd45d6e4eb074300023a439862bbba359b60d451627a",
"meta:altId": "_{TENANT_ID}.mixins.8779fd45d6e4eb074300023a439862bbba359b60d451627a",
"meta:resourceType": "mixins",
"version": "1.2",
"title": "Property Details",
"type": "object",
"description": "Detailed information related to the properties owned and 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}"
}
您可以使用PATCH请求更新字段组的一部分。 此 Schema Registry 支持所有标准JSON修补程序操作,包括 add
, remove
、和 replace
. 有关JSON修补程序的详细信息,请参见 API基础知识指南.
如果要使用新值替换整个资源,而不是更新各个字段,请参阅 使用PUT操作替换字段组.
API格式
PATCH /tenant/fieldgroups/{FIELD_GROUP_ID}
参数 | 描述 |
---|---|
{FIELD_GROUP_ID} |
URL编码 $id URI或 meta:altId 要更新的字段组的。 |
请求
下面的示例请求更新了 description
字段组的,并添加新的 propertyCity
字段。
请求正文采用数组的形式,每个列出的对象表示对单个字段的特定更改。 每个对象都包含要执行的操作(op
),应该对哪个字段执行操作(path
),以及操作中应包含哪些信息(value
)。
curl -X PATCH \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/fieldgroups/_{TENANT_ID}.mixins.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": "Details relating to a property operated by the company."
},
{
"op": "add",
"path": "/definitions/property/properties/_{TENANT_ID}/properties/propertyCity",
"value": {
"title": "Property City",
"description": "City where the property is located.",
"type": "string"
}
}
]'
响应
响应显示两个操作均已成功执行。 此 description
已更新,并且 propertyCountry
已添加在 definitions
.
{
"$id": "https://ns.adobe.com/{TENANT_ID}/mixins/8779fd45d6e4eb074300023a439862bbba359b60d451627a",
"meta:altId": "_{TENANT_ID}.mixins.8779fd45d6e4eb074300023a439862bbba359b60d451627a",
"meta:resourceType": "mixins",
"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}"
}
有时可能需要从架构注册表中删除字段组。 这是通过使用路径中提供的字段组ID执行DELETE请求来完成的。
API格式
DELETE /tenant/fieldgroups/{FIELD_GROUP_ID}
参数 | 描述 |
---|---|
{FIELD_GROUP_ID} |
URL编码 $id URI或 meta:altId 要删除的字段组的。 |
请求
curl -X DELETE \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/fieldgroups/_{TENANT_ID}.mixins.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(未找到),因为字段组已从架构注册表中删除。