{-# 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.GuardDuty.Types.Country
-- 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.GuardDuty.Types.Country where

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

-- | Contains information about the country where the remote IP address is
-- located.
--
-- /See:/ 'newCountry' smart constructor.
data Country = Country'
  { -- | The country name of the remote IP address.
    Country -> Maybe Text
countryName :: Prelude.Maybe Prelude.Text,
    -- | The country code of the remote IP address.
    Country -> Maybe Text
countryCode :: Prelude.Maybe Prelude.Text
  }
  deriving (Country -> Country -> Bool
(Country -> Country -> Bool)
-> (Country -> Country -> Bool) -> Eq Country
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Country -> Country -> Bool
$c/= :: Country -> Country -> Bool
== :: Country -> Country -> Bool
$c== :: Country -> Country -> Bool
Prelude.Eq, ReadPrec [Country]
ReadPrec Country
Int -> ReadS Country
ReadS [Country]
(Int -> ReadS Country)
-> ReadS [Country]
-> ReadPrec Country
-> ReadPrec [Country]
-> Read Country
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Country]
$creadListPrec :: ReadPrec [Country]
readPrec :: ReadPrec Country
$creadPrec :: ReadPrec Country
readList :: ReadS [Country]
$creadList :: ReadS [Country]
readsPrec :: Int -> ReadS Country
$creadsPrec :: Int -> ReadS Country
Prelude.Read, Int -> Country -> ShowS
[Country] -> ShowS
Country -> String
(Int -> Country -> ShowS)
-> (Country -> String) -> ([Country] -> ShowS) -> Show Country
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Country] -> ShowS
$cshowList :: [Country] -> ShowS
show :: Country -> String
$cshow :: Country -> String
showsPrec :: Int -> Country -> ShowS
$cshowsPrec :: Int -> Country -> ShowS
Prelude.Show, (forall x. Country -> Rep Country x)
-> (forall x. Rep Country x -> Country) -> Generic Country
forall x. Rep Country x -> Country
forall x. Country -> Rep Country x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Country x -> Country
$cfrom :: forall x. Country -> Rep Country x
Prelude.Generic)

-- |
-- Create a value of 'Country' 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:
--
-- 'countryName', 'country_countryName' - The country name of the remote IP address.
--
-- 'countryCode', 'country_countryCode' - The country code of the remote IP address.
newCountry ::
  Country
newCountry :: Country
newCountry =
  Country' :: Maybe Text -> Maybe Text -> Country
Country'
    { $sel:countryName:Country' :: Maybe Text
countryName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:countryCode:Country' :: Maybe Text
countryCode = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The country name of the remote IP address.
country_countryName :: Lens.Lens' Country (Prelude.Maybe Prelude.Text)
country_countryName :: (Maybe Text -> f (Maybe Text)) -> Country -> f Country
country_countryName = (Country -> Maybe Text)
-> (Country -> Maybe Text -> Country)
-> Lens Country Country (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Country' {Maybe Text
countryName :: Maybe Text
$sel:countryName:Country' :: Country -> Maybe Text
countryName} -> Maybe Text
countryName) (\s :: Country
s@Country' {} Maybe Text
a -> Country
s {$sel:countryName:Country' :: Maybe Text
countryName = Maybe Text
a} :: Country)

-- | The country code of the remote IP address.
country_countryCode :: Lens.Lens' Country (Prelude.Maybe Prelude.Text)
country_countryCode :: (Maybe Text -> f (Maybe Text)) -> Country -> f Country
country_countryCode = (Country -> Maybe Text)
-> (Country -> Maybe Text -> Country)
-> Lens Country Country (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Country' {Maybe Text
countryCode :: Maybe Text
$sel:countryCode:Country' :: Country -> Maybe Text
countryCode} -> Maybe Text
countryCode) (\s :: Country
s@Country' {} Maybe Text
a -> Country
s {$sel:countryCode:Country' :: Maybe Text
countryCode = Maybe Text
a} :: Country)

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

instance Prelude.Hashable Country

instance Prelude.NFData Country