{-# 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.Kendra.Types.Warning
-- 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.Kendra.Types.Warning where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kendra.Types.WarningCode
import qualified Amazonka.Prelude as Prelude

-- | The warning code and message that explains a problem with a query.
--
-- /See:/ 'newWarning' smart constructor.
data Warning = Warning'
  { -- | The code used to show the type of warning for the query.
    Warning -> Maybe WarningCode
code :: Prelude.Maybe WarningCode,
    -- | The message that explains the problem with the query.
    Warning -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (Warning -> Warning -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Warning -> Warning -> Bool
$c/= :: Warning -> Warning -> Bool
== :: Warning -> Warning -> Bool
$c== :: Warning -> Warning -> Bool
Prelude.Eq, ReadPrec [Warning]
ReadPrec Warning
Int -> ReadS Warning
ReadS [Warning]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Warning]
$creadListPrec :: ReadPrec [Warning]
readPrec :: ReadPrec Warning
$creadPrec :: ReadPrec Warning
readList :: ReadS [Warning]
$creadList :: ReadS [Warning]
readsPrec :: Int -> ReadS Warning
$creadsPrec :: Int -> ReadS Warning
Prelude.Read, Int -> Warning -> ShowS
[Warning] -> ShowS
Warning -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Warning] -> ShowS
$cshowList :: [Warning] -> ShowS
show :: Warning -> String
$cshow :: Warning -> String
showsPrec :: Int -> Warning -> ShowS
$cshowsPrec :: Int -> Warning -> ShowS
Prelude.Show, forall x. Rep Warning x -> Warning
forall x. Warning -> Rep Warning x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Warning x -> Warning
$cfrom :: forall x. Warning -> Rep Warning x
Prelude.Generic)

-- |
-- Create a value of 'Warning' 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', 'warning_code' - The code used to show the type of warning for the query.
--
-- 'message', 'warning_message' - The message that explains the problem with the query.
newWarning ::
  Warning
newWarning :: Warning
newWarning =
  Warning'
    { $sel:code:Warning' :: Maybe WarningCode
code = forall a. Maybe a
Prelude.Nothing,
      $sel:message:Warning' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing
    }

-- | The code used to show the type of warning for the query.
warning_code :: Lens.Lens' Warning (Prelude.Maybe WarningCode)
warning_code :: Lens' Warning (Maybe WarningCode)
warning_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Warning' {Maybe WarningCode
code :: Maybe WarningCode
$sel:code:Warning' :: Warning -> Maybe WarningCode
code} -> Maybe WarningCode
code) (\s :: Warning
s@Warning' {} Maybe WarningCode
a -> Warning
s {$sel:code:Warning' :: Maybe WarningCode
code = Maybe WarningCode
a} :: Warning)

-- | The message that explains the problem with the query.
warning_message :: Lens.Lens' Warning (Prelude.Maybe Prelude.Text)
warning_message :: Lens' Warning (Maybe Text)
warning_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Warning' {Maybe Text
message :: Maybe Text
$sel:message:Warning' :: Warning -> Maybe Text
message} -> Maybe Text
message) (\s :: Warning
s@Warning' {} Maybe Text
a -> Warning
s {$sel:message:Warning' :: Maybe Text
message = Maybe Text
a} :: Warning)

instance Data.FromJSON Warning where
  parseJSON :: Value -> Parser Warning
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Warning"
      ( \Object
x ->
          Maybe WarningCode -> Maybe Text -> Warning
Warning'
            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 Warning where
  hashWithSalt :: Int -> Warning -> Int
hashWithSalt Int
_salt Warning' {Maybe Text
Maybe WarningCode
message :: Maybe Text
code :: Maybe WarningCode
$sel:message:Warning' :: Warning -> Maybe Text
$sel:code:Warning' :: Warning -> Maybe WarningCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe WarningCode
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message

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