{-# 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-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.Pattern where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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,
    -- | A list of frame names that were searched during the analysis that
    -- generated a recommendation.
    Pattern -> Maybe [[Text]]
targetFrames :: Prelude.Maybe [[Prelude.Text]],
    -- | A list of the different counters used to determine if there is a match.
    Pattern -> Maybe [Text]
countersToAggregate :: 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,
    -- | The universally unique identifier (UUID) of this pattern.
    Pattern -> Maybe Text
id :: 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
  }
  deriving (Pattern -> Pattern -> Bool
(Pattern -> Pattern -> Bool)
-> (Pattern -> Pattern -> Bool) -> Eq Pattern
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]
(Int -> ReadS Pattern)
-> ReadS [Pattern]
-> ReadPrec Pattern
-> ReadPrec [Pattern]
-> Read 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
(Int -> Pattern -> ShowS)
-> (Pattern -> String) -> ([Pattern] -> ShowS) -> Show Pattern
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. Pattern -> Rep Pattern x)
-> (forall x. Rep Pattern x -> Pattern) -> Generic Pattern
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:
--
-- '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.
--
-- 'targetFrames', 'pattern_targetFrames' - A list of frame names that were searched during the analysis that
-- generated a recommendation.
--
-- 'countersToAggregate', 'pattern_countersToAggregate' - A list of the different counters used to determine if there is a match.
--
-- 'name', 'pattern_name' - The name for this pattern.
--
-- 'resolutionSteps', 'pattern_resolutionSteps' - A string that contains the steps recommended to address the potential
-- inefficiency.
--
-- 'id', 'pattern_id' - The universally unique identifier (UUID) of this pattern.
--
-- 'description', 'pattern_description' - The description of the recommendation. This explains a potential
-- inefficiency in a profiled application.
newPattern ::
  Pattern
newPattern :: Pattern
newPattern =
  Pattern' :: Maybe Double
-> Maybe [[Text]]
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Pattern
Pattern'
    { $sel:thresholdPercent:Pattern' :: Maybe Double
thresholdPercent = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:targetFrames:Pattern' :: Maybe [[Text]]
targetFrames = Maybe [[Text]]
forall a. Maybe a
Prelude.Nothing,
      $sel:countersToAggregate:Pattern' :: Maybe [Text]
countersToAggregate = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Pattern' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resolutionSteps:Pattern' :: Maybe Text
resolutionSteps = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Pattern' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:Pattern' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Double -> f (Maybe Double)) -> Pattern -> f Pattern
pattern_thresholdPercent = (Pattern -> Maybe Double)
-> (Pattern -> Maybe Double -> Pattern)
-> Lens Pattern Pattern (Maybe Double) (Maybe Double)
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)

-- | 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 :: (Maybe [[Text]] -> f (Maybe [[Text]])) -> Pattern -> f Pattern
pattern_targetFrames = (Pattern -> Maybe [[Text]])
-> (Pattern -> Maybe [[Text]] -> Pattern)
-> Lens Pattern Pattern (Maybe [[Text]]) (Maybe [[Text]])
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) ((Maybe [[Text]] -> f (Maybe [[Text]])) -> Pattern -> f Pattern)
-> ((Maybe [[Text]] -> f (Maybe [[Text]]))
    -> Maybe [[Text]] -> f (Maybe [[Text]]))
-> (Maybe [[Text]] -> f (Maybe [[Text]]))
-> Pattern
-> f Pattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [[Text]] [[Text]] [[Text]] [[Text]]
-> Iso
     (Maybe [[Text]]) (Maybe [[Text]]) (Maybe [[Text]]) (Maybe [[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 [[Text]] [[Text]] [[Text]] [[Text]]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe [Text] -> f (Maybe [Text])) -> Pattern -> f Pattern
pattern_countersToAggregate = (Pattern -> Maybe [Text])
-> (Pattern -> Maybe [Text] -> Pattern)
-> Lens Pattern Pattern (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text])) -> Pattern -> f Pattern)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Pattern
-> f Pattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name for this pattern.
pattern_name :: Lens.Lens' Pattern (Prelude.Maybe Prelude.Text)
pattern_name :: (Maybe Text -> f (Maybe Text)) -> Pattern -> f Pattern
pattern_name = (Pattern -> Maybe Text)
-> (Pattern -> Maybe Text -> Pattern)
-> Lens Pattern Pattern (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> Pattern -> f Pattern
pattern_resolutionSteps = (Pattern -> Maybe Text)
-> (Pattern -> Maybe Text -> Pattern)
-> Lens Pattern Pattern (Maybe Text) (Maybe Text)
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)

-- | The universally unique identifier (UUID) of this pattern.
pattern_id :: Lens.Lens' Pattern (Prelude.Maybe Prelude.Text)
pattern_id :: (Maybe Text -> f (Maybe Text)) -> Pattern -> f Pattern
pattern_id = (Pattern -> Maybe Text)
-> (Pattern -> Maybe Text -> Pattern)
-> Lens Pattern Pattern (Maybe Text) (Maybe Text)
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 description of the recommendation. This explains a potential
-- inefficiency in a profiled application.
pattern_description :: Lens.Lens' Pattern (Prelude.Maybe Prelude.Text)
pattern_description :: (Maybe Text -> f (Maybe Text)) -> Pattern -> f Pattern
pattern_description = (Pattern -> Maybe Text)
-> (Pattern -> Maybe Text -> Pattern)
-> Lens Pattern Pattern (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable Pattern

instance Prelude.NFData Pattern