{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.UpdatePreparedStatement
-- 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)
--
-- Updates a prepared statement.
module Amazonka.Athena.UpdatePreparedStatement
  ( -- * Creating a Request
    UpdatePreparedStatement (..),
    newUpdatePreparedStatement,

    -- * Request Lenses
    updatePreparedStatement_description,
    updatePreparedStatement_statementName,
    updatePreparedStatement_workGroup,
    updatePreparedStatement_queryStatement,

    -- * Destructuring the Response
    UpdatePreparedStatementResponse (..),
    newUpdatePreparedStatementResponse,

    -- * Response Lenses
    updatePreparedStatementResponse_httpStatus,
  )
where

import Amazonka.Athena.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdatePreparedStatement' smart constructor.
data UpdatePreparedStatement = UpdatePreparedStatement'
  { -- | The description of the prepared statement.
    UpdatePreparedStatement -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of the prepared statement.
    UpdatePreparedStatement -> Text
statementName :: Prelude.Text,
    -- | The workgroup for the prepared statement.
    UpdatePreparedStatement -> Text
workGroup :: Prelude.Text,
    -- | The query string for the prepared statement.
    UpdatePreparedStatement -> Text
queryStatement :: Prelude.Text
  }
  deriving (UpdatePreparedStatement -> UpdatePreparedStatement -> Bool
(UpdatePreparedStatement -> UpdatePreparedStatement -> Bool)
-> (UpdatePreparedStatement -> UpdatePreparedStatement -> Bool)
-> Eq UpdatePreparedStatement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePreparedStatement -> UpdatePreparedStatement -> Bool
$c/= :: UpdatePreparedStatement -> UpdatePreparedStatement -> Bool
== :: UpdatePreparedStatement -> UpdatePreparedStatement -> Bool
$c== :: UpdatePreparedStatement -> UpdatePreparedStatement -> Bool
Prelude.Eq, ReadPrec [UpdatePreparedStatement]
ReadPrec UpdatePreparedStatement
Int -> ReadS UpdatePreparedStatement
ReadS [UpdatePreparedStatement]
(Int -> ReadS UpdatePreparedStatement)
-> ReadS [UpdatePreparedStatement]
-> ReadPrec UpdatePreparedStatement
-> ReadPrec [UpdatePreparedStatement]
-> Read UpdatePreparedStatement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePreparedStatement]
$creadListPrec :: ReadPrec [UpdatePreparedStatement]
readPrec :: ReadPrec UpdatePreparedStatement
$creadPrec :: ReadPrec UpdatePreparedStatement
readList :: ReadS [UpdatePreparedStatement]
$creadList :: ReadS [UpdatePreparedStatement]
readsPrec :: Int -> ReadS UpdatePreparedStatement
$creadsPrec :: Int -> ReadS UpdatePreparedStatement
Prelude.Read, Int -> UpdatePreparedStatement -> ShowS
[UpdatePreparedStatement] -> ShowS
UpdatePreparedStatement -> String
(Int -> UpdatePreparedStatement -> ShowS)
-> (UpdatePreparedStatement -> String)
-> ([UpdatePreparedStatement] -> ShowS)
-> Show UpdatePreparedStatement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePreparedStatement] -> ShowS
$cshowList :: [UpdatePreparedStatement] -> ShowS
show :: UpdatePreparedStatement -> String
$cshow :: UpdatePreparedStatement -> String
showsPrec :: Int -> UpdatePreparedStatement -> ShowS
$cshowsPrec :: Int -> UpdatePreparedStatement -> ShowS
Prelude.Show, (forall x.
 UpdatePreparedStatement -> Rep UpdatePreparedStatement x)
-> (forall x.
    Rep UpdatePreparedStatement x -> UpdatePreparedStatement)
-> Generic UpdatePreparedStatement
forall x. Rep UpdatePreparedStatement x -> UpdatePreparedStatement
forall x. UpdatePreparedStatement -> Rep UpdatePreparedStatement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdatePreparedStatement x -> UpdatePreparedStatement
$cfrom :: forall x. UpdatePreparedStatement -> Rep UpdatePreparedStatement x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePreparedStatement' 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:
--
-- 'description', 'updatePreparedStatement_description' - The description of the prepared statement.
--
-- 'statementName', 'updatePreparedStatement_statementName' - The name of the prepared statement.
--
-- 'workGroup', 'updatePreparedStatement_workGroup' - The workgroup for the prepared statement.
--
-- 'queryStatement', 'updatePreparedStatement_queryStatement' - The query string for the prepared statement.
newUpdatePreparedStatement ::
  -- | 'statementName'
  Prelude.Text ->
  -- | 'workGroup'
  Prelude.Text ->
  -- | 'queryStatement'
  Prelude.Text ->
  UpdatePreparedStatement
newUpdatePreparedStatement :: Text -> Text -> Text -> UpdatePreparedStatement
newUpdatePreparedStatement
  Text
pStatementName_
  Text
pWorkGroup_
  Text
pQueryStatement_ =
    UpdatePreparedStatement' :: Maybe Text -> Text -> Text -> Text -> UpdatePreparedStatement
UpdatePreparedStatement'
      { $sel:description:UpdatePreparedStatement' :: Maybe Text
description =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:statementName:UpdatePreparedStatement' :: Text
statementName = Text
pStatementName_,
        $sel:workGroup:UpdatePreparedStatement' :: Text
workGroup = Text
pWorkGroup_,
        $sel:queryStatement:UpdatePreparedStatement' :: Text
queryStatement = Text
pQueryStatement_
      }

-- | The description of the prepared statement.
updatePreparedStatement_description :: Lens.Lens' UpdatePreparedStatement (Prelude.Maybe Prelude.Text)
updatePreparedStatement_description :: (Maybe Text -> f (Maybe Text))
-> UpdatePreparedStatement -> f UpdatePreparedStatement
updatePreparedStatement_description = (UpdatePreparedStatement -> Maybe Text)
-> (UpdatePreparedStatement
    -> Maybe Text -> UpdatePreparedStatement)
-> Lens
     UpdatePreparedStatement
     UpdatePreparedStatement
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePreparedStatement' {Maybe Text
description :: Maybe Text
$sel:description:UpdatePreparedStatement' :: UpdatePreparedStatement -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdatePreparedStatement
s@UpdatePreparedStatement' {} Maybe Text
a -> UpdatePreparedStatement
s {$sel:description:UpdatePreparedStatement' :: Maybe Text
description = Maybe Text
a} :: UpdatePreparedStatement)

-- | The name of the prepared statement.
updatePreparedStatement_statementName :: Lens.Lens' UpdatePreparedStatement Prelude.Text
updatePreparedStatement_statementName :: (Text -> f Text)
-> UpdatePreparedStatement -> f UpdatePreparedStatement
updatePreparedStatement_statementName = (UpdatePreparedStatement -> Text)
-> (UpdatePreparedStatement -> Text -> UpdatePreparedStatement)
-> Lens UpdatePreparedStatement UpdatePreparedStatement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePreparedStatement' {Text
statementName :: Text
$sel:statementName:UpdatePreparedStatement' :: UpdatePreparedStatement -> Text
statementName} -> Text
statementName) (\s :: UpdatePreparedStatement
s@UpdatePreparedStatement' {} Text
a -> UpdatePreparedStatement
s {$sel:statementName:UpdatePreparedStatement' :: Text
statementName = Text
a} :: UpdatePreparedStatement)

-- | The workgroup for the prepared statement.
updatePreparedStatement_workGroup :: Lens.Lens' UpdatePreparedStatement Prelude.Text
updatePreparedStatement_workGroup :: (Text -> f Text)
-> UpdatePreparedStatement -> f UpdatePreparedStatement
updatePreparedStatement_workGroup = (UpdatePreparedStatement -> Text)
-> (UpdatePreparedStatement -> Text -> UpdatePreparedStatement)
-> Lens UpdatePreparedStatement UpdatePreparedStatement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePreparedStatement' {Text
workGroup :: Text
$sel:workGroup:UpdatePreparedStatement' :: UpdatePreparedStatement -> Text
workGroup} -> Text
workGroup) (\s :: UpdatePreparedStatement
s@UpdatePreparedStatement' {} Text
a -> UpdatePreparedStatement
s {$sel:workGroup:UpdatePreparedStatement' :: Text
workGroup = Text
a} :: UpdatePreparedStatement)

-- | The query string for the prepared statement.
updatePreparedStatement_queryStatement :: Lens.Lens' UpdatePreparedStatement Prelude.Text
updatePreparedStatement_queryStatement :: (Text -> f Text)
-> UpdatePreparedStatement -> f UpdatePreparedStatement
updatePreparedStatement_queryStatement = (UpdatePreparedStatement -> Text)
-> (UpdatePreparedStatement -> Text -> UpdatePreparedStatement)
-> Lens UpdatePreparedStatement UpdatePreparedStatement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePreparedStatement' {Text
queryStatement :: Text
$sel:queryStatement:UpdatePreparedStatement' :: UpdatePreparedStatement -> Text
queryStatement} -> Text
queryStatement) (\s :: UpdatePreparedStatement
s@UpdatePreparedStatement' {} Text
a -> UpdatePreparedStatement
s {$sel:queryStatement:UpdatePreparedStatement' :: Text
queryStatement = Text
a} :: UpdatePreparedStatement)

instance Core.AWSRequest UpdatePreparedStatement where
  type
    AWSResponse UpdatePreparedStatement =
      UpdatePreparedStatementResponse
  request :: UpdatePreparedStatement -> Request UpdatePreparedStatement
request = Service
-> UpdatePreparedStatement -> Request UpdatePreparedStatement
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdatePreparedStatement
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdatePreparedStatement)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdatePreparedStatement))
-> Logger
-> Service
-> Proxy UpdatePreparedStatement
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdatePreparedStatement)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdatePreparedStatementResponse
UpdatePreparedStatementResponse'
            (Int -> UpdatePreparedStatementResponse)
-> Either String Int
-> Either String UpdatePreparedStatementResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdatePreparedStatement

instance Prelude.NFData UpdatePreparedStatement

instance Core.ToHeaders UpdatePreparedStatement where
  toHeaders :: UpdatePreparedStatement -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdatePreparedStatement -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AmazonAthena.UpdatePreparedStatement" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdatePreparedStatement where
  toJSON :: UpdatePreparedStatement -> Value
toJSON UpdatePreparedStatement' {Maybe Text
Text
queryStatement :: Text
workGroup :: Text
statementName :: Text
description :: Maybe Text
$sel:queryStatement:UpdatePreparedStatement' :: UpdatePreparedStatement -> Text
$sel:workGroup:UpdatePreparedStatement' :: UpdatePreparedStatement -> Text
$sel:statementName:UpdatePreparedStatement' :: UpdatePreparedStatement -> Text
$sel:description:UpdatePreparedStatement' :: UpdatePreparedStatement -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Description" 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
description,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StatementName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
statementName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"WorkGroup" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
workGroup),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"QueryStatement" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
queryStatement)
          ]
      )

instance Core.ToPath UpdatePreparedStatement where
  toPath :: UpdatePreparedStatement -> ByteString
toPath = ByteString -> UpdatePreparedStatement -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery UpdatePreparedStatement where
  toQuery :: UpdatePreparedStatement -> QueryString
toQuery = QueryString -> UpdatePreparedStatement -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdatePreparedStatementResponse' smart constructor.
data UpdatePreparedStatementResponse = UpdatePreparedStatementResponse'
  { -- | The response's http status code.
    UpdatePreparedStatementResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdatePreparedStatementResponse
-> UpdatePreparedStatementResponse -> Bool
(UpdatePreparedStatementResponse
 -> UpdatePreparedStatementResponse -> Bool)
-> (UpdatePreparedStatementResponse
    -> UpdatePreparedStatementResponse -> Bool)
-> Eq UpdatePreparedStatementResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePreparedStatementResponse
-> UpdatePreparedStatementResponse -> Bool
$c/= :: UpdatePreparedStatementResponse
-> UpdatePreparedStatementResponse -> Bool
== :: UpdatePreparedStatementResponse
-> UpdatePreparedStatementResponse -> Bool
$c== :: UpdatePreparedStatementResponse
-> UpdatePreparedStatementResponse -> Bool
Prelude.Eq, ReadPrec [UpdatePreparedStatementResponse]
ReadPrec UpdatePreparedStatementResponse
Int -> ReadS UpdatePreparedStatementResponse
ReadS [UpdatePreparedStatementResponse]
(Int -> ReadS UpdatePreparedStatementResponse)
-> ReadS [UpdatePreparedStatementResponse]
-> ReadPrec UpdatePreparedStatementResponse
-> ReadPrec [UpdatePreparedStatementResponse]
-> Read UpdatePreparedStatementResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePreparedStatementResponse]
$creadListPrec :: ReadPrec [UpdatePreparedStatementResponse]
readPrec :: ReadPrec UpdatePreparedStatementResponse
$creadPrec :: ReadPrec UpdatePreparedStatementResponse
readList :: ReadS [UpdatePreparedStatementResponse]
$creadList :: ReadS [UpdatePreparedStatementResponse]
readsPrec :: Int -> ReadS UpdatePreparedStatementResponse
$creadsPrec :: Int -> ReadS UpdatePreparedStatementResponse
Prelude.Read, Int -> UpdatePreparedStatementResponse -> ShowS
[UpdatePreparedStatementResponse] -> ShowS
UpdatePreparedStatementResponse -> String
(Int -> UpdatePreparedStatementResponse -> ShowS)
-> (UpdatePreparedStatementResponse -> String)
-> ([UpdatePreparedStatementResponse] -> ShowS)
-> Show UpdatePreparedStatementResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePreparedStatementResponse] -> ShowS
$cshowList :: [UpdatePreparedStatementResponse] -> ShowS
show :: UpdatePreparedStatementResponse -> String
$cshow :: UpdatePreparedStatementResponse -> String
showsPrec :: Int -> UpdatePreparedStatementResponse -> ShowS
$cshowsPrec :: Int -> UpdatePreparedStatementResponse -> ShowS
Prelude.Show, (forall x.
 UpdatePreparedStatementResponse
 -> Rep UpdatePreparedStatementResponse x)
-> (forall x.
    Rep UpdatePreparedStatementResponse x
    -> UpdatePreparedStatementResponse)
-> Generic UpdatePreparedStatementResponse
forall x.
Rep UpdatePreparedStatementResponse x
-> UpdatePreparedStatementResponse
forall x.
UpdatePreparedStatementResponse
-> Rep UpdatePreparedStatementResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdatePreparedStatementResponse x
-> UpdatePreparedStatementResponse
$cfrom :: forall x.
UpdatePreparedStatementResponse
-> Rep UpdatePreparedStatementResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePreparedStatementResponse' 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:
--
-- 'httpStatus', 'updatePreparedStatementResponse_httpStatus' - The response's http status code.
newUpdatePreparedStatementResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdatePreparedStatementResponse
newUpdatePreparedStatementResponse :: Int -> UpdatePreparedStatementResponse
newUpdatePreparedStatementResponse Int
pHttpStatus_ =
  UpdatePreparedStatementResponse' :: Int -> UpdatePreparedStatementResponse
UpdatePreparedStatementResponse'
    { $sel:httpStatus:UpdatePreparedStatementResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
updatePreparedStatementResponse_httpStatus :: Lens.Lens' UpdatePreparedStatementResponse Prelude.Int
updatePreparedStatementResponse_httpStatus :: (Int -> f Int)
-> UpdatePreparedStatementResponse
-> f UpdatePreparedStatementResponse
updatePreparedStatementResponse_httpStatus = (UpdatePreparedStatementResponse -> Int)
-> (UpdatePreparedStatementResponse
    -> Int -> UpdatePreparedStatementResponse)
-> Lens
     UpdatePreparedStatementResponse
     UpdatePreparedStatementResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePreparedStatementResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdatePreparedStatementResponse' :: UpdatePreparedStatementResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdatePreparedStatementResponse
s@UpdatePreparedStatementResponse' {} Int
a -> UpdatePreparedStatementResponse
s {$sel:httpStatus:UpdatePreparedStatementResponse' :: Int
httpStatus = Int
a} :: UpdatePreparedStatementResponse)

instance
  Prelude.NFData
    UpdatePreparedStatementResponse