{-# 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.DeleteNamedQuery
-- 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)
--
-- Deletes the named query if you have access to the workgroup in which the
-- query was saved.
--
-- For code samples using the Amazon Web Services SDK for Java, see
-- <http://docs.aws.amazon.com/athena/latest/ug/code-samples.html Examples and Code Samples>
-- in the /Amazon Athena User Guide/.
module Amazonka.Athena.DeleteNamedQuery
  ( -- * Creating a Request
    DeleteNamedQuery (..),
    newDeleteNamedQuery,

    -- * Request Lenses
    deleteNamedQuery_namedQueryId,

    -- * Destructuring the Response
    DeleteNamedQueryResponse (..),
    newDeleteNamedQueryResponse,

    -- * Response Lenses
    deleteNamedQueryResponse_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:/ 'newDeleteNamedQuery' smart constructor.
data DeleteNamedQuery = DeleteNamedQuery'
  { -- | The unique ID of the query to delete.
    DeleteNamedQuery -> Text
namedQueryId :: Prelude.Text
  }
  deriving (DeleteNamedQuery -> DeleteNamedQuery -> Bool
(DeleteNamedQuery -> DeleteNamedQuery -> Bool)
-> (DeleteNamedQuery -> DeleteNamedQuery -> Bool)
-> Eq DeleteNamedQuery
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteNamedQuery -> DeleteNamedQuery -> Bool
$c/= :: DeleteNamedQuery -> DeleteNamedQuery -> Bool
== :: DeleteNamedQuery -> DeleteNamedQuery -> Bool
$c== :: DeleteNamedQuery -> DeleteNamedQuery -> Bool
Prelude.Eq, ReadPrec [DeleteNamedQuery]
ReadPrec DeleteNamedQuery
Int -> ReadS DeleteNamedQuery
ReadS [DeleteNamedQuery]
(Int -> ReadS DeleteNamedQuery)
-> ReadS [DeleteNamedQuery]
-> ReadPrec DeleteNamedQuery
-> ReadPrec [DeleteNamedQuery]
-> Read DeleteNamedQuery
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteNamedQuery]
$creadListPrec :: ReadPrec [DeleteNamedQuery]
readPrec :: ReadPrec DeleteNamedQuery
$creadPrec :: ReadPrec DeleteNamedQuery
readList :: ReadS [DeleteNamedQuery]
$creadList :: ReadS [DeleteNamedQuery]
readsPrec :: Int -> ReadS DeleteNamedQuery
$creadsPrec :: Int -> ReadS DeleteNamedQuery
Prelude.Read, Int -> DeleteNamedQuery -> ShowS
[DeleteNamedQuery] -> ShowS
DeleteNamedQuery -> String
(Int -> DeleteNamedQuery -> ShowS)
-> (DeleteNamedQuery -> String)
-> ([DeleteNamedQuery] -> ShowS)
-> Show DeleteNamedQuery
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteNamedQuery] -> ShowS
$cshowList :: [DeleteNamedQuery] -> ShowS
show :: DeleteNamedQuery -> String
$cshow :: DeleteNamedQuery -> String
showsPrec :: Int -> DeleteNamedQuery -> ShowS
$cshowsPrec :: Int -> DeleteNamedQuery -> ShowS
Prelude.Show, (forall x. DeleteNamedQuery -> Rep DeleteNamedQuery x)
-> (forall x. Rep DeleteNamedQuery x -> DeleteNamedQuery)
-> Generic DeleteNamedQuery
forall x. Rep DeleteNamedQuery x -> DeleteNamedQuery
forall x. DeleteNamedQuery -> Rep DeleteNamedQuery x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteNamedQuery x -> DeleteNamedQuery
$cfrom :: forall x. DeleteNamedQuery -> Rep DeleteNamedQuery x
Prelude.Generic)

-- |
-- Create a value of 'DeleteNamedQuery' 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:
--
-- 'namedQueryId', 'deleteNamedQuery_namedQueryId' - The unique ID of the query to delete.
newDeleteNamedQuery ::
  -- | 'namedQueryId'
  Prelude.Text ->
  DeleteNamedQuery
newDeleteNamedQuery :: Text -> DeleteNamedQuery
newDeleteNamedQuery Text
pNamedQueryId_ =
  DeleteNamedQuery' :: Text -> DeleteNamedQuery
DeleteNamedQuery' {$sel:namedQueryId:DeleteNamedQuery' :: Text
namedQueryId = Text
pNamedQueryId_}

-- | The unique ID of the query to delete.
deleteNamedQuery_namedQueryId :: Lens.Lens' DeleteNamedQuery Prelude.Text
deleteNamedQuery_namedQueryId :: (Text -> f Text) -> DeleteNamedQuery -> f DeleteNamedQuery
deleteNamedQuery_namedQueryId = (DeleteNamedQuery -> Text)
-> (DeleteNamedQuery -> Text -> DeleteNamedQuery)
-> Lens DeleteNamedQuery DeleteNamedQuery Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteNamedQuery' {Text
namedQueryId :: Text
$sel:namedQueryId:DeleteNamedQuery' :: DeleteNamedQuery -> Text
namedQueryId} -> Text
namedQueryId) (\s :: DeleteNamedQuery
s@DeleteNamedQuery' {} Text
a -> DeleteNamedQuery
s {$sel:namedQueryId:DeleteNamedQuery' :: Text
namedQueryId = Text
a} :: DeleteNamedQuery)

instance Core.AWSRequest DeleteNamedQuery where
  type
    AWSResponse DeleteNamedQuery =
      DeleteNamedQueryResponse
  request :: DeleteNamedQuery -> Request DeleteNamedQuery
request = Service -> DeleteNamedQuery -> Request DeleteNamedQuery
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteNamedQuery
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteNamedQuery)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteNamedQuery))
-> Logger
-> Service
-> Proxy DeleteNamedQuery
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteNamedQuery)))
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 -> DeleteNamedQueryResponse
DeleteNamedQueryResponse'
            (Int -> DeleteNamedQueryResponse)
-> Either String Int -> Either String DeleteNamedQueryResponse
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 DeleteNamedQuery

instance Prelude.NFData DeleteNamedQuery

instance Core.ToHeaders DeleteNamedQuery where
  toHeaders :: DeleteNamedQuery -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteNamedQuery -> 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.DeleteNamedQuery" ::
                          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 DeleteNamedQuery where
  toJSON :: DeleteNamedQuery -> Value
toJSON DeleteNamedQuery' {Text
namedQueryId :: Text
$sel:namedQueryId:DeleteNamedQuery' :: DeleteNamedQuery -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"NamedQueryId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
namedQueryId)]
      )

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

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

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

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

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

instance Prelude.NFData DeleteNamedQueryResponse