{-# 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.Redshift.RevokeEndpointAccess
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Revokes access to a cluster.
module Amazonka.Redshift.RevokeEndpointAccess
  ( -- * Creating a Request
    RevokeEndpointAccess (..),
    newRevokeEndpointAccess,

    -- * Request Lenses
    revokeEndpointAccess_account,
    revokeEndpointAccess_clusterIdentifier,
    revokeEndpointAccess_force,
    revokeEndpointAccess_vpcIds,

    -- * Destructuring the Response
    EndpointAuthorization (..),
    newEndpointAuthorization,

    -- * Response Lenses
    endpointAuthorization_allowedAllVPCs,
    endpointAuthorization_allowedVPCs,
    endpointAuthorization_authorizeTime,
    endpointAuthorization_clusterIdentifier,
    endpointAuthorization_clusterStatus,
    endpointAuthorization_endpointCount,
    endpointAuthorization_grantee,
    endpointAuthorization_grantor,
    endpointAuthorization_status,
  )
where

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

-- | /See:/ 'newRevokeEndpointAccess' smart constructor.
data RevokeEndpointAccess = RevokeEndpointAccess'
  { -- | The Amazon Web Services account ID whose access is to be revoked.
    RevokeEndpointAccess -> Maybe Text
account :: Prelude.Maybe Prelude.Text,
    -- | The cluster to revoke access from.
    RevokeEndpointAccess -> Maybe Text
clusterIdentifier :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether to force the revoke action. If true, the
    -- Redshift-managed VPC endpoints associated with the endpoint
    -- authorization are also deleted.
    RevokeEndpointAccess -> Maybe Bool
force :: Prelude.Maybe Prelude.Bool,
    -- | The virtual private cloud (VPC) identifiers for which access is to be
    -- revoked.
    RevokeEndpointAccess -> Maybe [Text]
vpcIds :: Prelude.Maybe [Prelude.Text]
  }
  deriving (RevokeEndpointAccess -> RevokeEndpointAccess -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RevokeEndpointAccess -> RevokeEndpointAccess -> Bool
$c/= :: RevokeEndpointAccess -> RevokeEndpointAccess -> Bool
== :: RevokeEndpointAccess -> RevokeEndpointAccess -> Bool
$c== :: RevokeEndpointAccess -> RevokeEndpointAccess -> Bool
Prelude.Eq, ReadPrec [RevokeEndpointAccess]
ReadPrec RevokeEndpointAccess
Int -> ReadS RevokeEndpointAccess
ReadS [RevokeEndpointAccess]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RevokeEndpointAccess]
$creadListPrec :: ReadPrec [RevokeEndpointAccess]
readPrec :: ReadPrec RevokeEndpointAccess
$creadPrec :: ReadPrec RevokeEndpointAccess
readList :: ReadS [RevokeEndpointAccess]
$creadList :: ReadS [RevokeEndpointAccess]
readsPrec :: Int -> ReadS RevokeEndpointAccess
$creadsPrec :: Int -> ReadS RevokeEndpointAccess
Prelude.Read, Int -> RevokeEndpointAccess -> ShowS
[RevokeEndpointAccess] -> ShowS
RevokeEndpointAccess -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RevokeEndpointAccess] -> ShowS
$cshowList :: [RevokeEndpointAccess] -> ShowS
show :: RevokeEndpointAccess -> String
$cshow :: RevokeEndpointAccess -> String
showsPrec :: Int -> RevokeEndpointAccess -> ShowS
$cshowsPrec :: Int -> RevokeEndpointAccess -> ShowS
Prelude.Show, forall x. Rep RevokeEndpointAccess x -> RevokeEndpointAccess
forall x. RevokeEndpointAccess -> Rep RevokeEndpointAccess x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RevokeEndpointAccess x -> RevokeEndpointAccess
$cfrom :: forall x. RevokeEndpointAccess -> Rep RevokeEndpointAccess x
Prelude.Generic)

-- |
-- Create a value of 'RevokeEndpointAccess' 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:
--
-- 'account', 'revokeEndpointAccess_account' - The Amazon Web Services account ID whose access is to be revoked.
--
-- 'clusterIdentifier', 'revokeEndpointAccess_clusterIdentifier' - The cluster to revoke access from.
--
-- 'force', 'revokeEndpointAccess_force' - Indicates whether to force the revoke action. If true, the
-- Redshift-managed VPC endpoints associated with the endpoint
-- authorization are also deleted.
--
-- 'vpcIds', 'revokeEndpointAccess_vpcIds' - The virtual private cloud (VPC) identifiers for which access is to be
-- revoked.
newRevokeEndpointAccess ::
  RevokeEndpointAccess
newRevokeEndpointAccess :: RevokeEndpointAccess
newRevokeEndpointAccess =
  RevokeEndpointAccess'
    { $sel:account:RevokeEndpointAccess' :: Maybe Text
account = forall a. Maybe a
Prelude.Nothing,
      $sel:clusterIdentifier:RevokeEndpointAccess' :: Maybe Text
clusterIdentifier = forall a. Maybe a
Prelude.Nothing,
      $sel:force:RevokeEndpointAccess' :: Maybe Bool
force = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcIds:RevokeEndpointAccess' :: Maybe [Text]
vpcIds = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Web Services account ID whose access is to be revoked.
revokeEndpointAccess_account :: Lens.Lens' RevokeEndpointAccess (Prelude.Maybe Prelude.Text)
revokeEndpointAccess_account :: Lens' RevokeEndpointAccess (Maybe Text)
revokeEndpointAccess_account = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevokeEndpointAccess' {Maybe Text
account :: Maybe Text
$sel:account:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe Text
account} -> Maybe Text
account) (\s :: RevokeEndpointAccess
s@RevokeEndpointAccess' {} Maybe Text
a -> RevokeEndpointAccess
s {$sel:account:RevokeEndpointAccess' :: Maybe Text
account = Maybe Text
a} :: RevokeEndpointAccess)

-- | The cluster to revoke access from.
revokeEndpointAccess_clusterIdentifier :: Lens.Lens' RevokeEndpointAccess (Prelude.Maybe Prelude.Text)
revokeEndpointAccess_clusterIdentifier :: Lens' RevokeEndpointAccess (Maybe Text)
revokeEndpointAccess_clusterIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevokeEndpointAccess' {Maybe Text
clusterIdentifier :: Maybe Text
$sel:clusterIdentifier:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe Text
clusterIdentifier} -> Maybe Text
clusterIdentifier) (\s :: RevokeEndpointAccess
s@RevokeEndpointAccess' {} Maybe Text
a -> RevokeEndpointAccess
s {$sel:clusterIdentifier:RevokeEndpointAccess' :: Maybe Text
clusterIdentifier = Maybe Text
a} :: RevokeEndpointAccess)

-- | Indicates whether to force the revoke action. If true, the
-- Redshift-managed VPC endpoints associated with the endpoint
-- authorization are also deleted.
revokeEndpointAccess_force :: Lens.Lens' RevokeEndpointAccess (Prelude.Maybe Prelude.Bool)
revokeEndpointAccess_force :: Lens' RevokeEndpointAccess (Maybe Bool)
revokeEndpointAccess_force = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevokeEndpointAccess' {Maybe Bool
force :: Maybe Bool
$sel:force:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe Bool
force} -> Maybe Bool
force) (\s :: RevokeEndpointAccess
s@RevokeEndpointAccess' {} Maybe Bool
a -> RevokeEndpointAccess
s {$sel:force:RevokeEndpointAccess' :: Maybe Bool
force = Maybe Bool
a} :: RevokeEndpointAccess)

-- | The virtual private cloud (VPC) identifiers for which access is to be
-- revoked.
revokeEndpointAccess_vpcIds :: Lens.Lens' RevokeEndpointAccess (Prelude.Maybe [Prelude.Text])
revokeEndpointAccess_vpcIds :: Lens' RevokeEndpointAccess (Maybe [Text])
revokeEndpointAccess_vpcIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevokeEndpointAccess' {Maybe [Text]
vpcIds :: Maybe [Text]
$sel:vpcIds:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe [Text]
vpcIds} -> Maybe [Text]
vpcIds) (\s :: RevokeEndpointAccess
s@RevokeEndpointAccess' {} Maybe [Text]
a -> RevokeEndpointAccess
s {$sel:vpcIds:RevokeEndpointAccess' :: Maybe [Text]
vpcIds = Maybe [Text]
a} :: RevokeEndpointAccess) 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

instance Core.AWSRequest RevokeEndpointAccess where
  type
    AWSResponse RevokeEndpointAccess =
      EndpointAuthorization
  request :: (Service -> Service)
-> RevokeEndpointAccess -> Request RevokeEndpointAccess
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy RevokeEndpointAccess
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RevokeEndpointAccess)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"RevokeEndpointAccessResult"
      (\Int
s ResponseHeaders
h [Node]
x -> forall a. FromXML a => [Node] -> Either String a
Data.parseXML [Node]
x)

instance Prelude.Hashable RevokeEndpointAccess where
  hashWithSalt :: Int -> RevokeEndpointAccess -> Int
hashWithSalt Int
_salt RevokeEndpointAccess' {Maybe Bool
Maybe [Text]
Maybe Text
vpcIds :: Maybe [Text]
force :: Maybe Bool
clusterIdentifier :: Maybe Text
account :: Maybe Text
$sel:vpcIds:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe [Text]
$sel:force:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe Bool
$sel:clusterIdentifier:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe Text
$sel:account:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
account
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clusterIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
force
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
vpcIds

instance Prelude.NFData RevokeEndpointAccess where
  rnf :: RevokeEndpointAccess -> ()
rnf RevokeEndpointAccess' {Maybe Bool
Maybe [Text]
Maybe Text
vpcIds :: Maybe [Text]
force :: Maybe Bool
clusterIdentifier :: Maybe Text
account :: Maybe Text
$sel:vpcIds:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe [Text]
$sel:force:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe Bool
$sel:clusterIdentifier:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe Text
$sel:account:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
account
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clusterIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
force
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
vpcIds

instance Data.ToHeaders RevokeEndpointAccess where
  toHeaders :: RevokeEndpointAccess -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery RevokeEndpointAccess where
  toQuery :: RevokeEndpointAccess -> QueryString
toQuery RevokeEndpointAccess' {Maybe Bool
Maybe [Text]
Maybe Text
vpcIds :: Maybe [Text]
force :: Maybe Bool
clusterIdentifier :: Maybe Text
account :: Maybe Text
$sel:vpcIds:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe [Text]
$sel:force:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe Bool
$sel:clusterIdentifier:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe Text
$sel:account:RevokeEndpointAccess' :: RevokeEndpointAccess -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"RevokeEndpointAccess" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"Account" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
account,
        ByteString
"ClusterIdentifier" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
clusterIdentifier,
        ByteString
"Force" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
force,
        ByteString
"VpcIds"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"VpcIdentifier"
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
vpcIds
            )
      ]