{-# 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.EC2.Types.ValidationError
-- 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.EC2.Types.ValidationError where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import qualified Amazonka.Prelude as Prelude

-- | The error code and error message that is returned for a parameter or
-- parameter combination that is not valid when a new launch template or
-- new version of a launch template is created.
--
-- /See:/ 'newValidationError' smart constructor.
data ValidationError = ValidationError'
  { -- | The error code that indicates why the parameter or parameter combination
    -- is not valid. For more information about error codes, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html Error codes>.
    ValidationError -> Maybe Text
code :: Prelude.Maybe Prelude.Text,
    -- | The error message that describes why the parameter or parameter
    -- combination is not valid. For more information about error messages, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html Error codes>.
    ValidationError -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (ValidationError -> ValidationError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ValidationError -> ValidationError -> Bool
$c/= :: ValidationError -> ValidationError -> Bool
== :: ValidationError -> ValidationError -> Bool
$c== :: ValidationError -> ValidationError -> Bool
Prelude.Eq, ReadPrec [ValidationError]
ReadPrec ValidationError
Int -> ReadS ValidationError
ReadS [ValidationError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ValidationError]
$creadListPrec :: ReadPrec [ValidationError]
readPrec :: ReadPrec ValidationError
$creadPrec :: ReadPrec ValidationError
readList :: ReadS [ValidationError]
$creadList :: ReadS [ValidationError]
readsPrec :: Int -> ReadS ValidationError
$creadsPrec :: Int -> ReadS ValidationError
Prelude.Read, Int -> ValidationError -> ShowS
[ValidationError] -> ShowS
ValidationError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ValidationError] -> ShowS
$cshowList :: [ValidationError] -> ShowS
show :: ValidationError -> String
$cshow :: ValidationError -> String
showsPrec :: Int -> ValidationError -> ShowS
$cshowsPrec :: Int -> ValidationError -> ShowS
Prelude.Show, forall x. Rep ValidationError x -> ValidationError
forall x. ValidationError -> Rep ValidationError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ValidationError x -> ValidationError
$cfrom :: forall x. ValidationError -> Rep ValidationError x
Prelude.Generic)

-- |
-- Create a value of 'ValidationError' 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:
--
-- 'code', 'validationError_code' - The error code that indicates why the parameter or parameter combination
-- is not valid. For more information about error codes, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html Error codes>.
--
-- 'message', 'validationError_message' - The error message that describes why the parameter or parameter
-- combination is not valid. For more information about error messages, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html Error codes>.
newValidationError ::
  ValidationError
newValidationError :: ValidationError
newValidationError =
  ValidationError'
    { $sel:code:ValidationError' :: Maybe Text
code = forall a. Maybe a
Prelude.Nothing,
      $sel:message:ValidationError' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing
    }

-- | The error code that indicates why the parameter or parameter combination
-- is not valid. For more information about error codes, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html Error codes>.
validationError_code :: Lens.Lens' ValidationError (Prelude.Maybe Prelude.Text)
validationError_code :: Lens' ValidationError (Maybe Text)
validationError_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidationError' {Maybe Text
code :: Maybe Text
$sel:code:ValidationError' :: ValidationError -> Maybe Text
code} -> Maybe Text
code) (\s :: ValidationError
s@ValidationError' {} Maybe Text
a -> ValidationError
s {$sel:code:ValidationError' :: Maybe Text
code = Maybe Text
a} :: ValidationError)

-- | The error message that describes why the parameter or parameter
-- combination is not valid. For more information about error messages, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html Error codes>.
validationError_message :: Lens.Lens' ValidationError (Prelude.Maybe Prelude.Text)
validationError_message :: Lens' ValidationError (Maybe Text)
validationError_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidationError' {Maybe Text
message :: Maybe Text
$sel:message:ValidationError' :: ValidationError -> Maybe Text
message} -> Maybe Text
message) (\s :: ValidationError
s@ValidationError' {} Maybe Text
a -> ValidationError
s {$sel:message:ValidationError' :: Maybe Text
message = Maybe Text
a} :: ValidationError)

instance Data.FromXML ValidationError where
  parseXML :: [Node] -> Either String ValidationError
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> ValidationError
ValidationError'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"code")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"message")

instance Prelude.Hashable ValidationError where
  hashWithSalt :: Int -> ValidationError -> Int
hashWithSalt Int
_salt ValidationError' {Maybe Text
message :: Maybe Text
code :: Maybe Text
$sel:message:ValidationError' :: ValidationError -> Maybe Text
$sel:code:ValidationError' :: ValidationError -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message

instance Prelude.NFData ValidationError where
  rnf :: ValidationError -> ()
rnf ValidationError' {Maybe Text
message :: Maybe Text
code :: Maybe Text
$sel:message:ValidationError' :: ValidationError -> Maybe Text
$sel:code:ValidationError' :: ValidationError -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
code seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message