{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoT.Types.RegistrationConfig where

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

-- | The registration configuration.
--
-- /See:/ 'newRegistrationConfig' smart constructor.
data RegistrationConfig = RegistrationConfig'
  { -- | The ARN of the role.
    RegistrationConfig -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | The template body.
    RegistrationConfig -> Maybe Text
templateBody :: Prelude.Maybe Prelude.Text,
    -- | The name of the provisioning template.
    RegistrationConfig -> Maybe Text
templateName :: Prelude.Maybe Prelude.Text
  }
  deriving (RegistrationConfig -> RegistrationConfig -> Bool
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]
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
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. 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:
--
-- 'roleArn', 'registrationConfig_roleArn' - The ARN of the role.
--
-- 'templateBody', 'registrationConfig_templateBody' - The template body.
--
-- 'templateName', 'registrationConfig_templateName' - The name of the provisioning template.
newRegistrationConfig ::
  RegistrationConfig
newRegistrationConfig :: RegistrationConfig
newRegistrationConfig =
  RegistrationConfig'
    { $sel:roleArn:RegistrationConfig' :: Maybe Text
roleArn = forall a. Maybe a
Prelude.Nothing,
      $sel:templateBody:RegistrationConfig' :: Maybe Text
templateBody = forall a. Maybe a
Prelude.Nothing,
      $sel:templateName:RegistrationConfig' :: Maybe Text
templateName = forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the role.
registrationConfig_roleArn :: Lens.Lens' RegistrationConfig (Prelude.Maybe Prelude.Text)
registrationConfig_roleArn :: Lens' RegistrationConfig (Maybe Text)
registrationConfig_roleArn = 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)

-- | The template body.
registrationConfig_templateBody :: Lens.Lens' RegistrationConfig (Prelude.Maybe Prelude.Text)
registrationConfig_templateBody :: Lens' RegistrationConfig (Maybe Text)
registrationConfig_templateBody = 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 name of the provisioning template.
registrationConfig_templateName :: Lens.Lens' RegistrationConfig (Prelude.Maybe Prelude.Text)
registrationConfig_templateName :: Lens' RegistrationConfig (Maybe Text)
registrationConfig_templateName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegistrationConfig' {Maybe Text
templateName :: Maybe Text
$sel:templateName:RegistrationConfig' :: RegistrationConfig -> Maybe Text
templateName} -> Maybe Text
templateName) (\s :: RegistrationConfig
s@RegistrationConfig' {} Maybe Text
a -> RegistrationConfig
s {$sel:templateName:RegistrationConfig' :: Maybe Text
templateName = Maybe Text
a} :: RegistrationConfig)

instance Data.FromJSON RegistrationConfig where
  parseJSON :: Value -> Parser RegistrationConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RegistrationConfig"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> RegistrationConfig
RegistrationConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"roleArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"templateBody")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"templateName")
      )

instance Prelude.Hashable RegistrationConfig where
  hashWithSalt :: Int -> RegistrationConfig -> Int
hashWithSalt Int
_salt RegistrationConfig' {Maybe Text
templateName :: Maybe Text
templateBody :: Maybe Text
roleArn :: Maybe Text
$sel:templateName:RegistrationConfig' :: RegistrationConfig -> Maybe Text
$sel:templateBody:RegistrationConfig' :: RegistrationConfig -> Maybe Text
$sel:roleArn:RegistrationConfig' :: RegistrationConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
templateBody
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
templateName

instance Prelude.NFData RegistrationConfig where
  rnf :: RegistrationConfig -> ()
rnf RegistrationConfig' {Maybe Text
templateName :: Maybe Text
templateBody :: Maybe Text
roleArn :: Maybe Text
$sel:templateName:RegistrationConfig' :: RegistrationConfig -> Maybe Text
$sel:templateBody:RegistrationConfig' :: RegistrationConfig -> Maybe Text
$sel:roleArn:RegistrationConfig' :: RegistrationConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
templateBody
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
templateName

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