{-# 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.IoTAnalytics.Types.IotEventsDestinationConfiguration
-- 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.IoTAnalytics.Types.IotEventsDestinationConfiguration where

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

-- | Configuration information for delivery of dataset contents to IoT
-- Events.
--
-- /See:/ 'newIotEventsDestinationConfiguration' smart constructor.
data IotEventsDestinationConfiguration = IotEventsDestinationConfiguration'
  { -- | The name of the IoT Events input to which dataset contents are
    -- delivered.
    IotEventsDestinationConfiguration -> Text
inputName :: Prelude.Text,
    -- | The ARN of the role that grants IoT Analytics permission to deliver
    -- dataset contents to an IoT Events input.
    IotEventsDestinationConfiguration -> Text
roleArn :: Prelude.Text
  }
  deriving (IotEventsDestinationConfiguration
-> IotEventsDestinationConfiguration -> Bool
(IotEventsDestinationConfiguration
 -> IotEventsDestinationConfiguration -> Bool)
-> (IotEventsDestinationConfiguration
    -> IotEventsDestinationConfiguration -> Bool)
-> Eq IotEventsDestinationConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IotEventsDestinationConfiguration
-> IotEventsDestinationConfiguration -> Bool
$c/= :: IotEventsDestinationConfiguration
-> IotEventsDestinationConfiguration -> Bool
== :: IotEventsDestinationConfiguration
-> IotEventsDestinationConfiguration -> Bool
$c== :: IotEventsDestinationConfiguration
-> IotEventsDestinationConfiguration -> Bool
Prelude.Eq, ReadPrec [IotEventsDestinationConfiguration]
ReadPrec IotEventsDestinationConfiguration
Int -> ReadS IotEventsDestinationConfiguration
ReadS [IotEventsDestinationConfiguration]
(Int -> ReadS IotEventsDestinationConfiguration)
-> ReadS [IotEventsDestinationConfiguration]
-> ReadPrec IotEventsDestinationConfiguration
-> ReadPrec [IotEventsDestinationConfiguration]
-> Read IotEventsDestinationConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IotEventsDestinationConfiguration]
$creadListPrec :: ReadPrec [IotEventsDestinationConfiguration]
readPrec :: ReadPrec IotEventsDestinationConfiguration
$creadPrec :: ReadPrec IotEventsDestinationConfiguration
readList :: ReadS [IotEventsDestinationConfiguration]
$creadList :: ReadS [IotEventsDestinationConfiguration]
readsPrec :: Int -> ReadS IotEventsDestinationConfiguration
$creadsPrec :: Int -> ReadS IotEventsDestinationConfiguration
Prelude.Read, Int -> IotEventsDestinationConfiguration -> ShowS
[IotEventsDestinationConfiguration] -> ShowS
IotEventsDestinationConfiguration -> String
(Int -> IotEventsDestinationConfiguration -> ShowS)
-> (IotEventsDestinationConfiguration -> String)
-> ([IotEventsDestinationConfiguration] -> ShowS)
-> Show IotEventsDestinationConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IotEventsDestinationConfiguration] -> ShowS
$cshowList :: [IotEventsDestinationConfiguration] -> ShowS
show :: IotEventsDestinationConfiguration -> String
$cshow :: IotEventsDestinationConfiguration -> String
showsPrec :: Int -> IotEventsDestinationConfiguration -> ShowS
$cshowsPrec :: Int -> IotEventsDestinationConfiguration -> ShowS
Prelude.Show, (forall x.
 IotEventsDestinationConfiguration
 -> Rep IotEventsDestinationConfiguration x)
-> (forall x.
    Rep IotEventsDestinationConfiguration x
    -> IotEventsDestinationConfiguration)
-> Generic IotEventsDestinationConfiguration
forall x.
Rep IotEventsDestinationConfiguration x
-> IotEventsDestinationConfiguration
forall x.
IotEventsDestinationConfiguration
-> Rep IotEventsDestinationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep IotEventsDestinationConfiguration x
-> IotEventsDestinationConfiguration
$cfrom :: forall x.
IotEventsDestinationConfiguration
-> Rep IotEventsDestinationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'IotEventsDestinationConfiguration' 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:
--
-- 'inputName', 'iotEventsDestinationConfiguration_inputName' - The name of the IoT Events input to which dataset contents are
-- delivered.
--
-- 'roleArn', 'iotEventsDestinationConfiguration_roleArn' - The ARN of the role that grants IoT Analytics permission to deliver
-- dataset contents to an IoT Events input.
newIotEventsDestinationConfiguration ::
  -- | 'inputName'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  IotEventsDestinationConfiguration
newIotEventsDestinationConfiguration :: Text -> Text -> IotEventsDestinationConfiguration
newIotEventsDestinationConfiguration
  Text
pInputName_
  Text
pRoleArn_ =
    IotEventsDestinationConfiguration' :: Text -> Text -> IotEventsDestinationConfiguration
IotEventsDestinationConfiguration'
      { $sel:inputName:IotEventsDestinationConfiguration' :: Text
inputName =
          Text
pInputName_,
        $sel:roleArn:IotEventsDestinationConfiguration' :: Text
roleArn = Text
pRoleArn_
      }

-- | The name of the IoT Events input to which dataset contents are
-- delivered.
iotEventsDestinationConfiguration_inputName :: Lens.Lens' IotEventsDestinationConfiguration Prelude.Text
iotEventsDestinationConfiguration_inputName :: (Text -> f Text)
-> IotEventsDestinationConfiguration
-> f IotEventsDestinationConfiguration
iotEventsDestinationConfiguration_inputName = (IotEventsDestinationConfiguration -> Text)
-> (IotEventsDestinationConfiguration
    -> Text -> IotEventsDestinationConfiguration)
-> Lens
     IotEventsDestinationConfiguration
     IotEventsDestinationConfiguration
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IotEventsDestinationConfiguration' {Text
inputName :: Text
$sel:inputName:IotEventsDestinationConfiguration' :: IotEventsDestinationConfiguration -> Text
inputName} -> Text
inputName) (\s :: IotEventsDestinationConfiguration
s@IotEventsDestinationConfiguration' {} Text
a -> IotEventsDestinationConfiguration
s {$sel:inputName:IotEventsDestinationConfiguration' :: Text
inputName = Text
a} :: IotEventsDestinationConfiguration)

-- | The ARN of the role that grants IoT Analytics permission to deliver
-- dataset contents to an IoT Events input.
iotEventsDestinationConfiguration_roleArn :: Lens.Lens' IotEventsDestinationConfiguration Prelude.Text
iotEventsDestinationConfiguration_roleArn :: (Text -> f Text)
-> IotEventsDestinationConfiguration
-> f IotEventsDestinationConfiguration
iotEventsDestinationConfiguration_roleArn = (IotEventsDestinationConfiguration -> Text)
-> (IotEventsDestinationConfiguration
    -> Text -> IotEventsDestinationConfiguration)
-> Lens
     IotEventsDestinationConfiguration
     IotEventsDestinationConfiguration
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IotEventsDestinationConfiguration' {Text
roleArn :: Text
$sel:roleArn:IotEventsDestinationConfiguration' :: IotEventsDestinationConfiguration -> Text
roleArn} -> Text
roleArn) (\s :: IotEventsDestinationConfiguration
s@IotEventsDestinationConfiguration' {} Text
a -> IotEventsDestinationConfiguration
s {$sel:roleArn:IotEventsDestinationConfiguration' :: Text
roleArn = Text
a} :: IotEventsDestinationConfiguration)

instance
  Core.FromJSON
    IotEventsDestinationConfiguration
  where
  parseJSON :: Value -> Parser IotEventsDestinationConfiguration
parseJSON =
    String
-> (Object -> Parser IotEventsDestinationConfiguration)
-> Value
-> Parser IotEventsDestinationConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IotEventsDestinationConfiguration"
      ( \Object
x ->
          Text -> Text -> IotEventsDestinationConfiguration
IotEventsDestinationConfiguration'
            (Text -> Text -> IotEventsDestinationConfiguration)
-> Parser Text
-> Parser (Text -> IotEventsDestinationConfiguration)
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
"inputName")
            Parser (Text -> IotEventsDestinationConfiguration)
-> Parser Text -> Parser IotEventsDestinationConfiguration
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
"roleArn")
      )

instance
  Prelude.Hashable
    IotEventsDestinationConfiguration

instance
  Prelude.NFData
    IotEventsDestinationConfiguration

instance
  Core.ToJSON
    IotEventsDestinationConfiguration
  where
  toJSON :: IotEventsDestinationConfiguration -> Value
toJSON IotEventsDestinationConfiguration' {Text
roleArn :: Text
inputName :: Text
$sel:roleArn:IotEventsDestinationConfiguration' :: IotEventsDestinationConfiguration -> Text
$sel:inputName:IotEventsDestinationConfiguration' :: IotEventsDestinationConfiguration -> 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
"inputName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
inputName),
            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)
          ]
      )