Relationship.CreateAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
CreateAsync(AtlasRelationship, CancellationToken) |
Create a new relationship between entities. |
CreateAsync(RequestContent, RequestContext) |
[Protocol Method] Create a new relationship between entities.
|
CreateAsync(AtlasRelationship, CancellationToken)
- Source:
- Relationship.cs
Create a new relationship between entities.
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.AtlasRelationship>> CreateAsync(Azure.Analytics.Purview.DataMap.AtlasRelationship body, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateAsync : Azure.Analytics.Purview.DataMap.AtlasRelationship * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.AtlasRelationship>>
override this.CreateAsync : Azure.Analytics.Purview.DataMap.AtlasRelationship * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Purview.DataMap.AtlasRelationship>>
Public Overridable Function CreateAsync (body As AtlasRelationship, Optional cancellationToken As CancellationToken = Nothing) As Task(Of 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 CreateAsync.
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 = await client.CreateAsync(body);
Applies to
CreateAsync(RequestContent, RequestContext)
- Source:
- Relationship.cs
[Protocol Method] Create a new relationship between entities.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler CreateAsync(AtlasRelationship, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Response> CreateAsync(Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.CreateAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function CreateAsync (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 CreateAsync 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 = await client.CreateAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.ToString());