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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(S3DestinationSettings -> S3DestinationSettings -> Bool)
-> (S3DestinationSettings -> S3DestinationSettings -> Bool)
-> Eq S3DestinationSettings
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]
(Int -> ReadS S3DestinationSettings)
-> ReadS [S3DestinationSettings]
-> ReadPrec S3DestinationSettings
-> ReadPrec [S3DestinationSettings]
-> Read 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
(Int -> S3DestinationSettings -> ShowS)
-> (S3DestinationSettings -> String)
-> ([S3DestinationSettings] -> ShowS)
-> Show S3DestinationSettings
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. S3DestinationSettings -> Rep S3DestinationSettings x)
-> (forall x. Rep S3DestinationSettings x -> S3DestinationSettings)
-> Generic S3DestinationSettings
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' :: Maybe S3DestinationAccessControl
-> Maybe S3EncryptionSettings -> S3DestinationSettings
S3DestinationSettings'
    { $sel:accessControl:S3DestinationSettings' :: Maybe S3DestinationAccessControl
accessControl =
        Maybe S3DestinationAccessControl
forall a. Maybe a
Prelude.Nothing,
      $sel:encryption:S3DestinationSettings' :: Maybe S3EncryptionSettings
encryption = Maybe S3EncryptionSettings
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 :: (Maybe S3DestinationAccessControl
 -> f (Maybe S3DestinationAccessControl))
-> S3DestinationSettings -> f S3DestinationSettings
s3DestinationSettings_accessControl = (S3DestinationSettings -> Maybe S3DestinationAccessControl)
-> (S3DestinationSettings
    -> Maybe S3DestinationAccessControl -> S3DestinationSettings)
-> Lens
     S3DestinationSettings
     S3DestinationSettings
     (Maybe S3DestinationAccessControl)
     (Maybe S3DestinationAccessControl)
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 :: (Maybe S3EncryptionSettings -> f (Maybe S3EncryptionSettings))
-> S3DestinationSettings -> f S3DestinationSettings
s3DestinationSettings_encryption = (S3DestinationSettings -> Maybe S3EncryptionSettings)
-> (S3DestinationSettings
    -> Maybe S3EncryptionSettings -> S3DestinationSettings)
-> Lens
     S3DestinationSettings
     S3DestinationSettings
     (Maybe S3EncryptionSettings)
     (Maybe S3EncryptionSettings)
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 Core.FromJSON S3DestinationSettings where
  parseJSON :: Value -> Parser S3DestinationSettings
parseJSON =
    String
-> (Object -> Parser S3DestinationSettings)
-> Value
-> Parser S3DestinationSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3DestinationSettings"
      ( \Object
x ->
          Maybe S3DestinationAccessControl
-> Maybe S3EncryptionSettings -> S3DestinationSettings
S3DestinationSettings'
            (Maybe S3DestinationAccessControl
 -> Maybe S3EncryptionSettings -> S3DestinationSettings)
-> Parser (Maybe S3DestinationAccessControl)
-> Parser (Maybe S3EncryptionSettings -> S3DestinationSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe S3DestinationAccessControl)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"accessControl")
            Parser (Maybe S3EncryptionSettings -> S3DestinationSettings)
-> Parser (Maybe S3EncryptionSettings)
-> Parser S3DestinationSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe S3EncryptionSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"encryption")
      )

instance Prelude.Hashable S3DestinationSettings

instance Prelude.NFData S3DestinationSettings

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"accessControl" Text -> S3DestinationAccessControl -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (S3DestinationAccessControl -> Pair)
-> Maybe S3DestinationAccessControl -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3DestinationAccessControl
accessControl,
            (Text
"encryption" Text -> S3EncryptionSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (S3EncryptionSettings -> Pair)
-> Maybe S3EncryptionSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3EncryptionSettings
encryption
          ]
      )