{-# 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.ECS.Types.ClusterSetting
-- 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.ECS.Types.ClusterSetting where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ECS.Types.ClusterSettingName
import qualified Amazonka.Prelude as Prelude

-- | The settings to use when creating a cluster. This parameter is used to
-- turn on CloudWatch Container Insights for a cluster.
--
-- /See:/ 'newClusterSetting' smart constructor.
data ClusterSetting = ClusterSetting'
  { -- | The name of the cluster setting. The only supported value is
    -- @containerInsights@.
    ClusterSetting -> Maybe ClusterSettingName
name :: Prelude.Maybe ClusterSettingName,
    -- | The value to set for the cluster setting. The supported values are
    -- @enabled@ and @disabled@. If @enabled@ is specified, CloudWatch
    -- Container Insights will be enabled for the cluster, otherwise it will be
    -- disabled unless the @containerInsights@ account setting is enabled. If a
    -- cluster value is specified, it will override the @containerInsights@
    -- value set with PutAccountSetting or PutAccountSettingDefault.
    ClusterSetting -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (ClusterSetting -> ClusterSetting -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClusterSetting -> ClusterSetting -> Bool
$c/= :: ClusterSetting -> ClusterSetting -> Bool
== :: ClusterSetting -> ClusterSetting -> Bool
$c== :: ClusterSetting -> ClusterSetting -> Bool
Prelude.Eq, ReadPrec [ClusterSetting]
ReadPrec ClusterSetting
Int -> ReadS ClusterSetting
ReadS [ClusterSetting]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClusterSetting]
$creadListPrec :: ReadPrec [ClusterSetting]
readPrec :: ReadPrec ClusterSetting
$creadPrec :: ReadPrec ClusterSetting
readList :: ReadS [ClusterSetting]
$creadList :: ReadS [ClusterSetting]
readsPrec :: Int -> ReadS ClusterSetting
$creadsPrec :: Int -> ReadS ClusterSetting
Prelude.Read, Int -> ClusterSetting -> ShowS
[ClusterSetting] -> ShowS
ClusterSetting -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClusterSetting] -> ShowS
$cshowList :: [ClusterSetting] -> ShowS
show :: ClusterSetting -> String
$cshow :: ClusterSetting -> String
showsPrec :: Int -> ClusterSetting -> ShowS
$cshowsPrec :: Int -> ClusterSetting -> ShowS
Prelude.Show, forall x. Rep ClusterSetting x -> ClusterSetting
forall x. ClusterSetting -> Rep ClusterSetting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClusterSetting x -> ClusterSetting
$cfrom :: forall x. ClusterSetting -> Rep ClusterSetting x
Prelude.Generic)

-- |
-- Create a value of 'ClusterSetting' 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:
--
-- 'name', 'clusterSetting_name' - The name of the cluster setting. The only supported value is
-- @containerInsights@.
--
-- 'value', 'clusterSetting_value' - The value to set for the cluster setting. The supported values are
-- @enabled@ and @disabled@. If @enabled@ is specified, CloudWatch
-- Container Insights will be enabled for the cluster, otherwise it will be
-- disabled unless the @containerInsights@ account setting is enabled. If a
-- cluster value is specified, it will override the @containerInsights@
-- value set with PutAccountSetting or PutAccountSettingDefault.
newClusterSetting ::
  ClusterSetting
newClusterSetting :: ClusterSetting
newClusterSetting =
  ClusterSetting'
    { $sel:name:ClusterSetting' :: Maybe ClusterSettingName
name = forall a. Maybe a
Prelude.Nothing,
      $sel:value:ClusterSetting' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the cluster setting. The only supported value is
-- @containerInsights@.
clusterSetting_name :: Lens.Lens' ClusterSetting (Prelude.Maybe ClusterSettingName)
clusterSetting_name :: Lens' ClusterSetting (Maybe ClusterSettingName)
clusterSetting_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterSetting' {Maybe ClusterSettingName
name :: Maybe ClusterSettingName
$sel:name:ClusterSetting' :: ClusterSetting -> Maybe ClusterSettingName
name} -> Maybe ClusterSettingName
name) (\s :: ClusterSetting
s@ClusterSetting' {} Maybe ClusterSettingName
a -> ClusterSetting
s {$sel:name:ClusterSetting' :: Maybe ClusterSettingName
name = Maybe ClusterSettingName
a} :: ClusterSetting)

-- | The value to set for the cluster setting. The supported values are
-- @enabled@ and @disabled@. If @enabled@ is specified, CloudWatch
-- Container Insights will be enabled for the cluster, otherwise it will be
-- disabled unless the @containerInsights@ account setting is enabled. If a
-- cluster value is specified, it will override the @containerInsights@
-- value set with PutAccountSetting or PutAccountSettingDefault.
clusterSetting_value :: Lens.Lens' ClusterSetting (Prelude.Maybe Prelude.Text)
clusterSetting_value :: Lens' ClusterSetting (Maybe Text)
clusterSetting_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterSetting' {Maybe Text
value :: Maybe Text
$sel:value:ClusterSetting' :: ClusterSetting -> Maybe Text
value} -> Maybe Text
value) (\s :: ClusterSetting
s@ClusterSetting' {} Maybe Text
a -> ClusterSetting
s {$sel:value:ClusterSetting' :: Maybe Text
value = Maybe Text
a} :: ClusterSetting)

instance Data.FromJSON ClusterSetting where
  parseJSON :: Value -> Parser ClusterSetting
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ClusterSetting"
      ( \Object
x ->
          Maybe ClusterSettingName -> Maybe Text -> ClusterSetting
ClusterSetting'
            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
"name")
            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
"value")
      )

instance Prelude.Hashable ClusterSetting where
  hashWithSalt :: Int -> ClusterSetting -> Int
hashWithSalt Int
_salt ClusterSetting' {Maybe Text
Maybe ClusterSettingName
value :: Maybe Text
name :: Maybe ClusterSettingName
$sel:value:ClusterSetting' :: ClusterSetting -> Maybe Text
$sel:name:ClusterSetting' :: ClusterSetting -> Maybe ClusterSettingName
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ClusterSettingName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData ClusterSetting where
  rnf :: ClusterSetting -> ()
rnf ClusterSetting' {Maybe Text
Maybe ClusterSettingName
value :: Maybe Text
name :: Maybe ClusterSettingName
$sel:value:ClusterSetting' :: ClusterSetting -> Maybe Text
$sel:name:ClusterSetting' :: ClusterSetting -> Maybe ClusterSettingName
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ClusterSettingName
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value

instance Data.ToJSON ClusterSetting where
  toJSON :: ClusterSetting -> Value
toJSON ClusterSetting' {Maybe Text
Maybe ClusterSettingName
value :: Maybe Text
name :: Maybe ClusterSettingName
$sel:value:ClusterSetting' :: ClusterSetting -> Maybe Text
$sel:name:ClusterSetting' :: ClusterSetting -> Maybe ClusterSettingName
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"name" 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 ClusterSettingName
name,
            (Key
"value" 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
value
          ]
      )