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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The log configuration for the results of the execute command actions.
-- The logs can be sent to CloudWatch Logs or an Amazon S3 bucket.
--
-- /See:/ 'newExecuteCommandLogConfiguration' smart constructor.
data ExecuteCommandLogConfiguration = ExecuteCommandLogConfiguration'
  { -- | The name of the CloudWatch log group to send logs to.
    --
    -- The CloudWatch log group must already be created.
    ExecuteCommandLogConfiguration -> Maybe Text
cloudWatchLogGroupName :: Prelude.Maybe Prelude.Text,
    -- | An optional folder in the S3 bucket to place logs in.
    ExecuteCommandLogConfiguration -> Maybe Text
s3KeyPrefix :: Prelude.Maybe Prelude.Text,
    -- | Whether or not to enable encryption on the CloudWatch logs. If not
    -- specified, encryption will be disabled.
    ExecuteCommandLogConfiguration -> Maybe Bool
cloudWatchEncryptionEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether or not to enable encryption on the CloudWatch logs. If not
    -- specified, encryption will be disabled.
    ExecuteCommandLogConfiguration -> Maybe Bool
s3EncryptionEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The name of the S3 bucket to send logs to.
    --
    -- The S3 bucket must already be created.
    ExecuteCommandLogConfiguration -> Maybe Text
s3BucketName :: Prelude.Maybe Prelude.Text
  }
  deriving (ExecuteCommandLogConfiguration
-> ExecuteCommandLogConfiguration -> Bool
(ExecuteCommandLogConfiguration
 -> ExecuteCommandLogConfiguration -> Bool)
-> (ExecuteCommandLogConfiguration
    -> ExecuteCommandLogConfiguration -> Bool)
-> Eq ExecuteCommandLogConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecuteCommandLogConfiguration
-> ExecuteCommandLogConfiguration -> Bool
$c/= :: ExecuteCommandLogConfiguration
-> ExecuteCommandLogConfiguration -> Bool
== :: ExecuteCommandLogConfiguration
-> ExecuteCommandLogConfiguration -> Bool
$c== :: ExecuteCommandLogConfiguration
-> ExecuteCommandLogConfiguration -> Bool
Prelude.Eq, ReadPrec [ExecuteCommandLogConfiguration]
ReadPrec ExecuteCommandLogConfiguration
Int -> ReadS ExecuteCommandLogConfiguration
ReadS [ExecuteCommandLogConfiguration]
(Int -> ReadS ExecuteCommandLogConfiguration)
-> ReadS [ExecuteCommandLogConfiguration]
-> ReadPrec ExecuteCommandLogConfiguration
-> ReadPrec [ExecuteCommandLogConfiguration]
-> Read ExecuteCommandLogConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecuteCommandLogConfiguration]
$creadListPrec :: ReadPrec [ExecuteCommandLogConfiguration]
readPrec :: ReadPrec ExecuteCommandLogConfiguration
$creadPrec :: ReadPrec ExecuteCommandLogConfiguration
readList :: ReadS [ExecuteCommandLogConfiguration]
$creadList :: ReadS [ExecuteCommandLogConfiguration]
readsPrec :: Int -> ReadS ExecuteCommandLogConfiguration
$creadsPrec :: Int -> ReadS ExecuteCommandLogConfiguration
Prelude.Read, Int -> ExecuteCommandLogConfiguration -> ShowS
[ExecuteCommandLogConfiguration] -> ShowS
ExecuteCommandLogConfiguration -> String
(Int -> ExecuteCommandLogConfiguration -> ShowS)
-> (ExecuteCommandLogConfiguration -> String)
-> ([ExecuteCommandLogConfiguration] -> ShowS)
-> Show ExecuteCommandLogConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecuteCommandLogConfiguration] -> ShowS
$cshowList :: [ExecuteCommandLogConfiguration] -> ShowS
show :: ExecuteCommandLogConfiguration -> String
$cshow :: ExecuteCommandLogConfiguration -> String
showsPrec :: Int -> ExecuteCommandLogConfiguration -> ShowS
$cshowsPrec :: Int -> ExecuteCommandLogConfiguration -> ShowS
Prelude.Show, (forall x.
 ExecuteCommandLogConfiguration
 -> Rep ExecuteCommandLogConfiguration x)
-> (forall x.
    Rep ExecuteCommandLogConfiguration x
    -> ExecuteCommandLogConfiguration)
-> Generic ExecuteCommandLogConfiguration
forall x.
Rep ExecuteCommandLogConfiguration x
-> ExecuteCommandLogConfiguration
forall x.
ExecuteCommandLogConfiguration
-> Rep ExecuteCommandLogConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ExecuteCommandLogConfiguration x
-> ExecuteCommandLogConfiguration
$cfrom :: forall x.
ExecuteCommandLogConfiguration
-> Rep ExecuteCommandLogConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ExecuteCommandLogConfiguration' 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:
--
-- 'cloudWatchLogGroupName', 'executeCommandLogConfiguration_cloudWatchLogGroupName' - The name of the CloudWatch log group to send logs to.
--
-- The CloudWatch log group must already be created.
--
-- 's3KeyPrefix', 'executeCommandLogConfiguration_s3KeyPrefix' - An optional folder in the S3 bucket to place logs in.
--
-- 'cloudWatchEncryptionEnabled', 'executeCommandLogConfiguration_cloudWatchEncryptionEnabled' - Whether or not to enable encryption on the CloudWatch logs. If not
-- specified, encryption will be disabled.
--
-- 's3EncryptionEnabled', 'executeCommandLogConfiguration_s3EncryptionEnabled' - Whether or not to enable encryption on the CloudWatch logs. If not
-- specified, encryption will be disabled.
--
-- 's3BucketName', 'executeCommandLogConfiguration_s3BucketName' - The name of the S3 bucket to send logs to.
--
-- The S3 bucket must already be created.
newExecuteCommandLogConfiguration ::
  ExecuteCommandLogConfiguration
newExecuteCommandLogConfiguration :: ExecuteCommandLogConfiguration
newExecuteCommandLogConfiguration =
  ExecuteCommandLogConfiguration' :: Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Text
-> ExecuteCommandLogConfiguration
ExecuteCommandLogConfiguration'
    { $sel:cloudWatchLogGroupName:ExecuteCommandLogConfiguration' :: Maybe Text
cloudWatchLogGroupName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3KeyPrefix:ExecuteCommandLogConfiguration' :: Maybe Text
s3KeyPrefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:cloudWatchEncryptionEnabled:ExecuteCommandLogConfiguration' :: Maybe Bool
cloudWatchEncryptionEnabled =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:s3EncryptionEnabled:ExecuteCommandLogConfiguration' :: Maybe Bool
s3EncryptionEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:s3BucketName:ExecuteCommandLogConfiguration' :: Maybe Text
s3BucketName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the CloudWatch log group to send logs to.
--
-- The CloudWatch log group must already be created.
executeCommandLogConfiguration_cloudWatchLogGroupName :: Lens.Lens' ExecuteCommandLogConfiguration (Prelude.Maybe Prelude.Text)
executeCommandLogConfiguration_cloudWatchLogGroupName :: (Maybe Text -> f (Maybe Text))
-> ExecuteCommandLogConfiguration
-> f ExecuteCommandLogConfiguration
executeCommandLogConfiguration_cloudWatchLogGroupName = (ExecuteCommandLogConfiguration -> Maybe Text)
-> (ExecuteCommandLogConfiguration
    -> Maybe Text -> ExecuteCommandLogConfiguration)
-> Lens
     ExecuteCommandLogConfiguration
     ExecuteCommandLogConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteCommandLogConfiguration' {Maybe Text
cloudWatchLogGroupName :: Maybe Text
$sel:cloudWatchLogGroupName:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Text
cloudWatchLogGroupName} -> Maybe Text
cloudWatchLogGroupName) (\s :: ExecuteCommandLogConfiguration
s@ExecuteCommandLogConfiguration' {} Maybe Text
a -> ExecuteCommandLogConfiguration
s {$sel:cloudWatchLogGroupName:ExecuteCommandLogConfiguration' :: Maybe Text
cloudWatchLogGroupName = Maybe Text
a} :: ExecuteCommandLogConfiguration)

-- | An optional folder in the S3 bucket to place logs in.
executeCommandLogConfiguration_s3KeyPrefix :: Lens.Lens' ExecuteCommandLogConfiguration (Prelude.Maybe Prelude.Text)
executeCommandLogConfiguration_s3KeyPrefix :: (Maybe Text -> f (Maybe Text))
-> ExecuteCommandLogConfiguration
-> f ExecuteCommandLogConfiguration
executeCommandLogConfiguration_s3KeyPrefix = (ExecuteCommandLogConfiguration -> Maybe Text)
-> (ExecuteCommandLogConfiguration
    -> Maybe Text -> ExecuteCommandLogConfiguration)
-> Lens
     ExecuteCommandLogConfiguration
     ExecuteCommandLogConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteCommandLogConfiguration' {Maybe Text
s3KeyPrefix :: Maybe Text
$sel:s3KeyPrefix:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Text
s3KeyPrefix} -> Maybe Text
s3KeyPrefix) (\s :: ExecuteCommandLogConfiguration
s@ExecuteCommandLogConfiguration' {} Maybe Text
a -> ExecuteCommandLogConfiguration
s {$sel:s3KeyPrefix:ExecuteCommandLogConfiguration' :: Maybe Text
s3KeyPrefix = Maybe Text
a} :: ExecuteCommandLogConfiguration)

-- | Whether or not to enable encryption on the CloudWatch logs. If not
-- specified, encryption will be disabled.
executeCommandLogConfiguration_cloudWatchEncryptionEnabled :: Lens.Lens' ExecuteCommandLogConfiguration (Prelude.Maybe Prelude.Bool)
executeCommandLogConfiguration_cloudWatchEncryptionEnabled :: (Maybe Bool -> f (Maybe Bool))
-> ExecuteCommandLogConfiguration
-> f ExecuteCommandLogConfiguration
executeCommandLogConfiguration_cloudWatchEncryptionEnabled = (ExecuteCommandLogConfiguration -> Maybe Bool)
-> (ExecuteCommandLogConfiguration
    -> Maybe Bool -> ExecuteCommandLogConfiguration)
-> Lens
     ExecuteCommandLogConfiguration
     ExecuteCommandLogConfiguration
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteCommandLogConfiguration' {Maybe Bool
cloudWatchEncryptionEnabled :: Maybe Bool
$sel:cloudWatchEncryptionEnabled:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Bool
cloudWatchEncryptionEnabled} -> Maybe Bool
cloudWatchEncryptionEnabled) (\s :: ExecuteCommandLogConfiguration
s@ExecuteCommandLogConfiguration' {} Maybe Bool
a -> ExecuteCommandLogConfiguration
s {$sel:cloudWatchEncryptionEnabled:ExecuteCommandLogConfiguration' :: Maybe Bool
cloudWatchEncryptionEnabled = Maybe Bool
a} :: ExecuteCommandLogConfiguration)

-- | Whether or not to enable encryption on the CloudWatch logs. If not
-- specified, encryption will be disabled.
executeCommandLogConfiguration_s3EncryptionEnabled :: Lens.Lens' ExecuteCommandLogConfiguration (Prelude.Maybe Prelude.Bool)
executeCommandLogConfiguration_s3EncryptionEnabled :: (Maybe Bool -> f (Maybe Bool))
-> ExecuteCommandLogConfiguration
-> f ExecuteCommandLogConfiguration
executeCommandLogConfiguration_s3EncryptionEnabled = (ExecuteCommandLogConfiguration -> Maybe Bool)
-> (ExecuteCommandLogConfiguration
    -> Maybe Bool -> ExecuteCommandLogConfiguration)
-> Lens
     ExecuteCommandLogConfiguration
     ExecuteCommandLogConfiguration
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteCommandLogConfiguration' {Maybe Bool
s3EncryptionEnabled :: Maybe Bool
$sel:s3EncryptionEnabled:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Bool
s3EncryptionEnabled} -> Maybe Bool
s3EncryptionEnabled) (\s :: ExecuteCommandLogConfiguration
s@ExecuteCommandLogConfiguration' {} Maybe Bool
a -> ExecuteCommandLogConfiguration
s {$sel:s3EncryptionEnabled:ExecuteCommandLogConfiguration' :: Maybe Bool
s3EncryptionEnabled = Maybe Bool
a} :: ExecuteCommandLogConfiguration)

-- | The name of the S3 bucket to send logs to.
--
-- The S3 bucket must already be created.
executeCommandLogConfiguration_s3BucketName :: Lens.Lens' ExecuteCommandLogConfiguration (Prelude.Maybe Prelude.Text)
executeCommandLogConfiguration_s3BucketName :: (Maybe Text -> f (Maybe Text))
-> ExecuteCommandLogConfiguration
-> f ExecuteCommandLogConfiguration
executeCommandLogConfiguration_s3BucketName = (ExecuteCommandLogConfiguration -> Maybe Text)
-> (ExecuteCommandLogConfiguration
    -> Maybe Text -> ExecuteCommandLogConfiguration)
-> Lens
     ExecuteCommandLogConfiguration
     ExecuteCommandLogConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteCommandLogConfiguration' {Maybe Text
s3BucketName :: Maybe Text
$sel:s3BucketName:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Text
s3BucketName} -> Maybe Text
s3BucketName) (\s :: ExecuteCommandLogConfiguration
s@ExecuteCommandLogConfiguration' {} Maybe Text
a -> ExecuteCommandLogConfiguration
s {$sel:s3BucketName:ExecuteCommandLogConfiguration' :: Maybe Text
s3BucketName = Maybe Text
a} :: ExecuteCommandLogConfiguration)

instance Core.FromJSON ExecuteCommandLogConfiguration where
  parseJSON :: Value -> Parser ExecuteCommandLogConfiguration
parseJSON =
    String
-> (Object -> Parser ExecuteCommandLogConfiguration)
-> Value
-> Parser ExecuteCommandLogConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExecuteCommandLogConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Text
-> ExecuteCommandLogConfiguration
ExecuteCommandLogConfiguration'
            (Maybe Text
 -> Maybe Text
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Text
 -> ExecuteCommandLogConfiguration)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Text
      -> ExecuteCommandLogConfiguration)
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
"cloudWatchLogGroupName")
            Parser
  (Maybe Text
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Text
   -> ExecuteCommandLogConfiguration)
-> Parser (Maybe Text)
-> Parser
     (Maybe Bool
      -> Maybe Bool -> Maybe Text -> ExecuteCommandLogConfiguration)
forall (f :: * -> *) a b. Applicative f => 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
"s3KeyPrefix")
            Parser
  (Maybe Bool
   -> Maybe Bool -> Maybe Text -> ExecuteCommandLogConfiguration)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool -> Maybe Text -> ExecuteCommandLogConfiguration)
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
"cloudWatchEncryptionEnabled")
            Parser (Maybe Bool -> Maybe Text -> ExecuteCommandLogConfiguration)
-> Parser (Maybe Bool)
-> Parser (Maybe Text -> ExecuteCommandLogConfiguration)
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
"s3EncryptionEnabled")
            Parser (Maybe Text -> ExecuteCommandLogConfiguration)
-> Parser (Maybe Text) -> Parser ExecuteCommandLogConfiguration
forall (f :: * -> *) a b. Applicative f => 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
"s3BucketName")
      )

instance
  Prelude.Hashable
    ExecuteCommandLogConfiguration

instance
  Prelude.NFData
    ExecuteCommandLogConfiguration

instance Core.ToJSON ExecuteCommandLogConfiguration where
  toJSON :: ExecuteCommandLogConfiguration -> Value
toJSON ExecuteCommandLogConfiguration' {Maybe Bool
Maybe Text
s3BucketName :: Maybe Text
s3EncryptionEnabled :: Maybe Bool
cloudWatchEncryptionEnabled :: Maybe Bool
s3KeyPrefix :: Maybe Text
cloudWatchLogGroupName :: Maybe Text
$sel:s3BucketName:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Text
$sel:s3EncryptionEnabled:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Bool
$sel:cloudWatchEncryptionEnabled:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Bool
$sel:s3KeyPrefix:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Text
$sel:cloudWatchLogGroupName:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"cloudWatchLogGroupName" 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
cloudWatchLogGroupName,
            (Text
"s3KeyPrefix" 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
s3KeyPrefix,
            (Text
"cloudWatchEncryptionEnabled" 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
cloudWatchEncryptionEnabled,
            (Text
"s3EncryptionEnabled" 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
s3EncryptionEnabled,
            (Text
"s3BucketName" 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
s3BucketName
          ]
      )