{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreateImportJob
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates an import job for a data destination.
module Amazonka.SESV2.CreateImportJob
  ( -- * Creating a Request
    CreateImportJob (..),
    newCreateImportJob,

    -- * Request Lenses
    createImportJob_importDestination,
    createImportJob_importDataSource,

    -- * Destructuring the Response
    CreateImportJobResponse (..),
    newCreateImportJobResponse,

    -- * Response Lenses
    createImportJobResponse_jobId,
    createImportJobResponse_httpStatus,
  )
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SESV2.Types

-- | Represents a request to create an import job from a data source for a
-- data destination.
--
-- /See:/ 'newCreateImportJob' smart constructor.
data CreateImportJob = CreateImportJob'
  { -- | The destination for the import job.
    CreateImportJob -> ImportDestination
importDestination :: ImportDestination,
    -- | The data source for the import job.
    CreateImportJob -> ImportDataSource
importDataSource :: ImportDataSource
  }
  deriving (CreateImportJob -> CreateImportJob -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateImportJob -> CreateImportJob -> Bool
$c/= :: CreateImportJob -> CreateImportJob -> Bool
== :: CreateImportJob -> CreateImportJob -> Bool
$c== :: CreateImportJob -> CreateImportJob -> Bool
Prelude.Eq, ReadPrec [CreateImportJob]
ReadPrec CreateImportJob
Int -> ReadS CreateImportJob
ReadS [CreateImportJob]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateImportJob]
$creadListPrec :: ReadPrec [CreateImportJob]
readPrec :: ReadPrec CreateImportJob
$creadPrec :: ReadPrec CreateImportJob
readList :: ReadS [CreateImportJob]
$creadList :: ReadS [CreateImportJob]
readsPrec :: Int -> ReadS CreateImportJob
$creadsPrec :: Int -> ReadS CreateImportJob
Prelude.Read, Int -> CreateImportJob -> ShowS
[CreateImportJob] -> ShowS
CreateImportJob -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateImportJob] -> ShowS
$cshowList :: [CreateImportJob] -> ShowS
show :: CreateImportJob -> String
$cshow :: CreateImportJob -> String
showsPrec :: Int -> CreateImportJob -> ShowS
$cshowsPrec :: Int -> CreateImportJob -> ShowS
Prelude.Show, forall x. Rep CreateImportJob x -> CreateImportJob
forall x. CreateImportJob -> Rep CreateImportJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateImportJob x -> CreateImportJob
$cfrom :: forall x. CreateImportJob -> Rep CreateImportJob x
Prelude.Generic)

-- |
-- Create a value of 'CreateImportJob' 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:
--
-- 'importDestination', 'createImportJob_importDestination' - The destination for the import job.
--
-- 'importDataSource', 'createImportJob_importDataSource' - The data source for the import job.
newCreateImportJob ::
  -- | 'importDestination'
  ImportDestination ->
  -- | 'importDataSource'
  ImportDataSource ->
  CreateImportJob
newCreateImportJob :: ImportDestination -> ImportDataSource -> CreateImportJob
newCreateImportJob
  ImportDestination
pImportDestination_
  ImportDataSource
pImportDataSource_ =
    CreateImportJob'
      { $sel:importDestination:CreateImportJob' :: ImportDestination
importDestination =
          ImportDestination
pImportDestination_,
        $sel:importDataSource:CreateImportJob' :: ImportDataSource
importDataSource = ImportDataSource
pImportDataSource_
      }

-- | The destination for the import job.
createImportJob_importDestination :: Lens.Lens' CreateImportJob ImportDestination
createImportJob_importDestination :: Lens' CreateImportJob ImportDestination
createImportJob_importDestination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateImportJob' {ImportDestination
importDestination :: ImportDestination
$sel:importDestination:CreateImportJob' :: CreateImportJob -> ImportDestination
importDestination} -> ImportDestination
importDestination) (\s :: CreateImportJob
s@CreateImportJob' {} ImportDestination
a -> CreateImportJob
s {$sel:importDestination:CreateImportJob' :: ImportDestination
importDestination = ImportDestination
a} :: CreateImportJob)

-- | The data source for the import job.
createImportJob_importDataSource :: Lens.Lens' CreateImportJob ImportDataSource
createImportJob_importDataSource :: Lens' CreateImportJob ImportDataSource
createImportJob_importDataSource = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateImportJob' {ImportDataSource
importDataSource :: ImportDataSource
$sel:importDataSource:CreateImportJob' :: CreateImportJob -> ImportDataSource
importDataSource} -> ImportDataSource
importDataSource) (\s :: CreateImportJob
s@CreateImportJob' {} ImportDataSource
a -> CreateImportJob
s {$sel:importDataSource:CreateImportJob' :: ImportDataSource
importDataSource = ImportDataSource
a} :: CreateImportJob)

instance Core.AWSRequest CreateImportJob where
  type
    AWSResponse CreateImportJob =
      CreateImportJobResponse
  request :: (Service -> Service) -> CreateImportJob -> Request CreateImportJob
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateImportJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateImportJob)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> CreateImportJobResponse
CreateImportJobResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"JobId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateImportJob where
  hashWithSalt :: Int -> CreateImportJob -> Int
hashWithSalt Int
_salt CreateImportJob' {ImportDataSource
ImportDestination
importDataSource :: ImportDataSource
importDestination :: ImportDestination
$sel:importDataSource:CreateImportJob' :: CreateImportJob -> ImportDataSource
$sel:importDestination:CreateImportJob' :: CreateImportJob -> ImportDestination
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ImportDestination
importDestination
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ImportDataSource
importDataSource

instance Prelude.NFData CreateImportJob where
  rnf :: CreateImportJob -> ()
rnf CreateImportJob' {ImportDataSource
ImportDestination
importDataSource :: ImportDataSource
importDestination :: ImportDestination
$sel:importDataSource:CreateImportJob' :: CreateImportJob -> ImportDataSource
$sel:importDestination:CreateImportJob' :: CreateImportJob -> ImportDestination
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ImportDestination
importDestination
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ImportDataSource
importDataSource

instance Data.ToHeaders CreateImportJob where
  toHeaders :: CreateImportJob -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON CreateImportJob where
  toJSON :: CreateImportJob -> Value
toJSON CreateImportJob' {ImportDataSource
ImportDestination
importDataSource :: ImportDataSource
importDestination :: ImportDestination
$sel:importDataSource:CreateImportJob' :: CreateImportJob -> ImportDataSource
$sel:importDestination:CreateImportJob' :: CreateImportJob -> ImportDestination
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ImportDestination" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ImportDestination
importDestination),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ImportDataSource" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ImportDataSource
importDataSource)
          ]
      )

instance Data.ToPath CreateImportJob where
  toPath :: CreateImportJob -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v2/email/import-jobs"

instance Data.ToQuery CreateImportJob where
  toQuery :: CreateImportJob -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | An HTTP 200 response if the request succeeds, or an error message if the
-- request fails.
--
-- /See:/ 'newCreateImportJobResponse' smart constructor.
data CreateImportJobResponse = CreateImportJobResponse'
  { -- | A string that represents the import job ID.
    CreateImportJobResponse -> Maybe Text
jobId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateImportJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateImportJobResponse -> CreateImportJobResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateImportJobResponse -> CreateImportJobResponse -> Bool
$c/= :: CreateImportJobResponse -> CreateImportJobResponse -> Bool
== :: CreateImportJobResponse -> CreateImportJobResponse -> Bool
$c== :: CreateImportJobResponse -> CreateImportJobResponse -> Bool
Prelude.Eq, ReadPrec [CreateImportJobResponse]
ReadPrec CreateImportJobResponse
Int -> ReadS CreateImportJobResponse
ReadS [CreateImportJobResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateImportJobResponse]
$creadListPrec :: ReadPrec [CreateImportJobResponse]
readPrec :: ReadPrec CreateImportJobResponse
$creadPrec :: ReadPrec CreateImportJobResponse
readList :: ReadS [CreateImportJobResponse]
$creadList :: ReadS [CreateImportJobResponse]
readsPrec :: Int -> ReadS CreateImportJobResponse
$creadsPrec :: Int -> ReadS CreateImportJobResponse
Prelude.Read, Int -> CreateImportJobResponse -> ShowS
[CreateImportJobResponse] -> ShowS
CreateImportJobResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateImportJobResponse] -> ShowS
$cshowList :: [CreateImportJobResponse] -> ShowS
show :: CreateImportJobResponse -> String
$cshow :: CreateImportJobResponse -> String
showsPrec :: Int -> CreateImportJobResponse -> ShowS
$cshowsPrec :: Int -> CreateImportJobResponse -> ShowS
Prelude.Show, forall x. Rep CreateImportJobResponse x -> CreateImportJobResponse
forall x. CreateImportJobResponse -> Rep CreateImportJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateImportJobResponse x -> CreateImportJobResponse
$cfrom :: forall x. CreateImportJobResponse -> Rep CreateImportJobResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateImportJobResponse' 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:
--
-- 'jobId', 'createImportJobResponse_jobId' - A string that represents the import job ID.
--
-- 'httpStatus', 'createImportJobResponse_httpStatus' - The response's http status code.
newCreateImportJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateImportJobResponse
newCreateImportJobResponse :: Int -> CreateImportJobResponse
newCreateImportJobResponse Int
pHttpStatus_ =
  CreateImportJobResponse'
    { $sel:jobId:CreateImportJobResponse' :: Maybe Text
jobId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateImportJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A string that represents the import job ID.
createImportJobResponse_jobId :: Lens.Lens' CreateImportJobResponse (Prelude.Maybe Prelude.Text)
createImportJobResponse_jobId :: Lens' CreateImportJobResponse (Maybe Text)
createImportJobResponse_jobId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateImportJobResponse' {Maybe Text
jobId :: Maybe Text
$sel:jobId:CreateImportJobResponse' :: CreateImportJobResponse -> Maybe Text
jobId} -> Maybe Text
jobId) (\s :: CreateImportJobResponse
s@CreateImportJobResponse' {} Maybe Text
a -> CreateImportJobResponse
s {$sel:jobId:CreateImportJobResponse' :: Maybe Text
jobId = Maybe Text
a} :: CreateImportJobResponse)

-- | The response's http status code.
createImportJobResponse_httpStatus :: Lens.Lens' CreateImportJobResponse Prelude.Int
createImportJobResponse_httpStatus :: Lens' CreateImportJobResponse Int
createImportJobResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateImportJobResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateImportJobResponse' :: CreateImportJobResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateImportJobResponse
s@CreateImportJobResponse' {} Int
a -> CreateImportJobResponse
s {$sel:httpStatus:CreateImportJobResponse' :: Int
httpStatus = Int
a} :: CreateImportJobResponse)

instance Prelude.NFData CreateImportJobResponse where
  rnf :: CreateImportJobResponse -> ()
rnf CreateImportJobResponse' {Int
Maybe Text
httpStatus :: Int
jobId :: Maybe Text
$sel:httpStatus:CreateImportJobResponse' :: CreateImportJobResponse -> Int
$sel:jobId:CreateImportJobResponse' :: CreateImportJobResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
jobId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus