{-# 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.Transfer.DescribeExecution
-- 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)
--
-- You can use @DescribeExecution@ to check the details of the execution of
-- the specified workflow.
module Amazonka.Transfer.DescribeExecution
  ( -- * Creating a Request
    DescribeExecution (..),
    newDescribeExecution,

    -- * Request Lenses
    describeExecution_executionId,
    describeExecution_workflowId,

    -- * Destructuring the Response
    DescribeExecutionResponse (..),
    newDescribeExecutionResponse,

    -- * Response Lenses
    describeExecutionResponse_httpStatus,
    describeExecutionResponse_workflowId,
    describeExecutionResponse_execution,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Transfer.Types

-- | /See:/ 'newDescribeExecution' smart constructor.
data DescribeExecution = DescribeExecution'
  { -- | A unique identifier for the execution of a workflow.
    DescribeExecution -> Text
executionId :: Prelude.Text,
    -- | A unique identifier for the workflow.
    DescribeExecution -> Text
workflowId :: Prelude.Text
  }
  deriving (DescribeExecution -> DescribeExecution -> Bool
(DescribeExecution -> DescribeExecution -> Bool)
-> (DescribeExecution -> DescribeExecution -> Bool)
-> Eq DescribeExecution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeExecution -> DescribeExecution -> Bool
$c/= :: DescribeExecution -> DescribeExecution -> Bool
== :: DescribeExecution -> DescribeExecution -> Bool
$c== :: DescribeExecution -> DescribeExecution -> Bool
Prelude.Eq, ReadPrec [DescribeExecution]
ReadPrec DescribeExecution
Int -> ReadS DescribeExecution
ReadS [DescribeExecution]
(Int -> ReadS DescribeExecution)
-> ReadS [DescribeExecution]
-> ReadPrec DescribeExecution
-> ReadPrec [DescribeExecution]
-> Read DescribeExecution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeExecution]
$creadListPrec :: ReadPrec [DescribeExecution]
readPrec :: ReadPrec DescribeExecution
$creadPrec :: ReadPrec DescribeExecution
readList :: ReadS [DescribeExecution]
$creadList :: ReadS [DescribeExecution]
readsPrec :: Int -> ReadS DescribeExecution
$creadsPrec :: Int -> ReadS DescribeExecution
Prelude.Read, Int -> DescribeExecution -> ShowS
[DescribeExecution] -> ShowS
DescribeExecution -> String
(Int -> DescribeExecution -> ShowS)
-> (DescribeExecution -> String)
-> ([DescribeExecution] -> ShowS)
-> Show DescribeExecution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeExecution] -> ShowS
$cshowList :: [DescribeExecution] -> ShowS
show :: DescribeExecution -> String
$cshow :: DescribeExecution -> String
showsPrec :: Int -> DescribeExecution -> ShowS
$cshowsPrec :: Int -> DescribeExecution -> ShowS
Prelude.Show, (forall x. DescribeExecution -> Rep DescribeExecution x)
-> (forall x. Rep DescribeExecution x -> DescribeExecution)
-> Generic DescribeExecution
forall x. Rep DescribeExecution x -> DescribeExecution
forall x. DescribeExecution -> Rep DescribeExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeExecution x -> DescribeExecution
$cfrom :: forall x. DescribeExecution -> Rep DescribeExecution x
Prelude.Generic)

-- |
-- Create a value of 'DescribeExecution' 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:
--
-- 'executionId', 'describeExecution_executionId' - A unique identifier for the execution of a workflow.
--
-- 'workflowId', 'describeExecution_workflowId' - A unique identifier for the workflow.
newDescribeExecution ::
  -- | 'executionId'
  Prelude.Text ->
  -- | 'workflowId'
  Prelude.Text ->
  DescribeExecution
newDescribeExecution :: Text -> Text -> DescribeExecution
newDescribeExecution Text
pExecutionId_ Text
pWorkflowId_ =
  DescribeExecution' :: Text -> Text -> DescribeExecution
DescribeExecution'
    { $sel:executionId:DescribeExecution' :: Text
executionId = Text
pExecutionId_,
      $sel:workflowId:DescribeExecution' :: Text
workflowId = Text
pWorkflowId_
    }

-- | A unique identifier for the execution of a workflow.
describeExecution_executionId :: Lens.Lens' DescribeExecution Prelude.Text
describeExecution_executionId :: (Text -> f Text) -> DescribeExecution -> f DescribeExecution
describeExecution_executionId = (DescribeExecution -> Text)
-> (DescribeExecution -> Text -> DescribeExecution)
-> Lens DescribeExecution DescribeExecution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeExecution' {Text
executionId :: Text
$sel:executionId:DescribeExecution' :: DescribeExecution -> Text
executionId} -> Text
executionId) (\s :: DescribeExecution
s@DescribeExecution' {} Text
a -> DescribeExecution
s {$sel:executionId:DescribeExecution' :: Text
executionId = Text
a} :: DescribeExecution)

-- | A unique identifier for the workflow.
describeExecution_workflowId :: Lens.Lens' DescribeExecution Prelude.Text
describeExecution_workflowId :: (Text -> f Text) -> DescribeExecution -> f DescribeExecution
describeExecution_workflowId = (DescribeExecution -> Text)
-> (DescribeExecution -> Text -> DescribeExecution)
-> Lens DescribeExecution DescribeExecution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeExecution' {Text
workflowId :: Text
$sel:workflowId:DescribeExecution' :: DescribeExecution -> Text
workflowId} -> Text
workflowId) (\s :: DescribeExecution
s@DescribeExecution' {} Text
a -> DescribeExecution
s {$sel:workflowId:DescribeExecution' :: Text
workflowId = Text
a} :: DescribeExecution)

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

instance Prelude.Hashable DescribeExecution

instance Prelude.NFData DescribeExecution

instance Core.ToHeaders DescribeExecution where
  toHeaders :: DescribeExecution -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeExecution -> 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
"TransferService.DescribeExecution" ::
                          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 DescribeExecution where
  toJSON :: DescribeExecution -> Value
toJSON DescribeExecution' {Text
workflowId :: Text
executionId :: Text
$sel:workflowId:DescribeExecution' :: DescribeExecution -> Text
$sel:executionId:DescribeExecution' :: DescribeExecution -> 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
"ExecutionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
executionId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"WorkflowId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
workflowId)
          ]
      )

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

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

-- | /See:/ 'newDescribeExecutionResponse' smart constructor.
data DescribeExecutionResponse = DescribeExecutionResponse'
  { -- | The response's http status code.
    DescribeExecutionResponse -> Int
httpStatus :: Prelude.Int,
    -- | A unique identifier for the workflow.
    DescribeExecutionResponse -> Text
workflowId :: Prelude.Text,
    -- | The structure that contains the details of the workflow\' execution.
    DescribeExecutionResponse -> DescribedExecution
execution :: DescribedExecution
  }
  deriving (DescribeExecutionResponse -> DescribeExecutionResponse -> Bool
(DescribeExecutionResponse -> DescribeExecutionResponse -> Bool)
-> (DescribeExecutionResponse -> DescribeExecutionResponse -> Bool)
-> Eq DescribeExecutionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeExecutionResponse -> DescribeExecutionResponse -> Bool
$c/= :: DescribeExecutionResponse -> DescribeExecutionResponse -> Bool
== :: DescribeExecutionResponse -> DescribeExecutionResponse -> Bool
$c== :: DescribeExecutionResponse -> DescribeExecutionResponse -> Bool
Prelude.Eq, ReadPrec [DescribeExecutionResponse]
ReadPrec DescribeExecutionResponse
Int -> ReadS DescribeExecutionResponse
ReadS [DescribeExecutionResponse]
(Int -> ReadS DescribeExecutionResponse)
-> ReadS [DescribeExecutionResponse]
-> ReadPrec DescribeExecutionResponse
-> ReadPrec [DescribeExecutionResponse]
-> Read DescribeExecutionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeExecutionResponse]
$creadListPrec :: ReadPrec [DescribeExecutionResponse]
readPrec :: ReadPrec DescribeExecutionResponse
$creadPrec :: ReadPrec DescribeExecutionResponse
readList :: ReadS [DescribeExecutionResponse]
$creadList :: ReadS [DescribeExecutionResponse]
readsPrec :: Int -> ReadS DescribeExecutionResponse
$creadsPrec :: Int -> ReadS DescribeExecutionResponse
Prelude.Read, Int -> DescribeExecutionResponse -> ShowS
[DescribeExecutionResponse] -> ShowS
DescribeExecutionResponse -> String
(Int -> DescribeExecutionResponse -> ShowS)
-> (DescribeExecutionResponse -> String)
-> ([DescribeExecutionResponse] -> ShowS)
-> Show DescribeExecutionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeExecutionResponse] -> ShowS
$cshowList :: [DescribeExecutionResponse] -> ShowS
show :: DescribeExecutionResponse -> String
$cshow :: DescribeExecutionResponse -> String
showsPrec :: Int -> DescribeExecutionResponse -> ShowS
$cshowsPrec :: Int -> DescribeExecutionResponse -> ShowS
Prelude.Show, (forall x.
 DescribeExecutionResponse -> Rep DescribeExecutionResponse x)
-> (forall x.
    Rep DescribeExecutionResponse x -> DescribeExecutionResponse)
-> Generic DescribeExecutionResponse
forall x.
Rep DescribeExecutionResponse x -> DescribeExecutionResponse
forall x.
DescribeExecutionResponse -> Rep DescribeExecutionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeExecutionResponse x -> DescribeExecutionResponse
$cfrom :: forall x.
DescribeExecutionResponse -> Rep DescribeExecutionResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeExecutionResponse' 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:
--
-- 'httpStatus', 'describeExecutionResponse_httpStatus' - The response's http status code.
--
-- 'workflowId', 'describeExecutionResponse_workflowId' - A unique identifier for the workflow.
--
-- 'execution', 'describeExecutionResponse_execution' - The structure that contains the details of the workflow\' execution.
newDescribeExecutionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'workflowId'
  Prelude.Text ->
  -- | 'execution'
  DescribedExecution ->
  DescribeExecutionResponse
newDescribeExecutionResponse :: Int -> Text -> DescribedExecution -> DescribeExecutionResponse
newDescribeExecutionResponse
  Int
pHttpStatus_
  Text
pWorkflowId_
  DescribedExecution
pExecution_ =
    DescribeExecutionResponse' :: Int -> Text -> DescribedExecution -> DescribeExecutionResponse
DescribeExecutionResponse'
      { $sel:httpStatus:DescribeExecutionResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:workflowId:DescribeExecutionResponse' :: Text
workflowId = Text
pWorkflowId_,
        $sel:execution:DescribeExecutionResponse' :: DescribedExecution
execution = DescribedExecution
pExecution_
      }

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

-- | A unique identifier for the workflow.
describeExecutionResponse_workflowId :: Lens.Lens' DescribeExecutionResponse Prelude.Text
describeExecutionResponse_workflowId :: (Text -> f Text)
-> DescribeExecutionResponse -> f DescribeExecutionResponse
describeExecutionResponse_workflowId = (DescribeExecutionResponse -> Text)
-> (DescribeExecutionResponse -> Text -> DescribeExecutionResponse)
-> Lens
     DescribeExecutionResponse DescribeExecutionResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeExecutionResponse' {Text
workflowId :: Text
$sel:workflowId:DescribeExecutionResponse' :: DescribeExecutionResponse -> Text
workflowId} -> Text
workflowId) (\s :: DescribeExecutionResponse
s@DescribeExecutionResponse' {} Text
a -> DescribeExecutionResponse
s {$sel:workflowId:DescribeExecutionResponse' :: Text
workflowId = Text
a} :: DescribeExecutionResponse)

-- | The structure that contains the details of the workflow\' execution.
describeExecutionResponse_execution :: Lens.Lens' DescribeExecutionResponse DescribedExecution
describeExecutionResponse_execution :: (DescribedExecution -> f DescribedExecution)
-> DescribeExecutionResponse -> f DescribeExecutionResponse
describeExecutionResponse_execution = (DescribeExecutionResponse -> DescribedExecution)
-> (DescribeExecutionResponse
    -> DescribedExecution -> DescribeExecutionResponse)
-> Lens
     DescribeExecutionResponse
     DescribeExecutionResponse
     DescribedExecution
     DescribedExecution
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeExecutionResponse' {DescribedExecution
execution :: DescribedExecution
$sel:execution:DescribeExecutionResponse' :: DescribeExecutionResponse -> DescribedExecution
execution} -> DescribedExecution
execution) (\s :: DescribeExecutionResponse
s@DescribeExecutionResponse' {} DescribedExecution
a -> DescribeExecutionResponse
s {$sel:execution:DescribeExecutionResponse' :: DescribedExecution
execution = DescribedExecution
a} :: DescribeExecutionResponse)

instance Prelude.NFData DescribeExecutionResponse