Skip to content
Last updated

REST API を使用したタグのリストと確認

タグのリストを表示し、詳細、ポリシー、カラム情報を含む各タグの使用状況を表示できます。

この記事には以下が含まれます:

Information情報
ポリシータグは、すべてのタグの詳細および使用状況リストで分離されていません。したがって、namespace: POLICY と namespace: RESOURCE は結果に統合されます。

タグのリスト

すべてのタグの詳細をリストして表示します。

$ curl --request GET "https://api-data-def-repo.treasuredata.com/v1/annotation-type/custom" \
       --header 'Authorization: TD1 ${6542/1120000023340000042320000016789000005438}'

サンプルレスポンス

{
  "data": [
    {
      "id": "2f27b00e-9377-419e-91c3-4456598c30a8",
      "attributes": {
        "name": "PII",
        "humanReadableName": "PII",
        "comment": null,
        "version": 1,
        "createdAt": "2021-05-20T22:10:32.872791Z",
        "updatedAt": "2021-05-20T22:10:32.872791Z",
        "color": "POLICY_DEFAULT",
        "namespace": "POLICY"
      },
      "type": "annotation-type"
    },
    {
      "id": "6d4ed012-9a68-4de4-820d-e9b70c22382e",
      "attributes": {
        "name": "KarinTag",
        "humanReadableName": "KarinTag",
        "comment": "",
        "version": 1,
        "createdAt": "2022-01-07T17:08:32.255631Z",
        "updatedAt": "2022-01-07T17:08:32.255631Z",
        "color": "RESOURCE_DEFAULT",
        "namespace": "RESOURCE"
      },
      "type": "annotation-type"
    },
    ....
  ]
}

各タグの使用状況を表示

各タグの使用状況を表示できます。次の例では、PII の使用状況を確認できます。

$ curl --request GET "https://api-data-def-repo.treasuredata.com/v1/column-annotation/lookup?annotationTypeName=PII" \
       --header 'Authorization: TD1 ${6542/1120000023340000042320000016789000005438}'

サンプルレスポンス

{
  "data": [
    {
      "id": "465302e6-67c0-4b33-9462-2f501c511601",
      "attributes": {
        "comment": "",
        "createdAt": "2021-09-30T07:40:01.792499Z",
        "sensitive": false
      },
      "relationships": {
        "annotation-type": {
          "data": {
            "type": "annotation-type",
            "id": "2f27b00e-9377-419e-91c3-4456598c30a8",
            "name": "PII"
          }
        },
        "table": {
          "data": {
            "type": "treasure-data-table",
            "id": "607222.3276426"
          }
        },
        "column": {
          "data": {
            "type": "treasure-data-column",
            "id": "dob"
          }
        },
        "created-by": {
          "data": {
            "type": "treasure-data-user",
            "id": "33648"
          }
        }
      },
      "type": "column-annotation"
    },
    ...
  ],
  "links": {
    "first": "/v1/column-annotation/lookup?annotationTypeName=PII",
    "self": "/v1/column-annotation/lookup?annotationTypeName=PII"
  },
  "meta": {
    "perPage": 250
  }
}

特定のプロジェクトのタグをリスト

クエリパラメータ filter[projectId] とともに GET コマンドを使用して、特定のプロジェクトのタグをリストできます。次の例では、ユーザーはプロジェクト 187725 のタグをリストするよう要求しています。

curl --request GET 'https://api-data-def-repo.treasuredata.com/v1/project-annotation?filter[projectId]=187725' \
     --header 'Authorization: TD1 ${6542/1120000023340000042320000016789000005438}'

サンプルレスポンス

レスポンスが明らかにするように、プロジェクト 187725 には2つのタグがあります: 4a45b1de-b27b-4414-92d6-4224490a50788afc7323-432c-46f8-bb19-b0cc4f5b8e77

{
    "data": [
        {
            "id": "4ad2008c-1019-4ced-8e53-74b155df0c0f",
            "attributes": {
                "comment": null,
                "createdAt": "2022-05-17T02:50:36.586640Z"
            },
            "relationships": {
                "annotation-type": {
                    "data": {
                        "type": "annotation-type",
                        "id": "4a45b1de-b27b-4414-92d6-4224490a5078",
                        "name": "seasonal-sales"
                    }
                },
                "project": {
                    "data": {
                        "type": "treasure-data-workflow-project",
                        "id": "187725"
                    }
                },
                "created-by": {
                    "data": {
                        "type": "treasure-data-user",
                        "id": "1273"
                    }
                }
            },
            "type": "project-annotation"
        },
        {
            "id": "57eef758-23d4-4236-add5-837e9f398c33",
            "attributes": {
                "comment": null,
                "createdAt": "2022-05-17T02:50:36.586640Z"
            },
            "relationships": {
                "annotation-type": {
                    "data": {
                        "type": "annotation-type",
                        "id": "8afc7323-432c-46f8-bb19-b0cc4f5b8e77",
                        "name": "online-sales"
                    }
                },
                "project": {
                    "data": {
                        "type": "treasure-data-workflow-project",
                        "id": "187725"
                    }
                },
                "created-by": {
                    "data": {
                        "type": "treasure-data-user",
                        "id": "1273"
                    }
                }
            },
            "type": "project-annotation"
        }
    ],
    "links": {
        "first": "/v1/project-annotation?filter%5BprojectId%5D=187725",
        "self": "/v1/project-annotation?filter%5BprojectId%5D=187725"
    },
    "meta": {
        "perPage": 250
    }
}