{-# 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.Route53.Types.GeoLocation
-- 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.Route53.Types.GeoLocation where

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

-- | A complex type that contains information about a geographic location.
--
-- /See:/ 'newGeoLocation' smart constructor.
data GeoLocation = GeoLocation'
  { -- | For geolocation resource record sets, the two-letter code for a state of
    -- the United States. Route 53 doesn\'t support any other values for
    -- @SubdivisionCode@. For a list of state abbreviations, see
    -- <https://pe.usps.com/text/pub28/28apb.htm Appendix B: Two–Letter State and Possession Abbreviations>
    -- on the United States Postal Service website.
    --
    -- If you specify @subdivisioncode@, you must also specify @US@ for
    -- @CountryCode@.
    GeoLocation -> Maybe Text
subdivisionCode :: Prelude.Maybe Prelude.Text,
    -- | For geolocation resource record sets, the two-letter code for a country.
    --
    -- Amazon Route 53 uses the two-letter country codes that are specified in
    -- <https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO standard 3166-1 alpha-2>.
    GeoLocation -> Maybe Text
countryCode :: Prelude.Maybe Prelude.Text,
    -- | The two-letter code for the continent.
    --
    -- Amazon Route 53 supports the following continent codes:
    --
    -- -   __AF__: Africa
    --
    -- -   __AN__: Antarctica
    --
    -- -   __AS__: Asia
    --
    -- -   __EU__: Europe
    --
    -- -   __OC__: Oceania
    --
    -- -   __NA__: North America
    --
    -- -   __SA__: South America
    --
    -- Constraint: Specifying @ContinentCode@ with either @CountryCode@ or
    -- @SubdivisionCode@ returns an @InvalidInput@ error.
    GeoLocation -> Maybe Text
continentCode :: Prelude.Maybe Prelude.Text
  }
  deriving (GeoLocation -> GeoLocation -> Bool
(GeoLocation -> GeoLocation -> Bool)
-> (GeoLocation -> GeoLocation -> Bool) -> Eq GeoLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GeoLocation -> GeoLocation -> Bool
$c/= :: GeoLocation -> GeoLocation -> Bool
== :: GeoLocation -> GeoLocation -> Bool
$c== :: GeoLocation -> GeoLocation -> Bool
Prelude.Eq, ReadPrec [GeoLocation]
ReadPrec GeoLocation
Int -> ReadS GeoLocation
ReadS [GeoLocation]
(Int -> ReadS GeoLocation)
-> ReadS [GeoLocation]
-> ReadPrec GeoLocation
-> ReadPrec [GeoLocation]
-> Read GeoLocation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GeoLocation]
$creadListPrec :: ReadPrec [GeoLocation]
readPrec :: ReadPrec GeoLocation
$creadPrec :: ReadPrec GeoLocation
readList :: ReadS [GeoLocation]
$creadList :: ReadS [GeoLocation]
readsPrec :: Int -> ReadS GeoLocation
$creadsPrec :: Int -> ReadS GeoLocation
Prelude.Read, Int -> GeoLocation -> ShowS
[GeoLocation] -> ShowS
GeoLocation -> String
(Int -> GeoLocation -> ShowS)
-> (GeoLocation -> String)
-> ([GeoLocation] -> ShowS)
-> Show GeoLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GeoLocation] -> ShowS
$cshowList :: [GeoLocation] -> ShowS
show :: GeoLocation -> String
$cshow :: GeoLocation -> String
showsPrec :: Int -> GeoLocation -> ShowS
$cshowsPrec :: Int -> GeoLocation -> ShowS
Prelude.Show, (forall x. GeoLocation -> Rep GeoLocation x)
-> (forall x. Rep GeoLocation x -> GeoLocation)
-> Generic GeoLocation
forall x. Rep GeoLocation x -> GeoLocation
forall x. GeoLocation -> Rep GeoLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GeoLocation x -> GeoLocation
$cfrom :: forall x. GeoLocation -> Rep GeoLocation x
Prelude.Generic)

-- |
-- Create a value of 'GeoLocation' 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:
--
-- 'subdivisionCode', 'geoLocation_subdivisionCode' - For geolocation resource record sets, the two-letter code for a state of
-- the United States. Route 53 doesn\'t support any other values for
-- @SubdivisionCode@. For a list of state abbreviations, see
-- <https://pe.usps.com/text/pub28/28apb.htm Appendix B: Two–Letter State and Possession Abbreviations>
-- on the United States Postal Service website.
--
-- If you specify @subdivisioncode@, you must also specify @US@ for
-- @CountryCode@.
--
-- 'countryCode', 'geoLocation_countryCode' - For geolocation resource record sets, the two-letter code for a country.
--
-- Amazon Route 53 uses the two-letter country codes that are specified in
-- <https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO standard 3166-1 alpha-2>.
--
-- 'continentCode', 'geoLocation_continentCode' - The two-letter code for the continent.
--
-- Amazon Route 53 supports the following continent codes:
--
-- -   __AF__: Africa
--
-- -   __AN__: Antarctica
--
-- -   __AS__: Asia
--
-- -   __EU__: Europe
--
-- -   __OC__: Oceania
--
-- -   __NA__: North America
--
-- -   __SA__: South America
--
-- Constraint: Specifying @ContinentCode@ with either @CountryCode@ or
-- @SubdivisionCode@ returns an @InvalidInput@ error.
newGeoLocation ::
  GeoLocation
newGeoLocation :: GeoLocation
newGeoLocation =
  GeoLocation' :: Maybe Text -> Maybe Text -> Maybe Text -> GeoLocation
GeoLocation'
    { $sel:subdivisionCode:GeoLocation' :: Maybe Text
subdivisionCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:countryCode:GeoLocation' :: Maybe Text
countryCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:continentCode:GeoLocation' :: Maybe Text
continentCode = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | For geolocation resource record sets, the two-letter code for a state of
-- the United States. Route 53 doesn\'t support any other values for
-- @SubdivisionCode@. For a list of state abbreviations, see
-- <https://pe.usps.com/text/pub28/28apb.htm Appendix B: Two–Letter State and Possession Abbreviations>
-- on the United States Postal Service website.
--
-- If you specify @subdivisioncode@, you must also specify @US@ for
-- @CountryCode@.
geoLocation_subdivisionCode :: Lens.Lens' GeoLocation (Prelude.Maybe Prelude.Text)
geoLocation_subdivisionCode :: (Maybe Text -> f (Maybe Text)) -> GeoLocation -> f GeoLocation
geoLocation_subdivisionCode = (GeoLocation -> Maybe Text)
-> (GeoLocation -> Maybe Text -> GeoLocation)
-> Lens GeoLocation GeoLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoLocation' {Maybe Text
subdivisionCode :: Maybe Text
$sel:subdivisionCode:GeoLocation' :: GeoLocation -> Maybe Text
subdivisionCode} -> Maybe Text
subdivisionCode) (\s :: GeoLocation
s@GeoLocation' {} Maybe Text
a -> GeoLocation
s {$sel:subdivisionCode:GeoLocation' :: Maybe Text
subdivisionCode = Maybe Text
a} :: GeoLocation)

-- | For geolocation resource record sets, the two-letter code for a country.
--
-- Amazon Route 53 uses the two-letter country codes that are specified in
-- <https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO standard 3166-1 alpha-2>.
geoLocation_countryCode :: Lens.Lens' GeoLocation (Prelude.Maybe Prelude.Text)
geoLocation_countryCode :: (Maybe Text -> f (Maybe Text)) -> GeoLocation -> f GeoLocation
geoLocation_countryCode = (GeoLocation -> Maybe Text)
-> (GeoLocation -> Maybe Text -> GeoLocation)
-> Lens GeoLocation GeoLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoLocation' {Maybe Text
countryCode :: Maybe Text
$sel:countryCode:GeoLocation' :: GeoLocation -> Maybe Text
countryCode} -> Maybe Text
countryCode) (\s :: GeoLocation
s@GeoLocation' {} Maybe Text
a -> GeoLocation
s {$sel:countryCode:GeoLocation' :: Maybe Text
countryCode = Maybe Text
a} :: GeoLocation)

-- | The two-letter code for the continent.
--
-- Amazon Route 53 supports the following continent codes:
--
-- -   __AF__: Africa
--
-- -   __AN__: Antarctica
--
-- -   __AS__: Asia
--
-- -   __EU__: Europe
--
-- -   __OC__: Oceania
--
-- -   __NA__: North America
--
-- -   __SA__: South America
--
-- Constraint: Specifying @ContinentCode@ with either @CountryCode@ or
-- @SubdivisionCode@ returns an @InvalidInput@ error.
geoLocation_continentCode :: Lens.Lens' GeoLocation (Prelude.Maybe Prelude.Text)
geoLocation_continentCode :: (Maybe Text -> f (Maybe Text)) -> GeoLocation -> f GeoLocation
geoLocation_continentCode = (GeoLocation -> Maybe Text)
-> (GeoLocation -> Maybe Text -> GeoLocation)
-> Lens GeoLocation GeoLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoLocation' {Maybe Text
continentCode :: Maybe Text
$sel:continentCode:GeoLocation' :: GeoLocation -> Maybe Text
continentCode} -> Maybe Text
continentCode) (\s :: GeoLocation
s@GeoLocation' {} Maybe Text
a -> GeoLocation
s {$sel:continentCode:GeoLocation' :: Maybe Text
continentCode = Maybe Text
a} :: GeoLocation)

instance Core.FromXML GeoLocation where
  parseXML :: [Node] -> Either String GeoLocation
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Maybe Text -> GeoLocation
GeoLocation'
      (Maybe Text -> Maybe Text -> Maybe Text -> GeoLocation)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Maybe Text -> GeoLocation)
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
"SubdivisionCode")
      Either String (Maybe Text -> Maybe Text -> GeoLocation)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> GeoLocation)
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
"CountryCode")
      Either String (Maybe Text -> GeoLocation)
-> Either String (Maybe Text) -> Either String GeoLocation
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
"ContinentCode")

instance Prelude.Hashable GeoLocation

instance Prelude.NFData GeoLocation

instance Core.ToXML GeoLocation where
  toXML :: GeoLocation -> XML
toXML GeoLocation' {Maybe Text
continentCode :: Maybe Text
countryCode :: Maybe Text
subdivisionCode :: Maybe Text
$sel:continentCode:GeoLocation' :: GeoLocation -> Maybe Text
$sel:countryCode:GeoLocation' :: GeoLocation -> Maybe Text
$sel:subdivisionCode:GeoLocation' :: GeoLocation -> Maybe Text
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"SubdivisionCode" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
subdivisionCode,
        Name
"CountryCode" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
countryCode,
        Name
"ContinentCode" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
continentCode
      ]