{-# 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.KinesisAnalyticsV2.Types.S3ContentLocation
-- 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.KinesisAnalyticsV2.Types.S3ContentLocation 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

-- | For a Kinesis Data Analytics application provides a description of an
-- Amazon S3 object, including the Amazon Resource Name (ARN) of the S3
-- bucket, the name of the Amazon S3 object that contains the data, and the
-- version number of the Amazon S3 object that contains the data.
--
-- /See:/ 'newS3ContentLocation' smart constructor.
data S3ContentLocation = S3ContentLocation'
  { -- | The version of the object containing the application code.
    S3ContentLocation -> Maybe Text
objectVersion :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) for the S3 bucket containing the
    -- application code.
    S3ContentLocation -> Text
bucketARN :: Prelude.Text,
    -- | The file key for the object containing the application code.
    S3ContentLocation -> Text
fileKey :: Prelude.Text
  }
  deriving (S3ContentLocation -> S3ContentLocation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3ContentLocation -> S3ContentLocation -> Bool
$c/= :: S3ContentLocation -> S3ContentLocation -> Bool
== :: S3ContentLocation -> S3ContentLocation -> Bool
$c== :: S3ContentLocation -> S3ContentLocation -> Bool
Prelude.Eq, ReadPrec [S3ContentLocation]
ReadPrec S3ContentLocation
Int -> ReadS S3ContentLocation
ReadS [S3ContentLocation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3ContentLocation]
$creadListPrec :: ReadPrec [S3ContentLocation]
readPrec :: ReadPrec S3ContentLocation
$creadPrec :: ReadPrec S3ContentLocation
readList :: ReadS [S3ContentLocation]
$creadList :: ReadS [S3ContentLocation]
readsPrec :: Int -> ReadS S3ContentLocation
$creadsPrec :: Int -> ReadS S3ContentLocation
Prelude.Read, Int -> S3ContentLocation -> ShowS
[S3ContentLocation] -> ShowS
S3ContentLocation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3ContentLocation] -> ShowS
$cshowList :: [S3ContentLocation] -> ShowS
show :: S3ContentLocation -> String
$cshow :: S3ContentLocation -> String
showsPrec :: Int -> S3ContentLocation -> ShowS
$cshowsPrec :: Int -> S3ContentLocation -> ShowS
Prelude.Show, forall x. Rep S3ContentLocation x -> S3ContentLocation
forall x. S3ContentLocation -> Rep S3ContentLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3ContentLocation x -> S3ContentLocation
$cfrom :: forall x. S3ContentLocation -> Rep S3ContentLocation x
Prelude.Generic)

-- |
-- Create a value of 'S3ContentLocation' 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:
--
-- 'objectVersion', 's3ContentLocation_objectVersion' - The version of the object containing the application code.
--
-- 'bucketARN', 's3ContentLocation_bucketARN' - The Amazon Resource Name (ARN) for the S3 bucket containing the
-- application code.
--
-- 'fileKey', 's3ContentLocation_fileKey' - The file key for the object containing the application code.
newS3ContentLocation ::
  -- | 'bucketARN'
  Prelude.Text ->
  -- | 'fileKey'
  Prelude.Text ->
  S3ContentLocation
newS3ContentLocation :: Text -> Text -> S3ContentLocation
newS3ContentLocation Text
pBucketARN_ Text
pFileKey_ =
  S3ContentLocation'
    { $sel:objectVersion:S3ContentLocation' :: Maybe Text
objectVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:bucketARN:S3ContentLocation' :: Text
bucketARN = Text
pBucketARN_,
      $sel:fileKey:S3ContentLocation' :: Text
fileKey = Text
pFileKey_
    }

-- | The version of the object containing the application code.
s3ContentLocation_objectVersion :: Lens.Lens' S3ContentLocation (Prelude.Maybe Prelude.Text)
s3ContentLocation_objectVersion :: Lens' S3ContentLocation (Maybe Text)
s3ContentLocation_objectVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ContentLocation' {Maybe Text
objectVersion :: Maybe Text
$sel:objectVersion:S3ContentLocation' :: S3ContentLocation -> Maybe Text
objectVersion} -> Maybe Text
objectVersion) (\s :: S3ContentLocation
s@S3ContentLocation' {} Maybe Text
a -> S3ContentLocation
s {$sel:objectVersion:S3ContentLocation' :: Maybe Text
objectVersion = Maybe Text
a} :: S3ContentLocation)

-- | The Amazon Resource Name (ARN) for the S3 bucket containing the
-- application code.
s3ContentLocation_bucketARN :: Lens.Lens' S3ContentLocation Prelude.Text
s3ContentLocation_bucketARN :: Lens' S3ContentLocation Text
s3ContentLocation_bucketARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ContentLocation' {Text
bucketARN :: Text
$sel:bucketARN:S3ContentLocation' :: S3ContentLocation -> Text
bucketARN} -> Text
bucketARN) (\s :: S3ContentLocation
s@S3ContentLocation' {} Text
a -> S3ContentLocation
s {$sel:bucketARN:S3ContentLocation' :: Text
bucketARN = Text
a} :: S3ContentLocation)

-- | The file key for the object containing the application code.
s3ContentLocation_fileKey :: Lens.Lens' S3ContentLocation Prelude.Text
s3ContentLocation_fileKey :: Lens' S3ContentLocation Text
s3ContentLocation_fileKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ContentLocation' {Text
fileKey :: Text
$sel:fileKey:S3ContentLocation' :: S3ContentLocation -> Text
fileKey} -> Text
fileKey) (\s :: S3ContentLocation
s@S3ContentLocation' {} Text
a -> S3ContentLocation
s {$sel:fileKey:S3ContentLocation' :: Text
fileKey = Text
a} :: S3ContentLocation)

instance Data.FromJSON S3ContentLocation where
  parseJSON :: Value -> Parser S3ContentLocation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3ContentLocation"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> S3ContentLocation
S3ContentLocation'
            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
"ObjectVersion")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"BucketARN")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"FileKey")
      )

instance Prelude.Hashable S3ContentLocation where
  hashWithSalt :: Int -> S3ContentLocation -> Int
hashWithSalt Int
_salt S3ContentLocation' {Maybe Text
Text
fileKey :: Text
bucketARN :: Text
objectVersion :: Maybe Text
$sel:fileKey:S3ContentLocation' :: S3ContentLocation -> Text
$sel:bucketARN:S3ContentLocation' :: S3ContentLocation -> Text
$sel:objectVersion:S3ContentLocation' :: S3ContentLocation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
objectVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
bucketARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fileKey

instance Prelude.NFData S3ContentLocation where
  rnf :: S3ContentLocation -> ()
rnf S3ContentLocation' {Maybe Text
Text
fileKey :: Text
bucketARN :: Text
objectVersion :: Maybe Text
$sel:fileKey:S3ContentLocation' :: S3ContentLocation -> Text
$sel:bucketARN:S3ContentLocation' :: S3ContentLocation -> Text
$sel:objectVersion:S3ContentLocation' :: S3ContentLocation -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
objectVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
bucketARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
fileKey

instance Data.ToJSON S3ContentLocation where
  toJSON :: S3ContentLocation -> Value
toJSON S3ContentLocation' {Maybe Text
Text
fileKey :: Text
bucketARN :: Text
objectVersion :: Maybe Text
$sel:fileKey:S3ContentLocation' :: S3ContentLocation -> Text
$sel:bucketARN:S3ContentLocation' :: S3ContentLocation -> Text
$sel:objectVersion:S3ContentLocation' :: S3ContentLocation -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ObjectVersion" 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
objectVersion,
            forall a. a -> Maybe a
Prelude.Just (Key
"BucketARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
bucketARN),
            forall a. a -> Maybe a
Prelude.Just (Key
"FileKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
fileKey)
          ]
      )