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

import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.Types.PlatformDifference
import Amazonka.CostExplorer.Types.ResourceDetails
import Amazonka.CostExplorer.Types.ResourceUtilization
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Details on recommended instance.
--
-- /See:/ 'newTargetInstance' smart constructor.
data TargetInstance = TargetInstance'
  { -- | The currency code that Amazon Web Services used to calculate the costs
    -- for this instance.
    TargetInstance -> Maybe Text
currencyCode :: Prelude.Maybe Prelude.Text,
    -- | Details on the target instance type.
    TargetInstance -> Maybe ResourceDetails
resourceDetails :: Prelude.Maybe ResourceDetails,
    -- | Explains the actions you might need to take in order to successfully
    -- migrate your workloads from the current instance type to the recommended
    -- instance type.
    TargetInstance -> Maybe [PlatformDifference]
platformDifferences :: Prelude.Maybe [PlatformDifference],
    -- | Determines whether this recommendation is the defaulted Amazon Web
    -- Services recommendation.
    TargetInstance -> Maybe Bool
defaultTargetInstance :: Prelude.Maybe Prelude.Bool,
    -- | The expected cost to operate this instance type on a monthly basis.
    TargetInstance -> Maybe Text
estimatedMonthlyCost :: Prelude.Maybe Prelude.Text,
    -- | The estimated savings that result from modification, on a monthly basis.
    TargetInstance -> Maybe Text
estimatedMonthlySavings :: Prelude.Maybe Prelude.Text,
    -- | The expected utilization metrics for target instance type.
    TargetInstance -> Maybe ResourceUtilization
expectedResourceUtilization :: Prelude.Maybe ResourceUtilization
  }
  deriving (TargetInstance -> TargetInstance -> Bool
(TargetInstance -> TargetInstance -> Bool)
-> (TargetInstance -> TargetInstance -> Bool) -> Eq TargetInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetInstance -> TargetInstance -> Bool
$c/= :: TargetInstance -> TargetInstance -> Bool
== :: TargetInstance -> TargetInstance -> Bool
$c== :: TargetInstance -> TargetInstance -> Bool
Prelude.Eq, ReadPrec [TargetInstance]
ReadPrec TargetInstance
Int -> ReadS TargetInstance
ReadS [TargetInstance]
(Int -> ReadS TargetInstance)
-> ReadS [TargetInstance]
-> ReadPrec TargetInstance
-> ReadPrec [TargetInstance]
-> Read TargetInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TargetInstance]
$creadListPrec :: ReadPrec [TargetInstance]
readPrec :: ReadPrec TargetInstance
$creadPrec :: ReadPrec TargetInstance
readList :: ReadS [TargetInstance]
$creadList :: ReadS [TargetInstance]
readsPrec :: Int -> ReadS TargetInstance
$creadsPrec :: Int -> ReadS TargetInstance
Prelude.Read, Int -> TargetInstance -> ShowS
[TargetInstance] -> ShowS
TargetInstance -> String
(Int -> TargetInstance -> ShowS)
-> (TargetInstance -> String)
-> ([TargetInstance] -> ShowS)
-> Show TargetInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetInstance] -> ShowS
$cshowList :: [TargetInstance] -> ShowS
show :: TargetInstance -> String
$cshow :: TargetInstance -> String
showsPrec :: Int -> TargetInstance -> ShowS
$cshowsPrec :: Int -> TargetInstance -> ShowS
Prelude.Show, (forall x. TargetInstance -> Rep TargetInstance x)
-> (forall x. Rep TargetInstance x -> TargetInstance)
-> Generic TargetInstance
forall x. Rep TargetInstance x -> TargetInstance
forall x. TargetInstance -> Rep TargetInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TargetInstance x -> TargetInstance
$cfrom :: forall x. TargetInstance -> Rep TargetInstance x
Prelude.Generic)

-- |
-- Create a value of 'TargetInstance' 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:
--
-- 'currencyCode', 'targetInstance_currencyCode' - The currency code that Amazon Web Services used to calculate the costs
-- for this instance.
--
-- 'resourceDetails', 'targetInstance_resourceDetails' - Details on the target instance type.
--
-- 'platformDifferences', 'targetInstance_platformDifferences' - Explains the actions you might need to take in order to successfully
-- migrate your workloads from the current instance type to the recommended
-- instance type.
--
-- 'defaultTargetInstance', 'targetInstance_defaultTargetInstance' - Determines whether this recommendation is the defaulted Amazon Web
-- Services recommendation.
--
-- 'estimatedMonthlyCost', 'targetInstance_estimatedMonthlyCost' - The expected cost to operate this instance type on a monthly basis.
--
-- 'estimatedMonthlySavings', 'targetInstance_estimatedMonthlySavings' - The estimated savings that result from modification, on a monthly basis.
--
-- 'expectedResourceUtilization', 'targetInstance_expectedResourceUtilization' - The expected utilization metrics for target instance type.
newTargetInstance ::
  TargetInstance
newTargetInstance :: TargetInstance
newTargetInstance =
  TargetInstance' :: Maybe Text
-> Maybe ResourceDetails
-> Maybe [PlatformDifference]
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe ResourceUtilization
-> TargetInstance
TargetInstance'
    { $sel:currencyCode:TargetInstance' :: Maybe Text
currencyCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceDetails:TargetInstance' :: Maybe ResourceDetails
resourceDetails = Maybe ResourceDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:platformDifferences:TargetInstance' :: Maybe [PlatformDifference]
platformDifferences = Maybe [PlatformDifference]
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultTargetInstance:TargetInstance' :: Maybe Bool
defaultTargetInstance = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:estimatedMonthlyCost:TargetInstance' :: Maybe Text
estimatedMonthlyCost = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:estimatedMonthlySavings:TargetInstance' :: Maybe Text
estimatedMonthlySavings = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:expectedResourceUtilization:TargetInstance' :: Maybe ResourceUtilization
expectedResourceUtilization = Maybe ResourceUtilization
forall a. Maybe a
Prelude.Nothing
    }

-- | The currency code that Amazon Web Services used to calculate the costs
-- for this instance.
targetInstance_currencyCode :: Lens.Lens' TargetInstance (Prelude.Maybe Prelude.Text)
targetInstance_currencyCode :: (Maybe Text -> f (Maybe Text))
-> TargetInstance -> f TargetInstance
targetInstance_currencyCode = (TargetInstance -> Maybe Text)
-> (TargetInstance -> Maybe Text -> TargetInstance)
-> Lens TargetInstance TargetInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetInstance' {Maybe Text
currencyCode :: Maybe Text
$sel:currencyCode:TargetInstance' :: TargetInstance -> Maybe Text
currencyCode} -> Maybe Text
currencyCode) (\s :: TargetInstance
s@TargetInstance' {} Maybe Text
a -> TargetInstance
s {$sel:currencyCode:TargetInstance' :: Maybe Text
currencyCode = Maybe Text
a} :: TargetInstance)

-- | Details on the target instance type.
targetInstance_resourceDetails :: Lens.Lens' TargetInstance (Prelude.Maybe ResourceDetails)
targetInstance_resourceDetails :: (Maybe ResourceDetails -> f (Maybe ResourceDetails))
-> TargetInstance -> f TargetInstance
targetInstance_resourceDetails = (TargetInstance -> Maybe ResourceDetails)
-> (TargetInstance -> Maybe ResourceDetails -> TargetInstance)
-> Lens
     TargetInstance
     TargetInstance
     (Maybe ResourceDetails)
     (Maybe ResourceDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetInstance' {Maybe ResourceDetails
resourceDetails :: Maybe ResourceDetails
$sel:resourceDetails:TargetInstance' :: TargetInstance -> Maybe ResourceDetails
resourceDetails} -> Maybe ResourceDetails
resourceDetails) (\s :: TargetInstance
s@TargetInstance' {} Maybe ResourceDetails
a -> TargetInstance
s {$sel:resourceDetails:TargetInstance' :: Maybe ResourceDetails
resourceDetails = Maybe ResourceDetails
a} :: TargetInstance)

-- | Explains the actions you might need to take in order to successfully
-- migrate your workloads from the current instance type to the recommended
-- instance type.
targetInstance_platformDifferences :: Lens.Lens' TargetInstance (Prelude.Maybe [PlatformDifference])
targetInstance_platformDifferences :: (Maybe [PlatformDifference] -> f (Maybe [PlatformDifference]))
-> TargetInstance -> f TargetInstance
targetInstance_platformDifferences = (TargetInstance -> Maybe [PlatformDifference])
-> (TargetInstance -> Maybe [PlatformDifference] -> TargetInstance)
-> Lens
     TargetInstance
     TargetInstance
     (Maybe [PlatformDifference])
     (Maybe [PlatformDifference])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetInstance' {Maybe [PlatformDifference]
platformDifferences :: Maybe [PlatformDifference]
$sel:platformDifferences:TargetInstance' :: TargetInstance -> Maybe [PlatformDifference]
platformDifferences} -> Maybe [PlatformDifference]
platformDifferences) (\s :: TargetInstance
s@TargetInstance' {} Maybe [PlatformDifference]
a -> TargetInstance
s {$sel:platformDifferences:TargetInstance' :: Maybe [PlatformDifference]
platformDifferences = Maybe [PlatformDifference]
a} :: TargetInstance) ((Maybe [PlatformDifference] -> f (Maybe [PlatformDifference]))
 -> TargetInstance -> f TargetInstance)
-> ((Maybe [PlatformDifference] -> f (Maybe [PlatformDifference]))
    -> Maybe [PlatformDifference] -> f (Maybe [PlatformDifference]))
-> (Maybe [PlatformDifference] -> f (Maybe [PlatformDifference]))
-> TargetInstance
-> f TargetInstance
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PlatformDifference]
  [PlatformDifference]
  [PlatformDifference]
  [PlatformDifference]
-> Iso
     (Maybe [PlatformDifference])
     (Maybe [PlatformDifference])
     (Maybe [PlatformDifference])
     (Maybe [PlatformDifference])
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
  [PlatformDifference]
  [PlatformDifference]
  [PlatformDifference]
  [PlatformDifference]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Determines whether this recommendation is the defaulted Amazon Web
-- Services recommendation.
targetInstance_defaultTargetInstance :: Lens.Lens' TargetInstance (Prelude.Maybe Prelude.Bool)
targetInstance_defaultTargetInstance :: (Maybe Bool -> f (Maybe Bool))
-> TargetInstance -> f TargetInstance
targetInstance_defaultTargetInstance = (TargetInstance -> Maybe Bool)
-> (TargetInstance -> Maybe Bool -> TargetInstance)
-> Lens TargetInstance TargetInstance (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetInstance' {Maybe Bool
defaultTargetInstance :: Maybe Bool
$sel:defaultTargetInstance:TargetInstance' :: TargetInstance -> Maybe Bool
defaultTargetInstance} -> Maybe Bool
defaultTargetInstance) (\s :: TargetInstance
s@TargetInstance' {} Maybe Bool
a -> TargetInstance
s {$sel:defaultTargetInstance:TargetInstance' :: Maybe Bool
defaultTargetInstance = Maybe Bool
a} :: TargetInstance)

-- | The expected cost to operate this instance type on a monthly basis.
targetInstance_estimatedMonthlyCost :: Lens.Lens' TargetInstance (Prelude.Maybe Prelude.Text)
targetInstance_estimatedMonthlyCost :: (Maybe Text -> f (Maybe Text))
-> TargetInstance -> f TargetInstance
targetInstance_estimatedMonthlyCost = (TargetInstance -> Maybe Text)
-> (TargetInstance -> Maybe Text -> TargetInstance)
-> Lens TargetInstance TargetInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetInstance' {Maybe Text
estimatedMonthlyCost :: Maybe Text
$sel:estimatedMonthlyCost:TargetInstance' :: TargetInstance -> Maybe Text
estimatedMonthlyCost} -> Maybe Text
estimatedMonthlyCost) (\s :: TargetInstance
s@TargetInstance' {} Maybe Text
a -> TargetInstance
s {$sel:estimatedMonthlyCost:TargetInstance' :: Maybe Text
estimatedMonthlyCost = Maybe Text
a} :: TargetInstance)

-- | The estimated savings that result from modification, on a monthly basis.
targetInstance_estimatedMonthlySavings :: Lens.Lens' TargetInstance (Prelude.Maybe Prelude.Text)
targetInstance_estimatedMonthlySavings :: (Maybe Text -> f (Maybe Text))
-> TargetInstance -> f TargetInstance
targetInstance_estimatedMonthlySavings = (TargetInstance -> Maybe Text)
-> (TargetInstance -> Maybe Text -> TargetInstance)
-> Lens TargetInstance TargetInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetInstance' {Maybe Text
estimatedMonthlySavings :: Maybe Text
$sel:estimatedMonthlySavings:TargetInstance' :: TargetInstance -> Maybe Text
estimatedMonthlySavings} -> Maybe Text
estimatedMonthlySavings) (\s :: TargetInstance
s@TargetInstance' {} Maybe Text
a -> TargetInstance
s {$sel:estimatedMonthlySavings:TargetInstance' :: Maybe Text
estimatedMonthlySavings = Maybe Text
a} :: TargetInstance)

-- | The expected utilization metrics for target instance type.
targetInstance_expectedResourceUtilization :: Lens.Lens' TargetInstance (Prelude.Maybe ResourceUtilization)
targetInstance_expectedResourceUtilization :: (Maybe ResourceUtilization -> f (Maybe ResourceUtilization))
-> TargetInstance -> f TargetInstance
targetInstance_expectedResourceUtilization = (TargetInstance -> Maybe ResourceUtilization)
-> (TargetInstance -> Maybe ResourceUtilization -> TargetInstance)
-> Lens
     TargetInstance
     TargetInstance
     (Maybe ResourceUtilization)
     (Maybe ResourceUtilization)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetInstance' {Maybe ResourceUtilization
expectedResourceUtilization :: Maybe ResourceUtilization
$sel:expectedResourceUtilization:TargetInstance' :: TargetInstance -> Maybe ResourceUtilization
expectedResourceUtilization} -> Maybe ResourceUtilization
expectedResourceUtilization) (\s :: TargetInstance
s@TargetInstance' {} Maybe ResourceUtilization
a -> TargetInstance
s {$sel:expectedResourceUtilization:TargetInstance' :: Maybe ResourceUtilization
expectedResourceUtilization = Maybe ResourceUtilization
a} :: TargetInstance)

instance Core.FromJSON TargetInstance where
  parseJSON :: Value -> Parser TargetInstance
parseJSON =
    String
-> (Object -> Parser TargetInstance)
-> Value
-> Parser TargetInstance
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TargetInstance"
      ( \Object
x ->
          Maybe Text
-> Maybe ResourceDetails
-> Maybe [PlatformDifference]
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe ResourceUtilization
-> TargetInstance
TargetInstance'
            (Maybe Text
 -> Maybe ResourceDetails
 -> Maybe [PlatformDifference]
 -> Maybe Bool
 -> Maybe Text
 -> Maybe Text
 -> Maybe ResourceUtilization
 -> TargetInstance)
-> Parser (Maybe Text)
-> Parser
     (Maybe ResourceDetails
      -> Maybe [PlatformDifference]
      -> Maybe Bool
      -> Maybe Text
      -> Maybe Text
      -> Maybe ResourceUtilization
      -> TargetInstance)
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
"CurrencyCode")
            Parser
  (Maybe ResourceDetails
   -> Maybe [PlatformDifference]
   -> Maybe Bool
   -> Maybe Text
   -> Maybe Text
   -> Maybe ResourceUtilization
   -> TargetInstance)
-> Parser (Maybe ResourceDetails)
-> Parser
     (Maybe [PlatformDifference]
      -> Maybe Bool
      -> Maybe Text
      -> Maybe Text
      -> Maybe ResourceUtilization
      -> TargetInstance)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ResourceDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceDetails")
            Parser
  (Maybe [PlatformDifference]
   -> Maybe Bool
   -> Maybe Text
   -> Maybe Text
   -> Maybe ResourceUtilization
   -> TargetInstance)
-> Parser (Maybe [PlatformDifference])
-> Parser
     (Maybe Bool
      -> Maybe Text
      -> Maybe Text
      -> Maybe ResourceUtilization
      -> TargetInstance)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [PlatformDifference]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PlatformDifferences"
                            Parser (Maybe (Maybe [PlatformDifference]))
-> Maybe [PlatformDifference]
-> Parser (Maybe [PlatformDifference])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [PlatformDifference]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe Bool
   -> Maybe Text
   -> Maybe Text
   -> Maybe ResourceUtilization
   -> TargetInstance)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe ResourceUtilization -> TargetInstance)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DefaultTargetInstance")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe ResourceUtilization -> TargetInstance)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe ResourceUtilization -> TargetInstance)
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
"EstimatedMonthlyCost")
            Parser (Maybe Text -> Maybe ResourceUtilization -> TargetInstance)
-> Parser (Maybe Text)
-> Parser (Maybe ResourceUtilization -> TargetInstance)
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
"EstimatedMonthlySavings")
            Parser (Maybe ResourceUtilization -> TargetInstance)
-> Parser (Maybe ResourceUtilization) -> Parser TargetInstance
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ResourceUtilization)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ExpectedResourceUtilization")
      )

instance Prelude.Hashable TargetInstance

instance Prelude.NFData TargetInstance