{-# 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.EC2.Types.LastError
-- 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.EC2.Types.LastError where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import qualified Amazonka.Prelude as Prelude

-- | The last error that occurred for a VPC endpoint.
--
-- /See:/ 'newLastError' smart constructor.
data LastError = LastError'
  { -- | The error code for the VPC endpoint error.
    LastError -> Maybe Text
code :: Prelude.Maybe Prelude.Text,
    -- | The error message for the VPC endpoint error.
    LastError -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (LastError -> LastError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LastError -> LastError -> Bool
$c/= :: LastError -> LastError -> Bool
== :: LastError -> LastError -> Bool
$c== :: LastError -> LastError -> Bool
Prelude.Eq, ReadPrec [LastError]
ReadPrec LastError
Int -> ReadS LastError
ReadS [LastError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LastError]
$creadListPrec :: ReadPrec [LastError]
readPrec :: ReadPrec LastError
$creadPrec :: ReadPrec LastError
readList :: ReadS [LastError]
$creadList :: ReadS [LastError]
readsPrec :: Int -> ReadS LastError
$creadsPrec :: Int -> ReadS LastError
Prelude.Read, Int -> LastError -> ShowS
[LastError] -> ShowS
LastError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LastError] -> ShowS
$cshowList :: [LastError] -> ShowS
show :: LastError -> String
$cshow :: LastError -> String
showsPrec :: Int -> LastError -> ShowS
$cshowsPrec :: Int -> LastError -> ShowS
Prelude.Show, forall x. Rep LastError x -> LastError
forall x. LastError -> Rep LastError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LastError x -> LastError
$cfrom :: forall x. LastError -> Rep LastError x
Prelude.Generic)

-- |
-- Create a value of 'LastError' 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:
--
-- 'code', 'lastError_code' - The error code for the VPC endpoint error.
--
-- 'message', 'lastError_message' - The error message for the VPC endpoint error.
newLastError ::
  LastError
newLastError :: LastError
newLastError =
  LastError'
    { $sel:code:LastError' :: Maybe Text
code = forall a. Maybe a
Prelude.Nothing,
      $sel:message:LastError' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing
    }

-- | The error code for the VPC endpoint error.
lastError_code :: Lens.Lens' LastError (Prelude.Maybe Prelude.Text)
lastError_code :: Lens' LastError (Maybe Text)
lastError_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LastError' {Maybe Text
code :: Maybe Text
$sel:code:LastError' :: LastError -> Maybe Text
code} -> Maybe Text
code) (\s :: LastError
s@LastError' {} Maybe Text
a -> LastError
s {$sel:code:LastError' :: Maybe Text
code = Maybe Text
a} :: LastError)

-- | The error message for the VPC endpoint error.
lastError_message :: Lens.Lens' LastError (Prelude.Maybe Prelude.Text)
lastError_message :: Lens' LastError (Maybe Text)
lastError_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LastError' {Maybe Text
message :: Maybe Text
$sel:message:LastError' :: LastError -> Maybe Text
message} -> Maybe Text
message) (\s :: LastError
s@LastError' {} Maybe Text
a -> LastError
s {$sel:message:LastError' :: Maybe Text
message = Maybe Text
a} :: LastError)

instance Data.FromXML LastError where
  parseXML :: [Node] -> Either String LastError
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> LastError
LastError'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"code")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"message")

instance Prelude.Hashable LastError where
  hashWithSalt :: Int -> LastError -> Int
hashWithSalt Int
_salt LastError' {Maybe Text
message :: Maybe Text
code :: Maybe Text
$sel:message:LastError' :: LastError -> Maybe Text
$sel:code:LastError' :: LastError -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message

instance Prelude.NFData LastError where
  rnf :: LastError -> ()
rnf LastError' {Maybe Text
message :: Maybe Text
code :: Maybe Text
$sel:message:LastError' :: LastError -> Maybe Text
$sel:code:LastError' :: LastError -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
code seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message