{-# 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.Pattern
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CodeGuruProfiler.Types.Pattern where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | A set of rules used to make a recommendation during an analysis.
--
-- /See:/ 'newPattern' smart constructor.
data Pattern = Pattern'
  { -- | A list of the different counters used to determine if there is a match.
    Pattern -> Maybe [Text]
countersToAggregate :: Prelude.Maybe [Prelude.Text],
    -- | The description of the recommendation. This explains a potential
    -- inefficiency in a profiled application.
    Pattern -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The universally unique identifier (UUID) of this pattern.
    Pattern -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The name for this pattern.
    Pattern -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A string that contains the steps recommended to address the potential
    -- inefficiency.
    Pattern -> Maybe Text
resolutionSteps :: Prelude.Maybe Prelude.Text,
    -- | A list of frame names that were searched during the analysis that
    -- generated a recommendation.
    Pattern -> Maybe [[Text]]
targetFrames :: Prelude.Maybe [[Prelude.Text]],
    -- | The percentage of time an application spends in one method that triggers
    -- a recommendation. The percentage of time is the same as the percentage
    -- of the total gathered sample counts during analysis.
    Pattern -> Maybe Double
thresholdPercent :: Prelude.Maybe Prelude.Double
  }
  deriving (Pattern -> Pattern -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Pattern -> Pattern -> Bool
$c/= :: Pattern -> Pattern -> Bool
== :: Pattern -> Pattern -> Bool
$c== :: Pattern -> Pattern -> Bool
Prelude.Eq, ReadPrec [Pattern]
ReadPrec Pattern
Int -> ReadS Pattern
ReadS [Pattern]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Pattern]
$creadListPrec :: ReadPrec [Pattern]
readPrec :: ReadPrec Pattern
$creadPrec :: ReadPrec Pattern
readList :: ReadS [Pattern]
$creadList :: ReadS [Pattern]
readsPrec :: Int -> ReadS Pattern
$creadsPrec :: Int -> ReadS Pattern
Prelude.Read, Int -> Pattern -> ShowS
[Pattern] -> ShowS
Pattern -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Pattern] -> ShowS
$cshowList :: [Pattern] -> ShowS
show :: Pattern -> String
$cshow :: Pattern -> String
showsPrec :: Int -> Pattern -> ShowS
$cshowsPrec :: Int -> Pattern -> ShowS
Prelude.Show, forall x. Rep Pattern x -> Pattern
forall x. Pattern -> Rep Pattern x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Pattern x -> Pattern
$cfrom :: forall x. Pattern -> Rep Pattern x
Prelude.Generic)

-- |
-- Create a value of 'Pattern' 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:
--
-- 'countersToAggregate', 'pattern_countersToAggregate' - A list of the different counters used to determine if there is a match.
--
-- 'description', 'pattern_description' - The description of the recommendation. This explains a potential
-- inefficiency in a profiled application.
--
-- 'id', 'pattern_id' - The universally unique identifier (UUID) of this pattern.
--
-- 'name', 'pattern_name' - The name for this pattern.
--
-- 'resolutionSteps', 'pattern_resolutionSteps' - A string that contains the steps recommended to address the potential
-- inefficiency.
--
-- 'targetFrames', 'pattern_targetFrames' - A list of frame names that were searched during the analysis that
-- generated a recommendation.
--
-- 'thresholdPercent', 'pattern_thresholdPercent' - The percentage of time an application spends in one method that triggers
-- a recommendation. The percentage of time is the same as the percentage
-- of the total gathered sample counts during analysis.
newPattern ::
  Pattern
newPattern :: Pattern
newPattern =
  Pattern'
    { $sel:countersToAggregate:Pattern' :: Maybe [Text]
countersToAggregate = forall a. Maybe a
Prelude.Nothing,
      $sel:description:Pattern' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Pattern' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Pattern' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:resolutionSteps:Pattern' :: Maybe Text
resolutionSteps = forall a. Maybe a
Prelude.Nothing,
      $sel:targetFrames:Pattern' :: Maybe [[Text]]
targetFrames = forall a. Maybe a
Prelude.Nothing,
      $sel:thresholdPercent:Pattern' :: Maybe Double
thresholdPercent = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of the different counters used to determine if there is a match.
pattern_countersToAggregate :: Lens.Lens' Pattern (Prelude.Maybe [Prelude.Text])
pattern_countersToAggregate :: Lens' Pattern (Maybe [Text])
pattern_countersToAggregate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Pattern' {Maybe [Text]
countersToAggregate :: Maybe [Text]
$sel:countersToAggregate:Pattern' :: Pattern -> Maybe [Text]
countersToAggregate} -> Maybe [Text]
countersToAggregate) (\s :: Pattern
s@Pattern' {} Maybe [Text]
a -> Pattern
s {$sel:countersToAggregate:Pattern' :: Maybe [Text]
countersToAggregate = Maybe [Text]
a} :: Pattern) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The description of the recommendation. This explains a potential
-- inefficiency in a profiled application.
pattern_description :: Lens.Lens' Pattern (Prelude.Maybe Prelude.Text)
pattern_description :: Lens' Pattern (Maybe Text)
pattern_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Pattern' {Maybe Text
description :: Maybe Text
$sel:description:Pattern' :: Pattern -> Maybe Text
description} -> Maybe Text
description) (\s :: Pattern
s@Pattern' {} Maybe Text
a -> Pattern
s {$sel:description:Pattern' :: Maybe Text
description = Maybe Text
a} :: Pattern)

-- | The universally unique identifier (UUID) of this pattern.
pattern_id :: Lens.Lens' Pattern (Prelude.Maybe Prelude.Text)
pattern_id :: Lens' Pattern (Maybe Text)
pattern_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Pattern' {Maybe Text
id :: Maybe Text
$sel:id:Pattern' :: Pattern -> Maybe Text
id} -> Maybe Text
id) (\s :: Pattern
s@Pattern' {} Maybe Text
a -> Pattern
s {$sel:id:Pattern' :: Maybe Text
id = Maybe Text
a} :: Pattern)

-- | The name for this pattern.
pattern_name :: Lens.Lens' Pattern (Prelude.Maybe Prelude.Text)
pattern_name :: Lens' Pattern (Maybe Text)
pattern_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Pattern' {Maybe Text
name :: Maybe Text
$sel:name:Pattern' :: Pattern -> Maybe Text
name} -> Maybe Text
name) (\s :: Pattern
s@Pattern' {} Maybe Text
a -> Pattern
s {$sel:name:Pattern' :: Maybe Text
name = Maybe Text
a} :: Pattern)

-- | A string that contains the steps recommended to address the potential
-- inefficiency.
pattern_resolutionSteps :: Lens.Lens' Pattern (Prelude.Maybe Prelude.Text)
pattern_resolutionSteps :: Lens' Pattern (Maybe Text)
pattern_resolutionSteps = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Pattern' {Maybe Text
resolutionSteps :: Maybe Text
$sel:resolutionSteps:Pattern' :: Pattern -> Maybe Text
resolutionSteps} -> Maybe Text
resolutionSteps) (\s :: Pattern
s@Pattern' {} Maybe Text
a -> Pattern
s {$sel:resolutionSteps:Pattern' :: Maybe Text
resolutionSteps = Maybe Text
a} :: Pattern)

-- | A list of frame names that were searched during the analysis that
-- generated a recommendation.
pattern_targetFrames :: Lens.Lens' Pattern (Prelude.Maybe [[Prelude.Text]])
pattern_targetFrames :: Lens' Pattern (Maybe [[Text]])
pattern_targetFrames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Pattern' {Maybe [[Text]]
targetFrames :: Maybe [[Text]]
$sel:targetFrames:Pattern' :: Pattern -> Maybe [[Text]]
targetFrames} -> Maybe [[Text]]
targetFrames) (\s :: Pattern
s@Pattern' {} Maybe [[Text]]
a -> Pattern
s {$sel:targetFrames:Pattern' :: Maybe [[Text]]
targetFrames = Maybe [[Text]]
a} :: Pattern) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The percentage of time an application spends in one method that triggers
-- a recommendation. The percentage of time is the same as the percentage
-- of the total gathered sample counts during analysis.
pattern_thresholdPercent :: Lens.Lens' Pattern (Prelude.Maybe Prelude.Double)
pattern_thresholdPercent :: Lens' Pattern (Maybe Double)
pattern_thresholdPercent = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Pattern' {Maybe Double
thresholdPercent :: Maybe Double
$sel:thresholdPercent:Pattern' :: Pattern -> Maybe Double
thresholdPercent} -> Maybe Double
thresholdPercent) (\s :: Pattern
s@Pattern' {} Maybe Double
a -> Pattern
s {$sel:thresholdPercent:Pattern' :: Maybe Double
thresholdPercent = Maybe Double
a} :: Pattern)

instance Data.FromJSON Pattern where
  parseJSON :: Value -> Parser Pattern
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Pattern"
      ( \Object
x ->
          Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [[Text]]
-> Maybe Double
-> Pattern
Pattern'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"countersToAggregate"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"description")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"id")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"resolutionSteps")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"targetFrames" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"thresholdPercent")
      )

instance Prelude.Hashable Pattern where
  hashWithSalt :: Int -> Pattern -> Int
hashWithSalt Int
_salt Pattern' {Maybe Double
Maybe [[Text]]
Maybe [Text]
Maybe Text
thresholdPercent :: Maybe Double
targetFrames :: Maybe [[Text]]
resolutionSteps :: Maybe Text
name :: Maybe Text
id :: Maybe Text
description :: Maybe Text
countersToAggregate :: Maybe [Text]
$sel:thresholdPercent:Pattern' :: Pattern -> Maybe Double
$sel:targetFrames:Pattern' :: Pattern -> Maybe [[Text]]
$sel:resolutionSteps:Pattern' :: Pattern -> Maybe Text
$sel:name:Pattern' :: Pattern -> Maybe Text
$sel:id:Pattern' :: Pattern -> Maybe Text
$sel:description:Pattern' :: Pattern -> Maybe Text
$sel:countersToAggregate:Pattern' :: Pattern -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
countersToAggregate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resolutionSteps
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [[Text]]
targetFrames
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
thresholdPercent

instance Prelude.NFData Pattern where
  rnf :: Pattern -> ()
rnf Pattern' {Maybe Double
Maybe [[Text]]
Maybe [Text]
Maybe Text
thresholdPercent :: Maybe Double
targetFrames :: Maybe [[Text]]
resolutionSteps :: Maybe Text
name :: Maybe Text
id :: Maybe Text
description :: Maybe Text
countersToAggregate :: Maybe [Text]
$sel:thresholdPercent:Pattern' :: Pattern -> Maybe Double
$sel:targetFrames:Pattern' :: Pattern -> Maybe [[Text]]
$sel:resolutionSteps:Pattern' :: Pattern -> Maybe Text
$sel:name:Pattern' :: Pattern -> Maybe Text
$sel:id:Pattern' :: Pattern -> Maybe Text
$sel:description:Pattern' :: Pattern -> Maybe Text
$sel:countersToAggregate:Pattern' :: Pattern -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
countersToAggregate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resolutionSteps
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [[Text]]
targetFrames
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
thresholdPercent