{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CodeGuruProfiler.Types.AgentConfiguration
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CodeGuruProfiler.Types.AgentConfiguration where

import Amazonka.CodeGuruProfiler.Types.AgentParameterField
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The response of
-- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_ConfigureAgent.html ConfigureAgent>
-- that specifies if an agent profiles or not and for how long to return
-- profiling data.
--
-- /See:/ 'newAgentConfiguration' smart constructor.
data AgentConfiguration = AgentConfiguration'
  { -- | Parameters used by the profiler. The valid parameters are:
    --
    -- -   @MaxStackDepth@ - The maximum depth of the stacks in the code that
    --     is represented in the profile. For example, if CodeGuru Profiler
    --     finds a method @A@, which calls method @B@, which calls method @C@,
    --     which calls method @D@, then the depth is 4. If the @maxDepth@ is
    --     set to 2, then the profiler evaluates @A@ and @B@.
    --
    -- -   @MemoryUsageLimitPercent@ - The percentage of memory that is used by
    --     the profiler.
    --
    -- -   @MinimumTimeForReportingInMilliseconds@ - The minimum time in
    --     milliseconds between sending reports.
    --
    -- -   @ReportingIntervalInMilliseconds@ - The reporting interval in
    --     milliseconds used to report profiles.
    --
    -- -   @SamplingIntervalInMilliseconds@ - The sampling interval in
    --     milliseconds that is used to profile samples.
    AgentConfiguration -> Maybe (HashMap AgentParameterField Text)
agentParameters :: Prelude.Maybe (Prelude.HashMap AgentParameterField Prelude.Text),
    -- | How long a profiling agent should send profiling data using
    -- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_ConfigureAgent.html ConfigureAgent>
    -- . For example, if this is set to 300, the profiling agent calls
    -- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_ConfigureAgent.html ConfigureAgent>
    -- every 5 minutes to submit the profiled data collected during that
    -- period.
    AgentConfiguration -> Int
periodInSeconds :: Prelude.Int,
    -- | A @Boolean@ that specifies whether the profiling agent collects
    -- profiling data or not. Set to @true@ to enable profiling.
    AgentConfiguration -> Bool
shouldProfile :: Prelude.Bool
  }
  deriving (AgentConfiguration -> AgentConfiguration -> Bool
(AgentConfiguration -> AgentConfiguration -> Bool)
-> (AgentConfiguration -> AgentConfiguration -> Bool)
-> Eq AgentConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AgentConfiguration -> AgentConfiguration -> Bool
$c/= :: AgentConfiguration -> AgentConfiguration -> Bool
== :: AgentConfiguration -> AgentConfiguration -> Bool
$c== :: AgentConfiguration -> AgentConfiguration -> Bool
Prelude.Eq, ReadPrec [AgentConfiguration]
ReadPrec AgentConfiguration
Int -> ReadS AgentConfiguration
ReadS [AgentConfiguration]
(Int -> ReadS AgentConfiguration)
-> ReadS [AgentConfiguration]
-> ReadPrec AgentConfiguration
-> ReadPrec [AgentConfiguration]
-> Read AgentConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AgentConfiguration]
$creadListPrec :: ReadPrec [AgentConfiguration]
readPrec :: ReadPrec AgentConfiguration
$creadPrec :: ReadPrec AgentConfiguration
readList :: ReadS [AgentConfiguration]
$creadList :: ReadS [AgentConfiguration]
readsPrec :: Int -> ReadS AgentConfiguration
$creadsPrec :: Int -> ReadS AgentConfiguration
Prelude.Read, Int -> AgentConfiguration -> ShowS
[AgentConfiguration] -> ShowS
AgentConfiguration -> String
(Int -> AgentConfiguration -> ShowS)
-> (AgentConfiguration -> String)
-> ([AgentConfiguration] -> ShowS)
-> Show AgentConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AgentConfiguration] -> ShowS
$cshowList :: [AgentConfiguration] -> ShowS
show :: AgentConfiguration -> String
$cshow :: AgentConfiguration -> String
showsPrec :: Int -> AgentConfiguration -> ShowS
$cshowsPrec :: Int -> AgentConfiguration -> ShowS
Prelude.Show, (forall x. AgentConfiguration -> Rep AgentConfiguration x)
-> (forall x. Rep AgentConfiguration x -> AgentConfiguration)
-> Generic AgentConfiguration
forall x. Rep AgentConfiguration x -> AgentConfiguration
forall x. AgentConfiguration -> Rep AgentConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AgentConfiguration x -> AgentConfiguration
$cfrom :: forall x. AgentConfiguration -> Rep AgentConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'AgentConfiguration' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'agentParameters', 'agentConfiguration_agentParameters' - Parameters used by the profiler. The valid parameters are:
--
-- -   @MaxStackDepth@ - The maximum depth of the stacks in the code that
--     is represented in the profile. For example, if CodeGuru Profiler
--     finds a method @A@, which calls method @B@, which calls method @C@,
--     which calls method @D@, then the depth is 4. If the @maxDepth@ is
--     set to 2, then the profiler evaluates @A@ and @B@.
--
-- -   @MemoryUsageLimitPercent@ - The percentage of memory that is used by
--     the profiler.
--
-- -   @MinimumTimeForReportingInMilliseconds@ - The minimum time in
--     milliseconds between sending reports.
--
-- -   @ReportingIntervalInMilliseconds@ - The reporting interval in
--     milliseconds used to report profiles.
--
-- -   @SamplingIntervalInMilliseconds@ - The sampling interval in
--     milliseconds that is used to profile samples.
--
-- 'periodInSeconds', 'agentConfiguration_periodInSeconds' - How long a profiling agent should send profiling data using
-- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_ConfigureAgent.html ConfigureAgent>
-- . For example, if this is set to 300, the profiling agent calls
-- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_ConfigureAgent.html ConfigureAgent>
-- every 5 minutes to submit the profiled data collected during that
-- period.
--
-- 'shouldProfile', 'agentConfiguration_shouldProfile' - A @Boolean@ that specifies whether the profiling agent collects
-- profiling data or not. Set to @true@ to enable profiling.
newAgentConfiguration ::
  -- | 'periodInSeconds'
  Prelude.Int ->
  -- | 'shouldProfile'
  Prelude.Bool ->
  AgentConfiguration
newAgentConfiguration :: Int -> Bool -> AgentConfiguration
newAgentConfiguration
  Int
pPeriodInSeconds_
  Bool
pShouldProfile_ =
    AgentConfiguration' :: Maybe (HashMap AgentParameterField Text)
-> Int -> Bool -> AgentConfiguration
AgentConfiguration'
      { $sel:agentParameters:AgentConfiguration' :: Maybe (HashMap AgentParameterField Text)
agentParameters =
          Maybe (HashMap AgentParameterField Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:periodInSeconds:AgentConfiguration' :: Int
periodInSeconds = Int
pPeriodInSeconds_,
        $sel:shouldProfile:AgentConfiguration' :: Bool
shouldProfile = Bool
pShouldProfile_
      }

-- | Parameters used by the profiler. The valid parameters are:
--
-- -   @MaxStackDepth@ - The maximum depth of the stacks in the code that
--     is represented in the profile. For example, if CodeGuru Profiler
--     finds a method @A@, which calls method @B@, which calls method @C@,
--     which calls method @D@, then the depth is 4. If the @maxDepth@ is
--     set to 2, then the profiler evaluates @A@ and @B@.
--
-- -   @MemoryUsageLimitPercent@ - The percentage of memory that is used by
--     the profiler.
--
-- -   @MinimumTimeForReportingInMilliseconds@ - The minimum time in
--     milliseconds between sending reports.
--
-- -   @ReportingIntervalInMilliseconds@ - The reporting interval in
--     milliseconds used to report profiles.
--
-- -   @SamplingIntervalInMilliseconds@ - The sampling interval in
--     milliseconds that is used to profile samples.
agentConfiguration_agentParameters :: Lens.Lens' AgentConfiguration (Prelude.Maybe (Prelude.HashMap AgentParameterField Prelude.Text))
agentConfiguration_agentParameters :: (Maybe (HashMap AgentParameterField Text)
 -> f (Maybe (HashMap AgentParameterField Text)))
-> AgentConfiguration -> f AgentConfiguration
agentConfiguration_agentParameters = (AgentConfiguration -> Maybe (HashMap AgentParameterField Text))
-> (AgentConfiguration
    -> Maybe (HashMap AgentParameterField Text) -> AgentConfiguration)
-> Lens
     AgentConfiguration
     AgentConfiguration
     (Maybe (HashMap AgentParameterField Text))
     (Maybe (HashMap AgentParameterField Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AgentConfiguration' {Maybe (HashMap AgentParameterField Text)
agentParameters :: Maybe (HashMap AgentParameterField Text)
$sel:agentParameters:AgentConfiguration' :: AgentConfiguration -> Maybe (HashMap AgentParameterField Text)
agentParameters} -> Maybe (HashMap AgentParameterField Text)
agentParameters) (\s :: AgentConfiguration
s@AgentConfiguration' {} Maybe (HashMap AgentParameterField Text)
a -> AgentConfiguration
s {$sel:agentParameters:AgentConfiguration' :: Maybe (HashMap AgentParameterField Text)
agentParameters = Maybe (HashMap AgentParameterField Text)
a} :: AgentConfiguration) ((Maybe (HashMap AgentParameterField Text)
  -> f (Maybe (HashMap AgentParameterField Text)))
 -> AgentConfiguration -> f AgentConfiguration)
-> ((Maybe (HashMap AgentParameterField Text)
     -> f (Maybe (HashMap AgentParameterField Text)))
    -> Maybe (HashMap AgentParameterField Text)
    -> f (Maybe (HashMap AgentParameterField Text)))
-> (Maybe (HashMap AgentParameterField Text)
    -> f (Maybe (HashMap AgentParameterField Text)))
-> AgentConfiguration
-> f AgentConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap AgentParameterField Text)
  (HashMap AgentParameterField Text)
  (HashMap AgentParameterField Text)
  (HashMap AgentParameterField Text)
-> Iso
     (Maybe (HashMap AgentParameterField Text))
     (Maybe (HashMap AgentParameterField Text))
     (Maybe (HashMap AgentParameterField Text))
     (Maybe (HashMap AgentParameterField Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap AgentParameterField Text)
  (HashMap AgentParameterField Text)
  (HashMap AgentParameterField Text)
  (HashMap AgentParameterField Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | How long a profiling agent should send profiling data using
-- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_ConfigureAgent.html ConfigureAgent>
-- . For example, if this is set to 300, the profiling agent calls
-- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_ConfigureAgent.html ConfigureAgent>
-- every 5 minutes to submit the profiled data collected during that
-- period.
agentConfiguration_periodInSeconds :: Lens.Lens' AgentConfiguration Prelude.Int
agentConfiguration_periodInSeconds :: (Int -> f Int) -> AgentConfiguration -> f AgentConfiguration
agentConfiguration_periodInSeconds = (AgentConfiguration -> Int)
-> (AgentConfiguration -> Int -> AgentConfiguration)
-> Lens AgentConfiguration AgentConfiguration Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AgentConfiguration' {Int
periodInSeconds :: Int
$sel:periodInSeconds:AgentConfiguration' :: AgentConfiguration -> Int
periodInSeconds} -> Int
periodInSeconds) (\s :: AgentConfiguration
s@AgentConfiguration' {} Int
a -> AgentConfiguration
s {$sel:periodInSeconds:AgentConfiguration' :: Int
periodInSeconds = Int
a} :: AgentConfiguration)

-- | A @Boolean@ that specifies whether the profiling agent collects
-- profiling data or not. Set to @true@ to enable profiling.
agentConfiguration_shouldProfile :: Lens.Lens' AgentConfiguration Prelude.Bool
agentConfiguration_shouldProfile :: (Bool -> f Bool) -> AgentConfiguration -> f AgentConfiguration
agentConfiguration_shouldProfile = (AgentConfiguration -> Bool)
-> (AgentConfiguration -> Bool -> AgentConfiguration)
-> Lens AgentConfiguration AgentConfiguration Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AgentConfiguration' {Bool
shouldProfile :: Bool
$sel:shouldProfile:AgentConfiguration' :: AgentConfiguration -> Bool
shouldProfile} -> Bool
shouldProfile) (\s :: AgentConfiguration
s@AgentConfiguration' {} Bool
a -> AgentConfiguration
s {$sel:shouldProfile:AgentConfiguration' :: Bool
shouldProfile = Bool
a} :: AgentConfiguration)

instance Core.FromJSON AgentConfiguration where
  parseJSON :: Value -> Parser AgentConfiguration
parseJSON =
    String
-> (Object -> Parser AgentConfiguration)
-> Value
-> Parser AgentConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AgentConfiguration"
      ( \Object
x ->
          Maybe (HashMap AgentParameterField Text)
-> Int -> Bool -> AgentConfiguration
AgentConfiguration'
            (Maybe (HashMap AgentParameterField Text)
 -> Int -> Bool -> AgentConfiguration)
-> Parser (Maybe (HashMap AgentParameterField Text))
-> Parser (Int -> Bool -> AgentConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text
-> Parser (Maybe (Maybe (HashMap AgentParameterField Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"agentParameters"
                            Parser (Maybe (Maybe (HashMap AgentParameterField Text)))
-> Maybe (HashMap AgentParameterField Text)
-> Parser (Maybe (HashMap AgentParameterField Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap AgentParameterField Text)
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Int -> Bool -> AgentConfiguration)
-> Parser Int -> Parser (Bool -> AgentConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"periodInSeconds")
            Parser (Bool -> AgentConfiguration)
-> Parser Bool -> Parser AgentConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"shouldProfile")
      )

instance Prelude.Hashable AgentConfiguration

instance Prelude.NFData AgentConfiguration