{-# 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.OpsWorks.Types.ChefConfiguration
-- 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.OpsWorks.Types.ChefConfiguration 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

-- | Describes the Chef configuration.
--
-- /See:/ 'newChefConfiguration' smart constructor.
data ChefConfiguration = ChefConfiguration'
  { -- | The Berkshelf version.
    ChefConfiguration -> Maybe Text
berkshelfVersion :: Prelude.Maybe Prelude.Text,
    -- | Whether to enable Berkshelf.
    ChefConfiguration -> Maybe Bool
manageBerkshelf :: Prelude.Maybe Prelude.Bool
  }
  deriving (ChefConfiguration -> ChefConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChefConfiguration -> ChefConfiguration -> Bool
$c/= :: ChefConfiguration -> ChefConfiguration -> Bool
== :: ChefConfiguration -> ChefConfiguration -> Bool
$c== :: ChefConfiguration -> ChefConfiguration -> Bool
Prelude.Eq, ReadPrec [ChefConfiguration]
ReadPrec ChefConfiguration
Int -> ReadS ChefConfiguration
ReadS [ChefConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChefConfiguration]
$creadListPrec :: ReadPrec [ChefConfiguration]
readPrec :: ReadPrec ChefConfiguration
$creadPrec :: ReadPrec ChefConfiguration
readList :: ReadS [ChefConfiguration]
$creadList :: ReadS [ChefConfiguration]
readsPrec :: Int -> ReadS ChefConfiguration
$creadsPrec :: Int -> ReadS ChefConfiguration
Prelude.Read, Int -> ChefConfiguration -> ShowS
[ChefConfiguration] -> ShowS
ChefConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChefConfiguration] -> ShowS
$cshowList :: [ChefConfiguration] -> ShowS
show :: ChefConfiguration -> String
$cshow :: ChefConfiguration -> String
showsPrec :: Int -> ChefConfiguration -> ShowS
$cshowsPrec :: Int -> ChefConfiguration -> ShowS
Prelude.Show, forall x. Rep ChefConfiguration x -> ChefConfiguration
forall x. ChefConfiguration -> Rep ChefConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChefConfiguration x -> ChefConfiguration
$cfrom :: forall x. ChefConfiguration -> Rep ChefConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ChefConfiguration' 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:
--
-- 'berkshelfVersion', 'chefConfiguration_berkshelfVersion' - The Berkshelf version.
--
-- 'manageBerkshelf', 'chefConfiguration_manageBerkshelf' - Whether to enable Berkshelf.
newChefConfiguration ::
  ChefConfiguration
newChefConfiguration :: ChefConfiguration
newChefConfiguration =
  ChefConfiguration'
    { $sel:berkshelfVersion:ChefConfiguration' :: Maybe Text
berkshelfVersion =
        forall a. Maybe a
Prelude.Nothing,
      $sel:manageBerkshelf:ChefConfiguration' :: Maybe Bool
manageBerkshelf = forall a. Maybe a
Prelude.Nothing
    }

-- | The Berkshelf version.
chefConfiguration_berkshelfVersion :: Lens.Lens' ChefConfiguration (Prelude.Maybe Prelude.Text)
chefConfiguration_berkshelfVersion :: Lens' ChefConfiguration (Maybe Text)
chefConfiguration_berkshelfVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChefConfiguration' {Maybe Text
berkshelfVersion :: Maybe Text
$sel:berkshelfVersion:ChefConfiguration' :: ChefConfiguration -> Maybe Text
berkshelfVersion} -> Maybe Text
berkshelfVersion) (\s :: ChefConfiguration
s@ChefConfiguration' {} Maybe Text
a -> ChefConfiguration
s {$sel:berkshelfVersion:ChefConfiguration' :: Maybe Text
berkshelfVersion = Maybe Text
a} :: ChefConfiguration)

-- | Whether to enable Berkshelf.
chefConfiguration_manageBerkshelf :: Lens.Lens' ChefConfiguration (Prelude.Maybe Prelude.Bool)
chefConfiguration_manageBerkshelf :: Lens' ChefConfiguration (Maybe Bool)
chefConfiguration_manageBerkshelf = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChefConfiguration' {Maybe Bool
manageBerkshelf :: Maybe Bool
$sel:manageBerkshelf:ChefConfiguration' :: ChefConfiguration -> Maybe Bool
manageBerkshelf} -> Maybe Bool
manageBerkshelf) (\s :: ChefConfiguration
s@ChefConfiguration' {} Maybe Bool
a -> ChefConfiguration
s {$sel:manageBerkshelf:ChefConfiguration' :: Maybe Bool
manageBerkshelf = Maybe Bool
a} :: ChefConfiguration)

instance Data.FromJSON ChefConfiguration where
  parseJSON :: Value -> Parser ChefConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ChefConfiguration"
      ( \Object
x ->
          Maybe Text -> Maybe Bool -> ChefConfiguration
ChefConfiguration'
            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
"BerkshelfVersion")
            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
"ManageBerkshelf")
      )

instance Prelude.Hashable ChefConfiguration where
  hashWithSalt :: Int -> ChefConfiguration -> Int
hashWithSalt Int
_salt ChefConfiguration' {Maybe Bool
Maybe Text
manageBerkshelf :: Maybe Bool
berkshelfVersion :: Maybe Text
$sel:manageBerkshelf:ChefConfiguration' :: ChefConfiguration -> Maybe Bool
$sel:berkshelfVersion:ChefConfiguration' :: ChefConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
berkshelfVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
manageBerkshelf

instance Prelude.NFData ChefConfiguration where
  rnf :: ChefConfiguration -> ()
rnf ChefConfiguration' {Maybe Bool
Maybe Text
manageBerkshelf :: Maybe Bool
berkshelfVersion :: Maybe Text
$sel:manageBerkshelf:ChefConfiguration' :: ChefConfiguration -> Maybe Bool
$sel:berkshelfVersion:ChefConfiguration' :: ChefConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
berkshelfVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
manageBerkshelf

instance Data.ToJSON ChefConfiguration where
  toJSON :: ChefConfiguration -> Value
toJSON ChefConfiguration' {Maybe Bool
Maybe Text
manageBerkshelf :: Maybe Bool
berkshelfVersion :: Maybe Text
$sel:manageBerkshelf:ChefConfiguration' :: ChefConfiguration -> Maybe Bool
$sel:berkshelfVersion:ChefConfiguration' :: ChefConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"BerkshelfVersion" 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
berkshelfVersion,
            (Key
"ManageBerkshelf" 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 Bool
manageBerkshelf
          ]
      )