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

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

-- | Describes the resource location.
--
-- /See:/ 'newResourceLocation' smart constructor.
data ResourceLocation = ResourceLocation'
  { -- | The Availability Zone. Follows the format @us-east-2a@ (case-sensitive).
    ResourceLocation -> Maybe Text
availabilityZone :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services Region name.
    ResourceLocation -> Maybe RegionName
regionName :: Prelude.Maybe RegionName
  }
  deriving (ResourceLocation -> ResourceLocation -> Bool
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]
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
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. 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:
--
-- 'availabilityZone', 'resourceLocation_availabilityZone' - The Availability Zone. Follows the format @us-east-2a@ (case-sensitive).
--
-- 'regionName', 'resourceLocation_regionName' - The Amazon Web Services Region name.
newResourceLocation ::
  ResourceLocation
newResourceLocation :: ResourceLocation
newResourceLocation =
  ResourceLocation'
    { $sel:availabilityZone:ResourceLocation' :: Maybe Text
availabilityZone =
        forall a. Maybe a
Prelude.Nothing,
      $sel:regionName:ResourceLocation' :: Maybe RegionName
regionName = forall a. Maybe a
Prelude.Nothing
    }

-- | The Availability Zone. Follows the format @us-east-2a@ (case-sensitive).
resourceLocation_availabilityZone :: Lens.Lens' ResourceLocation (Prelude.Maybe Prelude.Text)
resourceLocation_availabilityZone :: Lens' ResourceLocation (Maybe Text)
resourceLocation_availabilityZone = 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)

-- | The Amazon Web Services Region name.
resourceLocation_regionName :: Lens.Lens' ResourceLocation (Prelude.Maybe RegionName)
resourceLocation_regionName :: Lens' ResourceLocation (Maybe RegionName)
resourceLocation_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)

instance Data.FromJSON ResourceLocation where
  parseJSON :: Value -> Parser ResourceLocation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourceLocation"
      ( \Object
x ->
          Maybe Text -> Maybe RegionName -> ResourceLocation
ResourceLocation'
            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
"availabilityZone")
            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
"regionName")
      )

instance Prelude.Hashable ResourceLocation where
  hashWithSalt :: Int -> ResourceLocation -> Int
hashWithSalt Int
_salt ResourceLocation' {Maybe Text
Maybe RegionName
regionName :: Maybe RegionName
availabilityZone :: Maybe Text
$sel:regionName:ResourceLocation' :: ResourceLocation -> Maybe RegionName
$sel:availabilityZone:ResourceLocation' :: ResourceLocation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
availabilityZone
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RegionName
regionName

instance Prelude.NFData ResourceLocation where
  rnf :: ResourceLocation -> ()
rnf ResourceLocation' {Maybe Text
Maybe RegionName
regionName :: Maybe RegionName
availabilityZone :: Maybe Text
$sel:regionName:ResourceLocation' :: ResourceLocation -> Maybe RegionName
$sel:availabilityZone:ResourceLocation' :: ResourceLocation -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
availabilityZone
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RegionName
regionName