{-# 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.Athena.Types.ResultReuseConfiguration
-- 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.Athena.Types.ResultReuseConfiguration where

import Amazonka.Athena.Types.ResultReuseByAgeConfiguration
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

-- | Specifies the query result reuse behavior for the query.
--
-- /See:/ 'newResultReuseConfiguration' smart constructor.
data ResultReuseConfiguration = ResultReuseConfiguration'
  { -- | Specifies whether previous query results are reused, and if so, their
    -- maximum age.
    ResultReuseConfiguration -> Maybe ResultReuseByAgeConfiguration
resultReuseByAgeConfiguration :: Prelude.Maybe ResultReuseByAgeConfiguration
  }
  deriving (ResultReuseConfiguration -> ResultReuseConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResultReuseConfiguration -> ResultReuseConfiguration -> Bool
$c/= :: ResultReuseConfiguration -> ResultReuseConfiguration -> Bool
== :: ResultReuseConfiguration -> ResultReuseConfiguration -> Bool
$c== :: ResultReuseConfiguration -> ResultReuseConfiguration -> Bool
Prelude.Eq, ReadPrec [ResultReuseConfiguration]
ReadPrec ResultReuseConfiguration
Int -> ReadS ResultReuseConfiguration
ReadS [ResultReuseConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResultReuseConfiguration]
$creadListPrec :: ReadPrec [ResultReuseConfiguration]
readPrec :: ReadPrec ResultReuseConfiguration
$creadPrec :: ReadPrec ResultReuseConfiguration
readList :: ReadS [ResultReuseConfiguration]
$creadList :: ReadS [ResultReuseConfiguration]
readsPrec :: Int -> ReadS ResultReuseConfiguration
$creadsPrec :: Int -> ReadS ResultReuseConfiguration
Prelude.Read, Int -> ResultReuseConfiguration -> ShowS
[ResultReuseConfiguration] -> ShowS
ResultReuseConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResultReuseConfiguration] -> ShowS
$cshowList :: [ResultReuseConfiguration] -> ShowS
show :: ResultReuseConfiguration -> String
$cshow :: ResultReuseConfiguration -> String
showsPrec :: Int -> ResultReuseConfiguration -> ShowS
$cshowsPrec :: Int -> ResultReuseConfiguration -> ShowS
Prelude.Show, forall x.
Rep ResultReuseConfiguration x -> ResultReuseConfiguration
forall x.
ResultReuseConfiguration -> Rep ResultReuseConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ResultReuseConfiguration x -> ResultReuseConfiguration
$cfrom :: forall x.
ResultReuseConfiguration -> Rep ResultReuseConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ResultReuseConfiguration' 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:
--
-- 'resultReuseByAgeConfiguration', 'resultReuseConfiguration_resultReuseByAgeConfiguration' - Specifies whether previous query results are reused, and if so, their
-- maximum age.
newResultReuseConfiguration ::
  ResultReuseConfiguration
newResultReuseConfiguration :: ResultReuseConfiguration
newResultReuseConfiguration =
  ResultReuseConfiguration'
    { $sel:resultReuseByAgeConfiguration:ResultReuseConfiguration' :: Maybe ResultReuseByAgeConfiguration
resultReuseByAgeConfiguration =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether previous query results are reused, and if so, their
-- maximum age.
resultReuseConfiguration_resultReuseByAgeConfiguration :: Lens.Lens' ResultReuseConfiguration (Prelude.Maybe ResultReuseByAgeConfiguration)
resultReuseConfiguration_resultReuseByAgeConfiguration :: Lens'
  ResultReuseConfiguration (Maybe ResultReuseByAgeConfiguration)
resultReuseConfiguration_resultReuseByAgeConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultReuseConfiguration' {Maybe ResultReuseByAgeConfiguration
resultReuseByAgeConfiguration :: Maybe ResultReuseByAgeConfiguration
$sel:resultReuseByAgeConfiguration:ResultReuseConfiguration' :: ResultReuseConfiguration -> Maybe ResultReuseByAgeConfiguration
resultReuseByAgeConfiguration} -> Maybe ResultReuseByAgeConfiguration
resultReuseByAgeConfiguration) (\s :: ResultReuseConfiguration
s@ResultReuseConfiguration' {} Maybe ResultReuseByAgeConfiguration
a -> ResultReuseConfiguration
s {$sel:resultReuseByAgeConfiguration:ResultReuseConfiguration' :: Maybe ResultReuseByAgeConfiguration
resultReuseByAgeConfiguration = Maybe ResultReuseByAgeConfiguration
a} :: ResultReuseConfiguration)

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

instance Prelude.Hashable ResultReuseConfiguration where
  hashWithSalt :: Int -> ResultReuseConfiguration -> Int
hashWithSalt Int
_salt ResultReuseConfiguration' {Maybe ResultReuseByAgeConfiguration
resultReuseByAgeConfiguration :: Maybe ResultReuseByAgeConfiguration
$sel:resultReuseByAgeConfiguration:ResultReuseConfiguration' :: ResultReuseConfiguration -> Maybe ResultReuseByAgeConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResultReuseByAgeConfiguration
resultReuseByAgeConfiguration

instance Prelude.NFData ResultReuseConfiguration where
  rnf :: ResultReuseConfiguration -> ()
rnf ResultReuseConfiguration' {Maybe ResultReuseByAgeConfiguration
resultReuseByAgeConfiguration :: Maybe ResultReuseByAgeConfiguration
$sel:resultReuseByAgeConfiguration:ResultReuseConfiguration' :: ResultReuseConfiguration -> Maybe ResultReuseByAgeConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ResultReuseByAgeConfiguration
resultReuseByAgeConfiguration

instance Data.ToJSON ResultReuseConfiguration where
  toJSON :: ResultReuseConfiguration -> Value
toJSON ResultReuseConfiguration' {Maybe ResultReuseByAgeConfiguration
resultReuseByAgeConfiguration :: Maybe ResultReuseByAgeConfiguration
$sel:resultReuseByAgeConfiguration:ResultReuseConfiguration' :: ResultReuseConfiguration -> Maybe ResultReuseByAgeConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ResultReuseByAgeConfiguration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ResultReuseByAgeConfiguration
resultReuseByAgeConfiguration
          ]
      )