{-# 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.ELBV2.Types.AvailabilityZone
-- 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.ELBV2.Types.AvailabilityZone where

import qualified Amazonka.Core as Core
import Amazonka.ELBV2.Types.LoadBalancerAddress
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about an Availability Zone.
--
-- /See:/ 'newAvailabilityZone' smart constructor.
data AvailabilityZone = AvailabilityZone'
  { -- | The ID of the subnet. You can specify one subnet per Availability Zone.
    AvailabilityZone -> Maybe Text
subnetId :: Prelude.Maybe Prelude.Text,
    -- | The name of the Availability Zone.
    AvailabilityZone -> Maybe Text
zoneName :: Prelude.Maybe Prelude.Text,
    -- | [Network Load Balancers] If you need static IP addresses for your load
    -- balancer, you can specify one Elastic IP address per Availability Zone
    -- when you create an internal-facing load balancer. For internal load
    -- balancers, you can specify a private IP address from the IPv4 range of
    -- the subnet.
    AvailabilityZone -> Maybe [LoadBalancerAddress]
loadBalancerAddresses :: Prelude.Maybe [LoadBalancerAddress],
    -- | [Application Load Balancers on Outposts] The ID of the Outpost.
    AvailabilityZone -> Maybe Text
outpostId :: Prelude.Maybe Prelude.Text
  }
  deriving (AvailabilityZone -> AvailabilityZone -> Bool
(AvailabilityZone -> AvailabilityZone -> Bool)
-> (AvailabilityZone -> AvailabilityZone -> Bool)
-> Eq AvailabilityZone
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AvailabilityZone -> AvailabilityZone -> Bool
$c/= :: AvailabilityZone -> AvailabilityZone -> Bool
== :: AvailabilityZone -> AvailabilityZone -> Bool
$c== :: AvailabilityZone -> AvailabilityZone -> Bool
Prelude.Eq, ReadPrec [AvailabilityZone]
ReadPrec AvailabilityZone
Int -> ReadS AvailabilityZone
ReadS [AvailabilityZone]
(Int -> ReadS AvailabilityZone)
-> ReadS [AvailabilityZone]
-> ReadPrec AvailabilityZone
-> ReadPrec [AvailabilityZone]
-> Read AvailabilityZone
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AvailabilityZone]
$creadListPrec :: ReadPrec [AvailabilityZone]
readPrec :: ReadPrec AvailabilityZone
$creadPrec :: ReadPrec AvailabilityZone
readList :: ReadS [AvailabilityZone]
$creadList :: ReadS [AvailabilityZone]
readsPrec :: Int -> ReadS AvailabilityZone
$creadsPrec :: Int -> ReadS AvailabilityZone
Prelude.Read, Int -> AvailabilityZone -> ShowS
[AvailabilityZone] -> ShowS
AvailabilityZone -> String
(Int -> AvailabilityZone -> ShowS)
-> (AvailabilityZone -> String)
-> ([AvailabilityZone] -> ShowS)
-> Show AvailabilityZone
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AvailabilityZone] -> ShowS
$cshowList :: [AvailabilityZone] -> ShowS
show :: AvailabilityZone -> String
$cshow :: AvailabilityZone -> String
showsPrec :: Int -> AvailabilityZone -> ShowS
$cshowsPrec :: Int -> AvailabilityZone -> ShowS
Prelude.Show, (forall x. AvailabilityZone -> Rep AvailabilityZone x)
-> (forall x. Rep AvailabilityZone x -> AvailabilityZone)
-> Generic AvailabilityZone
forall x. Rep AvailabilityZone x -> AvailabilityZone
forall x. AvailabilityZone -> Rep AvailabilityZone x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AvailabilityZone x -> AvailabilityZone
$cfrom :: forall x. AvailabilityZone -> Rep AvailabilityZone x
Prelude.Generic)

-- |
-- Create a value of 'AvailabilityZone' 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:
--
-- 'subnetId', 'availabilityZone_subnetId' - The ID of the subnet. You can specify one subnet per Availability Zone.
--
-- 'zoneName', 'availabilityZone_zoneName' - The name of the Availability Zone.
--
-- 'loadBalancerAddresses', 'availabilityZone_loadBalancerAddresses' - [Network Load Balancers] If you need static IP addresses for your load
-- balancer, you can specify one Elastic IP address per Availability Zone
-- when you create an internal-facing load balancer. For internal load
-- balancers, you can specify a private IP address from the IPv4 range of
-- the subnet.
--
-- 'outpostId', 'availabilityZone_outpostId' - [Application Load Balancers on Outposts] The ID of the Outpost.
newAvailabilityZone ::
  AvailabilityZone
newAvailabilityZone :: AvailabilityZone
newAvailabilityZone =
  AvailabilityZone' :: Maybe Text
-> Maybe Text
-> Maybe [LoadBalancerAddress]
-> Maybe Text
-> AvailabilityZone
AvailabilityZone'
    { $sel:subnetId:AvailabilityZone' :: Maybe Text
subnetId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:zoneName:AvailabilityZone' :: Maybe Text
zoneName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:loadBalancerAddresses:AvailabilityZone' :: Maybe [LoadBalancerAddress]
loadBalancerAddresses = Maybe [LoadBalancerAddress]
forall a. Maybe a
Prelude.Nothing,
      $sel:outpostId:AvailabilityZone' :: Maybe Text
outpostId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the subnet. You can specify one subnet per Availability Zone.
availabilityZone_subnetId :: Lens.Lens' AvailabilityZone (Prelude.Maybe Prelude.Text)
availabilityZone_subnetId :: (Maybe Text -> f (Maybe Text))
-> AvailabilityZone -> f AvailabilityZone
availabilityZone_subnetId = (AvailabilityZone -> Maybe Text)
-> (AvailabilityZone -> Maybe Text -> AvailabilityZone)
-> Lens AvailabilityZone AvailabilityZone (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AvailabilityZone' {Maybe Text
subnetId :: Maybe Text
$sel:subnetId:AvailabilityZone' :: AvailabilityZone -> Maybe Text
subnetId} -> Maybe Text
subnetId) (\s :: AvailabilityZone
s@AvailabilityZone' {} Maybe Text
a -> AvailabilityZone
s {$sel:subnetId:AvailabilityZone' :: Maybe Text
subnetId = Maybe Text
a} :: AvailabilityZone)

-- | The name of the Availability Zone.
availabilityZone_zoneName :: Lens.Lens' AvailabilityZone (Prelude.Maybe Prelude.Text)
availabilityZone_zoneName :: (Maybe Text -> f (Maybe Text))
-> AvailabilityZone -> f AvailabilityZone
availabilityZone_zoneName = (AvailabilityZone -> Maybe Text)
-> (AvailabilityZone -> Maybe Text -> AvailabilityZone)
-> Lens AvailabilityZone AvailabilityZone (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AvailabilityZone' {Maybe Text
zoneName :: Maybe Text
$sel:zoneName:AvailabilityZone' :: AvailabilityZone -> Maybe Text
zoneName} -> Maybe Text
zoneName) (\s :: AvailabilityZone
s@AvailabilityZone' {} Maybe Text
a -> AvailabilityZone
s {$sel:zoneName:AvailabilityZone' :: Maybe Text
zoneName = Maybe Text
a} :: AvailabilityZone)

-- | [Network Load Balancers] If you need static IP addresses for your load
-- balancer, you can specify one Elastic IP address per Availability Zone
-- when you create an internal-facing load balancer. For internal load
-- balancers, you can specify a private IP address from the IPv4 range of
-- the subnet.
availabilityZone_loadBalancerAddresses :: Lens.Lens' AvailabilityZone (Prelude.Maybe [LoadBalancerAddress])
availabilityZone_loadBalancerAddresses :: (Maybe [LoadBalancerAddress] -> f (Maybe [LoadBalancerAddress]))
-> AvailabilityZone -> f AvailabilityZone
availabilityZone_loadBalancerAddresses = (AvailabilityZone -> Maybe [LoadBalancerAddress])
-> (AvailabilityZone
    -> Maybe [LoadBalancerAddress] -> AvailabilityZone)
-> Lens
     AvailabilityZone
     AvailabilityZone
     (Maybe [LoadBalancerAddress])
     (Maybe [LoadBalancerAddress])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AvailabilityZone' {Maybe [LoadBalancerAddress]
loadBalancerAddresses :: Maybe [LoadBalancerAddress]
$sel:loadBalancerAddresses:AvailabilityZone' :: AvailabilityZone -> Maybe [LoadBalancerAddress]
loadBalancerAddresses} -> Maybe [LoadBalancerAddress]
loadBalancerAddresses) (\s :: AvailabilityZone
s@AvailabilityZone' {} Maybe [LoadBalancerAddress]
a -> AvailabilityZone
s {$sel:loadBalancerAddresses:AvailabilityZone' :: Maybe [LoadBalancerAddress]
loadBalancerAddresses = Maybe [LoadBalancerAddress]
a} :: AvailabilityZone) ((Maybe [LoadBalancerAddress] -> f (Maybe [LoadBalancerAddress]))
 -> AvailabilityZone -> f AvailabilityZone)
-> ((Maybe [LoadBalancerAddress]
     -> f (Maybe [LoadBalancerAddress]))
    -> Maybe [LoadBalancerAddress] -> f (Maybe [LoadBalancerAddress]))
-> (Maybe [LoadBalancerAddress] -> f (Maybe [LoadBalancerAddress]))
-> AvailabilityZone
-> f AvailabilityZone
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [LoadBalancerAddress]
  [LoadBalancerAddress]
  [LoadBalancerAddress]
  [LoadBalancerAddress]
-> Iso
     (Maybe [LoadBalancerAddress])
     (Maybe [LoadBalancerAddress])
     (Maybe [LoadBalancerAddress])
     (Maybe [LoadBalancerAddress])
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
  [LoadBalancerAddress]
  [LoadBalancerAddress]
  [LoadBalancerAddress]
  [LoadBalancerAddress]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | [Application Load Balancers on Outposts] The ID of the Outpost.
availabilityZone_outpostId :: Lens.Lens' AvailabilityZone (Prelude.Maybe Prelude.Text)
availabilityZone_outpostId :: (Maybe Text -> f (Maybe Text))
-> AvailabilityZone -> f AvailabilityZone
availabilityZone_outpostId = (AvailabilityZone -> Maybe Text)
-> (AvailabilityZone -> Maybe Text -> AvailabilityZone)
-> Lens AvailabilityZone AvailabilityZone (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AvailabilityZone' {Maybe Text
outpostId :: Maybe Text
$sel:outpostId:AvailabilityZone' :: AvailabilityZone -> Maybe Text
outpostId} -> Maybe Text
outpostId) (\s :: AvailabilityZone
s@AvailabilityZone' {} Maybe Text
a -> AvailabilityZone
s {$sel:outpostId:AvailabilityZone' :: Maybe Text
outpostId = Maybe Text
a} :: AvailabilityZone)

instance Core.FromXML AvailabilityZone where
  parseXML :: [Node] -> Either String AvailabilityZone
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe [LoadBalancerAddress]
-> Maybe Text
-> AvailabilityZone
AvailabilityZone'
      (Maybe Text
 -> Maybe Text
 -> Maybe [LoadBalancerAddress]
 -> Maybe Text
 -> AvailabilityZone)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe [LoadBalancerAddress] -> Maybe Text -> AvailabilityZone)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SubnetId")
      Either
  String
  (Maybe Text
   -> Maybe [LoadBalancerAddress] -> Maybe Text -> AvailabilityZone)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [LoadBalancerAddress] -> Maybe Text -> AvailabilityZone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ZoneName")
      Either
  String
  (Maybe [LoadBalancerAddress] -> Maybe Text -> AvailabilityZone)
-> Either String (Maybe [LoadBalancerAddress])
-> Either String (Maybe Text -> AvailabilityZone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LoadBalancerAddresses"
                      Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [LoadBalancerAddress]))
-> Either String (Maybe [LoadBalancerAddress])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [LoadBalancerAddress])
-> [Node] -> Either String (Maybe [LoadBalancerAddress])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [LoadBalancerAddress]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either String (Maybe Text -> AvailabilityZone)
-> Either String (Maybe Text) -> Either String AvailabilityZone
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"OutpostId")

instance Prelude.Hashable AvailabilityZone

instance Prelude.NFData AvailabilityZone