{-# 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.TagStepDetails
-- 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.TagStepDetails 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.S3Tag

-- | Each step type has its own @StepDetails@ structure.
--
-- The key\/value pairs used to tag a file during the execution of a
-- workflow step.
--
-- /See:/ 'newTagStepDetails' smart constructor.
data TagStepDetails = TagStepDetails'
  { -- | The name of the step, used as an identifier.
    TagStepDetails -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | 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.
    TagStepDetails -> Maybe Text
sourceFileLocation :: Prelude.Maybe Prelude.Text,
    -- | Array that contains from 1 to 10 key\/value pairs.
    TagStepDetails -> Maybe (NonEmpty S3Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty S3Tag)
  }
  deriving (TagStepDetails -> TagStepDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagStepDetails -> TagStepDetails -> Bool
$c/= :: TagStepDetails -> TagStepDetails -> Bool
== :: TagStepDetails -> TagStepDetails -> Bool
$c== :: TagStepDetails -> TagStepDetails -> Bool
Prelude.Eq, ReadPrec [TagStepDetails]
ReadPrec TagStepDetails
Int -> ReadS TagStepDetails
ReadS [TagStepDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagStepDetails]
$creadListPrec :: ReadPrec [TagStepDetails]
readPrec :: ReadPrec TagStepDetails
$creadPrec :: ReadPrec TagStepDetails
readList :: ReadS [TagStepDetails]
$creadList :: ReadS [TagStepDetails]
readsPrec :: Int -> ReadS TagStepDetails
$creadsPrec :: Int -> ReadS TagStepDetails
Prelude.Read, Int -> TagStepDetails -> ShowS
[TagStepDetails] -> ShowS
TagStepDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagStepDetails] -> ShowS
$cshowList :: [TagStepDetails] -> ShowS
show :: TagStepDetails -> String
$cshow :: TagStepDetails -> String
showsPrec :: Int -> TagStepDetails -> ShowS
$cshowsPrec :: Int -> TagStepDetails -> ShowS
Prelude.Show, forall x. Rep TagStepDetails x -> TagStepDetails
forall x. TagStepDetails -> Rep TagStepDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagStepDetails x -> TagStepDetails
$cfrom :: forall x. TagStepDetails -> Rep TagStepDetails x
Prelude.Generic)

-- |
-- Create a value of 'TagStepDetails' 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:
--
-- 'name', 'tagStepDetails_name' - The name of the step, used as an identifier.
--
-- 'sourceFileLocation', 'tagStepDetails_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.
--
-- 'tags', 'tagStepDetails_tags' - Array that contains from 1 to 10 key\/value pairs.
newTagStepDetails ::
  TagStepDetails
newTagStepDetails :: TagStepDetails
newTagStepDetails =
  TagStepDetails'
    { $sel:name:TagStepDetails' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceFileLocation:TagStepDetails' :: Maybe Text
sourceFileLocation = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:TagStepDetails' :: Maybe (NonEmpty S3Tag)
tags = forall a. Maybe a
Prelude.Nothing
    }

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

-- | 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.
tagStepDetails_sourceFileLocation :: Lens.Lens' TagStepDetails (Prelude.Maybe Prelude.Text)
tagStepDetails_sourceFileLocation :: Lens' TagStepDetails (Maybe Text)
tagStepDetails_sourceFileLocation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagStepDetails' {Maybe Text
sourceFileLocation :: Maybe Text
$sel:sourceFileLocation:TagStepDetails' :: TagStepDetails -> Maybe Text
sourceFileLocation} -> Maybe Text
sourceFileLocation) (\s :: TagStepDetails
s@TagStepDetails' {} Maybe Text
a -> TagStepDetails
s {$sel:sourceFileLocation:TagStepDetails' :: Maybe Text
sourceFileLocation = Maybe Text
a} :: TagStepDetails)

-- | Array that contains from 1 to 10 key\/value pairs.
tagStepDetails_tags :: Lens.Lens' TagStepDetails (Prelude.Maybe (Prelude.NonEmpty S3Tag))
tagStepDetails_tags :: Lens' TagStepDetails (Maybe (NonEmpty S3Tag))
tagStepDetails_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagStepDetails' {Maybe (NonEmpty S3Tag)
tags :: Maybe (NonEmpty S3Tag)
$sel:tags:TagStepDetails' :: TagStepDetails -> Maybe (NonEmpty S3Tag)
tags} -> Maybe (NonEmpty S3Tag)
tags) (\s :: TagStepDetails
s@TagStepDetails' {} Maybe (NonEmpty S3Tag)
a -> TagStepDetails
s {$sel:tags:TagStepDetails' :: Maybe (NonEmpty S3Tag)
tags = Maybe (NonEmpty S3Tag)
a} :: TagStepDetails) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON TagStepDetails where
  parseJSON :: Value -> Parser TagStepDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TagStepDetails"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe (NonEmpty S3Tag) -> TagStepDetails
TagStepDetails'
            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
"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
"SourceFileLocation")
            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
"Tags")
      )

instance Prelude.Hashable TagStepDetails where
  hashWithSalt :: Int -> TagStepDetails -> Int
hashWithSalt Int
_salt TagStepDetails' {Maybe (NonEmpty S3Tag)
Maybe Text
tags :: Maybe (NonEmpty S3Tag)
sourceFileLocation :: Maybe Text
name :: Maybe Text
$sel:tags:TagStepDetails' :: TagStepDetails -> Maybe (NonEmpty S3Tag)
$sel:sourceFileLocation:TagStepDetails' :: TagStepDetails -> Maybe Text
$sel:name:TagStepDetails' :: TagStepDetails -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceFileLocation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty S3Tag)
tags

instance Prelude.NFData TagStepDetails where
  rnf :: TagStepDetails -> ()
rnf TagStepDetails' {Maybe (NonEmpty S3Tag)
Maybe Text
tags :: Maybe (NonEmpty S3Tag)
sourceFileLocation :: Maybe Text
name :: Maybe Text
$sel:tags:TagStepDetails' :: TagStepDetails -> Maybe (NonEmpty S3Tag)
$sel:sourceFileLocation:TagStepDetails' :: TagStepDetails -> Maybe Text
$sel:name:TagStepDetails' :: TagStepDetails -> Maybe Text
..} =
    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 Text
sourceFileLocation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty S3Tag)
tags

instance Data.ToJSON TagStepDetails where
  toJSON :: TagStepDetails -> Value
toJSON TagStepDetails' {Maybe (NonEmpty S3Tag)
Maybe Text
tags :: Maybe (NonEmpty S3Tag)
sourceFileLocation :: Maybe Text
name :: Maybe Text
$sel:tags:TagStepDetails' :: TagStepDetails -> Maybe (NonEmpty S3Tag)
$sel:sourceFileLocation:TagStepDetails' :: TagStepDetails -> Maybe Text
$sel:name:TagStepDetails' :: TagStepDetails -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"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,
            (Key
"Tags" 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 (NonEmpty S3Tag)
tags
          ]
      )