{-# 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.CopyStepDetails
-- 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.CopyStepDetails 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
import Amazonka.Transfer.Types.InputFileLocation
import Amazonka.Transfer.Types.OverwriteExisting

-- | Each step type has its own @StepDetails@ structure.
--
-- /See:/ 'newCopyStepDetails' smart constructor.
data CopyStepDetails = CopyStepDetails'
  { -- | Specifies the location for the file being copied. Only applicable for
    -- Copy type workflow steps. Use @${Transfer:username}@ in this field to
    -- parametrize the destination prefix by username.
    CopyStepDetails -> Maybe InputFileLocation
destinationFileLocation :: Prelude.Maybe InputFileLocation,
    -- | The name of the step, used as an identifier.
    CopyStepDetails -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A flag that indicates whether or not to overwrite an existing file of
    -- the same name. The default is @FALSE@.
    CopyStepDetails -> Maybe OverwriteExisting
overwriteExisting :: Prelude.Maybe OverwriteExisting,
    -- | Specifies which file to use as input to the workflow step: either the
    -- output from the previous step, or the originally uploaded file for the
    -- workflow.
    --
    -- -   Enter @${previous.file}@ to use the previous file as the input. In
    --     this case, this workflow step uses the output file from the previous
    --     workflow step as input. This is the default value.
    --
    -- -   Enter @${original.file}@ to use the originally-uploaded file
    --     location as input for this step.
    CopyStepDetails -> Maybe Text
sourceFileLocation :: Prelude.Maybe Prelude.Text
  }
  deriving (CopyStepDetails -> CopyStepDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CopyStepDetails -> CopyStepDetails -> Bool
$c/= :: CopyStepDetails -> CopyStepDetails -> Bool
== :: CopyStepDetails -> CopyStepDetails -> Bool
$c== :: CopyStepDetails -> CopyStepDetails -> Bool
Prelude.Eq, ReadPrec [CopyStepDetails]
ReadPrec CopyStepDetails
Int -> ReadS CopyStepDetails
ReadS [CopyStepDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CopyStepDetails]
$creadListPrec :: ReadPrec [CopyStepDetails]
readPrec :: ReadPrec CopyStepDetails
$creadPrec :: ReadPrec CopyStepDetails
readList :: ReadS [CopyStepDetails]
$creadList :: ReadS [CopyStepDetails]
readsPrec :: Int -> ReadS CopyStepDetails
$creadsPrec :: Int -> ReadS CopyStepDetails
Prelude.Read, Int -> CopyStepDetails -> ShowS
[CopyStepDetails] -> ShowS
CopyStepDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CopyStepDetails] -> ShowS
$cshowList :: [CopyStepDetails] -> ShowS
show :: CopyStepDetails -> String
$cshow :: CopyStepDetails -> String
showsPrec :: Int -> CopyStepDetails -> ShowS
$cshowsPrec :: Int -> CopyStepDetails -> ShowS
Prelude.Show, forall x. Rep CopyStepDetails x -> CopyStepDetails
forall x. CopyStepDetails -> Rep CopyStepDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CopyStepDetails x -> CopyStepDetails
$cfrom :: forall x. CopyStepDetails -> Rep CopyStepDetails x
Prelude.Generic)

-- |
-- Create a value of 'CopyStepDetails' 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:
--
-- 'destinationFileLocation', 'copyStepDetails_destinationFileLocation' - Specifies the location for the file being copied. Only applicable for
-- Copy type workflow steps. Use @${Transfer:username}@ in this field to
-- parametrize the destination prefix by username.
--
-- 'name', 'copyStepDetails_name' - The name of the step, used as an identifier.
--
-- 'overwriteExisting', 'copyStepDetails_overwriteExisting' - A flag that indicates whether or not to overwrite an existing file of
-- the same name. The default is @FALSE@.
--
-- 'sourceFileLocation', 'copyStepDetails_sourceFileLocation' - Specifies which file to use as input to the workflow step: either the
-- output from the previous step, or the originally uploaded file for the
-- workflow.
--
-- -   Enter @${previous.file}@ to use the previous file as the input. In
--     this case, this workflow step uses the output file from the previous
--     workflow step as input. This is the default value.
--
-- -   Enter @${original.file}@ to use the originally-uploaded file
--     location as input for this step.
newCopyStepDetails ::
  CopyStepDetails
newCopyStepDetails :: CopyStepDetails
newCopyStepDetails =
  CopyStepDetails'
    { $sel:destinationFileLocation:CopyStepDetails' :: Maybe InputFileLocation
destinationFileLocation =
        forall a. Maybe a
Prelude.Nothing,
      $sel:name:CopyStepDetails' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:overwriteExisting:CopyStepDetails' :: Maybe OverwriteExisting
overwriteExisting = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceFileLocation:CopyStepDetails' :: Maybe Text
sourceFileLocation = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the location for the file being copied. Only applicable for
-- Copy type workflow steps. Use @${Transfer:username}@ in this field to
-- parametrize the destination prefix by username.
copyStepDetails_destinationFileLocation :: Lens.Lens' CopyStepDetails (Prelude.Maybe InputFileLocation)
copyStepDetails_destinationFileLocation :: Lens' CopyStepDetails (Maybe InputFileLocation)
copyStepDetails_destinationFileLocation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopyStepDetails' {Maybe InputFileLocation
destinationFileLocation :: Maybe InputFileLocation
$sel:destinationFileLocation:CopyStepDetails' :: CopyStepDetails -> Maybe InputFileLocation
destinationFileLocation} -> Maybe InputFileLocation
destinationFileLocation) (\s :: CopyStepDetails
s@CopyStepDetails' {} Maybe InputFileLocation
a -> CopyStepDetails
s {$sel:destinationFileLocation:CopyStepDetails' :: Maybe InputFileLocation
destinationFileLocation = Maybe InputFileLocation
a} :: CopyStepDetails)

-- | The name of the step, used as an identifier.
copyStepDetails_name :: Lens.Lens' CopyStepDetails (Prelude.Maybe Prelude.Text)
copyStepDetails_name :: Lens' CopyStepDetails (Maybe Text)
copyStepDetails_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopyStepDetails' {Maybe Text
name :: Maybe Text
$sel:name:CopyStepDetails' :: CopyStepDetails -> Maybe Text
name} -> Maybe Text
name) (\s :: CopyStepDetails
s@CopyStepDetails' {} Maybe Text
a -> CopyStepDetails
s {$sel:name:CopyStepDetails' :: Maybe Text
name = Maybe Text
a} :: CopyStepDetails)

-- | A flag that indicates whether or not to overwrite an existing file of
-- the same name. The default is @FALSE@.
copyStepDetails_overwriteExisting :: Lens.Lens' CopyStepDetails (Prelude.Maybe OverwriteExisting)
copyStepDetails_overwriteExisting :: Lens' CopyStepDetails (Maybe OverwriteExisting)
copyStepDetails_overwriteExisting = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopyStepDetails' {Maybe OverwriteExisting
overwriteExisting :: Maybe OverwriteExisting
$sel:overwriteExisting:CopyStepDetails' :: CopyStepDetails -> Maybe OverwriteExisting
overwriteExisting} -> Maybe OverwriteExisting
overwriteExisting) (\s :: CopyStepDetails
s@CopyStepDetails' {} Maybe OverwriteExisting
a -> CopyStepDetails
s {$sel:overwriteExisting:CopyStepDetails' :: Maybe OverwriteExisting
overwriteExisting = Maybe OverwriteExisting
a} :: CopyStepDetails)

-- | Specifies which file to use as input to the workflow step: either the
-- output from the previous step, or the originally uploaded file for the
-- workflow.
--
-- -   Enter @${previous.file}@ to use the previous file as the input. In
--     this case, this workflow step uses the output file from the previous
--     workflow step as input. This is the default value.
--
-- -   Enter @${original.file}@ to use the originally-uploaded file
--     location as input for this step.
copyStepDetails_sourceFileLocation :: Lens.Lens' CopyStepDetails (Prelude.Maybe Prelude.Text)
copyStepDetails_sourceFileLocation :: Lens' CopyStepDetails (Maybe Text)
copyStepDetails_sourceFileLocation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopyStepDetails' {Maybe Text
sourceFileLocation :: Maybe Text
$sel:sourceFileLocation:CopyStepDetails' :: CopyStepDetails -> Maybe Text
sourceFileLocation} -> Maybe Text
sourceFileLocation) (\s :: CopyStepDetails
s@CopyStepDetails' {} Maybe Text
a -> CopyStepDetails
s {$sel:sourceFileLocation:CopyStepDetails' :: Maybe Text
sourceFileLocation = Maybe Text
a} :: CopyStepDetails)

instance Data.FromJSON CopyStepDetails where
  parseJSON :: Value -> Parser CopyStepDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CopyStepDetails"
      ( \Object
x ->
          Maybe InputFileLocation
-> Maybe Text
-> Maybe OverwriteExisting
-> Maybe Text
-> CopyStepDetails
CopyStepDetails'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DestinationFileLocation")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"OverwriteExisting")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SourceFileLocation")
      )

instance Prelude.Hashable CopyStepDetails where
  hashWithSalt :: Int -> CopyStepDetails -> Int
hashWithSalt Int
_salt CopyStepDetails' {Maybe Text
Maybe OverwriteExisting
Maybe InputFileLocation
sourceFileLocation :: Maybe Text
overwriteExisting :: Maybe OverwriteExisting
name :: Maybe Text
destinationFileLocation :: Maybe InputFileLocation
$sel:sourceFileLocation:CopyStepDetails' :: CopyStepDetails -> Maybe Text
$sel:overwriteExisting:CopyStepDetails' :: CopyStepDetails -> Maybe OverwriteExisting
$sel:name:CopyStepDetails' :: CopyStepDetails -> Maybe Text
$sel:destinationFileLocation:CopyStepDetails' :: CopyStepDetails -> Maybe InputFileLocation
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InputFileLocation
destinationFileLocation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe OverwriteExisting
overwriteExisting
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceFileLocation

instance Prelude.NFData CopyStepDetails where
  rnf :: CopyStepDetails -> ()
rnf CopyStepDetails' {Maybe Text
Maybe OverwriteExisting
Maybe InputFileLocation
sourceFileLocation :: Maybe Text
overwriteExisting :: Maybe OverwriteExisting
name :: Maybe Text
destinationFileLocation :: Maybe InputFileLocation
$sel:sourceFileLocation:CopyStepDetails' :: CopyStepDetails -> Maybe Text
$sel:overwriteExisting:CopyStepDetails' :: CopyStepDetails -> Maybe OverwriteExisting
$sel:name:CopyStepDetails' :: CopyStepDetails -> Maybe Text
$sel:destinationFileLocation:CopyStepDetails' :: CopyStepDetails -> Maybe InputFileLocation
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe InputFileLocation
destinationFileLocation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe OverwriteExisting
overwriteExisting
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceFileLocation

instance Data.ToJSON CopyStepDetails where
  toJSON :: CopyStepDetails -> Value
toJSON CopyStepDetails' {Maybe Text
Maybe OverwriteExisting
Maybe InputFileLocation
sourceFileLocation :: Maybe Text
overwriteExisting :: Maybe OverwriteExisting
name :: Maybe Text
destinationFileLocation :: Maybe InputFileLocation
$sel:sourceFileLocation:CopyStepDetails' :: CopyStepDetails -> Maybe Text
$sel:overwriteExisting:CopyStepDetails' :: CopyStepDetails -> Maybe OverwriteExisting
$sel:name:CopyStepDetails' :: CopyStepDetails -> Maybe Text
$sel:destinationFileLocation:CopyStepDetails' :: CopyStepDetails -> Maybe InputFileLocation
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DestinationFileLocation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputFileLocation
destinationFileLocation,
            (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            (Key
"OverwriteExisting" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OverwriteExisting
overwriteExisting,
            (Key
"SourceFileLocation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sourceFileLocation
          ]
      )