{-# 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.Athena.Types.Database
-- 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.Athena.Types.Database where

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

-- | Contains metadata information for a database in a data catalog.
--
-- /See:/ 'newDatabase' smart constructor.
data Database = Database'
  { -- | A set of custom key\/value pairs.
    Database -> Maybe (HashMap Text Text)
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | An optional description of the database.
    Database -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of the database.
    Database -> Text
name :: Prelude.Text
  }
  deriving (Database -> Database -> Bool
(Database -> Database -> Bool)
-> (Database -> Database -> Bool) -> Eq Database
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Database -> Database -> Bool
$c/= :: Database -> Database -> Bool
== :: Database -> Database -> Bool
$c== :: Database -> Database -> Bool
Prelude.Eq, ReadPrec [Database]
ReadPrec Database
Int -> ReadS Database
ReadS [Database]
(Int -> ReadS Database)
-> ReadS [Database]
-> ReadPrec Database
-> ReadPrec [Database]
-> Read Database
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Database]
$creadListPrec :: ReadPrec [Database]
readPrec :: ReadPrec Database
$creadPrec :: ReadPrec Database
readList :: ReadS [Database]
$creadList :: ReadS [Database]
readsPrec :: Int -> ReadS Database
$creadsPrec :: Int -> ReadS Database
Prelude.Read, Int -> Database -> ShowS
[Database] -> ShowS
Database -> String
(Int -> Database -> ShowS)
-> (Database -> String) -> ([Database] -> ShowS) -> Show Database
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Database] -> ShowS
$cshowList :: [Database] -> ShowS
show :: Database -> String
$cshow :: Database -> String
showsPrec :: Int -> Database -> ShowS
$cshowsPrec :: Int -> Database -> ShowS
Prelude.Show, (forall x. Database -> Rep Database x)
-> (forall x. Rep Database x -> Database) -> Generic Database
forall x. Rep Database x -> Database
forall x. Database -> Rep Database x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Database x -> Database
$cfrom :: forall x. Database -> Rep Database x
Prelude.Generic)

-- |
-- Create a value of 'Database' 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:
--
-- 'parameters', 'database_parameters' - A set of custom key\/value pairs.
--
-- 'description', 'database_description' - An optional description of the database.
--
-- 'name', 'database_name' - The name of the database.
newDatabase ::
  -- | 'name'
  Prelude.Text ->
  Database
newDatabase :: Text -> Database
newDatabase Text
pName_ =
  Database' :: Maybe (HashMap Text Text) -> Maybe Text -> Text -> Database
Database'
    { $sel:parameters:Database' :: Maybe (HashMap Text Text)
parameters = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:description:Database' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Database' :: Text
name = Text
pName_
    }

-- | A set of custom key\/value pairs.
database_parameters :: Lens.Lens' Database (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
database_parameters :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Database -> f Database
database_parameters = (Database -> Maybe (HashMap Text Text))
-> (Database -> Maybe (HashMap Text Text) -> Database)
-> Lens
     Database
     Database
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Database' {Maybe (HashMap Text Text)
parameters :: Maybe (HashMap Text Text)
$sel:parameters:Database' :: Database -> Maybe (HashMap Text Text)
parameters} -> Maybe (HashMap Text Text)
parameters) (\s :: Database
s@Database' {} Maybe (HashMap Text Text)
a -> Database
s {$sel:parameters:Database' :: Maybe (HashMap Text Text)
parameters = Maybe (HashMap Text Text)
a} :: Database) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> Database -> f Database)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Database
-> f Database
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An optional description of the database.
database_description :: Lens.Lens' Database (Prelude.Maybe Prelude.Text)
database_description :: (Maybe Text -> f (Maybe Text)) -> Database -> f Database
database_description = (Database -> Maybe Text)
-> (Database -> Maybe Text -> Database)
-> Lens Database Database (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Database' {Maybe Text
description :: Maybe Text
$sel:description:Database' :: Database -> Maybe Text
description} -> Maybe Text
description) (\s :: Database
s@Database' {} Maybe Text
a -> Database
s {$sel:description:Database' :: Maybe Text
description = Maybe Text
a} :: Database)

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

instance Core.FromJSON Database where
  parseJSON :: Value -> Parser Database
parseJSON =
    String -> (Object -> Parser Database) -> Value -> Parser Database
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Database"
      ( \Object
x ->
          Maybe (HashMap Text Text) -> Maybe Text -> Text -> Database
Database'
            (Maybe (HashMap Text Text) -> Maybe Text -> Text -> Database)
-> Parser (Maybe (HashMap Text Text))
-> Parser (Maybe Text -> Text -> Database)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Parameters" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Text -> Database)
-> Parser (Maybe Text) -> Parser (Text -> Database)
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
"Description")
            Parser (Text -> Database) -> Parser Text -> Parser Database
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 Database

instance Prelude.NFData Database