{-# 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.FileLocation
-- 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.FileLocation 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.S3FileLocation

-- | Specifies the Amazon S3 or EFS file details to be used in the step.
--
-- /See:/ 'newFileLocation' smart constructor.
data FileLocation = FileLocation'
  { -- | Specifies the Amazon EFS ID and the path for the file being used.
    FileLocation -> Maybe EfsFileLocation
efsFileLocation :: Prelude.Maybe EfsFileLocation,
    -- | Specifies the S3 details for the file being used, such as bucket, Etag,
    -- and so forth.
    FileLocation -> Maybe S3FileLocation
s3FileLocation :: Prelude.Maybe S3FileLocation
  }
  deriving (FileLocation -> FileLocation -> Bool
(FileLocation -> FileLocation -> Bool)
-> (FileLocation -> FileLocation -> Bool) -> Eq FileLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileLocation -> FileLocation -> Bool
$c/= :: FileLocation -> FileLocation -> Bool
== :: FileLocation -> FileLocation -> Bool
$c== :: FileLocation -> FileLocation -> Bool
Prelude.Eq, ReadPrec [FileLocation]
ReadPrec FileLocation
Int -> ReadS FileLocation
ReadS [FileLocation]
(Int -> ReadS FileLocation)
-> ReadS [FileLocation]
-> ReadPrec FileLocation
-> ReadPrec [FileLocation]
-> Read FileLocation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FileLocation]
$creadListPrec :: ReadPrec [FileLocation]
readPrec :: ReadPrec FileLocation
$creadPrec :: ReadPrec FileLocation
readList :: ReadS [FileLocation]
$creadList :: ReadS [FileLocation]
readsPrec :: Int -> ReadS FileLocation
$creadsPrec :: Int -> ReadS FileLocation
Prelude.Read, Int -> FileLocation -> ShowS
[FileLocation] -> ShowS
FileLocation -> String
(Int -> FileLocation -> ShowS)
-> (FileLocation -> String)
-> ([FileLocation] -> ShowS)
-> Show FileLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileLocation] -> ShowS
$cshowList :: [FileLocation] -> ShowS
show :: FileLocation -> String
$cshow :: FileLocation -> String
showsPrec :: Int -> FileLocation -> ShowS
$cshowsPrec :: Int -> FileLocation -> ShowS
Prelude.Show, (forall x. FileLocation -> Rep FileLocation x)
-> (forall x. Rep FileLocation x -> FileLocation)
-> Generic FileLocation
forall x. Rep FileLocation x -> FileLocation
forall x. FileLocation -> Rep FileLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FileLocation x -> FileLocation
$cfrom :: forall x. FileLocation -> Rep FileLocation x
Prelude.Generic)

-- |
-- Create a value of 'FileLocation' 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', 'fileLocation_efsFileLocation' - Specifies the Amazon EFS ID and the path for the file being used.
--
-- 's3FileLocation', 'fileLocation_s3FileLocation' - Specifies the S3 details for the file being used, such as bucket, Etag,
-- and so forth.
newFileLocation ::
  FileLocation
newFileLocation :: FileLocation
newFileLocation =
  FileLocation' :: Maybe EfsFileLocation -> Maybe S3FileLocation -> FileLocation
FileLocation'
    { $sel:efsFileLocation:FileLocation' :: Maybe EfsFileLocation
efsFileLocation = Maybe EfsFileLocation
forall a. Maybe a
Prelude.Nothing,
      $sel:s3FileLocation:FileLocation' :: Maybe S3FileLocation
s3FileLocation = Maybe S3FileLocation
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the Amazon EFS ID and the path for the file being used.
fileLocation_efsFileLocation :: Lens.Lens' FileLocation (Prelude.Maybe EfsFileLocation)
fileLocation_efsFileLocation :: (Maybe EfsFileLocation -> f (Maybe EfsFileLocation))
-> FileLocation -> f FileLocation
fileLocation_efsFileLocation = (FileLocation -> Maybe EfsFileLocation)
-> (FileLocation -> Maybe EfsFileLocation -> FileLocation)
-> Lens
     FileLocation
     FileLocation
     (Maybe EfsFileLocation)
     (Maybe EfsFileLocation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileLocation' {Maybe EfsFileLocation
efsFileLocation :: Maybe EfsFileLocation
$sel:efsFileLocation:FileLocation' :: FileLocation -> Maybe EfsFileLocation
efsFileLocation} -> Maybe EfsFileLocation
efsFileLocation) (\s :: FileLocation
s@FileLocation' {} Maybe EfsFileLocation
a -> FileLocation
s {$sel:efsFileLocation:FileLocation' :: Maybe EfsFileLocation
efsFileLocation = Maybe EfsFileLocation
a} :: FileLocation)

-- | Specifies the S3 details for the file being used, such as bucket, Etag,
-- and so forth.
fileLocation_s3FileLocation :: Lens.Lens' FileLocation (Prelude.Maybe S3FileLocation)
fileLocation_s3FileLocation :: (Maybe S3FileLocation -> f (Maybe S3FileLocation))
-> FileLocation -> f FileLocation
fileLocation_s3FileLocation = (FileLocation -> Maybe S3FileLocation)
-> (FileLocation -> Maybe S3FileLocation -> FileLocation)
-> Lens
     FileLocation
     FileLocation
     (Maybe S3FileLocation)
     (Maybe S3FileLocation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileLocation' {Maybe S3FileLocation
s3FileLocation :: Maybe S3FileLocation
$sel:s3FileLocation:FileLocation' :: FileLocation -> Maybe S3FileLocation
s3FileLocation} -> Maybe S3FileLocation
s3FileLocation) (\s :: FileLocation
s@FileLocation' {} Maybe S3FileLocation
a -> FileLocation
s {$sel:s3FileLocation:FileLocation' :: Maybe S3FileLocation
s3FileLocation = Maybe S3FileLocation
a} :: FileLocation)

instance Core.FromJSON FileLocation where
  parseJSON :: Value -> Parser FileLocation
parseJSON =
    String
-> (Object -> Parser FileLocation) -> Value -> Parser FileLocation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FileLocation"
      ( \Object
x ->
          Maybe EfsFileLocation -> Maybe S3FileLocation -> FileLocation
FileLocation'
            (Maybe EfsFileLocation -> Maybe S3FileLocation -> FileLocation)
-> Parser (Maybe EfsFileLocation)
-> Parser (Maybe S3FileLocation -> FileLocation)
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 S3FileLocation -> FileLocation)
-> Parser (Maybe S3FileLocation) -> Parser FileLocation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe S3FileLocation)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"S3FileLocation")
      )

instance Prelude.Hashable FileLocation

instance Prelude.NFData FileLocation