数据类型端点

数据类型在类或架构字段组中用作引用类型字段的方式与基本文本字段相同,主要区别在于数据类型可以定义多个子字段。 虽然与字段组类似,它们允许一致地使用多字段结构,但数据类型更加灵活,因为它们可以包含在架构结构中的任意位置,而字段组只能在根级别添加。 此 /datatypes 中的端点 Schema Registry API允许您以编程方式管理体验应用程序中的数据类型。

NOTE
如果字段被定义为特定数据类型,则无法在另一个架构中创建具有不同数据类型的相同字段。 此限制适用于您组织的租户。

快速入门

本指南中使用的端点是 Schema Registry API. 在继续之前,请查看 快速入门指南 有关相关文档的链接、阅读本文档中示例API调用的指南,以及有关成功调用任何Experience PlatformAPI所需的所需标头的重要信息。

检索数据类型列表 list

您可以在 globaltenant 向以下对象发出GET请求,以获取container /global/datatypes/tenant/datatypes、ID名称和ID名称等。

NOTE
列出资源时,架构注册表将结果集限制为300个项目。 要返回超出此限制的资源,必须使用分页参数。 还建议您使用其他查询参数来筛选结果并减少返回的资源数。 请参阅以下部分 查询参数 在附录文档中了解更多信息。

API格式

GET /{CONTAINER_ID}/datatypes?{QUERY_PARAMS}
参数
描述
{CONTAINER_ID}
要从中检索数据类型的容器: global Adobe创建的数据类型或 tenant (对于贵组织拥有的数据类型)。
{QUERY_PARAMS}
用于筛选结果的可选查询参数。 请参阅 附录文档 以获取可用参数的列表。

请求

以下请求从检索数据类型列表 tenant 容器,使用 orderby 用于按数据类型对数据进行排序的查询参数 title 属性。

curl -X GET \
  https://platform.adobe.io/data/foundation/schemaregistry/tenant/datatypes?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数据类型,原始值为 $refallOf 包括。 (限制:300)

响应

上述请求使用了 application/vnd.adobe.xed-id+json Accept 标头,因此响应仅包含 title$idmeta:altId、和 version 每个数据类型的属性。 使用另一个 Accept 标题(application/vnd.adobe.xed+json)返回每种数据类型的所有属性。 选择适当的 Accept 标头,具体取决于您在响应中需要的信息。

{
  "results": [
    {
      "$id": "https://ns.adobe.com/{TENANT_ID}/datatypes/78570e371092c032260714dd8bfd6d44",
      "meta:altId": "_{TENANT_ID}.datatypes.78570e371092c032260714dd8bfd6d44",
      "version": "1.0",
      "title": "Loyalty"
    },
    {
      "$id": "https://ns.adobe.com/{TENANT_ID}/datatypes/4b0329b5573cbb7cb757db667d7fdf66",
      "meta:altId": "_{TENANT_ID}.datatypes.4b0329b5573cbb7cb757db667d7fdf66",
      "version": "1.0",
      "title": "Property Details"
    }
  ],
  "_page": {
    "orderby": "title",
    "next": null,
    "count": 2
  },
  "_links": {
    "next": null,
    "global_schemas": {
      "href": "https://platform.adobe.io/data/foundation/schemaregistry/global/datatypes?orderby=title"
    }
  }
}

查找数据类型 lookup

通过在GET请求的路径中包含数据类型的ID,您可以查找特定数据类型。

API格式

GET /{CONTAINER_ID}/datatypes/{DATA_TYPE_ID}
参数
描述
{CONTAINER_ID}
存放要检索的数据类型的容器: global Adobe创建的数据类型或 tenant (对于贵组织拥有的数据类型)。
{DATA_TYPE_ID}
meta:altId 或URL编码 $id 要查找的数据类型对应的字段。

请求

以下请求按其检索数据类型 meta:altId 路径中提供的值。

curl -X GET \
  https://platform.adobe.io/data/foundation/schemaregistry/tenant/datatypes/_{TENANT_ID}.datatypes.78570e371092c032260714dd8bfd6d44 \
  -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
原始 $refallOf,具有标题和描述。
application/vnd.adobe.xed-full+json; version=1
$refallOf 已解决,具有标题和描述。
application/vnd.adobe.xed-notext+json; version=1
原始 $refallOf,无标题或描述。
application/vnd.adobe.xed-full-notext+json; version=1
$refallOf 已解决,无标题或描述。
application/vnd.adobe.xed-full-desc+json; version=1
$refallOf 已解决,包含描述符。

响应

成功的响应将返回数据类型的详细信息。 返回的字段取决于 Accept 标头在请求中发送。 试验不同的 Accept 标头,用于比较响应并确定哪个标头最适合您的用例。

{
  "$id": "https://ns.adobe.com/{TENANT_ID}/datatypes/78570e371092c032260714dd8bfd6d44",
  "meta:altId": "_{TENANT_ID}.datatypes.78570e371092c032260714dd8bfd6d44",
  "meta:resourceType": "datatypes",
  "version": "1.0",
  "title": "Loyalty",
  "type": "object",
  "description": "Loyalty object containing loyalty-specific fields.",
  "definitions": {
    "customFields": {
      "properties": {
        "loyaltyId": {
          "title": "Loyalty ID",
          "description": "Unique loyalty program member ID. Should be in the format of an email address.",
          "type": "string",
          "meta:xdmType": "string"
        },
        "memberSince": {
          "title": "Member Since",
          "description": "Date person joined loyalty program.",
          "type": "string",
          "format": "date",
          "meta:xdmType": "date"
        },
        "points": {
          "title": "Points",
          "description": "Accumulated loyalty points",
          "type": "integer",
          "meta:xdmType": "int"
        },
        "loyaltyLevel": {
          "title": "Loyalty Level",
          "description": "The current loyalty program level to which the individual member belongs.",
          "type": "string",
          "enum": [
            "platinum",
            "gold",
            "silver",
            "bronze"
          ],
          "meta:enum": {
            "platinum": "Platinum",
            "gold": "Gold",
            "silver": "Silver",
            "bronze": "Bronze"
          },
          "meta:xdmType": "string"
        }
      },
      "type": "object",
      "meta:xdmType": "object"
    }
  },
  "allOf": [
    {
      "$ref": "#/definitions/customFields"
    }
  ],
  "imsOrg": "{ORG_ID}",
  "meta:extensible": true,
  "meta:abstract": true,
  "meta:xdmType": "object",
  "meta:registryMetadata": {
    "repo:createdDate": 1557529442681,
    "repo:lastModifiedDate": 1557529442681,
    "xdm:createdClientId": "{CLIENT_ID}",
    "xdm:lastModifiedClientId": "{CLIENT_ID}",
    "xdm:lastModifiedUserId": "{USER_ID}",
    "eTag": "50b8008b588e911314f9685240dd4c23a247f37179a6d9ff6ba3877dc11ca504",
    "meta:globalLibVersion": "1.15.4"
  },
  "meta:containerId": "tenant",
  "meta:tenantNamespace": "_{TENANT_ID}"
}

创建数据类型 create

您可以在 tenant POST请求的容器。

API格式

POST /tenant/datatypes

请求

与字段组不同,定义数据类型不需要 meta:extendsmeta:intendedToExtend 字段,也不需要嵌套字段以避免冲突。

在定义数据类型本身的字段结构时,您可以使用原始类型(如 stringobject),或者您也可以通过引用其他现有数据类型 $ref 属性。 请参阅指南,网址为 在API中定义自定义XDM字段 ,以了解不同XDM字段类型的预期格式的详细指导。

以下请求创建具有子属性的“属性构造”对象数据类型 yearBuiltpropertyType、和 location

curl -X POST \
  https://platform.adobe.io/data/foundation/schemaregistry/tenant/datatypes \
  -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 Construction",
        "description": "Information related to the property construction",
        "type": "object",
        "properties": {
          "yearBuilt": {
            "type": "integer",
            "title": "Year Built",
            "description": "The year the property was constructed."
          },
          "propertyType": {
            "type": "string",
            "title": "Property Type",
            "description": "Type of building or structure in which the property exists.",
            "enum": [
              "freeStanding",
              "mall",
              "shoppingCenter"
            ],
            "meta:enum": {
              "freeStanding": "Free Standing Building",
              "mall": "Mall Space",
              "shoppingCenter": "Shopping Center"
            }
          },
          "location": {
            "title": "Location",
            "description": "The physical location of the property.",
            "$ref": "https://ns.adobe.com/xdm/common/address"
          }
        }
      }'

响应

成功的响应会返回HTTP状态201(已创建)以及包含新创建的数据类型的详细信息的有效负载,包括 $idmeta:altId、和 version. 这三个值均为只读,并且由 Schema Registry.

{
  "$id": "https://ns.adobe.com/{TENANT_ID}/datatypes/669ffcc61cf5e94e8640dbe6a15f0f24eb3cd1ddbbfb6b36",
  "meta:altId": "_{TENANT_ID}.datatypes.669ffcc61cf5e94e8640dbe6a15f0f24eb3cd1ddbbfb6b36",
  "meta:resourceType": "datatypes",
  "version": "1.0",
  "title": "Property Construction",
  "type": "object",
  "description": "Information related to the property construction",
  "properties": {
    "yearBuilt": {
      "type": "integer",
      "title": "Year Built",
      "description": "The year the property was constructed.",
      "meta:xdmType": "int"
    },
    "propertyType": {
      "type": "string",
      "title": "Property Type",
      "description": "Type of building or structure in which the property exists.",
      "enum": [
        "freeStanding",
        "mall",
        "shoppingCenter"
      ],
      "meta:enum": {
        "freeStanding": "Free Standing Building",
        "mall": "Mall Space",
        "shoppingCenter": "Shopping Center"
      },
      "meta:xdmType": "string"
    },
    "location": {
      "title": "Location",
      "description": "The physical location of the property.",
      "$ref": "https://ns.adobe.com/xdm/common/address",
      "type": "object",
      "meta:xdmType": "object"
    }
  },
  "refs": [
    "https://ns.adobe.com/xdm/common/address"
  ],
  "imsOrg": "{ORG_ID}",
  "meta:extensible": true,
  "meta:abstract": true,
  "meta:xdmType": "object",
  "meta:registryMetadata": {
    "repo:createdDate": 1670885230789,
    "repo:lastModifiedDate": 1670885230789,
    "xdm:createdClientId": "{CLIENT_ID}",
    "xdm:lastModifiedClientId": "{CLIENT_ID}",
    "xdm:createdUserId": "{USER_ID}",
    "xdm:lastModifiedUserId": "{USER_ID}",
    "eTag": "d3cc803a1f8daa06b7c150d882bd337d88f4d5d5f08d36cfc4c2849dc0255f7e",
    "meta:globalLibVersion": "1.38.3.1"
  },
  "meta:containerId": "tenant",
  "meta:sandboxId": "1bd86660-c5da-11e9-93d4-6d5fc3a66a8e",
  "meta:sandboxType": "production",
  "meta:tenantNamespace": "_{TENANT_ID}"
}

执行GET请求至 列出所有数据类型 租户容器中现在包含资产详细信息数据类型,或者您可以 执行查找(GET)请求 使用URL编码 $id 用于直接查看新数据类型的URI。

更新数据类型 put

您可以通过PUT操作替换整个数据类型,从而本质上重新写入资源。 通过PUT请求更新数据类型时,正文必须包含以下情况下所需的所有字段: 创建新数据类型 在POST请求中。

NOTE
如果只想更新部分数据类型,而不是完全替换它,请参阅 更新数据类型的某个部分.

API格式

PUT /tenant/datatypes/{DATA_TYPE_ID}
参数
描述
{DATA_TYPE_ID}
meta:altId 或URL编码 $id 要重写的数据类型。

请求

以下请求重写现有数据类型,添加新的 floorSize 字段。

curl -X PUT \
  https://platform.adobe.io/data/foundation/schemaregistry/tenant/datatypes/_{TENANT_ID}.datatypes.7602bc6e97e5786a31c95d9e6531a1596687433451d97bc1 \
  -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 Construction",
        "description": "Information related to the property construction",
        "type": "object",
        "properties": {
          "yearBuilt": {
            "type": "integer",
            "title": "Year Built",
            "description": "The year the property was constructed."
          },
          "propertyType": {
            "type": "string",
            "title": "Property Type",
            "description": "Type of building or structure in which the property exists.",
            "enum": [
              "freeStanding",
              "mall",
              "shoppingCenter"
            ],
            "meta:enum": {
              "freeStanding": "Free Standing Building",
              "mall": "Mall Space",
              "shoppingCenter": "Shopping Center"
            }
          },
          "floorSize" {
            "type": "integer",
            "title": "Floor Size",
            "description": "The floor size of the property, in square feet."
          }
        }
      }'

响应

成功的响应将返回更新数据类型的详细信息。

{
  "$id": "https://ns.adobe.com/{TENANT_ID}/datatypes/7602bc6e97e5786a31c95d9e6531a1596687433451d97bc1",
  "meta:altId": "_{TENANT_ID}.datatypes.7602bc6e97e5786a31c95d9e6531a1596687433451d97bc1",
  "meta:resourceType": "datatypes",
  "version": "1.0",
  "title": "Property Construction",
  "type": "object",
  "description": "Information related to the property construction",
  "properties": {
    "yearBuilt": {
      "type": "integer",
      "title": "Year Built",
      "description": "The year the property was constructed.",
      "meta:xdmType": "int"
    },
    "propertyType": {
      "type": "string",
      "title": "Property Type",
      "description": "Type of building or structure in which the property exists.",
      "enum": [
        "freeStanding",
        "mall",
        "shoppingCenter"
      ],
      "meta:enum": {
        "freeStanding": "Free Standing Building",
        "mall": "Mall Space",
        "shoppingCenter": "Shopping Center"
      },
      "meta:xdmType": "string"
    },
    "floorSize" {
      "type":  "integer",
      "title":  "Floor Size",
      "description":  "The floor size of the property, in square feet.",
      "meta:xdmType": "int"
    }
  },
  "refs": [],
  "imsOrg": "{ORG_ID}",
  "meta:extensible": true,
  "meta:abstract": true,
  "meta:xdmType": "object",
  "meta:registryMetadata": {
    "repo:createdDate": 1604524729435,
    "repo:lastModifiedDate": 1604524729435,
    "xdm:createdClientId": "{CLIENT_ID}",
    "xdm:lastModifiedClientId": "{CLIENT_ID}",
    "xdm:createdUserId": "{USER_ID}",
    "xdm:lastModifiedUserId": "{USER_ID}",
    "eTag": "1c838764342756868ca1297869f582a38d15f03ed0acfc97fda7532d22e942c7",
    "meta:globalLibVersion": "1.15.4"
  },
  "meta:containerId": "tenant",
  "meta:sandboxId": "ff0f6870-c46d-11e9-8ca3-036939a64204",
  "meta:sandboxType": "production",
  "meta:tenantNamespace": "_{TENANT_ID}"
}

更新数据类型的部分 patch

您可以使用PATCH请求更新数据类型的某个部分。 此 Schema Registry 支持所有标准JSON修补程序操作,包括 addremove、和 replace. 有关JSON修补程序的详细信息,请参见 API基础指南.

NOTE
如果要使用新值替换整个资源,而不是更新单个字段,请参阅 使用PUT操作替换数据类型.

API格式

PATCH /tenant/data type/{DATA_TYPE_ID}
参数
描述
{DATA_TYPE_ID}
URL编码 $id URI或 meta:altId 要更新的数据类型的。

请求

下面的示例请求更新了 description ,并添加新的 floorSize 字段。

请求正文采用数组的形式,每个列出的对象表示对单个字段的特定更改。 每个对象都包括要执行的操作(op),应该对哪个字段执行操作(path),以及操作中应包含哪些信息(value)。

curl -X PATCH \
  https://platform.adobe.io/data/foundation/schemaregistry/tenant/datatypes/_{TENANT_ID}.datatypes.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": "Construction-related information for a company-operated property."
        },
        {
          "op": "add",
          "path": "/properties/floorSize",
          "value": {
            "type": "integer",
            "title": "Floor Size",
            "description": "The floor size of the property, in square feet."
          }
        }
      ]'

响应

响应显示两个操作均已成功执行。 此 description 已更新,并且 floorSize 已添加在 definitions.

{
  "$id": "https://ns.adobe.com/{TENANT_ID}/datatypes/8779fd45d6e4eb074300023a439862bbba359b60d451627a",
  "meta:altId": "_{TENANT_ID}.datatypes.8779fd45d6e4eb074300023a439862bbba359b60d451627a",
  "meta:resourceType": "datatypes",
  "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}"
}

删除数据类型 delete

有时可能需要从架构注册表中删除数据类型。 可使用路径中提供的数据类型ID执行DELETE请求,从而达到此目的。

API格式

DELETE /tenant/datatypes/{DATA_TYPE_ID}
参数
描述
{DATA_TYPE_ID}
URL编码 $id URI或 meta:altId 要删除的数据类型中的ID。

请求

curl -X DELETE \
  https://platform.adobe.io/data/foundation/schemaregistry/tenant/datatypes/_{TENANT_ID}.datatypes.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(未找到),因为数据类型已从架构注册表中删除。

recommendation-more-help
62e9ffd9-1c74-4cef-8f47-0d00af32fc07