Auf dieser Seite wird beschrieben, wie Sie Glossare, Kategorien, Begriffe und Eintragslinks mithilfe der Dataplex API in Knowledge Catalog (ehemals Dataplex Universal Catalog) importieren. Mit diesem Verfahren können Sie Metadaten aus anderen Katalogisierungstools migrieren oder Glossare per Bulk-Update aktualisieren, indem Sie JSON-Dateien in Cloud Storage hochladen.
Hinweis
Bevor Sie mit dem Import beginnen, müssen die folgenden Voraussetzungen erfüllt sein:
Cloud Storage-Bucket erstellen
Erstellen Sie einen Cloud Storage-Bucket, der als Stagingbereich für Importdateien dient.
Erforderliche Rollen
Bitten Sie Ihren Administrator, Ihnen die folgenden IAM-Rollen zuzuweisen, um die Berechtigungen zu erhalten, die Sie zum Importieren von Glossaren und Eintragslinks mithilfe von JSON-Dateien benötigen:
- Dataplex Metadata Editor (
roles/dataplex.metadataEditor) für das Projekt - Storage Object Viewer (
roles/storage.objectViewer) für den Bucket mit Ihren Importdateien
Weitere Informationen zum Zuweisen von Rollen finden Sie unter Zugriff auf Projekte, Ordner und Organisationen verwalten.
Sie können die erforderlichen Berechtigungen auch über benutzerdefinierte Rollen oder andere vordefinierte Rollen erhalten.
APIs aktivieren
Aktivieren Sie die Dataplex API in Ihrem Projekt, um Glossare und Eintragslinks zu importieren.
Erforderliche Rollen zum Aktivieren von APIs
Zum Aktivieren von APIs benötigen Sie die IAM-Rolle „Service Usage-Administrator“
(roles/serviceusage.serviceUsageAdmin), die
die Berechtigung serviceusage.services.enable enthält. Informationen zum Zuweisen von
Rollen.
Glossare mithilfe von JSON-Dateien importieren
Führen Sie die folgenden Aufgaben aus, um Glossare, Kategorien und Begriffe zu importieren.
Zielglossar erstellen
Erstellen Sie ein Zielglossar, in das Sie Metadaten importieren können.
alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"' gcurl -X POST https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries?glossary_id=GLOSSARY_ID -d "$(cat<<EOF { "displayName": "DISPLAY_NAME", "description": "DESCRIPTION" } EOF )"
Ersetzen Sie Folgendes:
PROJECT_ID: die Projekt-ID, in der Sie das Glossar erstellenLOCATION_ID: der Standort, an dem Sie das Glossar erstellen möchtenGLOSSARY_ID: die Glossar-IDDISPLAY_NAME: der Anzeigename des GlossarsDESCRIPTION: die Beschreibung des Glossars
JSON-Dateien vorbereiten
Erstellen Sie eine durch Zeilenumbrüche getrennte JSON-Datei mit Glossar, Kategorien und Begriffen, die Sie in den Cloud Storage-Bucket hochladen möchten.
Verwenden Sie das folgende JSON-Schema, um Ihre Importdateien zu strukturieren:
{"entry":{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID","entryType":"projects/dataplex-types/locations/global/entryTypes/glossary-category","aspects":{"dataplex-types.global.glossary-category-aspect":{"data":{}},"dataplex-types.global.overview":{"data":{"content":"CONTENT"}},"dataplex-types.global.contacts":{"data":{"identities":[{role: "steward", name: "CONTACT_DISPLAY_NAME", id: "CONTACT_EMAIL"}]}}},"parentEntry":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","entrySource":{"resource":"projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID","displayName":"CATEGORY_NAME","description":"CATEGORY_DESCRIPTION","ancestors":[{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary"}]}}} {"entry":{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM1_ID","entryType":"projects/dataplex-types/locations/global/entryTypes/glossary-term","aspects":{"dataplex-types.global.glossary-term-aspect":{"data":{}},"dataplex-types.global.overview":{"data":{"content":"TERM1_CONTENT"}},"dataplex-types.global.contacts":{"data":{"identities":[{role: "steward", name: "CONTACT_DISPLAY_NAME", id: "CONTACT_EMAIL"}]}}},"parentEntry":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","entrySource":{"resource":"projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM1_ID","displayName":"TERM1_DISPLAY_NAME","description":"TERM1_DESCRIPTION","ancestors":[{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary"},{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary-category"}]}}} {"entry":{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM2_ID","entryType":"projects/dataplex-types/locations/global/entryTypes/glossary-term","aspects":{"dataplex-types.global.glossary-term-aspect":{"data":{}},"dataplex-types.global.overview":{"data":{"content":"TERM1_CONTENT"}},"dataplex-types.global.contacts":{"data":{"identities":[{role: "steward", name: "CONTACT_DISPLAY_NAME", id: "CONTACT_EMAIL"}]}}},"parentEntry":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","entrySource":{"resource":"projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM2_ID","displayName":"TERM2_DISPLAY_NAME","description":"TERM2_DESCRIPTION","ancestors":[{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary"},{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary-category"}]}}}
Glossar, Kategorien und Begriffe importieren
Importieren Sie das Glossar, die Kategorien und die Begriffe in den Cloud Storage-Bucket:
# Set GCURL alias alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"' gcurl https://DATAPLEX_API/metadataJobs?metadata_job_id=JOB_ID -d "$(cat<<EOF { "type":"IMPORT", "import_spec":{ "log_level":"DEBUG", "source_storage_uri":"gs://STORAGE_BUCKET/", "entry_sync_mode":"FULL", "aspect_sync_mode":"INCREMENTAL", "scope":{ "glossaries": "GLOSSARY_NAME" } } } EOF )"
Ersetzen Sie DATAPLEX_API durch den Dataplex API
Endpunkt im Format
dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID.
Eintragslinks mithilfe von JSON-Dateien importieren
Führen Sie die folgenden Aufgaben aus, um Eintragslinks per Bulk-Import zu importieren.
JSON-Dateien vorbereiten
Erstellen Sie eine durch Zeilenumbrüche getrennte JSON-Datei mit den Eintragslinks, die Sie in den Cloud Storage-Bucket hochladen möchten.
Verwenden Sie das folgende JSON-Schema, um Ihre Importdateien zu strukturieren:
Beispielformat für Links zwischen Begriffen
{"entryLink":{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entryLinks/el-import-0606e3f2-8206-4f3a-aba9-32c6196f6048","entryLinkType":"projects/dataplex-types/locations/global/entryLinkTypes/synonym","entryReferences":[{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-1"},{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-2"}]}} {"entryLink":{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entryLinks/el-import-2f7408e3-af3d-405d-81bb-861cf9ec5146","entryLinkType":"projects/dataplex-types/locations/global/entryLinkTypes/related","entryReferences":[{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-1"},{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-2"}]}}
Beispielformat für Links zwischen Begriffen und Datenassets
{"entryLink":{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entryLinks/el-import-0606e3f2-8206-4f3a-aba9-32c6196f6048","entryLinkType":"projects/dataplex-types/locations/global/entryLinkTypes/definition","entryReferences":[{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-1"},{"name":"projects/PROJECT_NUMBER/locations/us-central1/entryGroups/entry-group-1/entries/entry-1"}]}}
Links zwischen Begriffen als Synonyme oder verwandte Begriffe importieren
Verwenden Sie den folgenden Befehl, um einen Metadatenimportjob zu starten, der synonym- oder related-Verbindungen zwischen Ihren Katalogbegriffen herstellt:
gcurl https://DATAPLEX_API/metadataJobs?metadata_job_id=JOB_ID -d "$(cat<<EOF { "type":"IMPORT", "import_spec":{ "log_level":"DEBUG", "source_storage_uri":"gs://STORAGE_BUCKET/", "entry_sync_mode":"FULL", "aspect_sync_mode":"INCREMENTAL", "scope":{ "entry_groups":[ "projects/PROJECT_ID/locations/LOCATION_ID/entryGroups/@dataplex" ], "entry_link_types":[ "projects/dataplex-types/locations/global/entryLinkTypes/synonym", "projects/dataplex-types/locations/global/entryLinkTypes/related" ], "referenced_entry_scopes":[ "PROJECT_IDS" ] } } } EOF )"
Ersetzen Sie DATAPLEX_API durch
dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID.
Links zwischen Begriffen und bestimmten Datenassets oder Spalten importieren
Wenn Sie einen Link zwischen Glossarbegriffen und Datenassets erstellen möchten, führen Sie den Importjob für jede Eintragsgruppe aus, zu der der Eintrag für das Datenasset gehört. Alle Definitionseintragslinks werden in dieser Eintragsgruppe erstellt.
gcurl https://DATAPLEX_API/metadataJobs?metadata_job_id=JOB_ID -d "$(cat<<EOF { "type":"IMPORT", "import_spec":{ "log_level":"DEBUG", "source_storage_uri":"gs://STORAGE_BUCKET/", "entry_sync_mode":"FULL", "aspect_sync_mode":"INCREMENTAL", "scope":{ "entry_groups":[ "projects/PROJECT_ID/locations/ENTRY_GROUP_LOCATION_ID/entryGroups/@dataplex" ], "entry_link_types":[ "projects/dataplex-types/locations/global/entryLinkTypes/definition" ], "referenced_entry_scopes":[ "PROJECT_IDS" ] } } } EOF )"
Ersetzen Sie DATAPLEX_API durch
dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID.
Status des Importjobs beobachten
Führen Sie den folgenden Befehl aus, um den Status des Vorgangs
importabzurufen:gcurl https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/operations/operation-OPERATION_IDErsetzen Sie
OPERATION_IDdurch die ID des Vorgangs.Führen Sie den folgenden Befehl aus, um den Status des Metadatenjobs abzurufen:
gcurl -X GET https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/metadataJobs/JOB_ID
Nächste Schritte
- Informationen zum Verwalten von Unternehmensglossaren in Knowledge Catalog .
- Informationen zum Importieren von Glossaren aus einem Google-Tabellen import glossaries from a Google Sheet.
- Weitere Informationen zur Metadatenverwaltung.