{-# 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.DeprovisionByoipCidr
-- 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)
--
-- Releases the specified address range that you provisioned to use with
-- your AWS resources through bring your own IP addresses (BYOIP) and
-- deletes the corresponding address pool.
--
-- Before you can release an address range, you must stop advertising it by
-- using
-- <https://docs.aws.amazon.com/global-accelerator/latest/api/WithdrawByoipCidr.html WithdrawByoipCidr>
-- and you must not have any accelerators that are using static IP
-- addresses allocated from its address range.
--
-- For more information, see
-- <https://docs.aws.amazon.com/global-accelerator/latest/dg/using-byoip.html Bring Your Own IP Addresses (BYOIP)>
-- in the /AWS Global Accelerator Developer Guide/.
module Amazonka.GlobalAccelerator.DeprovisionByoipCidr
  ( -- * Creating a Request
    DeprovisionByoipCidr (..),
    newDeprovisionByoipCidr,

    -- * Request Lenses
    deprovisionByoipCidr_cidr,

    -- * Destructuring the Response
    DeprovisionByoipCidrResponse (..),
    newDeprovisionByoipCidrResponse,

    -- * Response Lenses
    deprovisionByoipCidrResponse_byoipCidr,
    deprovisionByoipCidrResponse_httpStatus,
  )
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:/ 'newDeprovisionByoipCidr' smart constructor.
data DeprovisionByoipCidr = DeprovisionByoipCidr'
  { -- | The address range, in CIDR notation. The prefix must be the same prefix
    -- that you specified when you provisioned the address range.
    DeprovisionByoipCidr -> Text
cidr :: Prelude.Text
  }
  deriving (DeprovisionByoipCidr -> DeprovisionByoipCidr -> Bool
(DeprovisionByoipCidr -> DeprovisionByoipCidr -> Bool)
-> (DeprovisionByoipCidr -> DeprovisionByoipCidr -> Bool)
-> Eq DeprovisionByoipCidr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeprovisionByoipCidr -> DeprovisionByoipCidr -> Bool
$c/= :: DeprovisionByoipCidr -> DeprovisionByoipCidr -> Bool
== :: DeprovisionByoipCidr -> DeprovisionByoipCidr -> Bool
$c== :: DeprovisionByoipCidr -> DeprovisionByoipCidr -> Bool
Prelude.Eq, ReadPrec [DeprovisionByoipCidr]
ReadPrec DeprovisionByoipCidr
Int -> ReadS DeprovisionByoipCidr
ReadS [DeprovisionByoipCidr]
(Int -> ReadS DeprovisionByoipCidr)
-> ReadS [DeprovisionByoipCidr]
-> ReadPrec DeprovisionByoipCidr
-> ReadPrec [DeprovisionByoipCidr]
-> Read DeprovisionByoipCidr
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeprovisionByoipCidr]
$creadListPrec :: ReadPrec [DeprovisionByoipCidr]
readPrec :: ReadPrec DeprovisionByoipCidr
$creadPrec :: ReadPrec DeprovisionByoipCidr
readList :: ReadS [DeprovisionByoipCidr]
$creadList :: ReadS [DeprovisionByoipCidr]
readsPrec :: Int -> ReadS DeprovisionByoipCidr
$creadsPrec :: Int -> ReadS DeprovisionByoipCidr
Prelude.Read, Int -> DeprovisionByoipCidr -> ShowS
[DeprovisionByoipCidr] -> ShowS
DeprovisionByoipCidr -> String
(Int -> DeprovisionByoipCidr -> ShowS)
-> (DeprovisionByoipCidr -> String)
-> ([DeprovisionByoipCidr] -> ShowS)
-> Show DeprovisionByoipCidr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeprovisionByoipCidr] -> ShowS
$cshowList :: [DeprovisionByoipCidr] -> ShowS
show :: DeprovisionByoipCidr -> String
$cshow :: DeprovisionByoipCidr -> String
showsPrec :: Int -> DeprovisionByoipCidr -> ShowS
$cshowsPrec :: Int -> DeprovisionByoipCidr -> ShowS
Prelude.Show, (forall x. DeprovisionByoipCidr -> Rep DeprovisionByoipCidr x)
-> (forall x. Rep DeprovisionByoipCidr x -> DeprovisionByoipCidr)
-> Generic DeprovisionByoipCidr
forall x. Rep DeprovisionByoipCidr x -> DeprovisionByoipCidr
forall x. DeprovisionByoipCidr -> Rep DeprovisionByoipCidr x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeprovisionByoipCidr x -> DeprovisionByoipCidr
$cfrom :: forall x. DeprovisionByoipCidr -> Rep DeprovisionByoipCidr x
Prelude.Generic)

-- |
-- Create a value of 'DeprovisionByoipCidr' 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:
--
-- 'cidr', 'deprovisionByoipCidr_cidr' - The address range, in CIDR notation. The prefix must be the same prefix
-- that you specified when you provisioned the address range.
newDeprovisionByoipCidr ::
  -- | 'cidr'
  Prelude.Text ->
  DeprovisionByoipCidr
newDeprovisionByoipCidr :: Text -> DeprovisionByoipCidr
newDeprovisionByoipCidr Text
pCidr_ =
  DeprovisionByoipCidr' :: Text -> DeprovisionByoipCidr
DeprovisionByoipCidr' {$sel:cidr:DeprovisionByoipCidr' :: Text
cidr = Text
pCidr_}

-- | The address range, in CIDR notation. The prefix must be the same prefix
-- that you specified when you provisioned the address range.
deprovisionByoipCidr_cidr :: Lens.Lens' DeprovisionByoipCidr Prelude.Text
deprovisionByoipCidr_cidr :: (Text -> f Text) -> DeprovisionByoipCidr -> f DeprovisionByoipCidr
deprovisionByoipCidr_cidr = (DeprovisionByoipCidr -> Text)
-> (DeprovisionByoipCidr -> Text -> DeprovisionByoipCidr)
-> Lens DeprovisionByoipCidr DeprovisionByoipCidr Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeprovisionByoipCidr' {Text
cidr :: Text
$sel:cidr:DeprovisionByoipCidr' :: DeprovisionByoipCidr -> Text
cidr} -> Text
cidr) (\s :: DeprovisionByoipCidr
s@DeprovisionByoipCidr' {} Text
a -> DeprovisionByoipCidr
s {$sel:cidr:DeprovisionByoipCidr' :: Text
cidr = Text
a} :: DeprovisionByoipCidr)

instance Core.AWSRequest DeprovisionByoipCidr where
  type
    AWSResponse DeprovisionByoipCidr =
      DeprovisionByoipCidrResponse
  request :: DeprovisionByoipCidr -> Request DeprovisionByoipCidr
request = Service -> DeprovisionByoipCidr -> Request DeprovisionByoipCidr
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeprovisionByoipCidr
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeprovisionByoipCidr)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeprovisionByoipCidr))
-> Logger
-> Service
-> Proxy DeprovisionByoipCidr
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeprovisionByoipCidr)))
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 ByoipCidr -> Int -> DeprovisionByoipCidrResponse
DeprovisionByoipCidrResponse'
            (Maybe ByoipCidr -> Int -> DeprovisionByoipCidrResponse)
-> Either String (Maybe ByoipCidr)
-> Either String (Int -> DeprovisionByoipCidrResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ByoipCidr)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ByoipCidr")
            Either String (Int -> DeprovisionByoipCidrResponse)
-> Either String Int -> Either String DeprovisionByoipCidrResponse
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 DeprovisionByoipCidr

instance Prelude.NFData DeprovisionByoipCidr

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

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

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

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

-- |
-- Create a value of 'DeprovisionByoipCidrResponse' 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:
--
-- 'byoipCidr', 'deprovisionByoipCidrResponse_byoipCidr' - Information about the address range.
--
-- 'httpStatus', 'deprovisionByoipCidrResponse_httpStatus' - The response's http status code.
newDeprovisionByoipCidrResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeprovisionByoipCidrResponse
newDeprovisionByoipCidrResponse :: Int -> DeprovisionByoipCidrResponse
newDeprovisionByoipCidrResponse Int
pHttpStatus_ =
  DeprovisionByoipCidrResponse' :: Maybe ByoipCidr -> Int -> DeprovisionByoipCidrResponse
DeprovisionByoipCidrResponse'
    { $sel:byoipCidr:DeprovisionByoipCidrResponse' :: Maybe ByoipCidr
byoipCidr =
        Maybe ByoipCidr
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeprovisionByoipCidrResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the address range.
deprovisionByoipCidrResponse_byoipCidr :: Lens.Lens' DeprovisionByoipCidrResponse (Prelude.Maybe ByoipCidr)
deprovisionByoipCidrResponse_byoipCidr :: (Maybe ByoipCidr -> f (Maybe ByoipCidr))
-> DeprovisionByoipCidrResponse -> f DeprovisionByoipCidrResponse
deprovisionByoipCidrResponse_byoipCidr = (DeprovisionByoipCidrResponse -> Maybe ByoipCidr)
-> (DeprovisionByoipCidrResponse
    -> Maybe ByoipCidr -> DeprovisionByoipCidrResponse)
-> Lens
     DeprovisionByoipCidrResponse
     DeprovisionByoipCidrResponse
     (Maybe ByoipCidr)
     (Maybe ByoipCidr)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeprovisionByoipCidrResponse' {Maybe ByoipCidr
byoipCidr :: Maybe ByoipCidr
$sel:byoipCidr:DeprovisionByoipCidrResponse' :: DeprovisionByoipCidrResponse -> Maybe ByoipCidr
byoipCidr} -> Maybe ByoipCidr
byoipCidr) (\s :: DeprovisionByoipCidrResponse
s@DeprovisionByoipCidrResponse' {} Maybe ByoipCidr
a -> DeprovisionByoipCidrResponse
s {$sel:byoipCidr:DeprovisionByoipCidrResponse' :: Maybe ByoipCidr
byoipCidr = Maybe ByoipCidr
a} :: DeprovisionByoipCidrResponse)

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

instance Prelude.NFData DeprovisionByoipCidrResponse