{-# 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.WorkflowStep
-- 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.WorkflowStep where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Transfer.Types.CopyStepDetails
import Amazonka.Transfer.Types.CustomStepDetails
import Amazonka.Transfer.Types.DeleteStepDetails
import Amazonka.Transfer.Types.TagStepDetails
import Amazonka.Transfer.Types.WorkflowStepType

-- | The basic building block of a workflow.
--
-- /See:/ 'newWorkflowStep' smart constructor.
data WorkflowStep = WorkflowStep'
  { -- | Details for a step that creates one or more tags.
    --
    -- You specify one or more tags: each tag contains a key\/value pair.
    WorkflowStep -> Maybe TagStepDetails
tagStepDetails :: Prelude.Maybe TagStepDetails,
    -- | Details for a step that deletes the file.
    WorkflowStep -> Maybe DeleteStepDetails
deleteStepDetails :: Prelude.Maybe DeleteStepDetails,
    -- | Details for a step that performs a file copy.
    --
    -- Consists of the following values:
    --
    -- -   A description
    --
    -- -   An S3 location for the destination of the file copy.
    --
    -- -   A flag that indicates whether or not to overwrite an existing file
    --     of the same name. The default is @FALSE@.
    WorkflowStep -> Maybe CopyStepDetails
copyStepDetails :: Prelude.Maybe CopyStepDetails,
    -- | Currently, the following step types are supported.
    --
    -- -   /Copy/: copy the file to another location
    --
    -- -   /Custom/: custom step with a lambda target
    --
    -- -   /Delete/: delete the file
    --
    -- -   /Tag/: add a tag to the file
    WorkflowStep -> Maybe WorkflowStepType
type' :: Prelude.Maybe WorkflowStepType,
    -- | Details for a step that invokes a lambda function.
    --
    -- Consists of the lambda function name, target, and timeout (in seconds).
    WorkflowStep -> Maybe CustomStepDetails
customStepDetails :: Prelude.Maybe CustomStepDetails
  }
  deriving (WorkflowStep -> WorkflowStep -> Bool
(WorkflowStep -> WorkflowStep -> Bool)
-> (WorkflowStep -> WorkflowStep -> Bool) -> Eq WorkflowStep
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkflowStep -> WorkflowStep -> Bool
$c/= :: WorkflowStep -> WorkflowStep -> Bool
== :: WorkflowStep -> WorkflowStep -> Bool
$c== :: WorkflowStep -> WorkflowStep -> Bool
Prelude.Eq, ReadPrec [WorkflowStep]
ReadPrec WorkflowStep
Int -> ReadS WorkflowStep
ReadS [WorkflowStep]
(Int -> ReadS WorkflowStep)
-> ReadS [WorkflowStep]
-> ReadPrec WorkflowStep
-> ReadPrec [WorkflowStep]
-> Read WorkflowStep
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkflowStep]
$creadListPrec :: ReadPrec [WorkflowStep]
readPrec :: ReadPrec WorkflowStep
$creadPrec :: ReadPrec WorkflowStep
readList :: ReadS [WorkflowStep]
$creadList :: ReadS [WorkflowStep]
readsPrec :: Int -> ReadS WorkflowStep
$creadsPrec :: Int -> ReadS WorkflowStep
Prelude.Read, Int -> WorkflowStep -> ShowS
[WorkflowStep] -> ShowS
WorkflowStep -> String
(Int -> WorkflowStep -> ShowS)
-> (WorkflowStep -> String)
-> ([WorkflowStep] -> ShowS)
-> Show WorkflowStep
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkflowStep] -> ShowS
$cshowList :: [WorkflowStep] -> ShowS
show :: WorkflowStep -> String
$cshow :: WorkflowStep -> String
showsPrec :: Int -> WorkflowStep -> ShowS
$cshowsPrec :: Int -> WorkflowStep -> ShowS
Prelude.Show, (forall x. WorkflowStep -> Rep WorkflowStep x)
-> (forall x. Rep WorkflowStep x -> WorkflowStep)
-> Generic WorkflowStep
forall x. Rep WorkflowStep x -> WorkflowStep
forall x. WorkflowStep -> Rep WorkflowStep x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WorkflowStep x -> WorkflowStep
$cfrom :: forall x. WorkflowStep -> Rep WorkflowStep x
Prelude.Generic)

-- |
-- Create a value of 'WorkflowStep' 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:
--
-- 'tagStepDetails', 'workflowStep_tagStepDetails' - Details for a step that creates one or more tags.
--
-- You specify one or more tags: each tag contains a key\/value pair.
--
-- 'deleteStepDetails', 'workflowStep_deleteStepDetails' - Details for a step that deletes the file.
--
-- 'copyStepDetails', 'workflowStep_copyStepDetails' - Details for a step that performs a file copy.
--
-- Consists of the following values:
--
-- -   A description
--
-- -   An S3 location for the destination of the file copy.
--
-- -   A flag that indicates whether or not to overwrite an existing file
--     of the same name. The default is @FALSE@.
--
-- 'type'', 'workflowStep_type' - Currently, the following step types are supported.
--
-- -   /Copy/: copy the file to another location
--
-- -   /Custom/: custom step with a lambda target
--
-- -   /Delete/: delete the file
--
-- -   /Tag/: add a tag to the file
--
-- 'customStepDetails', 'workflowStep_customStepDetails' - Details for a step that invokes a lambda function.
--
-- Consists of the lambda function name, target, and timeout (in seconds).
newWorkflowStep ::
  WorkflowStep
newWorkflowStep :: WorkflowStep
newWorkflowStep =
  WorkflowStep' :: Maybe TagStepDetails
-> Maybe DeleteStepDetails
-> Maybe CopyStepDetails
-> Maybe WorkflowStepType
-> Maybe CustomStepDetails
-> WorkflowStep
WorkflowStep'
    { $sel:tagStepDetails:WorkflowStep' :: Maybe TagStepDetails
tagStepDetails = Maybe TagStepDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:deleteStepDetails:WorkflowStep' :: Maybe DeleteStepDetails
deleteStepDetails = Maybe DeleteStepDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:copyStepDetails:WorkflowStep' :: Maybe CopyStepDetails
copyStepDetails = Maybe CopyStepDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:type':WorkflowStep' :: Maybe WorkflowStepType
type' = Maybe WorkflowStepType
forall a. Maybe a
Prelude.Nothing,
      $sel:customStepDetails:WorkflowStep' :: Maybe CustomStepDetails
customStepDetails = Maybe CustomStepDetails
forall a. Maybe a
Prelude.Nothing
    }

-- | Details for a step that creates one or more tags.
--
-- You specify one or more tags: each tag contains a key\/value pair.
workflowStep_tagStepDetails :: Lens.Lens' WorkflowStep (Prelude.Maybe TagStepDetails)
workflowStep_tagStepDetails :: (Maybe TagStepDetails -> f (Maybe TagStepDetails))
-> WorkflowStep -> f WorkflowStep
workflowStep_tagStepDetails = (WorkflowStep -> Maybe TagStepDetails)
-> (WorkflowStep -> Maybe TagStepDetails -> WorkflowStep)
-> Lens
     WorkflowStep
     WorkflowStep
     (Maybe TagStepDetails)
     (Maybe TagStepDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowStep' {Maybe TagStepDetails
tagStepDetails :: Maybe TagStepDetails
$sel:tagStepDetails:WorkflowStep' :: WorkflowStep -> Maybe TagStepDetails
tagStepDetails} -> Maybe TagStepDetails
tagStepDetails) (\s :: WorkflowStep
s@WorkflowStep' {} Maybe TagStepDetails
a -> WorkflowStep
s {$sel:tagStepDetails:WorkflowStep' :: Maybe TagStepDetails
tagStepDetails = Maybe TagStepDetails
a} :: WorkflowStep)

-- | Details for a step that deletes the file.
workflowStep_deleteStepDetails :: Lens.Lens' WorkflowStep (Prelude.Maybe DeleteStepDetails)
workflowStep_deleteStepDetails :: (Maybe DeleteStepDetails -> f (Maybe DeleteStepDetails))
-> WorkflowStep -> f WorkflowStep
workflowStep_deleteStepDetails = (WorkflowStep -> Maybe DeleteStepDetails)
-> (WorkflowStep -> Maybe DeleteStepDetails -> WorkflowStep)
-> Lens
     WorkflowStep
     WorkflowStep
     (Maybe DeleteStepDetails)
     (Maybe DeleteStepDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowStep' {Maybe DeleteStepDetails
deleteStepDetails :: Maybe DeleteStepDetails
$sel:deleteStepDetails:WorkflowStep' :: WorkflowStep -> Maybe DeleteStepDetails
deleteStepDetails} -> Maybe DeleteStepDetails
deleteStepDetails) (\s :: WorkflowStep
s@WorkflowStep' {} Maybe DeleteStepDetails
a -> WorkflowStep
s {$sel:deleteStepDetails:WorkflowStep' :: Maybe DeleteStepDetails
deleteStepDetails = Maybe DeleteStepDetails
a} :: WorkflowStep)

-- | Details for a step that performs a file copy.
--
-- Consists of the following values:
--
-- -   A description
--
-- -   An S3 location for the destination of the file copy.
--
-- -   A flag that indicates whether or not to overwrite an existing file
--     of the same name. The default is @FALSE@.
workflowStep_copyStepDetails :: Lens.Lens' WorkflowStep (Prelude.Maybe CopyStepDetails)
workflowStep_copyStepDetails :: (Maybe CopyStepDetails -> f (Maybe CopyStepDetails))
-> WorkflowStep -> f WorkflowStep
workflowStep_copyStepDetails = (WorkflowStep -> Maybe CopyStepDetails)
-> (WorkflowStep -> Maybe CopyStepDetails -> WorkflowStep)
-> Lens
     WorkflowStep
     WorkflowStep
     (Maybe CopyStepDetails)
     (Maybe CopyStepDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowStep' {Maybe CopyStepDetails
copyStepDetails :: Maybe CopyStepDetails
$sel:copyStepDetails:WorkflowStep' :: WorkflowStep -> Maybe CopyStepDetails
copyStepDetails} -> Maybe CopyStepDetails
copyStepDetails) (\s :: WorkflowStep
s@WorkflowStep' {} Maybe CopyStepDetails
a -> WorkflowStep
s {$sel:copyStepDetails:WorkflowStep' :: Maybe CopyStepDetails
copyStepDetails = Maybe CopyStepDetails
a} :: WorkflowStep)

-- | Currently, the following step types are supported.
--
-- -   /Copy/: copy the file to another location
--
-- -   /Custom/: custom step with a lambda target
--
-- -   /Delete/: delete the file
--
-- -   /Tag/: add a tag to the file
workflowStep_type :: Lens.Lens' WorkflowStep (Prelude.Maybe WorkflowStepType)
workflowStep_type :: (Maybe WorkflowStepType -> f (Maybe WorkflowStepType))
-> WorkflowStep -> f WorkflowStep
workflowStep_type = (WorkflowStep -> Maybe WorkflowStepType)
-> (WorkflowStep -> Maybe WorkflowStepType -> WorkflowStep)
-> Lens
     WorkflowStep
     WorkflowStep
     (Maybe WorkflowStepType)
     (Maybe WorkflowStepType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowStep' {Maybe WorkflowStepType
type' :: Maybe WorkflowStepType
$sel:type':WorkflowStep' :: WorkflowStep -> Maybe WorkflowStepType
type'} -> Maybe WorkflowStepType
type') (\s :: WorkflowStep
s@WorkflowStep' {} Maybe WorkflowStepType
a -> WorkflowStep
s {$sel:type':WorkflowStep' :: Maybe WorkflowStepType
type' = Maybe WorkflowStepType
a} :: WorkflowStep)

-- | Details for a step that invokes a lambda function.
--
-- Consists of the lambda function name, target, and timeout (in seconds).
workflowStep_customStepDetails :: Lens.Lens' WorkflowStep (Prelude.Maybe CustomStepDetails)
workflowStep_customStepDetails :: (Maybe CustomStepDetails -> f (Maybe CustomStepDetails))
-> WorkflowStep -> f WorkflowStep
workflowStep_customStepDetails = (WorkflowStep -> Maybe CustomStepDetails)
-> (WorkflowStep -> Maybe CustomStepDetails -> WorkflowStep)
-> Lens
     WorkflowStep
     WorkflowStep
     (Maybe CustomStepDetails)
     (Maybe CustomStepDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowStep' {Maybe CustomStepDetails
customStepDetails :: Maybe CustomStepDetails
$sel:customStepDetails:WorkflowStep' :: WorkflowStep -> Maybe CustomStepDetails
customStepDetails} -> Maybe CustomStepDetails
customStepDetails) (\s :: WorkflowStep
s@WorkflowStep' {} Maybe CustomStepDetails
a -> WorkflowStep
s {$sel:customStepDetails:WorkflowStep' :: Maybe CustomStepDetails
customStepDetails = Maybe CustomStepDetails
a} :: WorkflowStep)

instance Core.FromJSON WorkflowStep where
  parseJSON :: Value -> Parser WorkflowStep
parseJSON =
    String
-> (Object -> Parser WorkflowStep) -> Value -> Parser WorkflowStep
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WorkflowStep"
      ( \Object
x ->
          Maybe TagStepDetails
-> Maybe DeleteStepDetails
-> Maybe CopyStepDetails
-> Maybe WorkflowStepType
-> Maybe CustomStepDetails
-> WorkflowStep
WorkflowStep'
            (Maybe TagStepDetails
 -> Maybe DeleteStepDetails
 -> Maybe CopyStepDetails
 -> Maybe WorkflowStepType
 -> Maybe CustomStepDetails
 -> WorkflowStep)
-> Parser (Maybe TagStepDetails)
-> Parser
     (Maybe DeleteStepDetails
      -> Maybe CopyStepDetails
      -> Maybe WorkflowStepType
      -> Maybe CustomStepDetails
      -> WorkflowStep)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TagStepDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TagStepDetails")
            Parser
  (Maybe DeleteStepDetails
   -> Maybe CopyStepDetails
   -> Maybe WorkflowStepType
   -> Maybe CustomStepDetails
   -> WorkflowStep)
-> Parser (Maybe DeleteStepDetails)
-> Parser
     (Maybe CopyStepDetails
      -> Maybe WorkflowStepType
      -> Maybe CustomStepDetails
      -> WorkflowStep)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DeleteStepDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DeleteStepDetails")
            Parser
  (Maybe CopyStepDetails
   -> Maybe WorkflowStepType
   -> Maybe CustomStepDetails
   -> WorkflowStep)
-> Parser (Maybe CopyStepDetails)
-> Parser
     (Maybe WorkflowStepType -> Maybe CustomStepDetails -> WorkflowStep)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CopyStepDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CopyStepDetails")
            Parser
  (Maybe WorkflowStepType -> Maybe CustomStepDetails -> WorkflowStep)
-> Parser (Maybe WorkflowStepType)
-> Parser (Maybe CustomStepDetails -> WorkflowStep)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe WorkflowStepType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            Parser (Maybe CustomStepDetails -> WorkflowStep)
-> Parser (Maybe CustomStepDetails) -> Parser WorkflowStep
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CustomStepDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CustomStepDetails")
      )

instance Prelude.Hashable WorkflowStep

instance Prelude.NFData WorkflowStep

instance Core.ToJSON WorkflowStep where
  toJSON :: WorkflowStep -> Value
toJSON WorkflowStep' {Maybe CustomStepDetails
Maybe DeleteStepDetails
Maybe CopyStepDetails
Maybe TagStepDetails
Maybe WorkflowStepType
customStepDetails :: Maybe CustomStepDetails
type' :: Maybe WorkflowStepType
copyStepDetails :: Maybe CopyStepDetails
deleteStepDetails :: Maybe DeleteStepDetails
tagStepDetails :: Maybe TagStepDetails
$sel:customStepDetails:WorkflowStep' :: WorkflowStep -> Maybe CustomStepDetails
$sel:type':WorkflowStep' :: WorkflowStep -> Maybe WorkflowStepType
$sel:copyStepDetails:WorkflowStep' :: WorkflowStep -> Maybe CopyStepDetails
$sel:deleteStepDetails:WorkflowStep' :: WorkflowStep -> Maybe DeleteStepDetails
$sel:tagStepDetails:WorkflowStep' :: WorkflowStep -> Maybe TagStepDetails
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TagStepDetails" Text -> TagStepDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (TagStepDetails -> Pair) -> Maybe TagStepDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TagStepDetails
tagStepDetails,
            (Text
"DeleteStepDetails" Text -> DeleteStepDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DeleteStepDetails -> Pair)
-> Maybe DeleteStepDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeleteStepDetails
deleteStepDetails,
            (Text
"CopyStepDetails" Text -> CopyStepDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CopyStepDetails -> Pair) -> Maybe CopyStepDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CopyStepDetails
copyStepDetails,
            (Text
"Type" Text -> WorkflowStepType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (WorkflowStepType -> Pair) -> Maybe WorkflowStepType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe WorkflowStepType
type',
            (Text
"CustomStepDetails" Text -> CustomStepDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CustomStepDetails -> Pair)
-> Maybe CustomStepDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CustomStepDetails
customStepDetails
          ]
      )