{-# 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.GetCatalogImportStatus
-- 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)
--
-- Retrieves the status of a migration operation.
module Amazonka.Glue.GetCatalogImportStatus
  ( -- * Creating a Request
    GetCatalogImportStatus (..),
    newGetCatalogImportStatus,

    -- * Request Lenses
    getCatalogImportStatus_catalogId,

    -- * Destructuring the Response
    GetCatalogImportStatusResponse (..),
    newGetCatalogImportStatusResponse,

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

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

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

instance Core.AWSRequest GetCatalogImportStatus where
  type
    AWSResponse GetCatalogImportStatus =
      GetCatalogImportStatusResponse
  request :: GetCatalogImportStatus -> Request GetCatalogImportStatus
request = Service -> GetCatalogImportStatus -> Request GetCatalogImportStatus
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetCatalogImportStatus
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetCatalogImportStatus)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetCatalogImportStatus))
-> Logger
-> Service
-> Proxy GetCatalogImportStatus
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetCatalogImportStatus)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe CatalogImportStatus -> Int -> GetCatalogImportStatusResponse
GetCatalogImportStatusResponse'
            (Maybe CatalogImportStatus
 -> Int -> GetCatalogImportStatusResponse)
-> Either String (Maybe CatalogImportStatus)
-> Either String (Int -> GetCatalogImportStatusResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe CatalogImportStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ImportStatus")
            Either String (Int -> GetCatalogImportStatusResponse)
-> Either String Int
-> Either String GetCatalogImportStatusResponse
forall (f :: * -> *) a b. Applicative f => 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 GetCatalogImportStatus

instance Prelude.NFData GetCatalogImportStatus

instance Core.ToHeaders GetCatalogImportStatus where
  toHeaders :: GetCatalogImportStatus -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetCatalogImportStatus -> 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.GetCatalogImportStatus" ::
                          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 GetCatalogImportStatus where
  toJSON :: GetCatalogImportStatus -> Value
toJSON GetCatalogImportStatus' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:GetCatalogImportStatus' :: GetCatalogImportStatus -> 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 GetCatalogImportStatus where
  toPath :: GetCatalogImportStatus -> ByteString
toPath = ByteString -> GetCatalogImportStatus -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'GetCatalogImportStatusResponse' 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:
--
-- 'importStatus', 'getCatalogImportStatusResponse_importStatus' - The status of the specified catalog migration.
--
-- 'httpStatus', 'getCatalogImportStatusResponse_httpStatus' - The response's http status code.
newGetCatalogImportStatusResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetCatalogImportStatusResponse
newGetCatalogImportStatusResponse :: Int -> GetCatalogImportStatusResponse
newGetCatalogImportStatusResponse Int
pHttpStatus_ =
  GetCatalogImportStatusResponse' :: Maybe CatalogImportStatus -> Int -> GetCatalogImportStatusResponse
GetCatalogImportStatusResponse'
    { $sel:importStatus:GetCatalogImportStatusResponse' :: Maybe CatalogImportStatus
importStatus =
        Maybe CatalogImportStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetCatalogImportStatusResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status of the specified catalog migration.
getCatalogImportStatusResponse_importStatus :: Lens.Lens' GetCatalogImportStatusResponse (Prelude.Maybe CatalogImportStatus)
getCatalogImportStatusResponse_importStatus :: (Maybe CatalogImportStatus -> f (Maybe CatalogImportStatus))
-> GetCatalogImportStatusResponse
-> f GetCatalogImportStatusResponse
getCatalogImportStatusResponse_importStatus = (GetCatalogImportStatusResponse -> Maybe CatalogImportStatus)
-> (GetCatalogImportStatusResponse
    -> Maybe CatalogImportStatus -> GetCatalogImportStatusResponse)
-> Lens
     GetCatalogImportStatusResponse
     GetCatalogImportStatusResponse
     (Maybe CatalogImportStatus)
     (Maybe CatalogImportStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCatalogImportStatusResponse' {Maybe CatalogImportStatus
importStatus :: Maybe CatalogImportStatus
$sel:importStatus:GetCatalogImportStatusResponse' :: GetCatalogImportStatusResponse -> Maybe CatalogImportStatus
importStatus} -> Maybe CatalogImportStatus
importStatus) (\s :: GetCatalogImportStatusResponse
s@GetCatalogImportStatusResponse' {} Maybe CatalogImportStatus
a -> GetCatalogImportStatusResponse
s {$sel:importStatus:GetCatalogImportStatusResponse' :: Maybe CatalogImportStatus
importStatus = Maybe CatalogImportStatus
a} :: GetCatalogImportStatusResponse)

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

instance
  Prelude.NFData
    GetCatalogImportStatusResponse