{-# 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.AddPartner
-- 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)
--
-- Adds a partner integration to a cluster. This operation authorizes a
-- partner to push status updates for the specified database. To complete
-- the integration, you also set up the integration on the partner website.
module Amazonka.Redshift.AddPartner
  ( -- * Creating a Request
    AddPartner (..),
    newAddPartner,

    -- * Request Lenses
    addPartner_accountId,
    addPartner_clusterIdentifier,
    addPartner_databaseName,
    addPartner_partnerName,

    -- * Destructuring the Response
    PartnerIntegrationOutputMessage (..),
    newPartnerIntegrationOutputMessage,

    -- * Response Lenses
    partnerIntegrationOutputMessage_partnerName,
    partnerIntegrationOutputMessage_databaseName,
  )
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:/ 'newAddPartner' smart constructor.
data AddPartner = AddPartner'
  { -- | The Amazon Web Services account ID that owns the cluster.
    AddPartner -> Text
accountId :: Prelude.Text,
    -- | The cluster identifier of the cluster that receives data from the
    -- partner.
    AddPartner -> Text
clusterIdentifier :: Prelude.Text,
    -- | The name of the database that receives data from the partner.
    AddPartner -> Text
databaseName :: Prelude.Text,
    -- | The name of the partner that is authorized to send data.
    AddPartner -> Text
partnerName :: Prelude.Text
  }
  deriving (AddPartner -> AddPartner -> Bool
(AddPartner -> AddPartner -> Bool)
-> (AddPartner -> AddPartner -> Bool) -> Eq AddPartner
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddPartner -> AddPartner -> Bool
$c/= :: AddPartner -> AddPartner -> Bool
== :: AddPartner -> AddPartner -> Bool
$c== :: AddPartner -> AddPartner -> Bool
Prelude.Eq, ReadPrec [AddPartner]
ReadPrec AddPartner
Int -> ReadS AddPartner
ReadS [AddPartner]
(Int -> ReadS AddPartner)
-> ReadS [AddPartner]
-> ReadPrec AddPartner
-> ReadPrec [AddPartner]
-> Read AddPartner
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddPartner]
$creadListPrec :: ReadPrec [AddPartner]
readPrec :: ReadPrec AddPartner
$creadPrec :: ReadPrec AddPartner
readList :: ReadS [AddPartner]
$creadList :: ReadS [AddPartner]
readsPrec :: Int -> ReadS AddPartner
$creadsPrec :: Int -> ReadS AddPartner
Prelude.Read, Int -> AddPartner -> ShowS
[AddPartner] -> ShowS
AddPartner -> String
(Int -> AddPartner -> ShowS)
-> (AddPartner -> String)
-> ([AddPartner] -> ShowS)
-> Show AddPartner
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddPartner] -> ShowS
$cshowList :: [AddPartner] -> ShowS
show :: AddPartner -> String
$cshow :: AddPartner -> String
showsPrec :: Int -> AddPartner -> ShowS
$cshowsPrec :: Int -> AddPartner -> ShowS
Prelude.Show, (forall x. AddPartner -> Rep AddPartner x)
-> (forall x. Rep AddPartner x -> AddPartner) -> Generic AddPartner
forall x. Rep AddPartner x -> AddPartner
forall x. AddPartner -> Rep AddPartner x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddPartner x -> AddPartner
$cfrom :: forall x. AddPartner -> Rep AddPartner x
Prelude.Generic)

-- |
-- Create a value of 'AddPartner' 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:
--
-- 'accountId', 'addPartner_accountId' - The Amazon Web Services account ID that owns the cluster.
--
-- 'clusterIdentifier', 'addPartner_clusterIdentifier' - The cluster identifier of the cluster that receives data from the
-- partner.
--
-- 'databaseName', 'addPartner_databaseName' - The name of the database that receives data from the partner.
--
-- 'partnerName', 'addPartner_partnerName' - The name of the partner that is authorized to send data.
newAddPartner ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'clusterIdentifier'
  Prelude.Text ->
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'partnerName'
  Prelude.Text ->
  AddPartner
newAddPartner :: Text -> Text -> Text -> Text -> AddPartner
newAddPartner
  Text
pAccountId_
  Text
pClusterIdentifier_
  Text
pDatabaseName_
  Text
pPartnerName_ =
    AddPartner' :: Text -> Text -> Text -> Text -> AddPartner
AddPartner'
      { $sel:accountId:AddPartner' :: Text
accountId = Text
pAccountId_,
        $sel:clusterIdentifier:AddPartner' :: Text
clusterIdentifier = Text
pClusterIdentifier_,
        $sel:databaseName:AddPartner' :: Text
databaseName = Text
pDatabaseName_,
        $sel:partnerName:AddPartner' :: Text
partnerName = Text
pPartnerName_
      }

-- | The Amazon Web Services account ID that owns the cluster.
addPartner_accountId :: Lens.Lens' AddPartner Prelude.Text
addPartner_accountId :: (Text -> f Text) -> AddPartner -> f AddPartner
addPartner_accountId = (AddPartner -> Text)
-> (AddPartner -> Text -> AddPartner)
-> Lens AddPartner AddPartner Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddPartner' {Text
accountId :: Text
$sel:accountId:AddPartner' :: AddPartner -> Text
accountId} -> Text
accountId) (\s :: AddPartner
s@AddPartner' {} Text
a -> AddPartner
s {$sel:accountId:AddPartner' :: Text
accountId = Text
a} :: AddPartner)

-- | The cluster identifier of the cluster that receives data from the
-- partner.
addPartner_clusterIdentifier :: Lens.Lens' AddPartner Prelude.Text
addPartner_clusterIdentifier :: (Text -> f Text) -> AddPartner -> f AddPartner
addPartner_clusterIdentifier = (AddPartner -> Text)
-> (AddPartner -> Text -> AddPartner)
-> Lens AddPartner AddPartner Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddPartner' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:AddPartner' :: AddPartner -> Text
clusterIdentifier} -> Text
clusterIdentifier) (\s :: AddPartner
s@AddPartner' {} Text
a -> AddPartner
s {$sel:clusterIdentifier:AddPartner' :: Text
clusterIdentifier = Text
a} :: AddPartner)

-- | The name of the database that receives data from the partner.
addPartner_databaseName :: Lens.Lens' AddPartner Prelude.Text
addPartner_databaseName :: (Text -> f Text) -> AddPartner -> f AddPartner
addPartner_databaseName = (AddPartner -> Text)
-> (AddPartner -> Text -> AddPartner)
-> Lens AddPartner AddPartner Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddPartner' {Text
databaseName :: Text
$sel:databaseName:AddPartner' :: AddPartner -> Text
databaseName} -> Text
databaseName) (\s :: AddPartner
s@AddPartner' {} Text
a -> AddPartner
s {$sel:databaseName:AddPartner' :: Text
databaseName = Text
a} :: AddPartner)

-- | The name of the partner that is authorized to send data.
addPartner_partnerName :: Lens.Lens' AddPartner Prelude.Text
addPartner_partnerName :: (Text -> f Text) -> AddPartner -> f AddPartner
addPartner_partnerName = (AddPartner -> Text)
-> (AddPartner -> Text -> AddPartner)
-> Lens AddPartner AddPartner Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddPartner' {Text
partnerName :: Text
$sel:partnerName:AddPartner' :: AddPartner -> Text
partnerName} -> Text
partnerName) (\s :: AddPartner
s@AddPartner' {} Text
a -> AddPartner
s {$sel:partnerName:AddPartner' :: Text
partnerName = Text
a} :: AddPartner)

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

instance Prelude.Hashable AddPartner

instance Prelude.NFData AddPartner

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

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

instance Core.ToQuery AddPartner where
  toQuery :: AddPartner -> QueryString
toQuery AddPartner' {Text
partnerName :: Text
databaseName :: Text
clusterIdentifier :: Text
accountId :: Text
$sel:partnerName:AddPartner' :: AddPartner -> Text
$sel:databaseName:AddPartner' :: AddPartner -> Text
$sel:clusterIdentifier:AddPartner' :: AddPartner -> Text
$sel:accountId:AddPartner' :: AddPartner -> 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
"AddPartner" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"AccountId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
accountId,
        ByteString
"ClusterIdentifier" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
clusterIdentifier,
        ByteString
"DatabaseName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
databaseName,
        ByteString
"PartnerName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
partnerName
      ]