{-# 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.ComputeOptimizer.Types.GetRecommendationError
-- 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.ComputeOptimizer.Types.GetRecommendationError where

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

-- | Describes an error experienced when getting recommendations.
--
-- For example, an error is returned if you request recommendations for an
-- unsupported Auto Scaling group, or if you request recommendations for an
-- instance of an unsupported instance family.
--
-- /See:/ 'newGetRecommendationError' smart constructor.
data GetRecommendationError = GetRecommendationError'
  { -- | The ID of the error.
    GetRecommendationError -> Maybe Text
identifier :: Prelude.Maybe Prelude.Text,
    -- | The error code.
    GetRecommendationError -> Maybe Text
code :: Prelude.Maybe Prelude.Text,
    -- | The message, or reason, for the error.
    GetRecommendationError -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (GetRecommendationError -> GetRecommendationError -> Bool
(GetRecommendationError -> GetRecommendationError -> Bool)
-> (GetRecommendationError -> GetRecommendationError -> Bool)
-> Eq GetRecommendationError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRecommendationError -> GetRecommendationError -> Bool
$c/= :: GetRecommendationError -> GetRecommendationError -> Bool
== :: GetRecommendationError -> GetRecommendationError -> Bool
$c== :: GetRecommendationError -> GetRecommendationError -> Bool
Prelude.Eq, ReadPrec [GetRecommendationError]
ReadPrec GetRecommendationError
Int -> ReadS GetRecommendationError
ReadS [GetRecommendationError]
(Int -> ReadS GetRecommendationError)
-> ReadS [GetRecommendationError]
-> ReadPrec GetRecommendationError
-> ReadPrec [GetRecommendationError]
-> Read GetRecommendationError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRecommendationError]
$creadListPrec :: ReadPrec [GetRecommendationError]
readPrec :: ReadPrec GetRecommendationError
$creadPrec :: ReadPrec GetRecommendationError
readList :: ReadS [GetRecommendationError]
$creadList :: ReadS [GetRecommendationError]
readsPrec :: Int -> ReadS GetRecommendationError
$creadsPrec :: Int -> ReadS GetRecommendationError
Prelude.Read, Int -> GetRecommendationError -> ShowS
[GetRecommendationError] -> ShowS
GetRecommendationError -> String
(Int -> GetRecommendationError -> ShowS)
-> (GetRecommendationError -> String)
-> ([GetRecommendationError] -> ShowS)
-> Show GetRecommendationError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRecommendationError] -> ShowS
$cshowList :: [GetRecommendationError] -> ShowS
show :: GetRecommendationError -> String
$cshow :: GetRecommendationError -> String
showsPrec :: Int -> GetRecommendationError -> ShowS
$cshowsPrec :: Int -> GetRecommendationError -> ShowS
Prelude.Show, (forall x. GetRecommendationError -> Rep GetRecommendationError x)
-> (forall x.
    Rep GetRecommendationError x -> GetRecommendationError)
-> Generic GetRecommendationError
forall x. Rep GetRecommendationError x -> GetRecommendationError
forall x. GetRecommendationError -> Rep GetRecommendationError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRecommendationError x -> GetRecommendationError
$cfrom :: forall x. GetRecommendationError -> Rep GetRecommendationError x
Prelude.Generic)

-- |
-- Create a value of 'GetRecommendationError' 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:
--
-- 'identifier', 'getRecommendationError_identifier' - The ID of the error.
--
-- 'code', 'getRecommendationError_code' - The error code.
--
-- 'message', 'getRecommendationError_message' - The message, or reason, for the error.
newGetRecommendationError ::
  GetRecommendationError
newGetRecommendationError :: GetRecommendationError
newGetRecommendationError =
  GetRecommendationError' :: Maybe Text -> Maybe Text -> Maybe Text -> GetRecommendationError
GetRecommendationError'
    { $sel:identifier:GetRecommendationError' :: Maybe Text
identifier =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:code:GetRecommendationError' :: Maybe Text
code = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:message:GetRecommendationError' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the error.
getRecommendationError_identifier :: Lens.Lens' GetRecommendationError (Prelude.Maybe Prelude.Text)
getRecommendationError_identifier :: (Maybe Text -> f (Maybe Text))
-> GetRecommendationError -> f GetRecommendationError
getRecommendationError_identifier = (GetRecommendationError -> Maybe Text)
-> (GetRecommendationError -> Maybe Text -> GetRecommendationError)
-> Lens
     GetRecommendationError
     GetRecommendationError
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecommendationError' {Maybe Text
identifier :: Maybe Text
$sel:identifier:GetRecommendationError' :: GetRecommendationError -> Maybe Text
identifier} -> Maybe Text
identifier) (\s :: GetRecommendationError
s@GetRecommendationError' {} Maybe Text
a -> GetRecommendationError
s {$sel:identifier:GetRecommendationError' :: Maybe Text
identifier = Maybe Text
a} :: GetRecommendationError)

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

-- | The message, or reason, for the error.
getRecommendationError_message :: Lens.Lens' GetRecommendationError (Prelude.Maybe Prelude.Text)
getRecommendationError_message :: (Maybe Text -> f (Maybe Text))
-> GetRecommendationError -> f GetRecommendationError
getRecommendationError_message = (GetRecommendationError -> Maybe Text)
-> (GetRecommendationError -> Maybe Text -> GetRecommendationError)
-> Lens
     GetRecommendationError
     GetRecommendationError
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRecommendationError' {Maybe Text
message :: Maybe Text
$sel:message:GetRecommendationError' :: GetRecommendationError -> Maybe Text
message} -> Maybe Text
message) (\s :: GetRecommendationError
s@GetRecommendationError' {} Maybe Text
a -> GetRecommendationError
s {$sel:message:GetRecommendationError' :: Maybe Text
message = Maybe Text
a} :: GetRecommendationError)

instance Core.FromJSON GetRecommendationError where
  parseJSON :: Value -> Parser GetRecommendationError
parseJSON =
    String
-> (Object -> Parser GetRecommendationError)
-> Value
-> Parser GetRecommendationError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GetRecommendationError"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> GetRecommendationError
GetRecommendationError'
            (Maybe Text -> Maybe Text -> Maybe Text -> GetRecommendationError)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> GetRecommendationError)
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
"identifier")
            Parser (Maybe Text -> Maybe Text -> GetRecommendationError)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> GetRecommendationError)
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
"code")
            Parser (Maybe Text -> GetRecommendationError)
-> Parser (Maybe Text) -> Parser GetRecommendationError
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 GetRecommendationError

instance Prelude.NFData GetRecommendationError