{-# 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.MGN.Types.DataReplicationError
-- 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.MGN.Types.DataReplicationError where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MGN.Types.DataReplicationErrorString
import qualified Amazonka.Prelude as Prelude

-- | Error in data replication.
--
-- /See:/ 'newDataReplicationError' smart constructor.
data DataReplicationError = DataReplicationError'
  { -- | Error in data replication.
    DataReplicationError -> Maybe Text
rawError :: Prelude.Maybe Prelude.Text,
    -- | Error in data replication.
    DataReplicationError -> Maybe DataReplicationErrorString
error :: Prelude.Maybe DataReplicationErrorString
  }
  deriving (DataReplicationError -> DataReplicationError -> Bool
(DataReplicationError -> DataReplicationError -> Bool)
-> (DataReplicationError -> DataReplicationError -> Bool)
-> Eq DataReplicationError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataReplicationError -> DataReplicationError -> Bool
$c/= :: DataReplicationError -> DataReplicationError -> Bool
== :: DataReplicationError -> DataReplicationError -> Bool
$c== :: DataReplicationError -> DataReplicationError -> Bool
Prelude.Eq, ReadPrec [DataReplicationError]
ReadPrec DataReplicationError
Int -> ReadS DataReplicationError
ReadS [DataReplicationError]
(Int -> ReadS DataReplicationError)
-> ReadS [DataReplicationError]
-> ReadPrec DataReplicationError
-> ReadPrec [DataReplicationError]
-> Read DataReplicationError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataReplicationError]
$creadListPrec :: ReadPrec [DataReplicationError]
readPrec :: ReadPrec DataReplicationError
$creadPrec :: ReadPrec DataReplicationError
readList :: ReadS [DataReplicationError]
$creadList :: ReadS [DataReplicationError]
readsPrec :: Int -> ReadS DataReplicationError
$creadsPrec :: Int -> ReadS DataReplicationError
Prelude.Read, Int -> DataReplicationError -> ShowS
[DataReplicationError] -> ShowS
DataReplicationError -> String
(Int -> DataReplicationError -> ShowS)
-> (DataReplicationError -> String)
-> ([DataReplicationError] -> ShowS)
-> Show DataReplicationError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataReplicationError] -> ShowS
$cshowList :: [DataReplicationError] -> ShowS
show :: DataReplicationError -> String
$cshow :: DataReplicationError -> String
showsPrec :: Int -> DataReplicationError -> ShowS
$cshowsPrec :: Int -> DataReplicationError -> ShowS
Prelude.Show, (forall x. DataReplicationError -> Rep DataReplicationError x)
-> (forall x. Rep DataReplicationError x -> DataReplicationError)
-> Generic DataReplicationError
forall x. Rep DataReplicationError x -> DataReplicationError
forall x. DataReplicationError -> Rep DataReplicationError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataReplicationError x -> DataReplicationError
$cfrom :: forall x. DataReplicationError -> Rep DataReplicationError x
Prelude.Generic)

-- |
-- Create a value of 'DataReplicationError' 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:
--
-- 'rawError', 'dataReplicationError_rawError' - Error in data replication.
--
-- 'error', 'dataReplicationError_error' - Error in data replication.
newDataReplicationError ::
  DataReplicationError
newDataReplicationError :: DataReplicationError
newDataReplicationError =
  DataReplicationError' :: Maybe Text
-> Maybe DataReplicationErrorString -> DataReplicationError
DataReplicationError'
    { $sel:rawError:DataReplicationError' :: Maybe Text
rawError = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:error:DataReplicationError' :: Maybe DataReplicationErrorString
error = Maybe DataReplicationErrorString
forall a. Maybe a
Prelude.Nothing
    }

-- | Error in data replication.
dataReplicationError_rawError :: Lens.Lens' DataReplicationError (Prelude.Maybe Prelude.Text)
dataReplicationError_rawError :: (Maybe Text -> f (Maybe Text))
-> DataReplicationError -> f DataReplicationError
dataReplicationError_rawError = (DataReplicationError -> Maybe Text)
-> (DataReplicationError -> Maybe Text -> DataReplicationError)
-> Lens
     DataReplicationError DataReplicationError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataReplicationError' {Maybe Text
rawError :: Maybe Text
$sel:rawError:DataReplicationError' :: DataReplicationError -> Maybe Text
rawError} -> Maybe Text
rawError) (\s :: DataReplicationError
s@DataReplicationError' {} Maybe Text
a -> DataReplicationError
s {$sel:rawError:DataReplicationError' :: Maybe Text
rawError = Maybe Text
a} :: DataReplicationError)

-- | Error in data replication.
dataReplicationError_error :: Lens.Lens' DataReplicationError (Prelude.Maybe DataReplicationErrorString)
dataReplicationError_error :: (Maybe DataReplicationErrorString
 -> f (Maybe DataReplicationErrorString))
-> DataReplicationError -> f DataReplicationError
dataReplicationError_error = (DataReplicationError -> Maybe DataReplicationErrorString)
-> (DataReplicationError
    -> Maybe DataReplicationErrorString -> DataReplicationError)
-> Lens
     DataReplicationError
     DataReplicationError
     (Maybe DataReplicationErrorString)
     (Maybe DataReplicationErrorString)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataReplicationError' {Maybe DataReplicationErrorString
error :: Maybe DataReplicationErrorString
$sel:error:DataReplicationError' :: DataReplicationError -> Maybe DataReplicationErrorString
error} -> Maybe DataReplicationErrorString
error) (\s :: DataReplicationError
s@DataReplicationError' {} Maybe DataReplicationErrorString
a -> DataReplicationError
s {$sel:error:DataReplicationError' :: Maybe DataReplicationErrorString
error = Maybe DataReplicationErrorString
a} :: DataReplicationError)

instance Core.FromJSON DataReplicationError where
  parseJSON :: Value -> Parser DataReplicationError
parseJSON =
    String
-> (Object -> Parser DataReplicationError)
-> Value
-> Parser DataReplicationError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DataReplicationError"
      ( \Object
x ->
          Maybe Text
-> Maybe DataReplicationErrorString -> DataReplicationError
DataReplicationError'
            (Maybe Text
 -> Maybe DataReplicationErrorString -> DataReplicationError)
-> Parser (Maybe Text)
-> Parser
     (Maybe DataReplicationErrorString -> DataReplicationError)
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
"rawError")
            Parser (Maybe DataReplicationErrorString -> DataReplicationError)
-> Parser (Maybe DataReplicationErrorString)
-> Parser DataReplicationError
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DataReplicationErrorString)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"error")
      )

instance Prelude.Hashable DataReplicationError

instance Prelude.NFData DataReplicationError