{-# 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.DataExchange.Types.AutoExportRevisionDestinationEntry
-- 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.DataExchange.Types.AutoExportRevisionDestinationEntry where

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

-- | A revision destination is the Amazon S3 bucket folder destination to
-- where the export will be sent.
--
-- /See:/ 'newAutoExportRevisionDestinationEntry' smart constructor.
data AutoExportRevisionDestinationEntry = AutoExportRevisionDestinationEntry'
  { -- | A string representing the pattern for generated names of the individual
    -- assets in the revision. For more information about key patterns, see
    -- <https://docs.aws.amazon.com/data-exchange/latest/userguide/jobs.html#revision-export-keypatterns Key patterns when exporting revisions>.
    AutoExportRevisionDestinationEntry -> Maybe Text
keyPattern :: Prelude.Maybe Prelude.Text,
    -- | The S3 bucket that is the destination for the event action.
    AutoExportRevisionDestinationEntry -> Text
bucket :: Prelude.Text
  }
  deriving (AutoExportRevisionDestinationEntry
-> AutoExportRevisionDestinationEntry -> Bool
(AutoExportRevisionDestinationEntry
 -> AutoExportRevisionDestinationEntry -> Bool)
-> (AutoExportRevisionDestinationEntry
    -> AutoExportRevisionDestinationEntry -> Bool)
-> Eq AutoExportRevisionDestinationEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoExportRevisionDestinationEntry
-> AutoExportRevisionDestinationEntry -> Bool
$c/= :: AutoExportRevisionDestinationEntry
-> AutoExportRevisionDestinationEntry -> Bool
== :: AutoExportRevisionDestinationEntry
-> AutoExportRevisionDestinationEntry -> Bool
$c== :: AutoExportRevisionDestinationEntry
-> AutoExportRevisionDestinationEntry -> Bool
Prelude.Eq, ReadPrec [AutoExportRevisionDestinationEntry]
ReadPrec AutoExportRevisionDestinationEntry
Int -> ReadS AutoExportRevisionDestinationEntry
ReadS [AutoExportRevisionDestinationEntry]
(Int -> ReadS AutoExportRevisionDestinationEntry)
-> ReadS [AutoExportRevisionDestinationEntry]
-> ReadPrec AutoExportRevisionDestinationEntry
-> ReadPrec [AutoExportRevisionDestinationEntry]
-> Read AutoExportRevisionDestinationEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoExportRevisionDestinationEntry]
$creadListPrec :: ReadPrec [AutoExportRevisionDestinationEntry]
readPrec :: ReadPrec AutoExportRevisionDestinationEntry
$creadPrec :: ReadPrec AutoExportRevisionDestinationEntry
readList :: ReadS [AutoExportRevisionDestinationEntry]
$creadList :: ReadS [AutoExportRevisionDestinationEntry]
readsPrec :: Int -> ReadS AutoExportRevisionDestinationEntry
$creadsPrec :: Int -> ReadS AutoExportRevisionDestinationEntry
Prelude.Read, Int -> AutoExportRevisionDestinationEntry -> ShowS
[AutoExportRevisionDestinationEntry] -> ShowS
AutoExportRevisionDestinationEntry -> String
(Int -> AutoExportRevisionDestinationEntry -> ShowS)
-> (AutoExportRevisionDestinationEntry -> String)
-> ([AutoExportRevisionDestinationEntry] -> ShowS)
-> Show AutoExportRevisionDestinationEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoExportRevisionDestinationEntry] -> ShowS
$cshowList :: [AutoExportRevisionDestinationEntry] -> ShowS
show :: AutoExportRevisionDestinationEntry -> String
$cshow :: AutoExportRevisionDestinationEntry -> String
showsPrec :: Int -> AutoExportRevisionDestinationEntry -> ShowS
$cshowsPrec :: Int -> AutoExportRevisionDestinationEntry -> ShowS
Prelude.Show, (forall x.
 AutoExportRevisionDestinationEntry
 -> Rep AutoExportRevisionDestinationEntry x)
-> (forall x.
    Rep AutoExportRevisionDestinationEntry x
    -> AutoExportRevisionDestinationEntry)
-> Generic AutoExportRevisionDestinationEntry
forall x.
Rep AutoExportRevisionDestinationEntry x
-> AutoExportRevisionDestinationEntry
forall x.
AutoExportRevisionDestinationEntry
-> Rep AutoExportRevisionDestinationEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AutoExportRevisionDestinationEntry x
-> AutoExportRevisionDestinationEntry
$cfrom :: forall x.
AutoExportRevisionDestinationEntry
-> Rep AutoExportRevisionDestinationEntry x
Prelude.Generic)

-- |
-- Create a value of 'AutoExportRevisionDestinationEntry' 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:
--
-- 'keyPattern', 'autoExportRevisionDestinationEntry_keyPattern' - A string representing the pattern for generated names of the individual
-- assets in the revision. For more information about key patterns, see
-- <https://docs.aws.amazon.com/data-exchange/latest/userguide/jobs.html#revision-export-keypatterns Key patterns when exporting revisions>.
--
-- 'bucket', 'autoExportRevisionDestinationEntry_bucket' - The S3 bucket that is the destination for the event action.
newAutoExportRevisionDestinationEntry ::
  -- | 'bucket'
  Prelude.Text ->
  AutoExportRevisionDestinationEntry
newAutoExportRevisionDestinationEntry :: Text -> AutoExportRevisionDestinationEntry
newAutoExportRevisionDestinationEntry Text
pBucket_ =
  AutoExportRevisionDestinationEntry' :: Maybe Text -> Text -> AutoExportRevisionDestinationEntry
AutoExportRevisionDestinationEntry'
    { $sel:keyPattern:AutoExportRevisionDestinationEntry' :: Maybe Text
keyPattern =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:AutoExportRevisionDestinationEntry' :: Text
bucket = Text
pBucket_
    }

-- | A string representing the pattern for generated names of the individual
-- assets in the revision. For more information about key patterns, see
-- <https://docs.aws.amazon.com/data-exchange/latest/userguide/jobs.html#revision-export-keypatterns Key patterns when exporting revisions>.
autoExportRevisionDestinationEntry_keyPattern :: Lens.Lens' AutoExportRevisionDestinationEntry (Prelude.Maybe Prelude.Text)
autoExportRevisionDestinationEntry_keyPattern :: (Maybe Text -> f (Maybe Text))
-> AutoExportRevisionDestinationEntry
-> f AutoExportRevisionDestinationEntry
autoExportRevisionDestinationEntry_keyPattern = (AutoExportRevisionDestinationEntry -> Maybe Text)
-> (AutoExportRevisionDestinationEntry
    -> Maybe Text -> AutoExportRevisionDestinationEntry)
-> Lens
     AutoExportRevisionDestinationEntry
     AutoExportRevisionDestinationEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoExportRevisionDestinationEntry' {Maybe Text
keyPattern :: Maybe Text
$sel:keyPattern:AutoExportRevisionDestinationEntry' :: AutoExportRevisionDestinationEntry -> Maybe Text
keyPattern} -> Maybe Text
keyPattern) (\s :: AutoExportRevisionDestinationEntry
s@AutoExportRevisionDestinationEntry' {} Maybe Text
a -> AutoExportRevisionDestinationEntry
s {$sel:keyPattern:AutoExportRevisionDestinationEntry' :: Maybe Text
keyPattern = Maybe Text
a} :: AutoExportRevisionDestinationEntry)

-- | The S3 bucket that is the destination for the event action.
autoExportRevisionDestinationEntry_bucket :: Lens.Lens' AutoExportRevisionDestinationEntry Prelude.Text
autoExportRevisionDestinationEntry_bucket :: (Text -> f Text)
-> AutoExportRevisionDestinationEntry
-> f AutoExportRevisionDestinationEntry
autoExportRevisionDestinationEntry_bucket = (AutoExportRevisionDestinationEntry -> Text)
-> (AutoExportRevisionDestinationEntry
    -> Text -> AutoExportRevisionDestinationEntry)
-> Lens
     AutoExportRevisionDestinationEntry
     AutoExportRevisionDestinationEntry
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoExportRevisionDestinationEntry' {Text
bucket :: Text
$sel:bucket:AutoExportRevisionDestinationEntry' :: AutoExportRevisionDestinationEntry -> Text
bucket} -> Text
bucket) (\s :: AutoExportRevisionDestinationEntry
s@AutoExportRevisionDestinationEntry' {} Text
a -> AutoExportRevisionDestinationEntry
s {$sel:bucket:AutoExportRevisionDestinationEntry' :: Text
bucket = Text
a} :: AutoExportRevisionDestinationEntry)

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

instance
  Prelude.Hashable
    AutoExportRevisionDestinationEntry

instance
  Prelude.NFData
    AutoExportRevisionDestinationEntry

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