/// <summary>
        /// Initializes a new instance of the <see cref="BaseOktaClient"/> class, called internally from this or any derived class's constructor.
        /// </summary>
        /// <param name="apiClientConfiguration">
        /// The client configuration. If <c>null</c>, the library will attempt to load
        /// configuration from an <c>okta.yaml</c> file or environment variables.
        /// </param>
        /// <param name="httpClient">The HTTP client to use for requests to the Okta API.</param>
        /// <param name="logger">The logging interface to use, if any.</param>
        /// <param name="userAgentBuilder">The builder for the user agent, which would be specific to any derived classes</param>
        /// <param name="resourceTypeResolverFactory">The factory with can resolve and enumerate all Resources in the assembly</param>
        protected BaseOktaClient(
            OktaClientConfiguration apiClientConfiguration,
            HttpClient httpClient,
            ILogger logger,
            UserAgentBuilder userAgentBuilder,
            AbstractResourceTypeResolverFactory resourceTypeResolverFactory)
        {
            Configuration = GetConfigurationOrDefault(apiClientConfiguration);
            OktaClientConfigurationValidator.Validate(Configuration);

            logger = logger ?? NullLogger.Instance;

            httpClient = httpClient ?? DefaultHttpClient.Create(
                Configuration.ConnectionTimeout,
                Configuration.Proxy,
                logger);

            var requestExecutor = new DefaultRequestExecutor(Configuration, httpClient, logger);
            var resourceFactory = new ResourceFactory(this, logger, resourceTypeResolverFactory);

            _dataStore = new DefaultDataStore(
                requestExecutor,
                new DefaultSerializer(),
                resourceFactory,
                logger,
                userAgentBuilder);
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceFactory"/> class.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="logger">The logging interface.</param>
 /// <param name="resourceTypeResolverFactory">The resource type resolver factory</param>
 public ResourceFactory(IOktaClient client, ILogger logger, AbstractResourceTypeResolverFactory resourceTypeResolverFactory)
 {
     _client = client;
     _logger = logger;
     _resourceTypeResolverFactory = resourceTypeResolverFactory ?? new AbstractResourceTypeResolverFactory(ResourceTypeHelper.AllDefinedTypes);
 }