{-# 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.Lightsail.DeleteDistribution
-- 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 your Amazon Lightsail content delivery network (CDN)
-- distribution.
module Amazonka.Lightsail.DeleteDistribution
  ( -- * Creating a Request
    DeleteDistribution (..),
    newDeleteDistribution,

    -- * Request Lenses
    deleteDistribution_distributionName,

    -- * Destructuring the Response
    DeleteDistributionResponse (..),
    newDeleteDistributionResponse,

    -- * Response Lenses
    deleteDistributionResponse_operation,
    deleteDistributionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteDistribution' smart constructor.
data DeleteDistribution = DeleteDistribution'
  { -- | The name of the distribution to delete.
    --
    -- Use the @GetDistributions@ action to get a list of distribution names
    -- that you can specify.
    DeleteDistribution -> Maybe Text
distributionName :: Prelude.Maybe Prelude.Text
  }
  deriving (DeleteDistribution -> DeleteDistribution -> Bool
(DeleteDistribution -> DeleteDistribution -> Bool)
-> (DeleteDistribution -> DeleteDistribution -> Bool)
-> Eq DeleteDistribution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDistribution -> DeleteDistribution -> Bool
$c/= :: DeleteDistribution -> DeleteDistribution -> Bool
== :: DeleteDistribution -> DeleteDistribution -> Bool
$c== :: DeleteDistribution -> DeleteDistribution -> Bool
Prelude.Eq, ReadPrec [DeleteDistribution]
ReadPrec DeleteDistribution
Int -> ReadS DeleteDistribution
ReadS [DeleteDistribution]
(Int -> ReadS DeleteDistribution)
-> ReadS [DeleteDistribution]
-> ReadPrec DeleteDistribution
-> ReadPrec [DeleteDistribution]
-> Read DeleteDistribution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDistribution]
$creadListPrec :: ReadPrec [DeleteDistribution]
readPrec :: ReadPrec DeleteDistribution
$creadPrec :: ReadPrec DeleteDistribution
readList :: ReadS [DeleteDistribution]
$creadList :: ReadS [DeleteDistribution]
readsPrec :: Int -> ReadS DeleteDistribution
$creadsPrec :: Int -> ReadS DeleteDistribution
Prelude.Read, Int -> DeleteDistribution -> ShowS
[DeleteDistribution] -> ShowS
DeleteDistribution -> String
(Int -> DeleteDistribution -> ShowS)
-> (DeleteDistribution -> String)
-> ([DeleteDistribution] -> ShowS)
-> Show DeleteDistribution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDistribution] -> ShowS
$cshowList :: [DeleteDistribution] -> ShowS
show :: DeleteDistribution -> String
$cshow :: DeleteDistribution -> String
showsPrec :: Int -> DeleteDistribution -> ShowS
$cshowsPrec :: Int -> DeleteDistribution -> ShowS
Prelude.Show, (forall x. DeleteDistribution -> Rep DeleteDistribution x)
-> (forall x. Rep DeleteDistribution x -> DeleteDistribution)
-> Generic DeleteDistribution
forall x. Rep DeleteDistribution x -> DeleteDistribution
forall x. DeleteDistribution -> Rep DeleteDistribution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteDistribution x -> DeleteDistribution
$cfrom :: forall x. DeleteDistribution -> Rep DeleteDistribution x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDistribution' 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:
--
-- 'distributionName', 'deleteDistribution_distributionName' - The name of the distribution to delete.
--
-- Use the @GetDistributions@ action to get a list of distribution names
-- that you can specify.
newDeleteDistribution ::
  DeleteDistribution
newDeleteDistribution :: DeleteDistribution
newDeleteDistribution =
  DeleteDistribution' :: Maybe Text -> DeleteDistribution
DeleteDistribution'
    { $sel:distributionName:DeleteDistribution' :: Maybe Text
distributionName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the distribution to delete.
--
-- Use the @GetDistributions@ action to get a list of distribution names
-- that you can specify.
deleteDistribution_distributionName :: Lens.Lens' DeleteDistribution (Prelude.Maybe Prelude.Text)
deleteDistribution_distributionName :: (Maybe Text -> f (Maybe Text))
-> DeleteDistribution -> f DeleteDistribution
deleteDistribution_distributionName = (DeleteDistribution -> Maybe Text)
-> (DeleteDistribution -> Maybe Text -> DeleteDistribution)
-> Lens
     DeleteDistribution DeleteDistribution (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDistribution' {Maybe Text
distributionName :: Maybe Text
$sel:distributionName:DeleteDistribution' :: DeleteDistribution -> Maybe Text
distributionName} -> Maybe Text
distributionName) (\s :: DeleteDistribution
s@DeleteDistribution' {} Maybe Text
a -> DeleteDistribution
s {$sel:distributionName:DeleteDistribution' :: Maybe Text
distributionName = Maybe Text
a} :: DeleteDistribution)

instance Core.AWSRequest DeleteDistribution where
  type
    AWSResponse DeleteDistribution =
      DeleteDistributionResponse
  request :: DeleteDistribution -> Request DeleteDistribution
request = Service -> DeleteDistribution -> Request DeleteDistribution
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteDistribution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDistribution)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteDistribution))
-> Logger
-> Service
-> Proxy DeleteDistribution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDistribution)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Operation -> Int -> DeleteDistributionResponse
DeleteDistributionResponse'
            (Maybe Operation -> Int -> DeleteDistributionResponse)
-> Either String (Maybe Operation)
-> Either String (Int -> DeleteDistributionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Operation)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"operation")
            Either String (Int -> DeleteDistributionResponse)
-> Either String Int -> Either String DeleteDistributionResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteDistribution

instance Prelude.NFData DeleteDistribution

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

instance Core.ToJSON DeleteDistribution where
  toJSON :: DeleteDistribution -> Value
toJSON DeleteDistribution' {Maybe Text
distributionName :: Maybe Text
$sel:distributionName:DeleteDistribution' :: DeleteDistribution -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"distributionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
distributionName
          ]
      )

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

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

-- | /See:/ 'newDeleteDistributionResponse' smart constructor.
data DeleteDistributionResponse = DeleteDistributionResponse'
  { -- | An object that describes the result of the action, such as the status of
    -- the request, the timestamp of the request, and the resources affected by
    -- the request.
    DeleteDistributionResponse -> Maybe Operation
operation :: Prelude.Maybe Operation,
    -- | The response's http status code.
    DeleteDistributionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteDistributionResponse -> DeleteDistributionResponse -> Bool
(DeleteDistributionResponse -> DeleteDistributionResponse -> Bool)
-> (DeleteDistributionResponse
    -> DeleteDistributionResponse -> Bool)
-> Eq DeleteDistributionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDistributionResponse -> DeleteDistributionResponse -> Bool
$c/= :: DeleteDistributionResponse -> DeleteDistributionResponse -> Bool
== :: DeleteDistributionResponse -> DeleteDistributionResponse -> Bool
$c== :: DeleteDistributionResponse -> DeleteDistributionResponse -> Bool
Prelude.Eq, ReadPrec [DeleteDistributionResponse]
ReadPrec DeleteDistributionResponse
Int -> ReadS DeleteDistributionResponse
ReadS [DeleteDistributionResponse]
(Int -> ReadS DeleteDistributionResponse)
-> ReadS [DeleteDistributionResponse]
-> ReadPrec DeleteDistributionResponse
-> ReadPrec [DeleteDistributionResponse]
-> Read DeleteDistributionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDistributionResponse]
$creadListPrec :: ReadPrec [DeleteDistributionResponse]
readPrec :: ReadPrec DeleteDistributionResponse
$creadPrec :: ReadPrec DeleteDistributionResponse
readList :: ReadS [DeleteDistributionResponse]
$creadList :: ReadS [DeleteDistributionResponse]
readsPrec :: Int -> ReadS DeleteDistributionResponse
$creadsPrec :: Int -> ReadS DeleteDistributionResponse
Prelude.Read, Int -> DeleteDistributionResponse -> ShowS
[DeleteDistributionResponse] -> ShowS
DeleteDistributionResponse -> String
(Int -> DeleteDistributionResponse -> ShowS)
-> (DeleteDistributionResponse -> String)
-> ([DeleteDistributionResponse] -> ShowS)
-> Show DeleteDistributionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDistributionResponse] -> ShowS
$cshowList :: [DeleteDistributionResponse] -> ShowS
show :: DeleteDistributionResponse -> String
$cshow :: DeleteDistributionResponse -> String
showsPrec :: Int -> DeleteDistributionResponse -> ShowS
$cshowsPrec :: Int -> DeleteDistributionResponse -> ShowS
Prelude.Show, (forall x.
 DeleteDistributionResponse -> Rep DeleteDistributionResponse x)
-> (forall x.
    Rep DeleteDistributionResponse x -> DeleteDistributionResponse)
-> Generic DeleteDistributionResponse
forall x.
Rep DeleteDistributionResponse x -> DeleteDistributionResponse
forall x.
DeleteDistributionResponse -> Rep DeleteDistributionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteDistributionResponse x -> DeleteDistributionResponse
$cfrom :: forall x.
DeleteDistributionResponse -> Rep DeleteDistributionResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDistributionResponse' 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:
--
-- 'operation', 'deleteDistributionResponse_operation' - An object that describes the result of the action, such as the status of
-- the request, the timestamp of the request, and the resources affected by
-- the request.
--
-- 'httpStatus', 'deleteDistributionResponse_httpStatus' - The response's http status code.
newDeleteDistributionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteDistributionResponse
newDeleteDistributionResponse :: Int -> DeleteDistributionResponse
newDeleteDistributionResponse Int
pHttpStatus_ =
  DeleteDistributionResponse' :: Maybe Operation -> Int -> DeleteDistributionResponse
DeleteDistributionResponse'
    { $sel:operation:DeleteDistributionResponse' :: Maybe Operation
operation =
        Maybe Operation
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteDistributionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object that describes the result of the action, such as the status of
-- the request, the timestamp of the request, and the resources affected by
-- the request.
deleteDistributionResponse_operation :: Lens.Lens' DeleteDistributionResponse (Prelude.Maybe Operation)
deleteDistributionResponse_operation :: (Maybe Operation -> f (Maybe Operation))
-> DeleteDistributionResponse -> f DeleteDistributionResponse
deleteDistributionResponse_operation = (DeleteDistributionResponse -> Maybe Operation)
-> (DeleteDistributionResponse
    -> Maybe Operation -> DeleteDistributionResponse)
-> Lens
     DeleteDistributionResponse
     DeleteDistributionResponse
     (Maybe Operation)
     (Maybe Operation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDistributionResponse' {Maybe Operation
operation :: Maybe Operation
$sel:operation:DeleteDistributionResponse' :: DeleteDistributionResponse -> Maybe Operation
operation} -> Maybe Operation
operation) (\s :: DeleteDistributionResponse
s@DeleteDistributionResponse' {} Maybe Operation
a -> DeleteDistributionResponse
s {$sel:operation:DeleteDistributionResponse' :: Maybe Operation
operation = Maybe Operation
a} :: DeleteDistributionResponse)

-- | The response's http status code.
deleteDistributionResponse_httpStatus :: Lens.Lens' DeleteDistributionResponse Prelude.Int
deleteDistributionResponse_httpStatus :: (Int -> f Int)
-> DeleteDistributionResponse -> f DeleteDistributionResponse
deleteDistributionResponse_httpStatus = (DeleteDistributionResponse -> Int)
-> (DeleteDistributionResponse
    -> Int -> DeleteDistributionResponse)
-> Lens
     DeleteDistributionResponse DeleteDistributionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDistributionResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteDistributionResponse' :: DeleteDistributionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DeleteDistributionResponse
s@DeleteDistributionResponse' {} Int
a -> DeleteDistributionResponse
s {$sel:httpStatus:DeleteDistributionResponse' :: Int
httpStatus = Int
a} :: DeleteDistributionResponse)

instance Prelude.NFData DeleteDistributionResponse