{-# 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.GetClassifier
-- 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)
--
-- Retrieve a classifier by name.
module Amazonka.Glue.GetClassifier
  ( -- * Creating a Request
    GetClassifier (..),
    newGetClassifier,

    -- * Request Lenses
    getClassifier_name,

    -- * Destructuring the Response
    GetClassifierResponse (..),
    newGetClassifierResponse,

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

-- |
-- Create a value of 'GetClassifier' 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', 'getClassifier_name' - Name of the classifier to retrieve.
newGetClassifier ::
  -- | 'name'
  Prelude.Text ->
  GetClassifier
newGetClassifier :: Text -> GetClassifier
newGetClassifier Text
pName_ =
  GetClassifier' :: Text -> GetClassifier
GetClassifier' {$sel:name:GetClassifier' :: Text
name = Text
pName_}

-- | Name of the classifier to retrieve.
getClassifier_name :: Lens.Lens' GetClassifier Prelude.Text
getClassifier_name :: (Text -> f Text) -> GetClassifier -> f GetClassifier
getClassifier_name = (GetClassifier -> Text)
-> (GetClassifier -> Text -> GetClassifier)
-> Lens GetClassifier GetClassifier Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetClassifier' {Text
name :: Text
$sel:name:GetClassifier' :: GetClassifier -> Text
name} -> Text
name) (\s :: GetClassifier
s@GetClassifier' {} Text
a -> GetClassifier
s {$sel:name:GetClassifier' :: Text
name = Text
a} :: GetClassifier)

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

instance Prelude.NFData GetClassifier

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

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

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

-- |
-- Create a value of 'GetClassifierResponse' 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:
--
-- 'classifier', 'getClassifierResponse_classifier' - The requested classifier.
--
-- 'httpStatus', 'getClassifierResponse_httpStatus' - The response's http status code.
newGetClassifierResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetClassifierResponse
newGetClassifierResponse :: Int -> GetClassifierResponse
newGetClassifierResponse Int
pHttpStatus_ =
  GetClassifierResponse' :: Maybe Classifier -> Int -> GetClassifierResponse
GetClassifierResponse'
    { $sel:classifier:GetClassifierResponse' :: Maybe Classifier
classifier =
        Maybe Classifier
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetClassifierResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The requested classifier.
getClassifierResponse_classifier :: Lens.Lens' GetClassifierResponse (Prelude.Maybe Classifier)
getClassifierResponse_classifier :: (Maybe Classifier -> f (Maybe Classifier))
-> GetClassifierResponse -> f GetClassifierResponse
getClassifierResponse_classifier = (GetClassifierResponse -> Maybe Classifier)
-> (GetClassifierResponse
    -> Maybe Classifier -> GetClassifierResponse)
-> Lens
     GetClassifierResponse
     GetClassifierResponse
     (Maybe Classifier)
     (Maybe Classifier)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetClassifierResponse' {Maybe Classifier
classifier :: Maybe Classifier
$sel:classifier:GetClassifierResponse' :: GetClassifierResponse -> Maybe Classifier
classifier} -> Maybe Classifier
classifier) (\s :: GetClassifierResponse
s@GetClassifierResponse' {} Maybe Classifier
a -> GetClassifierResponse
s {$sel:classifier:GetClassifierResponse' :: Maybe Classifier
classifier = Maybe Classifier
a} :: GetClassifierResponse)

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

instance Prelude.NFData GetClassifierResponse