{-# 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.EKS.Types.ErrorDetail
-- 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.EKS.Types.ErrorDetail where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EKS.Types.EKSErrorCode
import qualified Amazonka.Prelude as Prelude

-- | An object representing an error when an asynchronous operation fails.
--
-- /See:/ 'newErrorDetail' smart constructor.
data ErrorDetail = ErrorDetail'
  { -- | A brief description of the error.
    --
    -- -   __SubnetNotFound__: We couldn\'t find one of the subnets associated
    --     with the cluster.
    --
    -- -   __SecurityGroupNotFound__: We couldn\'t find one of the security
    --     groups associated with the cluster.
    --
    -- -   __EniLimitReached__: You have reached the elastic network interface
    --     limit for your account.
    --
    -- -   __IpNotAvailable__: A subnet associated with the cluster doesn\'t
    --     have any free IP addresses.
    --
    -- -   __AccessDenied__: You don\'t have permissions to perform the
    --     specified operation.
    --
    -- -   __OperationNotPermitted__: The service role associated with the
    --     cluster doesn\'t have the required access permissions for Amazon
    --     EKS.
    --
    -- -   __VpcIdNotFound__: We couldn\'t find the VPC associated with the
    --     cluster.
    ErrorDetail -> Maybe EKSErrorCode
errorCode :: Prelude.Maybe EKSErrorCode,
    -- | A more complete description of the error.
    ErrorDetail -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | An optional field that contains the resource IDs associated with the
    -- error.
    ErrorDetail -> Maybe [Text]
resourceIds :: Prelude.Maybe [Prelude.Text]
  }
  deriving (ErrorDetail -> ErrorDetail -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ErrorDetail -> ErrorDetail -> Bool
$c/= :: ErrorDetail -> ErrorDetail -> Bool
== :: ErrorDetail -> ErrorDetail -> Bool
$c== :: ErrorDetail -> ErrorDetail -> Bool
Prelude.Eq, ReadPrec [ErrorDetail]
ReadPrec ErrorDetail
Int -> ReadS ErrorDetail
ReadS [ErrorDetail]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ErrorDetail]
$creadListPrec :: ReadPrec [ErrorDetail]
readPrec :: ReadPrec ErrorDetail
$creadPrec :: ReadPrec ErrorDetail
readList :: ReadS [ErrorDetail]
$creadList :: ReadS [ErrorDetail]
readsPrec :: Int -> ReadS ErrorDetail
$creadsPrec :: Int -> ReadS ErrorDetail
Prelude.Read, Int -> ErrorDetail -> ShowS
[ErrorDetail] -> ShowS
ErrorDetail -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ErrorDetail] -> ShowS
$cshowList :: [ErrorDetail] -> ShowS
show :: ErrorDetail -> String
$cshow :: ErrorDetail -> String
showsPrec :: Int -> ErrorDetail -> ShowS
$cshowsPrec :: Int -> ErrorDetail -> ShowS
Prelude.Show, forall x. Rep ErrorDetail x -> ErrorDetail
forall x. ErrorDetail -> Rep ErrorDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ErrorDetail x -> ErrorDetail
$cfrom :: forall x. ErrorDetail -> Rep ErrorDetail x
Prelude.Generic)

-- |
-- Create a value of 'ErrorDetail' 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', 'errorDetail_errorCode' - A brief description of the error.
--
-- -   __SubnetNotFound__: We couldn\'t find one of the subnets associated
--     with the cluster.
--
-- -   __SecurityGroupNotFound__: We couldn\'t find one of the security
--     groups associated with the cluster.
--
-- -   __EniLimitReached__: You have reached the elastic network interface
--     limit for your account.
--
-- -   __IpNotAvailable__: A subnet associated with the cluster doesn\'t
--     have any free IP addresses.
--
-- -   __AccessDenied__: You don\'t have permissions to perform the
--     specified operation.
--
-- -   __OperationNotPermitted__: The service role associated with the
--     cluster doesn\'t have the required access permissions for Amazon
--     EKS.
--
-- -   __VpcIdNotFound__: We couldn\'t find the VPC associated with the
--     cluster.
--
-- 'errorMessage', 'errorDetail_errorMessage' - A more complete description of the error.
--
-- 'resourceIds', 'errorDetail_resourceIds' - An optional field that contains the resource IDs associated with the
-- error.
newErrorDetail ::
  ErrorDetail
newErrorDetail :: ErrorDetail
newErrorDetail =
  ErrorDetail'
    { $sel:errorCode:ErrorDetail' :: Maybe EKSErrorCode
errorCode = forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:ErrorDetail' :: Maybe Text
errorMessage = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceIds:ErrorDetail' :: Maybe [Text]
resourceIds = forall a. Maybe a
Prelude.Nothing
    }

-- | A brief description of the error.
--
-- -   __SubnetNotFound__: We couldn\'t find one of the subnets associated
--     with the cluster.
--
-- -   __SecurityGroupNotFound__: We couldn\'t find one of the security
--     groups associated with the cluster.
--
-- -   __EniLimitReached__: You have reached the elastic network interface
--     limit for your account.
--
-- -   __IpNotAvailable__: A subnet associated with the cluster doesn\'t
--     have any free IP addresses.
--
-- -   __AccessDenied__: You don\'t have permissions to perform the
--     specified operation.
--
-- -   __OperationNotPermitted__: The service role associated with the
--     cluster doesn\'t have the required access permissions for Amazon
--     EKS.
--
-- -   __VpcIdNotFound__: We couldn\'t find the VPC associated with the
--     cluster.
errorDetail_errorCode :: Lens.Lens' ErrorDetail (Prelude.Maybe EKSErrorCode)
errorDetail_errorCode :: Lens' ErrorDetail (Maybe EKSErrorCode)
errorDetail_errorCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorDetail' {Maybe EKSErrorCode
errorCode :: Maybe EKSErrorCode
$sel:errorCode:ErrorDetail' :: ErrorDetail -> Maybe EKSErrorCode
errorCode} -> Maybe EKSErrorCode
errorCode) (\s :: ErrorDetail
s@ErrorDetail' {} Maybe EKSErrorCode
a -> ErrorDetail
s {$sel:errorCode:ErrorDetail' :: Maybe EKSErrorCode
errorCode = Maybe EKSErrorCode
a} :: ErrorDetail)

-- | A more complete description of the error.
errorDetail_errorMessage :: Lens.Lens' ErrorDetail (Prelude.Maybe Prelude.Text)
errorDetail_errorMessage :: Lens' ErrorDetail (Maybe Text)
errorDetail_errorMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorDetail' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:ErrorDetail' :: ErrorDetail -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: ErrorDetail
s@ErrorDetail' {} Maybe Text
a -> ErrorDetail
s {$sel:errorMessage:ErrorDetail' :: Maybe Text
errorMessage = Maybe Text
a} :: ErrorDetail)

-- | An optional field that contains the resource IDs associated with the
-- error.
errorDetail_resourceIds :: Lens.Lens' ErrorDetail (Prelude.Maybe [Prelude.Text])
errorDetail_resourceIds :: Lens' ErrorDetail (Maybe [Text])
errorDetail_resourceIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ErrorDetail' {Maybe [Text]
resourceIds :: Maybe [Text]
$sel:resourceIds:ErrorDetail' :: ErrorDetail -> Maybe [Text]
resourceIds} -> Maybe [Text]
resourceIds) (\s :: ErrorDetail
s@ErrorDetail' {} Maybe [Text]
a -> ErrorDetail
s {$sel:resourceIds:ErrorDetail' :: Maybe [Text]
resourceIds = Maybe [Text]
a} :: ErrorDetail) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ErrorDetail where
  parseJSON :: Value -> Parser ErrorDetail
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ErrorDetail"
      ( \Object
x ->
          Maybe EKSErrorCode -> Maybe Text -> Maybe [Text] -> ErrorDetail
ErrorDetail'
            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
"resourceIds" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ErrorDetail where
  hashWithSalt :: Int -> ErrorDetail -> Int
hashWithSalt Int
_salt ErrorDetail' {Maybe [Text]
Maybe Text
Maybe EKSErrorCode
resourceIds :: Maybe [Text]
errorMessage :: Maybe Text
errorCode :: Maybe EKSErrorCode
$sel:resourceIds:ErrorDetail' :: ErrorDetail -> Maybe [Text]
$sel:errorMessage:ErrorDetail' :: ErrorDetail -> Maybe Text
$sel:errorCode:ErrorDetail' :: ErrorDetail -> Maybe EKSErrorCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EKSErrorCode
errorCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
resourceIds

instance Prelude.NFData ErrorDetail where
  rnf :: ErrorDetail -> ()
rnf ErrorDetail' {Maybe [Text]
Maybe Text
Maybe EKSErrorCode
resourceIds :: Maybe [Text]
errorMessage :: Maybe Text
errorCode :: Maybe EKSErrorCode
$sel:resourceIds:ErrorDetail' :: ErrorDetail -> Maybe [Text]
$sel:errorMessage:ErrorDetail' :: ErrorDetail -> Maybe Text
$sel:errorCode:ErrorDetail' :: ErrorDetail -> Maybe EKSErrorCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EKSErrorCode
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]
resourceIds