{-# 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.CostExplorer.Types.RightsizingRecommendation
-- 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.CostExplorer.Types.RightsizingRecommendation where

import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.Types.CurrentInstance
import Amazonka.CostExplorer.Types.FindingReasonCode
import Amazonka.CostExplorer.Types.ModifyRecommendationDetail
import Amazonka.CostExplorer.Types.RightsizingType
import Amazonka.CostExplorer.Types.TerminateRecommendationDetail
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Recommendations to rightsize resources.
--
-- /See:/ 'newRightsizingRecommendation' smart constructor.
data RightsizingRecommendation = RightsizingRecommendation'
  { -- | The account that this recommendation is for.
    RightsizingRecommendation -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The list of possible reasons why the recommendation is generated such as
    -- under or over utilization of specific metrics (for example, CPU, Memory,
    -- Network).
    RightsizingRecommendation -> Maybe [FindingReasonCode]
findingReasonCodes :: Prelude.Maybe [FindingReasonCode],
    -- | The details for the modification recommendations.
    RightsizingRecommendation -> Maybe ModifyRecommendationDetail
modifyRecommendationDetail :: Prelude.Maybe ModifyRecommendationDetail,
    -- | Context regarding the current instance.
    RightsizingRecommendation -> Maybe CurrentInstance
currentInstance :: Prelude.Maybe CurrentInstance,
    -- | A recommendation to either terminate or modify the resource.
    RightsizingRecommendation -> Maybe RightsizingType
rightsizingType :: Prelude.Maybe RightsizingType,
    -- | The details for termination recommendations.
    RightsizingRecommendation -> Maybe TerminateRecommendationDetail
terminateRecommendationDetail :: Prelude.Maybe TerminateRecommendationDetail
  }
  deriving (RightsizingRecommendation -> RightsizingRecommendation -> Bool
(RightsizingRecommendation -> RightsizingRecommendation -> Bool)
-> (RightsizingRecommendation -> RightsizingRecommendation -> Bool)
-> Eq RightsizingRecommendation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RightsizingRecommendation -> RightsizingRecommendation -> Bool
$c/= :: RightsizingRecommendation -> RightsizingRecommendation -> Bool
== :: RightsizingRecommendation -> RightsizingRecommendation -> Bool
$c== :: RightsizingRecommendation -> RightsizingRecommendation -> Bool
Prelude.Eq, ReadPrec [RightsizingRecommendation]
ReadPrec RightsizingRecommendation
Int -> ReadS RightsizingRecommendation
ReadS [RightsizingRecommendation]
(Int -> ReadS RightsizingRecommendation)
-> ReadS [RightsizingRecommendation]
-> ReadPrec RightsizingRecommendation
-> ReadPrec [RightsizingRecommendation]
-> Read RightsizingRecommendation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RightsizingRecommendation]
$creadListPrec :: ReadPrec [RightsizingRecommendation]
readPrec :: ReadPrec RightsizingRecommendation
$creadPrec :: ReadPrec RightsizingRecommendation
readList :: ReadS [RightsizingRecommendation]
$creadList :: ReadS [RightsizingRecommendation]
readsPrec :: Int -> ReadS RightsizingRecommendation
$creadsPrec :: Int -> ReadS RightsizingRecommendation
Prelude.Read, Int -> RightsizingRecommendation -> ShowS
[RightsizingRecommendation] -> ShowS
RightsizingRecommendation -> String
(Int -> RightsizingRecommendation -> ShowS)
-> (RightsizingRecommendation -> String)
-> ([RightsizingRecommendation] -> ShowS)
-> Show RightsizingRecommendation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RightsizingRecommendation] -> ShowS
$cshowList :: [RightsizingRecommendation] -> ShowS
show :: RightsizingRecommendation -> String
$cshow :: RightsizingRecommendation -> String
showsPrec :: Int -> RightsizingRecommendation -> ShowS
$cshowsPrec :: Int -> RightsizingRecommendation -> ShowS
Prelude.Show, (forall x.
 RightsizingRecommendation -> Rep RightsizingRecommendation x)
-> (forall x.
    Rep RightsizingRecommendation x -> RightsizingRecommendation)
-> Generic RightsizingRecommendation
forall x.
Rep RightsizingRecommendation x -> RightsizingRecommendation
forall x.
RightsizingRecommendation -> Rep RightsizingRecommendation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RightsizingRecommendation x -> RightsizingRecommendation
$cfrom :: forall x.
RightsizingRecommendation -> Rep RightsizingRecommendation x
Prelude.Generic)

-- |
-- Create a value of 'RightsizingRecommendation' 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:
--
-- 'accountId', 'rightsizingRecommendation_accountId' - The account that this recommendation is for.
--
-- 'findingReasonCodes', 'rightsizingRecommendation_findingReasonCodes' - The list of possible reasons why the recommendation is generated such as
-- under or over utilization of specific metrics (for example, CPU, Memory,
-- Network).
--
-- 'modifyRecommendationDetail', 'rightsizingRecommendation_modifyRecommendationDetail' - The details for the modification recommendations.
--
-- 'currentInstance', 'rightsizingRecommendation_currentInstance' - Context regarding the current instance.
--
-- 'rightsizingType', 'rightsizingRecommendation_rightsizingType' - A recommendation to either terminate or modify the resource.
--
-- 'terminateRecommendationDetail', 'rightsizingRecommendation_terminateRecommendationDetail' - The details for termination recommendations.
newRightsizingRecommendation ::
  RightsizingRecommendation
newRightsizingRecommendation :: RightsizingRecommendation
newRightsizingRecommendation =
  RightsizingRecommendation' :: Maybe Text
-> Maybe [FindingReasonCode]
-> Maybe ModifyRecommendationDetail
-> Maybe CurrentInstance
-> Maybe RightsizingType
-> Maybe TerminateRecommendationDetail
-> RightsizingRecommendation
RightsizingRecommendation'
    { $sel:accountId:RightsizingRecommendation' :: Maybe Text
accountId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:findingReasonCodes:RightsizingRecommendation' :: Maybe [FindingReasonCode]
findingReasonCodes = Maybe [FindingReasonCode]
forall a. Maybe a
Prelude.Nothing,
      $sel:modifyRecommendationDetail:RightsizingRecommendation' :: Maybe ModifyRecommendationDetail
modifyRecommendationDetail = Maybe ModifyRecommendationDetail
forall a. Maybe a
Prelude.Nothing,
      $sel:currentInstance:RightsizingRecommendation' :: Maybe CurrentInstance
currentInstance = Maybe CurrentInstance
forall a. Maybe a
Prelude.Nothing,
      $sel:rightsizingType:RightsizingRecommendation' :: Maybe RightsizingType
rightsizingType = Maybe RightsizingType
forall a. Maybe a
Prelude.Nothing,
      $sel:terminateRecommendationDetail:RightsizingRecommendation' :: Maybe TerminateRecommendationDetail
terminateRecommendationDetail = Maybe TerminateRecommendationDetail
forall a. Maybe a
Prelude.Nothing
    }

-- | The account that this recommendation is for.
rightsizingRecommendation_accountId :: Lens.Lens' RightsizingRecommendation (Prelude.Maybe Prelude.Text)
rightsizingRecommendation_accountId :: (Maybe Text -> f (Maybe Text))
-> RightsizingRecommendation -> f RightsizingRecommendation
rightsizingRecommendation_accountId = (RightsizingRecommendation -> Maybe Text)
-> (RightsizingRecommendation
    -> Maybe Text -> RightsizingRecommendation)
-> Lens
     RightsizingRecommendation
     RightsizingRecommendation
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RightsizingRecommendation' {Maybe Text
accountId :: Maybe Text
$sel:accountId:RightsizingRecommendation' :: RightsizingRecommendation -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: RightsizingRecommendation
s@RightsizingRecommendation' {} Maybe Text
a -> RightsizingRecommendation
s {$sel:accountId:RightsizingRecommendation' :: Maybe Text
accountId = Maybe Text
a} :: RightsizingRecommendation)

-- | The list of possible reasons why the recommendation is generated such as
-- under or over utilization of specific metrics (for example, CPU, Memory,
-- Network).
rightsizingRecommendation_findingReasonCodes :: Lens.Lens' RightsizingRecommendation (Prelude.Maybe [FindingReasonCode])
rightsizingRecommendation_findingReasonCodes :: (Maybe [FindingReasonCode] -> f (Maybe [FindingReasonCode]))
-> RightsizingRecommendation -> f RightsizingRecommendation
rightsizingRecommendation_findingReasonCodes = (RightsizingRecommendation -> Maybe [FindingReasonCode])
-> (RightsizingRecommendation
    -> Maybe [FindingReasonCode] -> RightsizingRecommendation)
-> Lens
     RightsizingRecommendation
     RightsizingRecommendation
     (Maybe [FindingReasonCode])
     (Maybe [FindingReasonCode])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RightsizingRecommendation' {Maybe [FindingReasonCode]
findingReasonCodes :: Maybe [FindingReasonCode]
$sel:findingReasonCodes:RightsizingRecommendation' :: RightsizingRecommendation -> Maybe [FindingReasonCode]
findingReasonCodes} -> Maybe [FindingReasonCode]
findingReasonCodes) (\s :: RightsizingRecommendation
s@RightsizingRecommendation' {} Maybe [FindingReasonCode]
a -> RightsizingRecommendation
s {$sel:findingReasonCodes:RightsizingRecommendation' :: Maybe [FindingReasonCode]
findingReasonCodes = Maybe [FindingReasonCode]
a} :: RightsizingRecommendation) ((Maybe [FindingReasonCode] -> f (Maybe [FindingReasonCode]))
 -> RightsizingRecommendation -> f RightsizingRecommendation)
-> ((Maybe [FindingReasonCode] -> f (Maybe [FindingReasonCode]))
    -> Maybe [FindingReasonCode] -> f (Maybe [FindingReasonCode]))
-> (Maybe [FindingReasonCode] -> f (Maybe [FindingReasonCode]))
-> RightsizingRecommendation
-> f RightsizingRecommendation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [FindingReasonCode]
  [FindingReasonCode]
  [FindingReasonCode]
  [FindingReasonCode]
-> Iso
     (Maybe [FindingReasonCode])
     (Maybe [FindingReasonCode])
     (Maybe [FindingReasonCode])
     (Maybe [FindingReasonCode])
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
  [FindingReasonCode]
  [FindingReasonCode]
  [FindingReasonCode]
  [FindingReasonCode]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The details for the modification recommendations.
rightsizingRecommendation_modifyRecommendationDetail :: Lens.Lens' RightsizingRecommendation (Prelude.Maybe ModifyRecommendationDetail)
rightsizingRecommendation_modifyRecommendationDetail :: (Maybe ModifyRecommendationDetail
 -> f (Maybe ModifyRecommendationDetail))
-> RightsizingRecommendation -> f RightsizingRecommendation
rightsizingRecommendation_modifyRecommendationDetail = (RightsizingRecommendation -> Maybe ModifyRecommendationDetail)
-> (RightsizingRecommendation
    -> Maybe ModifyRecommendationDetail -> RightsizingRecommendation)
-> Lens
     RightsizingRecommendation
     RightsizingRecommendation
     (Maybe ModifyRecommendationDetail)
     (Maybe ModifyRecommendationDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RightsizingRecommendation' {Maybe ModifyRecommendationDetail
modifyRecommendationDetail :: Maybe ModifyRecommendationDetail
$sel:modifyRecommendationDetail:RightsizingRecommendation' :: RightsizingRecommendation -> Maybe ModifyRecommendationDetail
modifyRecommendationDetail} -> Maybe ModifyRecommendationDetail
modifyRecommendationDetail) (\s :: RightsizingRecommendation
s@RightsizingRecommendation' {} Maybe ModifyRecommendationDetail
a -> RightsizingRecommendation
s {$sel:modifyRecommendationDetail:RightsizingRecommendation' :: Maybe ModifyRecommendationDetail
modifyRecommendationDetail = Maybe ModifyRecommendationDetail
a} :: RightsizingRecommendation)

-- | Context regarding the current instance.
rightsizingRecommendation_currentInstance :: Lens.Lens' RightsizingRecommendation (Prelude.Maybe CurrentInstance)
rightsizingRecommendation_currentInstance :: (Maybe CurrentInstance -> f (Maybe CurrentInstance))
-> RightsizingRecommendation -> f RightsizingRecommendation
rightsizingRecommendation_currentInstance = (RightsizingRecommendation -> Maybe CurrentInstance)
-> (RightsizingRecommendation
    -> Maybe CurrentInstance -> RightsizingRecommendation)
-> Lens
     RightsizingRecommendation
     RightsizingRecommendation
     (Maybe CurrentInstance)
     (Maybe CurrentInstance)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RightsizingRecommendation' {Maybe CurrentInstance
currentInstance :: Maybe CurrentInstance
$sel:currentInstance:RightsizingRecommendation' :: RightsizingRecommendation -> Maybe CurrentInstance
currentInstance} -> Maybe CurrentInstance
currentInstance) (\s :: RightsizingRecommendation
s@RightsizingRecommendation' {} Maybe CurrentInstance
a -> RightsizingRecommendation
s {$sel:currentInstance:RightsizingRecommendation' :: Maybe CurrentInstance
currentInstance = Maybe CurrentInstance
a} :: RightsizingRecommendation)

-- | A recommendation to either terminate or modify the resource.
rightsizingRecommendation_rightsizingType :: Lens.Lens' RightsizingRecommendation (Prelude.Maybe RightsizingType)
rightsizingRecommendation_rightsizingType :: (Maybe RightsizingType -> f (Maybe RightsizingType))
-> RightsizingRecommendation -> f RightsizingRecommendation
rightsizingRecommendation_rightsizingType = (RightsizingRecommendation -> Maybe RightsizingType)
-> (RightsizingRecommendation
    -> Maybe RightsizingType -> RightsizingRecommendation)
-> Lens
     RightsizingRecommendation
     RightsizingRecommendation
     (Maybe RightsizingType)
     (Maybe RightsizingType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RightsizingRecommendation' {Maybe RightsizingType
rightsizingType :: Maybe RightsizingType
$sel:rightsizingType:RightsizingRecommendation' :: RightsizingRecommendation -> Maybe RightsizingType
rightsizingType} -> Maybe RightsizingType
rightsizingType) (\s :: RightsizingRecommendation
s@RightsizingRecommendation' {} Maybe RightsizingType
a -> RightsizingRecommendation
s {$sel:rightsizingType:RightsizingRecommendation' :: Maybe RightsizingType
rightsizingType = Maybe RightsizingType
a} :: RightsizingRecommendation)

-- | The details for termination recommendations.
rightsizingRecommendation_terminateRecommendationDetail :: Lens.Lens' RightsizingRecommendation (Prelude.Maybe TerminateRecommendationDetail)
rightsizingRecommendation_terminateRecommendationDetail :: (Maybe TerminateRecommendationDetail
 -> f (Maybe TerminateRecommendationDetail))
-> RightsizingRecommendation -> f RightsizingRecommendation
rightsizingRecommendation_terminateRecommendationDetail = (RightsizingRecommendation -> Maybe TerminateRecommendationDetail)
-> (RightsizingRecommendation
    -> Maybe TerminateRecommendationDetail
    -> RightsizingRecommendation)
-> Lens
     RightsizingRecommendation
     RightsizingRecommendation
     (Maybe TerminateRecommendationDetail)
     (Maybe TerminateRecommendationDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RightsizingRecommendation' {Maybe TerminateRecommendationDetail
terminateRecommendationDetail :: Maybe TerminateRecommendationDetail
$sel:terminateRecommendationDetail:RightsizingRecommendation' :: RightsizingRecommendation -> Maybe TerminateRecommendationDetail
terminateRecommendationDetail} -> Maybe TerminateRecommendationDetail
terminateRecommendationDetail) (\s :: RightsizingRecommendation
s@RightsizingRecommendation' {} Maybe TerminateRecommendationDetail
a -> RightsizingRecommendation
s {$sel:terminateRecommendationDetail:RightsizingRecommendation' :: Maybe TerminateRecommendationDetail
terminateRecommendationDetail = Maybe TerminateRecommendationDetail
a} :: RightsizingRecommendation)

instance Core.FromJSON RightsizingRecommendation where
  parseJSON :: Value -> Parser RightsizingRecommendation
parseJSON =
    String
-> (Object -> Parser RightsizingRecommendation)
-> Value
-> Parser RightsizingRecommendation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RightsizingRecommendation"
      ( \Object
x ->
          Maybe Text
-> Maybe [FindingReasonCode]
-> Maybe ModifyRecommendationDetail
-> Maybe CurrentInstance
-> Maybe RightsizingType
-> Maybe TerminateRecommendationDetail
-> RightsizingRecommendation
RightsizingRecommendation'
            (Maybe Text
 -> Maybe [FindingReasonCode]
 -> Maybe ModifyRecommendationDetail
 -> Maybe CurrentInstance
 -> Maybe RightsizingType
 -> Maybe TerminateRecommendationDetail
 -> RightsizingRecommendation)
-> Parser (Maybe Text)
-> Parser
     (Maybe [FindingReasonCode]
      -> Maybe ModifyRecommendationDetail
      -> Maybe CurrentInstance
      -> Maybe RightsizingType
      -> Maybe TerminateRecommendationDetail
      -> RightsizingRecommendation)
forall (f :: * -> *) a b. Functor 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
"AccountId")
            Parser
  (Maybe [FindingReasonCode]
   -> Maybe ModifyRecommendationDetail
   -> Maybe CurrentInstance
   -> Maybe RightsizingType
   -> Maybe TerminateRecommendationDetail
   -> RightsizingRecommendation)
-> Parser (Maybe [FindingReasonCode])
-> Parser
     (Maybe ModifyRecommendationDetail
      -> Maybe CurrentInstance
      -> Maybe RightsizingType
      -> Maybe TerminateRecommendationDetail
      -> RightsizingRecommendation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [FindingReasonCode]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FindingReasonCodes"
                            Parser (Maybe (Maybe [FindingReasonCode]))
-> Maybe [FindingReasonCode] -> Parser (Maybe [FindingReasonCode])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [FindingReasonCode]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe ModifyRecommendationDetail
   -> Maybe CurrentInstance
   -> Maybe RightsizingType
   -> Maybe TerminateRecommendationDetail
   -> RightsizingRecommendation)
-> Parser (Maybe ModifyRecommendationDetail)
-> Parser
     (Maybe CurrentInstance
      -> Maybe RightsizingType
      -> Maybe TerminateRecommendationDetail
      -> RightsizingRecommendation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ModifyRecommendationDetail)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ModifyRecommendationDetail")
            Parser
  (Maybe CurrentInstance
   -> Maybe RightsizingType
   -> Maybe TerminateRecommendationDetail
   -> RightsizingRecommendation)
-> Parser (Maybe CurrentInstance)
-> Parser
     (Maybe RightsizingType
      -> Maybe TerminateRecommendationDetail
      -> RightsizingRecommendation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CurrentInstance)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CurrentInstance")
            Parser
  (Maybe RightsizingType
   -> Maybe TerminateRecommendationDetail
   -> RightsizingRecommendation)
-> Parser (Maybe RightsizingType)
-> Parser
     (Maybe TerminateRecommendationDetail -> RightsizingRecommendation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RightsizingType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RightsizingType")
            Parser
  (Maybe TerminateRecommendationDetail -> RightsizingRecommendation)
-> Parser (Maybe TerminateRecommendationDetail)
-> Parser RightsizingRecommendation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TerminateRecommendationDetail)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TerminateRecommendationDetail")
      )

instance Prelude.Hashable RightsizingRecommendation

instance Prelude.NFData RightsizingRecommendation