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

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

-- | Information about a failed world.
--
-- /See:/ 'newWorldFailure' smart constructor.
data WorldFailure = WorldFailure'
  { -- | 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,
    -- | 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
  }
  deriving (WorldFailure -> WorldFailure -> Bool
(WorldFailure -> WorldFailure -> Bool)
-> (WorldFailure -> WorldFailure -> Bool) -> Eq WorldFailure
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]
(Int -> ReadS WorldFailure)
-> ReadS [WorldFailure]
-> ReadPrec WorldFailure
-> ReadPrec [WorldFailure]
-> Read 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
(Int -> WorldFailure -> ShowS)
-> (WorldFailure -> String)
-> ([WorldFailure] -> ShowS)
-> Show WorldFailure
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. WorldFailure -> Rep WorldFailure x)
-> (forall x. Rep WorldFailure x -> WorldFailure)
-> Generic WorldFailure
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:
--
-- 'sampleFailureReason', 'worldFailure_sampleFailureReason' - The sample reason why the world failed. World errors are aggregated. A
-- sample is used as the @sampleFailureReason@.
--
-- '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.
newWorldFailure ::
  WorldFailure
newWorldFailure :: WorldFailure
newWorldFailure =
  WorldFailure' :: Maybe Text
-> Maybe WorldGenerationJobErrorCode -> Maybe Int -> WorldFailure
WorldFailure'
    { $sel:sampleFailureReason:WorldFailure' :: Maybe Text
sampleFailureReason =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:failureCode:WorldFailure' :: Maybe WorldGenerationJobErrorCode
failureCode = Maybe WorldGenerationJobErrorCode
forall a. Maybe a
Prelude.Nothing,
      $sel:failureCount:WorldFailure' :: Maybe Int
failureCount = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> WorldFailure -> f WorldFailure
worldFailure_sampleFailureReason = (WorldFailure -> Maybe Text)
-> (WorldFailure -> Maybe Text -> WorldFailure)
-> Lens WorldFailure WorldFailure (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe WorldGenerationJobErrorCode
 -> f (Maybe WorldGenerationJobErrorCode))
-> WorldFailure -> f WorldFailure
worldFailure_failureCode = (WorldFailure -> Maybe WorldGenerationJobErrorCode)
-> (WorldFailure
    -> Maybe WorldGenerationJobErrorCode -> WorldFailure)
-> Lens
     WorldFailure
     WorldFailure
     (Maybe WorldGenerationJobErrorCode)
     (Maybe WorldGenerationJobErrorCode)
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 :: (Maybe Int -> f (Maybe Int)) -> WorldFailure -> f WorldFailure
worldFailure_failureCount = (WorldFailure -> Maybe Int)
-> (WorldFailure -> Maybe Int -> WorldFailure)
-> Lens WorldFailure WorldFailure (Maybe Int) (Maybe Int)
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)

instance Core.FromJSON WorldFailure where
  parseJSON :: Value -> Parser WorldFailure
parseJSON =
    String
-> (Object -> Parser WorldFailure) -> Value -> Parser WorldFailure
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WorldFailure"
      ( \Object
x ->
          Maybe Text
-> Maybe WorldGenerationJobErrorCode -> Maybe Int -> WorldFailure
WorldFailure'
            (Maybe Text
 -> Maybe WorldGenerationJobErrorCode -> Maybe Int -> WorldFailure)
-> Parser (Maybe Text)
-> Parser
     (Maybe WorldGenerationJobErrorCode -> Maybe Int -> WorldFailure)
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
"sampleFailureReason")
            Parser
  (Maybe WorldGenerationJobErrorCode -> Maybe Int -> WorldFailure)
-> Parser (Maybe WorldGenerationJobErrorCode)
-> Parser (Maybe Int -> WorldFailure)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe WorldGenerationJobErrorCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"failureCode")
            Parser (Maybe Int -> WorldFailure)
-> Parser (Maybe Int) -> Parser WorldFailure
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"failureCount")
      )

instance Prelude.Hashable WorldFailure

instance Prelude.NFData WorldFailure