{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Athena.Types.Database where

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

-- | Contains metadata information for a database in a data catalog.
--
-- /See:/ 'newDatabase' smart constructor.
data Database = Database'
  { -- | An optional description of the database.
    Database -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | A set of custom key\/value pairs.
    Database -> Maybe (HashMap Text Text)
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of the database.
    Database -> Text
name :: Prelude.Text
  }
  deriving (Database -> Database -> Bool
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]
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
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. 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:
--
-- 'description', 'database_description' - An optional description of the database.
--
-- 'parameters', 'database_parameters' - A set of custom key\/value pairs.
--
-- 'name', 'database_name' - The name of the database.
newDatabase ::
  -- | 'name'
  Prelude.Text ->
  Database
newDatabase :: Text -> Database
newDatabase Text
pName_ =
  Database'
    { $sel:description:Database' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:Database' :: Maybe (HashMap Text Text)
parameters = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Database' :: Text
name = Text
pName_
    }

-- | An optional description of the database.
database_description :: Lens.Lens' Database (Prelude.Maybe Prelude.Text)
database_description :: Lens' Database (Maybe Text)
database_description = 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)

-- | A set of custom key\/value pairs.
database_parameters :: Lens.Lens' Database (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
database_parameters :: Lens' Database (Maybe (HashMap Text Text))
database_parameters = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the database.
database_name :: Lens.Lens' Database Prelude.Text
database_name :: Lens' Database Text
database_name = 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 Data.FromJSON Database where
  parseJSON :: Value -> Parser Database
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Database"
      ( \Object
x ->
          Maybe Text -> Maybe (HashMap Text Text) -> Text -> Database
Database'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Description")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Parameters" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
      )

instance Prelude.Hashable Database where
  hashWithSalt :: Int -> Database -> Int
hashWithSalt Int
_salt Database' {Maybe Text
Maybe (HashMap Text Text)
Text
name :: Text
parameters :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:name:Database' :: Database -> Text
$sel:parameters:Database' :: Database -> Maybe (HashMap Text Text)
$sel:description:Database' :: Database -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
parameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData Database where
  rnf :: Database -> ()
rnf Database' {Maybe Text
Maybe (HashMap Text Text)
Text
name :: Text
parameters :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:name:Database' :: Database -> Text
$sel:parameters:Database' :: Database -> Maybe (HashMap Text Text)
$sel:description:Database' :: Database -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
parameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name