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

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

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

-- |
-- Create a value of 'AppFlowConfig' 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', 'appFlowConfig_roleArn' - An IAM role that gives Amazon Lookout for Metrics permission to access
-- the flow.
--
-- 'flowName', 'appFlowConfig_flowName' - name of the flow.
newAppFlowConfig ::
  -- | 'roleArn'
  Prelude.Text ->
  -- | 'flowName'
  Prelude.Text ->
  AppFlowConfig
newAppFlowConfig :: Text -> Text -> AppFlowConfig
newAppFlowConfig Text
pRoleArn_ Text
pFlowName_ =
  AppFlowConfig' :: Text -> Text -> AppFlowConfig
AppFlowConfig'
    { $sel:roleArn:AppFlowConfig' :: Text
roleArn = Text
pRoleArn_,
      $sel:flowName:AppFlowConfig' :: Text
flowName = Text
pFlowName_
    }

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

-- | name of the flow.
appFlowConfig_flowName :: Lens.Lens' AppFlowConfig Prelude.Text
appFlowConfig_flowName :: (Text -> f Text) -> AppFlowConfig -> f AppFlowConfig
appFlowConfig_flowName = (AppFlowConfig -> Text)
-> (AppFlowConfig -> Text -> AppFlowConfig)
-> Lens AppFlowConfig AppFlowConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppFlowConfig' {Text
flowName :: Text
$sel:flowName:AppFlowConfig' :: AppFlowConfig -> Text
flowName} -> Text
flowName) (\s :: AppFlowConfig
s@AppFlowConfig' {} Text
a -> AppFlowConfig
s {$sel:flowName:AppFlowConfig' :: Text
flowName = Text
a} :: AppFlowConfig)

instance Core.FromJSON AppFlowConfig where
  parseJSON :: Value -> Parser AppFlowConfig
parseJSON =
    String
-> (Object -> Parser AppFlowConfig)
-> Value
-> Parser AppFlowConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AppFlowConfig"
      ( \Object
x ->
          Text -> Text -> AppFlowConfig
AppFlowConfig'
            (Text -> Text -> AppFlowConfig)
-> Parser Text -> Parser (Text -> AppFlowConfig)
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")
            Parser (Text -> AppFlowConfig)
-> Parser Text -> Parser AppFlowConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"FlowName")
      )

instance Prelude.Hashable AppFlowConfig

instance Prelude.NFData AppFlowConfig

instance Core.ToJSON AppFlowConfig where
  toJSON :: AppFlowConfig -> Value
toJSON AppFlowConfig' {Text
flowName :: Text
roleArn :: Text
$sel:flowName:AppFlowConfig' :: AppFlowConfig -> Text
$sel:roleArn:AppFlowConfig' :: AppFlowConfig -> 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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FlowName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
flowName)
          ]
      )