{-# 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.IoTEvents.Types.Input
-- 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.IoTEvents.Types.Input where

import qualified Amazonka.Core as Core
import Amazonka.IoTEvents.Types.InputConfiguration
import Amazonka.IoTEvents.Types.InputDefinition
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the input.
--
-- /See:/ 'newInput' smart constructor.
data Input = Input'
  { -- | The definition of the input.
    Input -> Maybe InputDefinition
inputDefinition :: Prelude.Maybe InputDefinition,
    -- | Information about the configuration of an input.
    Input -> Maybe InputConfiguration
inputConfiguration :: Prelude.Maybe InputConfiguration
  }
  deriving (Input -> Input -> Bool
(Input -> Input -> Bool) -> (Input -> Input -> Bool) -> Eq Input
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Input -> Input -> Bool
$c/= :: Input -> Input -> Bool
== :: Input -> Input -> Bool
$c== :: Input -> Input -> Bool
Prelude.Eq, ReadPrec [Input]
ReadPrec Input
Int -> ReadS Input
ReadS [Input]
(Int -> ReadS Input)
-> ReadS [Input]
-> ReadPrec Input
-> ReadPrec [Input]
-> Read Input
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Input]
$creadListPrec :: ReadPrec [Input]
readPrec :: ReadPrec Input
$creadPrec :: ReadPrec Input
readList :: ReadS [Input]
$creadList :: ReadS [Input]
readsPrec :: Int -> ReadS Input
$creadsPrec :: Int -> ReadS Input
Prelude.Read, Int -> Input -> ShowS
[Input] -> ShowS
Input -> String
(Int -> Input -> ShowS)
-> (Input -> String) -> ([Input] -> ShowS) -> Show Input
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Input] -> ShowS
$cshowList :: [Input] -> ShowS
show :: Input -> String
$cshow :: Input -> String
showsPrec :: Int -> Input -> ShowS
$cshowsPrec :: Int -> Input -> ShowS
Prelude.Show, (forall x. Input -> Rep Input x)
-> (forall x. Rep Input x -> Input) -> Generic Input
forall x. Rep Input x -> Input
forall x. Input -> Rep Input x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Input x -> Input
$cfrom :: forall x. Input -> Rep Input x
Prelude.Generic)

-- |
-- Create a value of 'Input' 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:
--
-- 'inputDefinition', 'input_inputDefinition' - The definition of the input.
--
-- 'inputConfiguration', 'input_inputConfiguration' - Information about the configuration of an input.
newInput ::
  Input
newInput :: Input
newInput =
  Input' :: Maybe InputDefinition -> Maybe InputConfiguration -> Input
Input'
    { $sel:inputDefinition:Input' :: Maybe InputDefinition
inputDefinition = Maybe InputDefinition
forall a. Maybe a
Prelude.Nothing,
      $sel:inputConfiguration:Input' :: Maybe InputConfiguration
inputConfiguration = Maybe InputConfiguration
forall a. Maybe a
Prelude.Nothing
    }

-- | The definition of the input.
input_inputDefinition :: Lens.Lens' Input (Prelude.Maybe InputDefinition)
input_inputDefinition :: (Maybe InputDefinition -> f (Maybe InputDefinition))
-> Input -> f Input
input_inputDefinition = (Input -> Maybe InputDefinition)
-> (Input -> Maybe InputDefinition -> Input)
-> Lens Input Input (Maybe InputDefinition) (Maybe InputDefinition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Input' {Maybe InputDefinition
inputDefinition :: Maybe InputDefinition
$sel:inputDefinition:Input' :: Input -> Maybe InputDefinition
inputDefinition} -> Maybe InputDefinition
inputDefinition) (\s :: Input
s@Input' {} Maybe InputDefinition
a -> Input
s {$sel:inputDefinition:Input' :: Maybe InputDefinition
inputDefinition = Maybe InputDefinition
a} :: Input)

-- | Information about the configuration of an input.
input_inputConfiguration :: Lens.Lens' Input (Prelude.Maybe InputConfiguration)
input_inputConfiguration :: (Maybe InputConfiguration -> f (Maybe InputConfiguration))
-> Input -> f Input
input_inputConfiguration = (Input -> Maybe InputConfiguration)
-> (Input -> Maybe InputConfiguration -> Input)
-> Lens
     Input Input (Maybe InputConfiguration) (Maybe InputConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Input' {Maybe InputConfiguration
inputConfiguration :: Maybe InputConfiguration
$sel:inputConfiguration:Input' :: Input -> Maybe InputConfiguration
inputConfiguration} -> Maybe InputConfiguration
inputConfiguration) (\s :: Input
s@Input' {} Maybe InputConfiguration
a -> Input
s {$sel:inputConfiguration:Input' :: Maybe InputConfiguration
inputConfiguration = Maybe InputConfiguration
a} :: Input)

instance Core.FromJSON Input where
  parseJSON :: Value -> Parser Input
parseJSON =
    String -> (Object -> Parser Input) -> Value -> Parser Input
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Input"
      ( \Object
x ->
          Maybe InputDefinition -> Maybe InputConfiguration -> Input
Input'
            (Maybe InputDefinition -> Maybe InputConfiguration -> Input)
-> Parser (Maybe InputDefinition)
-> Parser (Maybe InputConfiguration -> Input)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe InputDefinition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"inputDefinition")
            Parser (Maybe InputConfiguration -> Input)
-> Parser (Maybe InputConfiguration) -> Parser Input
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe InputConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"inputConfiguration")
      )

instance Prelude.Hashable Input

instance Prelude.NFData Input