Partilhar via


Relationship.Create Method

Definition

Overloads

Create(AtlasRelationship, CancellationToken)

Create a new relationship between entities.

Create(RequestContent, RequestContext)

[Protocol Method] Create a new relationship between entities.

Create(AtlasRelationship, CancellationToken)

Source:
Relationship.cs

Create a new relationship between entities.

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

Parameters

body
AtlasRelationship

Body parameter.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

body is null.

Examples

This sample shows how to call Create.

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

AtlasRelationship body = new AtlasRelationship
{
    Attributes =
    {
        ["expression"] = BinaryData.FromObjectAsJson("Example Expression"),
        ["steward"] = BinaryData.FromObjectAsJson("Example Steward"),
        ["description"] = BinaryData.FromObjectAsJson("Example Description"),
        ["source"] = null,
        ["status"] = null
    },
    TypeName = "AtlasGlossarySynonym",
    CreatedBy = "ExampleCreator",
    End1 = new AtlasObjectId
    {
        Guid = "856d31e6-e342-a1ce-6273-22ddb77029c6",
        TypeName = "AtlasGlossaryTerm",
    },
    End2 = new AtlasObjectId
    {
        Guid = "77481037-2874-9bdc-9b9e-76bb94ee71aa",
        TypeName = "AtlasGlossaryTerm",
    },
    Label = "r:AtlasGlossarySynonym",
    Status = StatusAtlasRelationship.Active,
    UpdatedBy = "ExampleUpdator",
    Version = 0L,
};
Response<AtlasRelationship> response = client.Create(body);

Applies to

Create(RequestContent, RequestContext)

Source:
Relationship.cs

[Protocol Method] Create a new relationship between entities.

public virtual Azure.Response Create(Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member Create : Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.Create : Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function Create (content As RequestContent, Optional context As RequestContext = Nothing) As 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 Create and parse the result.

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

using RequestContent content = RequestContent.Create(new
{
    typeName = "AtlasGlossarySynonym",
    attributes = new
    {
        expression = "Example Expression",
        steward = "Example Steward",
        description = "Example Description",
    },
    end1 = new
    {
        guid = "856d31e6-e342-a1ce-6273-22ddb77029c6",
        typeName = "AtlasGlossaryTerm",
    },
    end2 = new
    {
        guid = "77481037-2874-9bdc-9b9e-76bb94ee71aa",
        typeName = "AtlasGlossaryTerm",
    },
    label = "r:AtlasGlossarySynonym",
    status = "ACTIVE",
    createdBy = "ExampleCreator",
    updatedBy = "ExampleUpdator",
    version = 0L,
});
Response response = client.Create(content);

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

Applies to