{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $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 :: Lens' PutDeliveryChannel DeliveryChannel
putDeliveryChannel_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 :: (Service -> Service)
-> PutDeliveryChannel -> Request PutDeliveryChannel
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutDeliveryChannel
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutDeliveryChannel)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull PutDeliveryChannelResponse
PutDeliveryChannelResponse'

instance Prelude.Hashable PutDeliveryChannel where
  hashWithSalt :: Int -> PutDeliveryChannel -> Int
hashWithSalt Int
_salt PutDeliveryChannel' {DeliveryChannel
deliveryChannel :: DeliveryChannel
$sel:deliveryChannel:PutDeliveryChannel' :: PutDeliveryChannel -> DeliveryChannel
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DeliveryChannel
deliveryChannel

instance Prelude.NFData PutDeliveryChannel where
  rnf :: PutDeliveryChannel -> ()
rnf PutDeliveryChannel' {DeliveryChannel
deliveryChannel :: DeliveryChannel
$sel:deliveryChannel:PutDeliveryChannel' :: PutDeliveryChannel -> DeliveryChannel
..} =
    forall a. NFData a => a -> ()
Prelude.rnf DeliveryChannel
deliveryChannel

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

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

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

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

-- | /See:/ 'newPutDeliveryChannelResponse' smart constructor.
data PutDeliveryChannelResponse = PutDeliveryChannelResponse'
  {
  }
  deriving (PutDeliveryChannelResponse -> PutDeliveryChannelResponse -> Bool
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]
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
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.
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 where
  rnf :: PutDeliveryChannelResponse -> ()
rnf PutDeliveryChannelResponse
_ = ()