{-# 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.MediaConvert.Types.S3DestinationSettings
-- 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.MediaConvert.Types.S3DestinationSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaConvert.Types.S3DestinationAccessControl
import Amazonka.MediaConvert.Types.S3EncryptionSettings
import qualified Amazonka.Prelude as Prelude

-- | Settings associated with S3 destination
--
-- /See:/ 'newS3DestinationSettings' smart constructor.
data S3DestinationSettings = S3DestinationSettings'
  { -- | Optional. Have MediaConvert automatically apply Amazon S3 access control
    -- for the outputs in this output group. When you don\'t use this setting,
    -- S3 automatically applies the default access control list PRIVATE.
    S3DestinationSettings -> Maybe S3DestinationAccessControl
accessControl :: Prelude.Maybe S3DestinationAccessControl,
    -- | Settings for how your job outputs are encrypted as they are uploaded to
    -- Amazon S3.
    S3DestinationSettings -> Maybe S3EncryptionSettings
encryption :: Prelude.Maybe S3EncryptionSettings
  }
  deriving (S3DestinationSettings -> S3DestinationSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3DestinationSettings -> S3DestinationSettings -> Bool
$c/= :: S3DestinationSettings -> S3DestinationSettings -> Bool
== :: S3DestinationSettings -> S3DestinationSettings -> Bool
$c== :: S3DestinationSettings -> S3DestinationSettings -> Bool
Prelude.Eq, ReadPrec [S3DestinationSettings]
ReadPrec S3DestinationSettings
Int -> ReadS S3DestinationSettings
ReadS [S3DestinationSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3DestinationSettings]
$creadListPrec :: ReadPrec [S3DestinationSettings]
readPrec :: ReadPrec S3DestinationSettings
$creadPrec :: ReadPrec S3DestinationSettings
readList :: ReadS [S3DestinationSettings]
$creadList :: ReadS [S3DestinationSettings]
readsPrec :: Int -> ReadS S3DestinationSettings
$creadsPrec :: Int -> ReadS S3DestinationSettings
Prelude.Read, Int -> S3DestinationSettings -> ShowS
[S3DestinationSettings] -> ShowS
S3DestinationSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3DestinationSettings] -> ShowS
$cshowList :: [S3DestinationSettings] -> ShowS
show :: S3DestinationSettings -> String
$cshow :: S3DestinationSettings -> String
showsPrec :: Int -> S3DestinationSettings -> ShowS
$cshowsPrec :: Int -> S3DestinationSettings -> ShowS
Prelude.Show, forall x. Rep S3DestinationSettings x -> S3DestinationSettings
forall x. S3DestinationSettings -> Rep S3DestinationSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3DestinationSettings x -> S3DestinationSettings
$cfrom :: forall x. S3DestinationSettings -> Rep S3DestinationSettings x
Prelude.Generic)

-- |
-- Create a value of 'S3DestinationSettings' 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:
--
-- 'accessControl', 's3DestinationSettings_accessControl' - Optional. Have MediaConvert automatically apply Amazon S3 access control
-- for the outputs in this output group. When you don\'t use this setting,
-- S3 automatically applies the default access control list PRIVATE.
--
-- 'encryption', 's3DestinationSettings_encryption' - Settings for how your job outputs are encrypted as they are uploaded to
-- Amazon S3.
newS3DestinationSettings ::
  S3DestinationSettings
newS3DestinationSettings :: S3DestinationSettings
newS3DestinationSettings =
  S3DestinationSettings'
    { $sel:accessControl:S3DestinationSettings' :: Maybe S3DestinationAccessControl
accessControl =
        forall a. Maybe a
Prelude.Nothing,
      $sel:encryption:S3DestinationSettings' :: Maybe S3EncryptionSettings
encryption = forall a. Maybe a
Prelude.Nothing
    }

-- | Optional. Have MediaConvert automatically apply Amazon S3 access control
-- for the outputs in this output group. When you don\'t use this setting,
-- S3 automatically applies the default access control list PRIVATE.
s3DestinationSettings_accessControl :: Lens.Lens' S3DestinationSettings (Prelude.Maybe S3DestinationAccessControl)
s3DestinationSettings_accessControl :: Lens' S3DestinationSettings (Maybe S3DestinationAccessControl)
s3DestinationSettings_accessControl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3DestinationSettings' {Maybe S3DestinationAccessControl
accessControl :: Maybe S3DestinationAccessControl
$sel:accessControl:S3DestinationSettings' :: S3DestinationSettings -> Maybe S3DestinationAccessControl
accessControl} -> Maybe S3DestinationAccessControl
accessControl) (\s :: S3DestinationSettings
s@S3DestinationSettings' {} Maybe S3DestinationAccessControl
a -> S3DestinationSettings
s {$sel:accessControl:S3DestinationSettings' :: Maybe S3DestinationAccessControl
accessControl = Maybe S3DestinationAccessControl
a} :: S3DestinationSettings)

-- | Settings for how your job outputs are encrypted as they are uploaded to
-- Amazon S3.
s3DestinationSettings_encryption :: Lens.Lens' S3DestinationSettings (Prelude.Maybe S3EncryptionSettings)
s3DestinationSettings_encryption :: Lens' S3DestinationSettings (Maybe S3EncryptionSettings)
s3DestinationSettings_encryption = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3DestinationSettings' {Maybe S3EncryptionSettings
encryption :: Maybe S3EncryptionSettings
$sel:encryption:S3DestinationSettings' :: S3DestinationSettings -> Maybe S3EncryptionSettings
encryption} -> Maybe S3EncryptionSettings
encryption) (\s :: S3DestinationSettings
s@S3DestinationSettings' {} Maybe S3EncryptionSettings
a -> S3DestinationSettings
s {$sel:encryption:S3DestinationSettings' :: Maybe S3EncryptionSettings
encryption = Maybe S3EncryptionSettings
a} :: S3DestinationSettings)

instance Data.FromJSON S3DestinationSettings where
  parseJSON :: Value -> Parser S3DestinationSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3DestinationSettings"
      ( \Object
x ->
          Maybe S3DestinationAccessControl
-> Maybe S3EncryptionSettings -> S3DestinationSettings
S3DestinationSettings'
            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
"accessControl")
            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
"encryption")
      )

instance Prelude.Hashable S3DestinationSettings where
  hashWithSalt :: Int -> S3DestinationSettings -> Int
hashWithSalt Int
_salt S3DestinationSettings' {Maybe S3DestinationAccessControl
Maybe S3EncryptionSettings
encryption :: Maybe S3EncryptionSettings
accessControl :: Maybe S3DestinationAccessControl
$sel:encryption:S3DestinationSettings' :: S3DestinationSettings -> Maybe S3EncryptionSettings
$sel:accessControl:S3DestinationSettings' :: S3DestinationSettings -> Maybe S3DestinationAccessControl
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3DestinationAccessControl
accessControl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3EncryptionSettings
encryption

instance Prelude.NFData S3DestinationSettings where
  rnf :: S3DestinationSettings -> ()
rnf S3DestinationSettings' {Maybe S3DestinationAccessControl
Maybe S3EncryptionSettings
encryption :: Maybe S3EncryptionSettings
accessControl :: Maybe S3DestinationAccessControl
$sel:encryption:S3DestinationSettings' :: S3DestinationSettings -> Maybe S3EncryptionSettings
$sel:accessControl:S3DestinationSettings' :: S3DestinationSettings -> Maybe S3DestinationAccessControl
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe S3DestinationAccessControl
accessControl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe S3EncryptionSettings
encryption

instance Data.ToJSON S3DestinationSettings where
  toJSON :: S3DestinationSettings -> Value
toJSON S3DestinationSettings' {Maybe S3DestinationAccessControl
Maybe S3EncryptionSettings
encryption :: Maybe S3EncryptionSettings
accessControl :: Maybe S3DestinationAccessControl
$sel:encryption:S3DestinationSettings' :: S3DestinationSettings -> Maybe S3EncryptionSettings
$sel:accessControl:S3DestinationSettings' :: S3DestinationSettings -> Maybe S3DestinationAccessControl
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"accessControl" 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 S3DestinationAccessControl
accessControl,
            (Key
"encryption" 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 S3EncryptionSettings
encryption
          ]
      )