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

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

-- | The details of the execute command configuration.
--
-- /See:/ 'newExecuteCommandConfiguration' smart constructor.
data ExecuteCommandConfiguration = 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 -> Maybe ExecuteCommandLogConfiguration
logConfiguration :: Prelude.Maybe ExecuteCommandLogConfiguration,
    -- | 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 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
(ExecuteCommandConfiguration
 -> ExecuteCommandConfiguration -> Bool)
-> (ExecuteCommandConfiguration
    -> ExecuteCommandConfiguration -> Bool)
-> Eq ExecuteCommandConfiguration
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]
(Int -> ReadS ExecuteCommandConfiguration)
-> ReadS [ExecuteCommandConfiguration]
-> ReadPrec ExecuteCommandConfiguration
-> ReadPrec [ExecuteCommandConfiguration]
-> Read 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
(Int -> ExecuteCommandConfiguration -> ShowS)
-> (ExecuteCommandConfiguration -> String)
-> ([ExecuteCommandConfiguration] -> ShowS)
-> Show ExecuteCommandConfiguration
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.
 ExecuteCommandConfiguration -> Rep ExecuteCommandConfiguration x)
-> (forall x.
    Rep ExecuteCommandConfiguration x -> ExecuteCommandConfiguration)
-> Generic ExecuteCommandConfiguration
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:
--
-- '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.
--
-- 'kmsKeyId', 'executeCommandConfiguration_kmsKeyId' - Specify an Key Management Service key ID to encrypt the data between the
-- local client and the container.
--
-- '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' :: Maybe ExecuteCommandLogConfiguration
-> Maybe Text
-> Maybe ExecuteCommandLogging
-> ExecuteCommandConfiguration
ExecuteCommandConfiguration'
    { $sel:logConfiguration:ExecuteCommandConfiguration' :: Maybe ExecuteCommandLogConfiguration
logConfiguration =
        Maybe ExecuteCommandLogConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyId:ExecuteCommandConfiguration' :: Maybe Text
kmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:logging:ExecuteCommandConfiguration' :: Maybe ExecuteCommandLogging
logging = Maybe ExecuteCommandLogging
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe ExecuteCommandLogConfiguration
 -> f (Maybe ExecuteCommandLogConfiguration))
-> ExecuteCommandConfiguration -> f ExecuteCommandConfiguration
executeCommandConfiguration_logConfiguration = (ExecuteCommandConfiguration
 -> Maybe ExecuteCommandLogConfiguration)
-> (ExecuteCommandConfiguration
    -> Maybe ExecuteCommandLogConfiguration
    -> ExecuteCommandConfiguration)
-> Lens
     ExecuteCommandConfiguration
     ExecuteCommandConfiguration
     (Maybe ExecuteCommandLogConfiguration)
     (Maybe ExecuteCommandLogConfiguration)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> ExecuteCommandConfiguration -> f ExecuteCommandConfiguration
executeCommandConfiguration_kmsKeyId = (ExecuteCommandConfiguration -> Maybe Text)
-> (ExecuteCommandConfiguration
    -> Maybe Text -> ExecuteCommandConfiguration)
-> Lens
     ExecuteCommandConfiguration
     ExecuteCommandConfiguration
     (Maybe Text)
     (Maybe Text)
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 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 :: (Maybe ExecuteCommandLogging -> f (Maybe ExecuteCommandLogging))
-> ExecuteCommandConfiguration -> f ExecuteCommandConfiguration
executeCommandConfiguration_logging = (ExecuteCommandConfiguration -> Maybe ExecuteCommandLogging)
-> (ExecuteCommandConfiguration
    -> Maybe ExecuteCommandLogging -> ExecuteCommandConfiguration)
-> Lens
     ExecuteCommandConfiguration
     ExecuteCommandConfiguration
     (Maybe ExecuteCommandLogging)
     (Maybe ExecuteCommandLogging)
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 Core.FromJSON ExecuteCommandConfiguration where
  parseJSON :: Value -> Parser ExecuteCommandConfiguration
parseJSON =
    String
-> (Object -> Parser ExecuteCommandConfiguration)
-> Value
-> Parser ExecuteCommandConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExecuteCommandConfiguration"
      ( \Object
x ->
          Maybe ExecuteCommandLogConfiguration
-> Maybe Text
-> Maybe ExecuteCommandLogging
-> ExecuteCommandConfiguration
ExecuteCommandConfiguration'
            (Maybe ExecuteCommandLogConfiguration
 -> Maybe Text
 -> Maybe ExecuteCommandLogging
 -> ExecuteCommandConfiguration)
-> Parser (Maybe ExecuteCommandLogConfiguration)
-> Parser
     (Maybe Text
      -> Maybe ExecuteCommandLogging -> ExecuteCommandConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ExecuteCommandLogConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"logConfiguration")
            Parser
  (Maybe Text
   -> Maybe ExecuteCommandLogging -> ExecuteCommandConfiguration)
-> Parser (Maybe Text)
-> Parser
     (Maybe ExecuteCommandLogging -> ExecuteCommandConfiguration)
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
"kmsKeyId")
            Parser (Maybe ExecuteCommandLogging -> ExecuteCommandConfiguration)
-> Parser (Maybe ExecuteCommandLogging)
-> Parser ExecuteCommandConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ExecuteCommandLogging)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"logging")
      )

instance Prelude.Hashable ExecuteCommandConfiguration

instance Prelude.NFData ExecuteCommandConfiguration

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