{-# 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.MacieV2.Types.S3BucketOwner
-- 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.MacieV2.Types.S3BucketOwner where

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

-- | Provides information about the Amazon Web Services account that owns an
-- S3 bucket.
--
-- /See:/ 'newS3BucketOwner' smart constructor.
data S3BucketOwner = S3BucketOwner'
  { -- | The display name of the account that owns the bucket.
    S3BucketOwner -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | The canonical user ID for the account that owns the bucket.
    S3BucketOwner -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (S3BucketOwner -> S3BucketOwner -> Bool
(S3BucketOwner -> S3BucketOwner -> Bool)
-> (S3BucketOwner -> S3BucketOwner -> Bool) -> Eq S3BucketOwner
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3BucketOwner -> S3BucketOwner -> Bool
$c/= :: S3BucketOwner -> S3BucketOwner -> Bool
== :: S3BucketOwner -> S3BucketOwner -> Bool
$c== :: S3BucketOwner -> S3BucketOwner -> Bool
Prelude.Eq, ReadPrec [S3BucketOwner]
ReadPrec S3BucketOwner
Int -> ReadS S3BucketOwner
ReadS [S3BucketOwner]
(Int -> ReadS S3BucketOwner)
-> ReadS [S3BucketOwner]
-> ReadPrec S3BucketOwner
-> ReadPrec [S3BucketOwner]
-> Read S3BucketOwner
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3BucketOwner]
$creadListPrec :: ReadPrec [S3BucketOwner]
readPrec :: ReadPrec S3BucketOwner
$creadPrec :: ReadPrec S3BucketOwner
readList :: ReadS [S3BucketOwner]
$creadList :: ReadS [S3BucketOwner]
readsPrec :: Int -> ReadS S3BucketOwner
$creadsPrec :: Int -> ReadS S3BucketOwner
Prelude.Read, Int -> S3BucketOwner -> ShowS
[S3BucketOwner] -> ShowS
S3BucketOwner -> String
(Int -> S3BucketOwner -> ShowS)
-> (S3BucketOwner -> String)
-> ([S3BucketOwner] -> ShowS)
-> Show S3BucketOwner
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3BucketOwner] -> ShowS
$cshowList :: [S3BucketOwner] -> ShowS
show :: S3BucketOwner -> String
$cshow :: S3BucketOwner -> String
showsPrec :: Int -> S3BucketOwner -> ShowS
$cshowsPrec :: Int -> S3BucketOwner -> ShowS
Prelude.Show, (forall x. S3BucketOwner -> Rep S3BucketOwner x)
-> (forall x. Rep S3BucketOwner x -> S3BucketOwner)
-> Generic S3BucketOwner
forall x. Rep S3BucketOwner x -> S3BucketOwner
forall x. S3BucketOwner -> Rep S3BucketOwner x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3BucketOwner x -> S3BucketOwner
$cfrom :: forall x. S3BucketOwner -> Rep S3BucketOwner x
Prelude.Generic)

-- |
-- Create a value of 'S3BucketOwner' 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:
--
-- 'displayName', 's3BucketOwner_displayName' - The display name of the account that owns the bucket.
--
-- 'id', 's3BucketOwner_id' - The canonical user ID for the account that owns the bucket.
newS3BucketOwner ::
  S3BucketOwner
newS3BucketOwner :: S3BucketOwner
newS3BucketOwner =
  S3BucketOwner' :: Maybe Text -> Maybe Text -> S3BucketOwner
S3BucketOwner'
    { $sel:displayName:S3BucketOwner' :: Maybe Text
displayName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:S3BucketOwner' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The display name of the account that owns the bucket.
s3BucketOwner_displayName :: Lens.Lens' S3BucketOwner (Prelude.Maybe Prelude.Text)
s3BucketOwner_displayName :: (Maybe Text -> f (Maybe Text)) -> S3BucketOwner -> f S3BucketOwner
s3BucketOwner_displayName = (S3BucketOwner -> Maybe Text)
-> (S3BucketOwner -> Maybe Text -> S3BucketOwner)
-> Lens S3BucketOwner S3BucketOwner (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3BucketOwner' {Maybe Text
displayName :: Maybe Text
$sel:displayName:S3BucketOwner' :: S3BucketOwner -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: S3BucketOwner
s@S3BucketOwner' {} Maybe Text
a -> S3BucketOwner
s {$sel:displayName:S3BucketOwner' :: Maybe Text
displayName = Maybe Text
a} :: S3BucketOwner)

-- | The canonical user ID for the account that owns the bucket.
s3BucketOwner_id :: Lens.Lens' S3BucketOwner (Prelude.Maybe Prelude.Text)
s3BucketOwner_id :: (Maybe Text -> f (Maybe Text)) -> S3BucketOwner -> f S3BucketOwner
s3BucketOwner_id = (S3BucketOwner -> Maybe Text)
-> (S3BucketOwner -> Maybe Text -> S3BucketOwner)
-> Lens S3BucketOwner S3BucketOwner (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3BucketOwner' {Maybe Text
id :: Maybe Text
$sel:id:S3BucketOwner' :: S3BucketOwner -> Maybe Text
id} -> Maybe Text
id) (\s :: S3BucketOwner
s@S3BucketOwner' {} Maybe Text
a -> S3BucketOwner
s {$sel:id:S3BucketOwner' :: Maybe Text
id = Maybe Text
a} :: S3BucketOwner)

instance Core.FromJSON S3BucketOwner where
  parseJSON :: Value -> Parser S3BucketOwner
parseJSON =
    String
-> (Object -> Parser S3BucketOwner)
-> Value
-> Parser S3BucketOwner
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3BucketOwner"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> S3BucketOwner
S3BucketOwner'
            (Maybe Text -> Maybe Text -> S3BucketOwner)
-> Parser (Maybe Text) -> Parser (Maybe Text -> S3BucketOwner)
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
"displayName")
            Parser (Maybe Text -> S3BucketOwner)
-> Parser (Maybe Text) -> Parser S3BucketOwner
forall (f :: * -> *) a b. Applicative f => 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
"id")
      )

instance Prelude.Hashable S3BucketOwner

instance Prelude.NFData S3BucketOwner