{-# 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.GetCrawler
-- 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 metadata for a specified crawler.
module Amazonka.Glue.GetCrawler
  ( -- * Creating a Request
    GetCrawler (..),
    newGetCrawler,

    -- * Request Lenses
    getCrawler_name,

    -- * Destructuring the Response
    GetCrawlerResponse (..),
    newGetCrawlerResponse,

    -- * Response Lenses
    getCrawlerResponse_crawler,
    getCrawlerResponse_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:/ 'newGetCrawler' smart constructor.
data GetCrawler = GetCrawler'
  { -- | The name of the crawler to retrieve metadata for.
    GetCrawler -> Text
name :: Prelude.Text
  }
  deriving (GetCrawler -> GetCrawler -> Bool
(GetCrawler -> GetCrawler -> Bool)
-> (GetCrawler -> GetCrawler -> Bool) -> Eq GetCrawler
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCrawler -> GetCrawler -> Bool
$c/= :: GetCrawler -> GetCrawler -> Bool
== :: GetCrawler -> GetCrawler -> Bool
$c== :: GetCrawler -> GetCrawler -> Bool
Prelude.Eq, ReadPrec [GetCrawler]
ReadPrec GetCrawler
Int -> ReadS GetCrawler
ReadS [GetCrawler]
(Int -> ReadS GetCrawler)
-> ReadS [GetCrawler]
-> ReadPrec GetCrawler
-> ReadPrec [GetCrawler]
-> Read GetCrawler
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCrawler]
$creadListPrec :: ReadPrec [GetCrawler]
readPrec :: ReadPrec GetCrawler
$creadPrec :: ReadPrec GetCrawler
readList :: ReadS [GetCrawler]
$creadList :: ReadS [GetCrawler]
readsPrec :: Int -> ReadS GetCrawler
$creadsPrec :: Int -> ReadS GetCrawler
Prelude.Read, Int -> GetCrawler -> ShowS
[GetCrawler] -> ShowS
GetCrawler -> String
(Int -> GetCrawler -> ShowS)
-> (GetCrawler -> String)
-> ([GetCrawler] -> ShowS)
-> Show GetCrawler
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCrawler] -> ShowS
$cshowList :: [GetCrawler] -> ShowS
show :: GetCrawler -> String
$cshow :: GetCrawler -> String
showsPrec :: Int -> GetCrawler -> ShowS
$cshowsPrec :: Int -> GetCrawler -> ShowS
Prelude.Show, (forall x. GetCrawler -> Rep GetCrawler x)
-> (forall x. Rep GetCrawler x -> GetCrawler) -> Generic GetCrawler
forall x. Rep GetCrawler x -> GetCrawler
forall x. GetCrawler -> Rep GetCrawler x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCrawler x -> GetCrawler
$cfrom :: forall x. GetCrawler -> Rep GetCrawler x
Prelude.Generic)

-- |
-- Create a value of 'GetCrawler' 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:
--
-- 'name', 'getCrawler_name' - The name of the crawler to retrieve metadata for.
newGetCrawler ::
  -- | 'name'
  Prelude.Text ->
  GetCrawler
newGetCrawler :: Text -> GetCrawler
newGetCrawler Text
pName_ = GetCrawler' :: Text -> GetCrawler
GetCrawler' {$sel:name:GetCrawler' :: Text
name = Text
pName_}

-- | The name of the crawler to retrieve metadata for.
getCrawler_name :: Lens.Lens' GetCrawler Prelude.Text
getCrawler_name :: (Text -> f Text) -> GetCrawler -> f GetCrawler
getCrawler_name = (GetCrawler -> Text)
-> (GetCrawler -> Text -> GetCrawler)
-> Lens GetCrawler GetCrawler Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCrawler' {Text
name :: Text
$sel:name:GetCrawler' :: GetCrawler -> Text
name} -> Text
name) (\s :: GetCrawler
s@GetCrawler' {} Text
a -> GetCrawler
s {$sel:name:GetCrawler' :: Text
name = Text
a} :: GetCrawler)

instance Core.AWSRequest GetCrawler where
  type AWSResponse GetCrawler = GetCrawlerResponse
  request :: GetCrawler -> Request GetCrawler
request = Service -> GetCrawler -> Request GetCrawler
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetCrawler
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetCrawler)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetCrawler))
-> Logger
-> Service
-> Proxy GetCrawler
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetCrawler)))
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 Crawler -> Int -> GetCrawlerResponse
GetCrawlerResponse'
            (Maybe Crawler -> Int -> GetCrawlerResponse)
-> Either String (Maybe Crawler)
-> Either String (Int -> GetCrawlerResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Crawler)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Crawler")
            Either String (Int -> GetCrawlerResponse)
-> Either String Int -> Either String GetCrawlerResponse
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 GetCrawler

instance Prelude.NFData GetCrawler

instance Core.ToHeaders GetCrawler where
  toHeaders :: GetCrawler -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetCrawler -> 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.GetCrawler" :: 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 GetCrawler where
  toJSON :: GetCrawler -> Value
toJSON GetCrawler' {Text
name :: Text
$sel:name:GetCrawler' :: GetCrawler -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)]
      )

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

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

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

-- |
-- Create a value of 'GetCrawlerResponse' 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:
--
-- 'crawler', 'getCrawlerResponse_crawler' - The metadata for the specified crawler.
--
-- 'httpStatus', 'getCrawlerResponse_httpStatus' - The response's http status code.
newGetCrawlerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetCrawlerResponse
newGetCrawlerResponse :: Int -> GetCrawlerResponse
newGetCrawlerResponse Int
pHttpStatus_ =
  GetCrawlerResponse' :: Maybe Crawler -> Int -> GetCrawlerResponse
GetCrawlerResponse'
    { $sel:crawler:GetCrawlerResponse' :: Maybe Crawler
crawler = Maybe Crawler
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetCrawlerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The metadata for the specified crawler.
getCrawlerResponse_crawler :: Lens.Lens' GetCrawlerResponse (Prelude.Maybe Crawler)
getCrawlerResponse_crawler :: (Maybe Crawler -> f (Maybe Crawler))
-> GetCrawlerResponse -> f GetCrawlerResponse
getCrawlerResponse_crawler = (GetCrawlerResponse -> Maybe Crawler)
-> (GetCrawlerResponse -> Maybe Crawler -> GetCrawlerResponse)
-> Lens
     GetCrawlerResponse
     GetCrawlerResponse
     (Maybe Crawler)
     (Maybe Crawler)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCrawlerResponse' {Maybe Crawler
crawler :: Maybe Crawler
$sel:crawler:GetCrawlerResponse' :: GetCrawlerResponse -> Maybe Crawler
crawler} -> Maybe Crawler
crawler) (\s :: GetCrawlerResponse
s@GetCrawlerResponse' {} Maybe Crawler
a -> GetCrawlerResponse
s {$sel:crawler:GetCrawlerResponse' :: Maybe Crawler
crawler = Maybe Crawler
a} :: GetCrawlerResponse)

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

instance Prelude.NFData GetCrawlerResponse