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

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

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

-- |
-- Create a value of 'AssetSourceEntry' 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:
--
-- 'bucket', 'assetSourceEntry_bucket' - The S3 bucket that\'s part of the source of the asset.
--
-- 'key', 'assetSourceEntry_key' - The name of the object in Amazon S3 for the asset.
newAssetSourceEntry ::
  -- | 'bucket'
  Prelude.Text ->
  -- | 'key'
  Prelude.Text ->
  AssetSourceEntry
newAssetSourceEntry :: Text -> Text -> AssetSourceEntry
newAssetSourceEntry Text
pBucket_ Text
pKey_ =
  AssetSourceEntry' :: Text -> Text -> AssetSourceEntry
AssetSourceEntry' {$sel:bucket:AssetSourceEntry' :: Text
bucket = Text
pBucket_, $sel:key:AssetSourceEntry' :: Text
key = Text
pKey_}

-- | The S3 bucket that\'s part of the source of the asset.
assetSourceEntry_bucket :: Lens.Lens' AssetSourceEntry Prelude.Text
assetSourceEntry_bucket :: (Text -> f Text) -> AssetSourceEntry -> f AssetSourceEntry
assetSourceEntry_bucket = (AssetSourceEntry -> Text)
-> (AssetSourceEntry -> Text -> AssetSourceEntry)
-> Lens AssetSourceEntry AssetSourceEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetSourceEntry' {Text
bucket :: Text
$sel:bucket:AssetSourceEntry' :: AssetSourceEntry -> Text
bucket} -> Text
bucket) (\s :: AssetSourceEntry
s@AssetSourceEntry' {} Text
a -> AssetSourceEntry
s {$sel:bucket:AssetSourceEntry' :: Text
bucket = Text
a} :: AssetSourceEntry)

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

instance Core.FromJSON AssetSourceEntry where
  parseJSON :: Value -> Parser AssetSourceEntry
parseJSON =
    String
-> (Object -> Parser AssetSourceEntry)
-> Value
-> Parser AssetSourceEntry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AssetSourceEntry"
      ( \Object
x ->
          Text -> Text -> AssetSourceEntry
AssetSourceEntry'
            (Text -> Text -> AssetSourceEntry)
-> Parser Text -> Parser (Text -> AssetSourceEntry)
forall (f :: * -> *) a b. Functor 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 -> AssetSourceEntry)
-> Parser Text -> Parser AssetSourceEntry
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
"Key")
      )

instance Prelude.Hashable AssetSourceEntry

instance Prelude.NFData AssetSourceEntry

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