{-# 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.WithdrawByoipCidr
-- 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)
--
-- Stops advertising an address range that is provisioned as an address
-- pool. You can perform this operation at most once every 10 seconds, even
-- if you specify different address ranges each time.
--
-- It can take a few minutes before traffic to the specified addresses
-- stops routing to AWS because of propagation delays.
--
-- 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.WithdrawByoipCidr
  ( -- * Creating a Request
    WithdrawByoipCidr (..),
    newWithdrawByoipCidr,

    -- * Request Lenses
    withdrawByoipCidr_cidr,

    -- * Destructuring the Response
    WithdrawByoipCidrResponse (..),
    newWithdrawByoipCidrResponse,

    -- * Response Lenses
    withdrawByoipCidrResponse_byoipCidr,
    withdrawByoipCidrResponse_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:/ 'newWithdrawByoipCidr' smart constructor.
data WithdrawByoipCidr = WithdrawByoipCidr'
  { -- | The address range, in CIDR notation.
    WithdrawByoipCidr -> Text
cidr :: Prelude.Text
  }
  deriving (WithdrawByoipCidr -> WithdrawByoipCidr -> Bool
(WithdrawByoipCidr -> WithdrawByoipCidr -> Bool)
-> (WithdrawByoipCidr -> WithdrawByoipCidr -> Bool)
-> Eq WithdrawByoipCidr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WithdrawByoipCidr -> WithdrawByoipCidr -> Bool
$c/= :: WithdrawByoipCidr -> WithdrawByoipCidr -> Bool
== :: WithdrawByoipCidr -> WithdrawByoipCidr -> Bool
$c== :: WithdrawByoipCidr -> WithdrawByoipCidr -> Bool
Prelude.Eq, ReadPrec [WithdrawByoipCidr]
ReadPrec WithdrawByoipCidr
Int -> ReadS WithdrawByoipCidr
ReadS [WithdrawByoipCidr]
(Int -> ReadS WithdrawByoipCidr)
-> ReadS [WithdrawByoipCidr]
-> ReadPrec WithdrawByoipCidr
-> ReadPrec [WithdrawByoipCidr]
-> Read WithdrawByoipCidr
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WithdrawByoipCidr]
$creadListPrec :: ReadPrec [WithdrawByoipCidr]
readPrec :: ReadPrec WithdrawByoipCidr
$creadPrec :: ReadPrec WithdrawByoipCidr
readList :: ReadS [WithdrawByoipCidr]
$creadList :: ReadS [WithdrawByoipCidr]
readsPrec :: Int -> ReadS WithdrawByoipCidr
$creadsPrec :: Int -> ReadS WithdrawByoipCidr
Prelude.Read, Int -> WithdrawByoipCidr -> ShowS
[WithdrawByoipCidr] -> ShowS
WithdrawByoipCidr -> String
(Int -> WithdrawByoipCidr -> ShowS)
-> (WithdrawByoipCidr -> String)
-> ([WithdrawByoipCidr] -> ShowS)
-> Show WithdrawByoipCidr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WithdrawByoipCidr] -> ShowS
$cshowList :: [WithdrawByoipCidr] -> ShowS
show :: WithdrawByoipCidr -> String
$cshow :: WithdrawByoipCidr -> String
showsPrec :: Int -> WithdrawByoipCidr -> ShowS
$cshowsPrec :: Int -> WithdrawByoipCidr -> ShowS
Prelude.Show, (forall x. WithdrawByoipCidr -> Rep WithdrawByoipCidr x)
-> (forall x. Rep WithdrawByoipCidr x -> WithdrawByoipCidr)
-> Generic WithdrawByoipCidr
forall x. Rep WithdrawByoipCidr x -> WithdrawByoipCidr
forall x. WithdrawByoipCidr -> Rep WithdrawByoipCidr x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WithdrawByoipCidr x -> WithdrawByoipCidr
$cfrom :: forall x. WithdrawByoipCidr -> Rep WithdrawByoipCidr x
Prelude.Generic)

-- |
-- Create a value of 'WithdrawByoipCidr' 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', 'withdrawByoipCidr_cidr' - The address range, in CIDR notation.
newWithdrawByoipCidr ::
  -- | 'cidr'
  Prelude.Text ->
  WithdrawByoipCidr
newWithdrawByoipCidr :: Text -> WithdrawByoipCidr
newWithdrawByoipCidr Text
pCidr_ =
  WithdrawByoipCidr' :: Text -> WithdrawByoipCidr
WithdrawByoipCidr' {$sel:cidr:WithdrawByoipCidr' :: Text
cidr = Text
pCidr_}

-- | The address range, in CIDR notation.
withdrawByoipCidr_cidr :: Lens.Lens' WithdrawByoipCidr Prelude.Text
withdrawByoipCidr_cidr :: (Text -> f Text) -> WithdrawByoipCidr -> f WithdrawByoipCidr
withdrawByoipCidr_cidr = (WithdrawByoipCidr -> Text)
-> (WithdrawByoipCidr -> Text -> WithdrawByoipCidr)
-> Lens WithdrawByoipCidr WithdrawByoipCidr Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WithdrawByoipCidr' {Text
cidr :: Text
$sel:cidr:WithdrawByoipCidr' :: WithdrawByoipCidr -> Text
cidr} -> Text
cidr) (\s :: WithdrawByoipCidr
s@WithdrawByoipCidr' {} Text
a -> WithdrawByoipCidr
s {$sel:cidr:WithdrawByoipCidr' :: Text
cidr = Text
a} :: WithdrawByoipCidr)

instance Core.AWSRequest WithdrawByoipCidr where
  type
    AWSResponse WithdrawByoipCidr =
      WithdrawByoipCidrResponse
  request :: WithdrawByoipCidr -> Request WithdrawByoipCidr
request = Service -> WithdrawByoipCidr -> Request WithdrawByoipCidr
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy WithdrawByoipCidr
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse WithdrawByoipCidr)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse WithdrawByoipCidr))
-> Logger
-> Service
-> Proxy WithdrawByoipCidr
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse WithdrawByoipCidr)))
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 -> WithdrawByoipCidrResponse
WithdrawByoipCidrResponse'
            (Maybe ByoipCidr -> Int -> WithdrawByoipCidrResponse)
-> Either String (Maybe ByoipCidr)
-> Either String (Int -> WithdrawByoipCidrResponse)
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 -> WithdrawByoipCidrResponse)
-> Either String Int -> Either String WithdrawByoipCidrResponse
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 WithdrawByoipCidr

instance Prelude.NFData WithdrawByoipCidr

instance Core.ToHeaders WithdrawByoipCidr where
  toHeaders :: WithdrawByoipCidr -> ResponseHeaders
toHeaders =
    ResponseHeaders -> WithdrawByoipCidr -> 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.WithdrawByoipCidr" ::
                          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 WithdrawByoipCidr where
  toJSON :: WithdrawByoipCidr -> Value
toJSON WithdrawByoipCidr' {Text
cidr :: Text
$sel:cidr:WithdrawByoipCidr' :: WithdrawByoipCidr -> 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 WithdrawByoipCidr where
  toPath :: WithdrawByoipCidr -> ByteString
toPath = ByteString -> WithdrawByoipCidr -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

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

instance Prelude.NFData WithdrawByoipCidrResponse