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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ECS.Types.ExecuteCommandLogConfiguration
import Amazonka.ECS.Types.ExecuteCommandLogging
import qualified Amazonka.Prelude as Prelude

-- | The details of the execute command configuration.
--
-- /See:/ 'newExecuteCommandConfiguration' smart constructor.
data ExecuteCommandConfiguration = ExecuteCommandConfiguration'
  { -- | Specify an Key Management Service key ID to encrypt the data between the
    -- local client and the container.
    ExecuteCommandConfiguration -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The log configuration for the results of the execute command actions.
    -- The logs can be sent to CloudWatch Logs or an Amazon S3 bucket. When
    -- @logging=OVERRIDE@ is specified, a @logConfiguration@ must be provided.
    ExecuteCommandConfiguration -> Maybe ExecuteCommandLogConfiguration
logConfiguration :: Prelude.Maybe ExecuteCommandLogConfiguration,
    -- | The log setting to use for redirecting logs for your execute command
    -- results. The following log settings are available.
    --
    -- -   @NONE@: The execute command session is not logged.
    --
    -- -   @DEFAULT@: The @awslogs@ configuration in the task definition is
    --     used. If no logging parameter is specified, it defaults to this
    --     value. If no @awslogs@ log driver is configured in the task
    --     definition, the output won\'t be logged.
    --
    -- -   @OVERRIDE@: Specify the logging details as a part of
    --     @logConfiguration@. If the @OVERRIDE@ logging option is specified,
    --     the @logConfiguration@ is required.
    ExecuteCommandConfiguration -> Maybe ExecuteCommandLogging
logging :: Prelude.Maybe ExecuteCommandLogging
  }
  deriving (ExecuteCommandConfiguration -> ExecuteCommandConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecuteCommandConfiguration -> ExecuteCommandConfiguration -> Bool
$c/= :: ExecuteCommandConfiguration -> ExecuteCommandConfiguration -> Bool
== :: ExecuteCommandConfiguration -> ExecuteCommandConfiguration -> Bool
$c== :: ExecuteCommandConfiguration -> ExecuteCommandConfiguration -> Bool
Prelude.Eq, ReadPrec [ExecuteCommandConfiguration]
ReadPrec ExecuteCommandConfiguration
Int -> ReadS ExecuteCommandConfiguration
ReadS [ExecuteCommandConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecuteCommandConfiguration]
$creadListPrec :: ReadPrec [ExecuteCommandConfiguration]
readPrec :: ReadPrec ExecuteCommandConfiguration
$creadPrec :: ReadPrec ExecuteCommandConfiguration
readList :: ReadS [ExecuteCommandConfiguration]
$creadList :: ReadS [ExecuteCommandConfiguration]
readsPrec :: Int -> ReadS ExecuteCommandConfiguration
$creadsPrec :: Int -> ReadS ExecuteCommandConfiguration
Prelude.Read, Int -> ExecuteCommandConfiguration -> ShowS
[ExecuteCommandConfiguration] -> ShowS
ExecuteCommandConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecuteCommandConfiguration] -> ShowS
$cshowList :: [ExecuteCommandConfiguration] -> ShowS
show :: ExecuteCommandConfiguration -> String
$cshow :: ExecuteCommandConfiguration -> String
showsPrec :: Int -> ExecuteCommandConfiguration -> ShowS
$cshowsPrec :: Int -> ExecuteCommandConfiguration -> ShowS
Prelude.Show, forall x.
Rep ExecuteCommandConfiguration x -> ExecuteCommandConfiguration
forall x.
ExecuteCommandConfiguration -> Rep ExecuteCommandConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ExecuteCommandConfiguration x -> ExecuteCommandConfiguration
$cfrom :: forall x.
ExecuteCommandConfiguration -> Rep ExecuteCommandConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ExecuteCommandConfiguration' 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:
--
-- 'kmsKeyId', 'executeCommandConfiguration_kmsKeyId' - Specify an Key Management Service key ID to encrypt the data between the
-- local client and the container.
--
-- 'logConfiguration', 'executeCommandConfiguration_logConfiguration' - The log configuration for the results of the execute command actions.
-- The logs can be sent to CloudWatch Logs or an Amazon S3 bucket. When
-- @logging=OVERRIDE@ is specified, a @logConfiguration@ must be provided.
--
-- 'logging', 'executeCommandConfiguration_logging' - The log setting to use for redirecting logs for your execute command
-- results. The following log settings are available.
--
-- -   @NONE@: The execute command session is not logged.
--
-- -   @DEFAULT@: The @awslogs@ configuration in the task definition is
--     used. If no logging parameter is specified, it defaults to this
--     value. If no @awslogs@ log driver is configured in the task
--     definition, the output won\'t be logged.
--
-- -   @OVERRIDE@: Specify the logging details as a part of
--     @logConfiguration@. If the @OVERRIDE@ logging option is specified,
--     the @logConfiguration@ is required.
newExecuteCommandConfiguration ::
  ExecuteCommandConfiguration
newExecuteCommandConfiguration :: ExecuteCommandConfiguration
newExecuteCommandConfiguration =
  ExecuteCommandConfiguration'
    { $sel:kmsKeyId:ExecuteCommandConfiguration' :: Maybe Text
kmsKeyId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:logConfiguration:ExecuteCommandConfiguration' :: Maybe ExecuteCommandLogConfiguration
logConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:logging:ExecuteCommandConfiguration' :: Maybe ExecuteCommandLogging
logging = forall a. Maybe a
Prelude.Nothing
    }

-- | Specify an Key Management Service key ID to encrypt the data between the
-- local client and the container.
executeCommandConfiguration_kmsKeyId :: Lens.Lens' ExecuteCommandConfiguration (Prelude.Maybe Prelude.Text)
executeCommandConfiguration_kmsKeyId :: Lens' ExecuteCommandConfiguration (Maybe Text)
executeCommandConfiguration_kmsKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteCommandConfiguration' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:ExecuteCommandConfiguration' :: ExecuteCommandConfiguration -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: ExecuteCommandConfiguration
s@ExecuteCommandConfiguration' {} Maybe Text
a -> ExecuteCommandConfiguration
s {$sel:kmsKeyId:ExecuteCommandConfiguration' :: Maybe Text
kmsKeyId = Maybe Text
a} :: ExecuteCommandConfiguration)

-- | The log configuration for the results of the execute command actions.
-- The logs can be sent to CloudWatch Logs or an Amazon S3 bucket. When
-- @logging=OVERRIDE@ is specified, a @logConfiguration@ must be provided.
executeCommandConfiguration_logConfiguration :: Lens.Lens' ExecuteCommandConfiguration (Prelude.Maybe ExecuteCommandLogConfiguration)
executeCommandConfiguration_logConfiguration :: Lens'
  ExecuteCommandConfiguration (Maybe ExecuteCommandLogConfiguration)
executeCommandConfiguration_logConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteCommandConfiguration' {Maybe ExecuteCommandLogConfiguration
logConfiguration :: Maybe ExecuteCommandLogConfiguration
$sel:logConfiguration:ExecuteCommandConfiguration' :: ExecuteCommandConfiguration -> Maybe ExecuteCommandLogConfiguration
logConfiguration} -> Maybe ExecuteCommandLogConfiguration
logConfiguration) (\s :: ExecuteCommandConfiguration
s@ExecuteCommandConfiguration' {} Maybe ExecuteCommandLogConfiguration
a -> ExecuteCommandConfiguration
s {$sel:logConfiguration:ExecuteCommandConfiguration' :: Maybe ExecuteCommandLogConfiguration
logConfiguration = Maybe ExecuteCommandLogConfiguration
a} :: ExecuteCommandConfiguration)

-- | The log setting to use for redirecting logs for your execute command
-- results. The following log settings are available.
--
-- -   @NONE@: The execute command session is not logged.
--
-- -   @DEFAULT@: The @awslogs@ configuration in the task definition is
--     used. If no logging parameter is specified, it defaults to this
--     value. If no @awslogs@ log driver is configured in the task
--     definition, the output won\'t be logged.
--
-- -   @OVERRIDE@: Specify the logging details as a part of
--     @logConfiguration@. If the @OVERRIDE@ logging option is specified,
--     the @logConfiguration@ is required.
executeCommandConfiguration_logging :: Lens.Lens' ExecuteCommandConfiguration (Prelude.Maybe ExecuteCommandLogging)
executeCommandConfiguration_logging :: Lens' ExecuteCommandConfiguration (Maybe ExecuteCommandLogging)
executeCommandConfiguration_logging = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecuteCommandConfiguration' {Maybe ExecuteCommandLogging
logging :: Maybe ExecuteCommandLogging
$sel:logging:ExecuteCommandConfiguration' :: ExecuteCommandConfiguration -> Maybe ExecuteCommandLogging
logging} -> Maybe ExecuteCommandLogging
logging) (\s :: ExecuteCommandConfiguration
s@ExecuteCommandConfiguration' {} Maybe ExecuteCommandLogging
a -> ExecuteCommandConfiguration
s {$sel:logging:ExecuteCommandConfiguration' :: Maybe ExecuteCommandLogging
logging = Maybe ExecuteCommandLogging
a} :: ExecuteCommandConfiguration)

instance Data.FromJSON ExecuteCommandConfiguration where
  parseJSON :: Value -> Parser ExecuteCommandConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ExecuteCommandConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe ExecuteCommandLogConfiguration
-> Maybe ExecuteCommandLogging
-> ExecuteCommandConfiguration
ExecuteCommandConfiguration'
            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
"kmsKeyId")
            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
"logConfiguration")
            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
"logging")
      )

instance Prelude.Hashable ExecuteCommandConfiguration where
  hashWithSalt :: Int -> ExecuteCommandConfiguration -> Int
hashWithSalt Int
_salt ExecuteCommandConfiguration' {Maybe Text
Maybe ExecuteCommandLogConfiguration
Maybe ExecuteCommandLogging
logging :: Maybe ExecuteCommandLogging
logConfiguration :: Maybe ExecuteCommandLogConfiguration
kmsKeyId :: Maybe Text
$sel:logging:ExecuteCommandConfiguration' :: ExecuteCommandConfiguration -> Maybe ExecuteCommandLogging
$sel:logConfiguration:ExecuteCommandConfiguration' :: ExecuteCommandConfiguration -> Maybe ExecuteCommandLogConfiguration
$sel:kmsKeyId:ExecuteCommandConfiguration' :: ExecuteCommandConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ExecuteCommandLogConfiguration
logConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ExecuteCommandLogging
logging

instance Prelude.NFData ExecuteCommandConfiguration where
  rnf :: ExecuteCommandConfiguration -> ()
rnf ExecuteCommandConfiguration' {Maybe Text
Maybe ExecuteCommandLogConfiguration
Maybe ExecuteCommandLogging
logging :: Maybe ExecuteCommandLogging
logConfiguration :: Maybe ExecuteCommandLogConfiguration
kmsKeyId :: Maybe Text
$sel:logging:ExecuteCommandConfiguration' :: ExecuteCommandConfiguration -> Maybe ExecuteCommandLogging
$sel:logConfiguration:ExecuteCommandConfiguration' :: ExecuteCommandConfiguration -> Maybe ExecuteCommandLogConfiguration
$sel:kmsKeyId:ExecuteCommandConfiguration' :: ExecuteCommandConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ExecuteCommandLogConfiguration
logConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ExecuteCommandLogging
logging

instance Data.ToJSON ExecuteCommandConfiguration where
  toJSON :: ExecuteCommandConfiguration -> Value
toJSON ExecuteCommandConfiguration' {Maybe Text
Maybe ExecuteCommandLogConfiguration
Maybe ExecuteCommandLogging
logging :: Maybe ExecuteCommandLogging
logConfiguration :: Maybe ExecuteCommandLogConfiguration
kmsKeyId :: Maybe Text
$sel:logging:ExecuteCommandConfiguration' :: ExecuteCommandConfiguration -> Maybe ExecuteCommandLogging
$sel:logConfiguration:ExecuteCommandConfiguration' :: ExecuteCommandConfiguration -> Maybe ExecuteCommandLogConfiguration
$sel:kmsKeyId:ExecuteCommandConfiguration' :: ExecuteCommandConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"kmsKeyId" 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
kmsKeyId,
            (Key
"logConfiguration" 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 ExecuteCommandLogConfiguration
logConfiguration,
            (Key
"logging" 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 ExecuteCommandLogging
logging
          ]
      )