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

import Amazonka.CodeGuruProfiler.Types.Match
import Amazonka.CodeGuruProfiler.Types.Pattern
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 potential improvement that was found from analyzing the profiling
-- data.
--
-- /See:/ 'newRecommendation' smart constructor.
data Recommendation = Recommendation'
  { -- | How many different places in the profile graph triggered a match.
    Recommendation -> Int
allMatchesCount :: Prelude.Int,
    -- | How much of the total sample count is potentially affected.
    Recommendation -> Double
allMatchesSum :: Prelude.Double,
    -- | End time of the profile that was used by this analysis. This is
    -- specified using the ISO 8601 format. For example,
    -- 2020-06-01T13:15:02.001Z represents 1 millisecond past June 1, 2020
    -- 1:15:02 PM UTC.
    Recommendation -> ISO8601
endTime :: Data.ISO8601,
    -- | The pattern that analysis recognized in the profile to make this
    -- recommendation.
    Recommendation -> Pattern
pattern' :: Pattern,
    -- | The start time of the profile that was used by this analysis. This is
    -- specified using the ISO 8601 format. For example,
    -- 2020-06-01T13:15:02.001Z represents 1 millisecond past June 1, 2020
    -- 1:15:02 PM UTC.
    Recommendation -> ISO8601
startTime :: Data.ISO8601,
    -- | List of the matches with most impact.
    Recommendation -> [Match]
topMatches :: [Match]
  }
  deriving (Recommendation -> Recommendation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Recommendation -> Recommendation -> Bool
$c/= :: Recommendation -> Recommendation -> Bool
== :: Recommendation -> Recommendation -> Bool
$c== :: Recommendation -> Recommendation -> Bool
Prelude.Eq, ReadPrec [Recommendation]
ReadPrec Recommendation
Int -> ReadS Recommendation
ReadS [Recommendation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Recommendation]
$creadListPrec :: ReadPrec [Recommendation]
readPrec :: ReadPrec Recommendation
$creadPrec :: ReadPrec Recommendation
readList :: ReadS [Recommendation]
$creadList :: ReadS [Recommendation]
readsPrec :: Int -> ReadS Recommendation
$creadsPrec :: Int -> ReadS Recommendation
Prelude.Read, Int -> Recommendation -> ShowS
[Recommendation] -> ShowS
Recommendation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Recommendation] -> ShowS
$cshowList :: [Recommendation] -> ShowS
show :: Recommendation -> String
$cshow :: Recommendation -> String
showsPrec :: Int -> Recommendation -> ShowS
$cshowsPrec :: Int -> Recommendation -> ShowS
Prelude.Show, forall x. Rep Recommendation x -> Recommendation
forall x. Recommendation -> Rep Recommendation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Recommendation x -> Recommendation
$cfrom :: forall x. Recommendation -> Rep Recommendation x
Prelude.Generic)

-- |
-- Create a value of 'Recommendation' 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:
--
-- 'allMatchesCount', 'recommendation_allMatchesCount' - How many different places in the profile graph triggered a match.
--
-- 'allMatchesSum', 'recommendation_allMatchesSum' - How much of the total sample count is potentially affected.
--
-- 'endTime', 'recommendation_endTime' - End time of the profile that was used by this analysis. This is
-- specified using the ISO 8601 format. For example,
-- 2020-06-01T13:15:02.001Z represents 1 millisecond past June 1, 2020
-- 1:15:02 PM UTC.
--
-- 'pattern'', 'recommendation_pattern' - The pattern that analysis recognized in the profile to make this
-- recommendation.
--
-- 'startTime', 'recommendation_startTime' - The start time of the profile that was used by this analysis. This is
-- specified using the ISO 8601 format. For example,
-- 2020-06-01T13:15:02.001Z represents 1 millisecond past June 1, 2020
-- 1:15:02 PM UTC.
--
-- 'topMatches', 'recommendation_topMatches' - List of the matches with most impact.
newRecommendation ::
  -- | 'allMatchesCount'
  Prelude.Int ->
  -- | 'allMatchesSum'
  Prelude.Double ->
  -- | 'endTime'
  Prelude.UTCTime ->
  -- | 'pattern''
  Pattern ->
  -- | 'startTime'
  Prelude.UTCTime ->
  Recommendation
newRecommendation :: Int -> Double -> UTCTime -> Pattern -> UTCTime -> Recommendation
newRecommendation
  Int
pAllMatchesCount_
  Double
pAllMatchesSum_
  UTCTime
pEndTime_
  Pattern
pPattern_
  UTCTime
pStartTime_ =
    Recommendation'
      { $sel:allMatchesCount:Recommendation' :: Int
allMatchesCount =
          Int
pAllMatchesCount_,
        $sel:allMatchesSum:Recommendation' :: Double
allMatchesSum = Double
pAllMatchesSum_,
        $sel:endTime:Recommendation' :: ISO8601
endTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTime_,
        $sel:pattern':Recommendation' :: Pattern
pattern' = Pattern
pPattern_,
        $sel:startTime:Recommendation' :: ISO8601
startTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_,
        $sel:topMatches:Recommendation' :: [Match]
topMatches = forall a. Monoid a => a
Prelude.mempty
      }

-- | How many different places in the profile graph triggered a match.
recommendation_allMatchesCount :: Lens.Lens' Recommendation Prelude.Int
recommendation_allMatchesCount :: Lens' Recommendation Int
recommendation_allMatchesCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recommendation' {Int
allMatchesCount :: Int
$sel:allMatchesCount:Recommendation' :: Recommendation -> Int
allMatchesCount} -> Int
allMatchesCount) (\s :: Recommendation
s@Recommendation' {} Int
a -> Recommendation
s {$sel:allMatchesCount:Recommendation' :: Int
allMatchesCount = Int
a} :: Recommendation)

-- | How much of the total sample count is potentially affected.
recommendation_allMatchesSum :: Lens.Lens' Recommendation Prelude.Double
recommendation_allMatchesSum :: Lens' Recommendation Double
recommendation_allMatchesSum = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recommendation' {Double
allMatchesSum :: Double
$sel:allMatchesSum:Recommendation' :: Recommendation -> Double
allMatchesSum} -> Double
allMatchesSum) (\s :: Recommendation
s@Recommendation' {} Double
a -> Recommendation
s {$sel:allMatchesSum:Recommendation' :: Double
allMatchesSum = Double
a} :: Recommendation)

-- | End time of the profile that was used by this analysis. This is
-- specified using the ISO 8601 format. For example,
-- 2020-06-01T13:15:02.001Z represents 1 millisecond past June 1, 2020
-- 1:15:02 PM UTC.
recommendation_endTime :: Lens.Lens' Recommendation Prelude.UTCTime
recommendation_endTime :: Lens' Recommendation UTCTime
recommendation_endTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recommendation' {ISO8601
endTime :: ISO8601
$sel:endTime:Recommendation' :: Recommendation -> ISO8601
endTime} -> ISO8601
endTime) (\s :: Recommendation
s@Recommendation' {} ISO8601
a -> Recommendation
s {$sel:endTime:Recommendation' :: ISO8601
endTime = ISO8601
a} :: Recommendation) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The pattern that analysis recognized in the profile to make this
-- recommendation.
recommendation_pattern :: Lens.Lens' Recommendation Pattern
recommendation_pattern :: Lens' Recommendation Pattern
recommendation_pattern = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recommendation' {Pattern
pattern' :: Pattern
$sel:pattern':Recommendation' :: Recommendation -> Pattern
pattern'} -> Pattern
pattern') (\s :: Recommendation
s@Recommendation' {} Pattern
a -> Recommendation
s {$sel:pattern':Recommendation' :: Pattern
pattern' = Pattern
a} :: Recommendation)

-- | The start time of the profile that was used by this analysis. This is
-- specified using the ISO 8601 format. For example,
-- 2020-06-01T13:15:02.001Z represents 1 millisecond past June 1, 2020
-- 1:15:02 PM UTC.
recommendation_startTime :: Lens.Lens' Recommendation Prelude.UTCTime
recommendation_startTime :: Lens' Recommendation UTCTime
recommendation_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recommendation' {ISO8601
startTime :: ISO8601
$sel:startTime:Recommendation' :: Recommendation -> ISO8601
startTime} -> ISO8601
startTime) (\s :: Recommendation
s@Recommendation' {} ISO8601
a -> Recommendation
s {$sel:startTime:Recommendation' :: ISO8601
startTime = ISO8601
a} :: Recommendation) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | List of the matches with most impact.
recommendation_topMatches :: Lens.Lens' Recommendation [Match]
recommendation_topMatches :: Lens' Recommendation [Match]
recommendation_topMatches = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Recommendation' {[Match]
topMatches :: [Match]
$sel:topMatches:Recommendation' :: Recommendation -> [Match]
topMatches} -> [Match]
topMatches) (\s :: Recommendation
s@Recommendation' {} [Match]
a -> Recommendation
s {$sel:topMatches:Recommendation' :: [Match]
topMatches = [Match]
a} :: Recommendation) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON Recommendation where
  parseJSON :: Value -> Parser Recommendation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Recommendation"
      ( \Object
x ->
          Int
-> Double
-> ISO8601
-> Pattern
-> ISO8601
-> [Match]
-> Recommendation
Recommendation'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"allMatchesCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"allMatchesSum")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"endTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"pattern")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"startTime")
            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
"topMatches" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Recommendation where
  hashWithSalt :: Int -> Recommendation -> Int
hashWithSalt Int
_salt Recommendation' {Double
Int
[Match]
ISO8601
Pattern
topMatches :: [Match]
startTime :: ISO8601
pattern' :: Pattern
endTime :: ISO8601
allMatchesSum :: Double
allMatchesCount :: Int
$sel:topMatches:Recommendation' :: Recommendation -> [Match]
$sel:startTime:Recommendation' :: Recommendation -> ISO8601
$sel:pattern':Recommendation' :: Recommendation -> Pattern
$sel:endTime:Recommendation' :: Recommendation -> ISO8601
$sel:allMatchesSum:Recommendation' :: Recommendation -> Double
$sel:allMatchesCount:Recommendation' :: Recommendation -> Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
allMatchesCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
allMatchesSum
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
endTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Pattern
pattern'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
startTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Match]
topMatches

instance Prelude.NFData Recommendation where
  rnf :: Recommendation -> ()
rnf Recommendation' {Double
Int
[Match]
ISO8601
Pattern
topMatches :: [Match]
startTime :: ISO8601
pattern' :: Pattern
endTime :: ISO8601
allMatchesSum :: Double
allMatchesCount :: Int
$sel:topMatches:Recommendation' :: Recommendation -> [Match]
$sel:startTime:Recommendation' :: Recommendation -> ISO8601
$sel:pattern':Recommendation' :: Recommendation -> Pattern
$sel:endTime:Recommendation' :: Recommendation -> ISO8601
$sel:allMatchesSum:Recommendation' :: Recommendation -> Double
$sel:allMatchesCount:Recommendation' :: Recommendation -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
allMatchesCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
allMatchesSum
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ISO8601
endTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Pattern
pattern'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ISO8601
startTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Match]
topMatches