Share via


Entity.BatchCreateOrUpdateAsync Method

Definition

Overloads

BatchCreateOrUpdateAsync(AtlasEntitiesWithExtInfo, String, Nullable<BusinessAttributeUpdateBehavior>, CancellationToken)

Create or update entities in bulk. Existing entity is matched using its unique guid if supplied or by its unique attributes eg: qualifiedName. Map and array of collections are not well supported. E.g., array<array<int>>, array<map<string, int>>. For each contact type, the maximum number of contacts is 20.

BatchCreateOrUpdateAsync(RequestContent, String, String, RequestContext)

[Protocol Method] Create or update entities in bulk. Existing entity is matched using its unique guid if supplied or by its unique attributes eg: qualifiedName. Map and array of collections are not well supported. E.g., array<array<int>>, array<map<string, int>>. For each contact type, the maximum number of contacts is 20.

BatchCreateOrUpdateAsync(AtlasEntitiesWithExtInfo, String, Nullable<BusinessAttributeUpdateBehavior>, CancellationToken)

Source:
Entity.cs

Create or update entities in bulk. Existing entity is matched using its unique guid if supplied or by its unique attributes eg: qualifiedName. Map and array of collections are not well supported. E.g., array<array<int>>, array<map<string, int>>. For each contact type, the maximum number of contacts is 20.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.EntityMutationResult>> BatchCreateOrUpdateAsync (Azure.Analytics.Purview.DataMap.AtlasEntitiesWithExtInfo atlasEntitiesWithExtInfo, string collectionId = default, Azure.Analytics.Purview.DataMap.BusinessAttributeUpdateBehavior? businessAttributeUpdateBehavior = default, System.Threading.CancellationToken cancellationToken = default);
abstract member BatchCreateOrUpdateAsync : Azure.Analytics.Purview.DataMap.AtlasEntitiesWithExtInfo * string * Nullable<Azure.Analytics.Purview.DataMap.BusinessAttributeUpdateBehavior> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.EntityMutationResult>>
override this.BatchCreateOrUpdateAsync : Azure.Analytics.Purview.DataMap.AtlasEntitiesWithExtInfo * string * Nullable<Azure.Analytics.Purview.DataMap.BusinessAttributeUpdateBehavior> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.EntityMutationResult>>
Public Overridable Function BatchCreateOrUpdateAsync (atlasEntitiesWithExtInfo As AtlasEntitiesWithExtInfo, Optional collectionId As String = Nothing, Optional businessAttributeUpdateBehavior As Nullable(Of BusinessAttributeUpdateBehavior) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of EntityMutationResult))

Parameters

atlasEntitiesWithExtInfo
AtlasEntitiesWithExtInfo

An instance of an entity along with extended info - like hive_table, hive_database.

collectionId
String

The collection where entities will be moved to. Only specify a value if you need to move an entity to another collection.

businessAttributeUpdateBehavior
Nullable<BusinessAttributeUpdateBehavior>

Used to define the update behavior for business attributes when updating entities.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

atlasEntitiesWithExtInfo is null.

Examples

This sample shows how to call BatchCreateOrUpdateAsync.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
Entity client = new DataMapClient(endpoint, credential).GetEntityClient();

AtlasEntitiesWithExtInfo atlasEntitiesWithExtInfo = new AtlasEntitiesWithExtInfo();
Response<EntityMutationResult> response = await client.BatchCreateOrUpdateAsync(atlasEntitiesWithExtInfo);

This sample shows how to call BatchCreateOrUpdateAsync with all parameters.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
Entity client = new DataMapClient(endpoint, credential).GetEntityClient(apiVersion: "2023-09-01");

AtlasEntitiesWithExtInfo atlasEntitiesWithExtInfo = new AtlasEntitiesWithExtInfo
{
    ReferredEntities =
    {
        ["key"] = new AtlasEntity
        {
            Attributes =
            {
                ["key"] = BinaryData.FromObjectAsJson(new object())
            },
            TypeName = "<typeName>",
            LastModifiedTS = "<lastModifiedTS>",
            BusinessAttributes =
            {
                ["key"] = BinaryData.FromObjectAsJson(new object())
            },
            Classifications = {new AtlasClassification
            {
                Attributes =
                {
                    ["key"] = BinaryData.FromObjectAsJson(new object())
                },
                TypeName = "<typeName>",
                LastModifiedTS = "<lastModifiedTS>",
                EntityGuid = "<entityGuid>",
                EntityStatus = EntityStatus.Active,
                RemovePropagationsOnEntityDelete = true,
                ValidityPeriods = {new TimeBoundary
                {
                    EndTime = "<endTime>",
                    StartTime = "<startTime>",
                    TimeZone = "<timeZone>",
                }},
            }},
            CreateTime = 1234L,
            CreatedBy = "<createdBy>",
            CustomAttributes =
            {
                ["key"] = "<customAttributes>"
            },
            Guid = "<guid>",
            HomeId = "<homeId>",
            IsIncomplete = true,
            Labels = {"<labels>"},
            Meanings = {new AtlasTermAssignmentHeader
            {
                Confidence = 1234,
                CreatedBy = "<createdBy>",
                Description = "<description>",
                DisplayText = "<displayText>",
                Expression = "<expression>",
                RelationGuid = Guid.Parse("73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a"),
                Status = AtlasTermAssignmentStatus.Discovered,
                Steward = "<steward>",
                TermGuid = Guid.Parse("73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a"),
            }},
            ProvenanceType = 1234,
            Proxy = true,
            RelationshipAttributes =
            {
                ["key"] = BinaryData.FromObjectAsJson(new object())
            },
            Status = EntityStatus.Active,
            UpdateTime = 1234L,
            UpdatedBy = "<updatedBy>",
            Version = 1234L,
            Contacts =
            {
                ["key"] = {new ContactInfo
                {
                    Id = "<id>",
                    Info = "<info>",
                }}
            },
        }
    },
    Entities = { default },
};
Response<EntityMutationResult> response = await client.BatchCreateOrUpdateAsync(atlasEntitiesWithExtInfo, collectionId: "<collectionId>", businessAttributeUpdateBehavior: BusinessAttributeUpdateBehavior.Ignore);

Applies to

BatchCreateOrUpdateAsync(RequestContent, String, String, RequestContext)

Source:
Entity.cs

[Protocol Method] Create or update entities in bulk. Existing entity is matched using its unique guid if supplied or by its unique attributes eg: qualifiedName. Map and array of collections are not well supported. E.g., array<array<int>>, array<map<string, int>>. For each contact type, the maximum number of contacts is 20.

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

Parameters

content
RequestContent

The content to send as the body of the request.

collectionId
String

The collection where entities will be moved to. Only specify a value if you need to move an entity to another collection.

businessAttributeUpdateBehavior
String

Used to define the update behavior for business attributes when updating entities. Allowed values: "ignore" | "replace" | "merge"

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 BatchCreateOrUpdateAsync and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
Entity client = new DataMapClient(endpoint, credential).GetEntityClient();

using RequestContent content = RequestContent.Create(new object());
Response response = await client.BatchCreateOrUpdateAsync(content);

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

This sample shows how to call BatchCreateOrUpdateAsync with all parameters and request content and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
Entity client = new DataMapClient(endpoint, credential).GetEntityClient(apiVersion: "2023-09-01");

using RequestContent content = RequestContent.Create(new
{
    referredEntities = new
    {
        key = new
        {
            attributes = new
            {
                key = new object(),
            },
            typeName = "<typeName>",
            lastModifiedTS = "<lastModifiedTS>",
            businessAttributes = new
            {
                key = new object(),
            },
            classifications = new object[]
            {
                new
                {
                    attributes = new
                    {
                        key = new object(),
                    },
                    typeName = "<typeName>",
                    lastModifiedTS = "<lastModifiedTS>",
                    entityGuid = "<entityGuid>",
                    entityStatus = "ACTIVE",
                    removePropagationsOnEntityDelete = true,
                    validityPeriods = new object[]
                    {
                        new
                        {
                            endTime = "<endTime>",
                            startTime = "<startTime>",
                            timeZone = "<timeZone>",
                        }
                    },
                }
            },
            createTime = 1234L,
            createdBy = "<createdBy>",
            customAttributes = new
            {
                key = "<customAttributes>",
            },
            guid = "<guid>",
            homeId = "<homeId>",
            isIncomplete = true,
            labels = new object[]
            {
                "<labels>"
            },
            meanings = new object[]
            {
                new
                {
                    confidence = 1234,
                    createdBy = "<createdBy>",
                    description = "<description>",
                    displayText = "<displayText>",
                    expression = "<expression>",
                    relationGuid = "73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a",
                    status = "DISCOVERED",
                    steward = "<steward>",
                    termGuid = "73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a",
                }
            },
            provenanceType = 1234,
            proxy = true,
            relationshipAttributes = new
            {
                key = new object(),
            },
            status = "ACTIVE",
            updateTime = 1234L,
            updatedBy = "<updatedBy>",
            version = 1234L,
            contacts = new
            {
                key = new object[]
                {
                    new
                    {
                        id = "<id>",
                        info = "<info>",
                    }
                },
            },
        },
    },
    entities = new object[]
    {
        null
    },
});
Response response = await client.BatchCreateOrUpdateAsync(content, collectionId: "<collectionId>", businessAttributeUpdateBehavior: "ignore");

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("guidAssignments").GetProperty("<key>").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("attributes").GetProperty("<key>").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("typeName").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("lastModifiedTS").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("classificationNames")[0].ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("classifications")[0].GetProperty("attributes").GetProperty("<key>").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("classifications")[0].GetProperty("typeName").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("classifications")[0].GetProperty("lastModifiedTS").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("classifications")[0].GetProperty("entityGuid").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("classifications")[0].GetProperty("entityStatus").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("classifications")[0].GetProperty("removePropagationsOnEntityDelete").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("classifications")[0].GetProperty("validityPeriods")[0].GetProperty("endTime").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("classifications")[0].GetProperty("validityPeriods")[0].GetProperty("startTime").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("classifications")[0].GetProperty("validityPeriods")[0].GetProperty("timeZone").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("displayText").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("guid").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("isIncomplete").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("labels")[0].ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("meaningNames")[0].ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("meanings")[0].GetProperty("confidence").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("meanings")[0].GetProperty("createdBy").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("meanings")[0].GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("meanings")[0].GetProperty("displayText").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("meanings")[0].GetProperty("expression").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("meanings")[0].GetProperty("relationGuid").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("meanings")[0].GetProperty("status").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("meanings")[0].GetProperty("steward").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("meanings")[0].GetProperty("termGuid").ToString());
Console.WriteLine(result.GetProperty("mutatedEntities").GetProperty("<key>")[0].GetProperty("status").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("attributes").GetProperty("<key>").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("typeName").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("lastModifiedTS").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("classificationNames")[0].ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("classifications")[0].GetProperty("attributes").GetProperty("<key>").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("classifications")[0].GetProperty("typeName").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("classifications")[0].GetProperty("lastModifiedTS").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("classifications")[0].GetProperty("entityGuid").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("classifications")[0].GetProperty("entityStatus").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("classifications")[0].GetProperty("removePropagationsOnEntityDelete").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("classifications")[0].GetProperty("validityPeriods")[0].GetProperty("endTime").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("classifications")[0].GetProperty("validityPeriods")[0].GetProperty("startTime").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("classifications")[0].GetProperty("validityPeriods")[0].GetProperty("timeZone").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("displayText").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("guid").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("isIncomplete").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("labels")[0].ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("meaningNames")[0].ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("meanings")[0].GetProperty("confidence").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("meanings")[0].GetProperty("createdBy").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("meanings")[0].GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("meanings")[0].GetProperty("displayText").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("meanings")[0].GetProperty("expression").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("meanings")[0].GetProperty("relationGuid").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("meanings")[0].GetProperty("status").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("meanings")[0].GetProperty("steward").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("meanings")[0].GetProperty("termGuid").ToString());
Console.WriteLine(result.GetProperty("partialUpdatedEntities")[0].GetProperty("status").ToString());

Applies to