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

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

-- | Information about an Amazon Simple Storage Service (Amazon S3) bucket to
-- write instance-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
(LoggingInfo -> LoggingInfo -> Bool)
-> (LoggingInfo -> LoggingInfo -> Bool) -> Eq LoggingInfo
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]
(Int -> ReadS LoggingInfo)
-> ReadS [LoggingInfo]
-> ReadPrec LoggingInfo
-> ReadPrec [LoggingInfo]
-> Read 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
(Int -> LoggingInfo -> ShowS)
-> (LoggingInfo -> String)
-> ([LoggingInfo] -> ShowS)
-> Show LoggingInfo
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. LoggingInfo -> Rep LoggingInfo x)
-> (forall x. Rep LoggingInfo x -> LoggingInfo)
-> Generic LoggingInfo
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' :: Maybe Text -> Text -> Text -> LoggingInfo
LoggingInfo'
    { $sel:s3KeyPrefix:LoggingInfo' :: Maybe Text
s3KeyPrefix = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> LoggingInfo -> f LoggingInfo
loggingInfo_s3KeyPrefix = (LoggingInfo -> Maybe Text)
-> (LoggingInfo -> Maybe Text -> LoggingInfo)
-> Lens LoggingInfo LoggingInfo (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> LoggingInfo -> f LoggingInfo
loggingInfo_s3BucketName = (LoggingInfo -> Text)
-> (LoggingInfo -> Text -> LoggingInfo)
-> Lens LoggingInfo LoggingInfo Text Text
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 :: (Text -> f Text) -> LoggingInfo -> f LoggingInfo
loggingInfo_s3Region = (LoggingInfo -> Text)
-> (LoggingInfo -> Text -> LoggingInfo)
-> Lens LoggingInfo LoggingInfo Text Text
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 Core.FromJSON LoggingInfo where
  parseJSON :: Value -> Parser LoggingInfo
parseJSON =
    String
-> (Object -> Parser LoggingInfo) -> Value -> Parser LoggingInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LoggingInfo"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> LoggingInfo
LoggingInfo'
            (Maybe Text -> Text -> Text -> LoggingInfo)
-> Parser (Maybe Text) -> Parser (Text -> Text -> LoggingInfo)
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
"S3KeyPrefix")
            Parser (Text -> Text -> LoggingInfo)
-> Parser Text -> Parser (Text -> LoggingInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"S3BucketName")
            Parser (Text -> LoggingInfo) -> Parser Text -> Parser LoggingInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"S3Region")
      )

instance Prelude.Hashable LoggingInfo

instance Prelude.NFData LoggingInfo

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"S3BucketName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
s3BucketName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"S3Region" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
s3Region)
          ]
      )