你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
数据资产 (Azure 数据目录 REST API)
Annotate
对资产进行注释。
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 发出请求需要授权标头,因此必须确保在向 ADC 指定的重定向位置重新发出请求时仍提供授权标头。 下面是使用 .NET HttpWebRequest 对象演示这一点的示例代码。
URI 参数
名称 | 说明 | 数据类型 |
---|---|---|
catalog_name | 目录的名称,或“DefaultCatalog”以使用默认目录。 | 字符串 |
view_name | 数据资产视图的名称。 | 字符串 |
view_item_id | 视图项的 ID。 | 字符串 |
nested_view_name | 嵌套视图项的名称。 | 字符串 |
api-version | API 版本。 | 字符串 |
示例:添加专家
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
正文
{
"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",
}
}
响应
状态代码
代码 | 说明 |
---|---|
201 | Created. 请求已满足,并创建了一个新批注。 |
200 | 没问题。 现有批注已更新。 |
412 | 前置条件失败。 由于至少一项中的 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
注册或更新
如果已存在具有相同标识的资产,则注册新的数据资产或更新现有数据资产。 这些项可以选择性地包含 ETag 值,以便为它们启用乐观并发控制。
请求
POST https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}?api-version={api-version}
注意
某些 HTTP 客户端实现可能会自动重新发出请求以响应来自服务器的 302,但通常会从请求中删除 Authorization 标头。 由于向 ADC 发出请求需要授权标头,因此必须确保在向 ADC 指定的重定向位置重新发出请求时仍提供授权标头。 下面是使用 .NET HttpWebRequest 对象演示这一点的示例代码。
URI 参数
名称 | 说明 | 数据类型 |
---|---|---|
catalog_name | 目录的名称,或“DefaultCatalog”以使用默认目录。 | 字符串 |
view_name | 数据资产视图的名称。 | 字符串 |
api-version | API 版本。 | 字符串 |
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
}
]
}
}
}
}
响应
状态代码
代码 | 说明 |
---|---|
200 | 没问题。 现有资产已更新。 |
201 | Created. 请求已满足,并创建了一个新资产。 |
412 | 前置条件失败。 由于至少一项中的 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 数据目录支持的数据源。
示例
此示例演示如何获取 Azure AD 访问令牌并执行 注册 操作。
注意此示例使用 DefaultCatalog 关键字 (keyword) 更新用户的默认目录。 也可以指定实际的目录名称。 若要查找目录名称,请登录到 Azure 数据目录,然后选择“用户”。 你将看到 目录 名称。
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
}
]
}
}
}
}";
}
使用批注获取
获取具有批注的数据资产。
它支持可选的 Accept 标头参数,该参数 adc.metadata
请求在所有项的响应中包括 ETag。 使用最小值或完整值获取 ETag 作为响应。 有效值是 none
、minimal
和 full
。
请求
GET https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}?api-version={api-version}
注意
某些 HTTP 客户端实现可能会自动重新发出请求以响应来自服务器的 302,但通常会从请求中删除 Authorization 标头 。 由于向 ADC 发出请求需要授权标头,因此必须确保在向 ADC 指定的重定向位置重新发出请求时仍提供授权标头。 下面是使用 .NET HttpWebRequest 对象演示这一点的示例代码。
URI 参数
名称 | 说明 | 数据类型 |
---|---|---|
catalog_name | 目录的名称,或“DefaultCatalog”以使用默认目录。 | 字符串 |
view_name | 数据资产视图的名称。 | 字符串 |
view_item_id | 视图项的 ID。 | 字符串 |
api-version | API 版本。 | 字符串 |
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
响应
状态代码
代码 | 说明 |
---|---|
200 | 没问题。 响应包含请求的资产视图。 |
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"
}
}
}
]
}
}
搜索
根据提供的搜索词搜索数据资产。
请求
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}
注意
某些 HTTP 客户端实现可能会自动重新发出请求以响应来自服务器的 302,但通常会从请求中删除 Authorization 标头 。 由于向 ADC 发出请求需要授权标头,因此必须确保在向 ADC 指定的重定向位置重新发出请求时仍提供授权标头。 下面是使用 .NET HttpWebRequest 对象演示这一点的示例代码。
URI 参数
名称 | 说明 | 数据类型 |
---|---|---|
catalog_name | 目录的名称,或“DefaultCatalog”以使用默认目录。 | 字符串 |
api-version | API 版本。 | 字符串 |
查询参数
名称 | 说明 | 数据类型 |
---|---|---|
searchTerms | 必需。 要搜索的字词。 | 字符串 |
方面 | 可选 用于对结果进行分面的逗号分隔字段名称。 | 字符串 |
startPage | 用于分页的结果的可选起始页以及 count 参数。 允许的值大于 0,如果传递的值小于或等于 0,则返回错误代码为 400 的 HTTP 错误。 | 字符串 |
count | (分页) 单页所需的可选结果数。 默认值为 10。 允许的值的间隔为 1 到 100(含)。 如果传递了此范围外的值,则返回错误代码为 400 的 HTTP 错误。 若要获取搜索结果的下一部分,请重复请求,但将 startPage 增加 1。 | Integer |
查看 | 可选 获取客户端要查看的视图,目前是 DataSource 中唯一受支持的选项。 | 字符串 |
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...
响应
状态代码
代码 | 说明 |
---|---|
200 | 没问题。 包含搜索结果的成功操作。 |
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 数据目录,然后选择“用户”。 你将看到 目录 名称。
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”。
请求
DELETE https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}?api-version={api-version}
注意
某些 HTTP 客户端实现可能会自动重新发出请求以响应来自服务器的 302,但通常会从请求中删除 Authorization 标头 。 由于向 ADC 发出请求需要授权标头,因此必须确保在向 ADC 指定的重定向位置重新发出请求时仍提供授权标头。 下面是使用 .NET HttpWebRequest 对象演示这一点的示例代码。
URI 参数
名称 | 说明 | 数据类型 |
---|---|---|
catalog_name | 目录的名称,或“DefaultCatalog”以使用默认目录。 | 字符串 |
view_name | 数据资产视图的名称。 | 字符串 |
view_item_id | 视图项的 ID。 | 字符串 |
api-version | API 版本。 | 字符串 |
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"
响应
状态代码
代码 | 说明 |
---|---|
204 | 无内容 注意:删除操作语义为“如果存在,则删除”,因此如果资产或注释不存在,则返回成功状态代码 204 (NoContent) 。 |
412 | 前置条件失败。 由于 ETag 不匹配,请求已取消。 |
Content-Type
application/json
标头
x-ms-request-id: 664f86cf…5e512fa78e92
更新批注
汇报批注。
这些项可以选择性地包含 ETag 值,以便为它们启用乐观并发控制。
请求
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}
注意
某些 HTTP 客户端实现可能会自动重新发出请求以响应来自服务器的 302,但通常会从请求中删除 Authorization 标头 。 由于向 ADC 发出请求需要授权标头,因此必须确保在向 ADC 指定的重定向位置重新发出请求时仍提供授权标头。 下面是使用 .NET HttpWebRequest 对象演示这一点的示例代码。
URI 参数
名称 | 说明 | 数据类型 |
---|---|---|
catalog_name | 目录的名称,或“DefaultCatalog”以使用默认目录。 | 字符串 |
view_name | 数据资产视图的名称。 | 字符串 |
view_item_id | 视图项的 ID。 | 字符串 |
nested_view_name | 嵌套视图的名称。 | 字符串 |
nested_non_singleton_view_item_id | 嵌套的非单一实例视图项的 ID。 必须为非单一实例视图提供。 | 字符串 |
api-version | API 版本。 | 字符串 |
单一实例文档视图的 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",
}
响应
状态代码
代码 | 说明 |
---|---|
200 | 没问题。 现有批注已更新。 |
412 | 前置条件失败。 由于至少一项中的 ETag 不匹配,请求已取消。 |
Content-Type
application/json
标头
x-ms-request-id: 3b8668da…1558d0f407c0
删除批注
删除批注和 (所有嵌套批注(如果有任何) )。
它支持用于乐观并发控制的可选 If-Match 标头。 仅支持弱格式,例如 W/“123456789”。
请求
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}
注意
某些 HTTP 客户端实现可能会自动重新发出请求以响应来自服务器的 302,但通常会从请求中删除 Authorization 标头 。 由于向 ADC 发出请求需要授权标头,因此必须确保在向 ADC 指定的重定向位置重新发出请求时仍提供授权标头。 下面是使用 .NET HttpWebRequest 对象演示这一点的示例代码。
URI 参数
名称 | 说明 | 数据类型 |
---|---|---|
catalog_name | 目录的名称,或“DefaultCatalog”以使用默认目录。 | 字符串 |
view_name | 数据资产视图的名称。 | 字符串 |
view_item_id | 视图项的 ID。 | 字符串 |
nested_view_name | 嵌套视图的名称。 | 字符串 |
nested_non_singleton_view_item_id | 嵌套的非单一实例视图项的 ID。 必须为非单一实例视图提供。 | 字符串 |
api-version | API 版本。 | 字符串 |
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"
响应
状态代码
代码 | 说明 |
---|---|
204 | 无内容 |
412 | 前置条件失败。 由于 ETag 不匹配,请求已取消。 |
Content-Type
application/json
标头
x-ms-request-id: 276b9dc4…e5f7017805c