{-# 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.LakeFormation.DeleteLFTag
-- 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 the specified tag key name. If the attribute key does not exist
-- or the tag does not exist, then the operation will not do anything. If
-- the attribute key exists, then the operation checks if any resources are
-- tagged with this attribute key, if yes, the API throws a 400 Exception
-- with the message \"Delete not allowed\" as the tag key is still attached
-- with resources. You can consider untagging resources with this tag key.
module Amazonka.LakeFormation.DeleteLFTag
  ( -- * Creating a Request
    DeleteLFTag (..),
    newDeleteLFTag,

    -- * Request Lenses
    deleteLFTag_catalogId,
    deleteLFTag_tagKey,

    -- * Destructuring the Response
    DeleteLFTagResponse (..),
    newDeleteLFTagResponse,

    -- * Response Lenses
    deleteLFTagResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.LakeFormation.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:/ 'newDeleteLFTag' smart constructor.
data DeleteLFTag = DeleteLFTag'
  { -- | The identifier for the Data Catalog. By default, the account ID. The
    -- Data Catalog is the persistent metadata store. It contains database
    -- definitions, table definitions, and other control information to manage
    -- your AWS Lake Formation environment.
    DeleteLFTag -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The key-name for the tag to delete.
    DeleteLFTag -> Text
tagKey :: Prelude.Text
  }
  deriving (DeleteLFTag -> DeleteLFTag -> Bool
(DeleteLFTag -> DeleteLFTag -> Bool)
-> (DeleteLFTag -> DeleteLFTag -> Bool) -> Eq DeleteLFTag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteLFTag -> DeleteLFTag -> Bool
$c/= :: DeleteLFTag -> DeleteLFTag -> Bool
== :: DeleteLFTag -> DeleteLFTag -> Bool
$c== :: DeleteLFTag -> DeleteLFTag -> Bool
Prelude.Eq, ReadPrec [DeleteLFTag]
ReadPrec DeleteLFTag
Int -> ReadS DeleteLFTag
ReadS [DeleteLFTag]
(Int -> ReadS DeleteLFTag)
-> ReadS [DeleteLFTag]
-> ReadPrec DeleteLFTag
-> ReadPrec [DeleteLFTag]
-> Read DeleteLFTag
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteLFTag]
$creadListPrec :: ReadPrec [DeleteLFTag]
readPrec :: ReadPrec DeleteLFTag
$creadPrec :: ReadPrec DeleteLFTag
readList :: ReadS [DeleteLFTag]
$creadList :: ReadS [DeleteLFTag]
readsPrec :: Int -> ReadS DeleteLFTag
$creadsPrec :: Int -> ReadS DeleteLFTag
Prelude.Read, Int -> DeleteLFTag -> ShowS
[DeleteLFTag] -> ShowS
DeleteLFTag -> String
(Int -> DeleteLFTag -> ShowS)
-> (DeleteLFTag -> String)
-> ([DeleteLFTag] -> ShowS)
-> Show DeleteLFTag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteLFTag] -> ShowS
$cshowList :: [DeleteLFTag] -> ShowS
show :: DeleteLFTag -> String
$cshow :: DeleteLFTag -> String
showsPrec :: Int -> DeleteLFTag -> ShowS
$cshowsPrec :: Int -> DeleteLFTag -> ShowS
Prelude.Show, (forall x. DeleteLFTag -> Rep DeleteLFTag x)
-> (forall x. Rep DeleteLFTag x -> DeleteLFTag)
-> Generic DeleteLFTag
forall x. Rep DeleteLFTag x -> DeleteLFTag
forall x. DeleteLFTag -> Rep DeleteLFTag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteLFTag x -> DeleteLFTag
$cfrom :: forall x. DeleteLFTag -> Rep DeleteLFTag x
Prelude.Generic)

-- |
-- Create a value of 'DeleteLFTag' 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', 'deleteLFTag_catalogId' - The identifier for the Data Catalog. By default, the account ID. The
-- Data Catalog is the persistent metadata store. It contains database
-- definitions, table definitions, and other control information to manage
-- your AWS Lake Formation environment.
--
-- 'tagKey', 'deleteLFTag_tagKey' - The key-name for the tag to delete.
newDeleteLFTag ::
  -- | 'tagKey'
  Prelude.Text ->
  DeleteLFTag
newDeleteLFTag :: Text -> DeleteLFTag
newDeleteLFTag Text
pTagKey_ =
  DeleteLFTag' :: Maybe Text -> Text -> DeleteLFTag
DeleteLFTag'
    { $sel:catalogId:DeleteLFTag' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tagKey:DeleteLFTag' :: Text
tagKey = Text
pTagKey_
    }

-- | The identifier for the Data Catalog. By default, the account ID. The
-- Data Catalog is the persistent metadata store. It contains database
-- definitions, table definitions, and other control information to manage
-- your AWS Lake Formation environment.
deleteLFTag_catalogId :: Lens.Lens' DeleteLFTag (Prelude.Maybe Prelude.Text)
deleteLFTag_catalogId :: (Maybe Text -> f (Maybe Text)) -> DeleteLFTag -> f DeleteLFTag
deleteLFTag_catalogId = (DeleteLFTag -> Maybe Text)
-> (DeleteLFTag -> Maybe Text -> DeleteLFTag)
-> Lens DeleteLFTag DeleteLFTag (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteLFTag' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:DeleteLFTag' :: DeleteLFTag -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: DeleteLFTag
s@DeleteLFTag' {} Maybe Text
a -> DeleteLFTag
s {$sel:catalogId:DeleteLFTag' :: Maybe Text
catalogId = Maybe Text
a} :: DeleteLFTag)

-- | The key-name for the tag to delete.
deleteLFTag_tagKey :: Lens.Lens' DeleteLFTag Prelude.Text
deleteLFTag_tagKey :: (Text -> f Text) -> DeleteLFTag -> f DeleteLFTag
deleteLFTag_tagKey = (DeleteLFTag -> Text)
-> (DeleteLFTag -> Text -> DeleteLFTag)
-> Lens DeleteLFTag DeleteLFTag Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteLFTag' {Text
tagKey :: Text
$sel:tagKey:DeleteLFTag' :: DeleteLFTag -> Text
tagKey} -> Text
tagKey) (\s :: DeleteLFTag
s@DeleteLFTag' {} Text
a -> DeleteLFTag
s {$sel:tagKey:DeleteLFTag' :: Text
tagKey = Text
a} :: DeleteLFTag)

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

instance Prelude.NFData DeleteLFTag

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

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

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

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

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

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

instance Prelude.NFData DeleteLFTagResponse