{-# 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.DisassociateDataShareConsumer
-- 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 a consumer account, remove association for the specified datashare.
module Amazonka.Redshift.DisassociateDataShareConsumer
  ( -- * Creating a Request
    DisassociateDataShareConsumer (..),
    newDisassociateDataShareConsumer,

    -- * Request Lenses
    disassociateDataShareConsumer_disassociateEntireAccount,
    disassociateDataShareConsumer_consumerArn,
    disassociateDataShareConsumer_dataShareArn,

    -- * 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:/ 'newDisassociateDataShareConsumer' smart constructor.
data DisassociateDataShareConsumer = DisassociateDataShareConsumer'
  { -- | A value that specifies whether association for the datashare is removed
    -- from the entire account.
    DisassociateDataShareConsumer -> Maybe Bool
disassociateEntireAccount :: Prelude.Maybe Prelude.Bool,
    -- | The Amazon Resource Name (ARN) of the consumer that association for the
    -- datashare is removed from.
    DisassociateDataShareConsumer -> Maybe Text
consumerArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the datashare to remove association
    -- for.
    DisassociateDataShareConsumer -> Text
dataShareArn :: Prelude.Text
  }
  deriving (DisassociateDataShareConsumer
-> DisassociateDataShareConsumer -> Bool
(DisassociateDataShareConsumer
 -> DisassociateDataShareConsumer -> Bool)
-> (DisassociateDataShareConsumer
    -> DisassociateDataShareConsumer -> Bool)
-> Eq DisassociateDataShareConsumer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateDataShareConsumer
-> DisassociateDataShareConsumer -> Bool
$c/= :: DisassociateDataShareConsumer
-> DisassociateDataShareConsumer -> Bool
== :: DisassociateDataShareConsumer
-> DisassociateDataShareConsumer -> Bool
$c== :: DisassociateDataShareConsumer
-> DisassociateDataShareConsumer -> Bool
Prelude.Eq, ReadPrec [DisassociateDataShareConsumer]
ReadPrec DisassociateDataShareConsumer
Int -> ReadS DisassociateDataShareConsumer
ReadS [DisassociateDataShareConsumer]
(Int -> ReadS DisassociateDataShareConsumer)
-> ReadS [DisassociateDataShareConsumer]
-> ReadPrec DisassociateDataShareConsumer
-> ReadPrec [DisassociateDataShareConsumer]
-> Read DisassociateDataShareConsumer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateDataShareConsumer]
$creadListPrec :: ReadPrec [DisassociateDataShareConsumer]
readPrec :: ReadPrec DisassociateDataShareConsumer
$creadPrec :: ReadPrec DisassociateDataShareConsumer
readList :: ReadS [DisassociateDataShareConsumer]
$creadList :: ReadS [DisassociateDataShareConsumer]
readsPrec :: Int -> ReadS DisassociateDataShareConsumer
$creadsPrec :: Int -> ReadS DisassociateDataShareConsumer
Prelude.Read, Int -> DisassociateDataShareConsumer -> ShowS
[DisassociateDataShareConsumer] -> ShowS
DisassociateDataShareConsumer -> String
(Int -> DisassociateDataShareConsumer -> ShowS)
-> (DisassociateDataShareConsumer -> String)
-> ([DisassociateDataShareConsumer] -> ShowS)
-> Show DisassociateDataShareConsumer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateDataShareConsumer] -> ShowS
$cshowList :: [DisassociateDataShareConsumer] -> ShowS
show :: DisassociateDataShareConsumer -> String
$cshow :: DisassociateDataShareConsumer -> String
showsPrec :: Int -> DisassociateDataShareConsumer -> ShowS
$cshowsPrec :: Int -> DisassociateDataShareConsumer -> ShowS
Prelude.Show, (forall x.
 DisassociateDataShareConsumer
 -> Rep DisassociateDataShareConsumer x)
-> (forall x.
    Rep DisassociateDataShareConsumer x
    -> DisassociateDataShareConsumer)
-> Generic DisassociateDataShareConsumer
forall x.
Rep DisassociateDataShareConsumer x
-> DisassociateDataShareConsumer
forall x.
DisassociateDataShareConsumer
-> Rep DisassociateDataShareConsumer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateDataShareConsumer x
-> DisassociateDataShareConsumer
$cfrom :: forall x.
DisassociateDataShareConsumer
-> Rep DisassociateDataShareConsumer x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateDataShareConsumer' 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:
--
-- 'disassociateEntireAccount', 'disassociateDataShareConsumer_disassociateEntireAccount' - A value that specifies whether association for the datashare is removed
-- from the entire account.
--
-- 'consumerArn', 'disassociateDataShareConsumer_consumerArn' - The Amazon Resource Name (ARN) of the consumer that association for the
-- datashare is removed from.
--
-- 'dataShareArn', 'disassociateDataShareConsumer_dataShareArn' - The Amazon Resource Name (ARN) of the datashare to remove association
-- for.
newDisassociateDataShareConsumer ::
  -- | 'dataShareArn'
  Prelude.Text ->
  DisassociateDataShareConsumer
newDisassociateDataShareConsumer :: Text -> DisassociateDataShareConsumer
newDisassociateDataShareConsumer Text
pDataShareArn_ =
  DisassociateDataShareConsumer' :: Maybe Bool -> Maybe Text -> Text -> DisassociateDataShareConsumer
DisassociateDataShareConsumer'
    { $sel:disassociateEntireAccount:DisassociateDataShareConsumer' :: Maybe Bool
disassociateEntireAccount =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:consumerArn:DisassociateDataShareConsumer' :: Maybe Text
consumerArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dataShareArn:DisassociateDataShareConsumer' :: Text
dataShareArn = Text
pDataShareArn_
    }

-- | A value that specifies whether association for the datashare is removed
-- from the entire account.
disassociateDataShareConsumer_disassociateEntireAccount :: Lens.Lens' DisassociateDataShareConsumer (Prelude.Maybe Prelude.Bool)
disassociateDataShareConsumer_disassociateEntireAccount :: (Maybe Bool -> f (Maybe Bool))
-> DisassociateDataShareConsumer -> f DisassociateDataShareConsumer
disassociateDataShareConsumer_disassociateEntireAccount = (DisassociateDataShareConsumer -> Maybe Bool)
-> (DisassociateDataShareConsumer
    -> Maybe Bool -> DisassociateDataShareConsumer)
-> Lens
     DisassociateDataShareConsumer
     DisassociateDataShareConsumer
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateDataShareConsumer' {Maybe Bool
disassociateEntireAccount :: Maybe Bool
$sel:disassociateEntireAccount:DisassociateDataShareConsumer' :: DisassociateDataShareConsumer -> Maybe Bool
disassociateEntireAccount} -> Maybe Bool
disassociateEntireAccount) (\s :: DisassociateDataShareConsumer
s@DisassociateDataShareConsumer' {} Maybe Bool
a -> DisassociateDataShareConsumer
s {$sel:disassociateEntireAccount:DisassociateDataShareConsumer' :: Maybe Bool
disassociateEntireAccount = Maybe Bool
a} :: DisassociateDataShareConsumer)

-- | The Amazon Resource Name (ARN) of the consumer that association for the
-- datashare is removed from.
disassociateDataShareConsumer_consumerArn :: Lens.Lens' DisassociateDataShareConsumer (Prelude.Maybe Prelude.Text)
disassociateDataShareConsumer_consumerArn :: (Maybe Text -> f (Maybe Text))
-> DisassociateDataShareConsumer -> f DisassociateDataShareConsumer
disassociateDataShareConsumer_consumerArn = (DisassociateDataShareConsumer -> Maybe Text)
-> (DisassociateDataShareConsumer
    -> Maybe Text -> DisassociateDataShareConsumer)
-> Lens
     DisassociateDataShareConsumer
     DisassociateDataShareConsumer
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateDataShareConsumer' {Maybe Text
consumerArn :: Maybe Text
$sel:consumerArn:DisassociateDataShareConsumer' :: DisassociateDataShareConsumer -> Maybe Text
consumerArn} -> Maybe Text
consumerArn) (\s :: DisassociateDataShareConsumer
s@DisassociateDataShareConsumer' {} Maybe Text
a -> DisassociateDataShareConsumer
s {$sel:consumerArn:DisassociateDataShareConsumer' :: Maybe Text
consumerArn = Maybe Text
a} :: DisassociateDataShareConsumer)

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

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

instance Prelude.NFData DisassociateDataShareConsumer

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

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

instance Core.ToQuery DisassociateDataShareConsumer where
  toQuery :: DisassociateDataShareConsumer -> QueryString
toQuery DisassociateDataShareConsumer' {Maybe Bool
Maybe Text
Text
dataShareArn :: Text
consumerArn :: Maybe Text
disassociateEntireAccount :: Maybe Bool
$sel:dataShareArn:DisassociateDataShareConsumer' :: DisassociateDataShareConsumer -> Text
$sel:consumerArn:DisassociateDataShareConsumer' :: DisassociateDataShareConsumer -> Maybe Text
$sel:disassociateEntireAccount:DisassociateDataShareConsumer' :: DisassociateDataShareConsumer -> 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
"DisassociateDataShareConsumer" ::
                      Prelude.ByteString
                  ),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"DisassociateEntireAccount"
          ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
disassociateEntireAccount,
        ByteString
"ConsumerArn" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
consumerArn,
        ByteString
"DataShareArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
dataShareArn
      ]