{-# 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.Config.PutDeliveryChannel
-- 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)
--
-- Creates a delivery channel object to deliver configuration information
-- to an Amazon S3 bucket and Amazon SNS topic.
--
-- Before you can create a delivery channel, you must create a
-- configuration recorder.
--
-- You can use this action to change the Amazon S3 bucket or an Amazon SNS
-- topic of the existing delivery channel. To change the Amazon S3 bucket
-- or an Amazon SNS topic, call this action and specify the changed values
-- for the S3 bucket and the SNS topic. If you specify a different value
-- for either the S3 bucket or the SNS topic, this action will keep the
-- existing value for the parameter that is not changed.
--
-- You can have only one delivery channel per region in your account.
module Amazonka.Config.PutDeliveryChannel
  ( -- * Creating a Request
    PutDeliveryChannel (..),
    newPutDeliveryChannel,

    -- * Request Lenses
    putDeliveryChannel_deliveryChannel,

    -- * Destructuring the Response
    PutDeliveryChannelResponse (..),
    newPutDeliveryChannelResponse,
  )
where

import Amazonka.Config.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | The input for the PutDeliveryChannel action.
--
-- /See:/ 'newPutDeliveryChannel' smart constructor.
data PutDeliveryChannel = PutDeliveryChannel'
  { -- | The configuration delivery channel object that delivers the
    -- configuration information to an Amazon S3 bucket and to an Amazon SNS
    -- topic.
    PutDeliveryChannel -> DeliveryChannel
deliveryChannel :: DeliveryChannel
  }
  deriving (PutDeliveryChannel -> PutDeliveryChannel -> Bool
(PutDeliveryChannel -> PutDeliveryChannel -> Bool)
-> (PutDeliveryChannel -> PutDeliveryChannel -> Bool)
-> Eq PutDeliveryChannel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutDeliveryChannel -> PutDeliveryChannel -> Bool
$c/= :: PutDeliveryChannel -> PutDeliveryChannel -> Bool
== :: PutDeliveryChannel -> PutDeliveryChannel -> Bool
$c== :: PutDeliveryChannel -> PutDeliveryChannel -> Bool
Prelude.Eq, ReadPrec [PutDeliveryChannel]
ReadPrec PutDeliveryChannel
Int -> ReadS PutDeliveryChannel
ReadS [PutDeliveryChannel]
(Int -> ReadS PutDeliveryChannel)
-> ReadS [PutDeliveryChannel]
-> ReadPrec PutDeliveryChannel
-> ReadPrec [PutDeliveryChannel]
-> Read PutDeliveryChannel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutDeliveryChannel]
$creadListPrec :: ReadPrec [PutDeliveryChannel]
readPrec :: ReadPrec PutDeliveryChannel
$creadPrec :: ReadPrec PutDeliveryChannel
readList :: ReadS [PutDeliveryChannel]
$creadList :: ReadS [PutDeliveryChannel]
readsPrec :: Int -> ReadS PutDeliveryChannel
$creadsPrec :: Int -> ReadS PutDeliveryChannel
Prelude.Read, Int -> PutDeliveryChannel -> ShowS
[PutDeliveryChannel] -> ShowS
PutDeliveryChannel -> String
(Int -> PutDeliveryChannel -> ShowS)
-> (PutDeliveryChannel -> String)
-> ([PutDeliveryChannel] -> ShowS)
-> Show PutDeliveryChannel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutDeliveryChannel] -> ShowS
$cshowList :: [PutDeliveryChannel] -> ShowS
show :: PutDeliveryChannel -> String
$cshow :: PutDeliveryChannel -> String
showsPrec :: Int -> PutDeliveryChannel -> ShowS
$cshowsPrec :: Int -> PutDeliveryChannel -> ShowS
Prelude.Show, (forall x. PutDeliveryChannel -> Rep PutDeliveryChannel x)
-> (forall x. Rep PutDeliveryChannel x -> PutDeliveryChannel)
-> Generic PutDeliveryChannel
forall x. Rep PutDeliveryChannel x -> PutDeliveryChannel
forall x. PutDeliveryChannel -> Rep PutDeliveryChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutDeliveryChannel x -> PutDeliveryChannel
$cfrom :: forall x. PutDeliveryChannel -> Rep PutDeliveryChannel x
Prelude.Generic)

-- |
-- Create a value of 'PutDeliveryChannel' 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:
--
-- 'deliveryChannel', 'putDeliveryChannel_deliveryChannel' - The configuration delivery channel object that delivers the
-- configuration information to an Amazon S3 bucket and to an Amazon SNS
-- topic.
newPutDeliveryChannel ::
  -- | 'deliveryChannel'
  DeliveryChannel ->
  PutDeliveryChannel
newPutDeliveryChannel :: DeliveryChannel -> PutDeliveryChannel
newPutDeliveryChannel DeliveryChannel
pDeliveryChannel_ =
  PutDeliveryChannel' :: DeliveryChannel -> PutDeliveryChannel
PutDeliveryChannel'
    { $sel:deliveryChannel:PutDeliveryChannel' :: DeliveryChannel
deliveryChannel =
        DeliveryChannel
pDeliveryChannel_
    }

-- | The configuration delivery channel object that delivers the
-- configuration information to an Amazon S3 bucket and to an Amazon SNS
-- topic.
putDeliveryChannel_deliveryChannel :: Lens.Lens' PutDeliveryChannel DeliveryChannel
putDeliveryChannel_deliveryChannel :: (DeliveryChannel -> f DeliveryChannel)
-> PutDeliveryChannel -> f PutDeliveryChannel
putDeliveryChannel_deliveryChannel = (PutDeliveryChannel -> DeliveryChannel)
-> (PutDeliveryChannel -> DeliveryChannel -> PutDeliveryChannel)
-> Lens
     PutDeliveryChannel
     PutDeliveryChannel
     DeliveryChannel
     DeliveryChannel
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutDeliveryChannel' {DeliveryChannel
deliveryChannel :: DeliveryChannel
$sel:deliveryChannel:PutDeliveryChannel' :: PutDeliveryChannel -> DeliveryChannel
deliveryChannel} -> DeliveryChannel
deliveryChannel) (\s :: PutDeliveryChannel
s@PutDeliveryChannel' {} DeliveryChannel
a -> PutDeliveryChannel
s {$sel:deliveryChannel:PutDeliveryChannel' :: DeliveryChannel
deliveryChannel = DeliveryChannel
a} :: PutDeliveryChannel)

instance Core.AWSRequest PutDeliveryChannel where
  type
    AWSResponse PutDeliveryChannel =
      PutDeliveryChannelResponse
  request :: PutDeliveryChannel -> Request PutDeliveryChannel
request = Service -> PutDeliveryChannel -> Request PutDeliveryChannel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutDeliveryChannel
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutDeliveryChannel)))
response =
    AWSResponse PutDeliveryChannel
-> Logger
-> Service
-> Proxy PutDeliveryChannel
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutDeliveryChannel)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse PutDeliveryChannel
PutDeliveryChannelResponse
PutDeliveryChannelResponse'

instance Prelude.Hashable PutDeliveryChannel

instance Prelude.NFData PutDeliveryChannel

instance Core.ToHeaders PutDeliveryChannel where
  toHeaders :: PutDeliveryChannel -> [Header]
toHeaders =
    [Header] -> PutDeliveryChannel -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"StarlingDoveService.PutDeliveryChannel" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON PutDeliveryChannel where
  toJSON :: PutDeliveryChannel -> Value
toJSON PutDeliveryChannel' {DeliveryChannel
deliveryChannel :: DeliveryChannel
$sel:deliveryChannel:PutDeliveryChannel' :: PutDeliveryChannel -> DeliveryChannel
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"DeliveryChannel" Text -> DeliveryChannel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DeliveryChannel
deliveryChannel)
          ]
      )

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

instance Core.ToQuery PutDeliveryChannel where
  toQuery :: PutDeliveryChannel -> QueryString
toQuery = QueryString -> PutDeliveryChannel -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newPutDeliveryChannelResponse' smart constructor.
data PutDeliveryChannelResponse = PutDeliveryChannelResponse'
  {
  }
  deriving (PutDeliveryChannelResponse -> PutDeliveryChannelResponse -> Bool
(PutDeliveryChannelResponse -> PutDeliveryChannelResponse -> Bool)
-> (PutDeliveryChannelResponse
    -> PutDeliveryChannelResponse -> Bool)
-> Eq PutDeliveryChannelResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutDeliveryChannelResponse -> PutDeliveryChannelResponse -> Bool
$c/= :: PutDeliveryChannelResponse -> PutDeliveryChannelResponse -> Bool
== :: PutDeliveryChannelResponse -> PutDeliveryChannelResponse -> Bool
$c== :: PutDeliveryChannelResponse -> PutDeliveryChannelResponse -> Bool
Prelude.Eq, ReadPrec [PutDeliveryChannelResponse]
ReadPrec PutDeliveryChannelResponse
Int -> ReadS PutDeliveryChannelResponse
ReadS [PutDeliveryChannelResponse]
(Int -> ReadS PutDeliveryChannelResponse)
-> ReadS [PutDeliveryChannelResponse]
-> ReadPrec PutDeliveryChannelResponse
-> ReadPrec [PutDeliveryChannelResponse]
-> Read PutDeliveryChannelResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutDeliveryChannelResponse]
$creadListPrec :: ReadPrec [PutDeliveryChannelResponse]
readPrec :: ReadPrec PutDeliveryChannelResponse
$creadPrec :: ReadPrec PutDeliveryChannelResponse
readList :: ReadS [PutDeliveryChannelResponse]
$creadList :: ReadS [PutDeliveryChannelResponse]
readsPrec :: Int -> ReadS PutDeliveryChannelResponse
$creadsPrec :: Int -> ReadS PutDeliveryChannelResponse
Prelude.Read, Int -> PutDeliveryChannelResponse -> ShowS
[PutDeliveryChannelResponse] -> ShowS
PutDeliveryChannelResponse -> String
(Int -> PutDeliveryChannelResponse -> ShowS)
-> (PutDeliveryChannelResponse -> String)
-> ([PutDeliveryChannelResponse] -> ShowS)
-> Show PutDeliveryChannelResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutDeliveryChannelResponse] -> ShowS
$cshowList :: [PutDeliveryChannelResponse] -> ShowS
show :: PutDeliveryChannelResponse -> String
$cshow :: PutDeliveryChannelResponse -> String
showsPrec :: Int -> PutDeliveryChannelResponse -> ShowS
$cshowsPrec :: Int -> PutDeliveryChannelResponse -> ShowS
Prelude.Show, (forall x.
 PutDeliveryChannelResponse -> Rep PutDeliveryChannelResponse x)
-> (forall x.
    Rep PutDeliveryChannelResponse x -> PutDeliveryChannelResponse)
-> Generic PutDeliveryChannelResponse
forall x.
Rep PutDeliveryChannelResponse x -> PutDeliveryChannelResponse
forall x.
PutDeliveryChannelResponse -> Rep PutDeliveryChannelResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutDeliveryChannelResponse x -> PutDeliveryChannelResponse
$cfrom :: forall x.
PutDeliveryChannelResponse -> Rep PutDeliveryChannelResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutDeliveryChannelResponse' 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.
newPutDeliveryChannelResponse ::
  PutDeliveryChannelResponse
newPutDeliveryChannelResponse :: PutDeliveryChannelResponse
newPutDeliveryChannelResponse =
  PutDeliveryChannelResponse
PutDeliveryChannelResponse'

instance Prelude.NFData PutDeliveryChannelResponse