{-# 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.ImportCatalogToGlue
-- 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)
--
-- Imports an existing Amazon Athena Data Catalog to Glue.
module Amazonka.Glue.ImportCatalogToGlue
  ( -- * Creating a Request
    ImportCatalogToGlue (..),
    newImportCatalogToGlue,

    -- * Request Lenses
    importCatalogToGlue_catalogId,

    -- * Destructuring the Response
    ImportCatalogToGlueResponse (..),
    newImportCatalogToGlueResponse,

    -- * Response Lenses
    importCatalogToGlueResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newImportCatalogToGlue' smart constructor.
data ImportCatalogToGlue = ImportCatalogToGlue'
  { -- | The ID of the catalog to import. Currently, this should be the Amazon
    -- Web Services account ID.
    ImportCatalogToGlue -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text
  }
  deriving (ImportCatalogToGlue -> ImportCatalogToGlue -> Bool
(ImportCatalogToGlue -> ImportCatalogToGlue -> Bool)
-> (ImportCatalogToGlue -> ImportCatalogToGlue -> Bool)
-> Eq ImportCatalogToGlue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportCatalogToGlue -> ImportCatalogToGlue -> Bool
$c/= :: ImportCatalogToGlue -> ImportCatalogToGlue -> Bool
== :: ImportCatalogToGlue -> ImportCatalogToGlue -> Bool
$c== :: ImportCatalogToGlue -> ImportCatalogToGlue -> Bool
Prelude.Eq, ReadPrec [ImportCatalogToGlue]
ReadPrec ImportCatalogToGlue
Int -> ReadS ImportCatalogToGlue
ReadS [ImportCatalogToGlue]
(Int -> ReadS ImportCatalogToGlue)
-> ReadS [ImportCatalogToGlue]
-> ReadPrec ImportCatalogToGlue
-> ReadPrec [ImportCatalogToGlue]
-> Read ImportCatalogToGlue
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportCatalogToGlue]
$creadListPrec :: ReadPrec [ImportCatalogToGlue]
readPrec :: ReadPrec ImportCatalogToGlue
$creadPrec :: ReadPrec ImportCatalogToGlue
readList :: ReadS [ImportCatalogToGlue]
$creadList :: ReadS [ImportCatalogToGlue]
readsPrec :: Int -> ReadS ImportCatalogToGlue
$creadsPrec :: Int -> ReadS ImportCatalogToGlue
Prelude.Read, Int -> ImportCatalogToGlue -> ShowS
[ImportCatalogToGlue] -> ShowS
ImportCatalogToGlue -> String
(Int -> ImportCatalogToGlue -> ShowS)
-> (ImportCatalogToGlue -> String)
-> ([ImportCatalogToGlue] -> ShowS)
-> Show ImportCatalogToGlue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImportCatalogToGlue] -> ShowS
$cshowList :: [ImportCatalogToGlue] -> ShowS
show :: ImportCatalogToGlue -> String
$cshow :: ImportCatalogToGlue -> String
showsPrec :: Int -> ImportCatalogToGlue -> ShowS
$cshowsPrec :: Int -> ImportCatalogToGlue -> ShowS
Prelude.Show, (forall x. ImportCatalogToGlue -> Rep ImportCatalogToGlue x)
-> (forall x. Rep ImportCatalogToGlue x -> ImportCatalogToGlue)
-> Generic ImportCatalogToGlue
forall x. Rep ImportCatalogToGlue x -> ImportCatalogToGlue
forall x. ImportCatalogToGlue -> Rep ImportCatalogToGlue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImportCatalogToGlue x -> ImportCatalogToGlue
$cfrom :: forall x. ImportCatalogToGlue -> Rep ImportCatalogToGlue x
Prelude.Generic)

-- |
-- Create a value of 'ImportCatalogToGlue' 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', 'importCatalogToGlue_catalogId' - The ID of the catalog to import. Currently, this should be the Amazon
-- Web Services account ID.
newImportCatalogToGlue ::
  ImportCatalogToGlue
newImportCatalogToGlue :: ImportCatalogToGlue
newImportCatalogToGlue =
  ImportCatalogToGlue' :: Maybe Text -> ImportCatalogToGlue
ImportCatalogToGlue' {$sel:catalogId:ImportCatalogToGlue' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The ID of the catalog to import. Currently, this should be the Amazon
-- Web Services account ID.
importCatalogToGlue_catalogId :: Lens.Lens' ImportCatalogToGlue (Prelude.Maybe Prelude.Text)
importCatalogToGlue_catalogId :: (Maybe Text -> f (Maybe Text))
-> ImportCatalogToGlue -> f ImportCatalogToGlue
importCatalogToGlue_catalogId = (ImportCatalogToGlue -> Maybe Text)
-> (ImportCatalogToGlue -> Maybe Text -> ImportCatalogToGlue)
-> Lens
     ImportCatalogToGlue ImportCatalogToGlue (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportCatalogToGlue' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:ImportCatalogToGlue' :: ImportCatalogToGlue -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: ImportCatalogToGlue
s@ImportCatalogToGlue' {} Maybe Text
a -> ImportCatalogToGlue
s {$sel:catalogId:ImportCatalogToGlue' :: Maybe Text
catalogId = Maybe Text
a} :: ImportCatalogToGlue)

instance Core.AWSRequest ImportCatalogToGlue where
  type
    AWSResponse ImportCatalogToGlue =
      ImportCatalogToGlueResponse
  request :: ImportCatalogToGlue -> Request ImportCatalogToGlue
request = Service -> ImportCatalogToGlue -> Request ImportCatalogToGlue
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ImportCatalogToGlue
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ImportCatalogToGlue)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse ImportCatalogToGlue))
-> Logger
-> Service
-> Proxy ImportCatalogToGlue
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ImportCatalogToGlue)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> ImportCatalogToGlueResponse
ImportCatalogToGlueResponse'
            (Int -> ImportCatalogToGlueResponse)
-> Either String Int -> Either String ImportCatalogToGlueResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ImportCatalogToGlue

instance Prelude.NFData ImportCatalogToGlue

instance Core.ToHeaders ImportCatalogToGlue where
  toHeaders :: ImportCatalogToGlue -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ImportCatalogToGlue -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSGlue.ImportCatalogToGlue" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ImportCatalogToGlue where
  toJSON :: ImportCatalogToGlue -> Value
toJSON ImportCatalogToGlue' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:ImportCatalogToGlue' :: ImportCatalogToGlue -> 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]
      )

instance Core.ToPath ImportCatalogToGlue where
  toPath :: ImportCatalogToGlue -> ByteString
toPath = ByteString -> ImportCatalogToGlue -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ImportCatalogToGlue where
  toQuery :: ImportCatalogToGlue -> QueryString
toQuery = QueryString -> ImportCatalogToGlue -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newImportCatalogToGlueResponse' smart constructor.
data ImportCatalogToGlueResponse = ImportCatalogToGlueResponse'
  { -- | The response's http status code.
    ImportCatalogToGlueResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ImportCatalogToGlueResponse -> ImportCatalogToGlueResponse -> Bool
(ImportCatalogToGlueResponse
 -> ImportCatalogToGlueResponse -> Bool)
-> (ImportCatalogToGlueResponse
    -> ImportCatalogToGlueResponse -> Bool)
-> Eq ImportCatalogToGlueResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportCatalogToGlueResponse -> ImportCatalogToGlueResponse -> Bool
$c/= :: ImportCatalogToGlueResponse -> ImportCatalogToGlueResponse -> Bool
== :: ImportCatalogToGlueResponse -> ImportCatalogToGlueResponse -> Bool
$c== :: ImportCatalogToGlueResponse -> ImportCatalogToGlueResponse -> Bool
Prelude.Eq, ReadPrec [ImportCatalogToGlueResponse]
ReadPrec ImportCatalogToGlueResponse
Int -> ReadS ImportCatalogToGlueResponse
ReadS [ImportCatalogToGlueResponse]
(Int -> ReadS ImportCatalogToGlueResponse)
-> ReadS [ImportCatalogToGlueResponse]
-> ReadPrec ImportCatalogToGlueResponse
-> ReadPrec [ImportCatalogToGlueResponse]
-> Read ImportCatalogToGlueResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportCatalogToGlueResponse]
$creadListPrec :: ReadPrec [ImportCatalogToGlueResponse]
readPrec :: ReadPrec ImportCatalogToGlueResponse
$creadPrec :: ReadPrec ImportCatalogToGlueResponse
readList :: ReadS [ImportCatalogToGlueResponse]
$creadList :: ReadS [ImportCatalogToGlueResponse]
readsPrec :: Int -> ReadS ImportCatalogToGlueResponse
$creadsPrec :: Int -> ReadS ImportCatalogToGlueResponse
Prelude.Read, Int -> ImportCatalogToGlueResponse -> ShowS
[ImportCatalogToGlueResponse] -> ShowS
ImportCatalogToGlueResponse -> String
(Int -> ImportCatalogToGlueResponse -> ShowS)
-> (ImportCatalogToGlueResponse -> String)
-> ([ImportCatalogToGlueResponse] -> ShowS)
-> Show ImportCatalogToGlueResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImportCatalogToGlueResponse] -> ShowS
$cshowList :: [ImportCatalogToGlueResponse] -> ShowS
show :: ImportCatalogToGlueResponse -> String
$cshow :: ImportCatalogToGlueResponse -> String
showsPrec :: Int -> ImportCatalogToGlueResponse -> ShowS
$cshowsPrec :: Int -> ImportCatalogToGlueResponse -> ShowS
Prelude.Show, (forall x.
 ImportCatalogToGlueResponse -> Rep ImportCatalogToGlueResponse x)
-> (forall x.
    Rep ImportCatalogToGlueResponse x -> ImportCatalogToGlueResponse)
-> Generic ImportCatalogToGlueResponse
forall x.
Rep ImportCatalogToGlueResponse x -> ImportCatalogToGlueResponse
forall x.
ImportCatalogToGlueResponse -> Rep ImportCatalogToGlueResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ImportCatalogToGlueResponse x -> ImportCatalogToGlueResponse
$cfrom :: forall x.
ImportCatalogToGlueResponse -> Rep ImportCatalogToGlueResponse x
Prelude.Generic)

-- |
-- Create a value of 'ImportCatalogToGlueResponse' 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:
--
-- 'httpStatus', 'importCatalogToGlueResponse_httpStatus' - The response's http status code.
newImportCatalogToGlueResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ImportCatalogToGlueResponse
newImportCatalogToGlueResponse :: Int -> ImportCatalogToGlueResponse
newImportCatalogToGlueResponse Int
pHttpStatus_ =
  ImportCatalogToGlueResponse' :: Int -> ImportCatalogToGlueResponse
ImportCatalogToGlueResponse'
    { $sel:httpStatus:ImportCatalogToGlueResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
importCatalogToGlueResponse_httpStatus :: Lens.Lens' ImportCatalogToGlueResponse Prelude.Int
importCatalogToGlueResponse_httpStatus :: (Int -> f Int)
-> ImportCatalogToGlueResponse -> f ImportCatalogToGlueResponse
importCatalogToGlueResponse_httpStatus = (ImportCatalogToGlueResponse -> Int)
-> (ImportCatalogToGlueResponse
    -> Int -> ImportCatalogToGlueResponse)
-> Lens
     ImportCatalogToGlueResponse ImportCatalogToGlueResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportCatalogToGlueResponse' {Int
httpStatus :: Int
$sel:httpStatus:ImportCatalogToGlueResponse' :: ImportCatalogToGlueResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ImportCatalogToGlueResponse
s@ImportCatalogToGlueResponse' {} Int
a -> ImportCatalogToGlueResponse
s {$sel:httpStatus:ImportCatalogToGlueResponse' :: Int
httpStatus = Int
a} :: ImportCatalogToGlueResponse)

instance Prelude.NFData ImportCatalogToGlueResponse