{-# 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.S3.Types.InventoryS3BucketDestination
-- 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.S3.Types.InventoryS3BucketDestination where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal
import Amazonka.S3.Types.InventoryEncryption
import Amazonka.S3.Types.InventoryFormat

-- | Contains the bucket name, file format, bucket owner (optional), and
-- prefix (optional) where inventory results are published.
--
-- /See:/ 'newInventoryS3BucketDestination' smart constructor.
data InventoryS3BucketDestination = InventoryS3BucketDestination'
  { -- | The prefix that is prepended to all inventory results.
    InventoryS3BucketDestination -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    -- | The account ID that owns the destination S3 bucket. If no account ID is
    -- provided, the owner is not validated before exporting data.
    --
    -- Although this value is optional, we strongly recommend that you set it
    -- to help prevent problems if the destination bucket ownership changes.
    InventoryS3BucketDestination -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | Contains the type of server-side encryption used to encrypt the
    -- inventory results.
    InventoryS3BucketDestination -> Maybe InventoryEncryption
encryption :: Prelude.Maybe InventoryEncryption,
    -- | The Amazon Resource Name (ARN) of the bucket where inventory results
    -- will be published.
    InventoryS3BucketDestination -> BucketName
bucket :: BucketName,
    -- | Specifies the output format of the inventory results.
    InventoryS3BucketDestination -> InventoryFormat
format :: InventoryFormat
  }
  deriving (InventoryS3BucketDestination
-> InventoryS3BucketDestination -> Bool
(InventoryS3BucketDestination
 -> InventoryS3BucketDestination -> Bool)
-> (InventoryS3BucketDestination
    -> InventoryS3BucketDestination -> Bool)
-> Eq InventoryS3BucketDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InventoryS3BucketDestination
-> InventoryS3BucketDestination -> Bool
$c/= :: InventoryS3BucketDestination
-> InventoryS3BucketDestination -> Bool
== :: InventoryS3BucketDestination
-> InventoryS3BucketDestination -> Bool
$c== :: InventoryS3BucketDestination
-> InventoryS3BucketDestination -> Bool
Prelude.Eq, Int -> InventoryS3BucketDestination -> ShowS
[InventoryS3BucketDestination] -> ShowS
InventoryS3BucketDestination -> String
(Int -> InventoryS3BucketDestination -> ShowS)
-> (InventoryS3BucketDestination -> String)
-> ([InventoryS3BucketDestination] -> ShowS)
-> Show InventoryS3BucketDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InventoryS3BucketDestination] -> ShowS
$cshowList :: [InventoryS3BucketDestination] -> ShowS
show :: InventoryS3BucketDestination -> String
$cshow :: InventoryS3BucketDestination -> String
showsPrec :: Int -> InventoryS3BucketDestination -> ShowS
$cshowsPrec :: Int -> InventoryS3BucketDestination -> ShowS
Prelude.Show, (forall x.
 InventoryS3BucketDestination -> Rep InventoryS3BucketDestination x)
-> (forall x.
    Rep InventoryS3BucketDestination x -> InventoryS3BucketDestination)
-> Generic InventoryS3BucketDestination
forall x.
Rep InventoryS3BucketDestination x -> InventoryS3BucketDestination
forall x.
InventoryS3BucketDestination -> Rep InventoryS3BucketDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InventoryS3BucketDestination x -> InventoryS3BucketDestination
$cfrom :: forall x.
InventoryS3BucketDestination -> Rep InventoryS3BucketDestination x
Prelude.Generic)

-- |
-- Create a value of 'InventoryS3BucketDestination' 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:
--
-- 'prefix', 'inventoryS3BucketDestination_prefix' - The prefix that is prepended to all inventory results.
--
-- 'accountId', 'inventoryS3BucketDestination_accountId' - The account ID that owns the destination S3 bucket. If no account ID is
-- provided, the owner is not validated before exporting data.
--
-- Although this value is optional, we strongly recommend that you set it
-- to help prevent problems if the destination bucket ownership changes.
--
-- 'encryption', 'inventoryS3BucketDestination_encryption' - Contains the type of server-side encryption used to encrypt the
-- inventory results.
--
-- 'bucket', 'inventoryS3BucketDestination_bucket' - The Amazon Resource Name (ARN) of the bucket where inventory results
-- will be published.
--
-- 'format', 'inventoryS3BucketDestination_format' - Specifies the output format of the inventory results.
newInventoryS3BucketDestination ::
  -- | 'bucket'
  BucketName ->
  -- | 'format'
  InventoryFormat ->
  InventoryS3BucketDestination
newInventoryS3BucketDestination :: BucketName -> InventoryFormat -> InventoryS3BucketDestination
newInventoryS3BucketDestination BucketName
pBucket_ InventoryFormat
pFormat_ =
  InventoryS3BucketDestination' :: Maybe Text
-> Maybe Text
-> Maybe InventoryEncryption
-> BucketName
-> InventoryFormat
-> InventoryS3BucketDestination
InventoryS3BucketDestination'
    { $sel:prefix:InventoryS3BucketDestination' :: Maybe Text
prefix =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:InventoryS3BucketDestination' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:encryption:InventoryS3BucketDestination' :: Maybe InventoryEncryption
encryption = Maybe InventoryEncryption
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:InventoryS3BucketDestination' :: BucketName
bucket = BucketName
pBucket_,
      $sel:format:InventoryS3BucketDestination' :: InventoryFormat
format = InventoryFormat
pFormat_
    }

-- | The prefix that is prepended to all inventory results.
inventoryS3BucketDestination_prefix :: Lens.Lens' InventoryS3BucketDestination (Prelude.Maybe Prelude.Text)
inventoryS3BucketDestination_prefix :: (Maybe Text -> f (Maybe Text))
-> InventoryS3BucketDestination -> f InventoryS3BucketDestination
inventoryS3BucketDestination_prefix = (InventoryS3BucketDestination -> Maybe Text)
-> (InventoryS3BucketDestination
    -> Maybe Text -> InventoryS3BucketDestination)
-> Lens
     InventoryS3BucketDestination
     InventoryS3BucketDestination
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryS3BucketDestination' {Maybe Text
prefix :: Maybe Text
$sel:prefix:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: InventoryS3BucketDestination
s@InventoryS3BucketDestination' {} Maybe Text
a -> InventoryS3BucketDestination
s {$sel:prefix:InventoryS3BucketDestination' :: Maybe Text
prefix = Maybe Text
a} :: InventoryS3BucketDestination)

-- | The account ID that owns the destination S3 bucket. If no account ID is
-- provided, the owner is not validated before exporting data.
--
-- Although this value is optional, we strongly recommend that you set it
-- to help prevent problems if the destination bucket ownership changes.
inventoryS3BucketDestination_accountId :: Lens.Lens' InventoryS3BucketDestination (Prelude.Maybe Prelude.Text)
inventoryS3BucketDestination_accountId :: (Maybe Text -> f (Maybe Text))
-> InventoryS3BucketDestination -> f InventoryS3BucketDestination
inventoryS3BucketDestination_accountId = (InventoryS3BucketDestination -> Maybe Text)
-> (InventoryS3BucketDestination
    -> Maybe Text -> InventoryS3BucketDestination)
-> Lens
     InventoryS3BucketDestination
     InventoryS3BucketDestination
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryS3BucketDestination' {Maybe Text
accountId :: Maybe Text
$sel:accountId:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: InventoryS3BucketDestination
s@InventoryS3BucketDestination' {} Maybe Text
a -> InventoryS3BucketDestination
s {$sel:accountId:InventoryS3BucketDestination' :: Maybe Text
accountId = Maybe Text
a} :: InventoryS3BucketDestination)

-- | Contains the type of server-side encryption used to encrypt the
-- inventory results.
inventoryS3BucketDestination_encryption :: Lens.Lens' InventoryS3BucketDestination (Prelude.Maybe InventoryEncryption)
inventoryS3BucketDestination_encryption :: (Maybe InventoryEncryption -> f (Maybe InventoryEncryption))
-> InventoryS3BucketDestination -> f InventoryS3BucketDestination
inventoryS3BucketDestination_encryption = (InventoryS3BucketDestination -> Maybe InventoryEncryption)
-> (InventoryS3BucketDestination
    -> Maybe InventoryEncryption -> InventoryS3BucketDestination)
-> Lens
     InventoryS3BucketDestination
     InventoryS3BucketDestination
     (Maybe InventoryEncryption)
     (Maybe InventoryEncryption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryS3BucketDestination' {Maybe InventoryEncryption
encryption :: Maybe InventoryEncryption
$sel:encryption:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> Maybe InventoryEncryption
encryption} -> Maybe InventoryEncryption
encryption) (\s :: InventoryS3BucketDestination
s@InventoryS3BucketDestination' {} Maybe InventoryEncryption
a -> InventoryS3BucketDestination
s {$sel:encryption:InventoryS3BucketDestination' :: Maybe InventoryEncryption
encryption = Maybe InventoryEncryption
a} :: InventoryS3BucketDestination)

-- | The Amazon Resource Name (ARN) of the bucket where inventory results
-- will be published.
inventoryS3BucketDestination_bucket :: Lens.Lens' InventoryS3BucketDestination BucketName
inventoryS3BucketDestination_bucket :: (BucketName -> f BucketName)
-> InventoryS3BucketDestination -> f InventoryS3BucketDestination
inventoryS3BucketDestination_bucket = (InventoryS3BucketDestination -> BucketName)
-> (InventoryS3BucketDestination
    -> BucketName -> InventoryS3BucketDestination)
-> Lens
     InventoryS3BucketDestination
     InventoryS3BucketDestination
     BucketName
     BucketName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryS3BucketDestination' {BucketName
bucket :: BucketName
$sel:bucket:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> BucketName
bucket} -> BucketName
bucket) (\s :: InventoryS3BucketDestination
s@InventoryS3BucketDestination' {} BucketName
a -> InventoryS3BucketDestination
s {$sel:bucket:InventoryS3BucketDestination' :: BucketName
bucket = BucketName
a} :: InventoryS3BucketDestination)

-- | Specifies the output format of the inventory results.
inventoryS3BucketDestination_format :: Lens.Lens' InventoryS3BucketDestination InventoryFormat
inventoryS3BucketDestination_format :: (InventoryFormat -> f InventoryFormat)
-> InventoryS3BucketDestination -> f InventoryS3BucketDestination
inventoryS3BucketDestination_format = (InventoryS3BucketDestination -> InventoryFormat)
-> (InventoryS3BucketDestination
    -> InventoryFormat -> InventoryS3BucketDestination)
-> Lens
     InventoryS3BucketDestination
     InventoryS3BucketDestination
     InventoryFormat
     InventoryFormat
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryS3BucketDestination' {InventoryFormat
format :: InventoryFormat
$sel:format:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> InventoryFormat
format} -> InventoryFormat
format) (\s :: InventoryS3BucketDestination
s@InventoryS3BucketDestination' {} InventoryFormat
a -> InventoryS3BucketDestination
s {$sel:format:InventoryS3BucketDestination' :: InventoryFormat
format = InventoryFormat
a} :: InventoryS3BucketDestination)

instance Core.FromXML InventoryS3BucketDestination where
  parseXML :: [Node] -> Either String InventoryS3BucketDestination
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe InventoryEncryption
-> BucketName
-> InventoryFormat
-> InventoryS3BucketDestination
InventoryS3BucketDestination'
      (Maybe Text
 -> Maybe Text
 -> Maybe InventoryEncryption
 -> BucketName
 -> InventoryFormat
 -> InventoryS3BucketDestination)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe InventoryEncryption
      -> BucketName
      -> InventoryFormat
      -> InventoryS3BucketDestination)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Prefix")
      Either
  String
  (Maybe Text
   -> Maybe InventoryEncryption
   -> BucketName
   -> InventoryFormat
   -> InventoryS3BucketDestination)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe InventoryEncryption
      -> BucketName -> InventoryFormat -> InventoryS3BucketDestination)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"AccountId")
      Either
  String
  (Maybe InventoryEncryption
   -> BucketName -> InventoryFormat -> InventoryS3BucketDestination)
-> Either String (Maybe InventoryEncryption)
-> Either
     String
     (BucketName -> InventoryFormat -> InventoryS3BucketDestination)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe InventoryEncryption)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Encryption")
      Either
  String
  (BucketName -> InventoryFormat -> InventoryS3BucketDestination)
-> Either String BucketName
-> Either String (InventoryFormat -> InventoryS3BucketDestination)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String BucketName
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Bucket")
      Either String (InventoryFormat -> InventoryS3BucketDestination)
-> Either String InventoryFormat
-> Either String InventoryS3BucketDestination
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String InventoryFormat
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Format")

instance
  Prelude.Hashable
    InventoryS3BucketDestination

instance Prelude.NFData InventoryS3BucketDestination

instance Core.ToXML InventoryS3BucketDestination where
  toXML :: InventoryS3BucketDestination -> XML
toXML InventoryS3BucketDestination' {Maybe Text
Maybe InventoryEncryption
BucketName
InventoryFormat
format :: InventoryFormat
bucket :: BucketName
encryption :: Maybe InventoryEncryption
accountId :: Maybe Text
prefix :: Maybe Text
$sel:format:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> InventoryFormat
$sel:bucket:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> BucketName
$sel:encryption:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> Maybe InventoryEncryption
$sel:accountId:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> Maybe Text
$sel:prefix:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> Maybe Text
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Prefix" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
prefix,
        Name
"AccountId" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
accountId,
        Name
"Encryption" Name -> Maybe InventoryEncryption -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe InventoryEncryption
encryption,
        Name
"Bucket" Name -> BucketName -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= BucketName
bucket,
        Name
"Format" Name -> InventoryFormat -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= InventoryFormat
format
      ]