{-# 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.AppStream.Types.ResourceError
-- 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.AppStream.Types.ResourceError where

import Amazonka.AppStream.Types.FleetErrorCode
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a resource error.
--
-- /See:/ 'newResourceError' smart constructor.
data ResourceError = ResourceError'
  { -- | The error code.
    ResourceError -> Maybe FleetErrorCode
errorCode :: Prelude.Maybe FleetErrorCode,
    -- | The error message.
    ResourceError -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | The time the error occurred.
    ResourceError -> Maybe POSIX
errorTimestamp :: Prelude.Maybe Core.POSIX
  }
  deriving (ResourceError -> ResourceError -> Bool
(ResourceError -> ResourceError -> Bool)
-> (ResourceError -> ResourceError -> Bool) -> Eq ResourceError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceError -> ResourceError -> Bool
$c/= :: ResourceError -> ResourceError -> Bool
== :: ResourceError -> ResourceError -> Bool
$c== :: ResourceError -> ResourceError -> Bool
Prelude.Eq, ReadPrec [ResourceError]
ReadPrec ResourceError
Int -> ReadS ResourceError
ReadS [ResourceError]
(Int -> ReadS ResourceError)
-> ReadS [ResourceError]
-> ReadPrec ResourceError
-> ReadPrec [ResourceError]
-> Read ResourceError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceError]
$creadListPrec :: ReadPrec [ResourceError]
readPrec :: ReadPrec ResourceError
$creadPrec :: ReadPrec ResourceError
readList :: ReadS [ResourceError]
$creadList :: ReadS [ResourceError]
readsPrec :: Int -> ReadS ResourceError
$creadsPrec :: Int -> ReadS ResourceError
Prelude.Read, Int -> ResourceError -> ShowS
[ResourceError] -> ShowS
ResourceError -> String
(Int -> ResourceError -> ShowS)
-> (ResourceError -> String)
-> ([ResourceError] -> ShowS)
-> Show ResourceError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceError] -> ShowS
$cshowList :: [ResourceError] -> ShowS
show :: ResourceError -> String
$cshow :: ResourceError -> String
showsPrec :: Int -> ResourceError -> ShowS
$cshowsPrec :: Int -> ResourceError -> ShowS
Prelude.Show, (forall x. ResourceError -> Rep ResourceError x)
-> (forall x. Rep ResourceError x -> ResourceError)
-> Generic ResourceError
forall x. Rep ResourceError x -> ResourceError
forall x. ResourceError -> Rep ResourceError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceError x -> ResourceError
$cfrom :: forall x. ResourceError -> Rep ResourceError x
Prelude.Generic)

-- |
-- Create a value of 'ResourceError' 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:
--
-- 'errorCode', 'resourceError_errorCode' - The error code.
--
-- 'errorMessage', 'resourceError_errorMessage' - The error message.
--
-- 'errorTimestamp', 'resourceError_errorTimestamp' - The time the error occurred.
newResourceError ::
  ResourceError
newResourceError :: ResourceError
newResourceError =
  ResourceError' :: Maybe FleetErrorCode -> Maybe Text -> Maybe POSIX -> ResourceError
ResourceError'
    { $sel:errorCode:ResourceError' :: Maybe FleetErrorCode
errorCode = Maybe FleetErrorCode
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:ResourceError' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorTimestamp:ResourceError' :: Maybe POSIX
errorTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The error code.
resourceError_errorCode :: Lens.Lens' ResourceError (Prelude.Maybe FleetErrorCode)
resourceError_errorCode :: (Maybe FleetErrorCode -> f (Maybe FleetErrorCode))
-> ResourceError -> f ResourceError
resourceError_errorCode = (ResourceError -> Maybe FleetErrorCode)
-> (ResourceError -> Maybe FleetErrorCode -> ResourceError)
-> Lens
     ResourceError
     ResourceError
     (Maybe FleetErrorCode)
     (Maybe FleetErrorCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceError' {Maybe FleetErrorCode
errorCode :: Maybe FleetErrorCode
$sel:errorCode:ResourceError' :: ResourceError -> Maybe FleetErrorCode
errorCode} -> Maybe FleetErrorCode
errorCode) (\s :: ResourceError
s@ResourceError' {} Maybe FleetErrorCode
a -> ResourceError
s {$sel:errorCode:ResourceError' :: Maybe FleetErrorCode
errorCode = Maybe FleetErrorCode
a} :: ResourceError)

-- | The error message.
resourceError_errorMessage :: Lens.Lens' ResourceError (Prelude.Maybe Prelude.Text)
resourceError_errorMessage :: (Maybe Text -> f (Maybe Text)) -> ResourceError -> f ResourceError
resourceError_errorMessage = (ResourceError -> Maybe Text)
-> (ResourceError -> Maybe Text -> ResourceError)
-> Lens ResourceError ResourceError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceError' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:ResourceError' :: ResourceError -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: ResourceError
s@ResourceError' {} Maybe Text
a -> ResourceError
s {$sel:errorMessage:ResourceError' :: Maybe Text
errorMessage = Maybe Text
a} :: ResourceError)

-- | The time the error occurred.
resourceError_errorTimestamp :: Lens.Lens' ResourceError (Prelude.Maybe Prelude.UTCTime)
resourceError_errorTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ResourceError -> f ResourceError
resourceError_errorTimestamp = (ResourceError -> Maybe POSIX)
-> (ResourceError -> Maybe POSIX -> ResourceError)
-> Lens ResourceError ResourceError (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceError' {Maybe POSIX
errorTimestamp :: Maybe POSIX
$sel:errorTimestamp:ResourceError' :: ResourceError -> Maybe POSIX
errorTimestamp} -> Maybe POSIX
errorTimestamp) (\s :: ResourceError
s@ResourceError' {} Maybe POSIX
a -> ResourceError
s {$sel:errorTimestamp:ResourceError' :: Maybe POSIX
errorTimestamp = Maybe POSIX
a} :: ResourceError) ((Maybe POSIX -> f (Maybe POSIX))
 -> ResourceError -> f ResourceError)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ResourceError
-> f ResourceError
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON ResourceError where
  parseJSON :: Value -> Parser ResourceError
parseJSON =
    String
-> (Object -> Parser ResourceError)
-> Value
-> Parser ResourceError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceError"
      ( \Object
x ->
          Maybe FleetErrorCode -> Maybe Text -> Maybe POSIX -> ResourceError
ResourceError'
            (Maybe FleetErrorCode
 -> Maybe Text -> Maybe POSIX -> ResourceError)
-> Parser (Maybe FleetErrorCode)
-> Parser (Maybe Text -> Maybe POSIX -> ResourceError)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe FleetErrorCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ErrorCode")
            Parser (Maybe Text -> Maybe POSIX -> ResourceError)
-> Parser (Maybe Text) -> Parser (Maybe POSIX -> ResourceError)
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")
            Parser (Maybe POSIX -> ResourceError)
-> Parser (Maybe POSIX) -> Parser ResourceError
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ErrorTimestamp")
      )

instance Prelude.Hashable ResourceError

instance Prelude.NFData ResourceError