{-# 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 #-}
module Amazonka.SecurityHub.Types.Country where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Country = Country'
{
Country -> Maybe Text
countryName :: Prelude.Maybe Prelude.Text,
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)
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
}
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)
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
instance Core.ToJSON Country where
toJSON :: Country -> Value
toJSON Country' {Maybe Text
countryCode :: Maybe Text
countryName :: Maybe Text
$sel:countryCode:Country' :: Country -> Maybe Text
$sel:countryName:Country' :: Country -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"CountryName" 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
countryName,
(Text
"CountryCode" 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
countryCode
]
)