{-# 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-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.
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 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:/ '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
(DeletePartition -> DeletePartition -> Bool)
-> (DeletePartition -> DeletePartition -> Bool)
-> Eq DeletePartition
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]
(Int -> ReadS DeletePartition)
-> ReadS [DeletePartition]
-> ReadPrec DeletePartition
-> ReadPrec [DeletePartition]
-> Read 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
(Int -> DeletePartition -> ShowS)
-> (DeletePartition -> String)
-> ([DeletePartition] -> ShowS)
-> Show DeletePartition
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. DeletePartition -> Rep DeletePartition x)
-> (forall x. Rep DeletePartition x -> DeletePartition)
-> Generic DeletePartition
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' :: Maybe Text -> Text -> Text -> [Text] -> DeletePartition
DeletePartition'
    { $sel:catalogId:DeletePartition' :: Maybe Text
catalogId = Maybe Text
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 = [Text]
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 :: (Maybe Text -> f (Maybe Text))
-> DeletePartition -> f DeletePartition
deletePartition_catalogId = (DeletePartition -> Maybe Text)
-> (DeletePartition -> Maybe Text -> DeletePartition)
-> Lens DeletePartition DeletePartition (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> DeletePartition -> f DeletePartition
deletePartition_databaseName = (DeletePartition -> Text)
-> (DeletePartition -> Text -> DeletePartition)
-> Lens DeletePartition DeletePartition Text Text
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 :: (Text -> f Text) -> DeletePartition -> f DeletePartition
deletePartition_tableName = (DeletePartition -> Text)
-> (DeletePartition -> Text -> DeletePartition)
-> Lens DeletePartition DeletePartition Text Text
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 :: ([Text] -> f [Text]) -> DeletePartition -> f DeletePartition
deletePartition_partitionValues = (DeletePartition -> [Text])
-> (DeletePartition -> [Text] -> DeletePartition)
-> Lens DeletePartition DeletePartition [Text] [Text]
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) (([Text] -> f [Text]) -> DeletePartition -> f DeletePartition)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DeletePartition
-> f DeletePartition
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
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 :: DeletePartition -> Request DeletePartition
request = Service -> DeletePartition -> Request DeletePartition
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeletePartition
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeletePartition)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeletePartition))
-> Logger
-> Service
-> Proxy DeletePartition
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeletePartition)))
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 -> DeletePartitionResponse
DeletePartitionResponse'
            (Int -> DeletePartitionResponse)
-> Either String Int -> Either String DeletePartitionResponse
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 DeletePartition

instance Prelude.NFData DeletePartition

instance Core.ToHeaders DeletePartition where
  toHeaders :: DeletePartition -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeletePartition -> 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.DeletePartition" :: 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 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
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
"PartitionValues" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
partitionValues)
          ]
      )

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

instance Core.ToQuery DeletePartition where
  toQuery :: DeletePartition -> QueryString
toQuery = QueryString -> DeletePartition -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeletePartitionResponse -> DeletePartitionResponse -> Bool)
-> (DeletePartitionResponse -> DeletePartitionResponse -> Bool)
-> Eq DeletePartitionResponse
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]
(Int -> ReadS DeletePartitionResponse)
-> ReadS [DeletePartitionResponse]
-> ReadPrec DeletePartitionResponse
-> ReadPrec [DeletePartitionResponse]
-> Read 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
(Int -> DeletePartitionResponse -> ShowS)
-> (DeletePartitionResponse -> String)
-> ([DeletePartitionResponse] -> ShowS)
-> Show DeletePartitionResponse
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.
 DeletePartitionResponse -> Rep DeletePartitionResponse x)
-> (forall x.
    Rep DeletePartitionResponse x -> DeletePartitionResponse)
-> Generic DeletePartitionResponse
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' :: Int -> DeletePartitionResponse
DeletePartitionResponse' {$sel:httpStatus:DeletePartitionResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
deletePartitionResponse_httpStatus :: Lens.Lens' DeletePartitionResponse Prelude.Int
deletePartitionResponse_httpStatus :: (Int -> f Int)
-> DeletePartitionResponse -> f DeletePartitionResponse
deletePartitionResponse_httpStatus = (DeletePartitionResponse -> Int)
-> (DeletePartitionResponse -> Int -> DeletePartitionResponse)
-> Lens DeletePartitionResponse DeletePartitionResponse Int Int
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