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

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

-- | Describes the source of a recommendation, such as an Amazon EC2 instance
-- or Auto Scaling group.
--
-- /See:/ 'newRecommendationSource' smart constructor.
data RecommendationSource = RecommendationSource'
  { -- | The Amazon Resource Name (ARN) of the recommendation source.
    RecommendationSource -> Maybe Text
recommendationSourceArn :: Prelude.Maybe Prelude.Text,
    -- | The resource type of the recommendation source.
    RecommendationSource -> Maybe RecommendationSourceType
recommendationSourceType :: Prelude.Maybe RecommendationSourceType
  }
  deriving (RecommendationSource -> RecommendationSource -> Bool
(RecommendationSource -> RecommendationSource -> Bool)
-> (RecommendationSource -> RecommendationSource -> Bool)
-> Eq RecommendationSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecommendationSource -> RecommendationSource -> Bool
$c/= :: RecommendationSource -> RecommendationSource -> Bool
== :: RecommendationSource -> RecommendationSource -> Bool
$c== :: RecommendationSource -> RecommendationSource -> Bool
Prelude.Eq, ReadPrec [RecommendationSource]
ReadPrec RecommendationSource
Int -> ReadS RecommendationSource
ReadS [RecommendationSource]
(Int -> ReadS RecommendationSource)
-> ReadS [RecommendationSource]
-> ReadPrec RecommendationSource
-> ReadPrec [RecommendationSource]
-> Read RecommendationSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RecommendationSource]
$creadListPrec :: ReadPrec [RecommendationSource]
readPrec :: ReadPrec RecommendationSource
$creadPrec :: ReadPrec RecommendationSource
readList :: ReadS [RecommendationSource]
$creadList :: ReadS [RecommendationSource]
readsPrec :: Int -> ReadS RecommendationSource
$creadsPrec :: Int -> ReadS RecommendationSource
Prelude.Read, Int -> RecommendationSource -> ShowS
[RecommendationSource] -> ShowS
RecommendationSource -> String
(Int -> RecommendationSource -> ShowS)
-> (RecommendationSource -> String)
-> ([RecommendationSource] -> ShowS)
-> Show RecommendationSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecommendationSource] -> ShowS
$cshowList :: [RecommendationSource] -> ShowS
show :: RecommendationSource -> String
$cshow :: RecommendationSource -> String
showsPrec :: Int -> RecommendationSource -> ShowS
$cshowsPrec :: Int -> RecommendationSource -> ShowS
Prelude.Show, (forall x. RecommendationSource -> Rep RecommendationSource x)
-> (forall x. Rep RecommendationSource x -> RecommendationSource)
-> Generic RecommendationSource
forall x. Rep RecommendationSource x -> RecommendationSource
forall x. RecommendationSource -> Rep RecommendationSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RecommendationSource x -> RecommendationSource
$cfrom :: forall x. RecommendationSource -> Rep RecommendationSource x
Prelude.Generic)

-- |
-- Create a value of 'RecommendationSource' 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:
--
-- 'recommendationSourceArn', 'recommendationSource_recommendationSourceArn' - The Amazon Resource Name (ARN) of the recommendation source.
--
-- 'recommendationSourceType', 'recommendationSource_recommendationSourceType' - The resource type of the recommendation source.
newRecommendationSource ::
  RecommendationSource
newRecommendationSource :: RecommendationSource
newRecommendationSource =
  RecommendationSource' :: Maybe Text
-> Maybe RecommendationSourceType -> RecommendationSource
RecommendationSource'
    { $sel:recommendationSourceArn:RecommendationSource' :: Maybe Text
recommendationSourceArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:recommendationSourceType:RecommendationSource' :: Maybe RecommendationSourceType
recommendationSourceType = Maybe RecommendationSourceType
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the recommendation source.
recommendationSource_recommendationSourceArn :: Lens.Lens' RecommendationSource (Prelude.Maybe Prelude.Text)
recommendationSource_recommendationSourceArn :: (Maybe Text -> f (Maybe Text))
-> RecommendationSource -> f RecommendationSource
recommendationSource_recommendationSourceArn = (RecommendationSource -> Maybe Text)
-> (RecommendationSource -> Maybe Text -> RecommendationSource)
-> Lens
     RecommendationSource RecommendationSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationSource' {Maybe Text
recommendationSourceArn :: Maybe Text
$sel:recommendationSourceArn:RecommendationSource' :: RecommendationSource -> Maybe Text
recommendationSourceArn} -> Maybe Text
recommendationSourceArn) (\s :: RecommendationSource
s@RecommendationSource' {} Maybe Text
a -> RecommendationSource
s {$sel:recommendationSourceArn:RecommendationSource' :: Maybe Text
recommendationSourceArn = Maybe Text
a} :: RecommendationSource)

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

instance Core.FromJSON RecommendationSource where
  parseJSON :: Value -> Parser RecommendationSource
parseJSON =
    String
-> (Object -> Parser RecommendationSource)
-> Value
-> Parser RecommendationSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RecommendationSource"
      ( \Object
x ->
          Maybe Text
-> Maybe RecommendationSourceType -> RecommendationSource
RecommendationSource'
            (Maybe Text
 -> Maybe RecommendationSourceType -> RecommendationSource)
-> Parser (Maybe Text)
-> Parser (Maybe RecommendationSourceType -> RecommendationSource)
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
"recommendationSourceArn")
            Parser (Maybe RecommendationSourceType -> RecommendationSource)
-> Parser (Maybe RecommendationSourceType)
-> Parser RecommendationSource
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
"recommendationSourceType")
      )

instance Prelude.Hashable RecommendationSource

instance Prelude.NFData RecommendationSource