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

import Amazonka.CodeDeploy.Types.DeployErrorCode
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 AWS CodeDeploy>
    -- in the
    -- <https://docs.aws.amazon.com/codedeploy/latest/userguide AWS 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 AWS 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
(ErrorInformation -> ErrorInformation -> Bool)
-> (ErrorInformation -> ErrorInformation -> Bool)
-> Eq ErrorInformation
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]
(Int -> ReadS ErrorInformation)
-> ReadS [ErrorInformation]
-> ReadPrec ErrorInformation
-> ReadPrec [ErrorInformation]
-> Read 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
(Int -> ErrorInformation -> ShowS)
-> (ErrorInformation -> String)
-> ([ErrorInformation] -> ShowS)
-> Show ErrorInformation
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. ErrorInformation -> Rep ErrorInformation x)
-> (forall x. Rep ErrorInformation x -> ErrorInformation)
-> Generic ErrorInformation
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 AWS CodeDeploy>
-- in the
-- <https://docs.aws.amazon.com/codedeploy/latest/userguide AWS 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 AWS 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' :: Maybe DeployErrorCode -> Maybe Text -> ErrorInformation
ErrorInformation'
    { $sel:code:ErrorInformation' :: Maybe DeployErrorCode
code = Maybe DeployErrorCode
forall a. Maybe a
Prelude.Nothing,
      $sel:message:ErrorInformation' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | For more information, see
-- <https://docs.aws.amazon.com/codedeploy/latest/userguide/error-codes.html Error Codes for AWS CodeDeploy>
-- in the
-- <https://docs.aws.amazon.com/codedeploy/latest/userguide AWS 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 AWS 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 :: (Maybe DeployErrorCode -> f (Maybe DeployErrorCode))
-> ErrorInformation -> f ErrorInformation
errorInformation_code = (ErrorInformation -> Maybe DeployErrorCode)
-> (ErrorInformation -> Maybe DeployErrorCode -> ErrorInformation)
-> Lens
     ErrorInformation
     ErrorInformation
     (Maybe DeployErrorCode)
     (Maybe DeployErrorCode)
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 :: (Maybe Text -> f (Maybe Text))
-> ErrorInformation -> f ErrorInformation
errorInformation_message = (ErrorInformation -> Maybe Text)
-> (ErrorInformation -> Maybe Text -> ErrorInformation)
-> Lens ErrorInformation ErrorInformation (Maybe Text) (Maybe Text)
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 Core.FromJSON ErrorInformation where
  parseJSON :: Value -> Parser ErrorInformation
parseJSON =
    String
-> (Object -> Parser ErrorInformation)
-> Value
-> Parser ErrorInformation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ErrorInformation"
      ( \Object
x ->
          Maybe DeployErrorCode -> Maybe Text -> ErrorInformation
ErrorInformation'
            (Maybe DeployErrorCode -> Maybe Text -> ErrorInformation)
-> Parser (Maybe DeployErrorCode)
-> Parser (Maybe Text -> ErrorInformation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DeployErrorCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"code")
            Parser (Maybe Text -> ErrorInformation)
-> Parser (Maybe Text) -> Parser ErrorInformation
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 ErrorInformation

instance Prelude.NFData ErrorInformation