{-# 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.SESV2.Types.ImportDataSource
-- 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.SESV2.Types.ImportDataSource 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
import Amazonka.SESV2.Types.DataFormat

-- | An object that contains details about the data source of the import job.
--
-- /See:/ 'newImportDataSource' smart constructor.
data ImportDataSource = ImportDataSource'
  { -- | An Amazon S3 URL in the format s3:\/\//\<bucket_name>/\//\<object>/.
    ImportDataSource -> Text
s3Url :: Prelude.Text,
    -- | The data format of the import job\'s data source.
    ImportDataSource -> DataFormat
dataFormat :: DataFormat
  }
  deriving (ImportDataSource -> ImportDataSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportDataSource -> ImportDataSource -> Bool
$c/= :: ImportDataSource -> ImportDataSource -> Bool
== :: ImportDataSource -> ImportDataSource -> Bool
$c== :: ImportDataSource -> ImportDataSource -> Bool
Prelude.Eq, ReadPrec [ImportDataSource]
ReadPrec ImportDataSource
Int -> ReadS ImportDataSource
ReadS [ImportDataSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportDataSource]
$creadListPrec :: ReadPrec [ImportDataSource]
readPrec :: ReadPrec ImportDataSource
$creadPrec :: ReadPrec ImportDataSource
readList :: ReadS [ImportDataSource]
$creadList :: ReadS [ImportDataSource]
readsPrec :: Int -> ReadS ImportDataSource
$creadsPrec :: Int -> ReadS ImportDataSource
Prelude.Read, Int -> ImportDataSource -> ShowS
[ImportDataSource] -> ShowS
ImportDataSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImportDataSource] -> ShowS
$cshowList :: [ImportDataSource] -> ShowS
show :: ImportDataSource -> String
$cshow :: ImportDataSource -> String
showsPrec :: Int -> ImportDataSource -> ShowS
$cshowsPrec :: Int -> ImportDataSource -> ShowS
Prelude.Show, forall x. Rep ImportDataSource x -> ImportDataSource
forall x. ImportDataSource -> Rep ImportDataSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImportDataSource x -> ImportDataSource
$cfrom :: forall x. ImportDataSource -> Rep ImportDataSource x
Prelude.Generic)

-- |
-- Create a value of 'ImportDataSource' 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:
--
-- 's3Url', 'importDataSource_s3Url' - An Amazon S3 URL in the format s3:\/\//\<bucket_name>/\//\<object>/.
--
-- 'dataFormat', 'importDataSource_dataFormat' - The data format of the import job\'s data source.
newImportDataSource ::
  -- | 's3Url'
  Prelude.Text ->
  -- | 'dataFormat'
  DataFormat ->
  ImportDataSource
newImportDataSource :: Text -> DataFormat -> ImportDataSource
newImportDataSource Text
pS3Url_ DataFormat
pDataFormat_ =
  ImportDataSource'
    { $sel:s3Url:ImportDataSource' :: Text
s3Url = Text
pS3Url_,
      $sel:dataFormat:ImportDataSource' :: DataFormat
dataFormat = DataFormat
pDataFormat_
    }

-- | An Amazon S3 URL in the format s3:\/\//\<bucket_name>/\//\<object>/.
importDataSource_s3Url :: Lens.Lens' ImportDataSource Prelude.Text
importDataSource_s3Url :: Lens' ImportDataSource Text
importDataSource_s3Url = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportDataSource' {Text
s3Url :: Text
$sel:s3Url:ImportDataSource' :: ImportDataSource -> Text
s3Url} -> Text
s3Url) (\s :: ImportDataSource
s@ImportDataSource' {} Text
a -> ImportDataSource
s {$sel:s3Url:ImportDataSource' :: Text
s3Url = Text
a} :: ImportDataSource)

-- | The data format of the import job\'s data source.
importDataSource_dataFormat :: Lens.Lens' ImportDataSource DataFormat
importDataSource_dataFormat :: Lens' ImportDataSource DataFormat
importDataSource_dataFormat = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportDataSource' {DataFormat
dataFormat :: DataFormat
$sel:dataFormat:ImportDataSource' :: ImportDataSource -> DataFormat
dataFormat} -> DataFormat
dataFormat) (\s :: ImportDataSource
s@ImportDataSource' {} DataFormat
a -> ImportDataSource
s {$sel:dataFormat:ImportDataSource' :: DataFormat
dataFormat = DataFormat
a} :: ImportDataSource)

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

instance Prelude.Hashable ImportDataSource where
  hashWithSalt :: Int -> ImportDataSource -> Int
hashWithSalt Int
_salt ImportDataSource' {Text
DataFormat
dataFormat :: DataFormat
s3Url :: Text
$sel:dataFormat:ImportDataSource' :: ImportDataSource -> DataFormat
$sel:s3Url:ImportDataSource' :: ImportDataSource -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3Url
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DataFormat
dataFormat

instance Prelude.NFData ImportDataSource where
  rnf :: ImportDataSource -> ()
rnf ImportDataSource' {Text
DataFormat
dataFormat :: DataFormat
s3Url :: Text
$sel:dataFormat:ImportDataSource' :: ImportDataSource -> DataFormat
$sel:s3Url:ImportDataSource' :: ImportDataSource -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
s3Url
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DataFormat
dataFormat

instance Data.ToJSON ImportDataSource where
  toJSON :: ImportDataSource -> Value
toJSON ImportDataSource' {Text
DataFormat
dataFormat :: DataFormat
s3Url :: Text
$sel:dataFormat:ImportDataSource' :: ImportDataSource -> DataFormat
$sel:s3Url:ImportDataSource' :: ImportDataSource -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"S3Url" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3Url),
            forall a. a -> Maybe a
Prelude.Just (Key
"DataFormat" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DataFormat
dataFormat)
          ]
      )