{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DataExchange.Types.AssetDestinationEntry where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 unique identifier for the asset.
    AssetDestinationEntry -> Text
assetId :: Prelude.Text,
    -- | The Amazon S3 bucket that is the destination for the asset.
    AssetDestinationEntry -> Text
bucket :: Prelude.Text
  }
  deriving (AssetDestinationEntry -> AssetDestinationEntry -> Bool
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]
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
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. 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.
--
-- 'assetId', 'assetDestinationEntry_assetId' - The unique identifier for the asset.
--
-- 'bucket', 'assetDestinationEntry_bucket' - The Amazon S3 bucket that is the destination for the asset.
newAssetDestinationEntry ::
  -- | 'assetId'
  Prelude.Text ->
  -- | 'bucket'
  Prelude.Text ->
  AssetDestinationEntry
newAssetDestinationEntry :: Text -> Text -> AssetDestinationEntry
newAssetDestinationEntry Text
pAssetId_ Text
pBucket_ =
  AssetDestinationEntry'
    { $sel:key:AssetDestinationEntry' :: Maybe Text
key = forall a. Maybe a
Prelude.Nothing,
      $sel:assetId:AssetDestinationEntry' :: Text
assetId = Text
pAssetId_,
      $sel:bucket:AssetDestinationEntry' :: Text
bucket = Text
pBucket_
    }

-- | The name of the object in Amazon S3 for the asset.
assetDestinationEntry_key :: Lens.Lens' AssetDestinationEntry (Prelude.Maybe Prelude.Text)
assetDestinationEntry_key :: Lens' AssetDestinationEntry (Maybe Text)
assetDestinationEntry_key = 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 unique identifier for the asset.
assetDestinationEntry_assetId :: Lens.Lens' AssetDestinationEntry Prelude.Text
assetDestinationEntry_assetId :: Lens' AssetDestinationEntry Text
assetDestinationEntry_assetId = 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)

-- | The Amazon S3 bucket that is the destination for the asset.
assetDestinationEntry_bucket :: Lens.Lens' AssetDestinationEntry Prelude.Text
assetDestinationEntry_bucket :: Lens' AssetDestinationEntry Text
assetDestinationEntry_bucket = 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)

instance Data.FromJSON AssetDestinationEntry where
  parseJSON :: Value -> Parser AssetDestinationEntry
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AssetDestinationEntry"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> AssetDestinationEntry
AssetDestinationEntry'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Key")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"AssetId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Bucket")
      )

instance Prelude.Hashable AssetDestinationEntry where
  hashWithSalt :: Int -> AssetDestinationEntry -> Int
hashWithSalt Int
_salt AssetDestinationEntry' {Maybe Text
Text
bucket :: Text
assetId :: Text
key :: Maybe Text
$sel:bucket:AssetDestinationEntry' :: AssetDestinationEntry -> Text
$sel:assetId:AssetDestinationEntry' :: AssetDestinationEntry -> Text
$sel:key:AssetDestinationEntry' :: AssetDestinationEntry -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
assetId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
bucket

instance Prelude.NFData AssetDestinationEntry where
  rnf :: AssetDestinationEntry -> ()
rnf AssetDestinationEntry' {Maybe Text
Text
bucket :: Text
assetId :: Text
key :: Maybe Text
$sel:bucket:AssetDestinationEntry' :: AssetDestinationEntry -> Text
$sel:assetId:AssetDestinationEntry' :: AssetDestinationEntry -> Text
$sel:key:AssetDestinationEntry' :: AssetDestinationEntry -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
assetId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
bucket

instance Data.ToJSON AssetDestinationEntry where
  toJSON :: AssetDestinationEntry -> Value
toJSON AssetDestinationEntry' {Maybe Text
Text
bucket :: Text
assetId :: Text
key :: Maybe Text
$sel:bucket:AssetDestinationEntry' :: AssetDestinationEntry -> Text
$sel:assetId:AssetDestinationEntry' :: AssetDestinationEntry -> Text
$sel:key:AssetDestinationEntry' :: AssetDestinationEntry -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
key,
            forall a. a -> Maybe a
Prelude.Just (Key
"AssetId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
assetId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Bucket" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
bucket)
          ]
      )