public void CrdRelationshipFullCycle() { using (var context = MockContext.Start(this.GetType().FullName)) { var aciClient = context.GetServiceClient <CustomerInsightsManagementClient>(); var profileName = TestUtilities.GenerateName("testProfile232"); var relationshipName = TestUtilities.GenerateName("testRelationship232"); var profileResourceFormat = Helpers.GetTestProfile(profileName); aciClient.Profiles.CreateOrUpdate(ResourceGroupName, HubName, profileName, profileResourceFormat); var relationshipResourceFormat = new RelationshipResourceFormat { ProfileType = profileName, RelatedProfileType = profileName, DisplayName = new Dictionary <string, string> { { "en-us", "Relationship DisplayName" } }, Description = new Dictionary <string, string> { { "en-us", "Relationship Description" } }, Cardinality = CardinalityTypes.OneToOne }; var relationship = aciClient.Relationships.CreateOrUpdate( ResourceGroupName, HubName, relationshipName, relationshipResourceFormat); Assert.Equal(relationshipName, relationship.RelationshipName); Assert.Equal(relationship.Name, HubName + "/" + relationshipName, StringComparer.OrdinalIgnoreCase); Assert.Equal( "Microsoft.CustomerInsights/hubs/relationships", relationship.Type, StringComparer.OrdinalIgnoreCase); relationship = aciClient.Relationships.Get(ResourceGroupName, HubName, relationshipName); Assert.Equal(relationshipName, relationship.RelationshipName); Assert.Equal(relationship.Name, HubName + "/" + relationshipName, StringComparer.OrdinalIgnoreCase); Assert.Equal( "Microsoft.CustomerInsights/hubs/relationships", relationship.Type, StringComparer.OrdinalIgnoreCase); var relationships = aciClient.Relationships.ListByHub(ResourceGroupName, HubName); Assert.True(relationships.Any()); Assert.Contains(relationships.ToList(), item => relationshipName == item.RelationshipName); var deleteRelationshipResult = aciClient.Relationships.DeleteWithHttpMessagesAsync(ResourceGroupName, HubName, relationshipName) .Result; Assert.Equal(HttpStatusCode.OK, deleteRelationshipResult.Response.StatusCode); } }
/// <summary> /// Creates a relationship or updates an existing relationship within a hub. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='hubName'> /// The name of the hub. /// </param> /// <param name='relationshipName'> /// The name of the Relationship. /// </param> /// <param name='parameters'> /// Parameters supplied to the CreateOrUpdate Relationship operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <RelationshipResourceFormat> CreateOrUpdateAsync(this IRelationshipsOperations operations, string resourceGroupName, string hubName, string relationshipName, RelationshipResourceFormat parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, hubName, relationshipName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public void CrdRelationshipLinkFullCycle() { using (var context = MockContext.Start(this.GetType().FullName)) { var aciClient = context.GetServiceClient <CustomerInsightsManagementClient>(); var profileName = TestUtilities.GenerateName("testProfile232"); var relationshipName = TestUtilities.GenerateName("testRelationship232"); var profileResourceFormat = Helpers.GetTestProfile(profileName); aciClient.Profiles.CreateOrUpdate(ResourceGroupName, HubName, profileName, profileResourceFormat); var relationshipResourceFormat = new RelationshipResourceFormat { ProfileType = profileName, RelatedProfileType = profileName, DisplayName = new Dictionary <string, string> { { "en-us", "Relationship DisplayName" } }, Description = new Dictionary <string, string> { { "en-us", "Relationship Description" } } }; aciClient.Relationships.CreateOrUpdate( ResourceGroupName, HubName, relationshipName, relationshipResourceFormat); var interactionName = TestUtilities.GenerateName("TestInteractionType"); var interactionResourceFormat = Helpers.GetTestInteraction(interactionName, "profile1"); //Create interaction and verify var interactionResult = aciClient.Interactions.CreateOrUpdate( ResourceGroupName, HubName, interactionName, interactionResourceFormat); var relationshipLinkResourceFormat = new RelationshipLinkResourceFormat { InteractionType = interactionName, RelationshipName = relationshipName, DisplayName = new Dictionary <string, string> { { "en-us", "Link DisplayName" } }, Description = new Dictionary <string, string> { { "en-us", "Link Description" } }, ProfilePropertyReferences = new[] { new ParticipantPropertyReference { InteractionPropertyName = "profile1", ProfilePropertyName = "ProfileId" } }, RelatedProfilePropertyReferences = new[] { new ParticipantPropertyReference { InteractionPropertyName = "profile1", ProfilePropertyName = "ProfileId" } } }; var relationshipLinkName = TestUtilities.GenerateName("testRelationshipLink232"); var relationshipLink = aciClient.RelationshipLinks.CreateOrUpdate( ResourceGroupName, HubName, relationshipLinkName, relationshipLinkResourceFormat); Assert.Equal(relationshipLinkName, relationshipLink.LinkName); Assert.Equal( relationshipLink.Name, HubName + "/" + relationshipLinkName, StringComparer.OrdinalIgnoreCase); Assert.Equal( "Microsoft.CustomerInsights/hubs/relationshipLinks", relationshipLink.Type, StringComparer.OrdinalIgnoreCase); relationshipLink = aciClient.RelationshipLinks.Get(ResourceGroupName, HubName, relationshipLinkName); Assert.Equal(relationshipLinkName, relationshipLink.LinkName); Assert.Equal( relationshipLink.Name, HubName + "/" + relationshipLinkName, StringComparer.OrdinalIgnoreCase); Assert.Equal( "Microsoft.CustomerInsights/hubs/relationshipLinks", relationshipLink.Type, StringComparer.OrdinalIgnoreCase); var relationshipLinks = aciClient.RelationshipLinks.ListByHub(ResourceGroupName, HubName); Assert.True(relationshipLinks.Any()); Assert.Contains(relationshipLinks.ToList(), item => relationshipLinkName == item.LinkName); var deleteRelationshipResult = aciClient.RelationshipLinks.DeleteWithHttpMessagesAsync( ResourceGroupName, HubName, relationshipLinkName).Result; Assert.Equal(HttpStatusCode.OK, deleteRelationshipResult.Response.StatusCode); } }
/// <summary> /// Creates a relationship or updates an existing relationship within a hub. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='hubName'> /// The name of the hub. /// </param> /// <param name='relationshipName'> /// The name of the Relationship. /// </param> /// <param name='parameters'> /// Parameters supplied to the CreateOrUpdate Relationship operation. /// </param> public static RelationshipResourceFormat CreateOrUpdate(this IRelationshipsOperations operations, string resourceGroupName, string hubName, string relationshipName, RelationshipResourceFormat parameters) { return(operations.CreateOrUpdateAsync(resourceGroupName, hubName, relationshipName, parameters).GetAwaiter().GetResult()); }