Datentypendpunkt
Datentypen werden in Klassen oder Schemafeldgruppen auf die gleiche Weise wie einfache literale Felder als Referenztyp verwendet, wobei der wesentliche Unterschied darin besteht, dass Datentypen mehrere Unterfelder definieren können. Auch wenn sie Feldgruppen insofern ähnlich sind, als sie die konsistente Verwendung einer Mehrfeld-Struktur ermöglichen, sind Datentypen flexibler, da sie an einer beliebigen Stelle in die Schemastruktur aufgenommen werden können, während Feldgruppen nur auf der Stammebene hinzugefügt werden können. Die /datatypes
-Endpunkt im Schema Registry Mit der API können Sie Datentypen in Ihrer Erlebnisanwendung programmgesteuert verwalten.
Erste Schritte
Der in diesem Handbuch verwendete Endpunkt ist Teil der Schema Registry API. Bevor Sie fortfahren, lesen Sie das Handbuch Erste Schritte mit Links zur zugehörigen Dokumentation, einer Anleitung zum Lesen der API-Beispielaufrufe in diesem Dokument und wichtigen Informationen zu den erforderlichen Kopfzeilen, die für die erfolgreiche Ausführung von Aufrufen an eine Experience Platform-API erforderlich sind.
Liste von Datentypen abrufen list
Sie können alle Datentypen unter der global
oder tenant
Container durch eine GET-Anfrage an /global/datatypes
oder /tenant/datatypes
, bzw.
API-Format
GET /{CONTAINER_ID}/datatypes?{QUERY_PARAMS}
{CONTAINER_ID}
global
für von Adobe erstellte Datentypen oder tenant
für Datentypen, die Ihrem Unternehmen gehören.{QUERY_PARAMS}
Anfrage
Die folgende Anfrage ruft eine Liste von Datentypen aus der tenant
Container, mithilfe eines orderby
Abfrageparameter, um die Datentypen nach ihren title
-Attribut.
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}'
Das Antwortformat hängt von der Accept
-Kopfzeile, die in der Anfrage gesendet wird. Die folgenden Accept
-Header sind für die Auflistung von Datentypen verfügbar:
Accept
-Kopfzeileapplication/vnd.adobe.xed-id+json
application/vnd.adobe.xed+json
$ref
und allOf
enthalten. (Limit: 300)Antwort
Die obige Anfrage verwendete die application/vnd.adobe.xed-id+json
Accept
-Kopfzeile; daher enthält die Antwort nur die title
, $id
, meta:altId
, und version
-Attribute für jeden Datentyp. Andere verwenden Accept
header (application/vnd.adobe.xed+json
) gibt alle Attribute jedes Datentyps zurück. Wählen Sie die entsprechende Accept
-Kopfzeile entsprechend den Informationen, die Sie in Ihrer Antwort benötigen.
{
"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"
}
}
}
Nachschlagen eines Datentyps lookup
Sie können nach einem bestimmten Datentyp suchen, indem Sie die Kennung des Datentyps in den Pfad einer GET-Anfrage einschließen.
API-Format
GET /{CONTAINER_ID}/datatypes/{DATA_TYPE_ID}
{CONTAINER_ID}
global
für einen von der Adobe erstellten Datentyp oder tenant
für einen Datentyp, der Ihrem Unternehmen gehört.{DATA_TYPE_ID}
meta:altId
oder URL-kodiert $id
des Datentyps, den Sie nachschlagen möchten.Anfrage
Die folgende Anfrage ruft einen Datentyp anhand seiner meta:altId
-Wert, der im Pfad angegeben wird.
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}'
Das Antwortformat hängt von der Accept
-Kopfzeile, die in der Anfrage gesendet wird. Alle Anfragen zum Nachschlagen erfordern eine version
enthalten sein. Accept
-Kopfzeile. Die folgenden Accept
Header sind verfügbar:
Accept
-Kopfzeileapplication/vnd.adobe.xed+json; version=1
$ref
und allOf
, verfügt über Titel und Beschreibungen.application/vnd.adobe.xed-full+json; version=1
$ref
und allOf
aufgelöst, verfügt über Titel und Beschreibungen.application/vnd.adobe.xed-notext+json; version=1
$ref
und allOf
, keine Titel oder Beschreibungen.application/vnd.adobe.xed-full-notext+json; version=1
$ref
und allOf
aufgelöst, keine Titel oder Beschreibungen.application/vnd.adobe.xed-full-desc+json; version=1
$ref
und allOf
aufgelöst, einschließlich Deskriptoren.Antwort
Eine erfolgreiche Antwort gibt die Details des Datentyps zurück. Die zurückgegebenen Felder hängen von der Accept
-Kopfzeile, die in der Anfrage gesendet wird. Experimentieren mit verschiedenen Accept
Kopfzeilen zum Vergleich der Antworten und zur Bestimmung der Kopfzeile, die für Ihren Anwendungsfall am besten geeignet ist.
{
"$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}"
}
Erstellen eines Datentyps create
Sie können einen benutzerdefinierten Datentyp unter dem tenant
-Container, indem Sie eine POST-Anfrage ausführen.
API-Format
POST /tenant/datatypes
Anfrage
Im Gegensatz zu Feldergruppen erfordert das Definieren eines Datentyps keine meta:extends
oder meta:intendedToExtend
-Felder und Felder müssen nicht verschachtelt sein, um Kollisionen zu vermeiden.
Bei der Definition der Feldstruktur des Datentyps selbst können Sie Primitive-Typen verwenden (wie string
oder object
) oder Sie können andere vorhandene Datentypen über referenzieren. $ref
-Attribute. Siehe Handbuch unter Definieren benutzerdefinierter XDM-Felder in der API für ausführliche Anleitungen zum erwarteten Format für verschiedene XDM-Feldtypen.
Die folgende Anfrage erstellt einen Objektdatentyp "Property Construction"mit Untereigenschaften yearBuilt
, propertyType
, und 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"
}
}
}'
Antwort
Bei erfolgreicher Antwort wird der HTTP-Status-Code 201 (Erstellung bestätigt) und eine Payload zurückgegeben, die Details zum neu erstellten Datentyp einschließlich $id
, meta:altId
und version
enthält. Diese drei Werte sind schreibgeschützt und werden von der 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}"
}
Durchführen einer GET-Anfrage an alle Datentypen auflisten im Mandanten-Container nun den Datentyp Eigenschaftendetails enthalten, oder Sie können Anfrage zum Nachschlagen (GET) ausführen mit der URL-kodierten $id
URI, um den neuen Datentyp direkt anzuzeigen.
Datentyp aktualisieren put
Sie können einen ganzen Datentyp durch einen PUT-Vorgang ersetzen und die Ressource im Wesentlichen neu schreiben. Beim Aktualisieren eines Datentyps über eine PUT-Anfrage muss der Hauptteil alle Felder enthalten, die erforderlich sind, wenn Erstellen eines neuen Datentyps in einer POST-Anfrage.
API-Format
PUT /tenant/datatypes/{DATA_TYPE_ID}
{DATA_TYPE_ID}
meta:altId
oder URL-kodiert $id
des Datentyps, den Sie neu schreiben möchten.Anfrage
Die folgende Anfrage schreibt einen vorhandenen Datentyp neu und fügt einen neuen hinzu floorSize
-Feld.
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."
}
}
}'
Antwort
Eine erfolgreiche Antwort gibt die Details des aktualisierten Datentyps zurück.
{
"$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}"
}
Einen Teil eines Datentyps aktualisieren patch
Sie können einen Teil eines Datentyps mithilfe einer PATCH-Anfrage aktualisieren. Die Schema Registry unterstützt alle standardmäßigen JSON Patch-Vorgänge, einschließlich add
, remove
, und replace
. Weitere Informationen zu JSON-Patch-Vorgängen finden Sie im API-Grundlagenhandbuch.
API-Format
PATCH /tenant/data type/{DATA_TYPE_ID}
{DATA_TYPE_ID}
$id
URI oder meta:altId
des Datentyps, den Sie aktualisieren möchten.Anfrage
Die folgende Beispielanfrage aktualisiert die description
und fügt einen neuen floorSize
-Feld.
Der Anfragetext hat die Form eines Arrays, wobei jedes aufgelistete Objekt eine bestimmte Änderung an einem einzelnen Feld darstellt. Jedes Objekt enthält den auszuführenden Vorgang (op
), auf welchem Feld der Vorgang ausgeführt werden soll (path
) und welche Informationen in diesem Vorgang enthalten sein sollten (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."
}
}
]'
Antwort
Die Antwort zeigt, dass beide Vorgänge erfolgreich durchgeführt wurden. Die description
aktualisiert wurde und floorSize
wurde hinzugefügt unter 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}"
}
Datentyp löschen delete
Gelegentlich kann es erforderlich sein, einen Datentyp aus der Schema Registry zu entfernen. Dies geschieht durch Ausführen einer DELETE-Anfrage mit der im Pfad angegebenen Datentyp-ID.
API-Format
DELETE /tenant/datatypes/{DATA_TYPE_ID}
{DATA_TYPE_ID}
$id
URI oder meta:altId
des Datentyps, den Sie löschen möchten.Anfrage
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}'
Antwort
Eine erfolgreiche Antwort gibt den HTTP-Status 204 (Kein Inhalt) und leeren Text zurück.
Sie können den Löschvorgang bestätigen, indem Sie einen Anfrage zum Nachschlagen (GET) zum Datentyp hinzugefügt. Sie müssen eine Accept
-Kopfzeile in der Anfrage, sollte jedoch einen HTTP-Status 404 (Nicht gefunden) erhalten, da der Datentyp aus der Schema Registry entfernt wurde.