public override Task <EndpointReply> CheckEndpoint(EndpointRequest request, ServerCallContext context) { var reply = new EndpointReply { StartTime = DateTime.Now.ToString(), Success = true }; // DO TESTS if (request.Platform.ToLower() != "windows") { reply.Success = false; } if (!request.IPaddress.StartsWith("10.")) { reply.Success = false; } reply.EndTime = DateTime.Now.ToString(); //Add result to DB InsertCheck(request, reply); return(Task.FromResult(reply)); }
static void Main(string[] args) { try { // Create the platform session. using (ISession session = Configuration.Sessions.GetSession()) { // Open the session session.Open(); // ******************************************************************************************** // Basic Endpoint retrieval. // The specific endpoint URL below contains all required parameters. // ******************************************************************************************** var endpointUrl = "https://api.refinitiv.com/data/historical-pricing/v1/views/events/VOD.L"; // Request and display the timeseries data using the endpoint default parameters. DisplayResult(EndpointRequest.Definition(endpointUrl).GetData()); // Apply the same request but override the default 'count' which returns the number of hits. DisplayResult(EndpointRequest.Definition(endpointUrl).QueryParameter("count", "5").GetData()); } } catch (Exception e) { Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************"); } }
static void Main(string[] _) { const string dataGridEndpoint = "https://api.refinitiv.com/data/datagrid/beta1/"; try { // Create the platform session. using (ISession session = Configuration.Sessions.GetSession()) { // Open the session session.Open(); // Create the DataGrid endpoint definition var endpoint = EndpointRequest.Definition(dataGridEndpoint).Method(EndpointRequest.Method.POST); // Simple request var response = endpoint.BodyParameters(new JObject() { { "universe", new JArray("TRI.N", "IBM.N") }, { "fields", new JArray("TR.Revenue", "TR.GrossProfit") } }) .GetData(); DisplayResponse(response); // Global parameters response = endpoint.BodyParameters(new JObject() { { "universe", new JArray("GOOG.O", "AAPL.O") }, { "fields", new JArray("TR.RevenueMean", "TR.NetProfitMean") }, { "parameters", new JObject() { { "SDate", "0M" }, { "Curn", "EUR" } } } }).GetData(); DisplayResponse(response); // Historical data with specific date range response = endpoint.BodyParameters(new JObject() { { "universe", new JArray("BHP.AX") }, { "fields", new JArray("TR.AdjmtFactorAdjustmentDate", "TR.AdjmtFactorAdjustmentFactor") }, { "parameters", new JObject() { { "SDate", "1980-01-01" }, { "EDate", "2018-09-29" } } } }).GetData(); DisplayResponse(response); } } catch (Exception e) { Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************"); } }
static void Main(string[] _) { const string intradayEndpoint = "https://api.refinitiv.com/data/quantitative-analytics/v1/financial-contracts"; try { // Create the platform session. using (ISession session = Configuration.Sessions.GetSession()) { // Open the session session.Open(); // IPA - Financial Contracts (Option) var response = EndpointRequest.Definition(intradayEndpoint).Method(EndpointRequest.Method.POST) .BodyParameters(new JObject() { ["fields"] = new JArray("ErrorMessage", "UnderlyingRIC", "UnderlyingPrice", "DeltaPercent", "GammaPercent", "RhoPercent", "ThetaPercent", "VegaPercent"), ["universe"] = new JArray(new JObject() { ["instrumentType"] = "Option", ["instrumentDefinition"] = new JObject() { ["instrumentCode"] = "AAPLA192422500.U", ["underlyingType"] = "Eti" }, ["pricingParameters"] = new JObject() { ["underlyingTimeStamp"] = "Close" } }) }).GetData(); if (response.IsSuccess) { Console.WriteLine(response.Data.Raw["data"]); } else { Console.WriteLine($"Request failed: {response.HttpStatus}"); } } } catch (Exception e) { Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************"); } }
public static NewEndpoint MapRequestToNewEndpointDto(EndpointRequest request, IRandomGenerator randomGenerator, string sipAddressStem) { var sip = randomGenerator.GetWeakDeterministic(DateTime.UtcNow.Ticks, 1, 10); var pin = randomGenerator.GetWeakDeterministic(DateTime.UtcNow.Ticks, 1, 4); var sipComplete = sip + sipAddressStem; return(new NewEndpoint { Pin = pin, Sip = sipComplete, DisplayName = request.DisplayName, DefenceAdvocateUsername = request.DefenceAdvocateUsername }); }
public void Should_run() { var sipAddStream = "TestSipStream"; var randomGen = new Mock <IRandomGenerator>(); var endpointRequest = new EndpointRequest { DefenceAdvocateUsername = "******", DisplayName = "TestDispName" }; var result = EndpointToResponseMapper.MapRequestToNewEndpointDto(endpointRequest, randomGen.Object, sipAddStream); result.Should().NotBeNull(); result.Sip.EndsWith(sipAddStream).Should().BeTrue(); result.DisplayName.Should().Be(endpointRequest.DisplayName); result.DefenceAdvocateUsername.Should().Be(endpointRequest.DefenceAdvocateUsername); }
public void InsertCheck(EndpointRequest request, EndpointReply reply) { using (UnitOfWork unitOfWork = new UnitOfWork()) { EndpointCheck check = new EndpointCheck(unitOfWork) { Name = request.Name, IPaddress = request.IPaddress, Platform = request.Platform, Success = reply.Success, StartTime = DateTime.Parse(reply.StartTime), EndTime = DateTime.Parse(reply.EndTime) }; unitOfWork.CommitChanges(); } }
static void Main(string[] args) { try { // Create the platform session. using (ISession session = Configuration.Sessions.GetSession()) { // Open the session session.Open(); // ******************************************************************************************** // Define the news headline URL - we need this to retrieve the story ID. // ******************************************************************************************** var headlineUrl = "https://api.refinitiv.com/data/news/v1/headlines"; // Request for the headline based on the following query var query = "Adidas searchIn:HeadlineOnly"; var response = EndpointRequest.Definition(headlineUrl).QueryParameter("query", query).GetData(); // The headline response will carry the story ID. var storyId = GetStoryId(response); if (storyId != null) { Console.WriteLine($"\nFirst headline returned: {response.Data?.Raw["data"]?[0]["newsItem"]?["itemMeta"]?["title"]?[0]?["$"]}"); Console.Write($"Hit <Enter> to retrieve story [{storyId}]: "); Console.ReadLine(); // Display the headline and story. First, define the story endpoint Url. // The URL contains a path token {storyId} which will be replaced by the story ID extracted. var storyUrl = "https://api.refinitiv.com/data/news/v1/stories/{storyId}"; // Retrieve and display the story based on the ID we retrieved from the headline DisplayStory(EndpointRequest.Definition(storyUrl).PathParameter("storyId", storyId).GetData()); } else { Console.WriteLine($"Problems retrieving the story ID:{Environment.NewLine}{response.HttpStatus}"); } } } catch (Exception e) { Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************"); } }
public async Task Should_update_participant_username_to_aad_email_id() { var participant = new BookingsApi.Contract.Requests.ParticipantRequest { Username = "******", CaseRoleName = "Applicant", HearingRoleName = "Representative", ContactEmail = "*****@*****.**" }; var participantList = new List <BookingsApi.Contract.Requests.ParticipantRequest> { participant }; const string da = "*****@*****.**"; var endpoints = new EndpointRequest { DisplayName = "displayname", DefenceAdvocateUsername = da }; var endpointList = new List <EndpointRequest> { endpoints }; var hearing = new BookNewHearingRequest { Participants = participantList, Endpoints = endpointList }; var bookingRequest = new BookHearingRequest { BookingDetails = hearing }; // setup response var hearingDetailsResponse = HearingResponseBuilder.Build() .WithParticipant("Representative", participant.Username); _bookingsApiClient.Setup(x => x.BookNewHearingAsync(It.IsAny <BookNewHearingRequest>())) .ReturnsAsync(hearingDetailsResponse); await _controller.Post(bookingRequest); _userAccountService.Verify(x => x.GetAdUserIdForUsername(participant.Username), Times.Once); }
private async Task <EndpointItem> ProcessEndpoint(EndpointItem endpointItem) { try { var endpointrequest = new EndpointRequest { Name = endpointItem.Name, IPaddress = endpointItem.IPaddress, Platform = endpointItem.Platform }; var reply = client.CheckEndpointAsync(endpointrequest).ResponseAsync.Result; endpointItem.Success = reply.Success; endpointItem.StartTime = DateTime.Parse(reply.StartTime); endpointItem.EndTime = DateTime.Parse(reply.EndTime); } catch (Exception e) { endpointItem.Success = false; } return(endpointItem); }
public static async void ScoreRecord(object data) { if (data is JobThreadData) { JobThreadData threadData = data as JobThreadData; List <ThroughputMessage> eventMessages = new List <ThroughputMessage>(); int recordsProcessed = 0; // Gets a list of messages appropriate to the number of threads that are // being run for this test. Dictionary <int, string> rvp = threadData.Records.GetNextBatch(); String optionalError = String.Empty; try { // Consecutive errors. This is when an attempt to send fails // the limit and an error is returned here. If we get three // of these in a row, kill the thread. List <String> consecutiveErrorCodes = new List <String>(); foreach (KeyValuePair <int, string> record in rvp) { recordsProcessed++; // Full Execution Time DateTime fullStart = DateTime.Now; ScoringExecutionSummary jobExecutionSummary = new ScoringExecutionSummary(); jobExecutionSummary.PayloadSize = record.Value.Length; // Get new time for AI call RequestResult returnValue = await EndpointRequest.MakeRequest( threadData.Client, record.Value, threadData.Context.Execution.RetryCount); // Record timing for request jobExecutionSummary.AITime = returnValue.ResponseTime; jobExecutionSummary.Response = returnValue.Response; jobExecutionSummary.State = returnValue.State; jobExecutionSummary.Attempts = returnValue.Attempts; jobExecutionSummary.ExecutionTime = (DateTime.Now - fullStart); // Let the caller know about the call, good or bad threadData.RecordComplete?.Invoke(threadData.JobId, record.Key, jobExecutionSummary); // Record this send data for the event hub RecordEventHubRecords(threadData.Context.Execution.ClientName, eventMessages, returnValue); if (returnValue.State == false) { consecutiveErrorCodes.Add(returnValue.ResponseCode.ToString()); if (consecutiveErrorCodes.Count > 3) { String errorText = String.Format("Too many consecutive errors ; {0}", String.Join(" | ", consecutiveErrorCodes)); EventHubUtility.ProcessOneOff(threadData.Context.HubConfiguration, threadData.Context.Execution.ClientName, 2, errorText); // Get this thread to terminate and report throw new Exception(errorText); } } else { consecutiveErrorCodes.Clear(); } } } catch (Exception ex) { String exception = ex.Message; Exception tmpEx = ex.InnerException; while (tmpEx != null) { exception = String.Format("{0}{1}{2}", exception, Environment.NewLine, tmpEx.Message); tmpEx = tmpEx.InnerException; } optionalError = String.Format("Exception after processing {0} records, terminating run {1}{2}", recordsProcessed, Environment.NewLine, exception); } // Upload everything to event hub EventHubUtility.ProcessMessages(threadData.Context.HubConfiguration, eventMessages); // Notify that job is done threadData.ThreadExiting?.Invoke(threadData.JobId, recordsProcessed, optionalError); } }
static void Main(string[] args) { try { // Create the platform session. using (ISession session = Configuration.Sessions.GetSession()) { // Open the session session.Open(); // Create the symbology lookup endpoint definition var endpoint = EndpointRequest.Definition(symbolLookupEndpoint).Method(EndpointRequest.Method.POST); // RIC to multiple identifiers Console.WriteLine("\nRIC to multiple identifiers..."); Display(endpoint.BodyParameters(new JObject() { ["from"] = new JArray(new JObject() { ["identifierTypes"] = new JArray("RIC"), ["values"] = new JArray("MSFT.O") }), ["to"] = new JArray(new JObject() { ["identifierTypes"] = new JArray("ISIN", "LEI", "ExchangeTicker") }), ["type"] = "auto" }).GetData()); // Legal Entity Identifier (LEI) to multiple RICs Console.WriteLine("LEI to multiple RICs..."); Display(endpoint.BodyParameters(new JObject() { ["from"] = new JArray( new JObject() { ["identifierTypes"] = new JArray("LEI"), ["values"] = new JArray("INR2EJN1ERAN0W5ZP974") }), ["to"] = new JArray( new JObject() { ["identifierTypes"] = new JArray("RIC") }), ["type"] = "auto" }).GetData()); // CUSIP Internation Numbering System (CINS) to multiple RICs Console.WriteLine("CINS to RIC..."); Display(endpoint.BodyParameters(new JObject() { ["from"] = new JArray( new JObject() { ["identifierTypes"] = new JArray("CinsNumber"), ["values"] = new JArray("N7280EAK6") }), ["to"] = new JArray( new JObject() { ["identifierTypes"] = new JArray("RIC") }), ["type"] = "auto" }).GetData()); } } catch (Exception e) { Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************"); } }