{-# 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.RobOMaker.Types.WorldFailure
-- 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.RobOMaker.Types.WorldFailure where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.RobOMaker.Types.WorldGenerationJobErrorCode

-- | Information about a failed world.
--
-- /See:/ 'newWorldFailure' smart constructor.
data WorldFailure = WorldFailure'
  { -- | The failure code of the world export job if it failed:
    --
    -- [InternalServiceError]
    --     Internal service error.
    --
    -- [LimitExceeded]
    --     The requested resource exceeds the maximum number allowed, or the
    --     number of concurrent stream requests exceeds the maximum number
    --     allowed.
    --
    -- [ResourceNotFound]
    --     The specified resource could not be found.
    --
    -- [RequestThrottled]
    --     The request was throttled.
    --
    -- [InvalidInput]
    --     An input parameter in the request is not valid.
    WorldFailure -> Maybe WorldGenerationJobErrorCode
failureCode :: Prelude.Maybe WorldGenerationJobErrorCode,
    -- | The number of failed worlds.
    WorldFailure -> Maybe Int
failureCount :: Prelude.Maybe Prelude.Int,
    -- | The sample reason why the world failed. World errors are aggregated. A
    -- sample is used as the @sampleFailureReason@.
    WorldFailure -> Maybe Text
sampleFailureReason :: Prelude.Maybe Prelude.Text
  }
  deriving (WorldFailure -> WorldFailure -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorldFailure -> WorldFailure -> Bool
$c/= :: WorldFailure -> WorldFailure -> Bool
== :: WorldFailure -> WorldFailure -> Bool
$c== :: WorldFailure -> WorldFailure -> Bool
Prelude.Eq, ReadPrec [WorldFailure]
ReadPrec WorldFailure
Int -> ReadS WorldFailure
ReadS [WorldFailure]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorldFailure]
$creadListPrec :: ReadPrec [WorldFailure]
readPrec :: ReadPrec WorldFailure
$creadPrec :: ReadPrec WorldFailure
readList :: ReadS [WorldFailure]
$creadList :: ReadS [WorldFailure]
readsPrec :: Int -> ReadS WorldFailure
$creadsPrec :: Int -> ReadS WorldFailure
Prelude.Read, Int -> WorldFailure -> ShowS
[WorldFailure] -> ShowS
WorldFailure -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorldFailure] -> ShowS
$cshowList :: [WorldFailure] -> ShowS
show :: WorldFailure -> String
$cshow :: WorldFailure -> String
showsPrec :: Int -> WorldFailure -> ShowS
$cshowsPrec :: Int -> WorldFailure -> ShowS
Prelude.Show, forall x. Rep WorldFailure x -> WorldFailure
forall x. WorldFailure -> Rep WorldFailure x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WorldFailure x -> WorldFailure
$cfrom :: forall x. WorldFailure -> Rep WorldFailure x
Prelude.Generic)

-- |
-- Create a value of 'WorldFailure' 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:
--
-- 'failureCode', 'worldFailure_failureCode' - The failure code of the world export job if it failed:
--
-- [InternalServiceError]
--     Internal service error.
--
-- [LimitExceeded]
--     The requested resource exceeds the maximum number allowed, or the
--     number of concurrent stream requests exceeds the maximum number
--     allowed.
--
-- [ResourceNotFound]
--     The specified resource could not be found.
--
-- [RequestThrottled]
--     The request was throttled.
--
-- [InvalidInput]
--     An input parameter in the request is not valid.
--
-- 'failureCount', 'worldFailure_failureCount' - The number of failed worlds.
--
-- 'sampleFailureReason', 'worldFailure_sampleFailureReason' - The sample reason why the world failed. World errors are aggregated. A
-- sample is used as the @sampleFailureReason@.
newWorldFailure ::
  WorldFailure
newWorldFailure :: WorldFailure
newWorldFailure =
  WorldFailure'
    { $sel:failureCode:WorldFailure' :: Maybe WorldGenerationJobErrorCode
failureCode = forall a. Maybe a
Prelude.Nothing,
      $sel:failureCount:WorldFailure' :: Maybe Int
failureCount = forall a. Maybe a
Prelude.Nothing,
      $sel:sampleFailureReason:WorldFailure' :: Maybe Text
sampleFailureReason = forall a. Maybe a
Prelude.Nothing
    }

-- | The failure code of the world export job if it failed:
--
-- [InternalServiceError]
--     Internal service error.
--
-- [LimitExceeded]
--     The requested resource exceeds the maximum number allowed, or the
--     number of concurrent stream requests exceeds the maximum number
--     allowed.
--
-- [ResourceNotFound]
--     The specified resource could not be found.
--
-- [RequestThrottled]
--     The request was throttled.
--
-- [InvalidInput]
--     An input parameter in the request is not valid.
worldFailure_failureCode :: Lens.Lens' WorldFailure (Prelude.Maybe WorldGenerationJobErrorCode)
worldFailure_failureCode :: Lens' WorldFailure (Maybe WorldGenerationJobErrorCode)
worldFailure_failureCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorldFailure' {Maybe WorldGenerationJobErrorCode
failureCode :: Maybe WorldGenerationJobErrorCode
$sel:failureCode:WorldFailure' :: WorldFailure -> Maybe WorldGenerationJobErrorCode
failureCode} -> Maybe WorldGenerationJobErrorCode
failureCode) (\s :: WorldFailure
s@WorldFailure' {} Maybe WorldGenerationJobErrorCode
a -> WorldFailure
s {$sel:failureCode:WorldFailure' :: Maybe WorldGenerationJobErrorCode
failureCode = Maybe WorldGenerationJobErrorCode
a} :: WorldFailure)

-- | The number of failed worlds.
worldFailure_failureCount :: Lens.Lens' WorldFailure (Prelude.Maybe Prelude.Int)
worldFailure_failureCount :: Lens' WorldFailure (Maybe Int)
worldFailure_failureCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorldFailure' {Maybe Int
failureCount :: Maybe Int
$sel:failureCount:WorldFailure' :: WorldFailure -> Maybe Int
failureCount} -> Maybe Int
failureCount) (\s :: WorldFailure
s@WorldFailure' {} Maybe Int
a -> WorldFailure
s {$sel:failureCount:WorldFailure' :: Maybe Int
failureCount = Maybe Int
a} :: WorldFailure)

-- | The sample reason why the world failed. World errors are aggregated. A
-- sample is used as the @sampleFailureReason@.
worldFailure_sampleFailureReason :: Lens.Lens' WorldFailure (Prelude.Maybe Prelude.Text)
worldFailure_sampleFailureReason :: Lens' WorldFailure (Maybe Text)
worldFailure_sampleFailureReason = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorldFailure' {Maybe Text
sampleFailureReason :: Maybe Text
$sel:sampleFailureReason:WorldFailure' :: WorldFailure -> Maybe Text
sampleFailureReason} -> Maybe Text
sampleFailureReason) (\s :: WorldFailure
s@WorldFailure' {} Maybe Text
a -> WorldFailure
s {$sel:sampleFailureReason:WorldFailure' :: Maybe Text
sampleFailureReason = Maybe Text
a} :: WorldFailure)

instance Data.FromJSON WorldFailure where
  parseJSON :: Value -> Parser WorldFailure
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WorldFailure"
      ( \Object
x ->
          Maybe WorldGenerationJobErrorCode
-> Maybe Int -> Maybe Text -> WorldFailure
WorldFailure'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"failureCode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"failureCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"sampleFailureReason")
      )

instance Prelude.Hashable WorldFailure where
  hashWithSalt :: Int -> WorldFailure -> Int
hashWithSalt Int
_salt WorldFailure' {Maybe Int
Maybe Text
Maybe WorldGenerationJobErrorCode
sampleFailureReason :: Maybe Text
failureCount :: Maybe Int
failureCode :: Maybe WorldGenerationJobErrorCode
$sel:sampleFailureReason:WorldFailure' :: WorldFailure -> Maybe Text
$sel:failureCount:WorldFailure' :: WorldFailure -> Maybe Int
$sel:failureCode:WorldFailure' :: WorldFailure -> Maybe WorldGenerationJobErrorCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe WorldGenerationJobErrorCode
failureCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
failureCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sampleFailureReason

instance Prelude.NFData WorldFailure where
  rnf :: WorldFailure -> ()
rnf WorldFailure' {Maybe Int
Maybe Text
Maybe WorldGenerationJobErrorCode
sampleFailureReason :: Maybe Text
failureCount :: Maybe Int
failureCode :: Maybe WorldGenerationJobErrorCode
$sel:sampleFailureReason:WorldFailure' :: WorldFailure -> Maybe Text
$sel:failureCount:WorldFailure' :: WorldFailure -> Maybe Int
$sel:failureCode:WorldFailure' :: WorldFailure -> Maybe WorldGenerationJobErrorCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe WorldGenerationJobErrorCode
failureCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
failureCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sampleFailureReason