{-# 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.DeauthorizeDataShare
-- 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)
--
-- From the producer account, removes authorization from the specified
-- datashare.
module Amazonka.Redshift.DeauthorizeDataShare
  ( -- * Creating a Request
    DeauthorizeDataShare (..),
    newDeauthorizeDataShare,

    -- * Request Lenses
    deauthorizeDataShare_dataShareArn,
    deauthorizeDataShare_consumerIdentifier,

    -- * Destructuring the Response
    DataShare (..),
    newDataShare,

    -- * Response Lenses
    dataShare_producerArn,
    dataShare_dataShareAssociations,
    dataShare_dataShareArn,
    dataShare_allowPubliclyAccessibleConsumers,
  )
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:/ 'newDeauthorizeDataShare' smart constructor.
data DeauthorizeDataShare = DeauthorizeDataShare'
  { -- | The Amazon Resource Name (ARN) of the datashare to remove authorization
    -- from.
    DeauthorizeDataShare -> Text
dataShareArn :: Prelude.Text,
    -- | The identifier of the data consumer that is to have authorization
    -- removed from the datashare. This identifier is an AWS account ID.
    DeauthorizeDataShare -> Text
consumerIdentifier :: Prelude.Text
  }
  deriving (DeauthorizeDataShare -> DeauthorizeDataShare -> Bool
(DeauthorizeDataShare -> DeauthorizeDataShare -> Bool)
-> (DeauthorizeDataShare -> DeauthorizeDataShare -> Bool)
-> Eq DeauthorizeDataShare
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeauthorizeDataShare -> DeauthorizeDataShare -> Bool
$c/= :: DeauthorizeDataShare -> DeauthorizeDataShare -> Bool
== :: DeauthorizeDataShare -> DeauthorizeDataShare -> Bool
$c== :: DeauthorizeDataShare -> DeauthorizeDataShare -> Bool
Prelude.Eq, ReadPrec [DeauthorizeDataShare]
ReadPrec DeauthorizeDataShare
Int -> ReadS DeauthorizeDataShare
ReadS [DeauthorizeDataShare]
(Int -> ReadS DeauthorizeDataShare)
-> ReadS [DeauthorizeDataShare]
-> ReadPrec DeauthorizeDataShare
-> ReadPrec [DeauthorizeDataShare]
-> Read DeauthorizeDataShare
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeauthorizeDataShare]
$creadListPrec :: ReadPrec [DeauthorizeDataShare]
readPrec :: ReadPrec DeauthorizeDataShare
$creadPrec :: ReadPrec DeauthorizeDataShare
readList :: ReadS [DeauthorizeDataShare]
$creadList :: ReadS [DeauthorizeDataShare]
readsPrec :: Int -> ReadS DeauthorizeDataShare
$creadsPrec :: Int -> ReadS DeauthorizeDataShare
Prelude.Read, Int -> DeauthorizeDataShare -> ShowS
[DeauthorizeDataShare] -> ShowS
DeauthorizeDataShare -> String
(Int -> DeauthorizeDataShare -> ShowS)
-> (DeauthorizeDataShare -> String)
-> ([DeauthorizeDataShare] -> ShowS)
-> Show DeauthorizeDataShare
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeauthorizeDataShare] -> ShowS
$cshowList :: [DeauthorizeDataShare] -> ShowS
show :: DeauthorizeDataShare -> String
$cshow :: DeauthorizeDataShare -> String
showsPrec :: Int -> DeauthorizeDataShare -> ShowS
$cshowsPrec :: Int -> DeauthorizeDataShare -> ShowS
Prelude.Show, (forall x. DeauthorizeDataShare -> Rep DeauthorizeDataShare x)
-> (forall x. Rep DeauthorizeDataShare x -> DeauthorizeDataShare)
-> Generic DeauthorizeDataShare
forall x. Rep DeauthorizeDataShare x -> DeauthorizeDataShare
forall x. DeauthorizeDataShare -> Rep DeauthorizeDataShare x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeauthorizeDataShare x -> DeauthorizeDataShare
$cfrom :: forall x. DeauthorizeDataShare -> Rep DeauthorizeDataShare x
Prelude.Generic)

-- |
-- Create a value of 'DeauthorizeDataShare' 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:
--
-- 'dataShareArn', 'deauthorizeDataShare_dataShareArn' - The Amazon Resource Name (ARN) of the datashare to remove authorization
-- from.
--
-- 'consumerIdentifier', 'deauthorizeDataShare_consumerIdentifier' - The identifier of the data consumer that is to have authorization
-- removed from the datashare. This identifier is an AWS account ID.
newDeauthorizeDataShare ::
  -- | 'dataShareArn'
  Prelude.Text ->
  -- | 'consumerIdentifier'
  Prelude.Text ->
  DeauthorizeDataShare
newDeauthorizeDataShare :: Text -> Text -> DeauthorizeDataShare
newDeauthorizeDataShare
  Text
pDataShareArn_
  Text
pConsumerIdentifier_ =
    DeauthorizeDataShare' :: Text -> Text -> DeauthorizeDataShare
DeauthorizeDataShare'
      { $sel:dataShareArn:DeauthorizeDataShare' :: Text
dataShareArn =
          Text
pDataShareArn_,
        $sel:consumerIdentifier:DeauthorizeDataShare' :: Text
consumerIdentifier = Text
pConsumerIdentifier_
      }

-- | The Amazon Resource Name (ARN) of the datashare to remove authorization
-- from.
deauthorizeDataShare_dataShareArn :: Lens.Lens' DeauthorizeDataShare Prelude.Text
deauthorizeDataShare_dataShareArn :: (Text -> f Text) -> DeauthorizeDataShare -> f DeauthorizeDataShare
deauthorizeDataShare_dataShareArn = (DeauthorizeDataShare -> Text)
-> (DeauthorizeDataShare -> Text -> DeauthorizeDataShare)
-> Lens DeauthorizeDataShare DeauthorizeDataShare Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeauthorizeDataShare' {Text
dataShareArn :: Text
$sel:dataShareArn:DeauthorizeDataShare' :: DeauthorizeDataShare -> Text
dataShareArn} -> Text
dataShareArn) (\s :: DeauthorizeDataShare
s@DeauthorizeDataShare' {} Text
a -> DeauthorizeDataShare
s {$sel:dataShareArn:DeauthorizeDataShare' :: Text
dataShareArn = Text
a} :: DeauthorizeDataShare)

-- | The identifier of the data consumer that is to have authorization
-- removed from the datashare. This identifier is an AWS account ID.
deauthorizeDataShare_consumerIdentifier :: Lens.Lens' DeauthorizeDataShare Prelude.Text
deauthorizeDataShare_consumerIdentifier :: (Text -> f Text) -> DeauthorizeDataShare -> f DeauthorizeDataShare
deauthorizeDataShare_consumerIdentifier = (DeauthorizeDataShare -> Text)
-> (DeauthorizeDataShare -> Text -> DeauthorizeDataShare)
-> Lens DeauthorizeDataShare DeauthorizeDataShare Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeauthorizeDataShare' {Text
consumerIdentifier :: Text
$sel:consumerIdentifier:DeauthorizeDataShare' :: DeauthorizeDataShare -> Text
consumerIdentifier} -> Text
consumerIdentifier) (\s :: DeauthorizeDataShare
s@DeauthorizeDataShare' {} Text
a -> DeauthorizeDataShare
s {$sel:consumerIdentifier:DeauthorizeDataShare' :: Text
consumerIdentifier = Text
a} :: DeauthorizeDataShare)

instance Core.AWSRequest DeauthorizeDataShare where
  type AWSResponse DeauthorizeDataShare = DataShare
  request :: DeauthorizeDataShare -> Request DeauthorizeDataShare
request = Service -> DeauthorizeDataShare -> Request DeauthorizeDataShare
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DeauthorizeDataShare
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeauthorizeDataShare)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DeauthorizeDataShare))
-> Logger
-> Service
-> Proxy DeauthorizeDataShare
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeauthorizeDataShare)))
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
"DeauthorizeDataShareResult"
      (\Int
s ResponseHeaders
h [Node]
x -> [Node] -> Either String DataShare
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)

instance Prelude.Hashable DeauthorizeDataShare

instance Prelude.NFData DeauthorizeDataShare

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

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

instance Core.ToQuery DeauthorizeDataShare where
  toQuery :: DeauthorizeDataShare -> QueryString
toQuery DeauthorizeDataShare' {Text
consumerIdentifier :: Text
dataShareArn :: Text
$sel:consumerIdentifier:DeauthorizeDataShare' :: DeauthorizeDataShare -> Text
$sel:dataShareArn:DeauthorizeDataShare' :: DeauthorizeDataShare -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DeauthorizeDataShare" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"DataShareArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
dataShareArn,
        ByteString
"ConsumerIdentifier" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
consumerIdentifier
      ]