amazonka-glue-2.0: gen/Amazonka/Glue/GetDatabase.hs
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
-- Derived from AWS service descriptions, licensed under Apache 2.0.
-- |
-- Module : Amazonka.Glue.GetDatabase
-- Copyright : (c) 2013-2023 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the definition of a specified database.
module Amazonka.Glue.GetDatabase
( -- * Creating a Request
GetDatabase (..),
newGetDatabase,
-- * Request Lenses
getDatabase_catalogId,
getDatabase_name,
-- * Destructuring the Response
GetDatabaseResponse (..),
newGetDatabaseResponse,
-- * Response Lenses
getDatabaseResponse_database,
getDatabaseResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
-- | /See:/ 'newGetDatabase' smart constructor.
data GetDatabase = GetDatabase'
{ -- | The ID of the Data Catalog in which the database resides. If none is
-- provided, the Amazon Web Services account ID is used by default.
catalogId :: Prelude.Maybe Prelude.Text,
-- | The name of the database to retrieve. For Hive compatibility, this
-- should be all lowercase.
name :: Prelude.Text
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'GetDatabase' 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:
--
-- 'catalogId', 'getDatabase_catalogId' - The ID of the Data Catalog in which the database resides. If none is
-- provided, the Amazon Web Services account ID is used by default.
--
-- 'name', 'getDatabase_name' - The name of the database to retrieve. For Hive compatibility, this
-- should be all lowercase.
newGetDatabase ::
-- | 'name'
Prelude.Text ->
GetDatabase
newGetDatabase pName_ =
GetDatabase'
{ catalogId = Prelude.Nothing,
name = pName_
}
-- | The ID of the Data Catalog in which the database resides. If none is
-- provided, the Amazon Web Services account ID is used by default.
getDatabase_catalogId :: Lens.Lens' GetDatabase (Prelude.Maybe Prelude.Text)
getDatabase_catalogId = Lens.lens (\GetDatabase' {catalogId} -> catalogId) (\s@GetDatabase' {} a -> s {catalogId = a} :: GetDatabase)
-- | The name of the database to retrieve. For Hive compatibility, this
-- should be all lowercase.
getDatabase_name :: Lens.Lens' GetDatabase Prelude.Text
getDatabase_name = Lens.lens (\GetDatabase' {name} -> name) (\s@GetDatabase' {} a -> s {name = a} :: GetDatabase)
instance Core.AWSRequest GetDatabase where
type AWSResponse GetDatabase = GetDatabaseResponse
request overrides =
Request.postJSON (overrides defaultService)
response =
Response.receiveJSON
( \s h x ->
GetDatabaseResponse'
Prelude.<$> (x Data..?> "Database")
Prelude.<*> (Prelude.pure (Prelude.fromEnum s))
)
instance Prelude.Hashable GetDatabase where
hashWithSalt _salt GetDatabase' {..} =
_salt
`Prelude.hashWithSalt` catalogId
`Prelude.hashWithSalt` name
instance Prelude.NFData GetDatabase where
rnf GetDatabase' {..} =
Prelude.rnf catalogId
`Prelude.seq` Prelude.rnf name
instance Data.ToHeaders GetDatabase where
toHeaders =
Prelude.const
( Prelude.mconcat
[ "X-Amz-Target"
Data.=# ("AWSGlue.GetDatabase" :: Prelude.ByteString),
"Content-Type"
Data.=# ( "application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON GetDatabase where
toJSON GetDatabase' {..} =
Data.object
( Prelude.catMaybes
[ ("CatalogId" Data..=) Prelude.<$> catalogId,
Prelude.Just ("Name" Data..= name)
]
)
instance Data.ToPath GetDatabase where
toPath = Prelude.const "/"
instance Data.ToQuery GetDatabase where
toQuery = Prelude.const Prelude.mempty
-- | /See:/ 'newGetDatabaseResponse' smart constructor.
data GetDatabaseResponse = GetDatabaseResponse'
{ -- | The definition of the specified database in the Data Catalog.
database :: Prelude.Maybe Database,
-- | The response's http status code.
httpStatus :: Prelude.Int
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'GetDatabaseResponse' 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:
--
-- 'database', 'getDatabaseResponse_database' - The definition of the specified database in the Data Catalog.
--
-- 'httpStatus', 'getDatabaseResponse_httpStatus' - The response's http status code.
newGetDatabaseResponse ::
-- | 'httpStatus'
Prelude.Int ->
GetDatabaseResponse
newGetDatabaseResponse pHttpStatus_ =
GetDatabaseResponse'
{ database = Prelude.Nothing,
httpStatus = pHttpStatus_
}
-- | The definition of the specified database in the Data Catalog.
getDatabaseResponse_database :: Lens.Lens' GetDatabaseResponse (Prelude.Maybe Database)
getDatabaseResponse_database = Lens.lens (\GetDatabaseResponse' {database} -> database) (\s@GetDatabaseResponse' {} a -> s {database = a} :: GetDatabaseResponse)
-- | The response's http status code.
getDatabaseResponse_httpStatus :: Lens.Lens' GetDatabaseResponse Prelude.Int
getDatabaseResponse_httpStatus = Lens.lens (\GetDatabaseResponse' {httpStatus} -> httpStatus) (\s@GetDatabaseResponse' {} a -> s {httpStatus = a} :: GetDatabaseResponse)
instance Prelude.NFData GetDatabaseResponse where
rnf GetDatabaseResponse' {..} =
Prelude.rnf database
`Prelude.seq` Prelude.rnf httpStatus