{-# 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.CloudFront.DeleteStreamingDistribution
-- 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)
--
-- Delete a streaming distribution. To delete an RTMP distribution using
-- the CloudFront API, perform the following steps.
--
-- __To delete an RTMP distribution using the CloudFront API__:
--
-- 1.  Disable the RTMP distribution.
--
-- 2.  Submit a @GET Streaming Distribution Config@ request to get the
--     current configuration and the @Etag@ header for the distribution.
--
-- 3.  Update the XML document that was returned in the response to your
--     @GET Streaming Distribution Config@ request to change the value of
--     @Enabled@ to @false@.
--
-- 4.  Submit a @PUT Streaming Distribution Config@ request to update the
--     configuration for your distribution. In the request body, include
--     the XML document that you updated in Step 3. Then set the value of
--     the HTTP @If-Match@ header to the value of the @ETag@ header that
--     CloudFront returned when you submitted the
--     @GET Streaming Distribution Config@ request in Step 2.
--
-- 5.  Review the response to the @PUT Streaming Distribution Config@
--     request to confirm that the distribution was successfully disabled.
--
-- 6.  Submit a @GET Streaming Distribution Config@ request to confirm that
--     your changes have propagated. When propagation is complete, the
--     value of @Status@ is @Deployed@.
--
-- 7.  Submit a @DELETE Streaming Distribution@ request. Set the value of
--     the HTTP @If-Match@ header to the value of the @ETag@ header that
--     CloudFront returned when you submitted the
--     @GET Streaming Distribution Config@ request in Step 2.
--
-- 8.  Review the response to your @DELETE Streaming Distribution@ request
--     to confirm that the distribution was successfully deleted.
--
-- For information about deleting a distribution using the CloudFront
-- console, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/HowToDeleteDistribution.html Deleting a Distribution>
-- in the /Amazon CloudFront Developer Guide/.
module Amazonka.CloudFront.DeleteStreamingDistribution
  ( -- * Creating a Request
    DeleteStreamingDistribution (..),
    newDeleteStreamingDistribution,

    -- * Request Lenses
    deleteStreamingDistribution_ifMatch,
    deleteStreamingDistribution_id,

    -- * Destructuring the Response
    DeleteStreamingDistributionResponse (..),
    newDeleteStreamingDistributionResponse,
  )
where

import Amazonka.CloudFront.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 request to delete a streaming distribution.
--
-- /See:/ 'newDeleteStreamingDistribution' smart constructor.
data DeleteStreamingDistribution = DeleteStreamingDistribution'
  { -- | The value of the @ETag@ header that you received when you disabled the
    -- streaming distribution. For example: @E2QWRUHAPOMQZL@.
    DeleteStreamingDistribution -> Maybe Text
ifMatch :: Prelude.Maybe Prelude.Text,
    -- | The distribution ID.
    DeleteStreamingDistribution -> Text
id :: Prelude.Text
  }
  deriving (DeleteStreamingDistribution -> DeleteStreamingDistribution -> Bool
(DeleteStreamingDistribution
 -> DeleteStreamingDistribution -> Bool)
-> (DeleteStreamingDistribution
    -> DeleteStreamingDistribution -> Bool)
-> Eq DeleteStreamingDistribution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteStreamingDistribution -> DeleteStreamingDistribution -> Bool
$c/= :: DeleteStreamingDistribution -> DeleteStreamingDistribution -> Bool
== :: DeleteStreamingDistribution -> DeleteStreamingDistribution -> Bool
$c== :: DeleteStreamingDistribution -> DeleteStreamingDistribution -> Bool
Prelude.Eq, ReadPrec [DeleteStreamingDistribution]
ReadPrec DeleteStreamingDistribution
Int -> ReadS DeleteStreamingDistribution
ReadS [DeleteStreamingDistribution]
(Int -> ReadS DeleteStreamingDistribution)
-> ReadS [DeleteStreamingDistribution]
-> ReadPrec DeleteStreamingDistribution
-> ReadPrec [DeleteStreamingDistribution]
-> Read DeleteStreamingDistribution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteStreamingDistribution]
$creadListPrec :: ReadPrec [DeleteStreamingDistribution]
readPrec :: ReadPrec DeleteStreamingDistribution
$creadPrec :: ReadPrec DeleteStreamingDistribution
readList :: ReadS [DeleteStreamingDistribution]
$creadList :: ReadS [DeleteStreamingDistribution]
readsPrec :: Int -> ReadS DeleteStreamingDistribution
$creadsPrec :: Int -> ReadS DeleteStreamingDistribution
Prelude.Read, Int -> DeleteStreamingDistribution -> ShowS
[DeleteStreamingDistribution] -> ShowS
DeleteStreamingDistribution -> String
(Int -> DeleteStreamingDistribution -> ShowS)
-> (DeleteStreamingDistribution -> String)
-> ([DeleteStreamingDistribution] -> ShowS)
-> Show DeleteStreamingDistribution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteStreamingDistribution] -> ShowS
$cshowList :: [DeleteStreamingDistribution] -> ShowS
show :: DeleteStreamingDistribution -> String
$cshow :: DeleteStreamingDistribution -> String
showsPrec :: Int -> DeleteStreamingDistribution -> ShowS
$cshowsPrec :: Int -> DeleteStreamingDistribution -> ShowS
Prelude.Show, (forall x.
 DeleteStreamingDistribution -> Rep DeleteStreamingDistribution x)
-> (forall x.
    Rep DeleteStreamingDistribution x -> DeleteStreamingDistribution)
-> Generic DeleteStreamingDistribution
forall x.
Rep DeleteStreamingDistribution x -> DeleteStreamingDistribution
forall x.
DeleteStreamingDistribution -> Rep DeleteStreamingDistribution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteStreamingDistribution x -> DeleteStreamingDistribution
$cfrom :: forall x.
DeleteStreamingDistribution -> Rep DeleteStreamingDistribution x
Prelude.Generic)

-- |
-- Create a value of 'DeleteStreamingDistribution' 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:
--
-- 'ifMatch', 'deleteStreamingDistribution_ifMatch' - The value of the @ETag@ header that you received when you disabled the
-- streaming distribution. For example: @E2QWRUHAPOMQZL@.
--
-- 'id', 'deleteStreamingDistribution_id' - The distribution ID.
newDeleteStreamingDistribution ::
  -- | 'id'
  Prelude.Text ->
  DeleteStreamingDistribution
newDeleteStreamingDistribution :: Text -> DeleteStreamingDistribution
newDeleteStreamingDistribution Text
pId_ =
  DeleteStreamingDistribution' :: Maybe Text -> Text -> DeleteStreamingDistribution
DeleteStreamingDistribution'
    { $sel:ifMatch:DeleteStreamingDistribution' :: Maybe Text
ifMatch =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:DeleteStreamingDistribution' :: Text
id = Text
pId_
    }

-- | The value of the @ETag@ header that you received when you disabled the
-- streaming distribution. For example: @E2QWRUHAPOMQZL@.
deleteStreamingDistribution_ifMatch :: Lens.Lens' DeleteStreamingDistribution (Prelude.Maybe Prelude.Text)
deleteStreamingDistribution_ifMatch :: (Maybe Text -> f (Maybe Text))
-> DeleteStreamingDistribution -> f DeleteStreamingDistribution
deleteStreamingDistribution_ifMatch = (DeleteStreamingDistribution -> Maybe Text)
-> (DeleteStreamingDistribution
    -> Maybe Text -> DeleteStreamingDistribution)
-> Lens
     DeleteStreamingDistribution
     DeleteStreamingDistribution
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteStreamingDistribution' {Maybe Text
ifMatch :: Maybe Text
$sel:ifMatch:DeleteStreamingDistribution' :: DeleteStreamingDistribution -> Maybe Text
ifMatch} -> Maybe Text
ifMatch) (\s :: DeleteStreamingDistribution
s@DeleteStreamingDistribution' {} Maybe Text
a -> DeleteStreamingDistribution
s {$sel:ifMatch:DeleteStreamingDistribution' :: Maybe Text
ifMatch = Maybe Text
a} :: DeleteStreamingDistribution)

-- | The distribution ID.
deleteStreamingDistribution_id :: Lens.Lens' DeleteStreamingDistribution Prelude.Text
deleteStreamingDistribution_id :: (Text -> f Text)
-> DeleteStreamingDistribution -> f DeleteStreamingDistribution
deleteStreamingDistribution_id = (DeleteStreamingDistribution -> Text)
-> (DeleteStreamingDistribution
    -> Text -> DeleteStreamingDistribution)
-> Lens
     DeleteStreamingDistribution DeleteStreamingDistribution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteStreamingDistribution' {Text
id :: Text
$sel:id:DeleteStreamingDistribution' :: DeleteStreamingDistribution -> Text
id} -> Text
id) (\s :: DeleteStreamingDistribution
s@DeleteStreamingDistribution' {} Text
a -> DeleteStreamingDistribution
s {$sel:id:DeleteStreamingDistribution' :: Text
id = Text
a} :: DeleteStreamingDistribution)

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

instance Prelude.Hashable DeleteStreamingDistribution

instance Prelude.NFData DeleteStreamingDistribution

instance Core.ToHeaders DeleteStreamingDistribution where
  toHeaders :: DeleteStreamingDistribution -> [Header]
toHeaders DeleteStreamingDistribution' {Maybe Text
Text
id :: Text
ifMatch :: Maybe Text
$sel:id:DeleteStreamingDistribution' :: DeleteStreamingDistribution -> Text
$sel:ifMatch:DeleteStreamingDistribution' :: DeleteStreamingDistribution -> Maybe Text
..} =
    [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat [HeaderName
"If-Match" HeaderName -> Maybe Text -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Maybe Text
ifMatch]

instance Core.ToPath DeleteStreamingDistribution where
  toPath :: DeleteStreamingDistribution -> ByteString
toPath DeleteStreamingDistribution' {Maybe Text
Text
id :: Text
ifMatch :: Maybe Text
$sel:id:DeleteStreamingDistribution' :: DeleteStreamingDistribution -> Text
$sel:ifMatch:DeleteStreamingDistribution' :: DeleteStreamingDistribution -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2020-05-31/streaming-distribution/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id]

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

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

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

instance
  Prelude.NFData
    DeleteStreamingDistributionResponse