{-# 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.Lightsail.Types.AvailabilityZone
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Lightsail.Types.AvailabilityZone where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Describes an Availability Zone.
--
-- /See:/ 'newAvailabilityZone' smart constructor.
data AvailabilityZone = AvailabilityZone'
  { -- | The state of the Availability Zone.
    AvailabilityZone -> Maybe Text
state :: Prelude.Maybe Prelude.Text,
    -- | The name of the Availability Zone. The format is @us-east-2a@
    -- (case-sensitive).
    AvailabilityZone -> Maybe Text
zoneName :: Prelude.Maybe Prelude.Text
  }
  deriving (AvailabilityZone -> AvailabilityZone -> Bool
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]
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
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. 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:
--
-- 'state', 'availabilityZone_state' - The state of the Availability Zone.
--
-- 'zoneName', 'availabilityZone_zoneName' - The name of the Availability Zone. The format is @us-east-2a@
-- (case-sensitive).
newAvailabilityZone ::
  AvailabilityZone
newAvailabilityZone :: AvailabilityZone
newAvailabilityZone =
  AvailabilityZone'
    { $sel:state:AvailabilityZone' :: Maybe Text
state = forall a. Maybe a
Prelude.Nothing,
      $sel:zoneName:AvailabilityZone' :: Maybe Text
zoneName = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The name of the Availability Zone. The format is @us-east-2a@
-- (case-sensitive).
availabilityZone_zoneName :: Lens.Lens' AvailabilityZone (Prelude.Maybe Prelude.Text)
availabilityZone_zoneName :: Lens' AvailabilityZone (Maybe Text)
availabilityZone_zoneName = 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)

instance Data.FromJSON AvailabilityZone where
  parseJSON :: Value -> Parser AvailabilityZone
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AvailabilityZone"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> AvailabilityZone
AvailabilityZone'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"state")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"zoneName")
      )

instance Prelude.Hashable AvailabilityZone where
  hashWithSalt :: Int -> AvailabilityZone -> Int
hashWithSalt Int
_salt AvailabilityZone' {Maybe Text
zoneName :: Maybe Text
state :: Maybe Text
$sel:zoneName:AvailabilityZone' :: AvailabilityZone -> Maybe Text
$sel:state:AvailabilityZone' :: AvailabilityZone -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
state
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
zoneName

instance Prelude.NFData AvailabilityZone where
  rnf :: AvailabilityZone -> ()
rnf AvailabilityZone' {Maybe Text
zoneName :: Maybe Text
state :: Maybe Text
$sel:zoneName:AvailabilityZone' :: AvailabilityZone -> Maybe Text
$sel:state:AvailabilityZone' :: AvailabilityZone -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
zoneName