{-# 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-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 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.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:/ '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
(DeleteLoadBalancer -> DeleteLoadBalancer -> Bool)
-> (DeleteLoadBalancer -> DeleteLoadBalancer -> Bool)
-> Eq DeleteLoadBalancer
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]
(Int -> ReadS DeleteLoadBalancer)
-> ReadS [DeleteLoadBalancer]
-> ReadPrec DeleteLoadBalancer
-> ReadPrec [DeleteLoadBalancer]
-> Read 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
(Int -> DeleteLoadBalancer -> ShowS)
-> (DeleteLoadBalancer -> String)
-> ([DeleteLoadBalancer] -> ShowS)
-> Show DeleteLoadBalancer
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. DeleteLoadBalancer -> Rep DeleteLoadBalancer x)
-> (forall x. Rep DeleteLoadBalancer x -> DeleteLoadBalancer)
-> Generic DeleteLoadBalancer
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' :: Text -> DeleteLoadBalancer
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 :: (Text -> f Text) -> DeleteLoadBalancer -> f DeleteLoadBalancer
deleteLoadBalancer_loadBalancerName = (DeleteLoadBalancer -> Text)
-> (DeleteLoadBalancer -> Text -> DeleteLoadBalancer)
-> Lens DeleteLoadBalancer DeleteLoadBalancer Text Text
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 :: DeleteLoadBalancer -> Request DeleteLoadBalancer
request = Service -> DeleteLoadBalancer -> Request DeleteLoadBalancer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteLoadBalancer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteLoadBalancer)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteLoadBalancer))
-> Logger
-> Service
-> Proxy DeleteLoadBalancer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteLoadBalancer)))
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 -> DeleteLoadBalancerResponse
DeleteLoadBalancerResponse'
            (Maybe [Operation] -> Int -> DeleteLoadBalancerResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> DeleteLoadBalancerResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Operation]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"operations" Either String (Maybe (Maybe [Operation]))
-> Maybe [Operation] -> Either String (Maybe [Operation])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Operation]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> DeleteLoadBalancerResponse)
-> Either String Int -> Either String DeleteLoadBalancerResponse
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 DeleteLoadBalancer

instance Prelude.NFData DeleteLoadBalancer

instance Core.ToHeaders DeleteLoadBalancer where
  toHeaders :: DeleteLoadBalancer -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteLoadBalancer -> 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.DeleteLoadBalancer" ::
                          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 DeleteLoadBalancer where
  toJSON :: DeleteLoadBalancer -> Value
toJSON DeleteLoadBalancer' {Text
loadBalancerName :: Text
$sel:loadBalancerName:DeleteLoadBalancer' :: DeleteLoadBalancer -> Text
..} =
    [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
"loadBalancerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
loadBalancerName)
          ]
      )

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

instance Core.ToQuery DeleteLoadBalancer where
  toQuery :: DeleteLoadBalancer -> QueryString
toQuery = QueryString -> DeleteLoadBalancer -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteLoadBalancerResponse -> DeleteLoadBalancerResponse -> Bool)
-> (DeleteLoadBalancerResponse
    -> DeleteLoadBalancerResponse -> Bool)
-> Eq DeleteLoadBalancerResponse
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]
(Int -> ReadS DeleteLoadBalancerResponse)
-> ReadS [DeleteLoadBalancerResponse]
-> ReadPrec DeleteLoadBalancerResponse
-> ReadPrec [DeleteLoadBalancerResponse]
-> Read 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
(Int -> DeleteLoadBalancerResponse -> ShowS)
-> (DeleteLoadBalancerResponse -> String)
-> ([DeleteLoadBalancerResponse] -> ShowS)
-> Show DeleteLoadBalancerResponse
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.
 DeleteLoadBalancerResponse -> Rep DeleteLoadBalancerResponse x)
-> (forall x.
    Rep DeleteLoadBalancerResponse x -> DeleteLoadBalancerResponse)
-> Generic DeleteLoadBalancerResponse
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' :: Maybe [Operation] -> Int -> DeleteLoadBalancerResponse
DeleteLoadBalancerResponse'
    { $sel:operations:DeleteLoadBalancerResponse' :: Maybe [Operation]
operations =
        Maybe [Operation]
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 :: (Maybe [Operation] -> f (Maybe [Operation]))
-> DeleteLoadBalancerResponse -> f DeleteLoadBalancerResponse
deleteLoadBalancerResponse_operations = (DeleteLoadBalancerResponse -> Maybe [Operation])
-> (DeleteLoadBalancerResponse
    -> Maybe [Operation] -> DeleteLoadBalancerResponse)
-> Lens
     DeleteLoadBalancerResponse
     DeleteLoadBalancerResponse
     (Maybe [Operation])
     (Maybe [Operation])
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) ((Maybe [Operation] -> f (Maybe [Operation]))
 -> DeleteLoadBalancerResponse -> f DeleteLoadBalancerResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
    -> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> DeleteLoadBalancerResponse
-> f DeleteLoadBalancerResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Operation] [Operation] [Operation] [Operation]
-> Iso
     (Maybe [Operation])
     (Maybe [Operation])
     (Maybe [Operation])
     (Maybe [Operation])
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 AnIso [Operation] [Operation] [Operation] [Operation]
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 :: (Int -> f Int)
-> DeleteLoadBalancerResponse -> f DeleteLoadBalancerResponse
deleteLoadBalancerResponse_httpStatus = (DeleteLoadBalancerResponse -> Int)
-> (DeleteLoadBalancerResponse
    -> Int -> DeleteLoadBalancerResponse)
-> Lens
     DeleteLoadBalancerResponse DeleteLoadBalancerResponse Int Int
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