/// <summary> /// Create a new Idrac Job /// </summary> /// <param name="request">Request to create a Job</param> /// <returns>Uri for the Job created</returns> public async Task <string> CreateIdracJobAsync(IRequest request) { IClient client = RestFactory.CreateClient(); IResponse response = await client.ExecuteAsync(request); return(response.Headers["Location"].FirstOrDefault()); }
//[RuleInterceptor] public virtual async Task <Log> ExecuteAsync() { //ignore SSL errors ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; IRestClient client = RestFactory.CreateClient(Url); IRestRequest request = RestFactory.CreateRequest(Method); IRestResponse response = await client.ExecuteTaskAsync(request); if ((int)response.StatusCode == Code) { return(LogRepository.CreateLog(StatusEnum.Success)); } else { var log = LogRepository.CreateLog(StatusEnum.Failure); log.Message = FailureDescription(); log.FullData = $"Actual HTTP code: {(int)response.StatusCode} {response.StatusCode}. Expected: {Code}."; return(log); } }
/// <summary> /// Creates a new Crawler. /// </summary> /// <param name="host">Hostname or Ip address</param> /// <param name="authenticator">Authentication object</param> public RedfishCrawler(string host, IAuthenticator authenticator) { this.host = host; this.authenticator = authenticator; Resources = new Dictionary <string, string>(); urisFound = new List <string>(); urisFollowed = new List <string>(); client = RestFactory.CreateClient(); client.Host = host; }
/// <summary> /// Creates a new Crawler. /// </summary> /// <param name="host">Hostname or Ip address</param> /// <param name="user">User for basic authentication</param> /// <param name="password">Password for basic authentication</param> public RedfishCrawler(string host, string user, string password) { this.host = host; authenticator = new BasicAuthenticator(user, password); Resources = new Dictionary <string, string>(); urisFound = new List <string>(); urisFollowed = new List <string>(); urisToAdd = new List <string>(); client = RestFactory.CreateClient(); client.Host = host; }
private async Task AuditAsync(AuditDetail data) { var client = RestFactory.CreateClient(BaseUrl); var request = RestFactory.CreateRequest("api/InssAuditMessaging", RestSharp.Method.POST); request = request.AddJsonBody(data); var response = await client.ExecuteAsync(request); if (!response.IsSuccessful) { Logger.LogWarning($"Auditing Failed: {response.StatusCode}"); } }
protected virtual TokenResponse GetToken(AuthorityDetails authDetails) { var client = RestFactory.CreateClient(authDetails.ClientUrl); var request = RestFactory.CreateRequest("token", Method.POST); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Accept", "application/json"); request.AddParameter("grant_type", "client_credentials"); request.AddParameter("resource", authDetails.ResourceUrl); if (!string.IsNullOrEmpty(authDetails.Scope)) { request.AddParameter(JwtClaimTypes.Scope, authDetails.Scope); } client.Authenticator = new HttpBasicAuthenticator(authDetails.ClientId, authDetails.ClientSecret); var response = client.Execute <TokenResponse>(request); return(response?.Data); }
public void CreateClientTest() { var bambooOptions = new Mock <IBambooOptions>(); bambooOptions .SetupGet(i => i.BaseUrl) .Returns("http://test.bamboo.com"); var authentication = new Mock <IBambooAuthentication>(); authentication .Setup(i => i.CreateAuthenticator()) .Returns(new HttpBasicAuthenticator("TestUser", "TestPassword")); bambooOptions .Setup(i => i.Authentication) .Returns(authentication.Object); var serializer = new Mock <IRestSerializer>(); serializer .SetupGet(i => i.DataFormat) .Returns(DataFormat.Json) .Verifiable(); serializer .SetupGet(i => i.SupportedContentTypes) .Returns(new[] { "application/json" }) .Verifiable(); var factory = new RestFactory(bambooOptions.Object, serializer.Object); var client = factory.CreateClient(); client.ShouldNotBeNull(); client.Authenticator.ShouldNotBeNull(); client.Authenticator.ShouldBeOfType <HttpBasicAuthenticator>(); client.BaseUrl.ShouldBe(new Uri("http://test.bamboo.com")); serializer.Verify(); }
public Drive(string host, string user, string password) { client = RestFactory.CreateClient(); client.Host = host; authenticator = new BasicAuthenticator(user, password); }