{-# 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.DeleteTableVersion
-- 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 version of a table.
module Amazonka.Glue.DeleteTableVersion
  ( -- * Creating a Request
    DeleteTableVersion (..),
    newDeleteTableVersion,

    -- * Request Lenses
    deleteTableVersion_catalogId,
    deleteTableVersion_databaseName,
    deleteTableVersion_tableName,
    deleteTableVersion_versionId,

    -- * Destructuring the Response
    DeleteTableVersionResponse (..),
    newDeleteTableVersionResponse,

    -- * Response Lenses
    deleteTableVersionResponse_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:/ 'newDeleteTableVersion' smart constructor.
data DeleteTableVersion = DeleteTableVersion'
  { -- | The ID of the Data Catalog where the tables reside. If none is provided,
    -- the Amazon Web Services account ID is used by default.
    DeleteTableVersion -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The database in the catalog in which the table resides. For Hive
    -- compatibility, this name is entirely lowercase.
    DeleteTableVersion -> Text
databaseName :: Prelude.Text,
    -- | The name of the table. For Hive compatibility, this name is entirely
    -- lowercase.
    DeleteTableVersion -> Text
tableName :: Prelude.Text,
    -- | The ID of the table version to be deleted. A @VersionID@ is a string
    -- representation of an integer. Each version is incremented by 1.
    DeleteTableVersion -> Text
versionId :: Prelude.Text
  }
  deriving (DeleteTableVersion -> DeleteTableVersion -> Bool
(DeleteTableVersion -> DeleteTableVersion -> Bool)
-> (DeleteTableVersion -> DeleteTableVersion -> Bool)
-> Eq DeleteTableVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteTableVersion -> DeleteTableVersion -> Bool
$c/= :: DeleteTableVersion -> DeleteTableVersion -> Bool
== :: DeleteTableVersion -> DeleteTableVersion -> Bool
$c== :: DeleteTableVersion -> DeleteTableVersion -> Bool
Prelude.Eq, ReadPrec [DeleteTableVersion]
ReadPrec DeleteTableVersion
Int -> ReadS DeleteTableVersion
ReadS [DeleteTableVersion]
(Int -> ReadS DeleteTableVersion)
-> ReadS [DeleteTableVersion]
-> ReadPrec DeleteTableVersion
-> ReadPrec [DeleteTableVersion]
-> Read DeleteTableVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteTableVersion]
$creadListPrec :: ReadPrec [DeleteTableVersion]
readPrec :: ReadPrec DeleteTableVersion
$creadPrec :: ReadPrec DeleteTableVersion
readList :: ReadS [DeleteTableVersion]
$creadList :: ReadS [DeleteTableVersion]
readsPrec :: Int -> ReadS DeleteTableVersion
$creadsPrec :: Int -> ReadS DeleteTableVersion
Prelude.Read, Int -> DeleteTableVersion -> ShowS
[DeleteTableVersion] -> ShowS
DeleteTableVersion -> String
(Int -> DeleteTableVersion -> ShowS)
-> (DeleteTableVersion -> String)
-> ([DeleteTableVersion] -> ShowS)
-> Show DeleteTableVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteTableVersion] -> ShowS
$cshowList :: [DeleteTableVersion] -> ShowS
show :: DeleteTableVersion -> String
$cshow :: DeleteTableVersion -> String
showsPrec :: Int -> DeleteTableVersion -> ShowS
$cshowsPrec :: Int -> DeleteTableVersion -> ShowS
Prelude.Show, (forall x. DeleteTableVersion -> Rep DeleteTableVersion x)
-> (forall x. Rep DeleteTableVersion x -> DeleteTableVersion)
-> Generic DeleteTableVersion
forall x. Rep DeleteTableVersion x -> DeleteTableVersion
forall x. DeleteTableVersion -> Rep DeleteTableVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteTableVersion x -> DeleteTableVersion
$cfrom :: forall x. DeleteTableVersion -> Rep DeleteTableVersion x
Prelude.Generic)

-- |
-- Create a value of 'DeleteTableVersion' 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', 'deleteTableVersion_catalogId' - The ID of the Data Catalog where the tables reside. If none is provided,
-- the Amazon Web Services account ID is used by default.
--
-- 'databaseName', 'deleteTableVersion_databaseName' - The database in the catalog in which the table resides. For Hive
-- compatibility, this name is entirely lowercase.
--
-- 'tableName', 'deleteTableVersion_tableName' - The name of the table. For Hive compatibility, this name is entirely
-- lowercase.
--
-- 'versionId', 'deleteTableVersion_versionId' - The ID of the table version to be deleted. A @VersionID@ is a string
-- representation of an integer. Each version is incremented by 1.
newDeleteTableVersion ::
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'tableName'
  Prelude.Text ->
  -- | 'versionId'
  Prelude.Text ->
  DeleteTableVersion
newDeleteTableVersion :: Text -> Text -> Text -> DeleteTableVersion
newDeleteTableVersion
  Text
pDatabaseName_
  Text
pTableName_
  Text
pVersionId_ =
    DeleteTableVersion' :: Maybe Text -> Text -> Text -> Text -> DeleteTableVersion
DeleteTableVersion'
      { $sel:catalogId:DeleteTableVersion' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:databaseName:DeleteTableVersion' :: Text
databaseName = Text
pDatabaseName_,
        $sel:tableName:DeleteTableVersion' :: Text
tableName = Text
pTableName_,
        $sel:versionId:DeleteTableVersion' :: Text
versionId = Text
pVersionId_
      }

-- | The ID of the Data Catalog where the tables reside. If none is provided,
-- the Amazon Web Services account ID is used by default.
deleteTableVersion_catalogId :: Lens.Lens' DeleteTableVersion (Prelude.Maybe Prelude.Text)
deleteTableVersion_catalogId :: (Maybe Text -> f (Maybe Text))
-> DeleteTableVersion -> f DeleteTableVersion
deleteTableVersion_catalogId = (DeleteTableVersion -> Maybe Text)
-> (DeleteTableVersion -> Maybe Text -> DeleteTableVersion)
-> Lens
     DeleteTableVersion DeleteTableVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTableVersion' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:DeleteTableVersion' :: DeleteTableVersion -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: DeleteTableVersion
s@DeleteTableVersion' {} Maybe Text
a -> DeleteTableVersion
s {$sel:catalogId:DeleteTableVersion' :: Maybe Text
catalogId = Maybe Text
a} :: DeleteTableVersion)

-- | The database in the catalog in which the table resides. For Hive
-- compatibility, this name is entirely lowercase.
deleteTableVersion_databaseName :: Lens.Lens' DeleteTableVersion Prelude.Text
deleteTableVersion_databaseName :: (Text -> f Text) -> DeleteTableVersion -> f DeleteTableVersion
deleteTableVersion_databaseName = (DeleteTableVersion -> Text)
-> (DeleteTableVersion -> Text -> DeleteTableVersion)
-> Lens DeleteTableVersion DeleteTableVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTableVersion' {Text
databaseName :: Text
$sel:databaseName:DeleteTableVersion' :: DeleteTableVersion -> Text
databaseName} -> Text
databaseName) (\s :: DeleteTableVersion
s@DeleteTableVersion' {} Text
a -> DeleteTableVersion
s {$sel:databaseName:DeleteTableVersion' :: Text
databaseName = Text
a} :: DeleteTableVersion)

-- | The name of the table. For Hive compatibility, this name is entirely
-- lowercase.
deleteTableVersion_tableName :: Lens.Lens' DeleteTableVersion Prelude.Text
deleteTableVersion_tableName :: (Text -> f Text) -> DeleteTableVersion -> f DeleteTableVersion
deleteTableVersion_tableName = (DeleteTableVersion -> Text)
-> (DeleteTableVersion -> Text -> DeleteTableVersion)
-> Lens DeleteTableVersion DeleteTableVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTableVersion' {Text
tableName :: Text
$sel:tableName:DeleteTableVersion' :: DeleteTableVersion -> Text
tableName} -> Text
tableName) (\s :: DeleteTableVersion
s@DeleteTableVersion' {} Text
a -> DeleteTableVersion
s {$sel:tableName:DeleteTableVersion' :: Text
tableName = Text
a} :: DeleteTableVersion)

-- | The ID of the table version to be deleted. A @VersionID@ is a string
-- representation of an integer. Each version is incremented by 1.
deleteTableVersion_versionId :: Lens.Lens' DeleteTableVersion Prelude.Text
deleteTableVersion_versionId :: (Text -> f Text) -> DeleteTableVersion -> f DeleteTableVersion
deleteTableVersion_versionId = (DeleteTableVersion -> Text)
-> (DeleteTableVersion -> Text -> DeleteTableVersion)
-> Lens DeleteTableVersion DeleteTableVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTableVersion' {Text
versionId :: Text
$sel:versionId:DeleteTableVersion' :: DeleteTableVersion -> Text
versionId} -> Text
versionId) (\s :: DeleteTableVersion
s@DeleteTableVersion' {} Text
a -> DeleteTableVersion
s {$sel:versionId:DeleteTableVersion' :: Text
versionId = Text
a} :: DeleteTableVersion)

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

instance Prelude.NFData DeleteTableVersion

instance Core.ToHeaders DeleteTableVersion where
  toHeaders :: DeleteTableVersion -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteTableVersion -> 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.DeleteTableVersion" :: 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 DeleteTableVersion where
  toJSON :: DeleteTableVersion -> Value
toJSON DeleteTableVersion' {Maybe Text
Text
versionId :: Text
tableName :: Text
databaseName :: Text
catalogId :: Maybe Text
$sel:versionId:DeleteTableVersion' :: DeleteTableVersion -> Text
$sel:tableName:DeleteTableVersion' :: DeleteTableVersion -> Text
$sel:databaseName:DeleteTableVersion' :: DeleteTableVersion -> Text
$sel:catalogId:DeleteTableVersion' :: DeleteTableVersion -> 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
"VersionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
versionId)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeleteTableVersionResponse