{-# 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.SecurityHub.Types.City
-- 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.SecurityHub.Types.City where

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

-- | Information about a city.
--
-- /See:/ 'newCity' smart constructor.
data City = City'
  { -- | The name of the city.
    City -> Maybe Text
cityName :: Prelude.Maybe Prelude.Text
  }
  deriving (City -> City -> Bool
(City -> City -> Bool) -> (City -> City -> Bool) -> Eq City
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: City -> City -> Bool
$c/= :: City -> City -> Bool
== :: City -> City -> Bool
$c== :: City -> City -> Bool
Prelude.Eq, ReadPrec [City]
ReadPrec City
Int -> ReadS City
ReadS [City]
(Int -> ReadS City)
-> ReadS [City] -> ReadPrec City -> ReadPrec [City] -> Read City
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [City]
$creadListPrec :: ReadPrec [City]
readPrec :: ReadPrec City
$creadPrec :: ReadPrec City
readList :: ReadS [City]
$creadList :: ReadS [City]
readsPrec :: Int -> ReadS City
$creadsPrec :: Int -> ReadS City
Prelude.Read, Int -> City -> ShowS
[City] -> ShowS
City -> String
(Int -> City -> ShowS)
-> (City -> String) -> ([City] -> ShowS) -> Show City
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [City] -> ShowS
$cshowList :: [City] -> ShowS
show :: City -> String
$cshow :: City -> String
showsPrec :: Int -> City -> ShowS
$cshowsPrec :: Int -> City -> ShowS
Prelude.Show, (forall x. City -> Rep City x)
-> (forall x. Rep City x -> City) -> Generic City
forall x. Rep City x -> City
forall x. City -> Rep City x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep City x -> City
$cfrom :: forall x. City -> Rep City x
Prelude.Generic)

-- |
-- Create a value of 'City' 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:
--
-- 'cityName', 'city_cityName' - The name of the city.
newCity ::
  City
newCity :: City
newCity = City' :: Maybe Text -> City
City' {$sel:cityName:City' :: Maybe Text
cityName = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The name of the city.
city_cityName :: Lens.Lens' City (Prelude.Maybe Prelude.Text)
city_cityName :: (Maybe Text -> f (Maybe Text)) -> City -> f City
city_cityName = (City -> Maybe Text)
-> (City -> Maybe Text -> City)
-> Lens City City (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\City' {Maybe Text
cityName :: Maybe Text
$sel:cityName:City' :: City -> Maybe Text
cityName} -> Maybe Text
cityName) (\s :: City
s@City' {} Maybe Text
a -> City
s {$sel:cityName:City' :: Maybe Text
cityName = Maybe Text
a} :: City)

instance Core.FromJSON City where
  parseJSON :: Value -> Parser City
parseJSON =
    String -> (Object -> Parser City) -> Value -> Parser City
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"City"
      (\Object
x -> Maybe Text -> City
City' (Maybe Text -> City) -> Parser (Maybe Text) -> Parser City
forall (f :: * -> *) a b. Functor 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
"CityName"))

instance Prelude.Hashable City

instance Prelude.NFData City

instance Core.ToJSON City where
  toJSON :: City -> Value
toJSON City' {Maybe Text
cityName :: Maybe Text
$sel:cityName:City' :: City -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"CityName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
cityName]
      )