{-# 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.RejectDataShare
-- 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 consumer account, rejects the specified datashare.
module Amazonka.Redshift.RejectDataShare
  ( -- * Creating a Request
    RejectDataShare (..),
    newRejectDataShare,

    -- * Request Lenses
    rejectDataShare_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:/ 'newRejectDataShare' smart constructor.
data RejectDataShare = RejectDataShare'
  { -- | The Amazon Resource Name (ARN) of the datashare to reject.
    RejectDataShare -> Text
dataShareArn :: Prelude.Text
  }
  deriving (RejectDataShare -> RejectDataShare -> Bool
(RejectDataShare -> RejectDataShare -> Bool)
-> (RejectDataShare -> RejectDataShare -> Bool)
-> Eq RejectDataShare
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RejectDataShare -> RejectDataShare -> Bool
$c/= :: RejectDataShare -> RejectDataShare -> Bool
== :: RejectDataShare -> RejectDataShare -> Bool
$c== :: RejectDataShare -> RejectDataShare -> Bool
Prelude.Eq, ReadPrec [RejectDataShare]
ReadPrec RejectDataShare
Int -> ReadS RejectDataShare
ReadS [RejectDataShare]
(Int -> ReadS RejectDataShare)
-> ReadS [RejectDataShare]
-> ReadPrec RejectDataShare
-> ReadPrec [RejectDataShare]
-> Read RejectDataShare
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RejectDataShare]
$creadListPrec :: ReadPrec [RejectDataShare]
readPrec :: ReadPrec RejectDataShare
$creadPrec :: ReadPrec RejectDataShare
readList :: ReadS [RejectDataShare]
$creadList :: ReadS [RejectDataShare]
readsPrec :: Int -> ReadS RejectDataShare
$creadsPrec :: Int -> ReadS RejectDataShare
Prelude.Read, Int -> RejectDataShare -> ShowS
[RejectDataShare] -> ShowS
RejectDataShare -> String
(Int -> RejectDataShare -> ShowS)
-> (RejectDataShare -> String)
-> ([RejectDataShare] -> ShowS)
-> Show RejectDataShare
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RejectDataShare] -> ShowS
$cshowList :: [RejectDataShare] -> ShowS
show :: RejectDataShare -> String
$cshow :: RejectDataShare -> String
showsPrec :: Int -> RejectDataShare -> ShowS
$cshowsPrec :: Int -> RejectDataShare -> ShowS
Prelude.Show, (forall x. RejectDataShare -> Rep RejectDataShare x)
-> (forall x. Rep RejectDataShare x -> RejectDataShare)
-> Generic RejectDataShare
forall x. Rep RejectDataShare x -> RejectDataShare
forall x. RejectDataShare -> Rep RejectDataShare x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RejectDataShare x -> RejectDataShare
$cfrom :: forall x. RejectDataShare -> Rep RejectDataShare x
Prelude.Generic)

-- |
-- Create a value of 'RejectDataShare' 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', 'rejectDataShare_dataShareArn' - The Amazon Resource Name (ARN) of the datashare to reject.
newRejectDataShare ::
  -- | 'dataShareArn'
  Prelude.Text ->
  RejectDataShare
newRejectDataShare :: Text -> RejectDataShare
newRejectDataShare Text
pDataShareArn_ =
  RejectDataShare' :: Text -> RejectDataShare
RejectDataShare' {$sel:dataShareArn:RejectDataShare' :: Text
dataShareArn = Text
pDataShareArn_}

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

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

instance Prelude.NFData RejectDataShare

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

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

instance Core.ToQuery RejectDataShare where
  toQuery :: RejectDataShare -> QueryString
toQuery RejectDataShare' {Text
dataShareArn :: Text
$sel:dataShareArn:RejectDataShare' :: RejectDataShare -> 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
"RejectDataShare" :: 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
      ]