{-# 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.ComputeOptimizer.Types.RecommendationSummary
-- 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.ComputeOptimizer.Types.RecommendationSummary where

import Amazonka.ComputeOptimizer.Types.RecommendationSourceType
import Amazonka.ComputeOptimizer.Types.Summary
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A summary of a recommendation.
--
-- /See:/ 'newRecommendationSummary' smart constructor.
data RecommendationSummary = RecommendationSummary'
  { -- | The Amazon Web Services account ID of the recommendation summary.
    RecommendationSummary -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | An array of objects that describe a recommendation summary.
    RecommendationSummary -> Maybe [Summary]
summaries :: Prelude.Maybe [Summary],
    -- | The resource type of the recommendation.
    RecommendationSummary -> Maybe RecommendationSourceType
recommendationResourceType :: Prelude.Maybe RecommendationSourceType
  }
  deriving (RecommendationSummary -> RecommendationSummary -> Bool
(RecommendationSummary -> RecommendationSummary -> Bool)
-> (RecommendationSummary -> RecommendationSummary -> Bool)
-> Eq RecommendationSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecommendationSummary -> RecommendationSummary -> Bool
$c/= :: RecommendationSummary -> RecommendationSummary -> Bool
== :: RecommendationSummary -> RecommendationSummary -> Bool
$c== :: RecommendationSummary -> RecommendationSummary -> Bool
Prelude.Eq, ReadPrec [RecommendationSummary]
ReadPrec RecommendationSummary
Int -> ReadS RecommendationSummary
ReadS [RecommendationSummary]
(Int -> ReadS RecommendationSummary)
-> ReadS [RecommendationSummary]
-> ReadPrec RecommendationSummary
-> ReadPrec [RecommendationSummary]
-> Read RecommendationSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RecommendationSummary]
$creadListPrec :: ReadPrec [RecommendationSummary]
readPrec :: ReadPrec RecommendationSummary
$creadPrec :: ReadPrec RecommendationSummary
readList :: ReadS [RecommendationSummary]
$creadList :: ReadS [RecommendationSummary]
readsPrec :: Int -> ReadS RecommendationSummary
$creadsPrec :: Int -> ReadS RecommendationSummary
Prelude.Read, Int -> RecommendationSummary -> ShowS
[RecommendationSummary] -> ShowS
RecommendationSummary -> String
(Int -> RecommendationSummary -> ShowS)
-> (RecommendationSummary -> String)
-> ([RecommendationSummary] -> ShowS)
-> Show RecommendationSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecommendationSummary] -> ShowS
$cshowList :: [RecommendationSummary] -> ShowS
show :: RecommendationSummary -> String
$cshow :: RecommendationSummary -> String
showsPrec :: Int -> RecommendationSummary -> ShowS
$cshowsPrec :: Int -> RecommendationSummary -> ShowS
Prelude.Show, (forall x. RecommendationSummary -> Rep RecommendationSummary x)
-> (forall x. Rep RecommendationSummary x -> RecommendationSummary)
-> Generic RecommendationSummary
forall x. Rep RecommendationSummary x -> RecommendationSummary
forall x. RecommendationSummary -> Rep RecommendationSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RecommendationSummary x -> RecommendationSummary
$cfrom :: forall x. RecommendationSummary -> Rep RecommendationSummary x
Prelude.Generic)

-- |
-- Create a value of 'RecommendationSummary' 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', 'recommendationSummary_accountId' - The Amazon Web Services account ID of the recommendation summary.
--
-- 'summaries', 'recommendationSummary_summaries' - An array of objects that describe a recommendation summary.
--
-- 'recommendationResourceType', 'recommendationSummary_recommendationResourceType' - The resource type of the recommendation.
newRecommendationSummary ::
  RecommendationSummary
newRecommendationSummary :: RecommendationSummary
newRecommendationSummary =
  RecommendationSummary' :: Maybe Text
-> Maybe [Summary]
-> Maybe RecommendationSourceType
-> RecommendationSummary
RecommendationSummary'
    { $sel:accountId:RecommendationSummary' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:summaries:RecommendationSummary' :: Maybe [Summary]
summaries = Maybe [Summary]
forall a. Maybe a
Prelude.Nothing,
      $sel:recommendationResourceType:RecommendationSummary' :: Maybe RecommendationSourceType
recommendationResourceType = Maybe RecommendationSourceType
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Web Services account ID of the recommendation summary.
recommendationSummary_accountId :: Lens.Lens' RecommendationSummary (Prelude.Maybe Prelude.Text)
recommendationSummary_accountId :: (Maybe Text -> f (Maybe Text))
-> RecommendationSummary -> f RecommendationSummary
recommendationSummary_accountId = (RecommendationSummary -> Maybe Text)
-> (RecommendationSummary -> Maybe Text -> RecommendationSummary)
-> Lens
     RecommendationSummary
     RecommendationSummary
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationSummary' {Maybe Text
accountId :: Maybe Text
$sel:accountId:RecommendationSummary' :: RecommendationSummary -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: RecommendationSummary
s@RecommendationSummary' {} Maybe Text
a -> RecommendationSummary
s {$sel:accountId:RecommendationSummary' :: Maybe Text
accountId = Maybe Text
a} :: RecommendationSummary)

-- | An array of objects that describe a recommendation summary.
recommendationSummary_summaries :: Lens.Lens' RecommendationSummary (Prelude.Maybe [Summary])
recommendationSummary_summaries :: (Maybe [Summary] -> f (Maybe [Summary]))
-> RecommendationSummary -> f RecommendationSummary
recommendationSummary_summaries = (RecommendationSummary -> Maybe [Summary])
-> (RecommendationSummary
    -> Maybe [Summary] -> RecommendationSummary)
-> Lens
     RecommendationSummary
     RecommendationSummary
     (Maybe [Summary])
     (Maybe [Summary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationSummary' {Maybe [Summary]
summaries :: Maybe [Summary]
$sel:summaries:RecommendationSummary' :: RecommendationSummary -> Maybe [Summary]
summaries} -> Maybe [Summary]
summaries) (\s :: RecommendationSummary
s@RecommendationSummary' {} Maybe [Summary]
a -> RecommendationSummary
s {$sel:summaries:RecommendationSummary' :: Maybe [Summary]
summaries = Maybe [Summary]
a} :: RecommendationSummary) ((Maybe [Summary] -> f (Maybe [Summary]))
 -> RecommendationSummary -> f RecommendationSummary)
-> ((Maybe [Summary] -> f (Maybe [Summary]))
    -> Maybe [Summary] -> f (Maybe [Summary]))
-> (Maybe [Summary] -> f (Maybe [Summary]))
-> RecommendationSummary
-> f RecommendationSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Summary] [Summary] [Summary] [Summary]
-> Iso
     (Maybe [Summary])
     (Maybe [Summary])
     (Maybe [Summary])
     (Maybe [Summary])
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 [Summary] [Summary] [Summary] [Summary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The resource type of the recommendation.
recommendationSummary_recommendationResourceType :: Lens.Lens' RecommendationSummary (Prelude.Maybe RecommendationSourceType)
recommendationSummary_recommendationResourceType :: (Maybe RecommendationSourceType
 -> f (Maybe RecommendationSourceType))
-> RecommendationSummary -> f RecommendationSummary
recommendationSummary_recommendationResourceType = (RecommendationSummary -> Maybe RecommendationSourceType)
-> (RecommendationSummary
    -> Maybe RecommendationSourceType -> RecommendationSummary)
-> Lens
     RecommendationSummary
     RecommendationSummary
     (Maybe RecommendationSourceType)
     (Maybe RecommendationSourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationSummary' {Maybe RecommendationSourceType
recommendationResourceType :: Maybe RecommendationSourceType
$sel:recommendationResourceType:RecommendationSummary' :: RecommendationSummary -> Maybe RecommendationSourceType
recommendationResourceType} -> Maybe RecommendationSourceType
recommendationResourceType) (\s :: RecommendationSummary
s@RecommendationSummary' {} Maybe RecommendationSourceType
a -> RecommendationSummary
s {$sel:recommendationResourceType:RecommendationSummary' :: Maybe RecommendationSourceType
recommendationResourceType = Maybe RecommendationSourceType
a} :: RecommendationSummary)

instance Core.FromJSON RecommendationSummary where
  parseJSON :: Value -> Parser RecommendationSummary
parseJSON =
    String
-> (Object -> Parser RecommendationSummary)
-> Value
-> Parser RecommendationSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RecommendationSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe [Summary]
-> Maybe RecommendationSourceType
-> RecommendationSummary
RecommendationSummary'
            (Maybe Text
 -> Maybe [Summary]
 -> Maybe RecommendationSourceType
 -> RecommendationSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe [Summary]
      -> Maybe RecommendationSourceType -> RecommendationSummary)
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 [Summary]
   -> Maybe RecommendationSourceType -> RecommendationSummary)
-> Parser (Maybe [Summary])
-> Parser (Maybe RecommendationSourceType -> RecommendationSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Summary]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"summaries" Parser (Maybe (Maybe [Summary]))
-> Maybe [Summary] -> Parser (Maybe [Summary])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Summary]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe RecommendationSourceType -> RecommendationSummary)
-> Parser (Maybe RecommendationSourceType)
-> Parser RecommendationSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RecommendationSourceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"recommendationResourceType")
      )

instance Prelude.Hashable RecommendationSummary

instance Prelude.NFData RecommendationSummary