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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies the details for the file location for the file being used in
-- the workflow. Only applicable if you are using S3 storage.
--
-- /See:/ 'newS3FileLocation' smart constructor.
data S3FileLocation = S3FileLocation'
  { -- | Specifies the file version.
    S3FileLocation -> Maybe Text
versionId :: Prelude.Maybe Prelude.Text,
    -- | The entity tag is a hash of the object. The ETag reflects changes only
    -- to the contents of an object, not its metadata.
    S3FileLocation -> Maybe Text
etag :: Prelude.Maybe Prelude.Text,
    -- | Specifies the S3 bucket that contains the file being used.
    S3FileLocation -> Maybe Text
bucket :: Prelude.Maybe Prelude.Text,
    -- | The name assigned to the file when it was created in S3. You use the
    -- object key to retrieve the object.
    S3FileLocation -> Maybe Text
key :: Prelude.Maybe Prelude.Text
  }
  deriving (S3FileLocation -> S3FileLocation -> Bool
(S3FileLocation -> S3FileLocation -> Bool)
-> (S3FileLocation -> S3FileLocation -> Bool) -> Eq S3FileLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3FileLocation -> S3FileLocation -> Bool
$c/= :: S3FileLocation -> S3FileLocation -> Bool
== :: S3FileLocation -> S3FileLocation -> Bool
$c== :: S3FileLocation -> S3FileLocation -> Bool
Prelude.Eq, ReadPrec [S3FileLocation]
ReadPrec S3FileLocation
Int -> ReadS S3FileLocation
ReadS [S3FileLocation]
(Int -> ReadS S3FileLocation)
-> ReadS [S3FileLocation]
-> ReadPrec S3FileLocation
-> ReadPrec [S3FileLocation]
-> Read S3FileLocation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3FileLocation]
$creadListPrec :: ReadPrec [S3FileLocation]
readPrec :: ReadPrec S3FileLocation
$creadPrec :: ReadPrec S3FileLocation
readList :: ReadS [S3FileLocation]
$creadList :: ReadS [S3FileLocation]
readsPrec :: Int -> ReadS S3FileLocation
$creadsPrec :: Int -> ReadS S3FileLocation
Prelude.Read, Int -> S3FileLocation -> ShowS
[S3FileLocation] -> ShowS
S3FileLocation -> String
(Int -> S3FileLocation -> ShowS)
-> (S3FileLocation -> String)
-> ([S3FileLocation] -> ShowS)
-> Show S3FileLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3FileLocation] -> ShowS
$cshowList :: [S3FileLocation] -> ShowS
show :: S3FileLocation -> String
$cshow :: S3FileLocation -> String
showsPrec :: Int -> S3FileLocation -> ShowS
$cshowsPrec :: Int -> S3FileLocation -> ShowS
Prelude.Show, (forall x. S3FileLocation -> Rep S3FileLocation x)
-> (forall x. Rep S3FileLocation x -> S3FileLocation)
-> Generic S3FileLocation
forall x. Rep S3FileLocation x -> S3FileLocation
forall x. S3FileLocation -> Rep S3FileLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3FileLocation x -> S3FileLocation
$cfrom :: forall x. S3FileLocation -> Rep S3FileLocation x
Prelude.Generic)

-- |
-- Create a value of 'S3FileLocation' 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:
--
-- 'versionId', 's3FileLocation_versionId' - Specifies the file version.
--
-- 'etag', 's3FileLocation_etag' - The entity tag is a hash of the object. The ETag reflects changes only
-- to the contents of an object, not its metadata.
--
-- 'bucket', 's3FileLocation_bucket' - Specifies the S3 bucket that contains the file being used.
--
-- 'key', 's3FileLocation_key' - The name assigned to the file when it was created in S3. You use the
-- object key to retrieve the object.
newS3FileLocation ::
  S3FileLocation
newS3FileLocation :: S3FileLocation
newS3FileLocation =
  S3FileLocation' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> S3FileLocation
S3FileLocation'
    { $sel:versionId:S3FileLocation' :: Maybe Text
versionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:etag:S3FileLocation' :: Maybe Text
etag = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:S3FileLocation' :: Maybe Text
bucket = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:S3FileLocation' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the file version.
s3FileLocation_versionId :: Lens.Lens' S3FileLocation (Prelude.Maybe Prelude.Text)
s3FileLocation_versionId :: (Maybe Text -> f (Maybe Text))
-> S3FileLocation -> f S3FileLocation
s3FileLocation_versionId = (S3FileLocation -> Maybe Text)
-> (S3FileLocation -> Maybe Text -> S3FileLocation)
-> Lens S3FileLocation S3FileLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3FileLocation' {Maybe Text
versionId :: Maybe Text
$sel:versionId:S3FileLocation' :: S3FileLocation -> Maybe Text
versionId} -> Maybe Text
versionId) (\s :: S3FileLocation
s@S3FileLocation' {} Maybe Text
a -> S3FileLocation
s {$sel:versionId:S3FileLocation' :: Maybe Text
versionId = Maybe Text
a} :: S3FileLocation)

-- | The entity tag is a hash of the object. The ETag reflects changes only
-- to the contents of an object, not its metadata.
s3FileLocation_etag :: Lens.Lens' S3FileLocation (Prelude.Maybe Prelude.Text)
s3FileLocation_etag :: (Maybe Text -> f (Maybe Text))
-> S3FileLocation -> f S3FileLocation
s3FileLocation_etag = (S3FileLocation -> Maybe Text)
-> (S3FileLocation -> Maybe Text -> S3FileLocation)
-> Lens S3FileLocation S3FileLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3FileLocation' {Maybe Text
etag :: Maybe Text
$sel:etag:S3FileLocation' :: S3FileLocation -> Maybe Text
etag} -> Maybe Text
etag) (\s :: S3FileLocation
s@S3FileLocation' {} Maybe Text
a -> S3FileLocation
s {$sel:etag:S3FileLocation' :: Maybe Text
etag = Maybe Text
a} :: S3FileLocation)

-- | Specifies the S3 bucket that contains the file being used.
s3FileLocation_bucket :: Lens.Lens' S3FileLocation (Prelude.Maybe Prelude.Text)
s3FileLocation_bucket :: (Maybe Text -> f (Maybe Text))
-> S3FileLocation -> f S3FileLocation
s3FileLocation_bucket = (S3FileLocation -> Maybe Text)
-> (S3FileLocation -> Maybe Text -> S3FileLocation)
-> Lens S3FileLocation S3FileLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3FileLocation' {Maybe Text
bucket :: Maybe Text
$sel:bucket:S3FileLocation' :: S3FileLocation -> Maybe Text
bucket} -> Maybe Text
bucket) (\s :: S3FileLocation
s@S3FileLocation' {} Maybe Text
a -> S3FileLocation
s {$sel:bucket:S3FileLocation' :: Maybe Text
bucket = Maybe Text
a} :: S3FileLocation)

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

instance Core.FromJSON S3FileLocation where
  parseJSON :: Value -> Parser S3FileLocation
parseJSON =
    String
-> (Object -> Parser S3FileLocation)
-> Value
-> Parser S3FileLocation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3FileLocation"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> S3FileLocation
S3FileLocation'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> S3FileLocation)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> S3FileLocation)
forall (f :: * -> *) a b. Functor 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
"VersionId")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> S3FileLocation)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> S3FileLocation)
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
"Etag")
            Parser (Maybe Text -> Maybe Text -> S3FileLocation)
-> Parser (Maybe Text) -> Parser (Maybe Text -> S3FileLocation)
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
"Bucket")
            Parser (Maybe Text -> S3FileLocation)
-> Parser (Maybe Text) -> Parser S3FileLocation
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
"Key")
      )

instance Prelude.Hashable S3FileLocation

instance Prelude.NFData S3FileLocation