{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.WorkflowDetail
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Transfer.Types.WorkflowDetail where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Specifies the workflow ID for the workflow to assign and the execution
-- role that\'s used for executing the workflow.
--
-- In additon to a workflow to execute when a file is uploaded completely,
-- @WorkflowDeatails@ can also contain a workflow ID (and execution role)
-- for a workflow to execute on partial upload. A partial upload occurs
-- when a file is open when the session disconnects.
--
-- /See:/ 'newWorkflowDetail' smart constructor.
data WorkflowDetail = WorkflowDetail'
  { -- | A unique identifier for the workflow.
    WorkflowDetail -> Text
workflowId :: Prelude.Text,
    -- | Includes the necessary permissions for S3, EFS, and Lambda operations
    -- that Transfer can assume, so that all workflow steps can operate on the
    -- required resources
    WorkflowDetail -> Text
executionRole :: Prelude.Text
  }
  deriving (WorkflowDetail -> WorkflowDetail -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkflowDetail -> WorkflowDetail -> Bool
$c/= :: WorkflowDetail -> WorkflowDetail -> Bool
== :: WorkflowDetail -> WorkflowDetail -> Bool
$c== :: WorkflowDetail -> WorkflowDetail -> Bool
Prelude.Eq, ReadPrec [WorkflowDetail]
ReadPrec WorkflowDetail
Int -> ReadS WorkflowDetail
ReadS [WorkflowDetail]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkflowDetail]
$creadListPrec :: ReadPrec [WorkflowDetail]
readPrec :: ReadPrec WorkflowDetail
$creadPrec :: ReadPrec WorkflowDetail
readList :: ReadS [WorkflowDetail]
$creadList :: ReadS [WorkflowDetail]
readsPrec :: Int -> ReadS WorkflowDetail
$creadsPrec :: Int -> ReadS WorkflowDetail
Prelude.Read, Int -> WorkflowDetail -> ShowS
[WorkflowDetail] -> ShowS
WorkflowDetail -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkflowDetail] -> ShowS
$cshowList :: [WorkflowDetail] -> ShowS
show :: WorkflowDetail -> String
$cshow :: WorkflowDetail -> String
showsPrec :: Int -> WorkflowDetail -> ShowS
$cshowsPrec :: Int -> WorkflowDetail -> ShowS
Prelude.Show, forall x. Rep WorkflowDetail x -> WorkflowDetail
forall x. WorkflowDetail -> Rep WorkflowDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WorkflowDetail x -> WorkflowDetail
$cfrom :: forall x. WorkflowDetail -> Rep WorkflowDetail x
Prelude.Generic)

-- |
-- Create a value of 'WorkflowDetail' 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:
--
-- 'workflowId', 'workflowDetail_workflowId' - A unique identifier for the workflow.
--
-- 'executionRole', 'workflowDetail_executionRole' - Includes the necessary permissions for S3, EFS, and Lambda operations
-- that Transfer can assume, so that all workflow steps can operate on the
-- required resources
newWorkflowDetail ::
  -- | 'workflowId'
  Prelude.Text ->
  -- | 'executionRole'
  Prelude.Text ->
  WorkflowDetail
newWorkflowDetail :: Text -> Text -> WorkflowDetail
newWorkflowDetail Text
pWorkflowId_ Text
pExecutionRole_ =
  WorkflowDetail'
    { $sel:workflowId:WorkflowDetail' :: Text
workflowId = Text
pWorkflowId_,
      $sel:executionRole:WorkflowDetail' :: Text
executionRole = Text
pExecutionRole_
    }

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

-- | Includes the necessary permissions for S3, EFS, and Lambda operations
-- that Transfer can assume, so that all workflow steps can operate on the
-- required resources
workflowDetail_executionRole :: Lens.Lens' WorkflowDetail Prelude.Text
workflowDetail_executionRole :: Lens' WorkflowDetail Text
workflowDetail_executionRole = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowDetail' {Text
executionRole :: Text
$sel:executionRole:WorkflowDetail' :: WorkflowDetail -> Text
executionRole} -> Text
executionRole) (\s :: WorkflowDetail
s@WorkflowDetail' {} Text
a -> WorkflowDetail
s {$sel:executionRole:WorkflowDetail' :: Text
executionRole = Text
a} :: WorkflowDetail)

instance Data.FromJSON WorkflowDetail where
  parseJSON :: Value -> Parser WorkflowDetail
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WorkflowDetail"
      ( \Object
x ->
          Text -> Text -> WorkflowDetail
WorkflowDetail'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"WorkflowId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ExecutionRole")
      )

instance Prelude.Hashable WorkflowDetail where
  hashWithSalt :: Int -> WorkflowDetail -> Int
hashWithSalt Int
_salt WorkflowDetail' {Text
executionRole :: Text
workflowId :: Text
$sel:executionRole:WorkflowDetail' :: WorkflowDetail -> Text
$sel:workflowId:WorkflowDetail' :: WorkflowDetail -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
workflowId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
executionRole

instance Prelude.NFData WorkflowDetail where
  rnf :: WorkflowDetail -> ()
rnf WorkflowDetail' {Text
executionRole :: Text
workflowId :: Text
$sel:executionRole:WorkflowDetail' :: WorkflowDetail -> Text
$sel:workflowId:WorkflowDetail' :: WorkflowDetail -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
workflowId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
executionRole

instance Data.ToJSON WorkflowDetail where
  toJSON :: WorkflowDetail -> Value
toJSON WorkflowDetail' {Text
executionRole :: Text
workflowId :: Text
$sel:executionRole:WorkflowDetail' :: WorkflowDetail -> Text
$sel:workflowId:WorkflowDetail' :: WorkflowDetail -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"WorkflowId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
workflowId),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ExecutionRole" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
executionRole)
          ]
      )