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

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

-- | The destination for the asset.
--
-- /See:/ 'newAssetDestinationEntry' smart constructor.
data AssetDestinationEntry = AssetDestinationEntry'
  { -- | The name of the object in Amazon S3 for the asset.
    AssetDestinationEntry -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | The S3 bucket that is the destination for the asset.
    AssetDestinationEntry -> Text
bucket :: Prelude.Text,
    -- | The unique identifier for the asset.
    AssetDestinationEntry -> Text
assetId :: Prelude.Text
  }
  deriving (AssetDestinationEntry -> AssetDestinationEntry -> Bool
(AssetDestinationEntry -> AssetDestinationEntry -> Bool)
-> (AssetDestinationEntry -> AssetDestinationEntry -> Bool)
-> Eq AssetDestinationEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetDestinationEntry -> AssetDestinationEntry -> Bool
$c/= :: AssetDestinationEntry -> AssetDestinationEntry -> Bool
== :: AssetDestinationEntry -> AssetDestinationEntry -> Bool
$c== :: AssetDestinationEntry -> AssetDestinationEntry -> Bool
Prelude.Eq, ReadPrec [AssetDestinationEntry]
ReadPrec AssetDestinationEntry
Int -> ReadS AssetDestinationEntry
ReadS [AssetDestinationEntry]
(Int -> ReadS AssetDestinationEntry)
-> ReadS [AssetDestinationEntry]
-> ReadPrec AssetDestinationEntry
-> ReadPrec [AssetDestinationEntry]
-> Read AssetDestinationEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetDestinationEntry]
$creadListPrec :: ReadPrec [AssetDestinationEntry]
readPrec :: ReadPrec AssetDestinationEntry
$creadPrec :: ReadPrec AssetDestinationEntry
readList :: ReadS [AssetDestinationEntry]
$creadList :: ReadS [AssetDestinationEntry]
readsPrec :: Int -> ReadS AssetDestinationEntry
$creadsPrec :: Int -> ReadS AssetDestinationEntry
Prelude.Read, Int -> AssetDestinationEntry -> ShowS
[AssetDestinationEntry] -> ShowS
AssetDestinationEntry -> String
(Int -> AssetDestinationEntry -> ShowS)
-> (AssetDestinationEntry -> String)
-> ([AssetDestinationEntry] -> ShowS)
-> Show AssetDestinationEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetDestinationEntry] -> ShowS
$cshowList :: [AssetDestinationEntry] -> ShowS
show :: AssetDestinationEntry -> String
$cshow :: AssetDestinationEntry -> String
showsPrec :: Int -> AssetDestinationEntry -> ShowS
$cshowsPrec :: Int -> AssetDestinationEntry -> ShowS
Prelude.Show, (forall x. AssetDestinationEntry -> Rep AssetDestinationEntry x)
-> (forall x. Rep AssetDestinationEntry x -> AssetDestinationEntry)
-> Generic AssetDestinationEntry
forall x. Rep AssetDestinationEntry x -> AssetDestinationEntry
forall x. AssetDestinationEntry -> Rep AssetDestinationEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetDestinationEntry x -> AssetDestinationEntry
$cfrom :: forall x. AssetDestinationEntry -> Rep AssetDestinationEntry x
Prelude.Generic)

-- |
-- Create a value of 'AssetDestinationEntry' 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:
--
-- 'key', 'assetDestinationEntry_key' - The name of the object in Amazon S3 for the asset.
--
-- 'bucket', 'assetDestinationEntry_bucket' - The S3 bucket that is the destination for the asset.
--
-- 'assetId', 'assetDestinationEntry_assetId' - The unique identifier for the asset.
newAssetDestinationEntry ::
  -- | 'bucket'
  Prelude.Text ->
  -- | 'assetId'
  Prelude.Text ->
  AssetDestinationEntry
newAssetDestinationEntry :: Text -> Text -> AssetDestinationEntry
newAssetDestinationEntry Text
pBucket_ Text
pAssetId_ =
  AssetDestinationEntry' :: Maybe Text -> Text -> Text -> AssetDestinationEntry
AssetDestinationEntry'
    { $sel:key:AssetDestinationEntry' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:AssetDestinationEntry' :: Text
bucket = Text
pBucket_,
      $sel:assetId:AssetDestinationEntry' :: Text
assetId = Text
pAssetId_
    }

-- | The name of the object in Amazon S3 for the asset.
assetDestinationEntry_key :: Lens.Lens' AssetDestinationEntry (Prelude.Maybe Prelude.Text)
assetDestinationEntry_key :: (Maybe Text -> f (Maybe Text))
-> AssetDestinationEntry -> f AssetDestinationEntry
assetDestinationEntry_key = (AssetDestinationEntry -> Maybe Text)
-> (AssetDestinationEntry -> Maybe Text -> AssetDestinationEntry)
-> Lens
     AssetDestinationEntry
     AssetDestinationEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetDestinationEntry' {Maybe Text
key :: Maybe Text
$sel:key:AssetDestinationEntry' :: AssetDestinationEntry -> Maybe Text
key} -> Maybe Text
key) (\s :: AssetDestinationEntry
s@AssetDestinationEntry' {} Maybe Text
a -> AssetDestinationEntry
s {$sel:key:AssetDestinationEntry' :: Maybe Text
key = Maybe Text
a} :: AssetDestinationEntry)

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

-- | The unique identifier for the asset.
assetDestinationEntry_assetId :: Lens.Lens' AssetDestinationEntry Prelude.Text
assetDestinationEntry_assetId :: (Text -> f Text)
-> AssetDestinationEntry -> f AssetDestinationEntry
assetDestinationEntry_assetId = (AssetDestinationEntry -> Text)
-> (AssetDestinationEntry -> Text -> AssetDestinationEntry)
-> Lens AssetDestinationEntry AssetDestinationEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetDestinationEntry' {Text
assetId :: Text
$sel:assetId:AssetDestinationEntry' :: AssetDestinationEntry -> Text
assetId} -> Text
assetId) (\s :: AssetDestinationEntry
s@AssetDestinationEntry' {} Text
a -> AssetDestinationEntry
s {$sel:assetId:AssetDestinationEntry' :: Text
assetId = Text
a} :: AssetDestinationEntry)

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

instance Prelude.Hashable AssetDestinationEntry

instance Prelude.NFData AssetDestinationEntry

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