{-# 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.UpdateTableObjects
-- 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 manifest of Amazon S3 objects that make up the specified
-- governed table.
module Amazonka.LakeFormation.UpdateTableObjects
  ( -- * Creating a Request
    UpdateTableObjects (..),
    newUpdateTableObjects,

    -- * Request Lenses
    updateTableObjects_catalogId,
    updateTableObjects_transactionId,
    updateTableObjects_databaseName,
    updateTableObjects_tableName,
    updateTableObjects_writeOperations,

    -- * Destructuring the Response
    UpdateTableObjectsResponse (..),
    newUpdateTableObjectsResponse,

    -- * Response Lenses
    updateTableObjectsResponse_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:/ 'newUpdateTableObjects' smart constructor.
data UpdateTableObjects = UpdateTableObjects'
  { -- | The catalog containing the governed table to update. Defaults to the
    -- caller’s account ID.
    UpdateTableObjects -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The transaction at which to do the write.
    UpdateTableObjects -> Maybe Text
transactionId :: Prelude.Maybe Prelude.Text,
    -- | The database containing the governed table to update.
    UpdateTableObjects -> Text
databaseName :: Prelude.Text,
    -- | The governed table to update.
    UpdateTableObjects -> Text
tableName :: Prelude.Text,
    -- | A list of @WriteOperation@ objects that define an object to add to or
    -- delete from the manifest for a governed table.
    UpdateTableObjects -> NonEmpty WriteOperation
writeOperations :: Prelude.NonEmpty WriteOperation
  }
  deriving (UpdateTableObjects -> UpdateTableObjects -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateTableObjects -> UpdateTableObjects -> Bool
$c/= :: UpdateTableObjects -> UpdateTableObjects -> Bool
== :: UpdateTableObjects -> UpdateTableObjects -> Bool
$c== :: UpdateTableObjects -> UpdateTableObjects -> Bool
Prelude.Eq, ReadPrec [UpdateTableObjects]
ReadPrec UpdateTableObjects
Int -> ReadS UpdateTableObjects
ReadS [UpdateTableObjects]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateTableObjects]
$creadListPrec :: ReadPrec [UpdateTableObjects]
readPrec :: ReadPrec UpdateTableObjects
$creadPrec :: ReadPrec UpdateTableObjects
readList :: ReadS [UpdateTableObjects]
$creadList :: ReadS [UpdateTableObjects]
readsPrec :: Int -> ReadS UpdateTableObjects
$creadsPrec :: Int -> ReadS UpdateTableObjects
Prelude.Read, Int -> UpdateTableObjects -> ShowS
[UpdateTableObjects] -> ShowS
UpdateTableObjects -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateTableObjects] -> ShowS
$cshowList :: [UpdateTableObjects] -> ShowS
show :: UpdateTableObjects -> String
$cshow :: UpdateTableObjects -> String
showsPrec :: Int -> UpdateTableObjects -> ShowS
$cshowsPrec :: Int -> UpdateTableObjects -> ShowS
Prelude.Show, forall x. Rep UpdateTableObjects x -> UpdateTableObjects
forall x. UpdateTableObjects -> Rep UpdateTableObjects x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateTableObjects x -> UpdateTableObjects
$cfrom :: forall x. UpdateTableObjects -> Rep UpdateTableObjects x
Prelude.Generic)

-- |
-- Create a value of 'UpdateTableObjects' 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', 'updateTableObjects_catalogId' - The catalog containing the governed table to update. Defaults to the
-- caller’s account ID.
--
-- 'transactionId', 'updateTableObjects_transactionId' - The transaction at which to do the write.
--
-- 'databaseName', 'updateTableObjects_databaseName' - The database containing the governed table to update.
--
-- 'tableName', 'updateTableObjects_tableName' - The governed table to update.
--
-- 'writeOperations', 'updateTableObjects_writeOperations' - A list of @WriteOperation@ objects that define an object to add to or
-- delete from the manifest for a governed table.
newUpdateTableObjects ::
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'tableName'
  Prelude.Text ->
  -- | 'writeOperations'
  Prelude.NonEmpty WriteOperation ->
  UpdateTableObjects
newUpdateTableObjects :: Text -> Text -> NonEmpty WriteOperation -> UpdateTableObjects
newUpdateTableObjects
  Text
pDatabaseName_
  Text
pTableName_
  NonEmpty WriteOperation
pWriteOperations_ =
    UpdateTableObjects'
      { $sel:catalogId:UpdateTableObjects' :: Maybe Text
catalogId = forall a. Maybe a
Prelude.Nothing,
        $sel:transactionId:UpdateTableObjects' :: Maybe Text
transactionId = forall a. Maybe a
Prelude.Nothing,
        $sel:databaseName:UpdateTableObjects' :: Text
databaseName = Text
pDatabaseName_,
        $sel:tableName:UpdateTableObjects' :: Text
tableName = Text
pTableName_,
        $sel:writeOperations:UpdateTableObjects' :: NonEmpty WriteOperation
writeOperations =
          forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty WriteOperation
pWriteOperations_
      }

-- | The catalog containing the governed table to update. Defaults to the
-- caller’s account ID.
updateTableObjects_catalogId :: Lens.Lens' UpdateTableObjects (Prelude.Maybe Prelude.Text)
updateTableObjects_catalogId :: Lens' UpdateTableObjects (Maybe Text)
updateTableObjects_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTableObjects' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:UpdateTableObjects' :: UpdateTableObjects -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: UpdateTableObjects
s@UpdateTableObjects' {} Maybe Text
a -> UpdateTableObjects
s {$sel:catalogId:UpdateTableObjects' :: Maybe Text
catalogId = Maybe Text
a} :: UpdateTableObjects)

-- | The transaction at which to do the write.
updateTableObjects_transactionId :: Lens.Lens' UpdateTableObjects (Prelude.Maybe Prelude.Text)
updateTableObjects_transactionId :: Lens' UpdateTableObjects (Maybe Text)
updateTableObjects_transactionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTableObjects' {Maybe Text
transactionId :: Maybe Text
$sel:transactionId:UpdateTableObjects' :: UpdateTableObjects -> Maybe Text
transactionId} -> Maybe Text
transactionId) (\s :: UpdateTableObjects
s@UpdateTableObjects' {} Maybe Text
a -> UpdateTableObjects
s {$sel:transactionId:UpdateTableObjects' :: Maybe Text
transactionId = Maybe Text
a} :: UpdateTableObjects)

-- | The database containing the governed table to update.
updateTableObjects_databaseName :: Lens.Lens' UpdateTableObjects Prelude.Text
updateTableObjects_databaseName :: Lens' UpdateTableObjects Text
updateTableObjects_databaseName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTableObjects' {Text
databaseName :: Text
$sel:databaseName:UpdateTableObjects' :: UpdateTableObjects -> Text
databaseName} -> Text
databaseName) (\s :: UpdateTableObjects
s@UpdateTableObjects' {} Text
a -> UpdateTableObjects
s {$sel:databaseName:UpdateTableObjects' :: Text
databaseName = Text
a} :: UpdateTableObjects)

-- | The governed table to update.
updateTableObjects_tableName :: Lens.Lens' UpdateTableObjects Prelude.Text
updateTableObjects_tableName :: Lens' UpdateTableObjects Text
updateTableObjects_tableName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTableObjects' {Text
tableName :: Text
$sel:tableName:UpdateTableObjects' :: UpdateTableObjects -> Text
tableName} -> Text
tableName) (\s :: UpdateTableObjects
s@UpdateTableObjects' {} Text
a -> UpdateTableObjects
s {$sel:tableName:UpdateTableObjects' :: Text
tableName = Text
a} :: UpdateTableObjects)

-- | A list of @WriteOperation@ objects that define an object to add to or
-- delete from the manifest for a governed table.
updateTableObjects_writeOperations :: Lens.Lens' UpdateTableObjects (Prelude.NonEmpty WriteOperation)
updateTableObjects_writeOperations :: Lens' UpdateTableObjects (NonEmpty WriteOperation)
updateTableObjects_writeOperations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTableObjects' {NonEmpty WriteOperation
writeOperations :: NonEmpty WriteOperation
$sel:writeOperations:UpdateTableObjects' :: UpdateTableObjects -> NonEmpty WriteOperation
writeOperations} -> NonEmpty WriteOperation
writeOperations) (\s :: UpdateTableObjects
s@UpdateTableObjects' {} NonEmpty WriteOperation
a -> UpdateTableObjects
s {$sel:writeOperations:UpdateTableObjects' :: NonEmpty WriteOperation
writeOperations = NonEmpty WriteOperation
a} :: UpdateTableObjects) 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 UpdateTableObjects where
  type
    AWSResponse UpdateTableObjects =
      UpdateTableObjectsResponse
  request :: (Service -> Service)
-> UpdateTableObjects -> Request UpdateTableObjects
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 UpdateTableObjects
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateTableObjects)))
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 -> UpdateTableObjectsResponse
UpdateTableObjectsResponse'
            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 UpdateTableObjects where
  hashWithSalt :: Int -> UpdateTableObjects -> Int
hashWithSalt Int
_salt UpdateTableObjects' {Maybe Text
NonEmpty WriteOperation
Text
writeOperations :: NonEmpty WriteOperation
tableName :: Text
databaseName :: Text
transactionId :: Maybe Text
catalogId :: Maybe Text
$sel:writeOperations:UpdateTableObjects' :: UpdateTableObjects -> NonEmpty WriteOperation
$sel:tableName:UpdateTableObjects' :: UpdateTableObjects -> Text
$sel:databaseName:UpdateTableObjects' :: UpdateTableObjects -> Text
$sel:transactionId:UpdateTableObjects' :: UpdateTableObjects -> Maybe Text
$sel:catalogId:UpdateTableObjects' :: UpdateTableObjects -> 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 Text
transactionId
      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` NonEmpty WriteOperation
writeOperations

instance Prelude.NFData UpdateTableObjects where
  rnf :: UpdateTableObjects -> ()
rnf UpdateTableObjects' {Maybe Text
NonEmpty WriteOperation
Text
writeOperations :: NonEmpty WriteOperation
tableName :: Text
databaseName :: Text
transactionId :: Maybe Text
catalogId :: Maybe Text
$sel:writeOperations:UpdateTableObjects' :: UpdateTableObjects -> NonEmpty WriteOperation
$sel:tableName:UpdateTableObjects' :: UpdateTableObjects -> Text
$sel:databaseName:UpdateTableObjects' :: UpdateTableObjects -> Text
$sel:transactionId:UpdateTableObjects' :: UpdateTableObjects -> Maybe Text
$sel:catalogId:UpdateTableObjects' :: UpdateTableObjects -> 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 Text
transactionId
      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 NonEmpty WriteOperation
writeOperations

instance Data.ToHeaders UpdateTableObjects where
  toHeaders :: UpdateTableObjects -> 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 UpdateTableObjects where
  toJSON :: UpdateTableObjects -> Value
toJSON UpdateTableObjects' {Maybe Text
NonEmpty WriteOperation
Text
writeOperations :: NonEmpty WriteOperation
tableName :: Text
databaseName :: Text
transactionId :: Maybe Text
catalogId :: Maybe Text
$sel:writeOperations:UpdateTableObjects' :: UpdateTableObjects -> NonEmpty WriteOperation
$sel:tableName:UpdateTableObjects' :: UpdateTableObjects -> Text
$sel:databaseName:UpdateTableObjects' :: UpdateTableObjects -> Text
$sel:transactionId:UpdateTableObjects' :: UpdateTableObjects -> Maybe Text
$sel:catalogId:UpdateTableObjects' :: UpdateTableObjects -> 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
"TransactionId" 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
transactionId,
            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
"WriteOperations" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty WriteOperation
writeOperations)
          ]
      )

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

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

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

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

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

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