{-# 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.ResourceGroups.Types.FailedResource
-- 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.ResourceGroups.Types.FailedResource 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

-- | A resource that failed to be added to or removed from a group.
--
-- /See:/ 'newFailedResource' smart constructor.
data FailedResource = FailedResource'
  { -- | The error code associated with the failure.
    FailedResource -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | The error message text associated with the failure.
    FailedResource -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the resource that failed to be added or removed.
    FailedResource -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text
  }
  deriving (FailedResource -> FailedResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailedResource -> FailedResource -> Bool
$c/= :: FailedResource -> FailedResource -> Bool
== :: FailedResource -> FailedResource -> Bool
$c== :: FailedResource -> FailedResource -> Bool
Prelude.Eq, ReadPrec [FailedResource]
ReadPrec FailedResource
Int -> ReadS FailedResource
ReadS [FailedResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailedResource]
$creadListPrec :: ReadPrec [FailedResource]
readPrec :: ReadPrec FailedResource
$creadPrec :: ReadPrec FailedResource
readList :: ReadS [FailedResource]
$creadList :: ReadS [FailedResource]
readsPrec :: Int -> ReadS FailedResource
$creadsPrec :: Int -> ReadS FailedResource
Prelude.Read, Int -> FailedResource -> ShowS
[FailedResource] -> ShowS
FailedResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailedResource] -> ShowS
$cshowList :: [FailedResource] -> ShowS
show :: FailedResource -> String
$cshow :: FailedResource -> String
showsPrec :: Int -> FailedResource -> ShowS
$cshowsPrec :: Int -> FailedResource -> ShowS
Prelude.Show, forall x. Rep FailedResource x -> FailedResource
forall x. FailedResource -> Rep FailedResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FailedResource x -> FailedResource
$cfrom :: forall x. FailedResource -> Rep FailedResource x
Prelude.Generic)

-- |
-- Create a value of 'FailedResource' 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', 'failedResource_errorCode' - The error code associated with the failure.
--
-- 'errorMessage', 'failedResource_errorMessage' - The error message text associated with the failure.
--
-- 'resourceArn', 'failedResource_resourceArn' - The ARN of the resource that failed to be added or removed.
newFailedResource ::
  FailedResource
newFailedResource :: FailedResource
newFailedResource =
  FailedResource'
    { $sel:errorCode:FailedResource' :: Maybe Text
errorCode = forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:FailedResource' :: Maybe Text
errorMessage = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:FailedResource' :: Maybe Text
resourceArn = forall a. Maybe a
Prelude.Nothing
    }

-- | The error code associated with the failure.
failedResource_errorCode :: Lens.Lens' FailedResource (Prelude.Maybe Prelude.Text)
failedResource_errorCode :: Lens' FailedResource (Maybe Text)
failedResource_errorCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailedResource' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:FailedResource' :: FailedResource -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: FailedResource
s@FailedResource' {} Maybe Text
a -> FailedResource
s {$sel:errorCode:FailedResource' :: Maybe Text
errorCode = Maybe Text
a} :: FailedResource)

-- | The error message text associated with the failure.
failedResource_errorMessage :: Lens.Lens' FailedResource (Prelude.Maybe Prelude.Text)
failedResource_errorMessage :: Lens' FailedResource (Maybe Text)
failedResource_errorMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailedResource' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:FailedResource' :: FailedResource -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: FailedResource
s@FailedResource' {} Maybe Text
a -> FailedResource
s {$sel:errorMessage:FailedResource' :: Maybe Text
errorMessage = Maybe Text
a} :: FailedResource)

-- | The ARN of the resource that failed to be added or removed.
failedResource_resourceArn :: Lens.Lens' FailedResource (Prelude.Maybe Prelude.Text)
failedResource_resourceArn :: Lens' FailedResource (Maybe Text)
failedResource_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailedResource' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:FailedResource' :: FailedResource -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: FailedResource
s@FailedResource' {} Maybe Text
a -> FailedResource
s {$sel:resourceArn:FailedResource' :: Maybe Text
resourceArn = Maybe Text
a} :: FailedResource)

instance Data.FromJSON FailedResource where
  parseJSON :: Value -> Parser FailedResource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FailedResource"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> FailedResource
FailedResource'
            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
"ErrorCode")
            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
"ErrorMessage")
            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
"ResourceArn")
      )

instance Prelude.Hashable FailedResource where
  hashWithSalt :: Int -> FailedResource -> Int
hashWithSalt Int
_salt FailedResource' {Maybe Text
resourceArn :: Maybe Text
errorMessage :: Maybe Text
errorCode :: Maybe Text
$sel:resourceArn:FailedResource' :: FailedResource -> Maybe Text
$sel:errorMessage:FailedResource' :: FailedResource -> Maybe Text
$sel:errorCode:FailedResource' :: FailedResource -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceArn

instance Prelude.NFData FailedResource where
  rnf :: FailedResource -> ()
rnf FailedResource' {Maybe Text
resourceArn :: Maybe Text
errorMessage :: Maybe Text
errorCode :: Maybe Text
$sel:resourceArn:FailedResource' :: FailedResource -> Maybe Text
$sel:errorMessage:FailedResource' :: FailedResource -> Maybe Text
$sel:errorCode:FailedResource' :: FailedResource -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceArn