{-# 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.MediaPackage.Types.S3Destination
-- 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.MediaPackage.Types.S3Destination 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

-- | Configuration parameters for where in an S3 bucket to place the
-- harvested content
--
-- /See:/ 'newS3Destination' smart constructor.
data S3Destination = S3Destination'
  { -- | The key in the specified S3 bucket where the harvested top-level
    -- manifest will be placed.
    S3Destination -> Text
manifestKey :: Prelude.Text,
    -- | The name of an S3 bucket within which harvested content will be exported
    S3Destination -> Text
bucketName :: Prelude.Text,
    -- | The IAM role used to write to the specified S3 bucket
    S3Destination -> Text
roleArn :: Prelude.Text
  }
  deriving (S3Destination -> S3Destination -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Destination -> S3Destination -> Bool
$c/= :: S3Destination -> S3Destination -> Bool
== :: S3Destination -> S3Destination -> Bool
$c== :: S3Destination -> S3Destination -> Bool
Prelude.Eq, ReadPrec [S3Destination]
ReadPrec S3Destination
Int -> ReadS S3Destination
ReadS [S3Destination]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Destination]
$creadListPrec :: ReadPrec [S3Destination]
readPrec :: ReadPrec S3Destination
$creadPrec :: ReadPrec S3Destination
readList :: ReadS [S3Destination]
$creadList :: ReadS [S3Destination]
readsPrec :: Int -> ReadS S3Destination
$creadsPrec :: Int -> ReadS S3Destination
Prelude.Read, Int -> S3Destination -> ShowS
[S3Destination] -> ShowS
S3Destination -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Destination] -> ShowS
$cshowList :: [S3Destination] -> ShowS
show :: S3Destination -> String
$cshow :: S3Destination -> String
showsPrec :: Int -> S3Destination -> ShowS
$cshowsPrec :: Int -> S3Destination -> ShowS
Prelude.Show, forall x. Rep S3Destination x -> S3Destination
forall x. S3Destination -> Rep S3Destination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Destination x -> S3Destination
$cfrom :: forall x. S3Destination -> Rep S3Destination x
Prelude.Generic)

-- |
-- Create a value of 'S3Destination' 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:
--
-- 'manifestKey', 's3Destination_manifestKey' - The key in the specified S3 bucket where the harvested top-level
-- manifest will be placed.
--
-- 'bucketName', 's3Destination_bucketName' - The name of an S3 bucket within which harvested content will be exported
--
-- 'roleArn', 's3Destination_roleArn' - The IAM role used to write to the specified S3 bucket
newS3Destination ::
  -- | 'manifestKey'
  Prelude.Text ->
  -- | 'bucketName'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  S3Destination
newS3Destination :: Text -> Text -> Text -> S3Destination
newS3Destination Text
pManifestKey_ Text
pBucketName_ Text
pRoleArn_ =
  S3Destination'
    { $sel:manifestKey:S3Destination' :: Text
manifestKey = Text
pManifestKey_,
      $sel:bucketName:S3Destination' :: Text
bucketName = Text
pBucketName_,
      $sel:roleArn:S3Destination' :: Text
roleArn = Text
pRoleArn_
    }

-- | The key in the specified S3 bucket where the harvested top-level
-- manifest will be placed.
s3Destination_manifestKey :: Lens.Lens' S3Destination Prelude.Text
s3Destination_manifestKey :: Lens' S3Destination Text
s3Destination_manifestKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Destination' {Text
manifestKey :: Text
$sel:manifestKey:S3Destination' :: S3Destination -> Text
manifestKey} -> Text
manifestKey) (\s :: S3Destination
s@S3Destination' {} Text
a -> S3Destination
s {$sel:manifestKey:S3Destination' :: Text
manifestKey = Text
a} :: S3Destination)

-- | The name of an S3 bucket within which harvested content will be exported
s3Destination_bucketName :: Lens.Lens' S3Destination Prelude.Text
s3Destination_bucketName :: Lens' S3Destination Text
s3Destination_bucketName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Destination' {Text
bucketName :: Text
$sel:bucketName:S3Destination' :: S3Destination -> Text
bucketName} -> Text
bucketName) (\s :: S3Destination
s@S3Destination' {} Text
a -> S3Destination
s {$sel:bucketName:S3Destination' :: Text
bucketName = Text
a} :: S3Destination)

-- | The IAM role used to write to the specified S3 bucket
s3Destination_roleArn :: Lens.Lens' S3Destination Prelude.Text
s3Destination_roleArn :: Lens' S3Destination Text
s3Destination_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Destination' {Text
roleArn :: Text
$sel:roleArn:S3Destination' :: S3Destination -> Text
roleArn} -> Text
roleArn) (\s :: S3Destination
s@S3Destination' {} Text
a -> S3Destination
s {$sel:roleArn:S3Destination' :: Text
roleArn = Text
a} :: S3Destination)

instance Data.FromJSON S3Destination where
  parseJSON :: Value -> Parser S3Destination
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3Destination"
      ( \Object
x ->
          Text -> Text -> Text -> S3Destination
S3Destination'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"manifestKey")
            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
"bucketName")
            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
"roleArn")
      )

instance Prelude.Hashable S3Destination where
  hashWithSalt :: Int -> S3Destination -> Int
hashWithSalt Int
_salt S3Destination' {Text
roleArn :: Text
bucketName :: Text
manifestKey :: Text
$sel:roleArn:S3Destination' :: S3Destination -> Text
$sel:bucketName:S3Destination' :: S3Destination -> Text
$sel:manifestKey:S3Destination' :: S3Destination -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
manifestKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
bucketName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleArn

instance Prelude.NFData S3Destination where
  rnf :: S3Destination -> ()
rnf S3Destination' {Text
roleArn :: Text
bucketName :: Text
manifestKey :: Text
$sel:roleArn:S3Destination' :: S3Destination -> Text
$sel:bucketName:S3Destination' :: S3Destination -> Text
$sel:manifestKey:S3Destination' :: S3Destination -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
manifestKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
bucketName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleArn

instance Data.ToJSON S3Destination where
  toJSON :: S3Destination -> Value
toJSON S3Destination' {Text
roleArn :: Text
bucketName :: Text
manifestKey :: Text
$sel:roleArn:S3Destination' :: S3Destination -> Text
$sel:bucketName:S3Destination' :: S3Destination -> Text
$sel:manifestKey:S3Destination' :: S3Destination -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"manifestKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
manifestKey),
            forall a. a -> Maybe a
Prelude.Just (Key
"bucketName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
bucketName),
            forall a. a -> Maybe a
Prelude.Just (Key
"roleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
roleArn)
          ]
      )