{-# 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.IoTThingsGraph.GetFlowTemplate
-- 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)
--
-- Gets the latest version of the @DefinitionDocument@ and
-- @FlowTemplateSummary@ for the specified workflow.
module Amazonka.IoTThingsGraph.GetFlowTemplate
  ( -- * Creating a Request
    GetFlowTemplate (..),
    newGetFlowTemplate,

    -- * Request Lenses
    getFlowTemplate_revisionNumber,
    getFlowTemplate_id,

    -- * Destructuring the Response
    GetFlowTemplateResponse (..),
    newGetFlowTemplateResponse,

    -- * Response Lenses
    getFlowTemplateResponse_description,
    getFlowTemplateResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoTThingsGraph.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:/ 'newGetFlowTemplate' smart constructor.
data GetFlowTemplate = GetFlowTemplate'
  { -- | The number of the workflow revision to retrieve.
    GetFlowTemplate -> Maybe Integer
revisionNumber :: Prelude.Maybe Prelude.Integer,
    -- | The ID of the workflow.
    --
    -- The ID should be in the following format.
    --
    -- @urn:tdm:REGION\/ACCOUNT ID\/default:workflow:WORKFLOWNAME@
    GetFlowTemplate -> Text
id :: Prelude.Text
  }
  deriving (GetFlowTemplate -> GetFlowTemplate -> Bool
(GetFlowTemplate -> GetFlowTemplate -> Bool)
-> (GetFlowTemplate -> GetFlowTemplate -> Bool)
-> Eq GetFlowTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFlowTemplate -> GetFlowTemplate -> Bool
$c/= :: GetFlowTemplate -> GetFlowTemplate -> Bool
== :: GetFlowTemplate -> GetFlowTemplate -> Bool
$c== :: GetFlowTemplate -> GetFlowTemplate -> Bool
Prelude.Eq, ReadPrec [GetFlowTemplate]
ReadPrec GetFlowTemplate
Int -> ReadS GetFlowTemplate
ReadS [GetFlowTemplate]
(Int -> ReadS GetFlowTemplate)
-> ReadS [GetFlowTemplate]
-> ReadPrec GetFlowTemplate
-> ReadPrec [GetFlowTemplate]
-> Read GetFlowTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFlowTemplate]
$creadListPrec :: ReadPrec [GetFlowTemplate]
readPrec :: ReadPrec GetFlowTemplate
$creadPrec :: ReadPrec GetFlowTemplate
readList :: ReadS [GetFlowTemplate]
$creadList :: ReadS [GetFlowTemplate]
readsPrec :: Int -> ReadS GetFlowTemplate
$creadsPrec :: Int -> ReadS GetFlowTemplate
Prelude.Read, Int -> GetFlowTemplate -> ShowS
[GetFlowTemplate] -> ShowS
GetFlowTemplate -> String
(Int -> GetFlowTemplate -> ShowS)
-> (GetFlowTemplate -> String)
-> ([GetFlowTemplate] -> ShowS)
-> Show GetFlowTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFlowTemplate] -> ShowS
$cshowList :: [GetFlowTemplate] -> ShowS
show :: GetFlowTemplate -> String
$cshow :: GetFlowTemplate -> String
showsPrec :: Int -> GetFlowTemplate -> ShowS
$cshowsPrec :: Int -> GetFlowTemplate -> ShowS
Prelude.Show, (forall x. GetFlowTemplate -> Rep GetFlowTemplate x)
-> (forall x. Rep GetFlowTemplate x -> GetFlowTemplate)
-> Generic GetFlowTemplate
forall x. Rep GetFlowTemplate x -> GetFlowTemplate
forall x. GetFlowTemplate -> Rep GetFlowTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetFlowTemplate x -> GetFlowTemplate
$cfrom :: forall x. GetFlowTemplate -> Rep GetFlowTemplate x
Prelude.Generic)

-- |
-- Create a value of 'GetFlowTemplate' 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:
--
-- 'revisionNumber', 'getFlowTemplate_revisionNumber' - The number of the workflow revision to retrieve.
--
-- 'id', 'getFlowTemplate_id' - The ID of the workflow.
--
-- The ID should be in the following format.
--
-- @urn:tdm:REGION\/ACCOUNT ID\/default:workflow:WORKFLOWNAME@
newGetFlowTemplate ::
  -- | 'id'
  Prelude.Text ->
  GetFlowTemplate
newGetFlowTemplate :: Text -> GetFlowTemplate
newGetFlowTemplate Text
pId_ =
  GetFlowTemplate' :: Maybe Integer -> Text -> GetFlowTemplate
GetFlowTemplate'
    { $sel:revisionNumber:GetFlowTemplate' :: Maybe Integer
revisionNumber = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:id:GetFlowTemplate' :: Text
id = Text
pId_
    }

-- | The number of the workflow revision to retrieve.
getFlowTemplate_revisionNumber :: Lens.Lens' GetFlowTemplate (Prelude.Maybe Prelude.Integer)
getFlowTemplate_revisionNumber :: (Maybe Integer -> f (Maybe Integer))
-> GetFlowTemplate -> f GetFlowTemplate
getFlowTemplate_revisionNumber = (GetFlowTemplate -> Maybe Integer)
-> (GetFlowTemplate -> Maybe Integer -> GetFlowTemplate)
-> Lens
     GetFlowTemplate GetFlowTemplate (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFlowTemplate' {Maybe Integer
revisionNumber :: Maybe Integer
$sel:revisionNumber:GetFlowTemplate' :: GetFlowTemplate -> Maybe Integer
revisionNumber} -> Maybe Integer
revisionNumber) (\s :: GetFlowTemplate
s@GetFlowTemplate' {} Maybe Integer
a -> GetFlowTemplate
s {$sel:revisionNumber:GetFlowTemplate' :: Maybe Integer
revisionNumber = Maybe Integer
a} :: GetFlowTemplate)

-- | The ID of the workflow.
--
-- The ID should be in the following format.
--
-- @urn:tdm:REGION\/ACCOUNT ID\/default:workflow:WORKFLOWNAME@
getFlowTemplate_id :: Lens.Lens' GetFlowTemplate Prelude.Text
getFlowTemplate_id :: (Text -> f Text) -> GetFlowTemplate -> f GetFlowTemplate
getFlowTemplate_id = (GetFlowTemplate -> Text)
-> (GetFlowTemplate -> Text -> GetFlowTemplate)
-> Lens GetFlowTemplate GetFlowTemplate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFlowTemplate' {Text
id :: Text
$sel:id:GetFlowTemplate' :: GetFlowTemplate -> Text
id} -> Text
id) (\s :: GetFlowTemplate
s@GetFlowTemplate' {} Text
a -> GetFlowTemplate
s {$sel:id:GetFlowTemplate' :: Text
id = Text
a} :: GetFlowTemplate)

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

instance Prelude.NFData GetFlowTemplate

instance Core.ToHeaders GetFlowTemplate where
  toHeaders :: GetFlowTemplate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetFlowTemplate -> 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
"IotThingsGraphFrontEndService.GetFlowTemplate" ::
                          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 GetFlowTemplate where
  toJSON :: GetFlowTemplate -> Value
toJSON GetFlowTemplate' {Maybe Integer
Text
id :: Text
revisionNumber :: Maybe Integer
$sel:id:GetFlowTemplate' :: GetFlowTemplate -> Text
$sel:revisionNumber:GetFlowTemplate' :: GetFlowTemplate -> Maybe Integer
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"revisionNumber" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
revisionNumber,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)
          ]
      )

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

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

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

-- |
-- Create a value of 'GetFlowTemplateResponse' 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:
--
-- 'description', 'getFlowTemplateResponse_description' - The object that describes the specified workflow.
--
-- 'httpStatus', 'getFlowTemplateResponse_httpStatus' - The response's http status code.
newGetFlowTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetFlowTemplateResponse
newGetFlowTemplateResponse :: Int -> GetFlowTemplateResponse
newGetFlowTemplateResponse Int
pHttpStatus_ =
  GetFlowTemplateResponse' :: Maybe FlowTemplateDescription -> Int -> GetFlowTemplateResponse
GetFlowTemplateResponse'
    { $sel:description:GetFlowTemplateResponse' :: Maybe FlowTemplateDescription
description =
        Maybe FlowTemplateDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetFlowTemplateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The object that describes the specified workflow.
getFlowTemplateResponse_description :: Lens.Lens' GetFlowTemplateResponse (Prelude.Maybe FlowTemplateDescription)
getFlowTemplateResponse_description :: (Maybe FlowTemplateDescription
 -> f (Maybe FlowTemplateDescription))
-> GetFlowTemplateResponse -> f GetFlowTemplateResponse
getFlowTemplateResponse_description = (GetFlowTemplateResponse -> Maybe FlowTemplateDescription)
-> (GetFlowTemplateResponse
    -> Maybe FlowTemplateDescription -> GetFlowTemplateResponse)
-> Lens
     GetFlowTemplateResponse
     GetFlowTemplateResponse
     (Maybe FlowTemplateDescription)
     (Maybe FlowTemplateDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFlowTemplateResponse' {Maybe FlowTemplateDescription
description :: Maybe FlowTemplateDescription
$sel:description:GetFlowTemplateResponse' :: GetFlowTemplateResponse -> Maybe FlowTemplateDescription
description} -> Maybe FlowTemplateDescription
description) (\s :: GetFlowTemplateResponse
s@GetFlowTemplateResponse' {} Maybe FlowTemplateDescription
a -> GetFlowTemplateResponse
s {$sel:description:GetFlowTemplateResponse' :: Maybe FlowTemplateDescription
description = Maybe FlowTemplateDescription
a} :: GetFlowTemplateResponse)

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

instance Prelude.NFData GetFlowTemplateResponse