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

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

-- | An object representing an error when an asynchronous operation fails.
--
-- /See:/ 'newErrorDetail' smart constructor.
data ErrorDetail = ErrorDetail'
  { -- | An optional field that contains the resource IDs associated with the
    -- error.
    ErrorDetail -> Maybe [Text]
resourceIds :: Prelude.Maybe [Prelude.Text],
    -- | 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
  }
  deriving (ErrorDetail -> ErrorDetail -> Bool
(ErrorDetail -> ErrorDetail -> Bool)
-> (ErrorDetail -> ErrorDetail -> Bool) -> Eq ErrorDetail
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]
(Int -> ReadS ErrorDetail)
-> ReadS [ErrorDetail]
-> ReadPrec ErrorDetail
-> ReadPrec [ErrorDetail]
-> Read 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
(Int -> ErrorDetail -> ShowS)
-> (ErrorDetail -> String)
-> ([ErrorDetail] -> ShowS)
-> Show ErrorDetail
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. ErrorDetail -> Rep ErrorDetail x)
-> (forall x. Rep ErrorDetail x -> ErrorDetail)
-> Generic ErrorDetail
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:
--
-- 'resourceIds', 'errorDetail_resourceIds' - An optional field that contains the resource IDs associated with the
-- error.
--
-- '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.
newErrorDetail ::
  ErrorDetail
newErrorDetail :: ErrorDetail
newErrorDetail =
  ErrorDetail' :: Maybe [Text] -> Maybe EKSErrorCode -> Maybe Text -> ErrorDetail
ErrorDetail'
    { $sel:resourceIds:ErrorDetail' :: Maybe [Text]
resourceIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:errorCode:ErrorDetail' :: Maybe EKSErrorCode
errorCode = Maybe EKSErrorCode
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:ErrorDetail' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | An optional field that contains the resource IDs associated with the
-- error.
errorDetail_resourceIds :: Lens.Lens' ErrorDetail (Prelude.Maybe [Prelude.Text])
errorDetail_resourceIds :: (Maybe [Text] -> f (Maybe [Text])) -> ErrorDetail -> f ErrorDetail
errorDetail_resourceIds = (ErrorDetail -> Maybe [Text])
-> (ErrorDetail -> Maybe [Text] -> ErrorDetail)
-> Lens ErrorDetail ErrorDetail (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> ErrorDetail -> f ErrorDetail)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ErrorDetail
-> f ErrorDetail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe EKSErrorCode -> f (Maybe EKSErrorCode))
-> ErrorDetail -> f ErrorDetail
errorDetail_errorCode = (ErrorDetail -> Maybe EKSErrorCode)
-> (ErrorDetail -> Maybe EKSErrorCode -> ErrorDetail)
-> Lens
     ErrorDetail ErrorDetail (Maybe EKSErrorCode) (Maybe EKSErrorCode)
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 :: (Maybe Text -> f (Maybe Text)) -> ErrorDetail -> f ErrorDetail
errorDetail_errorMessage = (ErrorDetail -> Maybe Text)
-> (ErrorDetail -> Maybe Text -> ErrorDetail)
-> Lens ErrorDetail ErrorDetail (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON ErrorDetail where
  parseJSON :: Value -> Parser ErrorDetail
parseJSON =
    String
-> (Object -> Parser ErrorDetail) -> Value -> Parser ErrorDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ErrorDetail"
      ( \Object
x ->
          Maybe [Text] -> Maybe EKSErrorCode -> Maybe Text -> ErrorDetail
ErrorDetail'
            (Maybe [Text] -> Maybe EKSErrorCode -> Maybe Text -> ErrorDetail)
-> Parser (Maybe [Text])
-> Parser (Maybe EKSErrorCode -> Maybe Text -> ErrorDetail)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"resourceIds" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe EKSErrorCode -> Maybe Text -> ErrorDetail)
-> Parser (Maybe EKSErrorCode)
-> Parser (Maybe Text -> ErrorDetail)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EKSErrorCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"errorCode")
            Parser (Maybe Text -> ErrorDetail)
-> Parser (Maybe Text) -> Parser ErrorDetail
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
"errorMessage")
      )

instance Prelude.Hashable ErrorDetail

instance Prelude.NFData ErrorDetail