{-# 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.Redshift.Types.SnapshotErrorMessage
-- 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.Redshift.Types.SnapshotErrorMessage where

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

-- | Describes the errors returned by a snapshot.
--
-- /See:/ 'newSnapshotErrorMessage' smart constructor.
data SnapshotErrorMessage = SnapshotErrorMessage'
  { -- | The text message describing the error.
    SnapshotErrorMessage -> Maybe Text
failureReason :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for the snapshot returning the error.
    SnapshotErrorMessage -> Maybe Text
snapshotIdentifier :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for the cluster.
    SnapshotErrorMessage -> Maybe Text
snapshotClusterIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The failure code for the error.
    SnapshotErrorMessage -> Maybe Text
failureCode :: Prelude.Maybe Prelude.Text
  }
  deriving (SnapshotErrorMessage -> SnapshotErrorMessage -> Bool
(SnapshotErrorMessage -> SnapshotErrorMessage -> Bool)
-> (SnapshotErrorMessage -> SnapshotErrorMessage -> Bool)
-> Eq SnapshotErrorMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SnapshotErrorMessage -> SnapshotErrorMessage -> Bool
$c/= :: SnapshotErrorMessage -> SnapshotErrorMessage -> Bool
== :: SnapshotErrorMessage -> SnapshotErrorMessage -> Bool
$c== :: SnapshotErrorMessage -> SnapshotErrorMessage -> Bool
Prelude.Eq, ReadPrec [SnapshotErrorMessage]
ReadPrec SnapshotErrorMessage
Int -> ReadS SnapshotErrorMessage
ReadS [SnapshotErrorMessage]
(Int -> ReadS SnapshotErrorMessage)
-> ReadS [SnapshotErrorMessage]
-> ReadPrec SnapshotErrorMessage
-> ReadPrec [SnapshotErrorMessage]
-> Read SnapshotErrorMessage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SnapshotErrorMessage]
$creadListPrec :: ReadPrec [SnapshotErrorMessage]
readPrec :: ReadPrec SnapshotErrorMessage
$creadPrec :: ReadPrec SnapshotErrorMessage
readList :: ReadS [SnapshotErrorMessage]
$creadList :: ReadS [SnapshotErrorMessage]
readsPrec :: Int -> ReadS SnapshotErrorMessage
$creadsPrec :: Int -> ReadS SnapshotErrorMessage
Prelude.Read, Int -> SnapshotErrorMessage -> ShowS
[SnapshotErrorMessage] -> ShowS
SnapshotErrorMessage -> String
(Int -> SnapshotErrorMessage -> ShowS)
-> (SnapshotErrorMessage -> String)
-> ([SnapshotErrorMessage] -> ShowS)
-> Show SnapshotErrorMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SnapshotErrorMessage] -> ShowS
$cshowList :: [SnapshotErrorMessage] -> ShowS
show :: SnapshotErrorMessage -> String
$cshow :: SnapshotErrorMessage -> String
showsPrec :: Int -> SnapshotErrorMessage -> ShowS
$cshowsPrec :: Int -> SnapshotErrorMessage -> ShowS
Prelude.Show, (forall x. SnapshotErrorMessage -> Rep SnapshotErrorMessage x)
-> (forall x. Rep SnapshotErrorMessage x -> SnapshotErrorMessage)
-> Generic SnapshotErrorMessage
forall x. Rep SnapshotErrorMessage x -> SnapshotErrorMessage
forall x. SnapshotErrorMessage -> Rep SnapshotErrorMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SnapshotErrorMessage x -> SnapshotErrorMessage
$cfrom :: forall x. SnapshotErrorMessage -> Rep SnapshotErrorMessage x
Prelude.Generic)

-- |
-- Create a value of 'SnapshotErrorMessage' 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:
--
-- 'failureReason', 'snapshotErrorMessage_failureReason' - The text message describing the error.
--
-- 'snapshotIdentifier', 'snapshotErrorMessage_snapshotIdentifier' - A unique identifier for the snapshot returning the error.
--
-- 'snapshotClusterIdentifier', 'snapshotErrorMessage_snapshotClusterIdentifier' - A unique identifier for the cluster.
--
-- 'failureCode', 'snapshotErrorMessage_failureCode' - The failure code for the error.
newSnapshotErrorMessage ::
  SnapshotErrorMessage
newSnapshotErrorMessage :: SnapshotErrorMessage
newSnapshotErrorMessage =
  SnapshotErrorMessage' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> SnapshotErrorMessage
SnapshotErrorMessage'
    { $sel:failureReason:SnapshotErrorMessage' :: Maybe Text
failureReason =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:snapshotIdentifier:SnapshotErrorMessage' :: Maybe Text
snapshotIdentifier = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:snapshotClusterIdentifier:SnapshotErrorMessage' :: Maybe Text
snapshotClusterIdentifier = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:failureCode:SnapshotErrorMessage' :: Maybe Text
failureCode = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The text message describing the error.
snapshotErrorMessage_failureReason :: Lens.Lens' SnapshotErrorMessage (Prelude.Maybe Prelude.Text)
snapshotErrorMessage_failureReason :: (Maybe Text -> f (Maybe Text))
-> SnapshotErrorMessage -> f SnapshotErrorMessage
snapshotErrorMessage_failureReason = (SnapshotErrorMessage -> Maybe Text)
-> (SnapshotErrorMessage -> Maybe Text -> SnapshotErrorMessage)
-> Lens
     SnapshotErrorMessage SnapshotErrorMessage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapshotErrorMessage' {Maybe Text
failureReason :: Maybe Text
$sel:failureReason:SnapshotErrorMessage' :: SnapshotErrorMessage -> Maybe Text
failureReason} -> Maybe Text
failureReason) (\s :: SnapshotErrorMessage
s@SnapshotErrorMessage' {} Maybe Text
a -> SnapshotErrorMessage
s {$sel:failureReason:SnapshotErrorMessage' :: Maybe Text
failureReason = Maybe Text
a} :: SnapshotErrorMessage)

-- | A unique identifier for the snapshot returning the error.
snapshotErrorMessage_snapshotIdentifier :: Lens.Lens' SnapshotErrorMessage (Prelude.Maybe Prelude.Text)
snapshotErrorMessage_snapshotIdentifier :: (Maybe Text -> f (Maybe Text))
-> SnapshotErrorMessage -> f SnapshotErrorMessage
snapshotErrorMessage_snapshotIdentifier = (SnapshotErrorMessage -> Maybe Text)
-> (SnapshotErrorMessage -> Maybe Text -> SnapshotErrorMessage)
-> Lens
     SnapshotErrorMessage SnapshotErrorMessage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapshotErrorMessage' {Maybe Text
snapshotIdentifier :: Maybe Text
$sel:snapshotIdentifier:SnapshotErrorMessage' :: SnapshotErrorMessage -> Maybe Text
snapshotIdentifier} -> Maybe Text
snapshotIdentifier) (\s :: SnapshotErrorMessage
s@SnapshotErrorMessage' {} Maybe Text
a -> SnapshotErrorMessage
s {$sel:snapshotIdentifier:SnapshotErrorMessage' :: Maybe Text
snapshotIdentifier = Maybe Text
a} :: SnapshotErrorMessage)

-- | A unique identifier for the cluster.
snapshotErrorMessage_snapshotClusterIdentifier :: Lens.Lens' SnapshotErrorMessage (Prelude.Maybe Prelude.Text)
snapshotErrorMessage_snapshotClusterIdentifier :: (Maybe Text -> f (Maybe Text))
-> SnapshotErrorMessage -> f SnapshotErrorMessage
snapshotErrorMessage_snapshotClusterIdentifier = (SnapshotErrorMessage -> Maybe Text)
-> (SnapshotErrorMessage -> Maybe Text -> SnapshotErrorMessage)
-> Lens
     SnapshotErrorMessage SnapshotErrorMessage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapshotErrorMessage' {Maybe Text
snapshotClusterIdentifier :: Maybe Text
$sel:snapshotClusterIdentifier:SnapshotErrorMessage' :: SnapshotErrorMessage -> Maybe Text
snapshotClusterIdentifier} -> Maybe Text
snapshotClusterIdentifier) (\s :: SnapshotErrorMessage
s@SnapshotErrorMessage' {} Maybe Text
a -> SnapshotErrorMessage
s {$sel:snapshotClusterIdentifier:SnapshotErrorMessage' :: Maybe Text
snapshotClusterIdentifier = Maybe Text
a} :: SnapshotErrorMessage)

-- | The failure code for the error.
snapshotErrorMessage_failureCode :: Lens.Lens' SnapshotErrorMessage (Prelude.Maybe Prelude.Text)
snapshotErrorMessage_failureCode :: (Maybe Text -> f (Maybe Text))
-> SnapshotErrorMessage -> f SnapshotErrorMessage
snapshotErrorMessage_failureCode = (SnapshotErrorMessage -> Maybe Text)
-> (SnapshotErrorMessage -> Maybe Text -> SnapshotErrorMessage)
-> Lens
     SnapshotErrorMessage SnapshotErrorMessage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapshotErrorMessage' {Maybe Text
failureCode :: Maybe Text
$sel:failureCode:SnapshotErrorMessage' :: SnapshotErrorMessage -> Maybe Text
failureCode} -> Maybe Text
failureCode) (\s :: SnapshotErrorMessage
s@SnapshotErrorMessage' {} Maybe Text
a -> SnapshotErrorMessage
s {$sel:failureCode:SnapshotErrorMessage' :: Maybe Text
failureCode = Maybe Text
a} :: SnapshotErrorMessage)

instance Core.FromXML SnapshotErrorMessage where
  parseXML :: [Node] -> Either String SnapshotErrorMessage
parseXML [Node]
x =
    Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> SnapshotErrorMessage
SnapshotErrorMessage'
      (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> SnapshotErrorMessage)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text -> Maybe Text -> Maybe Text -> SnapshotErrorMessage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"FailureReason")
      Either
  String
  (Maybe Text -> Maybe Text -> Maybe Text -> SnapshotErrorMessage)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Maybe Text -> SnapshotErrorMessage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SnapshotIdentifier")
      Either String (Maybe Text -> Maybe Text -> SnapshotErrorMessage)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> SnapshotErrorMessage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SnapshotClusterIdentifier")
      Either String (Maybe Text -> SnapshotErrorMessage)
-> Either String (Maybe Text) -> Either String SnapshotErrorMessage
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"FailureCode")

instance Prelude.Hashable SnapshotErrorMessage

instance Prelude.NFData SnapshotErrorMessage