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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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'
  { -- | Determines whether to use encryption on the CloudWatch logs. If not
    -- specified, encryption will be disabled.
    ExecuteCommandLogConfiguration -> Maybe Bool
cloudWatchEncryptionEnabled :: Prelude.Maybe Prelude.Bool,
    -- | 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,
    -- | 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,
    -- | Determines whether to use encryption on the S3 logs. If not specified,
    -- encryption is not used.
    ExecuteCommandLogConfiguration -> Maybe Bool
s3EncryptionEnabled :: Prelude.Maybe Prelude.Bool,
    -- | An optional folder in the S3 bucket to place logs in.
    ExecuteCommandLogConfiguration -> Maybe Text
s3KeyPrefix :: Prelude.Maybe Prelude.Text
  }
  deriving (ExecuteCommandLogConfiguration
-> ExecuteCommandLogConfiguration -> Bool
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]
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
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.
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:
--
-- 'cloudWatchEncryptionEnabled', 'executeCommandLogConfiguration_cloudWatchEncryptionEnabled' - Determines whether to use encryption on the CloudWatch logs. If not
-- specified, encryption will be disabled.
--
-- 'cloudWatchLogGroupName', 'executeCommandLogConfiguration_cloudWatchLogGroupName' - The name of the CloudWatch log group to send logs to.
--
-- The CloudWatch log group must already be created.
--
-- 's3BucketName', 'executeCommandLogConfiguration_s3BucketName' - The name of the S3 bucket to send logs to.
--
-- The S3 bucket must already be created.
--
-- 's3EncryptionEnabled', 'executeCommandLogConfiguration_s3EncryptionEnabled' - Determines whether to use encryption on the S3 logs. If not specified,
-- encryption is not used.
--
-- 's3KeyPrefix', 'executeCommandLogConfiguration_s3KeyPrefix' - An optional folder in the S3 bucket to place logs in.
newExecuteCommandLogConfiguration ::
  ExecuteCommandLogConfiguration
newExecuteCommandLogConfiguration :: ExecuteCommandLogConfiguration
newExecuteCommandLogConfiguration =
  ExecuteCommandLogConfiguration'
    { $sel:cloudWatchEncryptionEnabled:ExecuteCommandLogConfiguration' :: Maybe Bool
cloudWatchEncryptionEnabled =
        forall a. Maybe a
Prelude.Nothing,
      $sel:cloudWatchLogGroupName:ExecuteCommandLogConfiguration' :: Maybe Text
cloudWatchLogGroupName = forall a. Maybe a
Prelude.Nothing,
      $sel:s3BucketName:ExecuteCommandLogConfiguration' :: Maybe Text
s3BucketName = forall a. Maybe a
Prelude.Nothing,
      $sel:s3EncryptionEnabled:ExecuteCommandLogConfiguration' :: Maybe Bool
s3EncryptionEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:s3KeyPrefix:ExecuteCommandLogConfiguration' :: Maybe Text
s3KeyPrefix = forall a. Maybe a
Prelude.Nothing
    }

-- | Determines whether to use encryption on the CloudWatch logs. If not
-- specified, encryption will be disabled.
executeCommandLogConfiguration_cloudWatchEncryptionEnabled :: Lens.Lens' ExecuteCommandLogConfiguration (Prelude.Maybe Prelude.Bool)
executeCommandLogConfiguration_cloudWatchEncryptionEnabled :: Lens' ExecuteCommandLogConfiguration (Maybe Bool)
executeCommandLogConfiguration_cloudWatchEncryptionEnabled = 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)

-- | 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 :: Lens' ExecuteCommandLogConfiguration (Maybe Text)
executeCommandLogConfiguration_cloudWatchLogGroupName = 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)

-- | 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 :: Lens' ExecuteCommandLogConfiguration (Maybe Text)
executeCommandLogConfiguration_s3BucketName = 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)

-- | Determines whether to use encryption on the S3 logs. If not specified,
-- encryption is not used.
executeCommandLogConfiguration_s3EncryptionEnabled :: Lens.Lens' ExecuteCommandLogConfiguration (Prelude.Maybe Prelude.Bool)
executeCommandLogConfiguration_s3EncryptionEnabled :: Lens' ExecuteCommandLogConfiguration (Maybe Bool)
executeCommandLogConfiguration_s3EncryptionEnabled = 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)

-- | An optional folder in the S3 bucket to place logs in.
executeCommandLogConfiguration_s3KeyPrefix :: Lens.Lens' ExecuteCommandLogConfiguration (Prelude.Maybe Prelude.Text)
executeCommandLogConfiguration_s3KeyPrefix :: Lens' ExecuteCommandLogConfiguration (Maybe Text)
executeCommandLogConfiguration_s3KeyPrefix = 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)

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

instance
  Prelude.Hashable
    ExecuteCommandLogConfiguration
  where
  hashWithSalt :: Int -> ExecuteCommandLogConfiguration -> Int
hashWithSalt
    Int
_salt
    ExecuteCommandLogConfiguration' {Maybe Bool
Maybe Text
s3KeyPrefix :: Maybe Text
s3EncryptionEnabled :: Maybe Bool
s3BucketName :: Maybe Text
cloudWatchLogGroupName :: Maybe Text
cloudWatchEncryptionEnabled :: Maybe Bool
$sel:s3KeyPrefix:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Text
$sel:s3EncryptionEnabled:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Bool
$sel:s3BucketName:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Text
$sel:cloudWatchLogGroupName:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Text
$sel:cloudWatchEncryptionEnabled:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Bool
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
cloudWatchEncryptionEnabled
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
cloudWatchLogGroupName
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
s3BucketName
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
s3EncryptionEnabled
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
s3KeyPrefix

instance
  Prelude.NFData
    ExecuteCommandLogConfiguration
  where
  rnf :: ExecuteCommandLogConfiguration -> ()
rnf ExecuteCommandLogConfiguration' {Maybe Bool
Maybe Text
s3KeyPrefix :: Maybe Text
s3EncryptionEnabled :: Maybe Bool
s3BucketName :: Maybe Text
cloudWatchLogGroupName :: Maybe Text
cloudWatchEncryptionEnabled :: Maybe Bool
$sel:s3KeyPrefix:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Text
$sel:s3EncryptionEnabled:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Bool
$sel:s3BucketName:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Text
$sel:cloudWatchLogGroupName:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Text
$sel:cloudWatchEncryptionEnabled:ExecuteCommandLogConfiguration' :: ExecuteCommandLogConfiguration -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
cloudWatchEncryptionEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
cloudWatchLogGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
s3BucketName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
s3EncryptionEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
s3KeyPrefix

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