{-# 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.MacieV2.Types.IpCity
-- 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.MacieV2.Types.IpCity where

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

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

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

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

instance Core.FromJSON IpCity where
  parseJSON :: Value -> Parser IpCity
parseJSON =
    String -> (Object -> Parser IpCity) -> Value -> Parser IpCity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IpCity"
      (\Object
x -> Maybe Text -> IpCity
IpCity' (Maybe Text -> IpCity) -> Parser (Maybe Text) -> Parser IpCity
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
"name"))

instance Prelude.Hashable IpCity

instance Prelude.NFData IpCity