{-# 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.BatchRevokePermissions
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Batch operation to revoke permissions from the principal.
module Amazonka.LakeFormation.BatchRevokePermissions
  ( -- * Creating a Request
    BatchRevokePermissions (..),
    newBatchRevokePermissions,

    -- * Request Lenses
    batchRevokePermissions_catalogId,
    batchRevokePermissions_entries,

    -- * Destructuring the Response
    BatchRevokePermissionsResponse (..),
    newBatchRevokePermissionsResponse,

    -- * Response Lenses
    batchRevokePermissionsResponse_failures,
    batchRevokePermissionsResponse_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:/ 'newBatchRevokePermissions' smart constructor.
data BatchRevokePermissions = BatchRevokePermissions'
  { -- | 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.
    BatchRevokePermissions -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | A list of up to 20 entries for resource permissions to be revoked by
    -- batch operation to the principal.
    BatchRevokePermissions -> [BatchPermissionsRequestEntry]
entries :: [BatchPermissionsRequestEntry]
  }
  deriving (BatchRevokePermissions -> BatchRevokePermissions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchRevokePermissions -> BatchRevokePermissions -> Bool
$c/= :: BatchRevokePermissions -> BatchRevokePermissions -> Bool
== :: BatchRevokePermissions -> BatchRevokePermissions -> Bool
$c== :: BatchRevokePermissions -> BatchRevokePermissions -> Bool
Prelude.Eq, ReadPrec [BatchRevokePermissions]
ReadPrec BatchRevokePermissions
Int -> ReadS BatchRevokePermissions
ReadS [BatchRevokePermissions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchRevokePermissions]
$creadListPrec :: ReadPrec [BatchRevokePermissions]
readPrec :: ReadPrec BatchRevokePermissions
$creadPrec :: ReadPrec BatchRevokePermissions
readList :: ReadS [BatchRevokePermissions]
$creadList :: ReadS [BatchRevokePermissions]
readsPrec :: Int -> ReadS BatchRevokePermissions
$creadsPrec :: Int -> ReadS BatchRevokePermissions
Prelude.Read, Int -> BatchRevokePermissions -> ShowS
[BatchRevokePermissions] -> ShowS
BatchRevokePermissions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchRevokePermissions] -> ShowS
$cshowList :: [BatchRevokePermissions] -> ShowS
show :: BatchRevokePermissions -> String
$cshow :: BatchRevokePermissions -> String
showsPrec :: Int -> BatchRevokePermissions -> ShowS
$cshowsPrec :: Int -> BatchRevokePermissions -> ShowS
Prelude.Show, forall x. Rep BatchRevokePermissions x -> BatchRevokePermissions
forall x. BatchRevokePermissions -> Rep BatchRevokePermissions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchRevokePermissions x -> BatchRevokePermissions
$cfrom :: forall x. BatchRevokePermissions -> Rep BatchRevokePermissions x
Prelude.Generic)

-- |
-- Create a value of 'BatchRevokePermissions' 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', 'batchRevokePermissions_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.
--
-- 'entries', 'batchRevokePermissions_entries' - A list of up to 20 entries for resource permissions to be revoked by
-- batch operation to the principal.
newBatchRevokePermissions ::
  BatchRevokePermissions
newBatchRevokePermissions :: BatchRevokePermissions
newBatchRevokePermissions =
  BatchRevokePermissions'
    { $sel:catalogId:BatchRevokePermissions' :: Maybe Text
catalogId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:entries:BatchRevokePermissions' :: [BatchPermissionsRequestEntry]
entries = forall a. Monoid a => a
Prelude.mempty
    }

-- | 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.
batchRevokePermissions_catalogId :: Lens.Lens' BatchRevokePermissions (Prelude.Maybe Prelude.Text)
batchRevokePermissions_catalogId :: Lens' BatchRevokePermissions (Maybe Text)
batchRevokePermissions_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchRevokePermissions' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:BatchRevokePermissions' :: BatchRevokePermissions -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: BatchRevokePermissions
s@BatchRevokePermissions' {} Maybe Text
a -> BatchRevokePermissions
s {$sel:catalogId:BatchRevokePermissions' :: Maybe Text
catalogId = Maybe Text
a} :: BatchRevokePermissions)

-- | A list of up to 20 entries for resource permissions to be revoked by
-- batch operation to the principal.
batchRevokePermissions_entries :: Lens.Lens' BatchRevokePermissions [BatchPermissionsRequestEntry]
batchRevokePermissions_entries :: Lens' BatchRevokePermissions [BatchPermissionsRequestEntry]
batchRevokePermissions_entries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchRevokePermissions' {[BatchPermissionsRequestEntry]
entries :: [BatchPermissionsRequestEntry]
$sel:entries:BatchRevokePermissions' :: BatchRevokePermissions -> [BatchPermissionsRequestEntry]
entries} -> [BatchPermissionsRequestEntry]
entries) (\s :: BatchRevokePermissions
s@BatchRevokePermissions' {} [BatchPermissionsRequestEntry]
a -> BatchRevokePermissions
s {$sel:entries:BatchRevokePermissions' :: [BatchPermissionsRequestEntry]
entries = [BatchPermissionsRequestEntry]
a} :: BatchRevokePermissions) 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 BatchRevokePermissions where
  type
    AWSResponse BatchRevokePermissions =
      BatchRevokePermissionsResponse
  request :: (Service -> Service)
-> BatchRevokePermissions -> Request BatchRevokePermissions
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 BatchRevokePermissions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchRevokePermissions)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [BatchPermissionsFailureEntry]
-> Int -> BatchRevokePermissionsResponse
BatchRevokePermissionsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Failures" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => 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 BatchRevokePermissions where
  hashWithSalt :: Int -> BatchRevokePermissions -> Int
hashWithSalt Int
_salt BatchRevokePermissions' {[BatchPermissionsRequestEntry]
Maybe Text
entries :: [BatchPermissionsRequestEntry]
catalogId :: Maybe Text
$sel:entries:BatchRevokePermissions' :: BatchRevokePermissions -> [BatchPermissionsRequestEntry]
$sel:catalogId:BatchRevokePermissions' :: BatchRevokePermissions -> 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` [BatchPermissionsRequestEntry]
entries

instance Prelude.NFData BatchRevokePermissions where
  rnf :: BatchRevokePermissions -> ()
rnf BatchRevokePermissions' {[BatchPermissionsRequestEntry]
Maybe Text
entries :: [BatchPermissionsRequestEntry]
catalogId :: Maybe Text
$sel:entries:BatchRevokePermissions' :: BatchRevokePermissions -> [BatchPermissionsRequestEntry]
$sel:catalogId:BatchRevokePermissions' :: BatchRevokePermissions -> 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 [BatchPermissionsRequestEntry]
entries

instance Data.ToHeaders BatchRevokePermissions where
  toHeaders :: BatchRevokePermissions -> 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 BatchRevokePermissions where
  toJSON :: BatchRevokePermissions -> Value
toJSON BatchRevokePermissions' {[BatchPermissionsRequestEntry]
Maybe Text
entries :: [BatchPermissionsRequestEntry]
catalogId :: Maybe Text
$sel:entries:BatchRevokePermissions' :: BatchRevokePermissions -> [BatchPermissionsRequestEntry]
$sel:catalogId:BatchRevokePermissions' :: BatchRevokePermissions -> 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,
            forall a. a -> Maybe a
Prelude.Just (Key
"Entries" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [BatchPermissionsRequestEntry]
entries)
          ]
      )

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

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

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

-- |
-- Create a value of 'BatchRevokePermissionsResponse' 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:
--
-- 'failures', 'batchRevokePermissionsResponse_failures' - A list of failures to revoke permissions to the resources.
--
-- 'httpStatus', 'batchRevokePermissionsResponse_httpStatus' - The response's http status code.
newBatchRevokePermissionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchRevokePermissionsResponse
newBatchRevokePermissionsResponse :: Int -> BatchRevokePermissionsResponse
newBatchRevokePermissionsResponse Int
pHttpStatus_ =
  BatchRevokePermissionsResponse'
    { $sel:failures:BatchRevokePermissionsResponse' :: Maybe [BatchPermissionsFailureEntry]
failures =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchRevokePermissionsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of failures to revoke permissions to the resources.
batchRevokePermissionsResponse_failures :: Lens.Lens' BatchRevokePermissionsResponse (Prelude.Maybe [BatchPermissionsFailureEntry])
batchRevokePermissionsResponse_failures :: Lens'
  BatchRevokePermissionsResponse
  (Maybe [BatchPermissionsFailureEntry])
batchRevokePermissionsResponse_failures = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchRevokePermissionsResponse' {Maybe [BatchPermissionsFailureEntry]
failures :: Maybe [BatchPermissionsFailureEntry]
$sel:failures:BatchRevokePermissionsResponse' :: BatchRevokePermissionsResponse
-> Maybe [BatchPermissionsFailureEntry]
failures} -> Maybe [BatchPermissionsFailureEntry]
failures) (\s :: BatchRevokePermissionsResponse
s@BatchRevokePermissionsResponse' {} Maybe [BatchPermissionsFailureEntry]
a -> BatchRevokePermissionsResponse
s {$sel:failures:BatchRevokePermissionsResponse' :: Maybe [BatchPermissionsFailureEntry]
failures = Maybe [BatchPermissionsFailureEntry]
a} :: BatchRevokePermissionsResponse) 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 response's http status code.
batchRevokePermissionsResponse_httpStatus :: Lens.Lens' BatchRevokePermissionsResponse Prelude.Int
batchRevokePermissionsResponse_httpStatus :: Lens' BatchRevokePermissionsResponse Int
batchRevokePermissionsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchRevokePermissionsResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchRevokePermissionsResponse' :: BatchRevokePermissionsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchRevokePermissionsResponse
s@BatchRevokePermissionsResponse' {} Int
a -> BatchRevokePermissionsResponse
s {$sel:httpStatus:BatchRevokePermissionsResponse' :: Int
httpStatus = Int
a} :: BatchRevokePermissionsResponse)

instance
  Prelude.NFData
    BatchRevokePermissionsResponse
  where
  rnf :: BatchRevokePermissionsResponse -> ()
rnf BatchRevokePermissionsResponse' {Int
Maybe [BatchPermissionsFailureEntry]
httpStatus :: Int
failures :: Maybe [BatchPermissionsFailureEntry]
$sel:httpStatus:BatchRevokePermissionsResponse' :: BatchRevokePermissionsResponse -> Int
$sel:failures:BatchRevokePermissionsResponse' :: BatchRevokePermissionsResponse
-> Maybe [BatchPermissionsFailureEntry]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [BatchPermissionsFailureEntry]
failures
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus