/// <summary>
 /// Creates a relationship link or updates an existing relationship link 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='relationshipLinkName'>
 /// The name of the relationship link.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the CreateOrUpdate relationship link operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <RelationshipLinkResourceFormat> CreateOrUpdateAsync(this IRelationshipLinksOperations operations, string resourceGroupName, string hubName, string relationshipLinkName, RelationshipLinkResourceFormat parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, hubName, relationshipLinkName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
示例#2
0
        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 link or updates an existing relationship link 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='relationshipLinkName'>
 /// The name of the relationship link.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the CreateOrUpdate relationship link operation.
 /// </param>
 public static RelationshipLinkResourceFormat CreateOrUpdate(this IRelationshipLinksOperations operations, string resourceGroupName, string hubName, string relationshipLinkName, RelationshipLinkResourceFormat parameters)
 {
     return(operations.CreateOrUpdateAsync(resourceGroupName, hubName, relationshipLinkName, parameters).GetAwaiter().GetResult());
 }