{-# 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.DeleteCoipCidr
-- 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 range of customer-owned IP addresses.
module Amazonka.EC2.DeleteCoipCidr
  ( -- * Creating a Request
    DeleteCoipCidr (..),
    newDeleteCoipCidr,

    -- * Request Lenses
    deleteCoipCidr_dryRun,
    deleteCoipCidr_cidr,
    deleteCoipCidr_coipPoolId,

    -- * Destructuring the Response
    DeleteCoipCidrResponse (..),
    newDeleteCoipCidrResponse,

    -- * Response Lenses
    deleteCoipCidrResponse_coipCidr,
    deleteCoipCidrResponse_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:/ 'newDeleteCoipCidr' smart constructor.
data DeleteCoipCidr = DeleteCoipCidr'
  { -- | 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@.
    DeleteCoipCidr -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | A customer-owned IP address range that you want to delete.
    DeleteCoipCidr -> Text
cidr :: Prelude.Text,
    -- | The ID of the customer-owned address pool.
    DeleteCoipCidr -> Text
coipPoolId :: Prelude.Text
  }
  deriving (DeleteCoipCidr -> DeleteCoipCidr -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteCoipCidr -> DeleteCoipCidr -> Bool
$c/= :: DeleteCoipCidr -> DeleteCoipCidr -> Bool
== :: DeleteCoipCidr -> DeleteCoipCidr -> Bool
$c== :: DeleteCoipCidr -> DeleteCoipCidr -> Bool
Prelude.Eq, ReadPrec [DeleteCoipCidr]
ReadPrec DeleteCoipCidr
Int -> ReadS DeleteCoipCidr
ReadS [DeleteCoipCidr]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteCoipCidr]
$creadListPrec :: ReadPrec [DeleteCoipCidr]
readPrec :: ReadPrec DeleteCoipCidr
$creadPrec :: ReadPrec DeleteCoipCidr
readList :: ReadS [DeleteCoipCidr]
$creadList :: ReadS [DeleteCoipCidr]
readsPrec :: Int -> ReadS DeleteCoipCidr
$creadsPrec :: Int -> ReadS DeleteCoipCidr
Prelude.Read, Int -> DeleteCoipCidr -> ShowS
[DeleteCoipCidr] -> ShowS
DeleteCoipCidr -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteCoipCidr] -> ShowS
$cshowList :: [DeleteCoipCidr] -> ShowS
show :: DeleteCoipCidr -> String
$cshow :: DeleteCoipCidr -> String
showsPrec :: Int -> DeleteCoipCidr -> ShowS
$cshowsPrec :: Int -> DeleteCoipCidr -> ShowS
Prelude.Show, forall x. Rep DeleteCoipCidr x -> DeleteCoipCidr
forall x. DeleteCoipCidr -> Rep DeleteCoipCidr x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteCoipCidr x -> DeleteCoipCidr
$cfrom :: forall x. DeleteCoipCidr -> Rep DeleteCoipCidr x
Prelude.Generic)

-- |
-- Create a value of 'DeleteCoipCidr' 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', 'deleteCoipCidr_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@.
--
-- 'cidr', 'deleteCoipCidr_cidr' - A customer-owned IP address range that you want to delete.
--
-- 'coipPoolId', 'deleteCoipCidr_coipPoolId' - The ID of the customer-owned address pool.
newDeleteCoipCidr ::
  -- | 'cidr'
  Prelude.Text ->
  -- | 'coipPoolId'
  Prelude.Text ->
  DeleteCoipCidr
newDeleteCoipCidr :: Text -> Text -> DeleteCoipCidr
newDeleteCoipCidr Text
pCidr_ Text
pCoipPoolId_ =
  DeleteCoipCidr'
    { $sel:dryRun:DeleteCoipCidr' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:cidr:DeleteCoipCidr' :: Text
cidr = Text
pCidr_,
      $sel:coipPoolId:DeleteCoipCidr' :: Text
coipPoolId = Text
pCoipPoolId_
    }

-- | 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@.
deleteCoipCidr_dryRun :: Lens.Lens' DeleteCoipCidr (Prelude.Maybe Prelude.Bool)
deleteCoipCidr_dryRun :: Lens' DeleteCoipCidr (Maybe Bool)
deleteCoipCidr_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCoipCidr' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:DeleteCoipCidr' :: DeleteCoipCidr -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: DeleteCoipCidr
s@DeleteCoipCidr' {} Maybe Bool
a -> DeleteCoipCidr
s {$sel:dryRun:DeleteCoipCidr' :: Maybe Bool
dryRun = Maybe Bool
a} :: DeleteCoipCidr)

-- | A customer-owned IP address range that you want to delete.
deleteCoipCidr_cidr :: Lens.Lens' DeleteCoipCidr Prelude.Text
deleteCoipCidr_cidr :: Lens' DeleteCoipCidr Text
deleteCoipCidr_cidr = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCoipCidr' {Text
cidr :: Text
$sel:cidr:DeleteCoipCidr' :: DeleteCoipCidr -> Text
cidr} -> Text
cidr) (\s :: DeleteCoipCidr
s@DeleteCoipCidr' {} Text
a -> DeleteCoipCidr
s {$sel:cidr:DeleteCoipCidr' :: Text
cidr = Text
a} :: DeleteCoipCidr)

-- | The ID of the customer-owned address pool.
deleteCoipCidr_coipPoolId :: Lens.Lens' DeleteCoipCidr Prelude.Text
deleteCoipCidr_coipPoolId :: Lens' DeleteCoipCidr Text
deleteCoipCidr_coipPoolId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCoipCidr' {Text
coipPoolId :: Text
$sel:coipPoolId:DeleteCoipCidr' :: DeleteCoipCidr -> Text
coipPoolId} -> Text
coipPoolId) (\s :: DeleteCoipCidr
s@DeleteCoipCidr' {} Text
a -> DeleteCoipCidr
s {$sel:coipPoolId:DeleteCoipCidr' :: Text
coipPoolId = Text
a} :: DeleteCoipCidr)

instance Core.AWSRequest DeleteCoipCidr where
  type
    AWSResponse DeleteCoipCidr =
      DeleteCoipCidrResponse
  request :: (Service -> Service) -> DeleteCoipCidr -> Request DeleteCoipCidr
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 DeleteCoipCidr
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteCoipCidr)))
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 CoipCidr -> Int -> DeleteCoipCidrResponse
DeleteCoipCidrResponse'
            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
"coipCidr")
            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 DeleteCoipCidr where
  hashWithSalt :: Int -> DeleteCoipCidr -> Int
hashWithSalt Int
_salt DeleteCoipCidr' {Maybe Bool
Text
coipPoolId :: Text
cidr :: Text
dryRun :: Maybe Bool
$sel:coipPoolId:DeleteCoipCidr' :: DeleteCoipCidr -> Text
$sel:cidr:DeleteCoipCidr' :: DeleteCoipCidr -> Text
$sel:dryRun:DeleteCoipCidr' :: DeleteCoipCidr -> 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
cidr
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
coipPoolId

instance Prelude.NFData DeleteCoipCidr where
  rnf :: DeleteCoipCidr -> ()
rnf DeleteCoipCidr' {Maybe Bool
Text
coipPoolId :: Text
cidr :: Text
dryRun :: Maybe Bool
$sel:coipPoolId:DeleteCoipCidr' :: DeleteCoipCidr -> Text
$sel:cidr:DeleteCoipCidr' :: DeleteCoipCidr -> Text
$sel:dryRun:DeleteCoipCidr' :: DeleteCoipCidr -> 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
cidr
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
coipPoolId

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

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

instance Data.ToQuery DeleteCoipCidr where
  toQuery :: DeleteCoipCidr -> QueryString
toQuery DeleteCoipCidr' {Maybe Bool
Text
coipPoolId :: Text
cidr :: Text
dryRun :: Maybe Bool
$sel:coipPoolId:DeleteCoipCidr' :: DeleteCoipCidr -> Text
$sel:cidr:DeleteCoipCidr' :: DeleteCoipCidr -> Text
$sel:dryRun:DeleteCoipCidr' :: DeleteCoipCidr -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DeleteCoipCidr" :: 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
"Cidr" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
cidr,
        ByteString
"CoipPoolId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
coipPoolId
      ]

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

-- |
-- Create a value of 'DeleteCoipCidrResponse' 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:
--
-- 'coipCidr', 'deleteCoipCidrResponse_coipCidr' - Information about a range of customer-owned IP addresses.
--
-- 'httpStatus', 'deleteCoipCidrResponse_httpStatus' - The response's http status code.
newDeleteCoipCidrResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteCoipCidrResponse
newDeleteCoipCidrResponse :: Int -> DeleteCoipCidrResponse
newDeleteCoipCidrResponse Int
pHttpStatus_ =
  DeleteCoipCidrResponse'
    { $sel:coipCidr:DeleteCoipCidrResponse' :: Maybe CoipCidr
coipCidr = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteCoipCidrResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about a range of customer-owned IP addresses.
deleteCoipCidrResponse_coipCidr :: Lens.Lens' DeleteCoipCidrResponse (Prelude.Maybe CoipCidr)
deleteCoipCidrResponse_coipCidr :: Lens' DeleteCoipCidrResponse (Maybe CoipCidr)
deleteCoipCidrResponse_coipCidr = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCoipCidrResponse' {Maybe CoipCidr
coipCidr :: Maybe CoipCidr
$sel:coipCidr:DeleteCoipCidrResponse' :: DeleteCoipCidrResponse -> Maybe CoipCidr
coipCidr} -> Maybe CoipCidr
coipCidr) (\s :: DeleteCoipCidrResponse
s@DeleteCoipCidrResponse' {} Maybe CoipCidr
a -> DeleteCoipCidrResponse
s {$sel:coipCidr:DeleteCoipCidrResponse' :: Maybe CoipCidr
coipCidr = Maybe CoipCidr
a} :: DeleteCoipCidrResponse)

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

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