{-# 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.DeletePartitionIndex
-- 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 a specified partition index from an existing table.
module Amazonka.Glue.DeletePartitionIndex
  ( -- * Creating a Request
    DeletePartitionIndex (..),
    newDeletePartitionIndex,

    -- * Request Lenses
    deletePartitionIndex_catalogId,
    deletePartitionIndex_databaseName,
    deletePartitionIndex_tableName,
    deletePartitionIndex_indexName,

    -- * Destructuring the Response
    DeletePartitionIndexResponse (..),
    newDeletePartitionIndexResponse,

    -- * Response Lenses
    deletePartitionIndexResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types
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:/ 'newDeletePartitionIndex' smart constructor.
data DeletePartitionIndex = DeletePartitionIndex'
  { -- | The catalog ID where the table resides.
    DeletePartitionIndex -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | Specifies the name of a database from which you want to delete a
    -- partition index.
    DeletePartitionIndex -> Text
databaseName :: Prelude.Text,
    -- | Specifies the name of a table from which you want to delete a partition
    -- index.
    DeletePartitionIndex -> Text
tableName :: Prelude.Text,
    -- | The name of the partition index to be deleted.
    DeletePartitionIndex -> Text
indexName :: Prelude.Text
  }
  deriving (DeletePartitionIndex -> DeletePartitionIndex -> Bool
(DeletePartitionIndex -> DeletePartitionIndex -> Bool)
-> (DeletePartitionIndex -> DeletePartitionIndex -> Bool)
-> Eq DeletePartitionIndex
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletePartitionIndex -> DeletePartitionIndex -> Bool
$c/= :: DeletePartitionIndex -> DeletePartitionIndex -> Bool
== :: DeletePartitionIndex -> DeletePartitionIndex -> Bool
$c== :: DeletePartitionIndex -> DeletePartitionIndex -> Bool
Prelude.Eq, ReadPrec [DeletePartitionIndex]
ReadPrec DeletePartitionIndex
Int -> ReadS DeletePartitionIndex
ReadS [DeletePartitionIndex]
(Int -> ReadS DeletePartitionIndex)
-> ReadS [DeletePartitionIndex]
-> ReadPrec DeletePartitionIndex
-> ReadPrec [DeletePartitionIndex]
-> Read DeletePartitionIndex
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeletePartitionIndex]
$creadListPrec :: ReadPrec [DeletePartitionIndex]
readPrec :: ReadPrec DeletePartitionIndex
$creadPrec :: ReadPrec DeletePartitionIndex
readList :: ReadS [DeletePartitionIndex]
$creadList :: ReadS [DeletePartitionIndex]
readsPrec :: Int -> ReadS DeletePartitionIndex
$creadsPrec :: Int -> ReadS DeletePartitionIndex
Prelude.Read, Int -> DeletePartitionIndex -> ShowS
[DeletePartitionIndex] -> ShowS
DeletePartitionIndex -> String
(Int -> DeletePartitionIndex -> ShowS)
-> (DeletePartitionIndex -> String)
-> ([DeletePartitionIndex] -> ShowS)
-> Show DeletePartitionIndex
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletePartitionIndex] -> ShowS
$cshowList :: [DeletePartitionIndex] -> ShowS
show :: DeletePartitionIndex -> String
$cshow :: DeletePartitionIndex -> String
showsPrec :: Int -> DeletePartitionIndex -> ShowS
$cshowsPrec :: Int -> DeletePartitionIndex -> ShowS
Prelude.Show, (forall x. DeletePartitionIndex -> Rep DeletePartitionIndex x)
-> (forall x. Rep DeletePartitionIndex x -> DeletePartitionIndex)
-> Generic DeletePartitionIndex
forall x. Rep DeletePartitionIndex x -> DeletePartitionIndex
forall x. DeletePartitionIndex -> Rep DeletePartitionIndex x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeletePartitionIndex x -> DeletePartitionIndex
$cfrom :: forall x. DeletePartitionIndex -> Rep DeletePartitionIndex x
Prelude.Generic)

-- |
-- Create a value of 'DeletePartitionIndex' 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:
--
-- 'catalogId', 'deletePartitionIndex_catalogId' - The catalog ID where the table resides.
--
-- 'databaseName', 'deletePartitionIndex_databaseName' - Specifies the name of a database from which you want to delete a
-- partition index.
--
-- 'tableName', 'deletePartitionIndex_tableName' - Specifies the name of a table from which you want to delete a partition
-- index.
--
-- 'indexName', 'deletePartitionIndex_indexName' - The name of the partition index to be deleted.
newDeletePartitionIndex ::
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'tableName'
  Prelude.Text ->
  -- | 'indexName'
  Prelude.Text ->
  DeletePartitionIndex
newDeletePartitionIndex :: Text -> Text -> Text -> DeletePartitionIndex
newDeletePartitionIndex
  Text
pDatabaseName_
  Text
pTableName_
  Text
pIndexName_ =
    DeletePartitionIndex' :: Maybe Text -> Text -> Text -> Text -> DeletePartitionIndex
DeletePartitionIndex'
      { $sel:catalogId:DeletePartitionIndex' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:databaseName:DeletePartitionIndex' :: Text
databaseName = Text
pDatabaseName_,
        $sel:tableName:DeletePartitionIndex' :: Text
tableName = Text
pTableName_,
        $sel:indexName:DeletePartitionIndex' :: Text
indexName = Text
pIndexName_
      }

-- | The catalog ID where the table resides.
deletePartitionIndex_catalogId :: Lens.Lens' DeletePartitionIndex (Prelude.Maybe Prelude.Text)
deletePartitionIndex_catalogId :: (Maybe Text -> f (Maybe Text))
-> DeletePartitionIndex -> f DeletePartitionIndex
deletePartitionIndex_catalogId = (DeletePartitionIndex -> Maybe Text)
-> (DeletePartitionIndex -> Maybe Text -> DeletePartitionIndex)
-> Lens
     DeletePartitionIndex DeletePartitionIndex (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePartitionIndex' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:DeletePartitionIndex' :: DeletePartitionIndex -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: DeletePartitionIndex
s@DeletePartitionIndex' {} Maybe Text
a -> DeletePartitionIndex
s {$sel:catalogId:DeletePartitionIndex' :: Maybe Text
catalogId = Maybe Text
a} :: DeletePartitionIndex)

-- | Specifies the name of a database from which you want to delete a
-- partition index.
deletePartitionIndex_databaseName :: Lens.Lens' DeletePartitionIndex Prelude.Text
deletePartitionIndex_databaseName :: (Text -> f Text) -> DeletePartitionIndex -> f DeletePartitionIndex
deletePartitionIndex_databaseName = (DeletePartitionIndex -> Text)
-> (DeletePartitionIndex -> Text -> DeletePartitionIndex)
-> Lens DeletePartitionIndex DeletePartitionIndex Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePartitionIndex' {Text
databaseName :: Text
$sel:databaseName:DeletePartitionIndex' :: DeletePartitionIndex -> Text
databaseName} -> Text
databaseName) (\s :: DeletePartitionIndex
s@DeletePartitionIndex' {} Text
a -> DeletePartitionIndex
s {$sel:databaseName:DeletePartitionIndex' :: Text
databaseName = Text
a} :: DeletePartitionIndex)

-- | Specifies the name of a table from which you want to delete a partition
-- index.
deletePartitionIndex_tableName :: Lens.Lens' DeletePartitionIndex Prelude.Text
deletePartitionIndex_tableName :: (Text -> f Text) -> DeletePartitionIndex -> f DeletePartitionIndex
deletePartitionIndex_tableName = (DeletePartitionIndex -> Text)
-> (DeletePartitionIndex -> Text -> DeletePartitionIndex)
-> Lens DeletePartitionIndex DeletePartitionIndex Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePartitionIndex' {Text
tableName :: Text
$sel:tableName:DeletePartitionIndex' :: DeletePartitionIndex -> Text
tableName} -> Text
tableName) (\s :: DeletePartitionIndex
s@DeletePartitionIndex' {} Text
a -> DeletePartitionIndex
s {$sel:tableName:DeletePartitionIndex' :: Text
tableName = Text
a} :: DeletePartitionIndex)

-- | The name of the partition index to be deleted.
deletePartitionIndex_indexName :: Lens.Lens' DeletePartitionIndex Prelude.Text
deletePartitionIndex_indexName :: (Text -> f Text) -> DeletePartitionIndex -> f DeletePartitionIndex
deletePartitionIndex_indexName = (DeletePartitionIndex -> Text)
-> (DeletePartitionIndex -> Text -> DeletePartitionIndex)
-> Lens DeletePartitionIndex DeletePartitionIndex Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePartitionIndex' {Text
indexName :: Text
$sel:indexName:DeletePartitionIndex' :: DeletePartitionIndex -> Text
indexName} -> Text
indexName) (\s :: DeletePartitionIndex
s@DeletePartitionIndex' {} Text
a -> DeletePartitionIndex
s {$sel:indexName:DeletePartitionIndex' :: Text
indexName = Text
a} :: DeletePartitionIndex)

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

instance Prelude.NFData DeletePartitionIndex

instance Core.ToHeaders DeletePartitionIndex where
  toHeaders :: DeletePartitionIndex -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeletePartitionIndex -> 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
"AWSGlue.DeletePartitionIndex" ::
                          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 DeletePartitionIndex where
  toJSON :: DeletePartitionIndex -> Value
toJSON DeletePartitionIndex' {Maybe Text
Text
indexName :: Text
tableName :: Text
databaseName :: Text
catalogId :: Maybe Text
$sel:indexName:DeletePartitionIndex' :: DeletePartitionIndex -> Text
$sel:tableName:DeletePartitionIndex' :: DeletePartitionIndex -> Text
$sel:databaseName:DeletePartitionIndex' :: DeletePartitionIndex -> Text
$sel:catalogId:DeletePartitionIndex' :: DeletePartitionIndex -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CatalogId" 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
catalogId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DatabaseName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
databaseName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TableName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
tableName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"IndexName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
indexName)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeletePartitionIndexResponse