public void GetEnrichingKpis()
        {
            using (var context = MockContext.Start(this.GetType()))
            {
                var aciClient = context.GetServiceClient <CustomerInsightsManagementClient>();

                var profileName1           = TestUtilities.GenerateName("TestProfileType1");
                var profileResourceFormat1 = Helpers.GetTestProfile(profileName1);
                aciClient.Profiles.CreateOrUpdate(ResourceGroupName, HubName, profileName1, profileResourceFormat1);

                var interactionName1           = TestUtilities.GenerateName("TestInteractionType1");
                var interactionResourceFormat1 = Helpers.GetTestInteraction(interactionName1, profileName1);
                interactionResourceFormat1.ParticipantProfiles =
                    new List <Participant>()
                {
                    new Participant()
                    {
                        ParticipantName = profileName1,
                        ProfileTypeName = profileName1,
                        ParticipantPropertyReferences =
                            new List <ParticipantPropertyReference>()
                        {
                            new ParticipantPropertyReference()
                            {
                                InteractionPropertyName = interactionName1,
                                ProfilePropertyName     = profileName1
                            }
                        }
                    }
                };

                var interaction1 = aciClient.Interactions.CreateOrUpdate(
                    ResourceGroupName,
                    HubName,
                    interactionName1,
                    interactionResourceFormat1);

                var kpiName           = TestUtilities.GenerateName("TestKpi1");
                var kpiResourceFormat = new KpiResourceFormat
                {
                    EntityType     = EntityTypes.Interaction,
                    EntityTypeName = interactionName1,
                    DisplayName    =
                        new Dictionary <string, string> {
                        { "en-us", "Kpi DisplayName" }
                    },
                    Description =
                        new Dictionary <string, string> {
                        { "en-us", "Kpi Description" }
                    },
                    CalculationWindow = CalculationWindowTypes.Day,
                    Function          = KpiFunctions.Count,
                    Expression        = "*",
                    GroupBy           = new[] { interactionName1 },
                    Unit       = "unit",
                    ThresHolds =
                        new KpiThresholds
                    {
                        LowerLimit    = 5.0m,
                        UpperLimit    = 50.0m,
                        IncreasingKpi = true
                    }
                };

                var kpi           = aciClient.Kpi.CreateOrUpdate(ResourceGroupName, HubName, kpiName, kpiResourceFormat);
                var enrichingKpis = aciClient.Profiles.GetEnrichingKpis(ResourceGroupName, HubName, profileName1);

                Assert.Equal(1, enrichingKpis.Count);
                Assert.Equal(kpi.KpiName, enrichingKpis[0].KpiName);
                Assert.Equal(kpi.EntityType, enrichingKpis[0].EntityType);
                Assert.Equal(kpi.EntityTypeName, enrichingKpis[0].EntityTypeName);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a KPI or updates an existing KPI in the 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='kpiName'>
 /// The name of the KPI.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the create/update KPI operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <KpiResourceFormat> CreateOrUpdateAsync(this IKpiOperations operations, string resourceGroupName, string hubName, string kpiName, KpiResourceFormat parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, hubName, kpiName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 3
0
        public void CrdKpiFullCycle()
        {
            using (var context = MockContext.Start(this.GetType()))
            {
                var aciClient = context.GetServiceClient <CustomerInsightsManagementClient>();

                var profileName           = TestUtilities.GenerateName("testProfile232");
                var profileResourceFormat = Helpers.GetTestProfile(profileName);

                var kpiName = TestUtilities.GenerateName("kpiTest4545");

                var kpiResourceFormat = new KpiResourceFormat
                {
                    EntityType     = EntityTypes.Profile,
                    EntityTypeName = profileName,
                    DisplayName    =
                        new Dictionary <string, string> {
                        { "en-us", "Kpi DisplayName" }
                    },
                    Description =
                        new Dictionary <string, string> {
                        { "en-us", "Kpi Description" }
                    },
                    CalculationWindow = CalculationWindowTypes.Day,
                    Function          = KpiFunctions.Sum,
                    Expression        = "SavingAccountBalance",
                    GroupBy           = new[] { "SavingAccountBalance" },
                    Unit       = "unit",
                    ThresHolds =
                        new KpiThresholds
                    {
                        LowerLimit    = 5.0m,
                        UpperLimit    = 50.0m,
                        IncreasingKpi = true
                    },
                    Aliases =
                        new[] { new KpiAlias {
                                    AliasName = "alias", Expression = "Id+4"
                                } }
                };

                aciClient.Profiles.CreateOrUpdate(ResourceGroupName, HubName, profileName, profileResourceFormat);

                var createKpiResult = aciClient.Kpi.CreateOrUpdate(
                    ResourceGroupName,
                    HubName,
                    kpiName,
                    kpiResourceFormat);

                Assert.Equal(kpiName, createKpiResult.KpiName);
                Assert.Equal(createKpiResult.Name, HubName + "/" + kpiName);
                Assert.Equal("Microsoft.CustomerInsights/hubs/kpi", createKpiResult.Type);

                var getKpiResult = aciClient.Kpi.Get(ResourceGroupName, HubName, kpiName);
                Assert.Equal(kpiName, getKpiResult.KpiName);
                Assert.Equal(getKpiResult.Name, HubName + "/" + kpiName, StringComparer.OrdinalIgnoreCase);
                Assert.Equal("Microsoft.CustomerInsights/hubs/kpi", getKpiResult.Type, StringComparer.OrdinalIgnoreCase);

                var listKpiResult = aciClient.Kpi.ListByHub(ResourceGroupName, HubName);
                Assert.True(listKpiResult.ToList().Count >= 1);
                Assert.Contains(listKpiResult.ToList(), kpiReturned => kpiName == kpiReturned.KpiName);

                var deleteKpiResult =
                    aciClient.Kpi.DeleteWithHttpMessagesAsync(ResourceGroupName, HubName, kpiName).Result;

                Assert.Equal(HttpStatusCode.OK, deleteKpiResult.Response.StatusCode);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a KPI or updates an existing KPI in the 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='kpiName'>
 /// The name of the KPI.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the create/update KPI operation.
 /// </param>
 public static KpiResourceFormat CreateOrUpdate(this IKpiOperations operations, string resourceGroupName, string hubName, string kpiName, KpiResourceFormat parameters)
 {
     return(operations.CreateOrUpdateAsync(resourceGroupName, hubName, kpiName, parameters).GetAwaiter().GetResult());
 }