Package: datacatalog-tag-exporter
Datacatalog Tag ExporterA Python package to manage Google Cloud Data Catalog Tag export scripts.Disclaimer: This is not an officially supported Google product.Table of ContentsExecuting in Cloud Shell1. Environment setup1.1. Python + virtualenv1.1.1. Install Python 3.6+1.1.2. Get the source code1.1.3. Create and activate an isolated Python environment1.1.4. Install the package1.2. Docker1.3. Auth credentials1.3.1. Create a service account and grant it below roles1.3.2. Download a JSON key and save it as1.3.3. Set the environment variables2. Export Tags to CSV file2.1. A list of CSV files, each representing one Template will be created.2.2. Run the datacatalog-tag-exporter script2.2.1 Run the datacatalog-tag-exporter filtering Tag TemplatesExecuting in Cloud Shell# Set your SERVICE ACCOUNT, for instructions go to 1.3. Auth credentials# This name is just a suggestion, feel free to name it following your naming conventionsexportGOOGLE_APPLICATION_CREDENTIALS=~/datacatalog-tag-exporter-sa.json# Install datacatalog-tag-exporterpip3installdatacatalog-tag-exporter--user# Add to your PATHexportPATH=~/.local/bin:$PATH# Look for available commandsdatacatalog-tag-exporter--help1. Environment setup1.1. Python + virtualenvUsingvirtualenvis optional, but strongly recommended unless you useDocker.1.1.1. Install Python 3.6+1.1.2. Get the source codegitclonehttps://github.com/mesmacosta/datacatalog-tag-exportercd./datacatalog-tag-exporterAll paths starting with./in the next steps are relative to thedatacatalog-tag-exporterfolder.1.1.3. Create and activate an isolated Python environmentpipinstall--upgradevirtualenv
python3-mvirtualenv--pythonpython3envsource./env/bin/activate1.1.4. Install the packagepipinstall--upgrade.1.2. DockerDocker may be used as an alternative to run the script. In this case, please disregard theVirtualenvsetup instructions.1.3. Auth credentials1.3.1. Create a service account and grant it below rolesData Catalog Admin1.3.2. Download a JSON key and save it asThis name is just a suggestion, feel free to name it following your naming conventions./credentials/datacatalog-tag-exporter-sa.json1.3.3. Set the environment variablesThis step may be skipped if you're usingDocker.exportGOOGLE_APPLICATION_CREDENTIALS=~/credentials/datacatalog-tag-exporter-sa.json2. Export Tags to CSV file2.1. A list of CSV files, each representing one Template will be created.One file with summary with stats about each template, will also be created on the same directory.The columns for the summary file are described as follows:ColumnDescriptiontemplate_nameResource name of the Tag Template for the Tag.tags_countNumber of tags found from the template.tagged_entries_countNumber of tagged entries with the template.tagged_columns_countNumber of tagged columns with the template.tag_string_fields_countNumber of used String fields on tags of the template.tag_bool_fields_countNumber of used Bool fields on tags of the template.tag_double_fields_countNumber of used Double fields on tags of the template.tag_timestamp_fields_countNumber of used Timestamp fields on tags of the template.tag_enum_fields_countNumber of used Enum fields on tags of the template.The columns for each template file are described as follows:ColumnDescriptionrelative_resource_nameFull resource name of the asset the Entry refers to.linked_resourceFull name of the asset the Entry refers to.template_nameResource name of the Tag Template for the Tag.tag_nameResource name of the Tag.columnAttach Tags to a column belonging to the Entry schema.field_idId of the Tag field.field_typeType of the Tag field.field_valueValue of the Tag field.2.2. Run the datacatalog-tag-exporter scriptPython + virtualenvdatacatalog-tag-exportertagsexport--project-idsmy-project--dir-pathDIR_PATH2.2.1 Run the datacatalog-tag-exporter filtering Tag TemplatesPython + virtualenvdatacatalog-tag-exportertagsexport--project-idsmy-project\--dir-pathDIR_PATH\--tag-templates-namesprojects/my-project/locations/us-central1/tagTemplates/my-template,\projects/my-project/locations/us-central1/tagTemplates/my-template-2History0.1.0 (2020-04-15)First release on PyPI.0.2.0 (2020-05-08)Added option to export tags after creation date.