{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.S3.Types.InventoryS3BucketDestination where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 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 prefix that is prepended to all inventory results.
    InventoryS3BucketDestination -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    -- | 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
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
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.
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:
--
-- '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.
--
-- 'prefix', 'inventoryS3BucketDestination_prefix' - The prefix that is prepended to all 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'
    { $sel:accountId:InventoryS3BucketDestination' :: Maybe Text
accountId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:encryption:InventoryS3BucketDestination' :: Maybe InventoryEncryption
encryption = forall a. Maybe a
Prelude.Nothing,
      $sel:prefix:InventoryS3BucketDestination' :: Maybe Text
prefix = forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:InventoryS3BucketDestination' :: BucketName
bucket = BucketName
pBucket_,
      $sel:format:InventoryS3BucketDestination' :: InventoryFormat
format = InventoryFormat
pFormat_
    }

-- | 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 :: Lens' InventoryS3BucketDestination (Maybe Text)
inventoryS3BucketDestination_accountId = 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 :: Lens' InventoryS3BucketDestination (Maybe InventoryEncryption)
inventoryS3BucketDestination_encryption = 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 prefix that is prepended to all inventory results.
inventoryS3BucketDestination_prefix :: Lens.Lens' InventoryS3BucketDestination (Prelude.Maybe Prelude.Text)
inventoryS3BucketDestination_prefix :: Lens' InventoryS3BucketDestination (Maybe Text)
inventoryS3BucketDestination_prefix = 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 Amazon Resource Name (ARN) of the bucket where inventory results
-- will be published.
inventoryS3BucketDestination_bucket :: Lens.Lens' InventoryS3BucketDestination BucketName
inventoryS3BucketDestination_bucket :: Lens' InventoryS3BucketDestination BucketName
inventoryS3BucketDestination_bucket = 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 :: Lens' InventoryS3BucketDestination InventoryFormat
inventoryS3BucketDestination_format = 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 Data.FromXML InventoryS3BucketDestination where
  parseXML :: [Node] -> Either String InventoryS3BucketDestination
parseXML [Node]
x =
    Maybe Text
-> Maybe InventoryEncryption
-> Maybe Text
-> BucketName
-> InventoryFormat
-> InventoryS3BucketDestination
InventoryS3BucketDestination'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"AccountId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Encryption")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Prefix")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Bucket")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Format")

instance
  Prelude.Hashable
    InventoryS3BucketDestination
  where
  hashWithSalt :: Int -> InventoryS3BucketDestination -> Int
hashWithSalt Int
_salt InventoryS3BucketDestination' {Maybe Text
Maybe InventoryEncryption
BucketName
InventoryFormat
format :: InventoryFormat
bucket :: BucketName
prefix :: Maybe Text
encryption :: Maybe InventoryEncryption
accountId :: Maybe Text
$sel:format:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> InventoryFormat
$sel:bucket:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> BucketName
$sel:prefix:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> Maybe Text
$sel:encryption:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> Maybe InventoryEncryption
$sel:accountId:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InventoryEncryption
encryption
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
prefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` BucketName
bucket
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` InventoryFormat
format

instance Prelude.NFData InventoryS3BucketDestination where
  rnf :: InventoryS3BucketDestination -> ()
rnf InventoryS3BucketDestination' {Maybe Text
Maybe InventoryEncryption
BucketName
InventoryFormat
format :: InventoryFormat
bucket :: BucketName
prefix :: Maybe Text
encryption :: Maybe InventoryEncryption
accountId :: Maybe Text
$sel:format:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> InventoryFormat
$sel:bucket:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> BucketName
$sel:prefix:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> Maybe Text
$sel:encryption:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> Maybe InventoryEncryption
$sel:accountId:InventoryS3BucketDestination' :: InventoryS3BucketDestination -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InventoryEncryption
encryption
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
prefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf BucketName
bucket
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf InventoryFormat
format

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