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

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

-- | The destination where the assets in the revision will be exported.
--
-- /See:/ 'newRevisionDestinationEntry' smart constructor.
data RevisionDestinationEntry = RevisionDestinationEntry'
  { -- | 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>.
    RevisionDestinationEntry -> Maybe Text
keyPattern :: Prelude.Maybe Prelude.Text,
    -- | The S3 bucket that is the destination for the assets in the revision.
    RevisionDestinationEntry -> Text
bucket :: Prelude.Text,
    -- | The unique identifier for the revision.
    RevisionDestinationEntry -> Text
revisionId :: Prelude.Text
  }
  deriving (RevisionDestinationEntry -> RevisionDestinationEntry -> Bool
(RevisionDestinationEntry -> RevisionDestinationEntry -> Bool)
-> (RevisionDestinationEntry -> RevisionDestinationEntry -> Bool)
-> Eq RevisionDestinationEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RevisionDestinationEntry -> RevisionDestinationEntry -> Bool
$c/= :: RevisionDestinationEntry -> RevisionDestinationEntry -> Bool
== :: RevisionDestinationEntry -> RevisionDestinationEntry -> Bool
$c== :: RevisionDestinationEntry -> RevisionDestinationEntry -> Bool
Prelude.Eq, ReadPrec [RevisionDestinationEntry]
ReadPrec RevisionDestinationEntry
Int -> ReadS RevisionDestinationEntry
ReadS [RevisionDestinationEntry]
(Int -> ReadS RevisionDestinationEntry)
-> ReadS [RevisionDestinationEntry]
-> ReadPrec RevisionDestinationEntry
-> ReadPrec [RevisionDestinationEntry]
-> Read RevisionDestinationEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RevisionDestinationEntry]
$creadListPrec :: ReadPrec [RevisionDestinationEntry]
readPrec :: ReadPrec RevisionDestinationEntry
$creadPrec :: ReadPrec RevisionDestinationEntry
readList :: ReadS [RevisionDestinationEntry]
$creadList :: ReadS [RevisionDestinationEntry]
readsPrec :: Int -> ReadS RevisionDestinationEntry
$creadsPrec :: Int -> ReadS RevisionDestinationEntry
Prelude.Read, Int -> RevisionDestinationEntry -> ShowS
[RevisionDestinationEntry] -> ShowS
RevisionDestinationEntry -> String
(Int -> RevisionDestinationEntry -> ShowS)
-> (RevisionDestinationEntry -> String)
-> ([RevisionDestinationEntry] -> ShowS)
-> Show RevisionDestinationEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RevisionDestinationEntry] -> ShowS
$cshowList :: [RevisionDestinationEntry] -> ShowS
show :: RevisionDestinationEntry -> String
$cshow :: RevisionDestinationEntry -> String
showsPrec :: Int -> RevisionDestinationEntry -> ShowS
$cshowsPrec :: Int -> RevisionDestinationEntry -> ShowS
Prelude.Show, (forall x.
 RevisionDestinationEntry -> Rep RevisionDestinationEntry x)
-> (forall x.
    Rep RevisionDestinationEntry x -> RevisionDestinationEntry)
-> Generic RevisionDestinationEntry
forall x.
Rep RevisionDestinationEntry x -> RevisionDestinationEntry
forall x.
RevisionDestinationEntry -> Rep RevisionDestinationEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RevisionDestinationEntry x -> RevisionDestinationEntry
$cfrom :: forall x.
RevisionDestinationEntry -> Rep RevisionDestinationEntry x
Prelude.Generic)

-- |
-- Create a value of 'RevisionDestinationEntry' 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', 'revisionDestinationEntry_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', 'revisionDestinationEntry_bucket' - The S3 bucket that is the destination for the assets in the revision.
--
-- 'revisionId', 'revisionDestinationEntry_revisionId' - The unique identifier for the revision.
newRevisionDestinationEntry ::
  -- | 'bucket'
  Prelude.Text ->
  -- | 'revisionId'
  Prelude.Text ->
  RevisionDestinationEntry
newRevisionDestinationEntry :: Text -> Text -> RevisionDestinationEntry
newRevisionDestinationEntry Text
pBucket_ Text
pRevisionId_ =
  RevisionDestinationEntry' :: Maybe Text -> Text -> Text -> RevisionDestinationEntry
RevisionDestinationEntry'
    { $sel:keyPattern:RevisionDestinationEntry' :: Maybe Text
keyPattern =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:RevisionDestinationEntry' :: Text
bucket = Text
pBucket_,
      $sel:revisionId:RevisionDestinationEntry' :: Text
revisionId = Text
pRevisionId_
    }

-- | 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>.
revisionDestinationEntry_keyPattern :: Lens.Lens' RevisionDestinationEntry (Prelude.Maybe Prelude.Text)
revisionDestinationEntry_keyPattern :: (Maybe Text -> f (Maybe Text))
-> RevisionDestinationEntry -> f RevisionDestinationEntry
revisionDestinationEntry_keyPattern = (RevisionDestinationEntry -> Maybe Text)
-> (RevisionDestinationEntry
    -> Maybe Text -> RevisionDestinationEntry)
-> Lens
     RevisionDestinationEntry
     RevisionDestinationEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevisionDestinationEntry' {Maybe Text
keyPattern :: Maybe Text
$sel:keyPattern:RevisionDestinationEntry' :: RevisionDestinationEntry -> Maybe Text
keyPattern} -> Maybe Text
keyPattern) (\s :: RevisionDestinationEntry
s@RevisionDestinationEntry' {} Maybe Text
a -> RevisionDestinationEntry
s {$sel:keyPattern:RevisionDestinationEntry' :: Maybe Text
keyPattern = Maybe Text
a} :: RevisionDestinationEntry)

-- | The S3 bucket that is the destination for the assets in the revision.
revisionDestinationEntry_bucket :: Lens.Lens' RevisionDestinationEntry Prelude.Text
revisionDestinationEntry_bucket :: (Text -> f Text)
-> RevisionDestinationEntry -> f RevisionDestinationEntry
revisionDestinationEntry_bucket = (RevisionDestinationEntry -> Text)
-> (RevisionDestinationEntry -> Text -> RevisionDestinationEntry)
-> Lens RevisionDestinationEntry RevisionDestinationEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevisionDestinationEntry' {Text
bucket :: Text
$sel:bucket:RevisionDestinationEntry' :: RevisionDestinationEntry -> Text
bucket} -> Text
bucket) (\s :: RevisionDestinationEntry
s@RevisionDestinationEntry' {} Text
a -> RevisionDestinationEntry
s {$sel:bucket:RevisionDestinationEntry' :: Text
bucket = Text
a} :: RevisionDestinationEntry)

-- | The unique identifier for the revision.
revisionDestinationEntry_revisionId :: Lens.Lens' RevisionDestinationEntry Prelude.Text
revisionDestinationEntry_revisionId :: (Text -> f Text)
-> RevisionDestinationEntry -> f RevisionDestinationEntry
revisionDestinationEntry_revisionId = (RevisionDestinationEntry -> Text)
-> (RevisionDestinationEntry -> Text -> RevisionDestinationEntry)
-> Lens RevisionDestinationEntry RevisionDestinationEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevisionDestinationEntry' {Text
revisionId :: Text
$sel:revisionId:RevisionDestinationEntry' :: RevisionDestinationEntry -> Text
revisionId} -> Text
revisionId) (\s :: RevisionDestinationEntry
s@RevisionDestinationEntry' {} Text
a -> RevisionDestinationEntry
s {$sel:revisionId:RevisionDestinationEntry' :: Text
revisionId = Text
a} :: RevisionDestinationEntry)

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

instance Prelude.Hashable RevisionDestinationEntry

instance Prelude.NFData RevisionDestinationEntry

instance Core.ToJSON RevisionDestinationEntry where
  toJSON :: RevisionDestinationEntry -> Value
toJSON RevisionDestinationEntry' {Maybe Text
Text
revisionId :: Text
bucket :: Text
keyPattern :: Maybe Text
$sel:revisionId:RevisionDestinationEntry' :: RevisionDestinationEntry -> Text
$sel:bucket:RevisionDestinationEntry' :: RevisionDestinationEntry -> Text
$sel:keyPattern:RevisionDestinationEntry' :: RevisionDestinationEntry -> 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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RevisionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
revisionId)
          ]
      )