Share via


Entity.CreateOrUpdate Method

Definition

Overloads

CreateOrUpdate(AtlasEntityWithExtInfo, Nullable<BusinessAttributeUpdateBehavior>, String, CancellationToken)

Create or update an entity. 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.

CreateOrUpdate(RequestContent, String, String, RequestContext)

[Protocol Method] Create or update an entity. 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.

CreateOrUpdate(AtlasEntityWithExtInfo, Nullable<BusinessAttributeUpdateBehavior>, String, CancellationToken)

Source:
Entity.cs

Create or update an entity. 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 Azure.Response<Azure.Analytics.Purview.DataMap.EntityMutationResult> CreateOrUpdate (Azure.Analytics.Purview.DataMap.AtlasEntityWithExtInfo atlasEntityWithExtInfo, Azure.Analytics.Purview.DataMap.BusinessAttributeUpdateBehavior? businessAttributeUpdateBehavior = default, string collectionId = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateOrUpdate : Azure.Analytics.Purview.DataMap.AtlasEntityWithExtInfo * Nullable<Azure.Analytics.Purview.DataMap.BusinessAttributeUpdateBehavior> * string * System.Threading.CancellationToken -> Azure.Response<Azure.Analytics.Purview.DataMap.EntityMutationResult>
override this.CreateOrUpdate : Azure.Analytics.Purview.DataMap.AtlasEntityWithExtInfo * Nullable<Azure.Analytics.Purview.DataMap.BusinessAttributeUpdateBehavior> * string * System.Threading.CancellationToken -> Azure.Response<Azure.Analytics.Purview.DataMap.EntityMutationResult>
Public Overridable Function CreateOrUpdate (atlasEntityWithExtInfo As AtlasEntityWithExtInfo, Optional businessAttributeUpdateBehavior As Nullable(Of BusinessAttributeUpdateBehavior) = Nothing, Optional collectionId As String = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Response(Of EntityMutationResult)

Parameters

atlasEntityWithExtInfo
AtlasEntityWithExtInfo

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

businessAttributeUpdateBehavior
Nullable<BusinessAttributeUpdateBehavior>

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

collectionId
String

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

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

atlasEntityWithExtInfo is null.

Examples

This sample shows how to call CreateOrUpdate.

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

AtlasEntityWithExtInfo atlasEntityWithExtInfo = new AtlasEntityWithExtInfo();
Response<EntityMutationResult> response = client.CreateOrUpdate(atlasEntityWithExtInfo);

This sample shows how to call CreateOrUpdate 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");

AtlasEntityWithExtInfo atlasEntityWithExtInfo = new AtlasEntityWithExtInfo
{
    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>",
                }}
            },
        }
    },
    Entity = default,
};
Response<EntityMutationResult> response = client.CreateOrUpdate(atlasEntityWithExtInfo, businessAttributeUpdateBehavior: BusinessAttributeUpdateBehavior.Ignore, collectionId: "<collectionId>");

Applies to

CreateOrUpdate(RequestContent, String, String, RequestContext)

Source:
Entity.cs

[Protocol Method] Create or update an entity. 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 Azure.Response CreateOrUpdate (Azure.Core.RequestContent content, string businessAttributeUpdateBehavior = default, string collectionId = default, Azure.RequestContext context = default);
abstract member CreateOrUpdate : Azure.Core.RequestContent * string * string * Azure.RequestContext -> Azure.Response
override this.CreateOrUpdate : Azure.Core.RequestContent * string * string * Azure.RequestContext -> Azure.Response
Public Overridable Function CreateOrUpdate (content As RequestContent, Optional businessAttributeUpdateBehavior As String = Nothing, Optional collectionId As String = Nothing, Optional context As RequestContext = Nothing) As Response

Parameters

content
RequestContent

The content to send as the body of the request.

businessAttributeUpdateBehavior
String

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

collectionId
String

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

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 CreateOrUpdate 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 = client.CreateOrUpdate(content);

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

This sample shows how to call CreateOrUpdate 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>",
                    }
                },
            },
        },
    },
});
Response response = client.CreateOrUpdate(content, businessAttributeUpdateBehavior: "ignore", collectionId: "<collectionId>");

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