【问题标题】:Dataplex API Tag PoliciesDataplex API 标签策略
【发布时间】:2023-02-07 08:25:37
【问题描述】:

我正在 Google 文档中使用 Python 探索 Dataplex API,有获取 Lake、Zone、Assets 等的文档。我已经探索了该文档,但我没有找到任何与 Tag Policies 相关的文档,例如,我需要附加我的标签模板并通过 API 将政策标签添加到我的 BigQuery 表。

是否可以通过 API 附加标签模板并将策略标签添加到 BigQuery 表中?

这是我探索过的链接:

Dataplex API Service

Dataplex API Metadata Service

Data Catalog API

【问题讨论】:

    标签: python google-cloud-platform google-data-catalog google-dataplex


    【解决方案1】:

    【讨论】:

    • 您好,谢谢您的回答,这个Entry主要做什么?为什么我需要先创建条目?
    • 您好,基本上入门是先在数据目录中搜索对象,然后通过调用 createTagRequest 方法启用附加。我将详细回答我的步骤作为新答案。
    【解决方案2】:

    再次。

    为了模拟 pythonic api 的行为,我使用了 google cloud api explorer 来详细解释。见下文。

    条目查找是搜索要附加标签/标签模板的对象

    基本上这是我如何使用 api explorer 模拟 api 调用

    1. 要将标签附加到 BigQuery 表,第一步是使用下面的 Datacatalog api url 向上搜索表

      LookupEntryRequest

      我传递给下面的响应的参数是 sqlResource: "bigquery.table.myproject.zz_DataSet.tblOne"

      上面应该给你输出

      {
        "name": "projects/myproject/locations/australia-southeast2/entryGroups/@bigquery/entries/mykey",
        "type": "TABLE",
        "schema": {
          "columns": [
            {
              "type": "STRING",
              "mode": "NULLABLE",
              "column": "firstname"
            },
            {
              "type": "STRING",
              "mode": "NULLABLE",
              "column": "lastname"
            }
          ]
        },
        "sourceSystemTimestamps": {
          "createTime": "2023-01-16T04:22:49.397Z",
          "updateTime": "2023-01-16T04:22:49.397Z"
        },
        "linkedResource": "//bigquery.googleapis.com/projects/myproject/datasets/zz_DataSet/tables/tblOne",
        "bigqueryTableSpec": {
          "tableSourceType": "BIGQUERY_TABLE"
        },
        "usageSignal": {
          "updateTime": "2023-02-05T07:59:59.928Z",
          "usageWithinTimeRange": {
            "30D": {
              "totalCompletions": 7,
              "totalFailures": 1,
              "totalExecutionTimeForCompletionsMillis": 7385
            }
          }
        },
        "integratedSystem": "BIGQUERY",
        "fullyQualifiedName": "bigquery:myproject.zz_DataSet.tblOne"
      }
      

      搜索使您能够查询多个表或在数据集级别附加标签,请参阅上面链接中的参数部分。

      这就是为什么我建议您首先使用条目查找作为其更具可扩展性的代码。

      1. API 调用二:这就是我如何模拟附加标签到资源。如果你去下面的链接

      CreateTagRequest

      例如:我从控制台预先创建了一个标签模板,然后使用模板 ID 值作为参数传递给请求

      输入:

      parent: projects/myproject/locations/australia-southeast2/entryGroups/@bigquery/entries/mykey 来自上面的名称元素 请求正文:

      {
        "template": "projects/myproject/locations/australia-southeast1/tagTemplates/api_call_test_tag_template",
        "fields": {
          "name": {
            "stringValue": "apitestcall"
          }
        }
      }
      

      输出:下面是生成的响应,如果您在数据目录控制台中看到,您将看到 bigquery 表附加了标签模板,名称字段的值附加为“apitestcall”。见附件

      {
        "name": "projects/myproject/locations/australia-southeast2/entryGroups/@bigquery/entries/mykey/tags/tagsKey",
        "template": "projects/myproject/locations/australia-southeast1/tagTemplates/api_call_test_tag_template",
        "fields": {
          "name": {
            "displayName": "name",
            "stringValue": "apitestcall"
          }
        },
        "templateDisplayName": "api-call-test-tag-template"
      }
      

      最后,请务必确保您拥有此任务所需的所有正确 IAM 权限。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-09
      • 2023-01-03
      • 2020-12-29
      • 2023-01-30
      • 2014-06-02
      • 2021-01-16
      • 2013-08-30
      • 1970-01-01
      相关资源
      最近更新 更多