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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Internal
import Amazonka.Redshift.Types.SupportedPlatform

-- | Describes an availability zone.
--
-- /See:/ 'newAvailabilityZone' smart constructor.
data AvailabilityZone = AvailabilityZone'
  { -- | The name of the availability zone.
    AvailabilityZone -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    AvailabilityZone -> Maybe [SupportedPlatform]
supportedPlatforms :: Prelude.Maybe [SupportedPlatform]
  }
  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:
--
-- 'name', 'availabilityZone_name' - The name of the availability zone.
--
-- 'supportedPlatforms', 'availabilityZone_supportedPlatforms' -
newAvailabilityZone ::
  AvailabilityZone
newAvailabilityZone :: AvailabilityZone
newAvailabilityZone =
  AvailabilityZone' :: Maybe Text -> Maybe [SupportedPlatform] -> AvailabilityZone
AvailabilityZone'
    { $sel:name:AvailabilityZone' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:supportedPlatforms:AvailabilityZone' :: Maybe [SupportedPlatform]
supportedPlatforms = Maybe [SupportedPlatform]
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the availability zone.
availabilityZone_name :: Lens.Lens' AvailabilityZone (Prelude.Maybe Prelude.Text)
availabilityZone_name :: (Maybe Text -> f (Maybe Text))
-> AvailabilityZone -> f AvailabilityZone
availabilityZone_name = (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
name :: Maybe Text
$sel:name:AvailabilityZone' :: AvailabilityZone -> Maybe Text
name} -> Maybe Text
name) (\s :: AvailabilityZone
s@AvailabilityZone' {} Maybe Text
a -> AvailabilityZone
s {$sel:name:AvailabilityZone' :: Maybe Text
name = Maybe Text
a} :: AvailabilityZone)

-- |
availabilityZone_supportedPlatforms :: Lens.Lens' AvailabilityZone (Prelude.Maybe [SupportedPlatform])
availabilityZone_supportedPlatforms :: (Maybe [SupportedPlatform] -> f (Maybe [SupportedPlatform]))
-> AvailabilityZone -> f AvailabilityZone
availabilityZone_supportedPlatforms = (AvailabilityZone -> Maybe [SupportedPlatform])
-> (AvailabilityZone
    -> Maybe [SupportedPlatform] -> AvailabilityZone)
-> Lens
     AvailabilityZone
     AvailabilityZone
     (Maybe [SupportedPlatform])
     (Maybe [SupportedPlatform])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AvailabilityZone' {Maybe [SupportedPlatform]
supportedPlatforms :: Maybe [SupportedPlatform]
$sel:supportedPlatforms:AvailabilityZone' :: AvailabilityZone -> Maybe [SupportedPlatform]
supportedPlatforms} -> Maybe [SupportedPlatform]
supportedPlatforms) (\s :: AvailabilityZone
s@AvailabilityZone' {} Maybe [SupportedPlatform]
a -> AvailabilityZone
s {$sel:supportedPlatforms:AvailabilityZone' :: Maybe [SupportedPlatform]
supportedPlatforms = Maybe [SupportedPlatform]
a} :: AvailabilityZone) ((Maybe [SupportedPlatform] -> f (Maybe [SupportedPlatform]))
 -> AvailabilityZone -> f AvailabilityZone)
-> ((Maybe [SupportedPlatform] -> f (Maybe [SupportedPlatform]))
    -> Maybe [SupportedPlatform] -> f (Maybe [SupportedPlatform]))
-> (Maybe [SupportedPlatform] -> f (Maybe [SupportedPlatform]))
-> AvailabilityZone
-> f AvailabilityZone
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SupportedPlatform]
  [SupportedPlatform]
  [SupportedPlatform]
  [SupportedPlatform]
-> Iso
     (Maybe [SupportedPlatform])
     (Maybe [SupportedPlatform])
     (Maybe [SupportedPlatform])
     (Maybe [SupportedPlatform])
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
  [SupportedPlatform]
  [SupportedPlatform]
  [SupportedPlatform]
  [SupportedPlatform]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML AvailabilityZone where
  parseXML :: [Node] -> Either String AvailabilityZone
parseXML [Node]
x =
    Maybe Text -> Maybe [SupportedPlatform] -> AvailabilityZone
AvailabilityZone'
      (Maybe Text -> Maybe [SupportedPlatform] -> AvailabilityZone)
-> Either String (Maybe Text)
-> Either String (Maybe [SupportedPlatform] -> 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
"Name")
      Either String (Maybe [SupportedPlatform] -> AvailabilityZone)
-> Either String (Maybe [SupportedPlatform])
-> Either String 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
"SupportedPlatforms"
                      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 [SupportedPlatform]))
-> Either String (Maybe [SupportedPlatform])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [SupportedPlatform])
-> [Node] -> Either String (Maybe [SupportedPlatform])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [SupportedPlatform]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"SupportedPlatform")
                  )

instance Prelude.Hashable AvailabilityZone

instance Prelude.NFData AvailabilityZone