{-# 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.GetTrigger
-- 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 definition of a trigger.
module Amazonka.Glue.GetTrigger
  ( -- * Creating a Request
    GetTrigger (..),
    newGetTrigger,

    -- * Request Lenses
    getTrigger_name,

    -- * Destructuring the Response
    GetTriggerResponse (..),
    newGetTriggerResponse,

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

-- |
-- Create a value of 'GetTrigger' 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', 'getTrigger_name' - The name of the trigger to retrieve.
newGetTrigger ::
  -- | 'name'
  Prelude.Text ->
  GetTrigger
newGetTrigger :: Text -> GetTrigger
newGetTrigger Text
pName_ = GetTrigger' :: Text -> GetTrigger
GetTrigger' {$sel:name:GetTrigger' :: Text
name = Text
pName_}

-- | The name of the trigger to retrieve.
getTrigger_name :: Lens.Lens' GetTrigger Prelude.Text
getTrigger_name :: (Text -> f Text) -> GetTrigger -> f GetTrigger
getTrigger_name = (GetTrigger -> Text)
-> (GetTrigger -> Text -> GetTrigger)
-> Lens GetTrigger GetTrigger Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTrigger' {Text
name :: Text
$sel:name:GetTrigger' :: GetTrigger -> Text
name} -> Text
name) (\s :: GetTrigger
s@GetTrigger' {} Text
a -> GetTrigger
s {$sel:name:GetTrigger' :: Text
name = Text
a} :: GetTrigger)

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

instance Prelude.NFData GetTrigger

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

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

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

-- |
-- Create a value of 'GetTriggerResponse' 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:
--
-- 'trigger', 'getTriggerResponse_trigger' - The requested trigger definition.
--
-- 'httpStatus', 'getTriggerResponse_httpStatus' - The response's http status code.
newGetTriggerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetTriggerResponse
newGetTriggerResponse :: Int -> GetTriggerResponse
newGetTriggerResponse Int
pHttpStatus_ =
  GetTriggerResponse' :: Maybe Trigger -> Int -> GetTriggerResponse
GetTriggerResponse'
    { $sel:trigger:GetTriggerResponse' :: Maybe Trigger
trigger = Maybe Trigger
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetTriggerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The requested trigger definition.
getTriggerResponse_trigger :: Lens.Lens' GetTriggerResponse (Prelude.Maybe Trigger)
getTriggerResponse_trigger :: (Maybe Trigger -> f (Maybe Trigger))
-> GetTriggerResponse -> f GetTriggerResponse
getTriggerResponse_trigger = (GetTriggerResponse -> Maybe Trigger)
-> (GetTriggerResponse -> Maybe Trigger -> GetTriggerResponse)
-> Lens
     GetTriggerResponse
     GetTriggerResponse
     (Maybe Trigger)
     (Maybe Trigger)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTriggerResponse' {Maybe Trigger
trigger :: Maybe Trigger
$sel:trigger:GetTriggerResponse' :: GetTriggerResponse -> Maybe Trigger
trigger} -> Maybe Trigger
trigger) (\s :: GetTriggerResponse
s@GetTriggerResponse' {} Maybe Trigger
a -> GetTriggerResponse
s {$sel:trigger:GetTriggerResponse' :: Maybe Trigger
trigger = Maybe Trigger
a} :: GetTriggerResponse)

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

instance Prelude.NFData GetTriggerResponse