{-# 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.OpenSearchServerless.Types.CollectionErrorDetail
-- 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.OpenSearchServerless.Types.CollectionErrorDetail where

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

-- | Error information for an OpenSearch Serverless request.
--
-- /See:/ 'newCollectionErrorDetail' smart constructor.
data CollectionErrorDetail = CollectionErrorDetail'
  { -- | The error code for the request. For example, @NOT_FOUND@.
    CollectionErrorDetail -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | A description of the error. For example,
    -- @The specified Collection is not found.@
    CollectionErrorDetail -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | If the request contains collection IDs, the response includes the IDs
    -- provided in the request.
    CollectionErrorDetail -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | If the request contains collection names, the response includes the
    -- names provided in the request.
    CollectionErrorDetail -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (CollectionErrorDetail -> CollectionErrorDetail -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CollectionErrorDetail -> CollectionErrorDetail -> Bool
$c/= :: CollectionErrorDetail -> CollectionErrorDetail -> Bool
== :: CollectionErrorDetail -> CollectionErrorDetail -> Bool
$c== :: CollectionErrorDetail -> CollectionErrorDetail -> Bool
Prelude.Eq, ReadPrec [CollectionErrorDetail]
ReadPrec CollectionErrorDetail
Int -> ReadS CollectionErrorDetail
ReadS [CollectionErrorDetail]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CollectionErrorDetail]
$creadListPrec :: ReadPrec [CollectionErrorDetail]
readPrec :: ReadPrec CollectionErrorDetail
$creadPrec :: ReadPrec CollectionErrorDetail
readList :: ReadS [CollectionErrorDetail]
$creadList :: ReadS [CollectionErrorDetail]
readsPrec :: Int -> ReadS CollectionErrorDetail
$creadsPrec :: Int -> ReadS CollectionErrorDetail
Prelude.Read, Int -> CollectionErrorDetail -> ShowS
[CollectionErrorDetail] -> ShowS
CollectionErrorDetail -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CollectionErrorDetail] -> ShowS
$cshowList :: [CollectionErrorDetail] -> ShowS
show :: CollectionErrorDetail -> String
$cshow :: CollectionErrorDetail -> String
showsPrec :: Int -> CollectionErrorDetail -> ShowS
$cshowsPrec :: Int -> CollectionErrorDetail -> ShowS
Prelude.Show, forall x. Rep CollectionErrorDetail x -> CollectionErrorDetail
forall x. CollectionErrorDetail -> Rep CollectionErrorDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CollectionErrorDetail x -> CollectionErrorDetail
$cfrom :: forall x. CollectionErrorDetail -> Rep CollectionErrorDetail x
Prelude.Generic)

-- |
-- Create a value of 'CollectionErrorDetail' 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', 'collectionErrorDetail_errorCode' - The error code for the request. For example, @NOT_FOUND@.
--
-- 'errorMessage', 'collectionErrorDetail_errorMessage' - A description of the error. For example,
-- @The specified Collection is not found.@
--
-- 'id', 'collectionErrorDetail_id' - If the request contains collection IDs, the response includes the IDs
-- provided in the request.
--
-- 'name', 'collectionErrorDetail_name' - If the request contains collection names, the response includes the
-- names provided in the request.
newCollectionErrorDetail ::
  CollectionErrorDetail
newCollectionErrorDetail :: CollectionErrorDetail
newCollectionErrorDetail =
  CollectionErrorDetail'
    { $sel:errorCode:CollectionErrorDetail' :: Maybe Text
errorCode = forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:CollectionErrorDetail' :: Maybe Text
errorMessage = forall a. Maybe a
Prelude.Nothing,
      $sel:id:CollectionErrorDetail' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:name:CollectionErrorDetail' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | The error code for the request. For example, @NOT_FOUND@.
collectionErrorDetail_errorCode :: Lens.Lens' CollectionErrorDetail (Prelude.Maybe Prelude.Text)
collectionErrorDetail_errorCode :: Lens' CollectionErrorDetail (Maybe Text)
collectionErrorDetail_errorCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CollectionErrorDetail' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:CollectionErrorDetail' :: CollectionErrorDetail -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: CollectionErrorDetail
s@CollectionErrorDetail' {} Maybe Text
a -> CollectionErrorDetail
s {$sel:errorCode:CollectionErrorDetail' :: Maybe Text
errorCode = Maybe Text
a} :: CollectionErrorDetail)

-- | A description of the error. For example,
-- @The specified Collection is not found.@
collectionErrorDetail_errorMessage :: Lens.Lens' CollectionErrorDetail (Prelude.Maybe Prelude.Text)
collectionErrorDetail_errorMessage :: Lens' CollectionErrorDetail (Maybe Text)
collectionErrorDetail_errorMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CollectionErrorDetail' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:CollectionErrorDetail' :: CollectionErrorDetail -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: CollectionErrorDetail
s@CollectionErrorDetail' {} Maybe Text
a -> CollectionErrorDetail
s {$sel:errorMessage:CollectionErrorDetail' :: Maybe Text
errorMessage = Maybe Text
a} :: CollectionErrorDetail)

-- | If the request contains collection IDs, the response includes the IDs
-- provided in the request.
collectionErrorDetail_id :: Lens.Lens' CollectionErrorDetail (Prelude.Maybe Prelude.Text)
collectionErrorDetail_id :: Lens' CollectionErrorDetail (Maybe Text)
collectionErrorDetail_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CollectionErrorDetail' {Maybe Text
id :: Maybe Text
$sel:id:CollectionErrorDetail' :: CollectionErrorDetail -> Maybe Text
id} -> Maybe Text
id) (\s :: CollectionErrorDetail
s@CollectionErrorDetail' {} Maybe Text
a -> CollectionErrorDetail
s {$sel:id:CollectionErrorDetail' :: Maybe Text
id = Maybe Text
a} :: CollectionErrorDetail)

-- | If the request contains collection names, the response includes the
-- names provided in the request.
collectionErrorDetail_name :: Lens.Lens' CollectionErrorDetail (Prelude.Maybe Prelude.Text)
collectionErrorDetail_name :: Lens' CollectionErrorDetail (Maybe Text)
collectionErrorDetail_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CollectionErrorDetail' {Maybe Text
name :: Maybe Text
$sel:name:CollectionErrorDetail' :: CollectionErrorDetail -> Maybe Text
name} -> Maybe Text
name) (\s :: CollectionErrorDetail
s@CollectionErrorDetail' {} Maybe Text
a -> CollectionErrorDetail
s {$sel:name:CollectionErrorDetail' :: Maybe Text
name = Maybe Text
a} :: CollectionErrorDetail)

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

instance Prelude.Hashable CollectionErrorDetail where
  hashWithSalt :: Int -> CollectionErrorDetail -> Int
hashWithSalt Int
_salt CollectionErrorDetail' {Maybe Text
name :: Maybe Text
id :: Maybe Text
errorMessage :: Maybe Text
errorCode :: Maybe Text
$sel:name:CollectionErrorDetail' :: CollectionErrorDetail -> Maybe Text
$sel:id:CollectionErrorDetail' :: CollectionErrorDetail -> Maybe Text
$sel:errorMessage:CollectionErrorDetail' :: CollectionErrorDetail -> Maybe Text
$sel:errorCode:CollectionErrorDetail' :: CollectionErrorDetail -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name

instance Prelude.NFData CollectionErrorDetail where
  rnf :: CollectionErrorDetail -> ()
rnf CollectionErrorDetail' {Maybe Text
name :: Maybe Text
id :: Maybe Text
errorMessage :: Maybe Text
errorCode :: Maybe Text
$sel:name:CollectionErrorDetail' :: CollectionErrorDetail -> Maybe Text
$sel:id:CollectionErrorDetail' :: CollectionErrorDetail -> Maybe Text
$sel:errorMessage:CollectionErrorDetail' :: CollectionErrorDetail -> Maybe Text
$sel:errorCode:CollectionErrorDetail' :: CollectionErrorDetail -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
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
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name