{-# 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.OpsWorks.Types.ServiceError
-- 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.OpsWorks.Types.ServiceError where

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

-- | Describes an AWS OpsWorks Stacks service error.
--
-- /See:/ 'newServiceError' smart constructor.
data ServiceError = ServiceError'
  { -- | The instance ID.
    ServiceError -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | When the error occurred.
    ServiceError -> Maybe Text
createdAt :: Prelude.Maybe Prelude.Text,
    -- | The error ID.
    ServiceError -> Maybe Text
serviceErrorId :: Prelude.Maybe Prelude.Text,
    -- | The error type.
    ServiceError -> Maybe Text
type' :: Prelude.Maybe Prelude.Text,
    -- | The stack ID.
    ServiceError -> Maybe Text
stackId :: Prelude.Maybe Prelude.Text,
    -- | A message that describes the error.
    ServiceError -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (ServiceError -> ServiceError -> Bool
(ServiceError -> ServiceError -> Bool)
-> (ServiceError -> ServiceError -> Bool) -> Eq ServiceError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServiceError -> ServiceError -> Bool
$c/= :: ServiceError -> ServiceError -> Bool
== :: ServiceError -> ServiceError -> Bool
$c== :: ServiceError -> ServiceError -> Bool
Prelude.Eq, ReadPrec [ServiceError]
ReadPrec ServiceError
Int -> ReadS ServiceError
ReadS [ServiceError]
(Int -> ReadS ServiceError)
-> ReadS [ServiceError]
-> ReadPrec ServiceError
-> ReadPrec [ServiceError]
-> Read ServiceError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServiceError]
$creadListPrec :: ReadPrec [ServiceError]
readPrec :: ReadPrec ServiceError
$creadPrec :: ReadPrec ServiceError
readList :: ReadS [ServiceError]
$creadList :: ReadS [ServiceError]
readsPrec :: Int -> ReadS ServiceError
$creadsPrec :: Int -> ReadS ServiceError
Prelude.Read, Int -> ServiceError -> ShowS
[ServiceError] -> ShowS
ServiceError -> String
(Int -> ServiceError -> ShowS)
-> (ServiceError -> String)
-> ([ServiceError] -> ShowS)
-> Show ServiceError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServiceError] -> ShowS
$cshowList :: [ServiceError] -> ShowS
show :: ServiceError -> String
$cshow :: ServiceError -> String
showsPrec :: Int -> ServiceError -> ShowS
$cshowsPrec :: Int -> ServiceError -> ShowS
Prelude.Show, (forall x. ServiceError -> Rep ServiceError x)
-> (forall x. Rep ServiceError x -> ServiceError)
-> Generic ServiceError
forall x. Rep ServiceError x -> ServiceError
forall x. ServiceError -> Rep ServiceError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ServiceError x -> ServiceError
$cfrom :: forall x. ServiceError -> Rep ServiceError x
Prelude.Generic)

-- |
-- Create a value of 'ServiceError' 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:
--
-- 'instanceId', 'serviceError_instanceId' - The instance ID.
--
-- 'createdAt', 'serviceError_createdAt' - When the error occurred.
--
-- 'serviceErrorId', 'serviceError_serviceErrorId' - The error ID.
--
-- 'type'', 'serviceError_type' - The error type.
--
-- 'stackId', 'serviceError_stackId' - The stack ID.
--
-- 'message', 'serviceError_message' - A message that describes the error.
newServiceError ::
  ServiceError
newServiceError :: ServiceError
newServiceError =
  ServiceError' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> ServiceError
ServiceError'
    { $sel:instanceId:ServiceError' :: Maybe Text
instanceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdAt:ServiceError' :: Maybe Text
createdAt = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceErrorId:ServiceError' :: Maybe Text
serviceErrorId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':ServiceError' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:stackId:ServiceError' :: Maybe Text
stackId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:message:ServiceError' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The instance ID.
serviceError_instanceId :: Lens.Lens' ServiceError (Prelude.Maybe Prelude.Text)
serviceError_instanceId :: (Maybe Text -> f (Maybe Text)) -> ServiceError -> f ServiceError
serviceError_instanceId = (ServiceError -> Maybe Text)
-> (ServiceError -> Maybe Text -> ServiceError)
-> Lens ServiceError ServiceError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceError' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:ServiceError' :: ServiceError -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: ServiceError
s@ServiceError' {} Maybe Text
a -> ServiceError
s {$sel:instanceId:ServiceError' :: Maybe Text
instanceId = Maybe Text
a} :: ServiceError)

-- | When the error occurred.
serviceError_createdAt :: Lens.Lens' ServiceError (Prelude.Maybe Prelude.Text)
serviceError_createdAt :: (Maybe Text -> f (Maybe Text)) -> ServiceError -> f ServiceError
serviceError_createdAt = (ServiceError -> Maybe Text)
-> (ServiceError -> Maybe Text -> ServiceError)
-> Lens ServiceError ServiceError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceError' {Maybe Text
createdAt :: Maybe Text
$sel:createdAt:ServiceError' :: ServiceError -> Maybe Text
createdAt} -> Maybe Text
createdAt) (\s :: ServiceError
s@ServiceError' {} Maybe Text
a -> ServiceError
s {$sel:createdAt:ServiceError' :: Maybe Text
createdAt = Maybe Text
a} :: ServiceError)

-- | The error ID.
serviceError_serviceErrorId :: Lens.Lens' ServiceError (Prelude.Maybe Prelude.Text)
serviceError_serviceErrorId :: (Maybe Text -> f (Maybe Text)) -> ServiceError -> f ServiceError
serviceError_serviceErrorId = (ServiceError -> Maybe Text)
-> (ServiceError -> Maybe Text -> ServiceError)
-> Lens ServiceError ServiceError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceError' {Maybe Text
serviceErrorId :: Maybe Text
$sel:serviceErrorId:ServiceError' :: ServiceError -> Maybe Text
serviceErrorId} -> Maybe Text
serviceErrorId) (\s :: ServiceError
s@ServiceError' {} Maybe Text
a -> ServiceError
s {$sel:serviceErrorId:ServiceError' :: Maybe Text
serviceErrorId = Maybe Text
a} :: ServiceError)

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

-- | The stack ID.
serviceError_stackId :: Lens.Lens' ServiceError (Prelude.Maybe Prelude.Text)
serviceError_stackId :: (Maybe Text -> f (Maybe Text)) -> ServiceError -> f ServiceError
serviceError_stackId = (ServiceError -> Maybe Text)
-> (ServiceError -> Maybe Text -> ServiceError)
-> Lens ServiceError ServiceError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceError' {Maybe Text
stackId :: Maybe Text
$sel:stackId:ServiceError' :: ServiceError -> Maybe Text
stackId} -> Maybe Text
stackId) (\s :: ServiceError
s@ServiceError' {} Maybe Text
a -> ServiceError
s {$sel:stackId:ServiceError' :: Maybe Text
stackId = Maybe Text
a} :: ServiceError)

-- | A message that describes the error.
serviceError_message :: Lens.Lens' ServiceError (Prelude.Maybe Prelude.Text)
serviceError_message :: (Maybe Text -> f (Maybe Text)) -> ServiceError -> f ServiceError
serviceError_message = (ServiceError -> Maybe Text)
-> (ServiceError -> Maybe Text -> ServiceError)
-> Lens ServiceError ServiceError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceError' {Maybe Text
message :: Maybe Text
$sel:message:ServiceError' :: ServiceError -> Maybe Text
message} -> Maybe Text
message) (\s :: ServiceError
s@ServiceError' {} Maybe Text
a -> ServiceError
s {$sel:message:ServiceError' :: Maybe Text
message = Maybe Text
a} :: ServiceError)

instance Core.FromJSON ServiceError where
  parseJSON :: Value -> Parser ServiceError
parseJSON =
    String
-> (Object -> Parser ServiceError) -> Value -> Parser ServiceError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ServiceError"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> ServiceError
ServiceError'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> ServiceError)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> ServiceError)
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
"InstanceId")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> ServiceError)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> ServiceError)
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
"CreatedAt")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> ServiceError)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> ServiceError)
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
"ServiceErrorId")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> ServiceError)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> ServiceError)
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
"Type")
            Parser (Maybe Text -> Maybe Text -> ServiceError)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ServiceError)
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
"StackId")
            Parser (Maybe Text -> ServiceError)
-> Parser (Maybe Text) -> Parser ServiceError
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
"Message")
      )

instance Prelude.Hashable ServiceError

instance Prelude.NFData ServiceError