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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ChefConfiguration -> ChefConfiguration -> Bool)
-> (ChefConfiguration -> ChefConfiguration -> Bool)
-> Eq ChefConfiguration
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]
(Int -> ReadS ChefConfiguration)
-> ReadS [ChefConfiguration]
-> ReadPrec ChefConfiguration
-> ReadPrec [ChefConfiguration]
-> Read 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
(Int -> ChefConfiguration -> ShowS)
-> (ChefConfiguration -> String)
-> ([ChefConfiguration] -> ShowS)
-> Show ChefConfiguration
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. ChefConfiguration -> Rep ChefConfiguration x)
-> (forall x. Rep ChefConfiguration x -> ChefConfiguration)
-> Generic ChefConfiguration
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' :: Maybe Text -> Maybe Bool -> ChefConfiguration
ChefConfiguration'
    { $sel:berkshelfVersion:ChefConfiguration' :: Maybe Text
berkshelfVersion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:manageBerkshelf:ChefConfiguration' :: Maybe Bool
manageBerkshelf = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The Berkshelf version.
chefConfiguration_berkshelfVersion :: Lens.Lens' ChefConfiguration (Prelude.Maybe Prelude.Text)
chefConfiguration_berkshelfVersion :: (Maybe Text -> f (Maybe Text))
-> ChefConfiguration -> f ChefConfiguration
chefConfiguration_berkshelfVersion = (ChefConfiguration -> Maybe Text)
-> (ChefConfiguration -> Maybe Text -> ChefConfiguration)
-> Lens
     ChefConfiguration ChefConfiguration (Maybe Text) (Maybe Text)
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 :: (Maybe Bool -> f (Maybe Bool))
-> ChefConfiguration -> f ChefConfiguration
chefConfiguration_manageBerkshelf = (ChefConfiguration -> Maybe Bool)
-> (ChefConfiguration -> Maybe Bool -> ChefConfiguration)
-> Lens
     ChefConfiguration ChefConfiguration (Maybe Bool) (Maybe Bool)
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 Core.FromJSON ChefConfiguration where
  parseJSON :: Value -> Parser ChefConfiguration
parseJSON =
    String
-> (Object -> Parser ChefConfiguration)
-> Value
-> Parser ChefConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ChefConfiguration"
      ( \Object
x ->
          Maybe Text -> Maybe Bool -> ChefConfiguration
ChefConfiguration'
            (Maybe Text -> Maybe Bool -> ChefConfiguration)
-> Parser (Maybe Text) -> Parser (Maybe Bool -> ChefConfiguration)
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
"BerkshelfVersion")
            Parser (Maybe Bool -> ChefConfiguration)
-> Parser (Maybe Bool) -> Parser ChefConfiguration
forall (f :: * -> *) a b. Applicative f => 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
"ManageBerkshelf")
      )

instance Prelude.Hashable ChefConfiguration

instance Prelude.NFData ChefConfiguration

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"BerkshelfVersion" 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
berkshelfVersion,
            (Text
"ManageBerkshelf" 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
manageBerkshelf
          ]
      )