# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/components/agent' require 'contrast/components/inventory' module Contrast module Config # The base of the Common Configuration settings. class RootConfiguration include Contrast::Config::BaseConfiguration # @return [Contrast::Config::ApiConfiguration] attr_writer :api # @return [Contrast::Components::Agent::Interface] attr_writer :agent # @return [Contrast::Config::ApplicationConfiguration] attr_writer :application # @return [Contrast::Config::ServerConfiguration] attr_writer :server # @return [Contrast::Config::AssessConfiguration] attr_writer :assess # @return [Contrast::Components::Inventory::Interface] attr_writer :inventory # @return [Contrast::Config::ProtectConfiguration] attr_writer :protect # @return [Contrast::Config::ServiceConfiguration] attr_writer :service # @return [Boolean, nil] attr_accessor :enable # @raise[ArgumentError] def initialize hsh = {} raise(ArgumentError, 'Expected a hash') unless hsh.is_a?(Hash) @api = Contrast::Config::ApiConfiguration.new(hsh[:api]) @enable = hsh[:enable] @agent = Contrast::Components::Agent::Interface.new(hsh[:agent]) @application = Contrast::Config::ApplicationConfiguration.new(hsh[:application]) @server = Contrast::Config::ServerConfiguration.new(hsh[:server]) @assess = Contrast::Config::AssessConfiguration.new(hsh[:assess]) @inventory = Contrast::Components::Inventory::Interface.new(hsh[:inventory]) @protect = Contrast::Config::ProtectConfiguration.new(hsh[:protect]) @service = Contrast::Config::ServiceConfiguration.new(hsh[:service]) end # @return [Contrast::Config::ApiConfiguration] def api @api ||= Contrast::Config::ApiConfiguration.new end # @return [Contrast::Components::Agent::Interface] def agent @agent ||= Contrast::Components::Agent::Interface.new end # @return [Contrast::Config::ApplicationConfiguration] def application @application ||= Contrast::Config::ApplicationConfiguration.new end # @return [Contrast::Config::ServerConfiguration] def server @server ||= Contrast::Config::ServerConfiguration.new end # @return [Contrast::Config::AssessConfiguration] def assess @assess ||= Contrast::Config::AssessConfiguration.new end # @return [Contrast::Components::Inventory::Interface] def inventory @inventory ||= Contrast::Components::Inventory::Interface.new end # @return [Contrast::Config::ProtectConfiguration] def protect @protect ||= Contrast::Config::ProtectConfiguration.new end # @return [Contrast::Config::ServiceConfiguration] def service @service ||= Contrast::Config::ServiceConfiguration.new end end end end