{-# 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.EC2.DeleteManagedPrefixList
-- 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 the specified managed prefix list. You must first remove all
-- references to the prefix list in your resources.
module Amazonka.EC2.DeleteManagedPrefixList
  ( -- * Creating a Request
    DeleteManagedPrefixList (..),
    newDeleteManagedPrefixList,

    -- * Request Lenses
    deleteManagedPrefixList_dryRun,
    deleteManagedPrefixList_prefixListId,

    -- * Destructuring the Response
    DeleteManagedPrefixListResponse (..),
    newDeleteManagedPrefixListResponse,

    -- * Response Lenses
    deleteManagedPrefixListResponse_prefixList,
    deleteManagedPrefixListResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteManagedPrefixList' smart constructor.
data DeleteManagedPrefixList = DeleteManagedPrefixList'
  { -- | Checks whether you have the required permissions for the action, without
    -- actually making the request, and provides an error response. If you have
    -- the required permissions, the error response is @DryRunOperation@.
    -- Otherwise, it is @UnauthorizedOperation@.
    DeleteManagedPrefixList -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the prefix list.
    DeleteManagedPrefixList -> Text
prefixListId :: Prelude.Text
  }
  deriving (DeleteManagedPrefixList -> DeleteManagedPrefixList -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteManagedPrefixList -> DeleteManagedPrefixList -> Bool
$c/= :: DeleteManagedPrefixList -> DeleteManagedPrefixList -> Bool
== :: DeleteManagedPrefixList -> DeleteManagedPrefixList -> Bool
$c== :: DeleteManagedPrefixList -> DeleteManagedPrefixList -> Bool
Prelude.Eq, ReadPrec [DeleteManagedPrefixList]
ReadPrec DeleteManagedPrefixList
Int -> ReadS DeleteManagedPrefixList
ReadS [DeleteManagedPrefixList]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteManagedPrefixList]
$creadListPrec :: ReadPrec [DeleteManagedPrefixList]
readPrec :: ReadPrec DeleteManagedPrefixList
$creadPrec :: ReadPrec DeleteManagedPrefixList
readList :: ReadS [DeleteManagedPrefixList]
$creadList :: ReadS [DeleteManagedPrefixList]
readsPrec :: Int -> ReadS DeleteManagedPrefixList
$creadsPrec :: Int -> ReadS DeleteManagedPrefixList
Prelude.Read, Int -> DeleteManagedPrefixList -> ShowS
[DeleteManagedPrefixList] -> ShowS
DeleteManagedPrefixList -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteManagedPrefixList] -> ShowS
$cshowList :: [DeleteManagedPrefixList] -> ShowS
show :: DeleteManagedPrefixList -> String
$cshow :: DeleteManagedPrefixList -> String
showsPrec :: Int -> DeleteManagedPrefixList -> ShowS
$cshowsPrec :: Int -> DeleteManagedPrefixList -> ShowS
Prelude.Show, forall x. Rep DeleteManagedPrefixList x -> DeleteManagedPrefixList
forall x. DeleteManagedPrefixList -> Rep DeleteManagedPrefixList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteManagedPrefixList x -> DeleteManagedPrefixList
$cfrom :: forall x. DeleteManagedPrefixList -> Rep DeleteManagedPrefixList x
Prelude.Generic)

-- |
-- Create a value of 'DeleteManagedPrefixList' 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:
--
-- 'dryRun', 'deleteManagedPrefixList_dryRun' - Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
--
-- 'prefixListId', 'deleteManagedPrefixList_prefixListId' - The ID of the prefix list.
newDeleteManagedPrefixList ::
  -- | 'prefixListId'
  Prelude.Text ->
  DeleteManagedPrefixList
newDeleteManagedPrefixList :: Text -> DeleteManagedPrefixList
newDeleteManagedPrefixList Text
pPrefixListId_ =
  DeleteManagedPrefixList'
    { $sel:dryRun:DeleteManagedPrefixList' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:prefixListId:DeleteManagedPrefixList' :: Text
prefixListId = Text
pPrefixListId_
    }

-- | Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
deleteManagedPrefixList_dryRun :: Lens.Lens' DeleteManagedPrefixList (Prelude.Maybe Prelude.Bool)
deleteManagedPrefixList_dryRun :: Lens' DeleteManagedPrefixList (Maybe Bool)
deleteManagedPrefixList_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteManagedPrefixList' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:DeleteManagedPrefixList' :: DeleteManagedPrefixList -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: DeleteManagedPrefixList
s@DeleteManagedPrefixList' {} Maybe Bool
a -> DeleteManagedPrefixList
s {$sel:dryRun:DeleteManagedPrefixList' :: Maybe Bool
dryRun = Maybe Bool
a} :: DeleteManagedPrefixList)

-- | The ID of the prefix list.
deleteManagedPrefixList_prefixListId :: Lens.Lens' DeleteManagedPrefixList Prelude.Text
deleteManagedPrefixList_prefixListId :: Lens' DeleteManagedPrefixList Text
deleteManagedPrefixList_prefixListId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteManagedPrefixList' {Text
prefixListId :: Text
$sel:prefixListId:DeleteManagedPrefixList' :: DeleteManagedPrefixList -> Text
prefixListId} -> Text
prefixListId) (\s :: DeleteManagedPrefixList
s@DeleteManagedPrefixList' {} Text
a -> DeleteManagedPrefixList
s {$sel:prefixListId:DeleteManagedPrefixList' :: Text
prefixListId = Text
a} :: DeleteManagedPrefixList)

instance Core.AWSRequest DeleteManagedPrefixList where
  type
    AWSResponse DeleteManagedPrefixList =
      DeleteManagedPrefixListResponse
  request :: (Service -> Service)
-> DeleteManagedPrefixList -> Request DeleteManagedPrefixList
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteManagedPrefixList
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteManagedPrefixList)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe ManagedPrefixList -> Int -> DeleteManagedPrefixListResponse
DeleteManagedPrefixListResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"prefixList")
            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 DeleteManagedPrefixList where
  hashWithSalt :: Int -> DeleteManagedPrefixList -> Int
hashWithSalt Int
_salt DeleteManagedPrefixList' {Maybe Bool
Text
prefixListId :: Text
dryRun :: Maybe Bool
$sel:prefixListId:DeleteManagedPrefixList' :: DeleteManagedPrefixList -> Text
$sel:dryRun:DeleteManagedPrefixList' :: DeleteManagedPrefixList -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dryRun
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
prefixListId

instance Prelude.NFData DeleteManagedPrefixList where
  rnf :: DeleteManagedPrefixList -> ()
rnf DeleteManagedPrefixList' {Maybe Bool
Text
prefixListId :: Text
dryRun :: Maybe Bool
$sel:prefixListId:DeleteManagedPrefixList' :: DeleteManagedPrefixList -> Text
$sel:dryRun:DeleteManagedPrefixList' :: DeleteManagedPrefixList -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dryRun
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
prefixListId

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

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

instance Data.ToQuery DeleteManagedPrefixList where
  toQuery :: DeleteManagedPrefixList -> QueryString
toQuery DeleteManagedPrefixList' {Maybe Bool
Text
prefixListId :: Text
dryRun :: Maybe Bool
$sel:prefixListId:DeleteManagedPrefixList' :: DeleteManagedPrefixList -> Text
$sel:dryRun:DeleteManagedPrefixList' :: DeleteManagedPrefixList -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DeleteManagedPrefixList" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2016-11-15" :: Prelude.ByteString),
        ByteString
"DryRun" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
dryRun,
        ByteString
"PrefixListId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
prefixListId
      ]

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

-- |
-- Create a value of 'DeleteManagedPrefixListResponse' 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:
--
-- 'prefixList', 'deleteManagedPrefixListResponse_prefixList' - Information about the prefix list.
--
-- 'httpStatus', 'deleteManagedPrefixListResponse_httpStatus' - The response's http status code.
newDeleteManagedPrefixListResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteManagedPrefixListResponse
newDeleteManagedPrefixListResponse :: Int -> DeleteManagedPrefixListResponse
newDeleteManagedPrefixListResponse Int
pHttpStatus_ =
  DeleteManagedPrefixListResponse'
    { $sel:prefixList:DeleteManagedPrefixListResponse' :: Maybe ManagedPrefixList
prefixList =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteManagedPrefixListResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the prefix list.
deleteManagedPrefixListResponse_prefixList :: Lens.Lens' DeleteManagedPrefixListResponse (Prelude.Maybe ManagedPrefixList)
deleteManagedPrefixListResponse_prefixList :: Lens' DeleteManagedPrefixListResponse (Maybe ManagedPrefixList)
deleteManagedPrefixListResponse_prefixList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteManagedPrefixListResponse' {Maybe ManagedPrefixList
prefixList :: Maybe ManagedPrefixList
$sel:prefixList:DeleteManagedPrefixListResponse' :: DeleteManagedPrefixListResponse -> Maybe ManagedPrefixList
prefixList} -> Maybe ManagedPrefixList
prefixList) (\s :: DeleteManagedPrefixListResponse
s@DeleteManagedPrefixListResponse' {} Maybe ManagedPrefixList
a -> DeleteManagedPrefixListResponse
s {$sel:prefixList:DeleteManagedPrefixListResponse' :: Maybe ManagedPrefixList
prefixList = Maybe ManagedPrefixList
a} :: DeleteManagedPrefixListResponse)

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

instance
  Prelude.NFData
    DeleteManagedPrefixListResponse
  where
  rnf :: DeleteManagedPrefixListResponse -> ()
rnf DeleteManagedPrefixListResponse' {Int
Maybe ManagedPrefixList
httpStatus :: Int
prefixList :: Maybe ManagedPrefixList
$sel:httpStatus:DeleteManagedPrefixListResponse' :: DeleteManagedPrefixListResponse -> Int
$sel:prefixList:DeleteManagedPrefixListResponse' :: DeleteManagedPrefixListResponse -> Maybe ManagedPrefixList
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ManagedPrefixList
prefixList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus