Exemplo n.º 1
0
        public RundeckClient(RundeckClientOptions options, ILogger logger = default !)
        {
            if (options == null)
            {
                throw new ConfigurationException(Resources.OptionsAreMissing);
            }
            options.Validate();
            _logger            = logger ?? NullLogger.Instance;
            _httpClientHandler = new AuthenticatedBackingOffHttpClientHandler(options ?? throw new ArgumentNullException(nameof(options)));
            _httpClient        = new HttpClient(_httpClientHandler)
            {
                BaseAddress = new Uri(options.Uri, $"/api/{options.ApiVersion}")
            };

            var refitSettings = new RefitSettings
            {
                ContentSerializer = new JsonContentSerializer(
                    new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                                        //, Converters = { new StringEnumConverter() }
#if DEBUG
                    ,
                    MissingMemberHandling = MissingMemberHandling.Error
#endif
                }
                    )
            };

            AuthenticationTokens = RestService.For <IAuthenticationTokens>(_httpClient, refitSettings);
            Cluster    = RestService.For <ICluster>(_httpClient, refitSettings);
            Executions = RestService.For <IExecutions>(_httpClient, refitSettings);
            Jobs       = RestService.For <IJobs>(_httpClient, refitSettings);
            Keys       = RestService.For <IKeys>(_httpClient, refitSettings);
            Metrics    = RestService.For <IMetrics>(_httpClient, refitSettings);
            Plugins    = RestService.For <IPlugins>(_httpClient, refitSettings);
            Policies   = RestService.For <IPolicies>(_httpClient, refitSettings);
            Projects   = RestService.For <IProjects>(_httpClient, refitSettings);
            Storage    = RestService.For <IStorage>(_httpClient, refitSettings);
            System     = RestService.For <ISystem>(_httpClient, refitSettings);
            Users      = RestService.For <IUsers>(_httpClient, refitSettings);
            WebHooks   = RestService.For <IWebHooks>(_httpClient, refitSettings);
        }
 public AuthenticatedBackingOffHttpClientHandler(RundeckClientOptions options)
 {
     _options = options;
     _logger  = options.Logger ?? NullLogger.Instance;
 }