教學課程:Atlas 2.2 新功能

在本教學課程中,您將瞭解如何在 Microsoft Purview 中以程式設計方式與新的 Atlas 2.2 API 互動。

必要條件

商務中繼資料 API

商務中繼資料是一個範本,其中包含自訂屬性 (索引鍵值) 。 您可以全域建立這些屬性,然後將它們套用到多個 typedef。

Atlas 端點

針對所有要求,您需要 Microsoft Purview 帳戶的 Atlas 端點。

  1. 在Azure 入口網站中尋找您的 Microsoft Purview 帳戶
  2. 選取左側功能表上的 [ 屬性 ] 頁面
  3. 複製 Atlas 端點

Microsoft Purview 屬性頁面的螢幕擷取畫面,其中已醒目提示 [Atlas 端點] 方塊。

使用屬性建立商務中繼資料

您可以將要求傳送 POST 至下列端點:

POST {{endpoint}}/api/atlas/v2/types/typedefs

提示

applicableEntityTypes 屬性會指出中繼資料將套用至哪些資料類型。

範例 JSON:

   {
  "businessMetadataDefs": [
    {
      "category": "BUSINESS_METADATA",
      "createdBy": "admin",
      "updatedBy": "admin",
      "version": 1,
      "typeVersion": "1.1",
      "name": "<Name of Business Metadata>",
      "description": "",
      "attributeDefs": [
        {
          "name": "<Attribute Name>",
          "typeName": "string",
          "isOptional": true,
          "cardinality": "SINGLE",
          "isUnique": false,
          "isIndexable": true,
          "options": {
            "maxStrLength": "50",
            "applicableEntityTypes": "[\"Referenceable\"]"
          }          
        }
      ]
    }
  ]
}

將屬性加入或更新至現有的商務中繼資料

您可以將要求傳送 PUT 至下列端點:

PUT {{endpoint}}/api/atlas/v2/types/typedefs

範例 JSON:

   {
  "businessMetadataDefs": [
    {
      "category": "BUSINESS_METADATA",
      "createdBy": "admin",
      "updatedBy": "admin",
      "version": 1,
      "typeVersion": "1.1",
      "name": "<Name of Business Metadata>",
      "description": "",
      "attributeDefs": [
        {
          "name": "<Attribute Name>",
          "typeName": "string",
          "isOptional": true,
          "cardinality": "SINGLE",
          "isUnique": false,
          "isIndexable": true,
          "options": {
            "maxStrLength": "500",
            "applicableEntityTypes": "[\"Referenceable\"]"
          }          
        },
        {
          "name": "<Attribute Name 2>",
          "typeName": "int",
          "isOptional": true,
          "cardinality": "SINGLE",
          "isUnique": false,
          "isIndexable": true,
          "options": {
            "applicableEntityTypes": "[\"Referenceable\"]"
          }          
        }
      ]
    }
  ]
}

取得商務元資料定義

您可以將要求傳送 GET 至下列端點:

GET {endpoint}}/api/atlas/v2/types/typedef/name/{{Business Metadata Name}}

將商務中繼資料屬性設定為實體

您可以將要求傳送 POST 至下列端點:

POST {{endpoint}}/api/atlas/v2/entity/guid/{{GUID}}/businessmetadata?isOverwrite=true

範例 JSON:

{
  "myBizMetaData1": {
        "bizAttr1": "I am myBizMetaData1.bizAttr1",
        "bizAttr2": 123,
  }
 }

從實體刪除商務中繼資料屬性

您可以將要求傳送 DELETE 至下列端點:

'DELETE' {{endpoint}}/api/atlas/v2/entity/guid/{{GUID}}/businessmetadata?isOverwrite=true

範例 JSON:

{
  "myBizMetaData1": {
    "bizAttr1": ""    
  }
}

刪除商務元資料類型定義

注意事項

如果商務元資料類型定義沒有參考,也就是如果尚未指派給目錄中的任何資產,您才能刪除它。

您可以將要求傳送 DELETE 至下列端點:

DELETE {{endpoint}}/api/atlas/v2/types/typedef/name/{{Business Metadata Name}}

自訂屬性 API

自訂屬性是可直接新增至 Atlas 實體的索引鍵/值組。

將自訂屬性設定為實體

您可以將要求傳送 POST 至下列端點:

POST {{endpoint}}/api/atlas/v2/entity

範例 JSON:

{
    "entity": {
        "typeName": "azure_datalake_gen2_path",
        "attributes": {
           
            "qualifiedName": "<FQN of the asset>",
            "name": "data6.csv"
        },
        "guid": "3ffb28ff-138f-419e-84ba-348b0165e9e0",
        "customAttributes": {
            "custAttr1": "attr1",
            "custAttr2": "attr2"
        }
    }
}

標籤 API

標籤是可用的文字標記,可以套用至任何 Atlas 實體。

將標籤設定為實體

您可以將要求傳送 POST 至下列端點:

POST {{endpoint}}/api/atlas/v2/entity/guid/{{GUID}}/labels

範例 JSON:

[
  "label1",
  "label2"
]

刪除實體的標籤

您可以將要求傳送 DELETE 至下列端點:

DELETE {{endpoint}}/api/atlas/v2/entity/guid/{{GUID}}/labels

範例 JSON:

[
  "label2"
]

後續步驟