{-# 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.IoT.Types.RegistrationConfig
-- 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.IoT.Types.RegistrationConfig where

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

-- | The registration configuration.
--
-- /See:/ 'newRegistrationConfig' smart constructor.
data RegistrationConfig = RegistrationConfig'
  { -- | The template body.
    RegistrationConfig -> Maybe Text
templateBody :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the role.
    RegistrationConfig -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (RegistrationConfig -> RegistrationConfig -> Bool
(RegistrationConfig -> RegistrationConfig -> Bool)
-> (RegistrationConfig -> RegistrationConfig -> Bool)
-> Eq RegistrationConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegistrationConfig -> RegistrationConfig -> Bool
$c/= :: RegistrationConfig -> RegistrationConfig -> Bool
== :: RegistrationConfig -> RegistrationConfig -> Bool
$c== :: RegistrationConfig -> RegistrationConfig -> Bool
Prelude.Eq, ReadPrec [RegistrationConfig]
ReadPrec RegistrationConfig
Int -> ReadS RegistrationConfig
ReadS [RegistrationConfig]
(Int -> ReadS RegistrationConfig)
-> ReadS [RegistrationConfig]
-> ReadPrec RegistrationConfig
-> ReadPrec [RegistrationConfig]
-> Read RegistrationConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegistrationConfig]
$creadListPrec :: ReadPrec [RegistrationConfig]
readPrec :: ReadPrec RegistrationConfig
$creadPrec :: ReadPrec RegistrationConfig
readList :: ReadS [RegistrationConfig]
$creadList :: ReadS [RegistrationConfig]
readsPrec :: Int -> ReadS RegistrationConfig
$creadsPrec :: Int -> ReadS RegistrationConfig
Prelude.Read, Int -> RegistrationConfig -> ShowS
[RegistrationConfig] -> ShowS
RegistrationConfig -> String
(Int -> RegistrationConfig -> ShowS)
-> (RegistrationConfig -> String)
-> ([RegistrationConfig] -> ShowS)
-> Show RegistrationConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegistrationConfig] -> ShowS
$cshowList :: [RegistrationConfig] -> ShowS
show :: RegistrationConfig -> String
$cshow :: RegistrationConfig -> String
showsPrec :: Int -> RegistrationConfig -> ShowS
$cshowsPrec :: Int -> RegistrationConfig -> ShowS
Prelude.Show, (forall x. RegistrationConfig -> Rep RegistrationConfig x)
-> (forall x. Rep RegistrationConfig x -> RegistrationConfig)
-> Generic RegistrationConfig
forall x. Rep RegistrationConfig x -> RegistrationConfig
forall x. RegistrationConfig -> Rep RegistrationConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegistrationConfig x -> RegistrationConfig
$cfrom :: forall x. RegistrationConfig -> Rep RegistrationConfig x
Prelude.Generic)

-- |
-- Create a value of 'RegistrationConfig' 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:
--
-- 'templateBody', 'registrationConfig_templateBody' - The template body.
--
-- 'roleArn', 'registrationConfig_roleArn' - The ARN of the role.
newRegistrationConfig ::
  RegistrationConfig
newRegistrationConfig :: RegistrationConfig
newRegistrationConfig =
  RegistrationConfig' :: Maybe Text -> Maybe Text -> RegistrationConfig
RegistrationConfig'
    { $sel:templateBody:RegistrationConfig' :: Maybe Text
templateBody = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:RegistrationConfig' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The template body.
registrationConfig_templateBody :: Lens.Lens' RegistrationConfig (Prelude.Maybe Prelude.Text)
registrationConfig_templateBody :: (Maybe Text -> f (Maybe Text))
-> RegistrationConfig -> f RegistrationConfig
registrationConfig_templateBody = (RegistrationConfig -> Maybe Text)
-> (RegistrationConfig -> Maybe Text -> RegistrationConfig)
-> Lens
     RegistrationConfig RegistrationConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegistrationConfig' {Maybe Text
templateBody :: Maybe Text
$sel:templateBody:RegistrationConfig' :: RegistrationConfig -> Maybe Text
templateBody} -> Maybe Text
templateBody) (\s :: RegistrationConfig
s@RegistrationConfig' {} Maybe Text
a -> RegistrationConfig
s {$sel:templateBody:RegistrationConfig' :: Maybe Text
templateBody = Maybe Text
a} :: RegistrationConfig)

-- | The ARN of the role.
registrationConfig_roleArn :: Lens.Lens' RegistrationConfig (Prelude.Maybe Prelude.Text)
registrationConfig_roleArn :: (Maybe Text -> f (Maybe Text))
-> RegistrationConfig -> f RegistrationConfig
registrationConfig_roleArn = (RegistrationConfig -> Maybe Text)
-> (RegistrationConfig -> Maybe Text -> RegistrationConfig)
-> Lens
     RegistrationConfig RegistrationConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegistrationConfig' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:RegistrationConfig' :: RegistrationConfig -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: RegistrationConfig
s@RegistrationConfig' {} Maybe Text
a -> RegistrationConfig
s {$sel:roleArn:RegistrationConfig' :: Maybe Text
roleArn = Maybe Text
a} :: RegistrationConfig)

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

instance Prelude.Hashable RegistrationConfig

instance Prelude.NFData RegistrationConfig

instance Core.ToJSON RegistrationConfig where
  toJSON :: RegistrationConfig -> Value
toJSON RegistrationConfig' {Maybe Text
roleArn :: Maybe Text
templateBody :: Maybe Text
$sel:roleArn:RegistrationConfig' :: RegistrationConfig -> Maybe Text
$sel:templateBody:RegistrationConfig' :: RegistrationConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"templateBody" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
templateBody,
            (Text
"roleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
roleArn
          ]
      )