public void ComponentsApi_Get_PAComponents_Success() { var componentGetAllResponse = componentsApi.GetPAComponentsWithHttpInfo(CommonParameters.PADefaultDocument); Assert.IsTrue(componentGetAllResponse.StatusCode == HttpStatusCode.OK, "Response should be 200 - OK"); Assert.IsTrue(componentGetAllResponse.Data.Data.GetType() == typeof(Dictionary <string, ComponentSummary>), "Response result should be of ComponentSummary Dictionary type."); Assert.IsTrue(componentGetAllResponse.Data.Data.Count != 0, "Response data should not be null."); }
private ApiResponse <object> RunCalculation() { var parameters = new Calculation(); var paComponents = _componentsApi.GetPAComponentsWithHttpInfo(CommonParameters.PADefaultDocument); var paComponentId = paComponents.Data.Keys.First(); var paAccountIdentifier = new PAIdentifier(CommonParameters.PABenchmarkSP50); var paAccounts = new List <PAIdentifier> { paAccountIdentifier }; var paBenchmarkIdentifier = new PAIdentifier(CommonParameters.PABenchmarkSP50PF); var paBenchmarks = new List <PAIdentifier> { paBenchmarkIdentifier }; var paCalculation = new PACalculationParameters(paComponentId, paAccounts, paBenchmarks); parameters.Pa = new Dictionary <string, PACalculationParameters> { { "1", paCalculation } }; var response = _calculationsApi.RunCalculationWithHttpInfo(parameters); return(response); }
private ApiResponse <object> RunCalculation() { var parameters = new Calculation(); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var paComponents = _componentsApi.GetPAComponentsWithHttpInfo(CommonParameters.PADefaultDocument); var paComponentId = paComponents.Data.Keys.First(); var paComponentId2 = paComponents.Data.Keys.Last(); var paAccountIdentifier = new PAIdentifier(CommonParameters.PABenchmarkSP50); var paAccounts = new List <PAIdentifier> { paAccountIdentifier }; var paBenchmarkIdentifier = new PAIdentifier(CommonParameters.PABenchmarkSP50PF); var paBenchmarks = new List <PAIdentifier> { paBenchmarkIdentifier }; var paCalculation = new PACalculationParameters(paComponentId, paAccounts, paBenchmarks); var paCalculation2 = new PACalculationParameters(paComponentId2, paAccounts, paBenchmarks); parameters.Pa = new Dictionary <string, PACalculationParameters> { { "1", paCalculation }, { "2", paCalculation2 } }; var response = _calculationsApi.RunCalculationWithHttpInfo(parameters); return(response); }
private ApiResponse <object> RunCalculation() { var paComponents = componentsApi.GetPAComponentsWithHttpInfo(CommonParameters.PADefaultDocument); var paComponentId = paComponents.Data.Data.Keys.First(); var paAccountIdentifier = new PAIdentifier(CommonParameters.PABenchmarkSP50); var paAccounts = new List <PAIdentifier> { paAccountIdentifier }; var paBenchmarkIdentifier = new PAIdentifier(CommonParameters.PABenchmarkR1000); var paBenchmarks = new List <PAIdentifier> { paBenchmarkIdentifier }; var paCalculation = new PACalculationParameters(paComponentId, paAccounts, paBenchmarks); var parameters = new PACalculationParametersRoot { Data = new Dictionary <string, PACalculationParameters> { { "1", paCalculation }, { "2", paCalculation } } }; var response = calculationsApi.PostAndCalculateWithHttpInfo(null, "max-stale=0", parameters); return(response); }
private ApiResponse <object> RunCalculation() { var parameters = new Calculation(); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var paComponents = _componentsApi.GetPAComponentsWithHttpInfo(CommonParameters.PADefaultDocument); var paComponentId = paComponents.Data.Keys.First(); var paAccountIdentifier = new PAIdentifier(CommonParameters.PABenchmarkSP50); var paAccounts = new List <PAIdentifier> { paAccountIdentifier }; var paBenchmarkIdentifier = new PAIdentifier(CommonParameters.PABenchmarkR1000); var paBenchmarks = new List <PAIdentifier> { paBenchmarkIdentifier }; var paCalculation = new PACalculationParameters(paComponentId, paAccounts, paBenchmarks); parameters.Pa = new Dictionary <string, PACalculationParameters> { { "1", paCalculation } }; var sparComponents = _componentsApi.GetSPARComponentsWithHttpInfo(CommonParameters.SPARDefaultDocument); var sparComponentId = sparComponents.Data.Keys.First(); var sparAccountIdentifier = new SPARIdentifier(CommonParameters.SPARBenchmarkR1000, CommonParameters.SPARBenchmarkRussellReturnType, CommonParameters.SPARBenchmarkRussellPrefix); var sparAccounts = new List <SPARIdentifier> { sparAccountIdentifier }; var sparBenchmarkIdentifier = new SPARIdentifier(CommonParameters.SPARBenchmarkRussellPR2000, CommonParameters.SPARBenchmarkRussellReturnType, CommonParameters.SPARBenchmarkRussellPrefix); var sparCalculation = new SPARCalculationParameters(sparComponentId, sparAccounts, sparBenchmarkIdentifier); parameters.Spar = new Dictionary <string, SPARCalculationParameters> { { "2", sparCalculation } }; var vaultComponents = _componentsApi.GetVaultComponentsWithHttpInfo(CommonParameters.VaultDefaultDocument); var vaultComponentId = vaultComponents.Data.Keys.First(); var vaultAccount = new VaultIdentifier(CommonParameters.VaultDefaultAccount); var vaultDates = new VaultDateParameters(CommonParameters.VaultStartDate, CommonParameters.VaultEndDate, CommonParameters.VaultFrequency); var vaultConfiguration = _configurationsApi.GetVaultConfigurationsWithHttpInfo(CommonParameters.VaultDefaultAccount); var vaultConfigurationId = vaultConfiguration.Data.Keys.First(); var vaultCalculation = new VaultCalculationParameters(vaultComponentId, vaultAccount, vaultDates, vaultConfigurationId); parameters.Vault = new Dictionary <string, VaultCalculationParameters> { { "3", vaultCalculation } }; var response = _calculationsApi.RunCalculationWithHttpInfo(parameters); return(response); }
public static void Main(string[] args) { try { var componentsApi = new ComponentsApi(GetEngineApiConfiguration()); var componentsResponse = componentsApi.GetPAComponentsWithHttpInfo(PADefaultDocument); var paComponentId = componentsResponse.Data.FirstOrDefault(component => (component.Value.Name == PAComponentName && component.Value.Category == PAComponentCategory)).Key; Console.WriteLine($"PA Component Id : {paComponentId}"); var paAccountIdentifier = new PAIdentifier(PABenchmarkSP50); var paAccounts = new List <PAIdentifier> { paAccountIdentifier }; var paBenchmarkIdentifier = new PAIdentifier(PABenchmarkR1000); var paBenchmarks = new List <PAIdentifier> { paBenchmarkIdentifier }; var paCalculation = new PACalculationParameters(paComponentId, paAccounts, paBenchmarks); var calculationApi = new PACalculationsApi(GetEngineApiConfiguration()); var runCalculationResponse = calculationApi.RunPACalculationWithHttpInfo(paCalculation); var calculationId = string.Empty; while (runCalculationResponse.StatusCode == HttpStatusCode.Accepted) { if (string.IsNullOrWhiteSpace(calculationId)) { runCalculationResponse.Headers.TryGetValue("Location", out var location); calculationId = location?[0].Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last(); } if (runCalculationResponse.Headers.ContainsKey("Cache-Control") && runCalculationResponse.Headers["Cache-Control"][0] is var maxAge && !string.IsNullOrWhiteSpace(maxAge)) { var age = int.Parse(maxAge.Replace("max-age=", "")); Console.WriteLine($"Sleeping for {age} seconds"); Thread.Sleep(age * 1000); } else { Console.WriteLine("Sleeping for 2 seconds"); // Sleep for at least 2 seconds. Thread.Sleep(2000); } runCalculationResponse = calculationApi.GetPACalculationByIdWithHttpInfo(calculationId); }
public void ComponentsApi_Get_PAComponentById_Success() { _componentsApi = new ComponentsApi(CommonFunctions.BuildConfiguration(Engine.PA)); var paComponents = _componentsApi.GetPAComponentsWithHttpInfo(CommonParameters.PADefaultDocument); var paComponentId = paComponents.Data.Keys.First(); var componentGetByIdResponse = _componentsApi.GetPAComponentByIdWithHttpInfo(paComponentId); Assert.IsTrue(componentGetByIdResponse.StatusCode == HttpStatusCode.OK, "Response should be 200 - OK"); Assert.IsTrue(componentGetByIdResponse.Data != null, "Response data should not be null"); Assert.IsTrue(componentGetByIdResponse.Data.GetType() == typeof(PAComponent), "Response result should be of PAComponent type"); }
private static PACalculationParameters GetPaCalculationParameters() { // Build PA Engine calculation parameters var componentsApi = new ComponentsApi(GetEngineApiConfiguration()); var componentsResponse = componentsApi.GetPAComponentsWithHttpInfo(PADefaultDocument); var paComponentId = componentsResponse.Data.FirstOrDefault(component => (component.Value.Name == PAComponentName && component.Value.Category == PAComponentCategory)).Key; Console.WriteLine($"PA Component Id : {paComponentId}"); var paAccountIdentifier = new PAIdentifier(PABenchmarkSP50); var paAccounts = new List <PAIdentifier> { paAccountIdentifier }; var paBenchmarkIdentifier = new PAIdentifier(PABenchmarkR1000); var paBenchmarks = new List <PAIdentifier> { paBenchmarkIdentifier }; var paCalculation = new PACalculationParameters(paComponentId, paAccounts, paBenchmarks); return(paCalculation); }