{-# 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.UpdateLFTag
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the list of possible values for the specified LF-tag key. If the
-- LF-tag does not exist, the operation throws an EntityNotFoundException.
-- The values in the delete key values will be deleted from list of
-- possible values. If any value in the delete key values is attached to a
-- resource, then API errors out with a 400 Exception - \"Update not
-- allowed\". Untag the attribute before deleting the LF-tag key\'s value.
module Amazonka.LakeFormation.UpdateLFTag
  ( -- * Creating a Request
    UpdateLFTag (..),
    newUpdateLFTag,

    -- * Request Lenses
    updateLFTag_catalogId,
    updateLFTag_tagValuesToAdd,
    updateLFTag_tagValuesToDelete,
    updateLFTag_tagKey,

    -- * Destructuring the Response
    UpdateLFTagResponse (..),
    newUpdateLFTagResponse,

    -- * Response Lenses
    updateLFTagResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LakeFormation.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateLFTag' smart constructor.
data UpdateLFTag = UpdateLFTag'
  { -- | 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 Lake Formation environment.
    UpdateLFTag -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | A list of LF-tag values to add from the LF-tag.
    UpdateLFTag -> Maybe (NonEmpty Text)
tagValuesToAdd :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | A list of LF-tag values to delete from the LF-tag.
    UpdateLFTag -> Maybe (NonEmpty Text)
tagValuesToDelete :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The key-name for the LF-tag for which to add or delete values.
    UpdateLFTag -> Text
tagKey :: Prelude.Text
  }
  deriving (UpdateLFTag -> UpdateLFTag -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateLFTag -> UpdateLFTag -> Bool
$c/= :: UpdateLFTag -> UpdateLFTag -> Bool
== :: UpdateLFTag -> UpdateLFTag -> Bool
$c== :: UpdateLFTag -> UpdateLFTag -> Bool
Prelude.Eq, ReadPrec [UpdateLFTag]
ReadPrec UpdateLFTag
Int -> ReadS UpdateLFTag
ReadS [UpdateLFTag]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateLFTag]
$creadListPrec :: ReadPrec [UpdateLFTag]
readPrec :: ReadPrec UpdateLFTag
$creadPrec :: ReadPrec UpdateLFTag
readList :: ReadS [UpdateLFTag]
$creadList :: ReadS [UpdateLFTag]
readsPrec :: Int -> ReadS UpdateLFTag
$creadsPrec :: Int -> ReadS UpdateLFTag
Prelude.Read, Int -> UpdateLFTag -> ShowS
[UpdateLFTag] -> ShowS
UpdateLFTag -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateLFTag] -> ShowS
$cshowList :: [UpdateLFTag] -> ShowS
show :: UpdateLFTag -> String
$cshow :: UpdateLFTag -> String
showsPrec :: Int -> UpdateLFTag -> ShowS
$cshowsPrec :: Int -> UpdateLFTag -> ShowS
Prelude.Show, forall x. Rep UpdateLFTag x -> UpdateLFTag
forall x. UpdateLFTag -> Rep UpdateLFTag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateLFTag x -> UpdateLFTag
$cfrom :: forall x. UpdateLFTag -> Rep UpdateLFTag x
Prelude.Generic)

-- |
-- Create a value of 'UpdateLFTag' 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', 'updateLFTag_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 Lake Formation environment.
--
-- 'tagValuesToAdd', 'updateLFTag_tagValuesToAdd' - A list of LF-tag values to add from the LF-tag.
--
-- 'tagValuesToDelete', 'updateLFTag_tagValuesToDelete' - A list of LF-tag values to delete from the LF-tag.
--
-- 'tagKey', 'updateLFTag_tagKey' - The key-name for the LF-tag for which to add or delete values.
newUpdateLFTag ::
  -- | 'tagKey'
  Prelude.Text ->
  UpdateLFTag
newUpdateLFTag :: Text -> UpdateLFTag
newUpdateLFTag Text
pTagKey_ =
  UpdateLFTag'
    { $sel:catalogId:UpdateLFTag' :: Maybe Text
catalogId = forall a. Maybe a
Prelude.Nothing,
      $sel:tagValuesToAdd:UpdateLFTag' :: Maybe (NonEmpty Text)
tagValuesToAdd = forall a. Maybe a
Prelude.Nothing,
      $sel:tagValuesToDelete:UpdateLFTag' :: Maybe (NonEmpty Text)
tagValuesToDelete = forall a. Maybe a
Prelude.Nothing,
      $sel:tagKey:UpdateLFTag' :: 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 Lake Formation environment.
updateLFTag_catalogId :: Lens.Lens' UpdateLFTag (Prelude.Maybe Prelude.Text)
updateLFTag_catalogId :: Lens' UpdateLFTag (Maybe Text)
updateLFTag_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLFTag' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:UpdateLFTag' :: UpdateLFTag -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: UpdateLFTag
s@UpdateLFTag' {} Maybe Text
a -> UpdateLFTag
s {$sel:catalogId:UpdateLFTag' :: Maybe Text
catalogId = Maybe Text
a} :: UpdateLFTag)

-- | A list of LF-tag values to add from the LF-tag.
updateLFTag_tagValuesToAdd :: Lens.Lens' UpdateLFTag (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
updateLFTag_tagValuesToAdd :: Lens' UpdateLFTag (Maybe (NonEmpty Text))
updateLFTag_tagValuesToAdd = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLFTag' {Maybe (NonEmpty Text)
tagValuesToAdd :: Maybe (NonEmpty Text)
$sel:tagValuesToAdd:UpdateLFTag' :: UpdateLFTag -> Maybe (NonEmpty Text)
tagValuesToAdd} -> Maybe (NonEmpty Text)
tagValuesToAdd) (\s :: UpdateLFTag
s@UpdateLFTag' {} Maybe (NonEmpty Text)
a -> UpdateLFTag
s {$sel:tagValuesToAdd:UpdateLFTag' :: Maybe (NonEmpty Text)
tagValuesToAdd = Maybe (NonEmpty Text)
a} :: UpdateLFTag) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of LF-tag values to delete from the LF-tag.
updateLFTag_tagValuesToDelete :: Lens.Lens' UpdateLFTag (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
updateLFTag_tagValuesToDelete :: Lens' UpdateLFTag (Maybe (NonEmpty Text))
updateLFTag_tagValuesToDelete = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLFTag' {Maybe (NonEmpty Text)
tagValuesToDelete :: Maybe (NonEmpty Text)
$sel:tagValuesToDelete:UpdateLFTag' :: UpdateLFTag -> Maybe (NonEmpty Text)
tagValuesToDelete} -> Maybe (NonEmpty Text)
tagValuesToDelete) (\s :: UpdateLFTag
s@UpdateLFTag' {} Maybe (NonEmpty Text)
a -> UpdateLFTag
s {$sel:tagValuesToDelete:UpdateLFTag' :: Maybe (NonEmpty Text)
tagValuesToDelete = Maybe (NonEmpty Text)
a} :: UpdateLFTag) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The key-name for the LF-tag for which to add or delete values.
updateLFTag_tagKey :: Lens.Lens' UpdateLFTag Prelude.Text
updateLFTag_tagKey :: Lens' UpdateLFTag Text
updateLFTag_tagKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLFTag' {Text
tagKey :: Text
$sel:tagKey:UpdateLFTag' :: UpdateLFTag -> Text
tagKey} -> Text
tagKey) (\s :: UpdateLFTag
s@UpdateLFTag' {} Text
a -> UpdateLFTag
s {$sel:tagKey:UpdateLFTag' :: Text
tagKey = Text
a} :: UpdateLFTag)

instance Core.AWSRequest UpdateLFTag where
  type AWSResponse UpdateLFTag = UpdateLFTagResponse
  request :: (Service -> Service) -> UpdateLFTag -> Request UpdateLFTag
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 UpdateLFTag
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateLFTag)))
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 -> UpdateLFTagResponse
UpdateLFTagResponse'
            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 UpdateLFTag where
  hashWithSalt :: Int -> UpdateLFTag -> Int
hashWithSalt Int
_salt UpdateLFTag' {Maybe (NonEmpty Text)
Maybe Text
Text
tagKey :: Text
tagValuesToDelete :: Maybe (NonEmpty Text)
tagValuesToAdd :: Maybe (NonEmpty Text)
catalogId :: Maybe Text
$sel:tagKey:UpdateLFTag' :: UpdateLFTag -> Text
$sel:tagValuesToDelete:UpdateLFTag' :: UpdateLFTag -> Maybe (NonEmpty Text)
$sel:tagValuesToAdd:UpdateLFTag' :: UpdateLFTag -> Maybe (NonEmpty Text)
$sel:catalogId:UpdateLFTag' :: UpdateLFTag -> 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` Maybe (NonEmpty Text)
tagValuesToAdd
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
tagValuesToDelete
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tagKey

instance Prelude.NFData UpdateLFTag where
  rnf :: UpdateLFTag -> ()
rnf UpdateLFTag' {Maybe (NonEmpty Text)
Maybe Text
Text
tagKey :: Text
tagValuesToDelete :: Maybe (NonEmpty Text)
tagValuesToAdd :: Maybe (NonEmpty Text)
catalogId :: Maybe Text
$sel:tagKey:UpdateLFTag' :: UpdateLFTag -> Text
$sel:tagValuesToDelete:UpdateLFTag' :: UpdateLFTag -> Maybe (NonEmpty Text)
$sel:tagValuesToAdd:UpdateLFTag' :: UpdateLFTag -> Maybe (NonEmpty Text)
$sel:catalogId:UpdateLFTag' :: UpdateLFTag -> 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 Maybe (NonEmpty Text)
tagValuesToAdd
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
tagValuesToDelete
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tagKey

instance Data.ToHeaders UpdateLFTag where
  toHeaders :: UpdateLFTag -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateLFTag where
  toJSON :: UpdateLFTag -> Value
toJSON UpdateLFTag' {Maybe (NonEmpty Text)
Maybe Text
Text
tagKey :: Text
tagValuesToDelete :: Maybe (NonEmpty Text)
tagValuesToAdd :: Maybe (NonEmpty Text)
catalogId :: Maybe Text
$sel:tagKey:UpdateLFTag' :: UpdateLFTag -> Text
$sel:tagValuesToDelete:UpdateLFTag' :: UpdateLFTag -> Maybe (NonEmpty Text)
$sel:tagValuesToAdd:UpdateLFTag' :: UpdateLFTag -> Maybe (NonEmpty Text)
$sel:catalogId:UpdateLFTag' :: UpdateLFTag -> 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,
            (Key
"TagValuesToAdd" 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 (NonEmpty Text)
tagValuesToAdd,
            (Key
"TagValuesToDelete" 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 (NonEmpty Text)
tagValuesToDelete,
            forall a. a -> Maybe a
Prelude.Just (Key
"TagKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tagKey)
          ]
      )

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

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

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

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

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

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