{-# 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-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)
--
-- Revokes access to a cluster.
module Amazonka.Redshift.RevokeEndpointAccess
  ( -- * Creating a Request
    RevokeEndpointAccess (..),
    newRevokeEndpointAccess,

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

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

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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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 cluster to revoke access from.
    RevokeEndpointAccess -> Maybe Text
clusterIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services account ID whose access is to be revoked.
    RevokeEndpointAccess -> Maybe Text
account :: Prelude.Maybe Prelude.Text,
    -- | 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
(RevokeEndpointAccess -> RevokeEndpointAccess -> Bool)
-> (RevokeEndpointAccess -> RevokeEndpointAccess -> Bool)
-> Eq RevokeEndpointAccess
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]
(Int -> ReadS RevokeEndpointAccess)
-> ReadS [RevokeEndpointAccess]
-> ReadPrec RevokeEndpointAccess
-> ReadPrec [RevokeEndpointAccess]
-> Read 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
(Int -> RevokeEndpointAccess -> ShowS)
-> (RevokeEndpointAccess -> String)
-> ([RevokeEndpointAccess] -> ShowS)
-> Show RevokeEndpointAccess
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. RevokeEndpointAccess -> Rep RevokeEndpointAccess x)
-> (forall x. Rep RevokeEndpointAccess x -> RevokeEndpointAccess)
-> Generic RevokeEndpointAccess
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:
--
-- '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.
--
-- 'clusterIdentifier', 'revokeEndpointAccess_clusterIdentifier' - The cluster to revoke access from.
--
-- 'account', 'revokeEndpointAccess_account' - The Amazon Web Services account ID whose access is to be revoked.
--
-- 'vpcIds', 'revokeEndpointAccess_vpcIds' - The virtual private cloud (VPC) identifiers for which access is to be
-- revoked.
newRevokeEndpointAccess ::
  RevokeEndpointAccess
newRevokeEndpointAccess :: RevokeEndpointAccess
newRevokeEndpointAccess =
  RevokeEndpointAccess' :: Maybe Bool
-> Maybe Text -> Maybe Text -> Maybe [Text] -> RevokeEndpointAccess
RevokeEndpointAccess'
    { $sel:force:RevokeEndpointAccess' :: Maybe Bool
force = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterIdentifier:RevokeEndpointAccess' :: Maybe Text
clusterIdentifier = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:account:RevokeEndpointAccess' :: Maybe Text
account = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:vpcIds:RevokeEndpointAccess' :: Maybe [Text]
vpcIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Bool -> f (Maybe Bool))
-> RevokeEndpointAccess -> f RevokeEndpointAccess
revokeEndpointAccess_force = (RevokeEndpointAccess -> Maybe Bool)
-> (RevokeEndpointAccess -> Maybe Bool -> RevokeEndpointAccess)
-> Lens
     RevokeEndpointAccess RevokeEndpointAccess (Maybe Bool) (Maybe Bool)
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 cluster to revoke access from.
revokeEndpointAccess_clusterIdentifier :: Lens.Lens' RevokeEndpointAccess (Prelude.Maybe Prelude.Text)
revokeEndpointAccess_clusterIdentifier :: (Maybe Text -> f (Maybe Text))
-> RevokeEndpointAccess -> f RevokeEndpointAccess
revokeEndpointAccess_clusterIdentifier = (RevokeEndpointAccess -> Maybe Text)
-> (RevokeEndpointAccess -> Maybe Text -> RevokeEndpointAccess)
-> Lens
     RevokeEndpointAccess RevokeEndpointAccess (Maybe Text) (Maybe Text)
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)

-- | The Amazon Web Services account ID whose access is to be revoked.
revokeEndpointAccess_account :: Lens.Lens' RevokeEndpointAccess (Prelude.Maybe Prelude.Text)
revokeEndpointAccess_account :: (Maybe Text -> f (Maybe Text))
-> RevokeEndpointAccess -> f RevokeEndpointAccess
revokeEndpointAccess_account = (RevokeEndpointAccess -> Maybe Text)
-> (RevokeEndpointAccess -> Maybe Text -> RevokeEndpointAccess)
-> Lens
     RevokeEndpointAccess RevokeEndpointAccess (Maybe Text) (Maybe Text)
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 virtual private cloud (VPC) identifiers for which access is to be
-- revoked.
revokeEndpointAccess_vpcIds :: Lens.Lens' RevokeEndpointAccess (Prelude.Maybe [Prelude.Text])
revokeEndpointAccess_vpcIds :: (Maybe [Text] -> f (Maybe [Text]))
-> RevokeEndpointAccess -> f RevokeEndpointAccess
revokeEndpointAccess_vpcIds = (RevokeEndpointAccess -> Maybe [Text])
-> (RevokeEndpointAccess -> Maybe [Text] -> RevokeEndpointAccess)
-> Lens
     RevokeEndpointAccess
     RevokeEndpointAccess
     (Maybe [Text])
     (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> RevokeEndpointAccess -> f RevokeEndpointAccess)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> RevokeEndpointAccess
-> f RevokeEndpointAccess
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: RevokeEndpointAccess -> Request RevokeEndpointAccess
request = Service -> RevokeEndpointAccess -> Request RevokeEndpointAccess
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy RevokeEndpointAccess
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RevokeEndpointAccess)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse RevokeEndpointAccess))
-> Logger
-> Service
-> Proxy RevokeEndpointAccess
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RevokeEndpointAccess)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"RevokeEndpointAccessResult"
      (\Int
s ResponseHeaders
h [Node]
x -> [Node] -> Either String EndpointAuthorization
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)

instance Prelude.Hashable RevokeEndpointAccess

instance Prelude.NFData RevokeEndpointAccess

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

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

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