{-# 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.Logging
-- 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.Logging where

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

-- | An object representing the logging configuration for resources in your
-- cluster.
--
-- /See:/ 'newLogging' smart constructor.
data Logging = Logging'
  { -- | The cluster control plane logging configuration for your cluster.
    Logging -> Maybe [LogSetup]
clusterLogging :: Prelude.Maybe [LogSetup]
  }
  deriving (Logging -> Logging -> Bool
(Logging -> Logging -> Bool)
-> (Logging -> Logging -> Bool) -> Eq Logging
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Logging -> Logging -> Bool
$c/= :: Logging -> Logging -> Bool
== :: Logging -> Logging -> Bool
$c== :: Logging -> Logging -> Bool
Prelude.Eq, ReadPrec [Logging]
ReadPrec Logging
Int -> ReadS Logging
ReadS [Logging]
(Int -> ReadS Logging)
-> ReadS [Logging]
-> ReadPrec Logging
-> ReadPrec [Logging]
-> Read Logging
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Logging]
$creadListPrec :: ReadPrec [Logging]
readPrec :: ReadPrec Logging
$creadPrec :: ReadPrec Logging
readList :: ReadS [Logging]
$creadList :: ReadS [Logging]
readsPrec :: Int -> ReadS Logging
$creadsPrec :: Int -> ReadS Logging
Prelude.Read, Int -> Logging -> ShowS
[Logging] -> ShowS
Logging -> String
(Int -> Logging -> ShowS)
-> (Logging -> String) -> ([Logging] -> ShowS) -> Show Logging
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Logging] -> ShowS
$cshowList :: [Logging] -> ShowS
show :: Logging -> String
$cshow :: Logging -> String
showsPrec :: Int -> Logging -> ShowS
$cshowsPrec :: Int -> Logging -> ShowS
Prelude.Show, (forall x. Logging -> Rep Logging x)
-> (forall x. Rep Logging x -> Logging) -> Generic Logging
forall x. Rep Logging x -> Logging
forall x. Logging -> Rep Logging x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Logging x -> Logging
$cfrom :: forall x. Logging -> Rep Logging x
Prelude.Generic)

-- |
-- Create a value of 'Logging' 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:
--
-- 'clusterLogging', 'logging_clusterLogging' - The cluster control plane logging configuration for your cluster.
newLogging ::
  Logging
newLogging :: Logging
newLogging =
  Logging' :: Maybe [LogSetup] -> Logging
Logging' {$sel:clusterLogging:Logging' :: Maybe [LogSetup]
clusterLogging = Maybe [LogSetup]
forall a. Maybe a
Prelude.Nothing}

-- | The cluster control plane logging configuration for your cluster.
logging_clusterLogging :: Lens.Lens' Logging (Prelude.Maybe [LogSetup])
logging_clusterLogging :: (Maybe [LogSetup] -> f (Maybe [LogSetup])) -> Logging -> f Logging
logging_clusterLogging = (Logging -> Maybe [LogSetup])
-> (Logging -> Maybe [LogSetup] -> Logging)
-> Lens Logging Logging (Maybe [LogSetup]) (Maybe [LogSetup])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Logging' {Maybe [LogSetup]
clusterLogging :: Maybe [LogSetup]
$sel:clusterLogging:Logging' :: Logging -> Maybe [LogSetup]
clusterLogging} -> Maybe [LogSetup]
clusterLogging) (\s :: Logging
s@Logging' {} Maybe [LogSetup]
a -> Logging
s {$sel:clusterLogging:Logging' :: Maybe [LogSetup]
clusterLogging = Maybe [LogSetup]
a} :: Logging) ((Maybe [LogSetup] -> f (Maybe [LogSetup]))
 -> Logging -> f Logging)
-> ((Maybe [LogSetup] -> f (Maybe [LogSetup]))
    -> Maybe [LogSetup] -> f (Maybe [LogSetup]))
-> (Maybe [LogSetup] -> f (Maybe [LogSetup]))
-> Logging
-> f Logging
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [LogSetup] [LogSetup] [LogSetup] [LogSetup]
-> Iso
     (Maybe [LogSetup])
     (Maybe [LogSetup])
     (Maybe [LogSetup])
     (Maybe [LogSetup])
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 [LogSetup] [LogSetup] [LogSetup] [LogSetup]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Logging where
  parseJSON :: Value -> Parser Logging
parseJSON =
    String -> (Object -> Parser Logging) -> Value -> Parser Logging
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Logging"
      ( \Object
x ->
          Maybe [LogSetup] -> Logging
Logging'
            (Maybe [LogSetup] -> Logging)
-> Parser (Maybe [LogSetup]) -> Parser Logging
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [LogSetup]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"clusterLogging"
                            Parser (Maybe (Maybe [LogSetup]))
-> Maybe [LogSetup] -> Parser (Maybe [LogSetup])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [LogSetup]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable Logging

instance Prelude.NFData Logging

instance Core.ToJSON Logging where
  toJSON :: Logging -> Value
toJSON Logging' {Maybe [LogSetup]
clusterLogging :: Maybe [LogSetup]
$sel:clusterLogging:Logging' :: Logging -> Maybe [LogSetup]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"clusterLogging" Text -> [LogSetup] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([LogSetup] -> Pair) -> Maybe [LogSetup] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [LogSetup]
clusterLogging
          ]
      )