{-# 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.LookoutMetrics.Types.CloudWatchConfig
-- 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.LookoutMetrics.Types.CloudWatchConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Details about an Amazon CloudWatch datasource.
--
-- /See:/ 'newCloudWatchConfig' smart constructor.
data CloudWatchConfig = CloudWatchConfig'
  { -- | An IAM role that gives Amazon Lookout for Metrics permission to access
    -- data in Amazon CloudWatch.
    CloudWatchConfig -> Text
roleArn :: Prelude.Text
  }
  deriving (CloudWatchConfig -> CloudWatchConfig -> Bool
(CloudWatchConfig -> CloudWatchConfig -> Bool)
-> (CloudWatchConfig -> CloudWatchConfig -> Bool)
-> Eq CloudWatchConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudWatchConfig -> CloudWatchConfig -> Bool
$c/= :: CloudWatchConfig -> CloudWatchConfig -> Bool
== :: CloudWatchConfig -> CloudWatchConfig -> Bool
$c== :: CloudWatchConfig -> CloudWatchConfig -> Bool
Prelude.Eq, ReadPrec [CloudWatchConfig]
ReadPrec CloudWatchConfig
Int -> ReadS CloudWatchConfig
ReadS [CloudWatchConfig]
(Int -> ReadS CloudWatchConfig)
-> ReadS [CloudWatchConfig]
-> ReadPrec CloudWatchConfig
-> ReadPrec [CloudWatchConfig]
-> Read CloudWatchConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudWatchConfig]
$creadListPrec :: ReadPrec [CloudWatchConfig]
readPrec :: ReadPrec CloudWatchConfig
$creadPrec :: ReadPrec CloudWatchConfig
readList :: ReadS [CloudWatchConfig]
$creadList :: ReadS [CloudWatchConfig]
readsPrec :: Int -> ReadS CloudWatchConfig
$creadsPrec :: Int -> ReadS CloudWatchConfig
Prelude.Read, Int -> CloudWatchConfig -> ShowS
[CloudWatchConfig] -> ShowS
CloudWatchConfig -> String
(Int -> CloudWatchConfig -> ShowS)
-> (CloudWatchConfig -> String)
-> ([CloudWatchConfig] -> ShowS)
-> Show CloudWatchConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudWatchConfig] -> ShowS
$cshowList :: [CloudWatchConfig] -> ShowS
show :: CloudWatchConfig -> String
$cshow :: CloudWatchConfig -> String
showsPrec :: Int -> CloudWatchConfig -> ShowS
$cshowsPrec :: Int -> CloudWatchConfig -> ShowS
Prelude.Show, (forall x. CloudWatchConfig -> Rep CloudWatchConfig x)
-> (forall x. Rep CloudWatchConfig x -> CloudWatchConfig)
-> Generic CloudWatchConfig
forall x. Rep CloudWatchConfig x -> CloudWatchConfig
forall x. CloudWatchConfig -> Rep CloudWatchConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CloudWatchConfig x -> CloudWatchConfig
$cfrom :: forall x. CloudWatchConfig -> Rep CloudWatchConfig x
Prelude.Generic)

-- |
-- Create a value of 'CloudWatchConfig' 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:
--
-- 'roleArn', 'cloudWatchConfig_roleArn' - An IAM role that gives Amazon Lookout for Metrics permission to access
-- data in Amazon CloudWatch.
newCloudWatchConfig ::
  -- | 'roleArn'
  Prelude.Text ->
  CloudWatchConfig
newCloudWatchConfig :: Text -> CloudWatchConfig
newCloudWatchConfig Text
pRoleArn_ =
  CloudWatchConfig' :: Text -> CloudWatchConfig
CloudWatchConfig' {$sel:roleArn:CloudWatchConfig' :: Text
roleArn = Text
pRoleArn_}

-- | An IAM role that gives Amazon Lookout for Metrics permission to access
-- data in Amazon CloudWatch.
cloudWatchConfig_roleArn :: Lens.Lens' CloudWatchConfig Prelude.Text
cloudWatchConfig_roleArn :: (Text -> f Text) -> CloudWatchConfig -> f CloudWatchConfig
cloudWatchConfig_roleArn = (CloudWatchConfig -> Text)
-> (CloudWatchConfig -> Text -> CloudWatchConfig)
-> Lens CloudWatchConfig CloudWatchConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchConfig' {Text
roleArn :: Text
$sel:roleArn:CloudWatchConfig' :: CloudWatchConfig -> Text
roleArn} -> Text
roleArn) (\s :: CloudWatchConfig
s@CloudWatchConfig' {} Text
a -> CloudWatchConfig
s {$sel:roleArn:CloudWatchConfig' :: Text
roleArn = Text
a} :: CloudWatchConfig)

instance Core.FromJSON CloudWatchConfig where
  parseJSON :: Value -> Parser CloudWatchConfig
parseJSON =
    String
-> (Object -> Parser CloudWatchConfig)
-> Value
-> Parser CloudWatchConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CloudWatchConfig"
      ( \Object
x ->
          Text -> CloudWatchConfig
CloudWatchConfig' (Text -> CloudWatchConfig)
-> Parser Text -> Parser CloudWatchConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RoleArn")
      )

instance Prelude.Hashable CloudWatchConfig

instance Prelude.NFData CloudWatchConfig

instance Core.ToJSON CloudWatchConfig where
  toJSON :: CloudWatchConfig -> Value
toJSON CloudWatchConfig' {Text
roleArn :: Text
$sel:roleArn:CloudWatchConfig' :: CloudWatchConfig -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RoleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArn)]
      )