Share via


TypeDefinition.BatchCreateAsync Method

Definition

Overloads

Name Description
BatchCreateAsync(AtlasTypesDef, CancellationToken)

Create all atlas type definitions in bulk. Please avoid recreating existing types.

BatchCreateAsync(RequestContent, RequestContext)

[Protocol Method] Create all atlas type definitions in bulk. Please avoid recreating existing types.

BatchCreateAsync(AtlasTypesDef, CancellationToken)

Source:
TypeDefinition.cs

Create all atlas type definitions in bulk. Please avoid recreating existing types.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.AtlasTypesDef>> BatchCreateAsync(Azure.Analytics.Purview.DataMap.AtlasTypesDef body, System.Threading.CancellationToken cancellationToken = default);
abstract member BatchCreateAsync : Azure.Analytics.Purview.DataMap.AtlasTypesDef * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.AtlasTypesDef>>
override this.BatchCreateAsync : Azure.Analytics.Purview.DataMap.AtlasTypesDef * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.AtlasTypesDef>>
Public Overridable Function BatchCreateAsync (body As AtlasTypesDef, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of AtlasTypesDef))

Parameters

body
AtlasTypesDef

Body parameter.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

body is null.

Examples

This sample shows how to call BatchCreateAsync.

Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
TypeDefinition client = new DataMapClient(endpoint, credential).GetTypeDefinitionClient();

AtlasTypesDef body = new AtlasTypesDef
{
    ClassificationDefs = { },
    EntityDefs = {new AtlasEntityDef
    {
        Name = "azure_sql_server_example",
        TypeVersion = "1.0",
        AttributeDefs = {new AtlasAttributeDef
        {
            Cardinality = CardinalityValue.Set,
            IsIndexable = false,
            IsOptional = true,
            IsUnique = false,
            Name = "databases",
            TypeName = "array<azure_sql_db>",
        }},
        SuperTypes = {"azure_resource"},
    }},
    EnumDefs = { },
    RelationshipDefs = { },
    StructDefs = { },
};
Response<AtlasTypesDef> response = await client.BatchCreateAsync(body);

This sample shows how to call BatchCreateAsync.

Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
TypeDefinition client = new DataMapClient(endpoint, credential).GetTypeDefinitionClient();

AtlasTypesDef body = new AtlasTypesDef
{
    BusinessMetadataDefs = {new AtlasBusinessMetadataDef
    {
        Description = "",
        Name = "myBizMetadata1",
        AttributeDefs = {new AtlasAttributeDef
        {
            Cardinality = CardinalityValue.Single,
            IsIndexable = true,
            IsOptional = true,
            IsUnique = false,
            Name = "bizAttr1",
            Options =
            {
                ["maxStrLength"] = "50",
                ["applicableEntityTypes"] = "[\"Path\"]"
            },
            TypeName = "string",
        }},
    }},
    ClassificationDefs = { },
    EntityDefs = { },
    EnumDefs = { },
    RelationshipDefs = { },
    StructDefs = { },
};
Response<AtlasTypesDef> response = await client.BatchCreateAsync(body);

Applies to

BatchCreateAsync(RequestContent, RequestContext)

Source:
TypeDefinition.cs

[Protocol Method] Create all atlas type definitions in bulk. Please avoid recreating existing types.

public virtual System.Threading.Tasks.Task<Azure.Response> BatchCreateAsync(Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member BatchCreateAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.BatchCreateAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function BatchCreateAsync (content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of Response)

Parameters

content
RequestContent

The content to send as the body of the request.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service.

Exceptions

content is null.

Service returned a non-success status code.

Examples

This sample shows how to call BatchCreateAsync and parse the result.

Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
TypeDefinition client = new DataMapClient(endpoint, credential).GetTypeDefinitionClient();

using RequestContent content = RequestContent.Create(new
{
    enumDefs = Array.Empty<object>(),
    structDefs = Array.Empty<object>(),
    classificationDefs = Array.Empty<object>(),
    entityDefs = new object[]
    {
        new
        {
            name = "azure_sql_server_example",
            superTypes = new object[]
            {
                "azure_resource"
            },
            typeVersion = "1.0",
            attributeDefs = new object[]
            {
                new
                {
                    name = "databases",
                    typeName = "array<azure_sql_db>",
                    cardinality = "SET",
                    isIndexable = false,
                    isOptional = true,
                    isUnique = false,
                }
            },
        }
    },
    relationshipDefs = Array.Empty<object>(),
});
Response response = await client.BatchCreateAsync(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.ToString());

This sample shows how to call BatchCreateAsync and parse the result.

Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
TypeDefinition client = new DataMapClient(endpoint, credential).GetTypeDefinitionClient();

using RequestContent content = RequestContent.Create(new
{
    enumDefs = Array.Empty<object>(),
    structDefs = Array.Empty<object>(),
    classificationDefs = Array.Empty<object>(),
    entityDefs = Array.Empty<object>(),
    relationshipDefs = Array.Empty<object>(),
    businessMetadataDefs = new object[]
    {
        new
        {
            name = "myBizMetadata1",
            description = "",
            attributeDefs = new object[]
            {
                new
                {
                    name = "bizAttr1",
                    typeName = "string",
                    isOptional = true,
                    cardinality = "SINGLE",
                    isUnique = false,
                    isIndexable = true,
                    options = new
                    {
                        maxStrLength = "50",
                        applicableEntityTypes = "[\"Path\"]",
                    },
                }
            },
        }
    },
});
Response response = await client.BatchCreateAsync(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.ToString());

Applies to