计算属性功能当前位于Alpha中,并非所有用户都可用。 文档和功能可能会发生变化。
要配置计算属性,您首先需要标识将包含计算属性值的字段。 可以使用架构注册表API创建此字段,以定义架构和将保存计算属性字段的自定义架构字段组。 建议最好创建一个单独的“计算属性”架构和字段组,贵组织可以在其中添加任何用作计算属性的属性。 这样,您的组织就可以将计算的属性架构与用于数据摄取的其他架构完全分离。
本文档中的工作流概述了如何使用架构注册表API创建引用自定义字段组的启用配置文件的“计算属性”架构。 本文档包含特定于计算属性的示例代码,但请参阅 架构注册API指南 有关使用API定义字段组和架构的详细信息。
要使用架构注册表API创建字段组,请首先向 /tenant/fieldgroups
端点和提供请求正文中字段组的详细信息。 有关使用架构注册表API与字段组合作的详细信息,请参阅 字段组API端点指南.
API格式
POST /tenant/fieldgroups
请求
curl -X POST \
https://platform.adobe.io/data/foundation/schemaregistry/tenant/fieldgroups\
-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 '{
"title":"Computed Attributes Field Group",
"description":"Description of the field group.",
"type":"object",
"meta:extensible": true,
"meta:abstract": true,
"meta:intendedToExtend": [
"https://ns.adobe.com/xdm/context/profile"
],
"definitions": {
"computedAttributesFieldGroup": {
"type": "object",
"meta:xdmType": "object",
"properties": {
"_{TENANT_ID}": {
"type": "object",
"meta:xdmType": "object",
"properties": {
"birthdayCurrentMonth": {
"type": "boolean",
"meta:xdmType": "boolean"
}
}
}
}
}
},
"allOf": [
{
"$ref": "#/definitions/computedAttributesFieldGroup"
}
]
}'
属性 | 描述 |
---|---|
title |
要创建的字段组的名称。 |
meta:intendedToExtend |
可使用字段组的XDM类。 |
响应
成功的请求会返回HTTP响应状态201(已创建),其中包含新创建字段组的详细信息(包括 $id
, meta:altIt
和 version
. 这些值是只读的,由架构注册表分配。
{
"$id": "https://ns.adobe.com/{TENANT_ID}/mixins/860ad1b1b35e0a88ecf6df92ebce08335c180313d5805352",
"meta:altId": "_{TENANT_ID}.mixins.860ad1b1b35e0a88ecf6df92ebce08335c180313d5805352",
"meta:resourceType": "mixins",
"version": "1.0",
"title": "Computed Attributes Field Group",
"type": "object",
"description": "Description of the field group.",
"definitions": {
"computedAttributesFieldGroup": {
"type": "object",
"meta:xdmType": "object",
"properties": {
"_{TENANT_ID}": {
"type": "object",
"meta:xdmType": "object",
"properties": {
"birthdayCurrentMonth": {
"type": "boolean",
"meta:xdmType": "boolean"
}
}
}
}
}
},
"allOf": [
{
"$ref": "#/definitions/computedAttributesFieldGroup",
"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": 1612861108205,
"repo:lastModifiedDate": 1612861108205,
"xdm:createdClientId": "{CLIENT_ID}",
"xdm:lastModifiedClientId": "{CLIENT_ID}",
"xdm:createdUserId": "{USER_ID}",
"xdm:lastModifiedUserId": "{USER_ID}",
"eTag": "627faa3346d3004aef2010e9bd2b7e721b19ae7857b276f3ef733e6e732d495f",
"meta:globalLibVersion": "1.19.4"
},
"meta:containerId": "tenant",
"meta:sandboxId": "{SANDBOX_ID}",
"meta:sandboxType": "production",
"meta:tenantNamespace": "_{TENANT_ID}"
}
由于需要更多计算属性,因此您可以通过向 /tenant/fieldgroups
端点。 此请求要求您包含在路径中创建的字段组的唯一ID,以及要在正文中添加的所有新字段。
有关使用架构注册表API更新字段组的详细信息,请参阅 字段组API端点指南.
API格式
PUT /tenant/fieldgroups/{FIELD_GROUP_ID}
请求
此请求会添加与 purchaseSummary
信息。
通过PUT请求更新字段组时,主体必须包含在POST请求中创建新字段组时需要填写的所有字段。
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 '{
"type": "object",
"title": "Computed Attributes Field Group",
"meta:extensible": true,
"meta:abstract": true,
"meta:intendedToExtend": [
"https://ns.adobe.com/xdm/context/profile"
],
"description": "Description of field group.",
"definitions": {
"computedAttributesFieldGroup": {
"type": "object",
"meta:xdmType": "object",
"properties": {
"_{TENANT_ID}": {
"type": "object",
"meta:xdmType": "object",
"properties": {
"birthdayCurrentMonth": {
"type": "boolean",
"meta:xdmType": "boolean"
},
"purchaseSummary": {
"type": "object",
"meta:xdmType": "object",
"properties": {
"totalSpend": {
"type": "number",
"meta:xdmType": "number"
},
"countPurchases": {
"meta:xdmType": "int",
"type": "integer",
"minimum": -2147483648,
"maximum": 2147483647
},
"averageSpend": {
"type": "number",
"meta:xdmType": "number"
}
}
}
}
}
}
}
},
"allOf": [
{
"$ref": "#/definitions/computedAttributesFieldGroup"
}
]
}'
响应
成功的响应会返回更新的字段组的详细信息。
{
"$id": "https://ns.adobe.com/{TENANT_ID}/mixins/860ad1b1b35e0a88ecf6df92ebce08335c180313d5805352",
"meta:altId": "_{TENANT_ID}.mixins.860ad1b1b35e0a88ecf6df92ebce08335c180313d5805352",
"meta:resourceType": "mixins",
"version": "1.0",
"title": "Computed Attributes Field Group",
"type": "object",
"description": "Description of field group.",
"definitions": {
"computedAttributesFieldGroup": {
"type": "object",
"meta:xdmType": "object",
"properties": {
"_{TENANT_ID}": {
"type": "object",
"meta:xdmType": "object",
"properties": {
"birthdayCurrentMonth": {
"type": "boolean",
"meta:xdmType": "boolean"
},
"purchaseSummary": {
"type": "object",
"meta:xdmType": "object",
"properties": {
"totalSpend": {
"type": "number",
"meta:xdmType": "number"
},
"countPurchases": {
"meta:xdmType": "int",
"type": "integer",
"minimum": -2147483648,
"maximum": 2147483647
},
"averageSpend": {
"type": "number",
"meta:xdmType": "number"
}
}
}
}
}
}
}
},
"allOf": [
{
"$ref": "#/definitions/computedAttributesFieldGroup",
"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": 1612861108205,
"repo:lastModifiedDate": 1612861108205,
"xdm:createdClientId": "{CLIENT_ID}",
"xdm:lastModifiedClientId": "{CLIENT_ID}",
"xdm:createdUserId": "{USER_ID}",
"xdm:lastModifiedUserId": "{USER_ID}",
"eTag": "627faa3346d3004aef2010e9bd2b7e721b19ae7857b276f3ef733e6e732d495f",
"meta:globalLibVersion": "1.19.4"
},
"meta:containerId": "tenant",
"meta:sandboxId": "{SANDBOX_ID}",
"meta:sandboxType": "production",
"meta:tenantNamespace": "_{TENANT_ID}"
}
要使用架构注册表API创建架构,请首先向 /tenant/schemas
端点,并在请求正文中提供架构的详细信息。 还必须为 Profile 和显示为架构类的并集架构的一部分。
有关 Profile-enabled schemas和union schemas,请查看 Schema Registry API指南 和 架构合成基础文档.
API格式
POST /tenants/schemas
请求
以下请求会创建一个引用 computedAttributesFieldGroup
此文档中之前创建的(使用其唯一ID),且已为配置文件合并架构启用(使用 meta:immutableTags
数组)。 有关如何使用架构注册表API创建架构的详细说明,请参阅 架构API端点指南.
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 '{
"type": "object",
"title": "Computed Attributes Schema",
"meta:extensible": false,
"meta:abstract": false,
"meta:immutableTags": [
"union"
],
"meta:extends": [
"https://ns.adobe.com/xdm/context/profile",
"https://ns.adobe.com/xdm/context/identitymap",
"https://ns.adobe.com/{TENANT_ID}/mixins/860ad1b1b35e0a88ecf6df92ebce08335c180313d5805352"
],
"description": "Description of schema.",
"definitions": {
},
"allOf": [
{
"$ref": "https://ns.adobe.com/xdm/context/profile"
},
{
"$ref": "https://ns.adobe.com/xdm/context/identitymap"
},
{
"$ref": "https://ns.adobe.com/{TENANT_ID}/mixins/860ad1b1b35e0a88ecf6df92ebce08335c180313d5805352"
}
],
"meta:class": "https://ns.adobe.com/xdm/context/profile"
}'
响应
成功响应会返回HTTP状态201(已创建)和包含新创建架构详细信息(包括 $id
, meta:altId
和 version
. 这些值是只读的,由架构注册表分配。
{
"$id": "https://ns.adobe.com/{TENANT_ID}/schemas/699c1f16821c51086394fef8233d7fdb61e6f5b574b5a230",
"meta:altId": "_{TENANT}.schemas.699c1f16821c51086394fef8233d7fdb61e6f5b574b5a230",
"meta:resourceType": "schemas",
"version": "1.0",
"title": "Computed Attributes Schema",
"type": "object",
"description": "Description of schema.",
"definitions": {},
"allOf": [
{
"$ref": "https://ns.adobe.com/xdm/context/profile",
"type": "object",
"meta:xdmType": "object"
},
{
"$ref": "https://ns.adobe.com/xdm/context/identitymap",
"type": "object",
"meta:xdmType": "object"
},
{
"$ref": "https://ns.adobe.com/{TENANT_ID}/mixins/860ad1b1b35e0a88ecf6df92ebce08335c180313d5805352",
"type": "object",
"meta:xdmType": "object"
}
],
"refs": [
"https://ns.adobe.com/xdm/context/profile",
"https://ns.adobe.com/xdm/context/identitymap",
"https://ns.adobe.com/{TENANT_ID}/mixins/860ad1b1b35e0a88ecf6df92ebce08335c180313d5805352"
],
"imsOrg": "{ORG_ID}",
"meta:extensible": false,
"meta:abstract": false,
"meta:extends": [
"https://ns.adobe.com/xdm/common/auditable",
"https://ns.adobe.com/xdm/data/record",
"https://ns.adobe.com/xdm/context/profile",
"https://ns.adobe.com/xdm/context/identitymap",
"https://ns.adobe.com/{TENANT_ID}/mixins/860ad1b1b35e0a88ecf6df92ebce08335c180313d5805352"
],
"meta:xdmType": "object",
"meta:registryMetadata": {
"repo:createdDate": 1612385766411,
"repo:lastModifiedDate": 1612385766411,
"xdm:createdClientId": "{CLIENT_ID}",
"xdm:lastModifiedClientId": "{CLIENT_ID}",
"xdm:createdUserId": "{USER_ID}",
"xdm:lastModifiedUserId": "{USER_ID}",
"eTag": "a9c6b5c25c109970ffa5eaeb3db2b47b59c696e1d9407fb39ccf7e48b74b558e",
"meta:globalLibVersion": "1.18.4"
},
"meta:class": "https://ns.adobe.com/xdm/context/profile",
"meta:containerId": "tenant",
"meta:sandboxId": "{SANDBOX_ID}",
"meta:sandboxType": "production",
"meta:tenantNamespace": "_{TENANT}",
"meta:immutableTags": [
"union"
]
}
现在,您已创建一个架构和字段组,计算属性将存储到其中,接下来可以使用 /computedattributes
API端点。 有关在API中创建计算属性的详细步骤,请按照 计算属性API端点指南.