{-# 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.WorkMailMessageFlow.Types.S3Reference
-- 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.WorkMailMessageFlow.Types.S3Reference where

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

-- | Amazon S3 object representing the updated message content, in MIME
-- format.
--
-- The region for the S3 bucket containing the S3 object must match the
-- region used for WorkMail operations. Also, for WorkMail to process an S3
-- object, it must have permission to access that object. For more
-- information, see
-- <https://docs.aws.amazon.com/workmail/latest/adminguide/update-with-lambda.html Updating message content with AWS Lambda>.
--
-- /See:/ 'newS3Reference' smart constructor.
data S3Reference = S3Reference'
  { -- | If you enable versioning for the bucket, you can specify the object
    -- version.
    S3Reference -> Maybe Text
objectVersion :: Prelude.Maybe Prelude.Text,
    -- | The S3 bucket name.
    S3Reference -> Text
bucket :: Prelude.Text,
    -- | The S3 key object name.
    S3Reference -> Text
key :: Prelude.Text
  }
  deriving (S3Reference -> S3Reference -> Bool
(S3Reference -> S3Reference -> Bool)
-> (S3Reference -> S3Reference -> Bool) -> Eq S3Reference
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Reference -> S3Reference -> Bool
$c/= :: S3Reference -> S3Reference -> Bool
== :: S3Reference -> S3Reference -> Bool
$c== :: S3Reference -> S3Reference -> Bool
Prelude.Eq, ReadPrec [S3Reference]
ReadPrec S3Reference
Int -> ReadS S3Reference
ReadS [S3Reference]
(Int -> ReadS S3Reference)
-> ReadS [S3Reference]
-> ReadPrec S3Reference
-> ReadPrec [S3Reference]
-> Read S3Reference
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Reference]
$creadListPrec :: ReadPrec [S3Reference]
readPrec :: ReadPrec S3Reference
$creadPrec :: ReadPrec S3Reference
readList :: ReadS [S3Reference]
$creadList :: ReadS [S3Reference]
readsPrec :: Int -> ReadS S3Reference
$creadsPrec :: Int -> ReadS S3Reference
Prelude.Read, Int -> S3Reference -> ShowS
[S3Reference] -> ShowS
S3Reference -> String
(Int -> S3Reference -> ShowS)
-> (S3Reference -> String)
-> ([S3Reference] -> ShowS)
-> Show S3Reference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Reference] -> ShowS
$cshowList :: [S3Reference] -> ShowS
show :: S3Reference -> String
$cshow :: S3Reference -> String
showsPrec :: Int -> S3Reference -> ShowS
$cshowsPrec :: Int -> S3Reference -> ShowS
Prelude.Show, (forall x. S3Reference -> Rep S3Reference x)
-> (forall x. Rep S3Reference x -> S3Reference)
-> Generic S3Reference
forall x. Rep S3Reference x -> S3Reference
forall x. S3Reference -> Rep S3Reference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Reference x -> S3Reference
$cfrom :: forall x. S3Reference -> Rep S3Reference x
Prelude.Generic)

-- |
-- Create a value of 'S3Reference' 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:
--
-- 'objectVersion', 's3Reference_objectVersion' - If you enable versioning for the bucket, you can specify the object
-- version.
--
-- 'bucket', 's3Reference_bucket' - The S3 bucket name.
--
-- 'key', 's3Reference_key' - The S3 key object name.
newS3Reference ::
  -- | 'bucket'
  Prelude.Text ->
  -- | 'key'
  Prelude.Text ->
  S3Reference
newS3Reference :: Text -> Text -> S3Reference
newS3Reference Text
pBucket_ Text
pKey_ =
  S3Reference' :: Maybe Text -> Text -> Text -> S3Reference
S3Reference'
    { $sel:objectVersion:S3Reference' :: Maybe Text
objectVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:S3Reference' :: Text
bucket = Text
pBucket_,
      $sel:key:S3Reference' :: Text
key = Text
pKey_
    }

-- | If you enable versioning for the bucket, you can specify the object
-- version.
s3Reference_objectVersion :: Lens.Lens' S3Reference (Prelude.Maybe Prelude.Text)
s3Reference_objectVersion :: (Maybe Text -> f (Maybe Text)) -> S3Reference -> f S3Reference
s3Reference_objectVersion = (S3Reference -> Maybe Text)
-> (S3Reference -> Maybe Text -> S3Reference)
-> Lens S3Reference S3Reference (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Reference' {Maybe Text
objectVersion :: Maybe Text
$sel:objectVersion:S3Reference' :: S3Reference -> Maybe Text
objectVersion} -> Maybe Text
objectVersion) (\s :: S3Reference
s@S3Reference' {} Maybe Text
a -> S3Reference
s {$sel:objectVersion:S3Reference' :: Maybe Text
objectVersion = Maybe Text
a} :: S3Reference)

-- | The S3 bucket name.
s3Reference_bucket :: Lens.Lens' S3Reference Prelude.Text
s3Reference_bucket :: (Text -> f Text) -> S3Reference -> f S3Reference
s3Reference_bucket = (S3Reference -> Text)
-> (S3Reference -> Text -> S3Reference)
-> Lens S3Reference S3Reference Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Reference' {Text
bucket :: Text
$sel:bucket:S3Reference' :: S3Reference -> Text
bucket} -> Text
bucket) (\s :: S3Reference
s@S3Reference' {} Text
a -> S3Reference
s {$sel:bucket:S3Reference' :: Text
bucket = Text
a} :: S3Reference)

-- | The S3 key object name.
s3Reference_key :: Lens.Lens' S3Reference Prelude.Text
s3Reference_key :: (Text -> f Text) -> S3Reference -> f S3Reference
s3Reference_key = (S3Reference -> Text)
-> (S3Reference -> Text -> S3Reference)
-> Lens S3Reference S3Reference Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Reference' {Text
key :: Text
$sel:key:S3Reference' :: S3Reference -> Text
key} -> Text
key) (\s :: S3Reference
s@S3Reference' {} Text
a -> S3Reference
s {$sel:key:S3Reference' :: Text
key = Text
a} :: S3Reference)

instance Prelude.Hashable S3Reference

instance Prelude.NFData S3Reference

instance Core.ToJSON S3Reference where
  toJSON :: S3Reference -> Value
toJSON S3Reference' {Maybe Text
Text
key :: Text
bucket :: Text
objectVersion :: Maybe Text
$sel:key:S3Reference' :: S3Reference -> Text
$sel:bucket:S3Reference' :: S3Reference -> Text
$sel:objectVersion:S3Reference' :: S3Reference -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"objectVersion" 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
objectVersion,
            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)
          ]
      )