{-# 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.EKS.Types.LogSetup
-- 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.EKS.Types.LogSetup where

import qualified Amazonka.Core as Core
import Amazonka.EKS.Types.LogType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object representing the enabled or disabled Kubernetes control plane
-- logs for your cluster.
--
-- /See:/ 'newLogSetup' smart constructor.
data LogSetup = LogSetup'
  { -- | If a log type is enabled, that log type exports its control plane logs
    -- to CloudWatch Logs. If a log type isn\'t enabled, that log type doesn\'t
    -- export its control plane logs. Each individual log type can be enabled
    -- or disabled independently.
    LogSetup -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The available cluster control plane log types.
    LogSetup -> Maybe [LogType]
types :: Prelude.Maybe [LogType]
  }
  deriving (LogSetup -> LogSetup -> Bool
(LogSetup -> LogSetup -> Bool)
-> (LogSetup -> LogSetup -> Bool) -> Eq LogSetup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogSetup -> LogSetup -> Bool
$c/= :: LogSetup -> LogSetup -> Bool
== :: LogSetup -> LogSetup -> Bool
$c== :: LogSetup -> LogSetup -> Bool
Prelude.Eq, ReadPrec [LogSetup]
ReadPrec LogSetup
Int -> ReadS LogSetup
ReadS [LogSetup]
(Int -> ReadS LogSetup)
-> ReadS [LogSetup]
-> ReadPrec LogSetup
-> ReadPrec [LogSetup]
-> Read LogSetup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogSetup]
$creadListPrec :: ReadPrec [LogSetup]
readPrec :: ReadPrec LogSetup
$creadPrec :: ReadPrec LogSetup
readList :: ReadS [LogSetup]
$creadList :: ReadS [LogSetup]
readsPrec :: Int -> ReadS LogSetup
$creadsPrec :: Int -> ReadS LogSetup
Prelude.Read, Int -> LogSetup -> ShowS
[LogSetup] -> ShowS
LogSetup -> String
(Int -> LogSetup -> ShowS)
-> (LogSetup -> String) -> ([LogSetup] -> ShowS) -> Show LogSetup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogSetup] -> ShowS
$cshowList :: [LogSetup] -> ShowS
show :: LogSetup -> String
$cshow :: LogSetup -> String
showsPrec :: Int -> LogSetup -> ShowS
$cshowsPrec :: Int -> LogSetup -> ShowS
Prelude.Show, (forall x. LogSetup -> Rep LogSetup x)
-> (forall x. Rep LogSetup x -> LogSetup) -> Generic LogSetup
forall x. Rep LogSetup x -> LogSetup
forall x. LogSetup -> Rep LogSetup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LogSetup x -> LogSetup
$cfrom :: forall x. LogSetup -> Rep LogSetup x
Prelude.Generic)

-- |
-- Create a value of 'LogSetup' 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', 'logSetup_enabled' - If a log type is enabled, that log type exports its control plane logs
-- to CloudWatch Logs. If a log type isn\'t enabled, that log type doesn\'t
-- export its control plane logs. Each individual log type can be enabled
-- or disabled independently.
--
-- 'types', 'logSetup_types' - The available cluster control plane log types.
newLogSetup ::
  LogSetup
newLogSetup :: LogSetup
newLogSetup =
  LogSetup' :: Maybe Bool -> Maybe [LogType] -> LogSetup
LogSetup'
    { $sel:enabled:LogSetup' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:types:LogSetup' :: Maybe [LogType]
types = Maybe [LogType]
forall a. Maybe a
Prelude.Nothing
    }

-- | If a log type is enabled, that log type exports its control plane logs
-- to CloudWatch Logs. If a log type isn\'t enabled, that log type doesn\'t
-- export its control plane logs. Each individual log type can be enabled
-- or disabled independently.
logSetup_enabled :: Lens.Lens' LogSetup (Prelude.Maybe Prelude.Bool)
logSetup_enabled :: (Maybe Bool -> f (Maybe Bool)) -> LogSetup -> f LogSetup
logSetup_enabled = (LogSetup -> Maybe Bool)
-> (LogSetup -> Maybe Bool -> LogSetup)
-> Lens LogSetup LogSetup (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogSetup' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:LogSetup' :: LogSetup -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: LogSetup
s@LogSetup' {} Maybe Bool
a -> LogSetup
s {$sel:enabled:LogSetup' :: Maybe Bool
enabled = Maybe Bool
a} :: LogSetup)

-- | The available cluster control plane log types.
logSetup_types :: Lens.Lens' LogSetup (Prelude.Maybe [LogType])
logSetup_types :: (Maybe [LogType] -> f (Maybe [LogType])) -> LogSetup -> f LogSetup
logSetup_types = (LogSetup -> Maybe [LogType])
-> (LogSetup -> Maybe [LogType] -> LogSetup)
-> Lens LogSetup LogSetup (Maybe [LogType]) (Maybe [LogType])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogSetup' {Maybe [LogType]
types :: Maybe [LogType]
$sel:types:LogSetup' :: LogSetup -> Maybe [LogType]
types} -> Maybe [LogType]
types) (\s :: LogSetup
s@LogSetup' {} Maybe [LogType]
a -> LogSetup
s {$sel:types:LogSetup' :: Maybe [LogType]
types = Maybe [LogType]
a} :: LogSetup) ((Maybe [LogType] -> f (Maybe [LogType]))
 -> LogSetup -> f LogSetup)
-> ((Maybe [LogType] -> f (Maybe [LogType]))
    -> Maybe [LogType] -> f (Maybe [LogType]))
-> (Maybe [LogType] -> f (Maybe [LogType]))
-> LogSetup
-> f LogSetup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [LogType] [LogType] [LogType] [LogType]
-> Iso
     (Maybe [LogType])
     (Maybe [LogType])
     (Maybe [LogType])
     (Maybe [LogType])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [LogType] [LogType] [LogType] [LogType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON LogSetup where
  parseJSON :: Value -> Parser LogSetup
parseJSON =
    String -> (Object -> Parser LogSetup) -> Value -> Parser LogSetup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LogSetup"
      ( \Object
x ->
          Maybe Bool -> Maybe [LogType] -> LogSetup
LogSetup'
            (Maybe Bool -> Maybe [LogType] -> LogSetup)
-> Parser (Maybe Bool) -> Parser (Maybe [LogType] -> LogSetup)
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")
            Parser (Maybe [LogType] -> LogSetup)
-> Parser (Maybe [LogType]) -> Parser LogSetup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [LogType]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"types" Parser (Maybe (Maybe [LogType]))
-> Maybe [LogType] -> Parser (Maybe [LogType])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [LogType]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable LogSetup

instance Prelude.NFData LogSetup

instance Core.ToJSON LogSetup where
  toJSON :: LogSetup -> Value
toJSON LogSetup' {Maybe Bool
Maybe [LogType]
types :: Maybe [LogType]
enabled :: Maybe Bool
$sel:types:LogSetup' :: LogSetup -> Maybe [LogType]
$sel:enabled:LogSetup' :: LogSetup -> 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,
            (Text
"types" Text -> [LogType] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([LogType] -> Pair) -> Maybe [LogType] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [LogType]
types
          ]
      )