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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Transfer.Types.EfsFileLocation
import Amazonka.Transfer.Types.S3InputFileLocation

-- | Specifies the location for the file being copied. Only applicable for
-- the Copy type of workflow steps.
--
-- /See:/ 'newInputFileLocation' smart constructor.
data InputFileLocation = InputFileLocation'
  { -- | Reserved for future use.
    InputFileLocation -> Maybe EfsFileLocation
efsFileLocation :: Prelude.Maybe EfsFileLocation,
    -- | Specifies the details for the S3 file being copied.
    InputFileLocation -> Maybe S3InputFileLocation
s3FileLocation :: Prelude.Maybe S3InputFileLocation
  }
  deriving (InputFileLocation -> InputFileLocation -> Bool
(InputFileLocation -> InputFileLocation -> Bool)
-> (InputFileLocation -> InputFileLocation -> Bool)
-> Eq InputFileLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputFileLocation -> InputFileLocation -> Bool
$c/= :: InputFileLocation -> InputFileLocation -> Bool
== :: InputFileLocation -> InputFileLocation -> Bool
$c== :: InputFileLocation -> InputFileLocation -> Bool
Prelude.Eq, ReadPrec [InputFileLocation]
ReadPrec InputFileLocation
Int -> ReadS InputFileLocation
ReadS [InputFileLocation]
(Int -> ReadS InputFileLocation)
-> ReadS [InputFileLocation]
-> ReadPrec InputFileLocation
-> ReadPrec [InputFileLocation]
-> Read InputFileLocation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputFileLocation]
$creadListPrec :: ReadPrec [InputFileLocation]
readPrec :: ReadPrec InputFileLocation
$creadPrec :: ReadPrec InputFileLocation
readList :: ReadS [InputFileLocation]
$creadList :: ReadS [InputFileLocation]
readsPrec :: Int -> ReadS InputFileLocation
$creadsPrec :: Int -> ReadS InputFileLocation
Prelude.Read, Int -> InputFileLocation -> ShowS
[InputFileLocation] -> ShowS
InputFileLocation -> String
(Int -> InputFileLocation -> ShowS)
-> (InputFileLocation -> String)
-> ([InputFileLocation] -> ShowS)
-> Show InputFileLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputFileLocation] -> ShowS
$cshowList :: [InputFileLocation] -> ShowS
show :: InputFileLocation -> String
$cshow :: InputFileLocation -> String
showsPrec :: Int -> InputFileLocation -> ShowS
$cshowsPrec :: Int -> InputFileLocation -> ShowS
Prelude.Show, (forall x. InputFileLocation -> Rep InputFileLocation x)
-> (forall x. Rep InputFileLocation x -> InputFileLocation)
-> Generic InputFileLocation
forall x. Rep InputFileLocation x -> InputFileLocation
forall x. InputFileLocation -> Rep InputFileLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputFileLocation x -> InputFileLocation
$cfrom :: forall x. InputFileLocation -> Rep InputFileLocation x
Prelude.Generic)

-- |
-- Create a value of 'InputFileLocation' 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:
--
-- 'efsFileLocation', 'inputFileLocation_efsFileLocation' - Reserved for future use.
--
-- 's3FileLocation', 'inputFileLocation_s3FileLocation' - Specifies the details for the S3 file being copied.
newInputFileLocation ::
  InputFileLocation
newInputFileLocation :: InputFileLocation
newInputFileLocation =
  InputFileLocation' :: Maybe EfsFileLocation
-> Maybe S3InputFileLocation -> InputFileLocation
InputFileLocation'
    { $sel:efsFileLocation:InputFileLocation' :: Maybe EfsFileLocation
efsFileLocation =
        Maybe EfsFileLocation
forall a. Maybe a
Prelude.Nothing,
      $sel:s3FileLocation:InputFileLocation' :: Maybe S3InputFileLocation
s3FileLocation = Maybe S3InputFileLocation
forall a. Maybe a
Prelude.Nothing
    }

-- | Reserved for future use.
inputFileLocation_efsFileLocation :: Lens.Lens' InputFileLocation (Prelude.Maybe EfsFileLocation)
inputFileLocation_efsFileLocation :: (Maybe EfsFileLocation -> f (Maybe EfsFileLocation))
-> InputFileLocation -> f InputFileLocation
inputFileLocation_efsFileLocation = (InputFileLocation -> Maybe EfsFileLocation)
-> (InputFileLocation
    -> Maybe EfsFileLocation -> InputFileLocation)
-> Lens
     InputFileLocation
     InputFileLocation
     (Maybe EfsFileLocation)
     (Maybe EfsFileLocation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputFileLocation' {Maybe EfsFileLocation
efsFileLocation :: Maybe EfsFileLocation
$sel:efsFileLocation:InputFileLocation' :: InputFileLocation -> Maybe EfsFileLocation
efsFileLocation} -> Maybe EfsFileLocation
efsFileLocation) (\s :: InputFileLocation
s@InputFileLocation' {} Maybe EfsFileLocation
a -> InputFileLocation
s {$sel:efsFileLocation:InputFileLocation' :: Maybe EfsFileLocation
efsFileLocation = Maybe EfsFileLocation
a} :: InputFileLocation)

-- | Specifies the details for the S3 file being copied.
inputFileLocation_s3FileLocation :: Lens.Lens' InputFileLocation (Prelude.Maybe S3InputFileLocation)
inputFileLocation_s3FileLocation :: (Maybe S3InputFileLocation -> f (Maybe S3InputFileLocation))
-> InputFileLocation -> f InputFileLocation
inputFileLocation_s3FileLocation = (InputFileLocation -> Maybe S3InputFileLocation)
-> (InputFileLocation
    -> Maybe S3InputFileLocation -> InputFileLocation)
-> Lens
     InputFileLocation
     InputFileLocation
     (Maybe S3InputFileLocation)
     (Maybe S3InputFileLocation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputFileLocation' {Maybe S3InputFileLocation
s3FileLocation :: Maybe S3InputFileLocation
$sel:s3FileLocation:InputFileLocation' :: InputFileLocation -> Maybe S3InputFileLocation
s3FileLocation} -> Maybe S3InputFileLocation
s3FileLocation) (\s :: InputFileLocation
s@InputFileLocation' {} Maybe S3InputFileLocation
a -> InputFileLocation
s {$sel:s3FileLocation:InputFileLocation' :: Maybe S3InputFileLocation
s3FileLocation = Maybe S3InputFileLocation
a} :: InputFileLocation)

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

instance Prelude.Hashable InputFileLocation

instance Prelude.NFData InputFileLocation

instance Core.ToJSON InputFileLocation where
  toJSON :: InputFileLocation -> Value
toJSON InputFileLocation' {Maybe EfsFileLocation
Maybe S3InputFileLocation
s3FileLocation :: Maybe S3InputFileLocation
efsFileLocation :: Maybe EfsFileLocation
$sel:s3FileLocation:InputFileLocation' :: InputFileLocation -> Maybe S3InputFileLocation
$sel:efsFileLocation:InputFileLocation' :: InputFileLocation -> Maybe EfsFileLocation
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EfsFileLocation" Text -> EfsFileLocation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (EfsFileLocation -> Pair) -> Maybe EfsFileLocation -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EfsFileLocation
efsFileLocation,
            (Text
"S3FileLocation" Text -> S3InputFileLocation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (S3InputFileLocation -> Pair)
-> Maybe S3InputFileLocation -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3InputFileLocation
s3FileLocation
          ]
      )