{-# 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.LakeFormation.Types.DatabaseResource where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data DatabaseResource = DatabaseResource'
{
DatabaseResource -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
DatabaseResource -> Text
name :: Prelude.Text
}
deriving (DatabaseResource -> DatabaseResource -> Bool
(DatabaseResource -> DatabaseResource -> Bool)
-> (DatabaseResource -> DatabaseResource -> Bool)
-> Eq DatabaseResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DatabaseResource -> DatabaseResource -> Bool
$c/= :: DatabaseResource -> DatabaseResource -> Bool
== :: DatabaseResource -> DatabaseResource -> Bool
$c== :: DatabaseResource -> DatabaseResource -> Bool
Prelude.Eq, ReadPrec [DatabaseResource]
ReadPrec DatabaseResource
Int -> ReadS DatabaseResource
ReadS [DatabaseResource]
(Int -> ReadS DatabaseResource)
-> ReadS [DatabaseResource]
-> ReadPrec DatabaseResource
-> ReadPrec [DatabaseResource]
-> Read DatabaseResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DatabaseResource]
$creadListPrec :: ReadPrec [DatabaseResource]
readPrec :: ReadPrec DatabaseResource
$creadPrec :: ReadPrec DatabaseResource
readList :: ReadS [DatabaseResource]
$creadList :: ReadS [DatabaseResource]
readsPrec :: Int -> ReadS DatabaseResource
$creadsPrec :: Int -> ReadS DatabaseResource
Prelude.Read, Int -> DatabaseResource -> ShowS
[DatabaseResource] -> ShowS
DatabaseResource -> String
(Int -> DatabaseResource -> ShowS)
-> (DatabaseResource -> String)
-> ([DatabaseResource] -> ShowS)
-> Show DatabaseResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DatabaseResource] -> ShowS
$cshowList :: [DatabaseResource] -> ShowS
show :: DatabaseResource -> String
$cshow :: DatabaseResource -> String
showsPrec :: Int -> DatabaseResource -> ShowS
$cshowsPrec :: Int -> DatabaseResource -> ShowS
Prelude.Show, (forall x. DatabaseResource -> Rep DatabaseResource x)
-> (forall x. Rep DatabaseResource x -> DatabaseResource)
-> Generic DatabaseResource
forall x. Rep DatabaseResource x -> DatabaseResource
forall x. DatabaseResource -> Rep DatabaseResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DatabaseResource x -> DatabaseResource
$cfrom :: forall x. DatabaseResource -> Rep DatabaseResource x
Prelude.Generic)
newDatabaseResource ::
Prelude.Text ->
DatabaseResource
newDatabaseResource :: Text -> DatabaseResource
newDatabaseResource Text
pName_ =
DatabaseResource' :: Maybe Text -> Text -> DatabaseResource
DatabaseResource'
{ $sel:catalogId:DatabaseResource' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:name:DatabaseResource' :: Text
name = Text
pName_
}
databaseResource_catalogId :: Lens.Lens' DatabaseResource (Prelude.Maybe Prelude.Text)
databaseResource_catalogId :: (Maybe Text -> f (Maybe Text))
-> DatabaseResource -> f DatabaseResource
databaseResource_catalogId = (DatabaseResource -> Maybe Text)
-> (DatabaseResource -> Maybe Text -> DatabaseResource)
-> Lens DatabaseResource DatabaseResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatabaseResource' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:DatabaseResource' :: DatabaseResource -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: DatabaseResource
s@DatabaseResource' {} Maybe Text
a -> DatabaseResource
s {$sel:catalogId:DatabaseResource' :: Maybe Text
catalogId = Maybe Text
a} :: DatabaseResource)
databaseResource_name :: Lens.Lens' DatabaseResource Prelude.Text
databaseResource_name :: (Text -> f Text) -> DatabaseResource -> f DatabaseResource
databaseResource_name = (DatabaseResource -> Text)
-> (DatabaseResource -> Text -> DatabaseResource)
-> Lens DatabaseResource DatabaseResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatabaseResource' {Text
name :: Text
$sel:name:DatabaseResource' :: DatabaseResource -> Text
name} -> Text
name) (\s :: DatabaseResource
s@DatabaseResource' {} Text
a -> DatabaseResource
s {$sel:name:DatabaseResource' :: Text
name = Text
a} :: DatabaseResource)
instance Core.FromJSON DatabaseResource where
parseJSON :: Value -> Parser DatabaseResource
parseJSON =
String
-> (Object -> Parser DatabaseResource)
-> Value
-> Parser DatabaseResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"DatabaseResource"
( \Object
x ->
Maybe Text -> Text -> DatabaseResource
DatabaseResource'
(Maybe Text -> Text -> DatabaseResource)
-> Parser (Maybe Text) -> Parser (Text -> DatabaseResource)
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
"CatalogId")
Parser (Text -> DatabaseResource)
-> Parser Text -> Parser DatabaseResource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
)
instance Prelude.Hashable DatabaseResource
instance Prelude.NFData DatabaseResource
instance Core.ToJSON DatabaseResource where
toJSON :: DatabaseResource -> Value
toJSON DatabaseResource' {Maybe Text
Text
name :: Text
catalogId :: Maybe Text
$sel:name:DatabaseResource' :: DatabaseResource -> Text
$sel:catalogId:DatabaseResource' :: DatabaseResource -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"CatalogId" 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
catalogId,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
]
)