{-# 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.ComputeOptimizer.Types.S3DestinationConfig
-- 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.ComputeOptimizer.Types.S3DestinationConfig where

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

-- | Describes the destination Amazon Simple Storage Service (Amazon S3)
-- bucket name and key prefix for a recommendations export job.
--
-- You must create the destination Amazon S3 bucket for your
-- recommendations export before you create the export job. Compute
-- Optimizer does not create the S3 bucket for you. After you create the S3
-- bucket, ensure that it has the required permission policy to allow
-- Compute Optimizer to write the export file to it. If you plan to specify
-- an object prefix when you create the export job, you must include the
-- object prefix in the policy that you add to the S3 bucket. For more
-- information, see
-- <https://docs.aws.amazon.com/compute-optimizer/latest/ug/create-s3-bucket-policy-for-compute-optimizer.html Amazon S3 Bucket Policy for Compute Optimizer>
-- in the /Compute Optimizer User Guide/.
--
-- /See:/ 'newS3DestinationConfig' smart constructor.
data S3DestinationConfig = S3DestinationConfig'
  { -- | The name of the Amazon S3 bucket to use as the destination for an export
    -- job.
    S3DestinationConfig -> Maybe Text
bucket :: Prelude.Maybe Prelude.Text,
    -- | The Amazon S3 bucket prefix for an export job.
    S3DestinationConfig -> Maybe Text
keyPrefix :: Prelude.Maybe Prelude.Text
  }
  deriving (S3DestinationConfig -> S3DestinationConfig -> Bool
(S3DestinationConfig -> S3DestinationConfig -> Bool)
-> (S3DestinationConfig -> S3DestinationConfig -> Bool)
-> Eq S3DestinationConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3DestinationConfig -> S3DestinationConfig -> Bool
$c/= :: S3DestinationConfig -> S3DestinationConfig -> Bool
== :: S3DestinationConfig -> S3DestinationConfig -> Bool
$c== :: S3DestinationConfig -> S3DestinationConfig -> Bool
Prelude.Eq, ReadPrec [S3DestinationConfig]
ReadPrec S3DestinationConfig
Int -> ReadS S3DestinationConfig
ReadS [S3DestinationConfig]
(Int -> ReadS S3DestinationConfig)
-> ReadS [S3DestinationConfig]
-> ReadPrec S3DestinationConfig
-> ReadPrec [S3DestinationConfig]
-> Read S3DestinationConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3DestinationConfig]
$creadListPrec :: ReadPrec [S3DestinationConfig]
readPrec :: ReadPrec S3DestinationConfig
$creadPrec :: ReadPrec S3DestinationConfig
readList :: ReadS [S3DestinationConfig]
$creadList :: ReadS [S3DestinationConfig]
readsPrec :: Int -> ReadS S3DestinationConfig
$creadsPrec :: Int -> ReadS S3DestinationConfig
Prelude.Read, Int -> S3DestinationConfig -> ShowS
[S3DestinationConfig] -> ShowS
S3DestinationConfig -> String
(Int -> S3DestinationConfig -> ShowS)
-> (S3DestinationConfig -> String)
-> ([S3DestinationConfig] -> ShowS)
-> Show S3DestinationConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3DestinationConfig] -> ShowS
$cshowList :: [S3DestinationConfig] -> ShowS
show :: S3DestinationConfig -> String
$cshow :: S3DestinationConfig -> String
showsPrec :: Int -> S3DestinationConfig -> ShowS
$cshowsPrec :: Int -> S3DestinationConfig -> ShowS
Prelude.Show, (forall x. S3DestinationConfig -> Rep S3DestinationConfig x)
-> (forall x. Rep S3DestinationConfig x -> S3DestinationConfig)
-> Generic S3DestinationConfig
forall x. Rep S3DestinationConfig x -> S3DestinationConfig
forall x. S3DestinationConfig -> Rep S3DestinationConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3DestinationConfig x -> S3DestinationConfig
$cfrom :: forall x. S3DestinationConfig -> Rep S3DestinationConfig x
Prelude.Generic)

-- |
-- Create a value of 'S3DestinationConfig' 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:
--
-- 'bucket', 's3DestinationConfig_bucket' - The name of the Amazon S3 bucket to use as the destination for an export
-- job.
--
-- 'keyPrefix', 's3DestinationConfig_keyPrefix' - The Amazon S3 bucket prefix for an export job.
newS3DestinationConfig ::
  S3DestinationConfig
newS3DestinationConfig :: S3DestinationConfig
newS3DestinationConfig =
  S3DestinationConfig' :: Maybe Text -> Maybe Text -> S3DestinationConfig
S3DestinationConfig'
    { $sel:bucket:S3DestinationConfig' :: Maybe Text
bucket = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:keyPrefix:S3DestinationConfig' :: Maybe Text
keyPrefix = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the Amazon S3 bucket to use as the destination for an export
-- job.
s3DestinationConfig_bucket :: Lens.Lens' S3DestinationConfig (Prelude.Maybe Prelude.Text)
s3DestinationConfig_bucket :: (Maybe Text -> f (Maybe Text))
-> S3DestinationConfig -> f S3DestinationConfig
s3DestinationConfig_bucket = (S3DestinationConfig -> Maybe Text)
-> (S3DestinationConfig -> Maybe Text -> S3DestinationConfig)
-> Lens
     S3DestinationConfig S3DestinationConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3DestinationConfig' {Maybe Text
bucket :: Maybe Text
$sel:bucket:S3DestinationConfig' :: S3DestinationConfig -> Maybe Text
bucket} -> Maybe Text
bucket) (\s :: S3DestinationConfig
s@S3DestinationConfig' {} Maybe Text
a -> S3DestinationConfig
s {$sel:bucket:S3DestinationConfig' :: Maybe Text
bucket = Maybe Text
a} :: S3DestinationConfig)

-- | The Amazon S3 bucket prefix for an export job.
s3DestinationConfig_keyPrefix :: Lens.Lens' S3DestinationConfig (Prelude.Maybe Prelude.Text)
s3DestinationConfig_keyPrefix :: (Maybe Text -> f (Maybe Text))
-> S3DestinationConfig -> f S3DestinationConfig
s3DestinationConfig_keyPrefix = (S3DestinationConfig -> Maybe Text)
-> (S3DestinationConfig -> Maybe Text -> S3DestinationConfig)
-> Lens
     S3DestinationConfig S3DestinationConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3DestinationConfig' {Maybe Text
keyPrefix :: Maybe Text
$sel:keyPrefix:S3DestinationConfig' :: S3DestinationConfig -> Maybe Text
keyPrefix} -> Maybe Text
keyPrefix) (\s :: S3DestinationConfig
s@S3DestinationConfig' {} Maybe Text
a -> S3DestinationConfig
s {$sel:keyPrefix:S3DestinationConfig' :: Maybe Text
keyPrefix = Maybe Text
a} :: S3DestinationConfig)

instance Prelude.Hashable S3DestinationConfig

instance Prelude.NFData S3DestinationConfig

instance Core.ToJSON S3DestinationConfig where
  toJSON :: S3DestinationConfig -> Value
toJSON S3DestinationConfig' {Maybe Text
keyPrefix :: Maybe Text
bucket :: Maybe Text
$sel:keyPrefix:S3DestinationConfig' :: S3DestinationConfig -> Maybe Text
$sel:bucket:S3DestinationConfig' :: S3DestinationConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"bucket" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
bucket,
            (Text
"keyPrefix" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
keyPrefix
          ]
      )