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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The Athena engine version for running queries.
--
-- /See:/ 'newEngineVersion' smart constructor.
data EngineVersion = EngineVersion'
  { -- | Read only. The engine version on which the query runs. If the user
    -- requests a valid engine version other than Auto, the effective engine
    -- version is the same as the engine version that the user requested. If
    -- the user requests Auto, the effective engine version is chosen by
    -- Athena. When a request to update the engine version is made by a
    -- @CreateWorkGroup@ or @UpdateWorkGroup@ operation, the
    -- @EffectiveEngineVersion@ field is ignored.
    EngineVersion -> Maybe Text
effectiveEngineVersion :: Prelude.Maybe Prelude.Text,
    -- | The engine version requested by the user. Possible values are determined
    -- by the output of @ListEngineVersions@, including Auto. The default is
    -- Auto.
    EngineVersion -> Maybe Text
selectedEngineVersion :: Prelude.Maybe Prelude.Text
  }
  deriving (EngineVersion -> EngineVersion -> Bool
(EngineVersion -> EngineVersion -> Bool)
-> (EngineVersion -> EngineVersion -> Bool) -> Eq EngineVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EngineVersion -> EngineVersion -> Bool
$c/= :: EngineVersion -> EngineVersion -> Bool
== :: EngineVersion -> EngineVersion -> Bool
$c== :: EngineVersion -> EngineVersion -> Bool
Prelude.Eq, ReadPrec [EngineVersion]
ReadPrec EngineVersion
Int -> ReadS EngineVersion
ReadS [EngineVersion]
(Int -> ReadS EngineVersion)
-> ReadS [EngineVersion]
-> ReadPrec EngineVersion
-> ReadPrec [EngineVersion]
-> Read EngineVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EngineVersion]
$creadListPrec :: ReadPrec [EngineVersion]
readPrec :: ReadPrec EngineVersion
$creadPrec :: ReadPrec EngineVersion
readList :: ReadS [EngineVersion]
$creadList :: ReadS [EngineVersion]
readsPrec :: Int -> ReadS EngineVersion
$creadsPrec :: Int -> ReadS EngineVersion
Prelude.Read, Int -> EngineVersion -> ShowS
[EngineVersion] -> ShowS
EngineVersion -> String
(Int -> EngineVersion -> ShowS)
-> (EngineVersion -> String)
-> ([EngineVersion] -> ShowS)
-> Show EngineVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EngineVersion] -> ShowS
$cshowList :: [EngineVersion] -> ShowS
show :: EngineVersion -> String
$cshow :: EngineVersion -> String
showsPrec :: Int -> EngineVersion -> ShowS
$cshowsPrec :: Int -> EngineVersion -> ShowS
Prelude.Show, (forall x. EngineVersion -> Rep EngineVersion x)
-> (forall x. Rep EngineVersion x -> EngineVersion)
-> Generic EngineVersion
forall x. Rep EngineVersion x -> EngineVersion
forall x. EngineVersion -> Rep EngineVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EngineVersion x -> EngineVersion
$cfrom :: forall x. EngineVersion -> Rep EngineVersion x
Prelude.Generic)

-- |
-- Create a value of 'EngineVersion' 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:
--
-- 'effectiveEngineVersion', 'engineVersion_effectiveEngineVersion' - Read only. The engine version on which the query runs. If the user
-- requests a valid engine version other than Auto, the effective engine
-- version is the same as the engine version that the user requested. If
-- the user requests Auto, the effective engine version is chosen by
-- Athena. When a request to update the engine version is made by a
-- @CreateWorkGroup@ or @UpdateWorkGroup@ operation, the
-- @EffectiveEngineVersion@ field is ignored.
--
-- 'selectedEngineVersion', 'engineVersion_selectedEngineVersion' - The engine version requested by the user. Possible values are determined
-- by the output of @ListEngineVersions@, including Auto. The default is
-- Auto.
newEngineVersion ::
  EngineVersion
newEngineVersion :: EngineVersion
newEngineVersion =
  EngineVersion' :: Maybe Text -> Maybe Text -> EngineVersion
EngineVersion'
    { $sel:effectiveEngineVersion:EngineVersion' :: Maybe Text
effectiveEngineVersion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:selectedEngineVersion:EngineVersion' :: Maybe Text
selectedEngineVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Read only. The engine version on which the query runs. If the user
-- requests a valid engine version other than Auto, the effective engine
-- version is the same as the engine version that the user requested. If
-- the user requests Auto, the effective engine version is chosen by
-- Athena. When a request to update the engine version is made by a
-- @CreateWorkGroup@ or @UpdateWorkGroup@ operation, the
-- @EffectiveEngineVersion@ field is ignored.
engineVersion_effectiveEngineVersion :: Lens.Lens' EngineVersion (Prelude.Maybe Prelude.Text)
engineVersion_effectiveEngineVersion :: (Maybe Text -> f (Maybe Text)) -> EngineVersion -> f EngineVersion
engineVersion_effectiveEngineVersion = (EngineVersion -> Maybe Text)
-> (EngineVersion -> Maybe Text -> EngineVersion)
-> Lens EngineVersion EngineVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EngineVersion' {Maybe Text
effectiveEngineVersion :: Maybe Text
$sel:effectiveEngineVersion:EngineVersion' :: EngineVersion -> Maybe Text
effectiveEngineVersion} -> Maybe Text
effectiveEngineVersion) (\s :: EngineVersion
s@EngineVersion' {} Maybe Text
a -> EngineVersion
s {$sel:effectiveEngineVersion:EngineVersion' :: Maybe Text
effectiveEngineVersion = Maybe Text
a} :: EngineVersion)

-- | The engine version requested by the user. Possible values are determined
-- by the output of @ListEngineVersions@, including Auto. The default is
-- Auto.
engineVersion_selectedEngineVersion :: Lens.Lens' EngineVersion (Prelude.Maybe Prelude.Text)
engineVersion_selectedEngineVersion :: (Maybe Text -> f (Maybe Text)) -> EngineVersion -> f EngineVersion
engineVersion_selectedEngineVersion = (EngineVersion -> Maybe Text)
-> (EngineVersion -> Maybe Text -> EngineVersion)
-> Lens EngineVersion EngineVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EngineVersion' {Maybe Text
selectedEngineVersion :: Maybe Text
$sel:selectedEngineVersion:EngineVersion' :: EngineVersion -> Maybe Text
selectedEngineVersion} -> Maybe Text
selectedEngineVersion) (\s :: EngineVersion
s@EngineVersion' {} Maybe Text
a -> EngineVersion
s {$sel:selectedEngineVersion:EngineVersion' :: Maybe Text
selectedEngineVersion = Maybe Text
a} :: EngineVersion)

instance Core.FromJSON EngineVersion where
  parseJSON :: Value -> Parser EngineVersion
parseJSON =
    String
-> (Object -> Parser EngineVersion)
-> Value
-> Parser EngineVersion
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EngineVersion"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> EngineVersion
EngineVersion'
            (Maybe Text -> Maybe Text -> EngineVersion)
-> Parser (Maybe Text) -> Parser (Maybe Text -> EngineVersion)
forall (f :: * -> *) a b. Functor 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
"EffectiveEngineVersion")
            Parser (Maybe Text -> EngineVersion)
-> Parser (Maybe Text) -> Parser EngineVersion
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
"SelectedEngineVersion")
      )

instance Prelude.Hashable EngineVersion

instance Prelude.NFData EngineVersion

instance Core.ToJSON EngineVersion where
  toJSON :: EngineVersion -> Value
toJSON EngineVersion' {Maybe Text
selectedEngineVersion :: Maybe Text
effectiveEngineVersion :: Maybe Text
$sel:selectedEngineVersion:EngineVersion' :: EngineVersion -> Maybe Text
$sel:effectiveEngineVersion:EngineVersion' :: EngineVersion -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EffectiveEngineVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
effectiveEngineVersion,
            (Text
"SelectedEngineVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
selectedEngineVersion
          ]
      )