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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { CopyStepDetails -> Maybe InputFileLocation
destinationFileLocation :: Prelude.Maybe InputFileLocation,
    -- | 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,
    -- | The name of the step, used as an identifier.
    CopyStepDetails -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (CopyStepDetails -> CopyStepDetails -> Bool
(CopyStepDetails -> CopyStepDetails -> Bool)
-> (CopyStepDetails -> CopyStepDetails -> Bool)
-> Eq CopyStepDetails
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]
(Int -> ReadS CopyStepDetails)
-> ReadS [CopyStepDetails]
-> ReadPrec CopyStepDetails
-> ReadPrec [CopyStepDetails]
-> Read 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
(Int -> CopyStepDetails -> ShowS)
-> (CopyStepDetails -> String)
-> ([CopyStepDetails] -> ShowS)
-> Show CopyStepDetails
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. CopyStepDetails -> Rep CopyStepDetails x)
-> (forall x. Rep CopyStepDetails x -> CopyStepDetails)
-> Generic CopyStepDetails
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' - Undocumented member.
--
-- 'overwriteExisting', 'copyStepDetails_overwriteExisting' - A flag that indicates whether or not to overwrite an existing file of
-- the same name. The default is @FALSE@.
--
-- 'name', 'copyStepDetails_name' - The name of the step, used as an identifier.
newCopyStepDetails ::
  CopyStepDetails
newCopyStepDetails :: CopyStepDetails
newCopyStepDetails =
  CopyStepDetails' :: Maybe InputFileLocation
-> Maybe OverwriteExisting -> Maybe Text -> CopyStepDetails
CopyStepDetails'
    { $sel:destinationFileLocation:CopyStepDetails' :: Maybe InputFileLocation
destinationFileLocation =
        Maybe InputFileLocation
forall a. Maybe a
Prelude.Nothing,
      $sel:overwriteExisting:CopyStepDetails' :: Maybe OverwriteExisting
overwriteExisting = Maybe OverwriteExisting
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CopyStepDetails' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
copyStepDetails_destinationFileLocation :: Lens.Lens' CopyStepDetails (Prelude.Maybe InputFileLocation)
copyStepDetails_destinationFileLocation :: (Maybe InputFileLocation -> f (Maybe InputFileLocation))
-> CopyStepDetails -> f CopyStepDetails
copyStepDetails_destinationFileLocation = (CopyStepDetails -> Maybe InputFileLocation)
-> (CopyStepDetails -> Maybe InputFileLocation -> CopyStepDetails)
-> Lens
     CopyStepDetails
     CopyStepDetails
     (Maybe InputFileLocation)
     (Maybe InputFileLocation)
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)

-- | 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 :: (Maybe OverwriteExisting -> f (Maybe OverwriteExisting))
-> CopyStepDetails -> f CopyStepDetails
copyStepDetails_overwriteExisting = (CopyStepDetails -> Maybe OverwriteExisting)
-> (CopyStepDetails -> Maybe OverwriteExisting -> CopyStepDetails)
-> Lens
     CopyStepDetails
     CopyStepDetails
     (Maybe OverwriteExisting)
     (Maybe 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)

-- | The name of the step, used as an identifier.
copyStepDetails_name :: Lens.Lens' CopyStepDetails (Prelude.Maybe Prelude.Text)
copyStepDetails_name :: (Maybe Text -> f (Maybe Text))
-> CopyStepDetails -> f CopyStepDetails
copyStepDetails_name = (CopyStepDetails -> Maybe Text)
-> (CopyStepDetails -> Maybe Text -> CopyStepDetails)
-> Lens CopyStepDetails CopyStepDetails (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable CopyStepDetails

instance Prelude.NFData CopyStepDetails

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