{-# 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.GlobalAccelerator.DeleteAccelerator
-- 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 an accelerator. Before you can delete an accelerator, you must
-- disable it and remove all dependent resources (listeners and endpoint
-- groups). To disable the accelerator, update the accelerator to set
-- @Enabled@ to false.
--
-- When you create an accelerator, by default, Global Accelerator provides
-- you with a set of two static IP addresses. Alternatively, you can bring
-- your own IP address ranges to Global Accelerator and assign IP addresses
-- from those ranges.
--
-- The IP addresses are assigned to your accelerator for as long as it
-- exists, even if you disable the accelerator and it no longer accepts or
-- routes traffic. However, when you /delete/ an accelerator, you lose the
-- static IP addresses that are assigned to the accelerator, so you can no
-- longer route traffic by using them. As a best practice, ensure that you
-- have permissions in place to avoid inadvertently deleting accelerators.
-- You can use IAM policies with Global Accelerator to limit the users who
-- have permissions to delete an accelerator. For more information, see
-- <https://docs.aws.amazon.com/global-accelerator/latest/dg/auth-and-access-control.html Authentication and Access Control>
-- in the /AWS Global Accelerator Developer Guide/.
module Amazonka.GlobalAccelerator.DeleteAccelerator
  ( -- * Creating a Request
    DeleteAccelerator (..),
    newDeleteAccelerator,

    -- * Request Lenses
    deleteAccelerator_acceleratorArn,

    -- * Destructuring the Response
    DeleteAcceleratorResponse (..),
    newDeleteAcceleratorResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GlobalAccelerator.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:/ 'newDeleteAccelerator' smart constructor.
data DeleteAccelerator = DeleteAccelerator'
  { -- | The Amazon Resource Name (ARN) of an accelerator.
    DeleteAccelerator -> Text
acceleratorArn :: Prelude.Text
  }
  deriving (DeleteAccelerator -> DeleteAccelerator -> Bool
(DeleteAccelerator -> DeleteAccelerator -> Bool)
-> (DeleteAccelerator -> DeleteAccelerator -> Bool)
-> Eq DeleteAccelerator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteAccelerator -> DeleteAccelerator -> Bool
$c/= :: DeleteAccelerator -> DeleteAccelerator -> Bool
== :: DeleteAccelerator -> DeleteAccelerator -> Bool
$c== :: DeleteAccelerator -> DeleteAccelerator -> Bool
Prelude.Eq, ReadPrec [DeleteAccelerator]
ReadPrec DeleteAccelerator
Int -> ReadS DeleteAccelerator
ReadS [DeleteAccelerator]
(Int -> ReadS DeleteAccelerator)
-> ReadS [DeleteAccelerator]
-> ReadPrec DeleteAccelerator
-> ReadPrec [DeleteAccelerator]
-> Read DeleteAccelerator
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteAccelerator]
$creadListPrec :: ReadPrec [DeleteAccelerator]
readPrec :: ReadPrec DeleteAccelerator
$creadPrec :: ReadPrec DeleteAccelerator
readList :: ReadS [DeleteAccelerator]
$creadList :: ReadS [DeleteAccelerator]
readsPrec :: Int -> ReadS DeleteAccelerator
$creadsPrec :: Int -> ReadS DeleteAccelerator
Prelude.Read, Int -> DeleteAccelerator -> ShowS
[DeleteAccelerator] -> ShowS
DeleteAccelerator -> String
(Int -> DeleteAccelerator -> ShowS)
-> (DeleteAccelerator -> String)
-> ([DeleteAccelerator] -> ShowS)
-> Show DeleteAccelerator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteAccelerator] -> ShowS
$cshowList :: [DeleteAccelerator] -> ShowS
show :: DeleteAccelerator -> String
$cshow :: DeleteAccelerator -> String
showsPrec :: Int -> DeleteAccelerator -> ShowS
$cshowsPrec :: Int -> DeleteAccelerator -> ShowS
Prelude.Show, (forall x. DeleteAccelerator -> Rep DeleteAccelerator x)
-> (forall x. Rep DeleteAccelerator x -> DeleteAccelerator)
-> Generic DeleteAccelerator
forall x. Rep DeleteAccelerator x -> DeleteAccelerator
forall x. DeleteAccelerator -> Rep DeleteAccelerator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteAccelerator x -> DeleteAccelerator
$cfrom :: forall x. DeleteAccelerator -> Rep DeleteAccelerator x
Prelude.Generic)

-- |
-- Create a value of 'DeleteAccelerator' 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:
--
-- 'acceleratorArn', 'deleteAccelerator_acceleratorArn' - The Amazon Resource Name (ARN) of an accelerator.
newDeleteAccelerator ::
  -- | 'acceleratorArn'
  Prelude.Text ->
  DeleteAccelerator
newDeleteAccelerator :: Text -> DeleteAccelerator
newDeleteAccelerator Text
pAcceleratorArn_ =
  DeleteAccelerator' :: Text -> DeleteAccelerator
DeleteAccelerator'
    { $sel:acceleratorArn:DeleteAccelerator' :: Text
acceleratorArn =
        Text
pAcceleratorArn_
    }

-- | The Amazon Resource Name (ARN) of an accelerator.
deleteAccelerator_acceleratorArn :: Lens.Lens' DeleteAccelerator Prelude.Text
deleteAccelerator_acceleratorArn :: (Text -> f Text) -> DeleteAccelerator -> f DeleteAccelerator
deleteAccelerator_acceleratorArn = (DeleteAccelerator -> Text)
-> (DeleteAccelerator -> Text -> DeleteAccelerator)
-> Lens DeleteAccelerator DeleteAccelerator Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAccelerator' {Text
acceleratorArn :: Text
$sel:acceleratorArn:DeleteAccelerator' :: DeleteAccelerator -> Text
acceleratorArn} -> Text
acceleratorArn) (\s :: DeleteAccelerator
s@DeleteAccelerator' {} Text
a -> DeleteAccelerator
s {$sel:acceleratorArn:DeleteAccelerator' :: Text
acceleratorArn = Text
a} :: DeleteAccelerator)

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

instance Prelude.Hashable DeleteAccelerator

instance Prelude.NFData DeleteAccelerator

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

instance Core.ToJSON DeleteAccelerator where
  toJSON :: DeleteAccelerator -> Value
toJSON DeleteAccelerator' {Text
acceleratorArn :: Text
$sel:acceleratorArn:DeleteAccelerator' :: DeleteAccelerator -> 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
"AcceleratorArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
acceleratorArn)
          ]
      )

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

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

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

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

instance Prelude.NFData DeleteAcceleratorResponse