{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.ByoipCidr
-- 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)
module Amazonka.GlobalAccelerator.Types.ByoipCidr where

import qualified Amazonka.Core as Core
import Amazonka.GlobalAccelerator.Types.ByoipCidrEvent
import Amazonka.GlobalAccelerator.Types.ByoipCidrState
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about an IP address range that is provisioned for use with
-- your AWS resources through bring your own IP address (BYOIP).
--
-- The following describes each BYOIP @State@ that your IP address range
-- can be in.
--
-- -   __PENDING_PROVISIONING__ — You’ve submitted a request to provision
--     an IP address range but it is not yet provisioned with AWS Global
--     Accelerator.
--
-- -   __READY__ — The address range is provisioned with AWS Global
--     Accelerator and can be advertised.
--
-- -   __PENDING_ADVERTISING__ — You’ve submitted a request for AWS Global
--     Accelerator to advertise an address range but it is not yet being
--     advertised.
--
-- -   __ADVERTISING__ — The address range is being advertised by AWS
--     Global Accelerator.
--
-- -   __PENDING_WITHDRAWING__ — You’ve submitted a request to withdraw an
--     address range from being advertised but it is still being advertised
--     by AWS Global Accelerator.
--
-- -   __PENDING_DEPROVISIONING__ — You’ve submitted a request to
--     deprovision an address range from AWS Global Accelerator but it is
--     still provisioned.
--
-- -   __DEPROVISIONED__ — The address range is deprovisioned from AWS
--     Global Accelerator.
--
-- -   __FAILED_PROVISION__ — The request to provision the address range
--     from AWS Global Accelerator was not successful. Please make sure
--     that you provide all of the correct information, and try again. If
--     the request fails a second time, contact AWS support.
--
-- -   __FAILED_ADVERTISING__ — The request for AWS Global Accelerator to
--     advertise the address range was not successful. Please make sure
--     that you provide all of the correct information, and try again. If
--     the request fails a second time, contact AWS support.
--
-- -   __FAILED_WITHDRAW__ — The request to withdraw the address range from
--     advertising by AWS Global Accelerator was not successful. Please
--     make sure that you provide all of the correct information, and try
--     again. If the request fails a second time, contact AWS support.
--
-- -   __FAILED_DEPROVISION__ — The request to deprovision the address
--     range from AWS Global Accelerator was not successful. Please make
--     sure that you provide all of the correct information, and try again.
--     If the request fails a second time, contact AWS support.
--
-- /See:/ 'newByoipCidr' smart constructor.
data ByoipCidr = ByoipCidr'
  { -- | The state of the address pool.
    ByoipCidr -> Maybe ByoipCidrState
state :: Prelude.Maybe ByoipCidrState,
    -- | The address range, in CIDR notation.
    ByoipCidr -> Maybe Text
cidr :: Prelude.Maybe Prelude.Text,
    -- | A history of status changes for an IP address range that you bring to
    -- AWS Global Accelerator through bring your own IP address (BYOIP).
    ByoipCidr -> Maybe [ByoipCidrEvent]
events :: Prelude.Maybe [ByoipCidrEvent]
  }
  deriving (ByoipCidr -> ByoipCidr -> Bool
(ByoipCidr -> ByoipCidr -> Bool)
-> (ByoipCidr -> ByoipCidr -> Bool) -> Eq ByoipCidr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ByoipCidr -> ByoipCidr -> Bool
$c/= :: ByoipCidr -> ByoipCidr -> Bool
== :: ByoipCidr -> ByoipCidr -> Bool
$c== :: ByoipCidr -> ByoipCidr -> Bool
Prelude.Eq, ReadPrec [ByoipCidr]
ReadPrec ByoipCidr
Int -> ReadS ByoipCidr
ReadS [ByoipCidr]
(Int -> ReadS ByoipCidr)
-> ReadS [ByoipCidr]
-> ReadPrec ByoipCidr
-> ReadPrec [ByoipCidr]
-> Read ByoipCidr
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ByoipCidr]
$creadListPrec :: ReadPrec [ByoipCidr]
readPrec :: ReadPrec ByoipCidr
$creadPrec :: ReadPrec ByoipCidr
readList :: ReadS [ByoipCidr]
$creadList :: ReadS [ByoipCidr]
readsPrec :: Int -> ReadS ByoipCidr
$creadsPrec :: Int -> ReadS ByoipCidr
Prelude.Read, Int -> ByoipCidr -> ShowS
[ByoipCidr] -> ShowS
ByoipCidr -> String
(Int -> ByoipCidr -> ShowS)
-> (ByoipCidr -> String)
-> ([ByoipCidr] -> ShowS)
-> Show ByoipCidr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ByoipCidr] -> ShowS
$cshowList :: [ByoipCidr] -> ShowS
show :: ByoipCidr -> String
$cshow :: ByoipCidr -> String
showsPrec :: Int -> ByoipCidr -> ShowS
$cshowsPrec :: Int -> ByoipCidr -> ShowS
Prelude.Show, (forall x. ByoipCidr -> Rep ByoipCidr x)
-> (forall x. Rep ByoipCidr x -> ByoipCidr) -> Generic ByoipCidr
forall x. Rep ByoipCidr x -> ByoipCidr
forall x. ByoipCidr -> Rep ByoipCidr x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ByoipCidr x -> ByoipCidr
$cfrom :: forall x. ByoipCidr -> Rep ByoipCidr x
Prelude.Generic)

-- |
-- Create a value of 'ByoipCidr' 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:
--
-- 'state', 'byoipCidr_state' - The state of the address pool.
--
-- 'cidr', 'byoipCidr_cidr' - The address range, in CIDR notation.
--
-- 'events', 'byoipCidr_events' - A history of status changes for an IP address range that you bring to
-- AWS Global Accelerator through bring your own IP address (BYOIP).
newByoipCidr ::
  ByoipCidr
newByoipCidr :: ByoipCidr
newByoipCidr =
  ByoipCidr' :: Maybe ByoipCidrState
-> Maybe Text -> Maybe [ByoipCidrEvent] -> ByoipCidr
ByoipCidr'
    { $sel:state:ByoipCidr' :: Maybe ByoipCidrState
state = Maybe ByoipCidrState
forall a. Maybe a
Prelude.Nothing,
      $sel:cidr:ByoipCidr' :: Maybe Text
cidr = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:events:ByoipCidr' :: Maybe [ByoipCidrEvent]
events = Maybe [ByoipCidrEvent]
forall a. Maybe a
Prelude.Nothing
    }

-- | The state of the address pool.
byoipCidr_state :: Lens.Lens' ByoipCidr (Prelude.Maybe ByoipCidrState)
byoipCidr_state :: (Maybe ByoipCidrState -> f (Maybe ByoipCidrState))
-> ByoipCidr -> f ByoipCidr
byoipCidr_state = (ByoipCidr -> Maybe ByoipCidrState)
-> (ByoipCidr -> Maybe ByoipCidrState -> ByoipCidr)
-> Lens
     ByoipCidr ByoipCidr (Maybe ByoipCidrState) (Maybe ByoipCidrState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ByoipCidr' {Maybe ByoipCidrState
state :: Maybe ByoipCidrState
$sel:state:ByoipCidr' :: ByoipCidr -> Maybe ByoipCidrState
state} -> Maybe ByoipCidrState
state) (\s :: ByoipCidr
s@ByoipCidr' {} Maybe ByoipCidrState
a -> ByoipCidr
s {$sel:state:ByoipCidr' :: Maybe ByoipCidrState
state = Maybe ByoipCidrState
a} :: ByoipCidr)

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

-- | A history of status changes for an IP address range that you bring to
-- AWS Global Accelerator through bring your own IP address (BYOIP).
byoipCidr_events :: Lens.Lens' ByoipCidr (Prelude.Maybe [ByoipCidrEvent])
byoipCidr_events :: (Maybe [ByoipCidrEvent] -> f (Maybe [ByoipCidrEvent]))
-> ByoipCidr -> f ByoipCidr
byoipCidr_events = (ByoipCidr -> Maybe [ByoipCidrEvent])
-> (ByoipCidr -> Maybe [ByoipCidrEvent] -> ByoipCidr)
-> Lens
     ByoipCidr
     ByoipCidr
     (Maybe [ByoipCidrEvent])
     (Maybe [ByoipCidrEvent])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ByoipCidr' {Maybe [ByoipCidrEvent]
events :: Maybe [ByoipCidrEvent]
$sel:events:ByoipCidr' :: ByoipCidr -> Maybe [ByoipCidrEvent]
events} -> Maybe [ByoipCidrEvent]
events) (\s :: ByoipCidr
s@ByoipCidr' {} Maybe [ByoipCidrEvent]
a -> ByoipCidr
s {$sel:events:ByoipCidr' :: Maybe [ByoipCidrEvent]
events = Maybe [ByoipCidrEvent]
a} :: ByoipCidr) ((Maybe [ByoipCidrEvent] -> f (Maybe [ByoipCidrEvent]))
 -> ByoipCidr -> f ByoipCidr)
-> ((Maybe [ByoipCidrEvent] -> f (Maybe [ByoipCidrEvent]))
    -> Maybe [ByoipCidrEvent] -> f (Maybe [ByoipCidrEvent]))
-> (Maybe [ByoipCidrEvent] -> f (Maybe [ByoipCidrEvent]))
-> ByoipCidr
-> f ByoipCidr
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ByoipCidrEvent] [ByoipCidrEvent] [ByoipCidrEvent] [ByoipCidrEvent]
-> Iso
     (Maybe [ByoipCidrEvent])
     (Maybe [ByoipCidrEvent])
     (Maybe [ByoipCidrEvent])
     (Maybe [ByoipCidrEvent])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ByoipCidrEvent] [ByoipCidrEvent] [ByoipCidrEvent] [ByoipCidrEvent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ByoipCidr where
  parseJSON :: Value -> Parser ByoipCidr
parseJSON =
    String -> (Object -> Parser ByoipCidr) -> Value -> Parser ByoipCidr
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ByoipCidr"
      ( \Object
x ->
          Maybe ByoipCidrState
-> Maybe Text -> Maybe [ByoipCidrEvent] -> ByoipCidr
ByoipCidr'
            (Maybe ByoipCidrState
 -> Maybe Text -> Maybe [ByoipCidrEvent] -> ByoipCidr)
-> Parser (Maybe ByoipCidrState)
-> Parser (Maybe Text -> Maybe [ByoipCidrEvent] -> ByoipCidr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ByoipCidrState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser (Maybe Text -> Maybe [ByoipCidrEvent] -> ByoipCidr)
-> Parser (Maybe Text)
-> Parser (Maybe [ByoipCidrEvent] -> ByoipCidr)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Cidr")
            Parser (Maybe [ByoipCidrEvent] -> ByoipCidr)
-> Parser (Maybe [ByoipCidrEvent]) -> Parser ByoipCidr
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [ByoipCidrEvent]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Events" Parser (Maybe (Maybe [ByoipCidrEvent]))
-> Maybe [ByoipCidrEvent] -> Parser (Maybe [ByoipCidrEvent])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ByoipCidrEvent]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ByoipCidr

instance Prelude.NFData ByoipCidr