{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 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:/ '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
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]
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
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. 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'
      { $sel:catalogId:DeletePartitionIndex' :: Maybe Text
catalogId = 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 :: Lens' DeletePartitionIndex (Maybe Text)
deletePartitionIndex_catalogId = 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 :: Lens' DeletePartitionIndex Text
deletePartitionIndex_databaseName = 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 :: Lens' DeletePartitionIndex Text
deletePartitionIndex_tableName = 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 :: Lens' DeletePartitionIndex Text
deletePartitionIndex_indexName = 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 :: (Service -> Service)
-> DeletePartitionIndex -> Request DeletePartitionIndex
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 DeletePartitionIndex
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeletePartitionIndex)))
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 -> DeletePartitionIndexResponse
DeletePartitionIndexResponse'
            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 DeletePartitionIndex where
  hashWithSalt :: Int -> DeletePartitionIndex -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
catalogId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
databaseName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tableName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
indexName

instance Prelude.NFData DeletePartitionIndex where
  rnf :: DeletePartitionIndex -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
catalogId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
databaseName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tableName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
indexName

instance Data.ToHeaders DeletePartitionIndex where
  toHeaders :: DeletePartitionIndex -> 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.DeletePartitionIndex" ::
                          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 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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CatalogId" 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
catalogId,
            forall a. a -> Maybe a
Prelude.Just (Key
"DatabaseName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
databaseName),
            forall a. a -> Maybe a
Prelude.Just (Key
"TableName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tableName),
            forall a. a -> Maybe a
Prelude.Just (Key
"IndexName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
indexName)
          ]
      )

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

instance Data.ToQuery DeletePartitionIndex where
  toQuery :: DeletePartitionIndex -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:httpStatus:DeletePartitionIndexResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deletePartitionIndexResponse_httpStatus :: Lens.Lens' DeletePartitionIndexResponse Prelude.Int
deletePartitionIndexResponse_httpStatus :: Lens' DeletePartitionIndexResponse Int
deletePartitionIndexResponse_httpStatus = 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 where
  rnf :: DeletePartitionIndexResponse -> ()
rnf DeletePartitionIndexResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeletePartitionIndexResponse' :: DeletePartitionIndexResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus