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

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

-- | An S3 bucket where you want to store the results of this request.
--
-- /See:/ 'newS3OutputLocation' smart constructor.
data S3OutputLocation = S3OutputLocation'
  { -- | The S3 bucket subfolder.
    S3OutputLocation -> Maybe Text
outputS3KeyPrefix :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services Region of the S3 bucket.
    S3OutputLocation -> Maybe Text
outputS3Region :: Prelude.Maybe Prelude.Text,
    -- | The name of the S3 bucket.
    S3OutputLocation -> Maybe Text
outputS3BucketName :: Prelude.Maybe Prelude.Text
  }
  deriving (S3OutputLocation -> S3OutputLocation -> Bool
(S3OutputLocation -> S3OutputLocation -> Bool)
-> (S3OutputLocation -> S3OutputLocation -> Bool)
-> Eq S3OutputLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3OutputLocation -> S3OutputLocation -> Bool
$c/= :: S3OutputLocation -> S3OutputLocation -> Bool
== :: S3OutputLocation -> S3OutputLocation -> Bool
$c== :: S3OutputLocation -> S3OutputLocation -> Bool
Prelude.Eq, ReadPrec [S3OutputLocation]
ReadPrec S3OutputLocation
Int -> ReadS S3OutputLocation
ReadS [S3OutputLocation]
(Int -> ReadS S3OutputLocation)
-> ReadS [S3OutputLocation]
-> ReadPrec S3OutputLocation
-> ReadPrec [S3OutputLocation]
-> Read S3OutputLocation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3OutputLocation]
$creadListPrec :: ReadPrec [S3OutputLocation]
readPrec :: ReadPrec S3OutputLocation
$creadPrec :: ReadPrec S3OutputLocation
readList :: ReadS [S3OutputLocation]
$creadList :: ReadS [S3OutputLocation]
readsPrec :: Int -> ReadS S3OutputLocation
$creadsPrec :: Int -> ReadS S3OutputLocation
Prelude.Read, Int -> S3OutputLocation -> ShowS
[S3OutputLocation] -> ShowS
S3OutputLocation -> String
(Int -> S3OutputLocation -> ShowS)
-> (S3OutputLocation -> String)
-> ([S3OutputLocation] -> ShowS)
-> Show S3OutputLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3OutputLocation] -> ShowS
$cshowList :: [S3OutputLocation] -> ShowS
show :: S3OutputLocation -> String
$cshow :: S3OutputLocation -> String
showsPrec :: Int -> S3OutputLocation -> ShowS
$cshowsPrec :: Int -> S3OutputLocation -> ShowS
Prelude.Show, (forall x. S3OutputLocation -> Rep S3OutputLocation x)
-> (forall x. Rep S3OutputLocation x -> S3OutputLocation)
-> Generic S3OutputLocation
forall x. Rep S3OutputLocation x -> S3OutputLocation
forall x. S3OutputLocation -> Rep S3OutputLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3OutputLocation x -> S3OutputLocation
$cfrom :: forall x. S3OutputLocation -> Rep S3OutputLocation x
Prelude.Generic)

-- |
-- Create a value of 'S3OutputLocation' 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:
--
-- 'outputS3KeyPrefix', 's3OutputLocation_outputS3KeyPrefix' - The S3 bucket subfolder.
--
-- 'outputS3Region', 's3OutputLocation_outputS3Region' - The Amazon Web Services Region of the S3 bucket.
--
-- 'outputS3BucketName', 's3OutputLocation_outputS3BucketName' - The name of the S3 bucket.
newS3OutputLocation ::
  S3OutputLocation
newS3OutputLocation :: S3OutputLocation
newS3OutputLocation =
  S3OutputLocation' :: Maybe Text -> Maybe Text -> Maybe Text -> S3OutputLocation
S3OutputLocation'
    { $sel:outputS3KeyPrefix:S3OutputLocation' :: Maybe Text
outputS3KeyPrefix =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:outputS3Region:S3OutputLocation' :: Maybe Text
outputS3Region = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:outputS3BucketName:S3OutputLocation' :: Maybe Text
outputS3BucketName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The S3 bucket subfolder.
s3OutputLocation_outputS3KeyPrefix :: Lens.Lens' S3OutputLocation (Prelude.Maybe Prelude.Text)
s3OutputLocation_outputS3KeyPrefix :: (Maybe Text -> f (Maybe Text))
-> S3OutputLocation -> f S3OutputLocation
s3OutputLocation_outputS3KeyPrefix = (S3OutputLocation -> Maybe Text)
-> (S3OutputLocation -> Maybe Text -> S3OutputLocation)
-> Lens S3OutputLocation S3OutputLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3OutputLocation' {Maybe Text
outputS3KeyPrefix :: Maybe Text
$sel:outputS3KeyPrefix:S3OutputLocation' :: S3OutputLocation -> Maybe Text
outputS3KeyPrefix} -> Maybe Text
outputS3KeyPrefix) (\s :: S3OutputLocation
s@S3OutputLocation' {} Maybe Text
a -> S3OutputLocation
s {$sel:outputS3KeyPrefix:S3OutputLocation' :: Maybe Text
outputS3KeyPrefix = Maybe Text
a} :: S3OutputLocation)

-- | The Amazon Web Services Region of the S3 bucket.
s3OutputLocation_outputS3Region :: Lens.Lens' S3OutputLocation (Prelude.Maybe Prelude.Text)
s3OutputLocation_outputS3Region :: (Maybe Text -> f (Maybe Text))
-> S3OutputLocation -> f S3OutputLocation
s3OutputLocation_outputS3Region = (S3OutputLocation -> Maybe Text)
-> (S3OutputLocation -> Maybe Text -> S3OutputLocation)
-> Lens S3OutputLocation S3OutputLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3OutputLocation' {Maybe Text
outputS3Region :: Maybe Text
$sel:outputS3Region:S3OutputLocation' :: S3OutputLocation -> Maybe Text
outputS3Region} -> Maybe Text
outputS3Region) (\s :: S3OutputLocation
s@S3OutputLocation' {} Maybe Text
a -> S3OutputLocation
s {$sel:outputS3Region:S3OutputLocation' :: Maybe Text
outputS3Region = Maybe Text
a} :: S3OutputLocation)

-- | The name of the S3 bucket.
s3OutputLocation_outputS3BucketName :: Lens.Lens' S3OutputLocation (Prelude.Maybe Prelude.Text)
s3OutputLocation_outputS3BucketName :: (Maybe Text -> f (Maybe Text))
-> S3OutputLocation -> f S3OutputLocation
s3OutputLocation_outputS3BucketName = (S3OutputLocation -> Maybe Text)
-> (S3OutputLocation -> Maybe Text -> S3OutputLocation)
-> Lens S3OutputLocation S3OutputLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3OutputLocation' {Maybe Text
outputS3BucketName :: Maybe Text
$sel:outputS3BucketName:S3OutputLocation' :: S3OutputLocation -> Maybe Text
outputS3BucketName} -> Maybe Text
outputS3BucketName) (\s :: S3OutputLocation
s@S3OutputLocation' {} Maybe Text
a -> S3OutputLocation
s {$sel:outputS3BucketName:S3OutputLocation' :: Maybe Text
outputS3BucketName = Maybe Text
a} :: S3OutputLocation)

instance Core.FromJSON S3OutputLocation where
  parseJSON :: Value -> Parser S3OutputLocation
parseJSON =
    String
-> (Object -> Parser S3OutputLocation)
-> Value
-> Parser S3OutputLocation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3OutputLocation"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> S3OutputLocation
S3OutputLocation'
            (Maybe Text -> Maybe Text -> Maybe Text -> S3OutputLocation)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> S3OutputLocation)
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
"OutputS3KeyPrefix")
            Parser (Maybe Text -> Maybe Text -> S3OutputLocation)
-> Parser (Maybe Text) -> Parser (Maybe Text -> S3OutputLocation)
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
"OutputS3Region")
            Parser (Maybe Text -> S3OutputLocation)
-> Parser (Maybe Text) -> Parser S3OutputLocation
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
"OutputS3BucketName")
      )

instance Prelude.Hashable S3OutputLocation

instance Prelude.NFData S3OutputLocation

instance Core.ToJSON S3OutputLocation where
  toJSON :: S3OutputLocation -> Value
toJSON S3OutputLocation' {Maybe Text
outputS3BucketName :: Maybe Text
outputS3Region :: Maybe Text
outputS3KeyPrefix :: Maybe Text
$sel:outputS3BucketName:S3OutputLocation' :: S3OutputLocation -> Maybe Text
$sel:outputS3Region:S3OutputLocation' :: S3OutputLocation -> Maybe Text
$sel:outputS3KeyPrefix:S3OutputLocation' :: S3OutputLocation -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"OutputS3KeyPrefix" 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
outputS3KeyPrefix,
            (Text
"OutputS3Region" 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
outputS3Region,
            (Text
"OutputS3BucketName" 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
outputS3BucketName
          ]
      )