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

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

-- | The settings to use when creating a cluster. This parameter is used to
-- enable CloudWatch Container Insights for a cluster.
--
-- /See:/ 'newClusterSetting' smart constructor.
data ClusterSetting = 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 -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The name of the cluster setting. The only supported value is
    -- @containerInsights@.
    ClusterSetting -> Maybe ClusterSettingName
name :: Prelude.Maybe ClusterSettingName
  }
  deriving (ClusterSetting -> ClusterSetting -> Bool
(ClusterSetting -> ClusterSetting -> Bool)
-> (ClusterSetting -> ClusterSetting -> Bool) -> Eq ClusterSetting
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]
(Int -> ReadS ClusterSetting)
-> ReadS [ClusterSetting]
-> ReadPrec ClusterSetting
-> ReadPrec [ClusterSetting]
-> Read 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
(Int -> ClusterSetting -> ShowS)
-> (ClusterSetting -> String)
-> ([ClusterSetting] -> ShowS)
-> Show ClusterSetting
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. ClusterSetting -> Rep ClusterSetting x)
-> (forall x. Rep ClusterSetting x -> ClusterSetting)
-> Generic ClusterSetting
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:
--
-- '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.
--
-- 'name', 'clusterSetting_name' - The name of the cluster setting. The only supported value is
-- @containerInsights@.
newClusterSetting ::
  ClusterSetting
newClusterSetting :: ClusterSetting
newClusterSetting =
  ClusterSetting' :: Maybe Text -> Maybe ClusterSettingName -> ClusterSetting
ClusterSetting'
    { $sel:value:ClusterSetting' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ClusterSetting' :: Maybe ClusterSettingName
name = Maybe ClusterSettingName
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> ClusterSetting -> f ClusterSetting
clusterSetting_value = (ClusterSetting -> Maybe Text)
-> (ClusterSetting -> Maybe Text -> ClusterSetting)
-> Lens ClusterSetting ClusterSetting (Maybe Text) (Maybe Text)
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)

-- | The name of the cluster setting. The only supported value is
-- @containerInsights@.
clusterSetting_name :: Lens.Lens' ClusterSetting (Prelude.Maybe ClusterSettingName)
clusterSetting_name :: (Maybe ClusterSettingName -> f (Maybe ClusterSettingName))
-> ClusterSetting -> f ClusterSetting
clusterSetting_name = (ClusterSetting -> Maybe ClusterSettingName)
-> (ClusterSetting -> Maybe ClusterSettingName -> ClusterSetting)
-> Lens
     ClusterSetting
     ClusterSetting
     (Maybe ClusterSettingName)
     (Maybe ClusterSettingName)
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)

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

instance Prelude.Hashable ClusterSetting

instance Prelude.NFData ClusterSetting

instance Core.ToJSON ClusterSetting where
  toJSON :: ClusterSetting -> Value
toJSON ClusterSetting' {Maybe Text
Maybe ClusterSettingName
name :: Maybe ClusterSettingName
value :: Maybe Text
$sel:name:ClusterSetting' :: ClusterSetting -> Maybe ClusterSettingName
$sel:value:ClusterSetting' :: ClusterSetting -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"value" 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
value,
            (Text
"name" Text -> ClusterSettingName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ClusterSettingName -> Pair)
-> Maybe ClusterSettingName -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ClusterSettingName
name
          ]
      )