{-# 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.S3InputFileLocation
-- 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.S3InputFileLocation 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

-- | Specifies the customer input S3 file location. If it is used inside
-- @copyStepDetails.DestinationFileLocation@, it should be the S3 copy
-- destination.
--
-- You need to provide the bucket and key. The key can represent either a
-- path or a file. This is determined by whether or not you end the key
-- value with the forward slash (\/) character. If the final character is
-- \"\/\", then your file is copied to the folder, and its name does not
-- change. If, rather, the final character is alphanumeric, your uploaded
-- file is renamed to the path value. In this case, if a file with that
-- name already exists, it is overwritten.
--
-- For example, if your path is @shared-files\/bob\/@, your uploaded files
-- are copied to the @shared-files\/bob\/@, folder. If your path is
-- @shared-files\/today@, each uploaded file is copied to the
-- @shared-files@ folder and named @today@: each upload overwrites the
-- previous version of the /bob/ file.
--
-- /See:/ 'newS3InputFileLocation' smart constructor.
data S3InputFileLocation = S3InputFileLocation'
  { -- | Specifies the S3 bucket for the customer input file.
    S3InputFileLocation -> Maybe Text
bucket :: Prelude.Maybe Prelude.Text,
    -- | The name assigned to the file when it was created in Amazon S3. You use
    -- the object key to retrieve the object.
    S3InputFileLocation -> Maybe Text
key :: Prelude.Maybe Prelude.Text
  }
  deriving (S3InputFileLocation -> S3InputFileLocation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3InputFileLocation -> S3InputFileLocation -> Bool
$c/= :: S3InputFileLocation -> S3InputFileLocation -> Bool
== :: S3InputFileLocation -> S3InputFileLocation -> Bool
$c== :: S3InputFileLocation -> S3InputFileLocation -> Bool
Prelude.Eq, ReadPrec [S3InputFileLocation]
ReadPrec S3InputFileLocation
Int -> ReadS S3InputFileLocation
ReadS [S3InputFileLocation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3InputFileLocation]
$creadListPrec :: ReadPrec [S3InputFileLocation]
readPrec :: ReadPrec S3InputFileLocation
$creadPrec :: ReadPrec S3InputFileLocation
readList :: ReadS [S3InputFileLocation]
$creadList :: ReadS [S3InputFileLocation]
readsPrec :: Int -> ReadS S3InputFileLocation
$creadsPrec :: Int -> ReadS S3InputFileLocation
Prelude.Read, Int -> S3InputFileLocation -> ShowS
[S3InputFileLocation] -> ShowS
S3InputFileLocation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3InputFileLocation] -> ShowS
$cshowList :: [S3InputFileLocation] -> ShowS
show :: S3InputFileLocation -> String
$cshow :: S3InputFileLocation -> String
showsPrec :: Int -> S3InputFileLocation -> ShowS
$cshowsPrec :: Int -> S3InputFileLocation -> ShowS
Prelude.Show, forall x. Rep S3InputFileLocation x -> S3InputFileLocation
forall x. S3InputFileLocation -> Rep S3InputFileLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3InputFileLocation x -> S3InputFileLocation
$cfrom :: forall x. S3InputFileLocation -> Rep S3InputFileLocation x
Prelude.Generic)

-- |
-- Create a value of 'S3InputFileLocation' 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:
--
-- 'bucket', 's3InputFileLocation_bucket' - Specifies the S3 bucket for the customer input file.
--
-- 'key', 's3InputFileLocation_key' - The name assigned to the file when it was created in Amazon S3. You use
-- the object key to retrieve the object.
newS3InputFileLocation ::
  S3InputFileLocation
newS3InputFileLocation :: S3InputFileLocation
newS3InputFileLocation =
  S3InputFileLocation'
    { $sel:bucket:S3InputFileLocation' :: Maybe Text
bucket = forall a. Maybe a
Prelude.Nothing,
      $sel:key:S3InputFileLocation' :: Maybe Text
key = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the S3 bucket for the customer input file.
s3InputFileLocation_bucket :: Lens.Lens' S3InputFileLocation (Prelude.Maybe Prelude.Text)
s3InputFileLocation_bucket :: Lens' S3InputFileLocation (Maybe Text)
s3InputFileLocation_bucket = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3InputFileLocation' {Maybe Text
bucket :: Maybe Text
$sel:bucket:S3InputFileLocation' :: S3InputFileLocation -> Maybe Text
bucket} -> Maybe Text
bucket) (\s :: S3InputFileLocation
s@S3InputFileLocation' {} Maybe Text
a -> S3InputFileLocation
s {$sel:bucket:S3InputFileLocation' :: Maybe Text
bucket = Maybe Text
a} :: S3InputFileLocation)

-- | The name assigned to the file when it was created in Amazon S3. You use
-- the object key to retrieve the object.
s3InputFileLocation_key :: Lens.Lens' S3InputFileLocation (Prelude.Maybe Prelude.Text)
s3InputFileLocation_key :: Lens' S3InputFileLocation (Maybe Text)
s3InputFileLocation_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3InputFileLocation' {Maybe Text
key :: Maybe Text
$sel:key:S3InputFileLocation' :: S3InputFileLocation -> Maybe Text
key} -> Maybe Text
key) (\s :: S3InputFileLocation
s@S3InputFileLocation' {} Maybe Text
a -> S3InputFileLocation
s {$sel:key:S3InputFileLocation' :: Maybe Text
key = Maybe Text
a} :: S3InputFileLocation)

instance Data.FromJSON S3InputFileLocation where
  parseJSON :: Value -> Parser S3InputFileLocation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3InputFileLocation"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> S3InputFileLocation
S3InputFileLocation'
            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
"Bucket")
            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
"Key")
      )

instance Prelude.Hashable S3InputFileLocation where
  hashWithSalt :: Int -> S3InputFileLocation -> Int
hashWithSalt Int
_salt S3InputFileLocation' {Maybe Text
key :: Maybe Text
bucket :: Maybe Text
$sel:key:S3InputFileLocation' :: S3InputFileLocation -> Maybe Text
$sel:bucket:S3InputFileLocation' :: S3InputFileLocation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
bucket
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
key

instance Prelude.NFData S3InputFileLocation where
  rnf :: S3InputFileLocation -> ()
rnf S3InputFileLocation' {Maybe Text
key :: Maybe Text
bucket :: Maybe Text
$sel:key:S3InputFileLocation' :: S3InputFileLocation -> Maybe Text
$sel:bucket:S3InputFileLocation' :: S3InputFileLocation -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
bucket seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
key

instance Data.ToJSON S3InputFileLocation where
  toJSON :: S3InputFileLocation -> Value
toJSON S3InputFileLocation' {Maybe Text
key :: Maybe Text
bucket :: Maybe Text
$sel:key:S3InputFileLocation' :: S3InputFileLocation -> Maybe Text
$sel:bucket:S3InputFileLocation' :: S3InputFileLocation -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Bucket" 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
bucket,
            (Key
"Key" 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
key
          ]
      )