{-# 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.DeletePartner
-- 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)
--
-- Deletes a partner integration from a cluster. Data can still flow to the
-- cluster until the integration is deleted at the partner\'s website.
module Amazonka.Redshift.DeletePartner
  ( -- * Creating a Request
    DeletePartner (..),
    newDeletePartner,

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

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

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

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

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

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

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

instance Prelude.NFData DeletePartner

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

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

instance Core.ToQuery DeletePartner where
  toQuery :: DeletePartner -> QueryString
toQuery DeletePartner' {Text
partnerName :: Text
databaseName :: Text
clusterIdentifier :: Text
accountId :: Text
$sel:partnerName:DeletePartner' :: DeletePartner -> Text
$sel:databaseName:DeletePartner' :: DeletePartner -> Text
$sel:clusterIdentifier:DeletePartner' :: DeletePartner -> Text
$sel:accountId:DeletePartner' :: DeletePartner -> 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
"DeletePartner" :: 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
      ]