{-# 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.DeletePartition
-- 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.
module Amazonka.Glue.DeletePartition
  ( -- * Creating a Request
    DeletePartition (..),
    newDeletePartition,

    -- * Request Lenses
    deletePartition_catalogId,
    deletePartition_databaseName,
    deletePartition_tableName,
    deletePartition_partitionValues,

    -- * Destructuring the Response
    DeletePartitionResponse (..),
    newDeletePartitionResponse,

    -- * Response Lenses
    deletePartitionResponse_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:/ 'newDeletePartition' smart constructor.
data DeletePartition = DeletePartition'
  { -- | The ID of the Data Catalog where the partition to be deleted resides. If
    -- none is provided, the Amazon Web Services account ID is used by default.
    DeletePartition -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The name of the catalog database in which the table in question resides.
    DeletePartition -> Text
databaseName :: Prelude.Text,
    -- | The name of the table that contains the partition to be deleted.
    DeletePartition -> Text
tableName :: Prelude.Text,
    -- | The values that define the partition.
    DeletePartition -> [Text]
partitionValues :: [Prelude.Text]
  }
  deriving (DeletePartition -> DeletePartition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletePartition -> DeletePartition -> Bool
$c/= :: DeletePartition -> DeletePartition -> Bool
== :: DeletePartition -> DeletePartition -> Bool
$c== :: DeletePartition -> DeletePartition -> Bool
Prelude.Eq, ReadPrec [DeletePartition]
ReadPrec DeletePartition
Int -> ReadS DeletePartition
ReadS [DeletePartition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeletePartition]
$creadListPrec :: ReadPrec [DeletePartition]
readPrec :: ReadPrec DeletePartition
$creadPrec :: ReadPrec DeletePartition
readList :: ReadS [DeletePartition]
$creadList :: ReadS [DeletePartition]
readsPrec :: Int -> ReadS DeletePartition
$creadsPrec :: Int -> ReadS DeletePartition
Prelude.Read, Int -> DeletePartition -> ShowS
[DeletePartition] -> ShowS
DeletePartition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletePartition] -> ShowS
$cshowList :: [DeletePartition] -> ShowS
show :: DeletePartition -> String
$cshow :: DeletePartition -> String
showsPrec :: Int -> DeletePartition -> ShowS
$cshowsPrec :: Int -> DeletePartition -> ShowS
Prelude.Show, forall x. Rep DeletePartition x -> DeletePartition
forall x. DeletePartition -> Rep DeletePartition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeletePartition x -> DeletePartition
$cfrom :: forall x. DeletePartition -> Rep DeletePartition x
Prelude.Generic)

-- |
-- Create a value of 'DeletePartition' 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', 'deletePartition_catalogId' - The ID of the Data Catalog where the partition to be deleted resides. If
-- none is provided, the Amazon Web Services account ID is used by default.
--
-- 'databaseName', 'deletePartition_databaseName' - The name of the catalog database in which the table in question resides.
--
-- 'tableName', 'deletePartition_tableName' - The name of the table that contains the partition to be deleted.
--
-- 'partitionValues', 'deletePartition_partitionValues' - The values that define the partition.
newDeletePartition ::
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'tableName'
  Prelude.Text ->
  DeletePartition
newDeletePartition :: Text -> Text -> DeletePartition
newDeletePartition Text
pDatabaseName_ Text
pTableName_ =
  DeletePartition'
    { $sel:catalogId:DeletePartition' :: Maybe Text
catalogId = forall a. Maybe a
Prelude.Nothing,
      $sel:databaseName:DeletePartition' :: Text
databaseName = Text
pDatabaseName_,
      $sel:tableName:DeletePartition' :: Text
tableName = Text
pTableName_,
      $sel:partitionValues:DeletePartition' :: [Text]
partitionValues = forall a. Monoid a => a
Prelude.mempty
    }

-- | The ID of the Data Catalog where the partition to be deleted resides. If
-- none is provided, the Amazon Web Services account ID is used by default.
deletePartition_catalogId :: Lens.Lens' DeletePartition (Prelude.Maybe Prelude.Text)
deletePartition_catalogId :: Lens' DeletePartition (Maybe Text)
deletePartition_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePartition' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:DeletePartition' :: DeletePartition -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: DeletePartition
s@DeletePartition' {} Maybe Text
a -> DeletePartition
s {$sel:catalogId:DeletePartition' :: Maybe Text
catalogId = Maybe Text
a} :: DeletePartition)

-- | The name of the catalog database in which the table in question resides.
deletePartition_databaseName :: Lens.Lens' DeletePartition Prelude.Text
deletePartition_databaseName :: Lens' DeletePartition Text
deletePartition_databaseName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePartition' {Text
databaseName :: Text
$sel:databaseName:DeletePartition' :: DeletePartition -> Text
databaseName} -> Text
databaseName) (\s :: DeletePartition
s@DeletePartition' {} Text
a -> DeletePartition
s {$sel:databaseName:DeletePartition' :: Text
databaseName = Text
a} :: DeletePartition)

-- | The name of the table that contains the partition to be deleted.
deletePartition_tableName :: Lens.Lens' DeletePartition Prelude.Text
deletePartition_tableName :: Lens' DeletePartition Text
deletePartition_tableName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePartition' {Text
tableName :: Text
$sel:tableName:DeletePartition' :: DeletePartition -> Text
tableName} -> Text
tableName) (\s :: DeletePartition
s@DeletePartition' {} Text
a -> DeletePartition
s {$sel:tableName:DeletePartition' :: Text
tableName = Text
a} :: DeletePartition)

-- | The values that define the partition.
deletePartition_partitionValues :: Lens.Lens' DeletePartition [Prelude.Text]
deletePartition_partitionValues :: Lens' DeletePartition [Text]
deletePartition_partitionValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePartition' {[Text]
partitionValues :: [Text]
$sel:partitionValues:DeletePartition' :: DeletePartition -> [Text]
partitionValues} -> [Text]
partitionValues) (\s :: DeletePartition
s@DeletePartition' {} [Text]
a -> DeletePartition
s {$sel:partitionValues:DeletePartition' :: [Text]
partitionValues = [Text]
a} :: DeletePartition) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest DeletePartition where
  type
    AWSResponse DeletePartition =
      DeletePartitionResponse
  request :: (Service -> Service) -> DeletePartition -> Request DeletePartition
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 DeletePartition
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeletePartition)))
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 -> DeletePartitionResponse
DeletePartitionResponse'
            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 DeletePartition where
  hashWithSalt :: Int -> DeletePartition -> Int
hashWithSalt Int
_salt DeletePartition' {[Text]
Maybe Text
Text
partitionValues :: [Text]
tableName :: Text
databaseName :: Text
catalogId :: Maybe Text
$sel:partitionValues:DeletePartition' :: DeletePartition -> [Text]
$sel:tableName:DeletePartition' :: DeletePartition -> Text
$sel:databaseName:DeletePartition' :: DeletePartition -> Text
$sel:catalogId:DeletePartition' :: DeletePartition -> 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]
partitionValues

instance Prelude.NFData DeletePartition where
  rnf :: DeletePartition -> ()
rnf DeletePartition' {[Text]
Maybe Text
Text
partitionValues :: [Text]
tableName :: Text
databaseName :: Text
catalogId :: Maybe Text
$sel:partitionValues:DeletePartition' :: DeletePartition -> [Text]
$sel:tableName:DeletePartition' :: DeletePartition -> Text
$sel:databaseName:DeletePartition' :: DeletePartition -> Text
$sel:catalogId:DeletePartition' :: DeletePartition -> 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]
partitionValues

instance Data.ToHeaders DeletePartition where
  toHeaders :: DeletePartition -> 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.DeletePartition" :: 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 DeletePartition where
  toJSON :: DeletePartition -> Value
toJSON DeletePartition' {[Text]
Maybe Text
Text
partitionValues :: [Text]
tableName :: Text
databaseName :: Text
catalogId :: Maybe Text
$sel:partitionValues:DeletePartition' :: DeletePartition -> [Text]
$sel:tableName:DeletePartition' :: DeletePartition -> Text
$sel:databaseName:DeletePartition' :: DeletePartition -> Text
$sel:catalogId:DeletePartition' :: DeletePartition -> 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
"PartitionValues" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
partitionValues)
          ]
      )

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

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

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

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

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

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