# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/utils/object_share'
require 'contrast/agent/reporting/settings/assess_server_feature'
require 'contrast/agent/reporting/settings/protect_server_feature'

module Contrast
  module Agent
    module Reporting
      # This module will hold all the settings from the TS responce
      module Settings
        # All of the settings from TeamServer that apply at the server level.
        # At least one, but not necessarily all, setting will differ from the agent's current set.
        # agents are able to replace all server settings with those in this message.
        class ServerFeatures
          # The level at which the agent should log. Overridden by agent.logger.level
          # if set in a local configuration
          #
          # @return log_level [String] [ ERROR, WARN, INFO, DEBUG, TRACE ]
          def log_level
            @_log_level ||= Contrast::Utils::ObjectShare::EMPTY_STRING
          end

          # set the log level
          #
          # @param log_level [String]
          # @return log_level [String] [ ERROR, WARN, INFO, DEBUG, TRACE ]
          def log_level= log_level
            @_log_level = log_level if log_level.is_a? String
          end

          # Where to log the agent's log file, if set by the user. Overridden by agent.logger.path
          # if set in a local configuration.
          #
          # @return log_file [String] path
          def log_file
            @_log_file ||= Contrast::Utils::ObjectShare::EMPTY_STRING
          end

          # Set the log file
          #
          # @param log_file [String] path
          # @return log_file [String] path
          def log_file= log_file
            @_log_file = log_file if log_file.is_a? String
          end

          # Controls for the reporting of telemetry events from the agent to TeamServer.
          # This is NOT for the agent telemetry feature collecting metrics sent to other services.
          #
          # @return telemetry [Boolean]
          def telemetry
            @_telemetry
          end

          # sets the telemetry value
          #
          # @param telemetry [Boolean]
          # @return telemetry [Boolean]
          def telemetry= telemetry
            @_telemetry = telemetry if !!telemetry == telemetry
          end

          # @return assess [Contrast::Agent::Reporting::Settings::AssessServerFeature]
          def assess
            @_assess ||= Contrast::Agent::Reporting::Settings::AssessServerFeature.new
          end

          # @return protect [Contrast::Agent::Reporting::Settings::ProtectServerFeature]
          def protect
            @_protect ||= Contrast::Agent::Reporting::Settings::ProtectServerFeature.new
          end
        end
      end
    end
  end
end