Relationship.Create 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
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 atlasRelationship, 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 (atlasRelationship As AtlasRelationship, Optional cancellationToken As CancellationToken = Nothing) As Response(Of AtlasRelationship)
Parameters
- atlasRelationship
- AtlasRelationship
Atlas relationship instance.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
atlasRelationship
is null.
Examples
This sample shows how to call Create.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
Relationship client = new DataMapClient(endpoint, credential).GetRelationshipClient();
AtlasRelationship atlasRelationship = new AtlasRelationship();
Response<AtlasRelationship> response = client.Create(atlasRelationship);
This sample shows how to call Create with all parameters.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
Relationship client = new DataMapClient(endpoint, credential).GetRelationshipClient();
AtlasRelationship atlasRelationship = new AtlasRelationship
{
Attributes =
{
["key"] = BinaryData.FromObjectAsJson(new object())
},
TypeName = "<typeName>",
LastModifiedTS = "<lastModifiedTS>",
CreateTime = 1234L,
CreatedBy = "<createdBy>",
End1 = new AtlasObjectId
{
Guid = "<guid>",
TypeName = "<typeName>",
UniqueAttributes =
{
["key"] = BinaryData.FromObjectAsJson(new object())
},
},
End2 = default,
Guid = "<guid>",
HomeId = "<homeId>",
Label = "<label>",
ProvenanceType = 1234,
Status = StatusAtlasRelationship.Active,
UpdateTime = 1234L,
UpdatedBy = "<updatedBy>",
Version = 1234L,
};
Response<AtlasRelationship> response = client.Create(atlasRelationship);
Applies to
Create(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 Create(AtlasRelationship, CancellationToken) convenience overload with strongly typed models first.
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("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
Relationship client = new DataMapClient(endpoint, credential).GetRelationshipClient();
using RequestContent content = RequestContent.Create(new object());
Response response = client.Create(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.ToString());
This sample shows how to call Create with all request content and parse the result.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
Relationship client = new DataMapClient(endpoint, credential).GetRelationshipClient();
using RequestContent content = RequestContent.Create(new
{
attributes = new
{
key = new object(),
},
typeName = "<typeName>",
lastModifiedTS = "<lastModifiedTS>",
createTime = 1234L,
createdBy = "<createdBy>",
end1 = new
{
guid = "<guid>",
typeName = "<typeName>",
uniqueAttributes = new
{
key = new object(),
},
},
guid = "<guid>",
homeId = "<homeId>",
label = "<label>",
provenanceType = 1234,
status = "ACTIVE",
updateTime = 1234L,
updatedBy = "<updatedBy>",
version = 1234L,
});
Response response = client.Create(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("attributes").GetProperty("<key>").ToString());
Console.WriteLine(result.GetProperty("typeName").ToString());
Console.WriteLine(result.GetProperty("lastModifiedTS").ToString());
Console.WriteLine(result.GetProperty("createTime").ToString());
Console.WriteLine(result.GetProperty("createdBy").ToString());
Console.WriteLine(result.GetProperty("end1").GetProperty("guid").ToString());
Console.WriteLine(result.GetProperty("end1").GetProperty("typeName").ToString());
Console.WriteLine(result.GetProperty("end1").GetProperty("uniqueAttributes").GetProperty("<key>").ToString());
Console.WriteLine(result.GetProperty("end2").GetProperty("guid").ToString());
Console.WriteLine(result.GetProperty("end2").GetProperty("typeName").ToString());
Console.WriteLine(result.GetProperty("end2").GetProperty("uniqueAttributes").GetProperty("<key>").ToString());
Console.WriteLine(result.GetProperty("guid").ToString());
Console.WriteLine(result.GetProperty("homeId").ToString());
Console.WriteLine(result.GetProperty("label").ToString());
Console.WriteLine(result.GetProperty("provenanceType").ToString());
Console.WriteLine(result.GetProperty("status").ToString());
Console.WriteLine(result.GetProperty("updateTime").ToString());
Console.WriteLine(result.GetProperty("updatedBy").ToString());
Console.WriteLine(result.GetProperty("version").ToString());
Applies to
Azure SDK for .NET