{-# 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.Proton.Types.S3ObjectSource
-- 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.Proton.Types.S3ObjectSource where

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

-- | Template bundle S3 bucket data.
--
-- /See:/ 'newS3ObjectSource' smart constructor.
data S3ObjectSource = S3ObjectSource'
  { -- | The name of the S3 bucket that contains a template bundle.
    S3ObjectSource -> Text
bucket :: Prelude.Text,
    -- | The path to the S3 bucket that contains a template bundle.
    S3ObjectSource -> Text
key :: Prelude.Text
  }
  deriving (S3ObjectSource -> S3ObjectSource -> Bool
(S3ObjectSource -> S3ObjectSource -> Bool)
-> (S3ObjectSource -> S3ObjectSource -> Bool) -> Eq S3ObjectSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3ObjectSource -> S3ObjectSource -> Bool
$c/= :: S3ObjectSource -> S3ObjectSource -> Bool
== :: S3ObjectSource -> S3ObjectSource -> Bool
$c== :: S3ObjectSource -> S3ObjectSource -> Bool
Prelude.Eq, ReadPrec [S3ObjectSource]
ReadPrec S3ObjectSource
Int -> ReadS S3ObjectSource
ReadS [S3ObjectSource]
(Int -> ReadS S3ObjectSource)
-> ReadS [S3ObjectSource]
-> ReadPrec S3ObjectSource
-> ReadPrec [S3ObjectSource]
-> Read S3ObjectSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3ObjectSource]
$creadListPrec :: ReadPrec [S3ObjectSource]
readPrec :: ReadPrec S3ObjectSource
$creadPrec :: ReadPrec S3ObjectSource
readList :: ReadS [S3ObjectSource]
$creadList :: ReadS [S3ObjectSource]
readsPrec :: Int -> ReadS S3ObjectSource
$creadsPrec :: Int -> ReadS S3ObjectSource
Prelude.Read, Int -> S3ObjectSource -> ShowS
[S3ObjectSource] -> ShowS
S3ObjectSource -> String
(Int -> S3ObjectSource -> ShowS)
-> (S3ObjectSource -> String)
-> ([S3ObjectSource] -> ShowS)
-> Show S3ObjectSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3ObjectSource] -> ShowS
$cshowList :: [S3ObjectSource] -> ShowS
show :: S3ObjectSource -> String
$cshow :: S3ObjectSource -> String
showsPrec :: Int -> S3ObjectSource -> ShowS
$cshowsPrec :: Int -> S3ObjectSource -> ShowS
Prelude.Show, (forall x. S3ObjectSource -> Rep S3ObjectSource x)
-> (forall x. Rep S3ObjectSource x -> S3ObjectSource)
-> Generic S3ObjectSource
forall x. Rep S3ObjectSource x -> S3ObjectSource
forall x. S3ObjectSource -> Rep S3ObjectSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3ObjectSource x -> S3ObjectSource
$cfrom :: forall x. S3ObjectSource -> Rep S3ObjectSource x
Prelude.Generic)

-- |
-- Create a value of 'S3ObjectSource' 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:
--
-- 'bucket', 's3ObjectSource_bucket' - The name of the S3 bucket that contains a template bundle.
--
-- 'key', 's3ObjectSource_key' - The path to the S3 bucket that contains a template bundle.
newS3ObjectSource ::
  -- | 'bucket'
  Prelude.Text ->
  -- | 'key'
  Prelude.Text ->
  S3ObjectSource
newS3ObjectSource :: Text -> Text -> S3ObjectSource
newS3ObjectSource Text
pBucket_ Text
pKey_ =
  S3ObjectSource' :: Text -> Text -> S3ObjectSource
S3ObjectSource' {$sel:bucket:S3ObjectSource' :: Text
bucket = Text
pBucket_, $sel:key:S3ObjectSource' :: Text
key = Text
pKey_}

-- | The name of the S3 bucket that contains a template bundle.
s3ObjectSource_bucket :: Lens.Lens' S3ObjectSource Prelude.Text
s3ObjectSource_bucket :: (Text -> f Text) -> S3ObjectSource -> f S3ObjectSource
s3ObjectSource_bucket = (S3ObjectSource -> Text)
-> (S3ObjectSource -> Text -> S3ObjectSource)
-> Lens S3ObjectSource S3ObjectSource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ObjectSource' {Text
bucket :: Text
$sel:bucket:S3ObjectSource' :: S3ObjectSource -> Text
bucket} -> Text
bucket) (\s :: S3ObjectSource
s@S3ObjectSource' {} Text
a -> S3ObjectSource
s {$sel:bucket:S3ObjectSource' :: Text
bucket = Text
a} :: S3ObjectSource)

-- | The path to the S3 bucket that contains a template bundle.
s3ObjectSource_key :: Lens.Lens' S3ObjectSource Prelude.Text
s3ObjectSource_key :: (Text -> f Text) -> S3ObjectSource -> f S3ObjectSource
s3ObjectSource_key = (S3ObjectSource -> Text)
-> (S3ObjectSource -> Text -> S3ObjectSource)
-> Lens S3ObjectSource S3ObjectSource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ObjectSource' {Text
key :: Text
$sel:key:S3ObjectSource' :: S3ObjectSource -> Text
key} -> Text
key) (\s :: S3ObjectSource
s@S3ObjectSource' {} Text
a -> S3ObjectSource
s {$sel:key:S3ObjectSource' :: Text
key = Text
a} :: S3ObjectSource)

instance Prelude.Hashable S3ObjectSource

instance Prelude.NFData S3ObjectSource

instance Core.ToJSON S3ObjectSource where
  toJSON :: S3ObjectSource -> Value
toJSON S3ObjectSource' {Text
key :: Text
bucket :: Text
$sel:key:S3ObjectSource' :: S3ObjectSource -> Text
$sel:bucket:S3ObjectSource' :: S3ObjectSource -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"bucket" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
bucket),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
key)
          ]
      )