{-# 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.Backup.Types.ReportDeliveryChannel
-- 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.Backup.Types.ReportDeliveryChannel where

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

-- | Contains information from your report plan about where to deliver your
-- reports, specifically your Amazon S3 bucket name, S3 key prefix, and the
-- formats of your reports.
--
-- /See:/ 'newReportDeliveryChannel' smart constructor.
data ReportDeliveryChannel = ReportDeliveryChannel'
  { -- | The prefix for where Backup Audit Manager delivers your reports to
    -- Amazon S3. The prefix is this part of the following path:
    -- s3:\/\/your-bucket-name\/@prefix@\/Backup\/us-west-2\/year\/month\/day\/report-name.
    -- If not specified, there is no prefix.
    ReportDeliveryChannel -> Maybe Text
s3KeyPrefix :: Prelude.Maybe Prelude.Text,
    -- | A list of the format of your reports: @CSV@, @JSON@, or both. If not
    -- specified, the default format is @CSV@.
    ReportDeliveryChannel -> Maybe [Text]
formats :: Prelude.Maybe [Prelude.Text],
    -- | The unique name of the S3 bucket that receives your reports.
    ReportDeliveryChannel -> Text
s3BucketName :: Prelude.Text
  }
  deriving (ReportDeliveryChannel -> ReportDeliveryChannel -> Bool
(ReportDeliveryChannel -> ReportDeliveryChannel -> Bool)
-> (ReportDeliveryChannel -> ReportDeliveryChannel -> Bool)
-> Eq ReportDeliveryChannel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReportDeliveryChannel -> ReportDeliveryChannel -> Bool
$c/= :: ReportDeliveryChannel -> ReportDeliveryChannel -> Bool
== :: ReportDeliveryChannel -> ReportDeliveryChannel -> Bool
$c== :: ReportDeliveryChannel -> ReportDeliveryChannel -> Bool
Prelude.Eq, ReadPrec [ReportDeliveryChannel]
ReadPrec ReportDeliveryChannel
Int -> ReadS ReportDeliveryChannel
ReadS [ReportDeliveryChannel]
(Int -> ReadS ReportDeliveryChannel)
-> ReadS [ReportDeliveryChannel]
-> ReadPrec ReportDeliveryChannel
-> ReadPrec [ReportDeliveryChannel]
-> Read ReportDeliveryChannel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReportDeliveryChannel]
$creadListPrec :: ReadPrec [ReportDeliveryChannel]
readPrec :: ReadPrec ReportDeliveryChannel
$creadPrec :: ReadPrec ReportDeliveryChannel
readList :: ReadS [ReportDeliveryChannel]
$creadList :: ReadS [ReportDeliveryChannel]
readsPrec :: Int -> ReadS ReportDeliveryChannel
$creadsPrec :: Int -> ReadS ReportDeliveryChannel
Prelude.Read, Int -> ReportDeliveryChannel -> ShowS
[ReportDeliveryChannel] -> ShowS
ReportDeliveryChannel -> String
(Int -> ReportDeliveryChannel -> ShowS)
-> (ReportDeliveryChannel -> String)
-> ([ReportDeliveryChannel] -> ShowS)
-> Show ReportDeliveryChannel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReportDeliveryChannel] -> ShowS
$cshowList :: [ReportDeliveryChannel] -> ShowS
show :: ReportDeliveryChannel -> String
$cshow :: ReportDeliveryChannel -> String
showsPrec :: Int -> ReportDeliveryChannel -> ShowS
$cshowsPrec :: Int -> ReportDeliveryChannel -> ShowS
Prelude.Show, (forall x. ReportDeliveryChannel -> Rep ReportDeliveryChannel x)
-> (forall x. Rep ReportDeliveryChannel x -> ReportDeliveryChannel)
-> Generic ReportDeliveryChannel
forall x. Rep ReportDeliveryChannel x -> ReportDeliveryChannel
forall x. ReportDeliveryChannel -> Rep ReportDeliveryChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReportDeliveryChannel x -> ReportDeliveryChannel
$cfrom :: forall x. ReportDeliveryChannel -> Rep ReportDeliveryChannel x
Prelude.Generic)

-- |
-- Create a value of 'ReportDeliveryChannel' 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:
--
-- 's3KeyPrefix', 'reportDeliveryChannel_s3KeyPrefix' - The prefix for where Backup Audit Manager delivers your reports to
-- Amazon S3. The prefix is this part of the following path:
-- s3:\/\/your-bucket-name\/@prefix@\/Backup\/us-west-2\/year\/month\/day\/report-name.
-- If not specified, there is no prefix.
--
-- 'formats', 'reportDeliveryChannel_formats' - A list of the format of your reports: @CSV@, @JSON@, or both. If not
-- specified, the default format is @CSV@.
--
-- 's3BucketName', 'reportDeliveryChannel_s3BucketName' - The unique name of the S3 bucket that receives your reports.
newReportDeliveryChannel ::
  -- | 's3BucketName'
  Prelude.Text ->
  ReportDeliveryChannel
newReportDeliveryChannel :: Text -> ReportDeliveryChannel
newReportDeliveryChannel Text
pS3BucketName_ =
  ReportDeliveryChannel' :: Maybe Text -> Maybe [Text] -> Text -> ReportDeliveryChannel
ReportDeliveryChannel'
    { $sel:s3KeyPrefix:ReportDeliveryChannel' :: Maybe Text
s3KeyPrefix =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:formats:ReportDeliveryChannel' :: Maybe [Text]
formats = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:s3BucketName:ReportDeliveryChannel' :: Text
s3BucketName = Text
pS3BucketName_
    }

-- | The prefix for where Backup Audit Manager delivers your reports to
-- Amazon S3. The prefix is this part of the following path:
-- s3:\/\/your-bucket-name\/@prefix@\/Backup\/us-west-2\/year\/month\/day\/report-name.
-- If not specified, there is no prefix.
reportDeliveryChannel_s3KeyPrefix :: Lens.Lens' ReportDeliveryChannel (Prelude.Maybe Prelude.Text)
reportDeliveryChannel_s3KeyPrefix :: (Maybe Text -> f (Maybe Text))
-> ReportDeliveryChannel -> f ReportDeliveryChannel
reportDeliveryChannel_s3KeyPrefix = (ReportDeliveryChannel -> Maybe Text)
-> (ReportDeliveryChannel -> Maybe Text -> ReportDeliveryChannel)
-> Lens
     ReportDeliveryChannel
     ReportDeliveryChannel
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReportDeliveryChannel' {Maybe Text
s3KeyPrefix :: Maybe Text
$sel:s3KeyPrefix:ReportDeliveryChannel' :: ReportDeliveryChannel -> Maybe Text
s3KeyPrefix} -> Maybe Text
s3KeyPrefix) (\s :: ReportDeliveryChannel
s@ReportDeliveryChannel' {} Maybe Text
a -> ReportDeliveryChannel
s {$sel:s3KeyPrefix:ReportDeliveryChannel' :: Maybe Text
s3KeyPrefix = Maybe Text
a} :: ReportDeliveryChannel)

-- | A list of the format of your reports: @CSV@, @JSON@, or both. If not
-- specified, the default format is @CSV@.
reportDeliveryChannel_formats :: Lens.Lens' ReportDeliveryChannel (Prelude.Maybe [Prelude.Text])
reportDeliveryChannel_formats :: (Maybe [Text] -> f (Maybe [Text]))
-> ReportDeliveryChannel -> f ReportDeliveryChannel
reportDeliveryChannel_formats = (ReportDeliveryChannel -> Maybe [Text])
-> (ReportDeliveryChannel -> Maybe [Text] -> ReportDeliveryChannel)
-> Lens
     ReportDeliveryChannel
     ReportDeliveryChannel
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReportDeliveryChannel' {Maybe [Text]
formats :: Maybe [Text]
$sel:formats:ReportDeliveryChannel' :: ReportDeliveryChannel -> Maybe [Text]
formats} -> Maybe [Text]
formats) (\s :: ReportDeliveryChannel
s@ReportDeliveryChannel' {} Maybe [Text]
a -> ReportDeliveryChannel
s {$sel:formats:ReportDeliveryChannel' :: Maybe [Text]
formats = Maybe [Text]
a} :: ReportDeliveryChannel) ((Maybe [Text] -> f (Maybe [Text]))
 -> ReportDeliveryChannel -> f ReportDeliveryChannel)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ReportDeliveryChannel
-> f ReportDeliveryChannel
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The unique name of the S3 bucket that receives your reports.
reportDeliveryChannel_s3BucketName :: Lens.Lens' ReportDeliveryChannel Prelude.Text
reportDeliveryChannel_s3BucketName :: (Text -> f Text)
-> ReportDeliveryChannel -> f ReportDeliveryChannel
reportDeliveryChannel_s3BucketName = (ReportDeliveryChannel -> Text)
-> (ReportDeliveryChannel -> Text -> ReportDeliveryChannel)
-> Lens ReportDeliveryChannel ReportDeliveryChannel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReportDeliveryChannel' {Text
s3BucketName :: Text
$sel:s3BucketName:ReportDeliveryChannel' :: ReportDeliveryChannel -> Text
s3BucketName} -> Text
s3BucketName) (\s :: ReportDeliveryChannel
s@ReportDeliveryChannel' {} Text
a -> ReportDeliveryChannel
s {$sel:s3BucketName:ReportDeliveryChannel' :: Text
s3BucketName = Text
a} :: ReportDeliveryChannel)

instance Core.FromJSON ReportDeliveryChannel where
  parseJSON :: Value -> Parser ReportDeliveryChannel
parseJSON =
    String
-> (Object -> Parser ReportDeliveryChannel)
-> Value
-> Parser ReportDeliveryChannel
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReportDeliveryChannel"
      ( \Object
x ->
          Maybe Text -> Maybe [Text] -> Text -> ReportDeliveryChannel
ReportDeliveryChannel'
            (Maybe Text -> Maybe [Text] -> Text -> ReportDeliveryChannel)
-> Parser (Maybe Text)
-> Parser (Maybe [Text] -> Text -> ReportDeliveryChannel)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"S3KeyPrefix")
            Parser (Maybe [Text] -> Text -> ReportDeliveryChannel)
-> Parser (Maybe [Text]) -> Parser (Text -> ReportDeliveryChannel)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Formats" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> ReportDeliveryChannel)
-> Parser Text -> Parser ReportDeliveryChannel
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"S3BucketName")
      )

instance Prelude.Hashable ReportDeliveryChannel

instance Prelude.NFData ReportDeliveryChannel

instance Core.ToJSON ReportDeliveryChannel where
  toJSON :: ReportDeliveryChannel -> Value
toJSON ReportDeliveryChannel' {Maybe [Text]
Maybe Text
Text
s3BucketName :: Text
formats :: Maybe [Text]
s3KeyPrefix :: Maybe Text
$sel:s3BucketName:ReportDeliveryChannel' :: ReportDeliveryChannel -> Text
$sel:formats:ReportDeliveryChannel' :: ReportDeliveryChannel -> Maybe [Text]
$sel:s3KeyPrefix:ReportDeliveryChannel' :: ReportDeliveryChannel -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"S3KeyPrefix" 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
s3KeyPrefix,
            (Text
"Formats" 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]
formats,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"S3BucketName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
s3BucketName)
          ]
      )