{-# 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.Glue.CancelStatement
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Cancels the statement.
module Amazonka.Glue.CancelStatement
  ( -- * Creating a Request
    CancelStatement (..),
    newCancelStatement,

    -- * Request Lenses
    cancelStatement_requestOrigin,
    cancelStatement_sessionId,
    cancelStatement_id,

    -- * Destructuring the Response
    CancelStatementResponse (..),
    newCancelStatementResponse,

    -- * Response Lenses
    cancelStatementResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCancelStatement' smart constructor.
data CancelStatement = CancelStatement'
  { -- | The origin of the request to cancel the statement.
    CancelStatement -> Maybe Text
requestOrigin :: Prelude.Maybe Prelude.Text,
    -- | The Session ID of the statement to be cancelled.
    CancelStatement -> Text
sessionId :: Prelude.Text,
    -- | The ID of the statement to be cancelled.
    CancelStatement -> Int
id :: Prelude.Int
  }
  deriving (CancelStatement -> CancelStatement -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelStatement -> CancelStatement -> Bool
$c/= :: CancelStatement -> CancelStatement -> Bool
== :: CancelStatement -> CancelStatement -> Bool
$c== :: CancelStatement -> CancelStatement -> Bool
Prelude.Eq, ReadPrec [CancelStatement]
ReadPrec CancelStatement
Int -> ReadS CancelStatement
ReadS [CancelStatement]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelStatement]
$creadListPrec :: ReadPrec [CancelStatement]
readPrec :: ReadPrec CancelStatement
$creadPrec :: ReadPrec CancelStatement
readList :: ReadS [CancelStatement]
$creadList :: ReadS [CancelStatement]
readsPrec :: Int -> ReadS CancelStatement
$creadsPrec :: Int -> ReadS CancelStatement
Prelude.Read, Int -> CancelStatement -> ShowS
[CancelStatement] -> ShowS
CancelStatement -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelStatement] -> ShowS
$cshowList :: [CancelStatement] -> ShowS
show :: CancelStatement -> String
$cshow :: CancelStatement -> String
showsPrec :: Int -> CancelStatement -> ShowS
$cshowsPrec :: Int -> CancelStatement -> ShowS
Prelude.Show, forall x. Rep CancelStatement x -> CancelStatement
forall x. CancelStatement -> Rep CancelStatement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelStatement x -> CancelStatement
$cfrom :: forall x. CancelStatement -> Rep CancelStatement x
Prelude.Generic)

-- |
-- Create a value of 'CancelStatement' 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:
--
-- 'requestOrigin', 'cancelStatement_requestOrigin' - The origin of the request to cancel the statement.
--
-- 'sessionId', 'cancelStatement_sessionId' - The Session ID of the statement to be cancelled.
--
-- 'id', 'cancelStatement_id' - The ID of the statement to be cancelled.
newCancelStatement ::
  -- | 'sessionId'
  Prelude.Text ->
  -- | 'id'
  Prelude.Int ->
  CancelStatement
newCancelStatement :: Text -> Int -> CancelStatement
newCancelStatement Text
pSessionId_ Int
pId_ =
  CancelStatement'
    { $sel:requestOrigin:CancelStatement' :: Maybe Text
requestOrigin = forall a. Maybe a
Prelude.Nothing,
      $sel:sessionId:CancelStatement' :: Text
sessionId = Text
pSessionId_,
      $sel:id:CancelStatement' :: Int
id = Int
pId_
    }

-- | The origin of the request to cancel the statement.
cancelStatement_requestOrigin :: Lens.Lens' CancelStatement (Prelude.Maybe Prelude.Text)
cancelStatement_requestOrigin :: Lens' CancelStatement (Maybe Text)
cancelStatement_requestOrigin = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelStatement' {Maybe Text
requestOrigin :: Maybe Text
$sel:requestOrigin:CancelStatement' :: CancelStatement -> Maybe Text
requestOrigin} -> Maybe Text
requestOrigin) (\s :: CancelStatement
s@CancelStatement' {} Maybe Text
a -> CancelStatement
s {$sel:requestOrigin:CancelStatement' :: Maybe Text
requestOrigin = Maybe Text
a} :: CancelStatement)

-- | The Session ID of the statement to be cancelled.
cancelStatement_sessionId :: Lens.Lens' CancelStatement Prelude.Text
cancelStatement_sessionId :: Lens' CancelStatement Text
cancelStatement_sessionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelStatement' {Text
sessionId :: Text
$sel:sessionId:CancelStatement' :: CancelStatement -> Text
sessionId} -> Text
sessionId) (\s :: CancelStatement
s@CancelStatement' {} Text
a -> CancelStatement
s {$sel:sessionId:CancelStatement' :: Text
sessionId = Text
a} :: CancelStatement)

-- | The ID of the statement to be cancelled.
cancelStatement_id :: Lens.Lens' CancelStatement Prelude.Int
cancelStatement_id :: Lens' CancelStatement Int
cancelStatement_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelStatement' {Int
id :: Int
$sel:id:CancelStatement' :: CancelStatement -> Int
id} -> Int
id) (\s :: CancelStatement
s@CancelStatement' {} Int
a -> CancelStatement
s {$sel:id:CancelStatement' :: Int
id = Int
a} :: CancelStatement)

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

instance Prelude.Hashable CancelStatement where
  hashWithSalt :: Int -> CancelStatement -> Int
hashWithSalt Int
_salt CancelStatement' {Int
Maybe Text
Text
id :: Int
sessionId :: Text
requestOrigin :: Maybe Text
$sel:id:CancelStatement' :: CancelStatement -> Int
$sel:sessionId:CancelStatement' :: CancelStatement -> Text
$sel:requestOrigin:CancelStatement' :: CancelStatement -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
requestOrigin
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sessionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
id

instance Prelude.NFData CancelStatement where
  rnf :: CancelStatement -> ()
rnf CancelStatement' {Int
Maybe Text
Text
id :: Int
sessionId :: Text
requestOrigin :: Maybe Text
$sel:id:CancelStatement' :: CancelStatement -> Int
$sel:sessionId:CancelStatement' :: CancelStatement -> Text
$sel:requestOrigin:CancelStatement' :: CancelStatement -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
requestOrigin
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sessionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
id

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

instance Data.ToJSON CancelStatement where
  toJSON :: CancelStatement -> Value
toJSON CancelStatement' {Int
Maybe Text
Text
id :: Int
sessionId :: Text
requestOrigin :: Maybe Text
$sel:id:CancelStatement' :: CancelStatement -> Int
$sel:sessionId:CancelStatement' :: CancelStatement -> Text
$sel:requestOrigin:CancelStatement' :: CancelStatement -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"RequestOrigin" 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 Text
requestOrigin,
            forall a. a -> Maybe a
Prelude.Just (Key
"SessionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
sessionId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Int
id)
          ]
      )

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

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

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

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

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

instance Prelude.NFData CancelStatementResponse where
  rnf :: CancelStatementResponse -> ()
rnf CancelStatementResponse' {Int
httpStatus :: Int
$sel:httpStatus:CancelStatementResponse' :: CancelStatementResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus