{-# 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.DeleteLoadBalancer
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a Lightsail load balancer and all its associated SSL\/TLS
-- certificates. Once the load balancer is deleted, you will need to create
-- a new load balancer, create a new certificate, and verify domain
-- ownership again.
--
-- The @delete load balancer@ operation supports tag-based access control
-- via resource tags applied to the resource identified by
-- @load balancer name@. For more information, see the
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-controlling-access-using-tags Amazon Lightsail Developer Guide>.
module Amazonka.Lightsail.DeleteLoadBalancer
  ( -- * Creating a Request
    DeleteLoadBalancer (..),
    newDeleteLoadBalancer,

    -- * Request Lenses
    deleteLoadBalancer_loadBalancerName,

    -- * Destructuring the Response
    DeleteLoadBalancerResponse (..),
    newDeleteLoadBalancerResponse,

    -- * Response Lenses
    deleteLoadBalancerResponse_operations,
    deleteLoadBalancerResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteLoadBalancer' smart constructor.
data DeleteLoadBalancer = DeleteLoadBalancer'
  { -- | The name of the load balancer you want to delete.
    DeleteLoadBalancer -> Text
loadBalancerName :: Prelude.Text
  }
  deriving (DeleteLoadBalancer -> DeleteLoadBalancer -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteLoadBalancer -> DeleteLoadBalancer -> Bool
$c/= :: DeleteLoadBalancer -> DeleteLoadBalancer -> Bool
== :: DeleteLoadBalancer -> DeleteLoadBalancer -> Bool
$c== :: DeleteLoadBalancer -> DeleteLoadBalancer -> Bool
Prelude.Eq, ReadPrec [DeleteLoadBalancer]
ReadPrec DeleteLoadBalancer
Int -> ReadS DeleteLoadBalancer
ReadS [DeleteLoadBalancer]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteLoadBalancer]
$creadListPrec :: ReadPrec [DeleteLoadBalancer]
readPrec :: ReadPrec DeleteLoadBalancer
$creadPrec :: ReadPrec DeleteLoadBalancer
readList :: ReadS [DeleteLoadBalancer]
$creadList :: ReadS [DeleteLoadBalancer]
readsPrec :: Int -> ReadS DeleteLoadBalancer
$creadsPrec :: Int -> ReadS DeleteLoadBalancer
Prelude.Read, Int -> DeleteLoadBalancer -> ShowS
[DeleteLoadBalancer] -> ShowS
DeleteLoadBalancer -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteLoadBalancer] -> ShowS
$cshowList :: [DeleteLoadBalancer] -> ShowS
show :: DeleteLoadBalancer -> String
$cshow :: DeleteLoadBalancer -> String
showsPrec :: Int -> DeleteLoadBalancer -> ShowS
$cshowsPrec :: Int -> DeleteLoadBalancer -> ShowS
Prelude.Show, forall x. Rep DeleteLoadBalancer x -> DeleteLoadBalancer
forall x. DeleteLoadBalancer -> Rep DeleteLoadBalancer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteLoadBalancer x -> DeleteLoadBalancer
$cfrom :: forall x. DeleteLoadBalancer -> Rep DeleteLoadBalancer x
Prelude.Generic)

-- |
-- Create a value of 'DeleteLoadBalancer' 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:
--
-- 'loadBalancerName', 'deleteLoadBalancer_loadBalancerName' - The name of the load balancer you want to delete.
newDeleteLoadBalancer ::
  -- | 'loadBalancerName'
  Prelude.Text ->
  DeleteLoadBalancer
newDeleteLoadBalancer :: Text -> DeleteLoadBalancer
newDeleteLoadBalancer Text
pLoadBalancerName_ =
  DeleteLoadBalancer'
    { $sel:loadBalancerName:DeleteLoadBalancer' :: Text
loadBalancerName =
        Text
pLoadBalancerName_
    }

-- | The name of the load balancer you want to delete.
deleteLoadBalancer_loadBalancerName :: Lens.Lens' DeleteLoadBalancer Prelude.Text
deleteLoadBalancer_loadBalancerName :: Lens' DeleteLoadBalancer Text
deleteLoadBalancer_loadBalancerName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteLoadBalancer' {Text
loadBalancerName :: Text
$sel:loadBalancerName:DeleteLoadBalancer' :: DeleteLoadBalancer -> Text
loadBalancerName} -> Text
loadBalancerName) (\s :: DeleteLoadBalancer
s@DeleteLoadBalancer' {} Text
a -> DeleteLoadBalancer
s {$sel:loadBalancerName:DeleteLoadBalancer' :: Text
loadBalancerName = Text
a} :: DeleteLoadBalancer)

instance Core.AWSRequest DeleteLoadBalancer where
  type
    AWSResponse DeleteLoadBalancer =
      DeleteLoadBalancerResponse
  request :: (Service -> Service)
-> DeleteLoadBalancer -> Request DeleteLoadBalancer
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 DeleteLoadBalancer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteLoadBalancer)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Operation] -> Int -> DeleteLoadBalancerResponse
DeleteLoadBalancerResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"operations" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteLoadBalancer where
  hashWithSalt :: Int -> DeleteLoadBalancer -> Int
hashWithSalt Int
_salt DeleteLoadBalancer' {Text
loadBalancerName :: Text
$sel:loadBalancerName:DeleteLoadBalancer' :: DeleteLoadBalancer -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
loadBalancerName

instance Prelude.NFData DeleteLoadBalancer where
  rnf :: DeleteLoadBalancer -> ()
rnf DeleteLoadBalancer' {Text
loadBalancerName :: Text
$sel:loadBalancerName:DeleteLoadBalancer' :: DeleteLoadBalancer -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
loadBalancerName

instance Data.ToHeaders DeleteLoadBalancer where
  toHeaders :: DeleteLoadBalancer -> ResponseHeaders
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 -> ResponseHeaders
Data.=# ( ByteString
"Lightsail_20161128.DeleteLoadBalancer" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

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

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

-- |
-- Create a value of 'DeleteLoadBalancerResponse' 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:
--
-- 'operations', 'deleteLoadBalancerResponse_operations' - An array of objects that describe 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', 'deleteLoadBalancerResponse_httpStatus' - The response's http status code.
newDeleteLoadBalancerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteLoadBalancerResponse
newDeleteLoadBalancerResponse :: Int -> DeleteLoadBalancerResponse
newDeleteLoadBalancerResponse Int
pHttpStatus_ =
  DeleteLoadBalancerResponse'
    { $sel:operations:DeleteLoadBalancerResponse' :: Maybe [Operation]
operations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteLoadBalancerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
deleteLoadBalancerResponse_operations :: Lens.Lens' DeleteLoadBalancerResponse (Prelude.Maybe [Operation])
deleteLoadBalancerResponse_operations :: Lens' DeleteLoadBalancerResponse (Maybe [Operation])
deleteLoadBalancerResponse_operations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteLoadBalancerResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:DeleteLoadBalancerResponse' :: DeleteLoadBalancerResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: DeleteLoadBalancerResponse
s@DeleteLoadBalancerResponse' {} Maybe [Operation]
a -> DeleteLoadBalancerResponse
s {$sel:operations:DeleteLoadBalancerResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: DeleteLoadBalancerResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DeleteLoadBalancerResponse where
  rnf :: DeleteLoadBalancerResponse -> ()
rnf DeleteLoadBalancerResponse' {Int
Maybe [Operation]
httpStatus :: Int
operations :: Maybe [Operation]
$sel:httpStatus:DeleteLoadBalancerResponse' :: DeleteLoadBalancerResponse -> Int
$sel:operations:DeleteLoadBalancerResponse' :: DeleteLoadBalancerResponse -> Maybe [Operation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Operation]
operations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus