{-# 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-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)
module Amazonka.Transfer.Types.WorkflowDetail where

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

-- | Specifies the workflow ID for the workflow to assign and the execution
-- role used for executing the workflow.
--
-- /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
(WorkflowDetail -> WorkflowDetail -> Bool)
-> (WorkflowDetail -> WorkflowDetail -> Bool) -> Eq WorkflowDetail
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]
(Int -> ReadS WorkflowDetail)
-> ReadS [WorkflowDetail]
-> ReadPrec WorkflowDetail
-> ReadPrec [WorkflowDetail]
-> Read 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
(Int -> WorkflowDetail -> ShowS)
-> (WorkflowDetail -> String)
-> ([WorkflowDetail] -> ShowS)
-> Show WorkflowDetail
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. WorkflowDetail -> Rep WorkflowDetail x)
-> (forall x. Rep WorkflowDetail x -> WorkflowDetail)
-> Generic WorkflowDetail
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' :: Text -> Text -> WorkflowDetail
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 :: (Text -> f Text) -> WorkflowDetail -> f WorkflowDetail
workflowDetail_workflowId = (WorkflowDetail -> Text)
-> (WorkflowDetail -> Text -> WorkflowDetail)
-> Lens WorkflowDetail WorkflowDetail Text Text
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 :: (Text -> f Text) -> WorkflowDetail -> f WorkflowDetail
workflowDetail_executionRole = (WorkflowDetail -> Text)
-> (WorkflowDetail -> Text -> WorkflowDetail)
-> Lens WorkflowDetail WorkflowDetail Text Text
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 Core.FromJSON WorkflowDetail where
  parseJSON :: Value -> Parser WorkflowDetail
parseJSON =
    String
-> (Object -> Parser WorkflowDetail)
-> Value
-> Parser WorkflowDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WorkflowDetail"
      ( \Object
x ->
          Text -> Text -> WorkflowDetail
WorkflowDetail'
            (Text -> Text -> WorkflowDetail)
-> Parser Text -> Parser (Text -> WorkflowDetail)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"WorkflowId")
            Parser (Text -> WorkflowDetail)
-> Parser Text -> Parser WorkflowDetail
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ExecutionRole")
      )

instance Prelude.Hashable WorkflowDetail

instance Prelude.NFData WorkflowDetail

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ExecutionRole" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
executionRole)
          ]
      )