{-# 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.ELBV2.DeleteTargetGroup
-- 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 the specified target group.
--
-- You can delete a target group if it is not referenced by any actions.
-- Deleting a target group also deletes any associated health checks.
-- Deleting a target group does not affect its registered targets. For
-- example, any EC2 instances continue to run until you stop or terminate
-- them.
module Amazonka.ELBV2.DeleteTargetGroup
  ( -- * Creating a Request
    DeleteTargetGroup (..),
    newDeleteTargetGroup,

    -- * Request Lenses
    deleteTargetGroup_targetGroupArn,

    -- * Destructuring the Response
    DeleteTargetGroupResponse (..),
    newDeleteTargetGroupResponse,

    -- * Response Lenses
    deleteTargetGroupResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteTargetGroup' smart constructor.
data DeleteTargetGroup = DeleteTargetGroup'
  { -- | The Amazon Resource Name (ARN) of the target group.
    DeleteTargetGroup -> Text
targetGroupArn :: Prelude.Text
  }
  deriving (DeleteTargetGroup -> DeleteTargetGroup -> Bool
(DeleteTargetGroup -> DeleteTargetGroup -> Bool)
-> (DeleteTargetGroup -> DeleteTargetGroup -> Bool)
-> Eq DeleteTargetGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteTargetGroup -> DeleteTargetGroup -> Bool
$c/= :: DeleteTargetGroup -> DeleteTargetGroup -> Bool
== :: DeleteTargetGroup -> DeleteTargetGroup -> Bool
$c== :: DeleteTargetGroup -> DeleteTargetGroup -> Bool
Prelude.Eq, ReadPrec [DeleteTargetGroup]
ReadPrec DeleteTargetGroup
Int -> ReadS DeleteTargetGroup
ReadS [DeleteTargetGroup]
(Int -> ReadS DeleteTargetGroup)
-> ReadS [DeleteTargetGroup]
-> ReadPrec DeleteTargetGroup
-> ReadPrec [DeleteTargetGroup]
-> Read DeleteTargetGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteTargetGroup]
$creadListPrec :: ReadPrec [DeleteTargetGroup]
readPrec :: ReadPrec DeleteTargetGroup
$creadPrec :: ReadPrec DeleteTargetGroup
readList :: ReadS [DeleteTargetGroup]
$creadList :: ReadS [DeleteTargetGroup]
readsPrec :: Int -> ReadS DeleteTargetGroup
$creadsPrec :: Int -> ReadS DeleteTargetGroup
Prelude.Read, Int -> DeleteTargetGroup -> ShowS
[DeleteTargetGroup] -> ShowS
DeleteTargetGroup -> String
(Int -> DeleteTargetGroup -> ShowS)
-> (DeleteTargetGroup -> String)
-> ([DeleteTargetGroup] -> ShowS)
-> Show DeleteTargetGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteTargetGroup] -> ShowS
$cshowList :: [DeleteTargetGroup] -> ShowS
show :: DeleteTargetGroup -> String
$cshow :: DeleteTargetGroup -> String
showsPrec :: Int -> DeleteTargetGroup -> ShowS
$cshowsPrec :: Int -> DeleteTargetGroup -> ShowS
Prelude.Show, (forall x. DeleteTargetGroup -> Rep DeleteTargetGroup x)
-> (forall x. Rep DeleteTargetGroup x -> DeleteTargetGroup)
-> Generic DeleteTargetGroup
forall x. Rep DeleteTargetGroup x -> DeleteTargetGroup
forall x. DeleteTargetGroup -> Rep DeleteTargetGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteTargetGroup x -> DeleteTargetGroup
$cfrom :: forall x. DeleteTargetGroup -> Rep DeleteTargetGroup x
Prelude.Generic)

-- |
-- Create a value of 'DeleteTargetGroup' 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:
--
-- 'targetGroupArn', 'deleteTargetGroup_targetGroupArn' - The Amazon Resource Name (ARN) of the target group.
newDeleteTargetGroup ::
  -- | 'targetGroupArn'
  Prelude.Text ->
  DeleteTargetGroup
newDeleteTargetGroup :: Text -> DeleteTargetGroup
newDeleteTargetGroup Text
pTargetGroupArn_ =
  DeleteTargetGroup' :: Text -> DeleteTargetGroup
DeleteTargetGroup'
    { $sel:targetGroupArn:DeleteTargetGroup' :: Text
targetGroupArn =
        Text
pTargetGroupArn_
    }

-- | The Amazon Resource Name (ARN) of the target group.
deleteTargetGroup_targetGroupArn :: Lens.Lens' DeleteTargetGroup Prelude.Text
deleteTargetGroup_targetGroupArn :: (Text -> f Text) -> DeleteTargetGroup -> f DeleteTargetGroup
deleteTargetGroup_targetGroupArn = (DeleteTargetGroup -> Text)
-> (DeleteTargetGroup -> Text -> DeleteTargetGroup)
-> Lens DeleteTargetGroup DeleteTargetGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTargetGroup' {Text
targetGroupArn :: Text
$sel:targetGroupArn:DeleteTargetGroup' :: DeleteTargetGroup -> Text
targetGroupArn} -> Text
targetGroupArn) (\s :: DeleteTargetGroup
s@DeleteTargetGroup' {} Text
a -> DeleteTargetGroup
s {$sel:targetGroupArn:DeleteTargetGroup' :: Text
targetGroupArn = Text
a} :: DeleteTargetGroup)

instance Core.AWSRequest DeleteTargetGroup where
  type
    AWSResponse DeleteTargetGroup =
      DeleteTargetGroupResponse
  request :: DeleteTargetGroup -> Request DeleteTargetGroup
request = Service -> DeleteTargetGroup -> Request DeleteTargetGroup
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteTargetGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteTargetGroup)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DeleteTargetGroup))
-> Logger
-> Service
-> Proxy DeleteTargetGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteTargetGroup)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DeleteTargetGroupResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> DeleteTargetGroupResponse
DeleteTargetGroupResponse'
            (Int -> DeleteTargetGroupResponse)
-> Either String Int -> Either String DeleteTargetGroupResponse
forall (f :: * -> *) a b. Functor 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 DeleteTargetGroup

instance Prelude.NFData DeleteTargetGroup

instance Core.ToHeaders DeleteTargetGroup where
  toHeaders :: DeleteTargetGroup -> ResponseHeaders
toHeaders = ResponseHeaders -> DeleteTargetGroup -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery DeleteTargetGroup where
  toQuery :: DeleteTargetGroup -> QueryString
toQuery DeleteTargetGroup' {Text
targetGroupArn :: Text
$sel:targetGroupArn:DeleteTargetGroup' :: DeleteTargetGroup -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DeleteTargetGroup" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2015-12-01" :: Prelude.ByteString),
        ByteString
"TargetGroupArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
targetGroupArn
      ]

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

-- |
-- Create a value of 'DeleteTargetGroupResponse' 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:
--
-- 'httpStatus', 'deleteTargetGroupResponse_httpStatus' - The response's http status code.
newDeleteTargetGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteTargetGroupResponse
newDeleteTargetGroupResponse :: Int -> DeleteTargetGroupResponse
newDeleteTargetGroupResponse Int
pHttpStatus_ =
  DeleteTargetGroupResponse' :: Int -> DeleteTargetGroupResponse
DeleteTargetGroupResponse'
    { $sel:httpStatus:DeleteTargetGroupResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData DeleteTargetGroupResponse