データ資産 (Azure Data Catalog REST API)

注釈

資産に注釈を付けます。

etag プロパティは省略可能であり、コンカレンシー制御に使用されます。

POST https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}/{nested_view_name}?api-version={api-version}

注意

一部の HTTP クライアント実装では、サーバーからの 302 に応答して要求を自動的に再発行できますが、通常は 要求から Authorization ヘッダー を削除します。 ADC に要求を行うには Authorization ヘッダーが必要であるため、ADC で指定されたリダイレクト場所に要求を再発行するときに、Authorization ヘッダーが引き続き提供されていることを確認する必要があります。 .NET HttpWebRequest オブジェクトを使用してこれを示すサンプル コードを次に示します。

URI パラメーター

名前 説明 データ型
catalog_name カタログの名前。既定のカタログを使用する "DefaultCatalog" です。 String
view_name データ資産ビューの名前。 String
view_item_id ビュー アイテムの ID。 String
nested_view_name 入れ子になったビュー アイテムの名前。 String
api-version API のバージョン。 String

例: エキスパートの追加

POST https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b0...1be45ecd462a/experts?api-version=2016-03-30
Content-Type: application/json
x-ms-client-request-id:   13d9f885…a92d-8a9f8cf9f707
Authorization: Bearer eyJ0eX ... FWSXfwtQ

本文

{
    "etag": "59085E253E2244A59F664A2F447E675E",
    "properties":
    {
        "fromSourceSystem": false,
        "key": "22c3fa019b3945dc97143ebc3ad74cbf--1111fa019b3945dc97143ebc3ad74cbf",
        "expert":
        {
            "upn": "expert1@contoso.com",
            "objectId": "1111fa019b3945dc97143ebc3ad74cbf"
        },
    }
}

例: 用語集の用語タグを追加する

POST https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b0...1be45ecd462a/termTags?api-version=2016-03-30

ヘッダー

Content-Type: application/json
x-ms-client-request-id:   13d9f885…a92d-8a9f8cf9f707
Authorization: Bearer eyJ0eX ... FWSXfwtQ

本文

{
    "etag": "59085E253E2244A59F664A2F447E675E",
    "properties":
    {
        "fromSourceSystem": false,
        "key": "22c3fa019b3945dc97143ebc3ad74cbf--1111fa019b3945dc97143ebc3ad74cbf",
        "termId": "https://test.catalog.com/catalogs/DefaultCatalog/glossaries/DefaultGlossary/terms/ed975c9d-2fb2-49a3-b6f2-222389cefd7e",
    }
}

例: 用語集の列用語タグを追加する

POST https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b0...1be45ecd462a/columnTermTags?api-version=2016-03-30

ヘッダー

Content-Type: application/json
x-ms-client-request-id:   13d9f885…a92d-8a9f8cf9f707
Authorization: Bearer eyJ0eX ... FWSXfwtQ

Body

{
    "etag": "59085E253E2244A59F664A2F447E675E",
    "properties":
    {
        "fromSourceSystem": false,
        "key": "22c3fa019b3945dc97143ebc3ad74cbf--1111fa019b3945dc97143ebc3ad74cbf",
        "columnName": "Col1",
        "termId": "https://test.catalog.com/catalogs/DefaultCatalog/glossaries/DefaultGlossary/terms/ed975c9d-2fb2-49a3-b6f2-222389cefd7e",
    }
}

Response

状態コード

コード 説明
201 作成されました。 要求が満たされ、新しい注釈が作成されました。
200 OK です。 既存の注釈が更新されました。
412 前提条件に失敗しました。 少なくとも 1 つの項目で ETag が一致しないため、要求が取り消されました。

Content-Type

application/json

ヘッダー

HTTP/1.1 201 Created
x-ms-request-id: 72cf83c0…058f2b2a0c68
Location: https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b0...1be45ecd462a/experts/22c3fa019b3945dc97143ebc3ad74cbf-1111fa019b3945dc97143ebc3ad74cbf

登録または更新

同じ ID を持つ資産が既に存在する場合は、新しいデータ資産を登録するか、既存のデータ資産を更新します。 項目には、必要に応じて ETag 値を含めて、オプティミスティック コンカレンシー制御を有効にすることができます。

GitHub でのサンプルの概要

Request

POST https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}?api-version={api-version}  

Note

一部の HTTP クライアント実装では、サーバーからの 302 に応答して要求を自動的に再発行できますが、通常は要求から Authorization ヘッダーを削除します。 ADC に要求を行うには Authorization ヘッダーが必要であるため、ADC で指定されたリダイレクト場所に要求を再発行するときに、Authorization ヘッダーが引き続き提供されていることを確認する必要があります。 .NET HttpWebRequest オブジェクトを使用してこれを示すサンプル コードを次に示します。

URI パラメーター

名前 説明 データ型
catalog_name カタログの名前。既定のカタログを使用する "DefaultCatalog" です。 String
view_name データ資産ビューの名前。 String
api-version API のバージョン。 String

POST 例

POST https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables?api-version=2016-03-30  

ヘッダー

Content-Type: application/json    
x-ms-client-request-id: 13c45c14…46ab469473f0    
Authorization: Bearer eyJ0eX ... FWSXfwtQ

本文の例

{  
    "roles": [  
        {  
            "role": "Contributor",  
            "members": [  
                {  
                    "objectId": "00000000-0000-0000-0000-000000000201"  
                }  
            ]  
        }  
    ],  
    "properties": {  
        "fromSourceSystem": true,  
        "name": "Orders",  
        "dataSource": {  
            "sourceType": "SQL Server",  
            "objectType": "Table"  
        },  
        "dsl": {  
            "protocol": "tds",  
            "authentication": "windows",  
            "address": {  
                "server": "MyServer.contoso.com",  
                "database": "NORTHWND",  
                "schema": "dbo",  
                "object": "Orders"  
            }  
        },  
        "lastRegisteredBy": {  
            "upn": "user1@contoso.com",  
            "firstName": "User1FirstName",  
            "lastName": "User1LastName"  
        },  
        "containerId": "containers/3b2c00be-...-1f15367f54e4"  
    },  
    "annotations": {  
        "schema": {  
            "roles": [  
                {  
                    "role": "Contributor",  
                    "members": [  
                        {  
                            "objectId": "00000000-0000-0000-0000-000000000201"  
                        }  
                    ]  
                }  
            ],  
            "properties": {  
                "fromSourceSystem": true,  
                "columns": [  
                    {  
                        "name": "OrderID",  
                        "isNullable": false,  
                        "type": "int",  
                        "maxLength": 4,  
                        "precision": 10  
                    },  
                    {  
                        "name": "CustomerID",  
                        "isNullable": true,  
                        "type": "nchar",  
                        "maxLength": 10,  
                        "precision": 0  
                    },  
                    {  
                        "name": "EmployeeID",  
                        "isNullable": true,  
                        "type": "int",  
                        "maxLength": 4,  
                        "precision": 10  
                    },  
                    {  
                        "name": "OrderDate",  
                        "isNullable": true,  
                        "type": "datetime",  
                        "maxLength": 8,  
                        "precision": 23  
                    }  
                ]  
            }  
        }  
    }  
}  

Response

状態コード

コード 説明
200 OK です。 既存の資産が更新されました。
201 作成されました。 要求が満たされ、新しい資産が作成されました。
412 前提条件に失敗しました。 少なくとも 1 つの項目で ETag が一致しないため、要求が取り消されました。

Content-Type

application/json

ヘッダー

HTTP/1.1 201 Created  
x-ms-request-id: 72cf83c0…058f2b2a0c68  
Location: https://e2255231-6dd3-1a0d-a6d8-7fc96dd780c2-mycatalog.api.azuredatacatalog.com/catalogs/MyCatalog/views/tables/042297b0…1be45ecd462a  

サポートされるデータ ソース

現在サポートされているデータ ソース オブジェクトの一覧については、Azure Data Catalogサポートされているデータ ソースに関するページを参照してください。

この例では、Azure AD アクセス トークンを取得し、 Register 操作を実行する方法を示します。

メモこの例では、DefaultCatalog キーワード (keyword)を使用して、ユーザーの既定のカタログを更新します。 実際のカタログ名を指定することもできます。 カタログ名を見つけるには、Azure Data Catalogにサインインし、[ユーザー] を選択しますカタログ名が表示されます。

using System;  
using System.Net;  
using Microsoft.IdentityModel.Clients.ActiveDirectory;  
using System.IO;  

...  

//To learn how to register a client app and get a Client ID,  
// see https://msdn.microsoft.com/library/azure/mt403303.aspx#clientID  
static string clientIDFromAzureAppRegistration = "{clientID}";  

static void Main(string[] args)  
{  
    //Note: This example uses the "DefaultCatalog" keyword to update the user's default catalog.  You may alternately  
    //specify the actual catalog name.  
    string catalogName = "DefaultCatalog";  

    string registerJson = Register(catalogName, OrdersJsonWithEveryoneContributor());  

    Console.ReadLine();  
}  

static AuthenticationResult AccessToken()  
{  
    //Get access token:  
    // To call a Data Catalog REST operation, create an instance of AuthenticationContext and call AcquireToken  
    // AuthenticationContext is part of the Active Directory Authentication Library NuGet package  
    // To install the Active Directory Authentication Library NuGet package in Visual Studio,  
    //  run "Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory" from the nuget Package Manager Console.  

    //Resource Uri for Data Catalog API  
    string resourceUri = "https://api.azuredatacatalog.com";  

    //To learn how to register a client app and get a Client ID, see https://msdn.microsoft.com/library/azure/mt403303.aspx#clientID     
    string clientId = clientIDFromAzureAppRegistration;  

    //A redirect uri gives AAD more details about the specific application that it will authenticate.  
    //Since a client app does not have an external service to redirect to, this Uri is the standard placeholder for a client app.  
    string redirectUri = "https://login.live.com/oauth20_desktop.srf";  

    // Create an instance of AuthenticationContext to acquire an Azure access token  
    // OAuth2 authority Uri  
    string authorityUri = "https://login.windows.net/common/oauth2/authorize";  
    AuthenticationContext authContext = new AuthenticationContext(authorityUri);  

    // Call AcquireToken to get an Azure token from Azure Active Directory token issuance endpoint  
    //  AcquireToken takes a Client Id that Azure AD creates when you register your client app.  
    return authContext.AcquireToken(resourceUri, clientId, new Uri(redirectUri), PromptBehavior.RefreshSession);  
}  

static string Register(string catalogName, string json)  
{  
    string location = string.Empty;  
    string fullUri = string.Format("https://api.azuredatacatalog.com/catalogs/{0}/views/{1}?api-version=2016-03-30", catalogName, viewType);  

    //Create a POST WebRequest as a Json content type  
    HttpWebRequest request = System.Net.WebRequest.Create(fullUri) as System.Net.HttpWebRequest;  
    request.KeepAlive = true;  
    request.Method = "POST";  
    try  
    {  
        var response = SetRequestAndGetResponse(request, json);  

        //Get the Response header which contains the data asset ID  
        //The format is: tables/{data asset ID}  
        location = httpWebResponse.Headers["Location"];  
    }  
    catch (WebException ex)  
    {  
        Console.WriteLine(ex.Message);  
        Console.WriteLine(ex.Status);  
        if (ex.Response != null)  
        {  
            // can use ex.Response.Status, .StatusDescription  
            if (ex.Response.ContentLength != 0)  
            {  
                using (var stream = ex.Response.GetResponseStream())  
                {  
                    using (var reader = new StreamReader(stream))  
                    {  
                        Console.WriteLine(reader.ReadToEnd());  
                    }  
                }  
            }  
        }  
        location = null;  
    }  
    return location;  
}  

static HttpWebResponse SetRequestAndGetResponse(HttpWebRequest request, string payload = null)  
{  
    while (true)  
    {  
        //To authorize the operation call, you need an access token which is part of the Authorization header  
        request.Headers.Add("Authorization", AccessToken().CreateAuthorizationHeader());  
        //Set to false to be able to intercept redirects  
        request.AllowAutoRedirect = false;  

        if (!string.IsNullOrEmpty(payload))  
        {  
            byte[] byteArray = Encoding.UTF8.GetBytes(payload);  
            request.ContentLength = byteArray.Length;  
            request.ContentType = "application/json";  
            //Write JSON byte[] into a Stream  
            request.GetRequestStream().Write(byteArray, 0, byteArray.Length);  
        }  
        else  
        {  
            request.ContentLength = 0;  
        }  

        HttpWebResponse response = request.GetResponse() as HttpWebResponse;  

        // Requests to **Azure Data Catalog (ADC)** may return an HTTP 302 response to indicate  
        // redirection to a different endpoint. In response to a 302, the caller must re-issue  
        // the request to the URL specified by the Location response header.  
        if (response.StatusCode == HttpStatusCode.Redirect)  
        {  
            string redirectedUrl = response.Headers["Location"];  
            HttpWebRequest nextRequest = WebRequest.Create(redirectedUrl) as HttpWebRequest;  
            nextRequest.Method = request.Method;  
            request = nextRequest;  
        }  
        else  
        {  
            return response;  
            break;  
        }  
    }  
}  

static string OrdersJsonWithEveryoneContributor()  
{  
    return @"  
    {  
        'roles': [  
            {  
                'role': 'Contributor',  
                'members': [  
                    {  
                        'objectId': '00000000-0000-0000-0000-000000000201'  
                    }  
                ]  
            }  
        ],  
        'properties': {  
            'fromSourceSystem': 'true',  
            'name': 'Orders',  
            'dataSource': {  
                'sourceType': 'SQL Server',  
                'objectType': 'Table'  
            },  
            'dsl': {  
                'protocol': 'tds',  
                'authentication': 'windows',  
                'address': {  
                    'server': 'MyServer.contoso.com',  
                    'database': 'NORTHWND',  
                    'schema': 'dbo',  
                    'object': 'Orders'  
                }  
            },  
            'lastRegisteredBy': {  
                'upn': 'user1@contoso.com',  
                'firstName': 'User1FirstName',  
                'lastName': 'User1LastName'  
            },  
            'containerId': 'containers/a9f8a2e1-d826-7c0c-b186-c7f4334a6b4f'  
        },  
        'annotations': {  
            'schema': {  
                'roles': [  
                    {  
                        'role': 'Contributor',  
                        'members': [  
                            {  
                                'objectId': '00000000-0000-0000-0000-000000000201'  
                            }  
                        ]  
                    }  
                ],  
                'properties': {  
                    'fromSourceSystem': 'true',  
                    'columns': [  
                        {  
                            'name': 'OrderID',  
                            'isNullable': false,  
                            'type': 'int',  
                            'maxLength': 4,  
                            'precision': 10  
                        },  
                        {  
                            'name': 'CustomerID',  
                            'isNullable': true,  
                            'type': 'nchar',  
                            'maxLength': 10,  
                            'precision': 0  
                        },  
                        {  
                            'name': 'EmployeeID',  
                            'isNullable': true,  
                            'type': 'int',  
                            'maxLength': 4,  
                            'precision': 10  
                        },  
                        {  
                            'name': 'OrderDate',  
                            'isNullable': true,  
                            'type': 'datetime',  
                            'maxLength': 8,  
                            'precision': 23  
                        }  
                    ]  
                }  
            }  
        }  
    }";  
}  

注釈を使用して取得する

注釈を含むデータ資産を取得します。

すべての項目の応答に ETag を含めるよう要求する省略可能な Accept ヘッダー パラメーター adc.metadata がサポートされています。 応答で ETag を取得するには、最小値または完全な値を使用します。 有効な値は、noneminimalfull です。

Request

GET https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}?api-version={api-version}  

Note

一部の HTTP クライアント実装では、サーバーからの 302 に応答して要求を自動的に再発行できますが、通常は 要求から Authorization ヘッダー を削除します。 ADC に要求を行うには Authorization ヘッダーが必要であるため、ADC で指定されたリダイレクト場所に要求を再発行するときに、Authorization ヘッダーが引き続き提供されていることを確認する必要があります。 .NET HttpWebRequest オブジェクトを使用してこれを示すサンプル コードを次に示します。

URI パラメーター

名前 説明 データ型
catalog_name カタログの名前。既定のカタログを使用する "DefaultCatalog" です。 String
view_name データ資産ビューの名前。 String
view_item_id ビュー アイテムの ID。 String
api-version API のバージョン。 String

GET の例

GET https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b...1be45ecd462a?api-version=2016-03-30  

ヘッダー

x-ms-client-request-id: 8091955f…8f5b4c0acede    
Authorization:  Bearer eXJ0eyAiOiJKV1QiLCJhbGciOi...    
Accept: application/json;adc.metadata=full  

Response

状態コード

コード 説明
200 OK です。 応答には、要求された資産ビューが含まれています。

Content-Type

application/json

ヘッダー

x-ms-request-id: 1095e88c…caffabd6dabd  
Content-Type:   application/json; charset=utf-8

本文

{  
    "id": "https://e2255231-6dd3-1a0d-a6d8-7fc96dd780c2-mycatalog.api.azuredatacatalog.com/catalogs/MyCatalog/views/tables/042297b0-...-1be45ecd462a",  
    "etag": "1234567891",  
    "timestamp": "2015-05-15T03:48:39.2425547",  
    "roles": [  
        {  
            "role": "Contributor",  
            "members": [  
                {  
                    "objectId": "00000000-0000-0000-0000-000000000201"  
                }  
            ]  
        }  
    ],  
    "effectiveRights": [  
        "Read",  
        "Delete",  
        "ChangeOwnership",  
        "ChangeVisibility",  
        "ViewPermissions",  
        "ViewRoles",  
        "Update",  
        "TakeOwnership"  
    ],  
    "properties": {  
        "fromSourceSystem": true,  
    "name": "Orders",  
    "dataSource": {  
        "sourceType": "SQL Server",  
            "objectType": "Table"  
    },  
    "dsl": {  
        "protocol": "tds",  
        "authentication": "windows",  
        "address": {  
            "server": "MyServer.contoso.com",  
            "database": "NORTHWND",  
            "schema": "dbo",  
            "object": "Orders"  
        }  
    },  
    "lastRegisteredBy": {  
        "upn": "user1@contoso.com",  
        "firstName": "User1FirstName",  
        "lastName": "User1LastName"  
    },  
        "containerId": "containers/3b2c00be-...-1f15367f54e4"  
    },  
    "annotations": {  
        "schema": {  
            "id": "https://e2255231-6dd3-1a0d-a6d8-7fc96dd780c2-mycatalog.api.azuredatacatalog.com/catalogs/MyCatalog/views/tables/042297b0-...-1be45ecd462a/schema",  
            "etag": "1234567892",  
            "timestamp": "2015-05-15T03:48:39.2425547",  
            "roles": [  
                {  
                    "role": "Contributor",  
                    "members": [  
        {  
                            "objectId": "00000000-0000-0000-0000-000000000201"  
                        }  
                    ]  
                }  
            ],  
            "effectiveRights": [  
                    "Read",  
                    "Delete",  
                    "ViewRoles",  
                    "Update"  
                ],  
            "properties": {  
                "fromSourceSystem": true,  
            "columns": [  
                {  
                    "name": "OrderID",  
                    "isNullable": false,  
                    "type": "int",  
                    "maxLength": 4,  
                    "precision": 10  
                },  
                {  
                    "name": "CustomerID",  
                    "isNullable": true,  
                    "type": "nchar",  
                    "maxLength": 10,  
                    "precision": 0  
                },  
                {  
                    "name": "EmployeeID",  
                    "isNullable": true,  
                    "type": "int",  
                    "maxLength": 4,  
                    "precision": 10  
                },  
                {  
                    "name": "OrderDate",  
                    "isNullable": true,  
                    "type": "datetime",  
                    "maxLength": 8,  
                    "precision": 23  
                }  
                ]  
        }  
        },  
    "experts": [  
        {  
                "id": "https://e2255231-6dd3-1a0d-a6d8-7fc96dd780c2-mycatalog.api.azuredatacatalog.com/catalogs/MyCatalog/views/tables/042297b0-...-1be45ecd462a/experts/22c3fa019b3945dc97143ebc3ad74cbf-1111fa019b3945dc97143ebc3ad74cbf",  
                "etag": "1234567893",  
                "timestamp": "2015-05-15T03:48:39.2425547",  
                "roles": [  
                    {  
                        "role": "Contributor",  
                        "members": [  
                            {  
                                "objectId": "22c3fa01-9b39-45dc-9714-3ebc3ad74cbf"  
                            }  
                        ]  
                    }  
                ],  
                "effectiveRights": [  
                    "Read",  
                    "Delete",  
                    "ViewRoles",  
                    "Update"  
                ],  
                "properties": {  
                    "fromSourceSystem": false,  
                    "key": "22c3fa019b3945dc97143ebc3ad74cbf-1111fa019b3945dc97143ebc3ad74cbf",  
                    "expert": {  
                        "upn": "expert1@contoso.com",  
                        "objectId": "1111fa019b3945dc97143ebc3ad74cbf"  
                    }  
                }  
        }  
    ]  
}  
}

指定された検索語句に基づいて、データ資産を検索します。

Request

GET https://api.azuredatacatalog.com/catalogs/{catalog_name}/search/search?api-version={api-version}&searchTerms={search_terms}&facets={facet_terms}&startPage={start_page}&count={count}&view={data_source}  

Note

一部の HTTP クライアント実装では、サーバーからの 302 に応答して要求を自動的に再発行できますが、通常は 要求から Authorization ヘッダー を削除します。 ADC に要求を行うには Authorization ヘッダーが必要であるため、ADC で指定されたリダイレクト場所に要求を再発行するときに、Authorization ヘッダーが引き続き提供されていることを確認する必要があります。 .NET HttpWebRequest オブジェクトを使用してこれを示すサンプル コードを次に示します。

URI パラメーター

名前 説明 データ型
catalog_name カタログの名前。既定のカタログを使用する "DefaultCatalog" です。 String
api-version API のバージョン。 String

クエリ パラメーター

名前 説明 データ型
searchTerms 必須。 検索対象の用語。 String
ファセット 省略可能 結果をファセットするコンマ区切りのフィールド名。 String
startPage Count パラメーターと共にページングに使用される結果の省略可能な開始ページ。 使用できる値が 0 より大きい場合、0 以下の値が渡されると、エラー コード 400 の HTTP エラーが返されます。 String
count オプション 1 ページで必要な結果の数 (ページング)。 既定値は 10 です。 使用できる値は、1 から 100 までの間隔です。 この範囲外の値が渡されると、エラー コード 400 の HTTP エラーが返されます。 検索結果の次の部分を取得するには、要求を繰り返しますが、startPage を 1 ずつ増やします。 Integer
ビュー 省略可能 クライアントが表示するビューを取得します。現時点では、DataSource でサポートされている唯一のオプションです。 String

GET の例

https://api.azuredatacatalog.com/catalogs/DefaultCatalog/search/search?searchTerms=My_Server&count=10&startPage=1&api-version=2016-03-30

ヘッダー

x-ms-client-request-id: 546f053a…a1612f3a3d69  
Authorization:  Bearer eXJ0eyAiOiJKV1QiLCJhbGciOi...  

Response

状態コード

コード 説明
200 OK です。 検索結果を含む正常な操作。

Content-Type

application/json

ヘッダー

x-ms-request-id: 0ab2e798…088223257ad2  
Content-Length:  3926

本文

{  
"query": {  
    "id": "bd067219...4ba9a56e204b",  
    "searchTerms": "My_server",  
    "startIndex": 1,  
    "startPage": 1,  
    "count": 1,  
    "id": "bd067219...4ba9a56e204b",  
    "totalResults": 508,  
    "startIndex": 1,  
    "itemsPerPage": 1,  
    "results": [{  
    "updated": "0001-01-01T00:00:00",  
    "content": {  
          "properties": {  
            "fromSourceSystem": true,  
            "name": "MyTable",  
            "dsl": {  
              "protocol": "tds",  
              "authentication": "windows",  
              "address": {  
                "server": "My_SERVER",  
                "database": "my_DB",  
                "schema": "my_SCHEMA",  
                "object": "my_TABLE"  
              }  
            },  
            "dataSource": {  
              "sourceType": "SQL Server",  
              "objectType": "Table"  
            },  
            "lastRegisteredBy": {  
              "upn": "user1@contoso.com",  
              "firstName": "User1FirstName",  
              "lastName": "User1LastName"  
            },  
            "containerId": "https://e2255231-6dd3-1a0d-a6d8-7fc96dd780c2-mycatalog.api.azuredatacatalog.com/catalogs/MyCatalog/views/containers/a9f8a2e1-d826-7c0c-b186-c7f4334a6b4f"  
          },  
          "id": "https://e2255231-6dd3-1a0d-a6d8-7fc96dd780c2-mycatalog.api.azuredatacatalog.com/catalogs/MyCatalog/views/tables/08d91f0d-26a0-1e8e-ab3b-d463ac3e62cb",  
          "type": "Microsoft.DataSource.Table.1",  
          "timestamp": "2016-03-15T23:20:12.5423855",  
          "annotations": {  
            "schema": {  
              "properties": {  
                "fromSourceSystem": true,  
                "columns": [  
                  {  
                    "name": "ID",  
                    "type": "int",  
                    "maxLength": 4,  
                    "precision": 10,  
                    "isNullable": false  
                  },  
                  {  
                    "name": "Column2",  
                    "type": "nchar",  
                    "maxLength": 10,  
                    "precision": 0,  
                    "isNullable": true  
                  }  
                ]  
              },  
              "id": "https://e2255231-6dd3-1a0d-a6d8-7fc96dd780c2-mycatalog.api.azuredatacatalog.com/catalogs/MyCatalog/views/tables/08d91f0d-26a0-1e8e-ab3b-d463ac3e62cb/schema",  
              "type": "Microsoft.DataSource.Schema.1",  
              "timestamp": "2016-03-15T23:20:12.5423855",  
              "roles": [  
                {  
                  "role": "Contributor",  
                  "members": [  
                    {  
                      "objectId": "00000000-0000-0000-0000-000000000201"  
                    }  
                  ]  
                }  
              ],  
              "effectiveRights": [  
                "Read",  
                "Delete",  
                "ViewRoles",  
                "Update"  
              ]  
            }  
          },  
          "roles": [  
            {  
              "role": "Contributor",  
              "members": [  
                {  
                  "objectId": "00000000-0000-0000-0000-000000000201"  
                }  
              ]  
            }  
          ],  
          "effectiveRights": [  
            "Read",  
            "Delete",  
            "ChangeOwnership",  
            "ChangeVisibility",  
            "ViewPermissions",  
            "ViewRoles",  
            "Update",  
            "TakeOwnership"  
          ]  
        },  
    "hitProperties": [{  
        "fieldPath": "properties.dsl.address.server",  
        "highlightDetail": [{  
            "highlightedWords": [{  
                "word": "My_sERVER"  
            }],  
            "highlightedFragment": "My_sERVER"  
        }]  
    },  
    {  
        "fieldPath": "properties.dataSource.sourceType",  
        "highlightDetail": [{  
            "highlightedWords": [{  
                "word": "Server"  
            }],  
            "highlightedFragment": "SQL Server"  
        }]  
    },  
    {  
        "fieldPath": "properties.dsl.address.object",  
        "highlightDetail": [{  
            "highlightedWords": [{  
                "word": "my"  
            }],  
            "highlightedFragment": "my_TABLE"  
        }]  
    },  
    {  
        "fieldPath": "properties.dsl.address.database",  
        "highlightDetail": [{  
            "highlightedWords": [{  
                "word": "my"  
            }],  
            "highlightedFragment": "my_DB"  
        }]  
    },  
    {  
        "fieldPath": "properties.dsl.address.schema",  
        "highlightDetail": [{  
            "highlightedWords": [{  
                "word": "my"  
            }],  
            "highlightedFragment": "my_SCHEMA"  
        }]  
    }]  
}]  
}

この例では、Azure AD アクセス トークンを取得し、 検索 操作を実行する方法を示します。

メモカタログ名を見つけるには、Azure Data Catalogにサインインし、[ユーザー] を選択しますカタログ名が表示されます。

using System;  
using System.Net;  
using Microsoft.IdentityModel.Clients.ActiveDirectory;  
using System.IO;  

...  

//To learn how to register a client app and get a Client ID,  
// see https://msdn.microsoft.com/library/azure/mt403303.aspx#clientID  
static string clientIDFromAzureAppRegistration = "{clientID}";  

static void Main(string[] args)  
{  
    //Note: This example uses the "DefaultCatalog" keyword to update the user's default catalog.  You may alternately  
    //specify the actual catalog name.  
    string catalogName = "DefaultCatalog";  

    //Search everything  
    string searchTerm = string.Empty;  

    string searchJson = Search(catalogName, searchTerm);  
    //Other examples "tags:=Sales", "upn:{username}"  

    Console.WriteLine(searchJson);  
}  

static AuthenticationResult AccessToken()  
{  
    //Get access token:  
    // To call a Data Catalog REST operation, create an instance of AuthenticationContext and call AcquireToken  
    // AuthenticationContext is part of the Active Directory Authentication Library NuGet package  
    // To install the Active Directory Authentication Library NuGet package in Visual Studio,  
    //  run "Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory" from the nuget Package Manager Console.  

    //Resource Uri for Data Catalog API  
    string resourceUri = "https://api.azuredatacatalog.com";  

    //To learn how to register a client app and get a Client ID, see https://msdn.microsoft.com/library/azure/mt403303.aspx#clientID    
    string clientId = clientIDFromAzureAppRegistration;  

    //A redirect uri gives AAD more details about the specific application that it will authenticate.  
    //Since a client app does not have an external service to redirect to, this Uri is the standard placeholder for a client app.  
    string redirectUri = "https://login.live.com/oauth20_desktop.srf";  

    // Create an instance of AuthenticationContext to acquire an Azure access token  
    // OAuth2 authority Uri  
    string authorityUri = "https://login.windows.net/common/oauth2/authorize";  
    AuthenticationContext authContext = new AuthenticationContext(authorityUri);  

    // Call AcquireToken to get an Azure token from Azure Active Directory token issuance endpoint  
    //  AcquireToken takes a Client Id that Azure AD creates when you register your client app.  
    return authContext.AcquireToken(resourceUri, clientId, new Uri(redirectUri), PromptBehavior.RefreshSession);  
}  

static string Search(string catalogName, string searchTerm)  
{  
    string responseContent = string.Empty;  

    //NOTE: To find the Catalog Name, sign into Azure Data Catalog, and choose User. You will see a list of Catalog names.            
    string fullUri =  
        string.Format("https://api.azuredatacatalog.com/catalogs/{0}/search/search?searchTerms={1}&count=10&api-version=2016-03-30", catalogName, searchTerm);  

    //Create a GET WebRequest  
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fullUri);  
    request.Method = "GET";  

    try  
    {  
        //Get HttpWebResponse from GET request  
        using (HttpWebResponse httpResponse = SetRequestAndGetResponse(request))  
        {  
            //Get StreamReader that holds the response stream  
            using (StreamReader reader = new System.IO.StreamReader(httpResponse.GetResponseStream()))  
            {  
                responseContent = reader.ReadToEnd();  
            }  
        }  
    }  
    catch (WebException ex)  
    {  
        Console.WriteLine(ex.Message);  
        Console.WriteLine(ex.Status);  
        if (ex.Response != null)  
        {  
            // can use ex.Response.Status, .StatusDescription  
            if (ex.Response.ContentLength != 0)  
            {  
                using (var stream = ex.Response.GetResponseStream())  
                {  
                    using (var reader = new StreamReader(stream))  
                    {  
                        Console.WriteLine(reader.ReadToEnd());  
                    }  
                }  
            }  
        }  
        return null;  
    }  

    return responseContent;  
}  

static HttpWebResponse SetRequestAndGetResponse(HttpWebRequest request, string payload = null)  
{  
    while (true)  
    {  
        //To authorize the operation call, you need an access token which is part of the Authorization header  
        request.Headers.Add("Authorization", AccessToken().CreateAuthorizationHeader());  
        //Set to false to be able to intercept redirects  
        request.AllowAutoRedirect = false;  

        if (!string.IsNullOrEmpty(payload))  
        {  
            byte[] byteArray = Encoding.UTF8.GetBytes(payload);  
            request.ContentLength = byteArray.Length;  
            request.ContentType = "application/json";  
            //Write JSON byte[] into a Stream  
            request.GetRequestStream().Write(byteArray, 0, byteArray.Length);  
        }  
        else  
        {  
            request.ContentLength = 0;  
        }  

        HttpWebResponse response = request.GetResponse() as HttpWebResponse;  

        // Requests to **Azure Data Catalog (ADC)** may return an HTTP 302 response to indicate  
        // redirection to a different endpoint. In response to a 302, the caller must re-issue  
        // the request to the URL specified by the Location response header.    
        if (response.StatusCode == HttpStatusCode.Redirect)  
        {  
            string redirectedUrl = response.Headers["Location"];  
            HttpWebRequest nextRequest = WebRequest.Create(redirectedUrl) as HttpWebRequest;  
            nextRequest.Method = request.Method;  
            request = nextRequest;  
        }  
        else  
        {  
            return response;  
            break;  
        }  
    }  
}

削除

データ資産と、それにアタッチされているすべての注釈 (存在する場合) を削除します。

オプティミスティック コンカレンシー制御用の省略可能な If-Match ヘッダーがサポートされています。 W/"123456789" などの弱い形式のみがサポートされています。

Request

DELETE https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}?api-version={api-version}  

Note

一部の HTTP クライアント実装では、サーバーからの 302 に応答して要求を自動的に再発行できますが、通常は 要求から Authorization ヘッダー を削除します。 ADC に要求を行うには Authorization ヘッダーが必要であるため、ADC で指定されたリダイレクト場所に要求を再発行するときに、Authorization ヘッダーが引き続き提供されていることを確認する必要があります。 .NET HttpWebRequest オブジェクトを使用してこれを示すサンプル コードを次に示します。

URI パラメーター

名前 説明 データ型
catalog_name カタログの名前。既定のカタログを使用する "DefaultCatalog" です。 String
view_name データ資産ビューの名前。 String
view_item_id ビュー アイテムの ID。 String
api-version API のバージョン。 String

DELETE の例

DELETE https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b0...1be45ecd462a?api-version=2016-03-30

ヘッダー

x-ms-client-request-id: 59b68a46…46dc3ec8dcb8    
Authorization:  Bearer eXJ0eyAiOiJKV1QiLCJhbGciOi...    
If-Match: W/"123456789"  

Response

状態コード

コード 説明
204 NoContent
: 削除操作のセマンティックは "存在する場合は削除" であるため、資産または注釈が存在しない場合は成功状態コード 204 (NoContent) が返されます。
412 前提条件に失敗しました。 ETag の不一致が原因で要求が取り消されました。

Content-Type

application/json

ヘッダー

x-ms-request-id: 664f86cf…5e512fa78e92  

注釈の更新

注釈を更新します。

項目には、必要に応じて ETag 値を含めて、オプティミスティック コンカレンシー制御を有効にすることができます。

Request

PUT https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}/{nested_view_name}/{nested_non_singleton_view_item_id}?api-version={api-version} 
 
PUT https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}/{nested_view_name}?api-version={api-version}  

Note

一部の HTTP クライアント実装では、サーバーからの 302 に応答して要求を自動的に再発行できますが、通常は 要求から Authorization ヘッダー を削除します。 ADC に要求を行うには Authorization ヘッダーが必要であるため、ADC で指定されたリダイレクト場所に要求を再発行するときに、Authorization ヘッダーが引き続き提供されていることを確認する必要があります。 .NET HttpWebRequest オブジェクトを使用してこれを示すサンプル コードを次に示します。

URI パラメーター

名前 説明 データ型
catalog_name カタログの名前。既定のカタログを使用する "DefaultCatalog" です。 String
view_name データ資産ビューの名前。 String
view_item_id ビュー アイテムの ID。 String
nested_view_name 入れ子になったビューの名前。 String
nested_non_singleton_view_item_id 入れ子になった非シングルトン ビュー項目の ID。 シングルトン以外のビューに対して指定する必要があります。 String
api-version API のバージョン。 String

シングルトン ドキュメント ビューの PUT の例

PUT https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b0...1be45ecd462a/documentation?api-version=2016-03-30

ヘッダー

Content-Type:   application/json; charset=utf-8    
x-ms-client-request-id:   059692ee-...-57490fcec42c    
Authorization:  Bearer eXJ0eyAiOiJKV1QiLCJhbGciOi...  

ボディ スキーマ

Body:  
    {  
        "fromSourceSystem": false,  
        "etag": "123456789",  
        "content": "<new documentation content>",  
        "mimetype": "text",  
    }  

Response

状態コード

コード 説明
200 OK です。 既存の注釈が更新されました。
412 前提条件に失敗しました。 少なくとも 1 つの項目で ETag が一致しないため、要求が取り消されました。

Content-Type

application/json

ヘッダー

x-ms-request-id: 3b8668da…1558d0f407c0  

注釈の削除

注釈とすべての入れ子になった注釈 (存在する場合) を削除します。

オプティミスティック コンカレンシー制御用の省略可能な If-Match ヘッダーがサポートされています。 W/"123456789" などの弱い形式のみがサポートされています。

Request

DELETE https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}/{nested_view_name}/{nested_non_singleton_view_item_id}?api-version={api-version}  
	
DELETE https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}/{nested_view_name}?api-version={api-version}  

Note

一部の HTTP クライアント実装では、サーバーからの 302 に応答して要求を自動的に再発行できますが、通常は 要求から Authorization ヘッダー を削除します。 ADC に要求を行うには Authorization ヘッダーが必要であるため、ADC で指定されたリダイレクト場所に要求を再発行するときに、Authorization ヘッダーが引き続き提供されていることを確認する必要があります。 .NET HttpWebRequest オブジェクトを使用してこれを示すサンプル コードを次に示します。

URI パラメーター

名前 説明 データ型
catalog_name カタログの名前。既定のカタログを使用する "DefaultCatalog" です。 String
view_name データ資産ビューの名前。 String
view_item_id ビュー アイテムの ID。 String
nested_view_name 入れ子になったビューの名前。 String
nested_non_singleton_view_item_id 入れ子になった非シングルトン ビュー項目の ID。 シングルトンビュー以外のビューに対して指定する必要があります。 String
api-version API のバージョン。 String

DELETE の例

DELETE https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b0-c187-49cc-8f30-1be45ecd462a/experts/22c3fa019b3945dc97143ebc3ad74cbf-1111fa019b3945dc97143ebc3ad74cbf?api-version=2016-03-30  

ヘッダー

x-ms-client-request-id:   c8da5f08…67b203d77b2d  
Authorization:  Bearer eXJ0eyAiOiJKV1QiLCJhbGciOi...  
If-Match: W/"123456789"  

Response

状態コード

コード 説明
204 NoContent
412 前提条件に失敗しました。 ETag の不一致が原因で要求が取り消されました。

Content-Type

application/json

ヘッダー

x-ms-request-id: 276b9dc4…e5f7017805c