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

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

-- | Configuration.
--
-- /See:/ 'newConfiguration' smart constructor.
data Configuration = Configuration'
  { -- | True to enable the configuration.
    Configuration -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (Configuration -> Configuration -> Bool
(Configuration -> Configuration -> Bool)
-> (Configuration -> Configuration -> Bool) -> Eq Configuration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Configuration -> Configuration -> Bool
$c/= :: Configuration -> Configuration -> Bool
== :: Configuration -> Configuration -> Bool
$c== :: Configuration -> Configuration -> Bool
Prelude.Eq, ReadPrec [Configuration]
ReadPrec Configuration
Int -> ReadS Configuration
ReadS [Configuration]
(Int -> ReadS Configuration)
-> ReadS [Configuration]
-> ReadPrec Configuration
-> ReadPrec [Configuration]
-> Read Configuration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Configuration]
$creadListPrec :: ReadPrec [Configuration]
readPrec :: ReadPrec Configuration
$creadPrec :: ReadPrec Configuration
readList :: ReadS [Configuration]
$creadList :: ReadS [Configuration]
readsPrec :: Int -> ReadS Configuration
$creadsPrec :: Int -> ReadS Configuration
Prelude.Read, Int -> Configuration -> ShowS
[Configuration] -> ShowS
Configuration -> String
(Int -> Configuration -> ShowS)
-> (Configuration -> String)
-> ([Configuration] -> ShowS)
-> Show Configuration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Configuration] -> ShowS
$cshowList :: [Configuration] -> ShowS
show :: Configuration -> String
$cshow :: Configuration -> String
showsPrec :: Int -> Configuration -> ShowS
$cshowsPrec :: Int -> Configuration -> ShowS
Prelude.Show, (forall x. Configuration -> Rep Configuration x)
-> (forall x. Rep Configuration x -> Configuration)
-> Generic Configuration
forall x. Rep Configuration x -> Configuration
forall x. Configuration -> Rep Configuration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Configuration x -> Configuration
$cfrom :: forall x. Configuration -> Rep Configuration x
Prelude.Generic)

-- |
-- Create a value of 'Configuration' 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:
--
-- 'enabled', 'configuration_enabled' - True to enable the configuration.
newConfiguration ::
  Configuration
newConfiguration :: Configuration
newConfiguration =
  Configuration' :: Maybe Bool -> Configuration
Configuration' {$sel:enabled:Configuration' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing}

-- | True to enable the configuration.
configuration_enabled :: Lens.Lens' Configuration (Prelude.Maybe Prelude.Bool)
configuration_enabled :: (Maybe Bool -> f (Maybe Bool)) -> Configuration -> f Configuration
configuration_enabled = (Configuration -> Maybe Bool)
-> (Configuration -> Maybe Bool -> Configuration)
-> Lens Configuration Configuration (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Configuration' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:Configuration' :: Configuration -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: Configuration
s@Configuration' {} Maybe Bool
a -> Configuration
s {$sel:enabled:Configuration' :: Maybe Bool
enabled = Maybe Bool
a} :: Configuration)

instance Core.FromJSON Configuration where
  parseJSON :: Value -> Parser Configuration
parseJSON =
    String
-> (Object -> Parser Configuration)
-> Value
-> Parser Configuration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Configuration"
      ( \Object
x ->
          Maybe Bool -> Configuration
Configuration' (Maybe Bool -> Configuration)
-> Parser (Maybe Bool) -> Parser Configuration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Enabled")
      )

instance Prelude.Hashable Configuration

instance Prelude.NFData Configuration

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