{-# 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.FailureInfo
-- 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.SESV2.Types.FailureInfo where

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

-- | An object that contains the failure details about an import job.
--
-- /See:/ 'newFailureInfo' smart constructor.
data FailureInfo = FailureInfo'
  { -- | An Amazon S3 presigned URL that contains all the failed records and
    -- related information.
    FailureInfo -> Maybe Text
failedRecordsS3Url :: Prelude.Maybe Prelude.Text,
    -- | A message about why the import job failed.
    FailureInfo -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text
  }
  deriving (FailureInfo -> FailureInfo -> Bool
(FailureInfo -> FailureInfo -> Bool)
-> (FailureInfo -> FailureInfo -> Bool) -> Eq FailureInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailureInfo -> FailureInfo -> Bool
$c/= :: FailureInfo -> FailureInfo -> Bool
== :: FailureInfo -> FailureInfo -> Bool
$c== :: FailureInfo -> FailureInfo -> Bool
Prelude.Eq, ReadPrec [FailureInfo]
ReadPrec FailureInfo
Int -> ReadS FailureInfo
ReadS [FailureInfo]
(Int -> ReadS FailureInfo)
-> ReadS [FailureInfo]
-> ReadPrec FailureInfo
-> ReadPrec [FailureInfo]
-> Read FailureInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailureInfo]
$creadListPrec :: ReadPrec [FailureInfo]
readPrec :: ReadPrec FailureInfo
$creadPrec :: ReadPrec FailureInfo
readList :: ReadS [FailureInfo]
$creadList :: ReadS [FailureInfo]
readsPrec :: Int -> ReadS FailureInfo
$creadsPrec :: Int -> ReadS FailureInfo
Prelude.Read, Int -> FailureInfo -> ShowS
[FailureInfo] -> ShowS
FailureInfo -> String
(Int -> FailureInfo -> ShowS)
-> (FailureInfo -> String)
-> ([FailureInfo] -> ShowS)
-> Show FailureInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailureInfo] -> ShowS
$cshowList :: [FailureInfo] -> ShowS
show :: FailureInfo -> String
$cshow :: FailureInfo -> String
showsPrec :: Int -> FailureInfo -> ShowS
$cshowsPrec :: Int -> FailureInfo -> ShowS
Prelude.Show, (forall x. FailureInfo -> Rep FailureInfo x)
-> (forall x. Rep FailureInfo x -> FailureInfo)
-> Generic FailureInfo
forall x. Rep FailureInfo x -> FailureInfo
forall x. FailureInfo -> Rep FailureInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FailureInfo x -> FailureInfo
$cfrom :: forall x. FailureInfo -> Rep FailureInfo x
Prelude.Generic)

-- |
-- Create a value of 'FailureInfo' 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:
--
-- 'failedRecordsS3Url', 'failureInfo_failedRecordsS3Url' - An Amazon S3 presigned URL that contains all the failed records and
-- related information.
--
-- 'errorMessage', 'failureInfo_errorMessage' - A message about why the import job failed.
newFailureInfo ::
  FailureInfo
newFailureInfo :: FailureInfo
newFailureInfo =
  FailureInfo' :: Maybe Text -> Maybe Text -> FailureInfo
FailureInfo'
    { $sel:failedRecordsS3Url:FailureInfo' :: Maybe Text
failedRecordsS3Url = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:FailureInfo' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | An Amazon S3 presigned URL that contains all the failed records and
-- related information.
failureInfo_failedRecordsS3Url :: Lens.Lens' FailureInfo (Prelude.Maybe Prelude.Text)
failureInfo_failedRecordsS3Url :: (Maybe Text -> f (Maybe Text)) -> FailureInfo -> f FailureInfo
failureInfo_failedRecordsS3Url = (FailureInfo -> Maybe Text)
-> (FailureInfo -> Maybe Text -> FailureInfo)
-> Lens FailureInfo FailureInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureInfo' {Maybe Text
failedRecordsS3Url :: Maybe Text
$sel:failedRecordsS3Url:FailureInfo' :: FailureInfo -> Maybe Text
failedRecordsS3Url} -> Maybe Text
failedRecordsS3Url) (\s :: FailureInfo
s@FailureInfo' {} Maybe Text
a -> FailureInfo
s {$sel:failedRecordsS3Url:FailureInfo' :: Maybe Text
failedRecordsS3Url = Maybe Text
a} :: FailureInfo)

-- | A message about why the import job failed.
failureInfo_errorMessage :: Lens.Lens' FailureInfo (Prelude.Maybe Prelude.Text)
failureInfo_errorMessage :: (Maybe Text -> f (Maybe Text)) -> FailureInfo -> f FailureInfo
failureInfo_errorMessage = (FailureInfo -> Maybe Text)
-> (FailureInfo -> Maybe Text -> FailureInfo)
-> Lens FailureInfo FailureInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailureInfo' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:FailureInfo' :: FailureInfo -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: FailureInfo
s@FailureInfo' {} Maybe Text
a -> FailureInfo
s {$sel:errorMessage:FailureInfo' :: Maybe Text
errorMessage = Maybe Text
a} :: FailureInfo)

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

instance Prelude.Hashable FailureInfo

instance Prelude.NFData FailureInfo