{-# 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.SSM.Types.LoggingInfo
-- 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.SSM.Types.LoggingInfo 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

-- | Information about an Amazon Simple Storage Service (Amazon S3) bucket to
-- write managed node-level logs to.
--
-- @LoggingInfo@ has been deprecated. To specify an Amazon Simple Storage
-- Service (Amazon S3) bucket to contain logs, instead use the
-- @OutputS3BucketName@ and @OutputS3KeyPrefix@ options in the
-- @TaskInvocationParameters@ structure. For information about how Amazon
-- Web Services Systems Manager handles these options for the supported
-- maintenance window task types, see
-- MaintenanceWindowTaskInvocationParameters.
--
-- /See:/ 'newLoggingInfo' smart constructor.
data LoggingInfo = LoggingInfo'
  { -- | (Optional) The S3 bucket subfolder.
    LoggingInfo -> Maybe Text
s3KeyPrefix :: Prelude.Maybe Prelude.Text,
    -- | The name of an S3 bucket where execution logs are stored.
    LoggingInfo -> Text
s3BucketName :: Prelude.Text,
    -- | The Amazon Web Services Region where the S3 bucket is located.
    LoggingInfo -> Text
s3Region :: Prelude.Text
  }
  deriving (LoggingInfo -> LoggingInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoggingInfo -> LoggingInfo -> Bool
$c/= :: LoggingInfo -> LoggingInfo -> Bool
== :: LoggingInfo -> LoggingInfo -> Bool
$c== :: LoggingInfo -> LoggingInfo -> Bool
Prelude.Eq, ReadPrec [LoggingInfo]
ReadPrec LoggingInfo
Int -> ReadS LoggingInfo
ReadS [LoggingInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LoggingInfo]
$creadListPrec :: ReadPrec [LoggingInfo]
readPrec :: ReadPrec LoggingInfo
$creadPrec :: ReadPrec LoggingInfo
readList :: ReadS [LoggingInfo]
$creadList :: ReadS [LoggingInfo]
readsPrec :: Int -> ReadS LoggingInfo
$creadsPrec :: Int -> ReadS LoggingInfo
Prelude.Read, Int -> LoggingInfo -> ShowS
[LoggingInfo] -> ShowS
LoggingInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoggingInfo] -> ShowS
$cshowList :: [LoggingInfo] -> ShowS
show :: LoggingInfo -> String
$cshow :: LoggingInfo -> String
showsPrec :: Int -> LoggingInfo -> ShowS
$cshowsPrec :: Int -> LoggingInfo -> ShowS
Prelude.Show, forall x. Rep LoggingInfo x -> LoggingInfo
forall x. LoggingInfo -> Rep LoggingInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoggingInfo x -> LoggingInfo
$cfrom :: forall x. LoggingInfo -> Rep LoggingInfo x
Prelude.Generic)

-- |
-- Create a value of 'LoggingInfo' 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:
--
-- 's3KeyPrefix', 'loggingInfo_s3KeyPrefix' - (Optional) The S3 bucket subfolder.
--
-- 's3BucketName', 'loggingInfo_s3BucketName' - The name of an S3 bucket where execution logs are stored.
--
-- 's3Region', 'loggingInfo_s3Region' - The Amazon Web Services Region where the S3 bucket is located.
newLoggingInfo ::
  -- | 's3BucketName'
  Prelude.Text ->
  -- | 's3Region'
  Prelude.Text ->
  LoggingInfo
newLoggingInfo :: Text -> Text -> LoggingInfo
newLoggingInfo Text
pS3BucketName_ Text
pS3Region_ =
  LoggingInfo'
    { $sel:s3KeyPrefix:LoggingInfo' :: Maybe Text
s3KeyPrefix = forall a. Maybe a
Prelude.Nothing,
      $sel:s3BucketName:LoggingInfo' :: Text
s3BucketName = Text
pS3BucketName_,
      $sel:s3Region:LoggingInfo' :: Text
s3Region = Text
pS3Region_
    }

-- | (Optional) The S3 bucket subfolder.
loggingInfo_s3KeyPrefix :: Lens.Lens' LoggingInfo (Prelude.Maybe Prelude.Text)
loggingInfo_s3KeyPrefix :: Lens' LoggingInfo (Maybe Text)
loggingInfo_s3KeyPrefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingInfo' {Maybe Text
s3KeyPrefix :: Maybe Text
$sel:s3KeyPrefix:LoggingInfo' :: LoggingInfo -> Maybe Text
s3KeyPrefix} -> Maybe Text
s3KeyPrefix) (\s :: LoggingInfo
s@LoggingInfo' {} Maybe Text
a -> LoggingInfo
s {$sel:s3KeyPrefix:LoggingInfo' :: Maybe Text
s3KeyPrefix = Maybe Text
a} :: LoggingInfo)

-- | The name of an S3 bucket where execution logs are stored.
loggingInfo_s3BucketName :: Lens.Lens' LoggingInfo Prelude.Text
loggingInfo_s3BucketName :: Lens' LoggingInfo Text
loggingInfo_s3BucketName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingInfo' {Text
s3BucketName :: Text
$sel:s3BucketName:LoggingInfo' :: LoggingInfo -> Text
s3BucketName} -> Text
s3BucketName) (\s :: LoggingInfo
s@LoggingInfo' {} Text
a -> LoggingInfo
s {$sel:s3BucketName:LoggingInfo' :: Text
s3BucketName = Text
a} :: LoggingInfo)

-- | The Amazon Web Services Region where the S3 bucket is located.
loggingInfo_s3Region :: Lens.Lens' LoggingInfo Prelude.Text
loggingInfo_s3Region :: Lens' LoggingInfo Text
loggingInfo_s3Region = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingInfo' {Text
s3Region :: Text
$sel:s3Region:LoggingInfo' :: LoggingInfo -> Text
s3Region} -> Text
s3Region) (\s :: LoggingInfo
s@LoggingInfo' {} Text
a -> LoggingInfo
s {$sel:s3Region:LoggingInfo' :: Text
s3Region = Text
a} :: LoggingInfo)

instance Data.FromJSON LoggingInfo where
  parseJSON :: Value -> Parser LoggingInfo
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LoggingInfo"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> LoggingInfo
LoggingInfo'
            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
"S3KeyPrefix")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser 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 a
Data..: Key
"S3Region")
      )

instance Prelude.Hashable LoggingInfo where
  hashWithSalt :: Int -> LoggingInfo -> Int
hashWithSalt Int
_salt LoggingInfo' {Maybe Text
Text
s3Region :: Text
s3BucketName :: Text
s3KeyPrefix :: Maybe Text
$sel:s3Region:LoggingInfo' :: LoggingInfo -> Text
$sel:s3BucketName:LoggingInfo' :: LoggingInfo -> Text
$sel:s3KeyPrefix:LoggingInfo' :: LoggingInfo -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
s3KeyPrefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3BucketName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3Region

instance Prelude.NFData LoggingInfo where
  rnf :: LoggingInfo -> ()
rnf LoggingInfo' {Maybe Text
Text
s3Region :: Text
s3BucketName :: Text
s3KeyPrefix :: Maybe Text
$sel:s3Region:LoggingInfo' :: LoggingInfo -> Text
$sel:s3BucketName:LoggingInfo' :: LoggingInfo -> Text
$sel:s3KeyPrefix:LoggingInfo' :: LoggingInfo -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
s3KeyPrefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
s3BucketName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
s3Region

instance Data.ToJSON LoggingInfo where
  toJSON :: LoggingInfo -> Value
toJSON LoggingInfo' {Maybe Text
Text
s3Region :: Text
s3BucketName :: Text
s3KeyPrefix :: Maybe Text
$sel:s3Region:LoggingInfo' :: LoggingInfo -> Text
$sel:s3BucketName:LoggingInfo' :: LoggingInfo -> Text
$sel:s3KeyPrefix:LoggingInfo' :: LoggingInfo -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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,
            forall a. a -> Maybe a
Prelude.Just (Key
"S3BucketName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3BucketName),
            forall a. a -> Maybe a
Prelude.Just (Key
"S3Region" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3Region)
          ]
      )