{-# 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.ResourceLocation
-- 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.Lightsail.Types.ResourceLocation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types.RegionName
import qualified Amazonka.Prelude as Prelude

-- | Describes the resource location.
--
-- /See:/ 'newResourceLocation' smart constructor.
data ResourceLocation = ResourceLocation'
  { -- | The AWS Region name.
    ResourceLocation -> Maybe RegionName
regionName :: Prelude.Maybe RegionName,
    -- | The Availability Zone. Follows the format @us-east-2a@ (case-sensitive).
    ResourceLocation -> Maybe Text
availabilityZone :: Prelude.Maybe Prelude.Text
  }
  deriving (ResourceLocation -> ResourceLocation -> Bool
(ResourceLocation -> ResourceLocation -> Bool)
-> (ResourceLocation -> ResourceLocation -> Bool)
-> Eq ResourceLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceLocation -> ResourceLocation -> Bool
$c/= :: ResourceLocation -> ResourceLocation -> Bool
== :: ResourceLocation -> ResourceLocation -> Bool
$c== :: ResourceLocation -> ResourceLocation -> Bool
Prelude.Eq, ReadPrec [ResourceLocation]
ReadPrec ResourceLocation
Int -> ReadS ResourceLocation
ReadS [ResourceLocation]
(Int -> ReadS ResourceLocation)
-> ReadS [ResourceLocation]
-> ReadPrec ResourceLocation
-> ReadPrec [ResourceLocation]
-> Read ResourceLocation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceLocation]
$creadListPrec :: ReadPrec [ResourceLocation]
readPrec :: ReadPrec ResourceLocation
$creadPrec :: ReadPrec ResourceLocation
readList :: ReadS [ResourceLocation]
$creadList :: ReadS [ResourceLocation]
readsPrec :: Int -> ReadS ResourceLocation
$creadsPrec :: Int -> ReadS ResourceLocation
Prelude.Read, Int -> ResourceLocation -> ShowS
[ResourceLocation] -> ShowS
ResourceLocation -> String
(Int -> ResourceLocation -> ShowS)
-> (ResourceLocation -> String)
-> ([ResourceLocation] -> ShowS)
-> Show ResourceLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceLocation] -> ShowS
$cshowList :: [ResourceLocation] -> ShowS
show :: ResourceLocation -> String
$cshow :: ResourceLocation -> String
showsPrec :: Int -> ResourceLocation -> ShowS
$cshowsPrec :: Int -> ResourceLocation -> ShowS
Prelude.Show, (forall x. ResourceLocation -> Rep ResourceLocation x)
-> (forall x. Rep ResourceLocation x -> ResourceLocation)
-> Generic ResourceLocation
forall x. Rep ResourceLocation x -> ResourceLocation
forall x. ResourceLocation -> Rep ResourceLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceLocation x -> ResourceLocation
$cfrom :: forall x. ResourceLocation -> Rep ResourceLocation x
Prelude.Generic)

-- |
-- Create a value of 'ResourceLocation' 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:
--
-- 'regionName', 'resourceLocation_regionName' - The AWS Region name.
--
-- 'availabilityZone', 'resourceLocation_availabilityZone' - The Availability Zone. Follows the format @us-east-2a@ (case-sensitive).
newResourceLocation ::
  ResourceLocation
newResourceLocation :: ResourceLocation
newResourceLocation =
  ResourceLocation' :: Maybe RegionName -> Maybe Text -> ResourceLocation
ResourceLocation'
    { $sel:regionName:ResourceLocation' :: Maybe RegionName
regionName = Maybe RegionName
forall a. Maybe a
Prelude.Nothing,
      $sel:availabilityZone:ResourceLocation' :: Maybe Text
availabilityZone = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The AWS Region name.
resourceLocation_regionName :: Lens.Lens' ResourceLocation (Prelude.Maybe RegionName)
resourceLocation_regionName :: (Maybe RegionName -> f (Maybe RegionName))
-> ResourceLocation -> f ResourceLocation
resourceLocation_regionName = (ResourceLocation -> Maybe RegionName)
-> (ResourceLocation -> Maybe RegionName -> ResourceLocation)
-> Lens
     ResourceLocation
     ResourceLocation
     (Maybe RegionName)
     (Maybe RegionName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceLocation' {Maybe RegionName
regionName :: Maybe RegionName
$sel:regionName:ResourceLocation' :: ResourceLocation -> Maybe RegionName
regionName} -> Maybe RegionName
regionName) (\s :: ResourceLocation
s@ResourceLocation' {} Maybe RegionName
a -> ResourceLocation
s {$sel:regionName:ResourceLocation' :: Maybe RegionName
regionName = Maybe RegionName
a} :: ResourceLocation)

-- | The Availability Zone. Follows the format @us-east-2a@ (case-sensitive).
resourceLocation_availabilityZone :: Lens.Lens' ResourceLocation (Prelude.Maybe Prelude.Text)
resourceLocation_availabilityZone :: (Maybe Text -> f (Maybe Text))
-> ResourceLocation -> f ResourceLocation
resourceLocation_availabilityZone = (ResourceLocation -> Maybe Text)
-> (ResourceLocation -> Maybe Text -> ResourceLocation)
-> Lens ResourceLocation ResourceLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceLocation' {Maybe Text
availabilityZone :: Maybe Text
$sel:availabilityZone:ResourceLocation' :: ResourceLocation -> Maybe Text
availabilityZone} -> Maybe Text
availabilityZone) (\s :: ResourceLocation
s@ResourceLocation' {} Maybe Text
a -> ResourceLocation
s {$sel:availabilityZone:ResourceLocation' :: Maybe Text
availabilityZone = Maybe Text
a} :: ResourceLocation)

instance Core.FromJSON ResourceLocation where
  parseJSON :: Value -> Parser ResourceLocation
parseJSON =
    String
-> (Object -> Parser ResourceLocation)
-> Value
-> Parser ResourceLocation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceLocation"
      ( \Object
x ->
          Maybe RegionName -> Maybe Text -> ResourceLocation
ResourceLocation'
            (Maybe RegionName -> Maybe Text -> ResourceLocation)
-> Parser (Maybe RegionName)
-> Parser (Maybe Text -> ResourceLocation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RegionName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"regionName")
            Parser (Maybe Text -> ResourceLocation)
-> Parser (Maybe Text) -> Parser ResourceLocation
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
"availabilityZone")
      )

instance Prelude.Hashable ResourceLocation

instance Prelude.NFData ResourceLocation