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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.CostExplorer.Types.PlatformDifference
import Amazonka.CostExplorer.Types.ResourceDetails
import Amazonka.CostExplorer.Types.ResourceUtilization
import qualified Amazonka.Data as Data
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,
    -- | 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,
    -- | Explains the actions that you might need to take to successfully migrate
    -- your workloads from the current instance type to the recommended
    -- instance type.
    TargetInstance -> Maybe [PlatformDifference]
platformDifferences :: Prelude.Maybe [PlatformDifference],
    -- | Details on the target instance type.
    TargetInstance -> Maybe ResourceDetails
resourceDetails :: Prelude.Maybe ResourceDetails
  }
  deriving (TargetInstance -> TargetInstance -> Bool
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]
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
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. 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.
--
-- '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.
--
-- 'platformDifferences', 'targetInstance_platformDifferences' - Explains the actions that you might need to take to successfully migrate
-- your workloads from the current instance type to the recommended
-- instance type.
--
-- 'resourceDetails', 'targetInstance_resourceDetails' - Details on the target instance type.
newTargetInstance ::
  TargetInstance
newTargetInstance :: TargetInstance
newTargetInstance =
  TargetInstance'
    { $sel:currencyCode:TargetInstance' :: Maybe Text
currencyCode = forall a. Maybe a
Prelude.Nothing,
      $sel:defaultTargetInstance:TargetInstance' :: Maybe Bool
defaultTargetInstance = forall a. Maybe a
Prelude.Nothing,
      $sel:estimatedMonthlyCost:TargetInstance' :: Maybe Text
estimatedMonthlyCost = forall a. Maybe a
Prelude.Nothing,
      $sel:estimatedMonthlySavings:TargetInstance' :: Maybe Text
estimatedMonthlySavings = forall a. Maybe a
Prelude.Nothing,
      $sel:expectedResourceUtilization:TargetInstance' :: Maybe ResourceUtilization
expectedResourceUtilization = forall a. Maybe a
Prelude.Nothing,
      $sel:platformDifferences:TargetInstance' :: Maybe [PlatformDifference]
platformDifferences = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceDetails:TargetInstance' :: Maybe ResourceDetails
resourceDetails = 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 :: Lens' TargetInstance (Maybe Text)
targetInstance_currencyCode = 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)

-- | Determines whether this recommendation is the defaulted Amazon Web
-- Services recommendation.
targetInstance_defaultTargetInstance :: Lens.Lens' TargetInstance (Prelude.Maybe Prelude.Bool)
targetInstance_defaultTargetInstance :: Lens' TargetInstance (Maybe Bool)
targetInstance_defaultTargetInstance = 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 :: Lens' TargetInstance (Maybe Text)
targetInstance_estimatedMonthlyCost = 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 :: Lens' TargetInstance (Maybe Text)
targetInstance_estimatedMonthlySavings = 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 :: Lens' TargetInstance (Maybe ResourceUtilization)
targetInstance_expectedResourceUtilization = 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)

-- | Explains the actions that you might need to take 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 :: Lens' TargetInstance (Maybe [PlatformDifference])
targetInstance_platformDifferences = 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) 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

-- | Details on the target instance type.
targetInstance_resourceDetails :: Lens.Lens' TargetInstance (Prelude.Maybe ResourceDetails)
targetInstance_resourceDetails :: Lens' TargetInstance (Maybe ResourceDetails)
targetInstance_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)

instance Data.FromJSON TargetInstance where
  parseJSON :: Value -> Parser TargetInstance
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TargetInstance"
      ( \Object
x ->
          Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe ResourceUtilization
-> Maybe [PlatformDifference]
-> Maybe ResourceDetails
-> TargetInstance
TargetInstance'
            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
"CurrencyCode")
            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
"DefaultTargetInstance")
            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
"EstimatedMonthlyCost")
            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
"EstimatedMonthlySavings")
            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
"ExpectedResourceUtilization")
            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
"PlatformDifferences"
                            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
"ResourceDetails")
      )

instance Prelude.Hashable TargetInstance where
  hashWithSalt :: Int -> TargetInstance -> Int
hashWithSalt Int
_salt TargetInstance' {Maybe Bool
Maybe [PlatformDifference]
Maybe Text
Maybe ResourceDetails
Maybe ResourceUtilization
resourceDetails :: Maybe ResourceDetails
platformDifferences :: Maybe [PlatformDifference]
expectedResourceUtilization :: Maybe ResourceUtilization
estimatedMonthlySavings :: Maybe Text
estimatedMonthlyCost :: Maybe Text
defaultTargetInstance :: Maybe Bool
currencyCode :: Maybe Text
$sel:resourceDetails:TargetInstance' :: TargetInstance -> Maybe ResourceDetails
$sel:platformDifferences:TargetInstance' :: TargetInstance -> Maybe [PlatformDifference]
$sel:expectedResourceUtilization:TargetInstance' :: TargetInstance -> Maybe ResourceUtilization
$sel:estimatedMonthlySavings:TargetInstance' :: TargetInstance -> Maybe Text
$sel:estimatedMonthlyCost:TargetInstance' :: TargetInstance -> Maybe Text
$sel:defaultTargetInstance:TargetInstance' :: TargetInstance -> Maybe Bool
$sel:currencyCode:TargetInstance' :: TargetInstance -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
currencyCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
defaultTargetInstance
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
estimatedMonthlyCost
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
estimatedMonthlySavings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceUtilization
expectedResourceUtilization
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PlatformDifference]
platformDifferences
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceDetails
resourceDetails

instance Prelude.NFData TargetInstance where
  rnf :: TargetInstance -> ()
rnf TargetInstance' {Maybe Bool
Maybe [PlatformDifference]
Maybe Text
Maybe ResourceDetails
Maybe ResourceUtilization
resourceDetails :: Maybe ResourceDetails
platformDifferences :: Maybe [PlatformDifference]
expectedResourceUtilization :: Maybe ResourceUtilization
estimatedMonthlySavings :: Maybe Text
estimatedMonthlyCost :: Maybe Text
defaultTargetInstance :: Maybe Bool
currencyCode :: Maybe Text
$sel:resourceDetails:TargetInstance' :: TargetInstance -> Maybe ResourceDetails
$sel:platformDifferences:TargetInstance' :: TargetInstance -> Maybe [PlatformDifference]
$sel:expectedResourceUtilization:TargetInstance' :: TargetInstance -> Maybe ResourceUtilization
$sel:estimatedMonthlySavings:TargetInstance' :: TargetInstance -> Maybe Text
$sel:estimatedMonthlyCost:TargetInstance' :: TargetInstance -> Maybe Text
$sel:defaultTargetInstance:TargetInstance' :: TargetInstance -> Maybe Bool
$sel:currencyCode:TargetInstance' :: TargetInstance -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
currencyCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
defaultTargetInstance
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
estimatedMonthlyCost
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
estimatedMonthlySavings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceUtilization
expectedResourceUtilization
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [PlatformDifference]
platformDifferences
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceDetails
resourceDetails