{-# 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.CodeDeploy.Types.ErrorInformation
-- 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.CodeDeploy.Types.ErrorInformation where

import Amazonka.CodeDeploy.Types.DeployErrorCode
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

-- | Information about a deployment error.
--
-- /See:/ 'newErrorInformation' smart constructor.
data ErrorInformation = ErrorInformation'
  { -- | For more information, see
    -- <https://docs.aws.amazon.com/codedeploy/latest/userguide/error-codes.html Error Codes for CodeDeploy>
    -- in the
    -- <https://docs.aws.amazon.com/codedeploy/latest/userguide CodeDeploy User Guide>.
    --
    -- The error code:
    --
    -- -   APPLICATION_MISSING: The application was missing. This error code is
    --     most likely raised if the application is deleted after the
    --     deployment is created, but before it is started.
    --
    -- -   DEPLOYMENT_GROUP_MISSING: The deployment group was missing. This
    --     error code is most likely raised if the deployment group is deleted
    --     after the deployment is created, but before it is started.
    --
    -- -   HEALTH_CONSTRAINTS: The deployment failed on too many instances to
    --     be successfully deployed within the instance health constraints
    --     specified.
    --
    -- -   HEALTH_CONSTRAINTS_INVALID: The revision cannot be successfully
    --     deployed within the instance health constraints specified.
    --
    -- -   IAM_ROLE_MISSING: The service role cannot be accessed.
    --
    -- -   IAM_ROLE_PERMISSIONS: The service role does not have the correct
    --     permissions.
    --
    -- -   INTERNAL_ERROR: There was an internal error.
    --
    -- -   NO_EC2_SUBSCRIPTION: The calling account is not subscribed to Amazon
    --     EC2.
    --
    -- -   NO_INSTANCES: No instances were specified, or no instances can be
    --     found.
    --
    -- -   OVER_MAX_INSTANCES: The maximum number of instances was exceeded.
    --
    -- -   THROTTLED: The operation was throttled because the calling account
    --     exceeded the throttling limits of one or more Amazon Web Services
    --     services.
    --
    -- -   TIMEOUT: The deployment has timed out.
    --
    -- -   REVISION_MISSING: The revision ID was missing. This error code is
    --     most likely raised if the revision is deleted after the deployment
    --     is created, but before it is started.
    ErrorInformation -> Maybe DeployErrorCode
code :: Prelude.Maybe DeployErrorCode,
    -- | An accompanying error message.
    ErrorInformation -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (ErrorInformation -> ErrorInformation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ErrorInformation -> ErrorInformation -> Bool
$c/= :: ErrorInformation -> ErrorInformation -> Bool
== :: ErrorInformation -> ErrorInformation -> Bool
$c== :: ErrorInformation -> ErrorInformation -> Bool
Prelude.Eq, ReadPrec [ErrorInformation]
ReadPrec ErrorInformation
Int -> ReadS ErrorInformation
ReadS [ErrorInformation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ErrorInformation]
$creadListPrec :: ReadPrec [ErrorInformation]
readPrec :: ReadPrec ErrorInformation
$creadPrec :: ReadPrec ErrorInformation
readList :: ReadS [ErrorInformation]
$creadList :: ReadS [ErrorInformation]
readsPrec :: Int -> ReadS ErrorInformation
$creadsPrec :: Int -> ReadS ErrorInformation
Prelude.Read, Int -> ErrorInformation -> ShowS
[ErrorInformation] -> ShowS
ErrorInformation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ErrorInformation] -> ShowS
$cshowList :: [ErrorInformation] -> ShowS
show :: ErrorInformation -> String
$cshow :: ErrorInformation -> String
showsPrec :: Int -> ErrorInformation -> ShowS
$cshowsPrec :: Int -> ErrorInformation -> ShowS
Prelude.Show, forall x. Rep ErrorInformation x -> ErrorInformation
forall x. ErrorInformation -> Rep ErrorInformation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ErrorInformation x -> ErrorInformation
$cfrom :: forall x. ErrorInformation -> Rep ErrorInformation x
Prelude.Generic)

-- |
-- Create a value of 'ErrorInformation' 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', 'errorInformation_code' - For more information, see
-- <https://docs.aws.amazon.com/codedeploy/latest/userguide/error-codes.html Error Codes for CodeDeploy>
-- in the
-- <https://docs.aws.amazon.com/codedeploy/latest/userguide CodeDeploy User Guide>.
--
-- The error code:
--
-- -   APPLICATION_MISSING: The application was missing. This error code is
--     most likely raised if the application is deleted after the
--     deployment is created, but before it is started.
--
-- -   DEPLOYMENT_GROUP_MISSING: The deployment group was missing. This
--     error code is most likely raised if the deployment group is deleted
--     after the deployment is created, but before it is started.
--
-- -   HEALTH_CONSTRAINTS: The deployment failed on too many instances to
--     be successfully deployed within the instance health constraints
--     specified.
--
-- -   HEALTH_CONSTRAINTS_INVALID: The revision cannot be successfully
--     deployed within the instance health constraints specified.
--
-- -   IAM_ROLE_MISSING: The service role cannot be accessed.
--
-- -   IAM_ROLE_PERMISSIONS: The service role does not have the correct
--     permissions.
--
-- -   INTERNAL_ERROR: There was an internal error.
--
-- -   NO_EC2_SUBSCRIPTION: The calling account is not subscribed to Amazon
--     EC2.
--
-- -   NO_INSTANCES: No instances were specified, or no instances can be
--     found.
--
-- -   OVER_MAX_INSTANCES: The maximum number of instances was exceeded.
--
-- -   THROTTLED: The operation was throttled because the calling account
--     exceeded the throttling limits of one or more Amazon Web Services
--     services.
--
-- -   TIMEOUT: The deployment has timed out.
--
-- -   REVISION_MISSING: The revision ID was missing. This error code is
--     most likely raised if the revision is deleted after the deployment
--     is created, but before it is started.
--
-- 'message', 'errorInformation_message' - An accompanying error message.
newErrorInformation ::
  ErrorInformation
newErrorInformation :: ErrorInformation
newErrorInformation =
  ErrorInformation'
    { $sel:code:ErrorInformation' :: Maybe DeployErrorCode
code = forall a. Maybe a
Prelude.Nothing,
      $sel:message:ErrorInformation' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing
    }

-- | For more information, see
-- <https://docs.aws.amazon.com/codedeploy/latest/userguide/error-codes.html Error Codes for CodeDeploy>
-- in the
-- <https://docs.aws.amazon.com/codedeploy/latest/userguide CodeDeploy User Guide>.
--
-- The error code:
--
-- -   APPLICATION_MISSING: The application was missing. This error code is
--     most likely raised if the application is deleted after the
--     deployment is created, but before it is started.
--
-- -   DEPLOYMENT_GROUP_MISSING: The deployment group was missing. This
--     error code is most likely raised if the deployment group is deleted
--     after the deployment is created, but before it is started.
--
-- -   HEALTH_CONSTRAINTS: The deployment failed on too many instances to
--     be successfully deployed within the instance health constraints
--     specified.
--
-- -   HEALTH_CONSTRAINTS_INVALID: The revision cannot be successfully
--     deployed within the instance health constraints specified.
--
-- -   IAM_ROLE_MISSING: The service role cannot be accessed.
--
-- -   IAM_ROLE_PERMISSIONS: The service role does not have the correct
--     permissions.
--
-- -   INTERNAL_ERROR: There was an internal error.
--
-- -   NO_EC2_SUBSCRIPTION: The calling account is not subscribed to Amazon
--     EC2.
--
-- -   NO_INSTANCES: No instances were specified, or no instances can be
--     found.
--
-- -   OVER_MAX_INSTANCES: The maximum number of instances was exceeded.
--
-- -   THROTTLED: The operation was throttled because the calling account
--     exceeded the throttling limits of one or more Amazon Web Services
--     services.
--
-- -   TIMEOUT: The deployment has timed out.
--
-- -   REVISION_MISSING: The revision ID was missing. This error code is
--     most likely raised if the revision is deleted after the deployment
--     is created, but before it is started.
errorInformation_code :: Lens.Lens' ErrorInformation (Prelude.Maybe DeployErrorCode)
errorInformation_code :: Lens' ErrorInformation (Maybe DeployErrorCode)
errorInformation_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorInformation' {Maybe DeployErrorCode
code :: Maybe DeployErrorCode
$sel:code:ErrorInformation' :: ErrorInformation -> Maybe DeployErrorCode
code} -> Maybe DeployErrorCode
code) (\s :: ErrorInformation
s@ErrorInformation' {} Maybe DeployErrorCode
a -> ErrorInformation
s {$sel:code:ErrorInformation' :: Maybe DeployErrorCode
code = Maybe DeployErrorCode
a} :: ErrorInformation)

-- | An accompanying error message.
errorInformation_message :: Lens.Lens' ErrorInformation (Prelude.Maybe Prelude.Text)
errorInformation_message :: Lens' ErrorInformation (Maybe Text)
errorInformation_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorInformation' {Maybe Text
message :: Maybe Text
$sel:message:ErrorInformation' :: ErrorInformation -> Maybe Text
message} -> Maybe Text
message) (\s :: ErrorInformation
s@ErrorInformation' {} Maybe Text
a -> ErrorInformation
s {$sel:message:ErrorInformation' :: Maybe Text
message = Maybe Text
a} :: ErrorInformation)

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

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

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