{-# 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.Owner
-- 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.Owner where

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

-- | Container for the owner\'s display name and ID.
--
-- /See:/ 'newOwner' smart constructor.
data Owner = Owner'
  { -- | Container for the display name of the owner.
    Owner -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | Container for the ID of the owner.
    Owner -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (Owner -> Owner -> Bool
(Owner -> Owner -> Bool) -> (Owner -> Owner -> Bool) -> Eq Owner
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Owner -> Owner -> Bool
$c/= :: Owner -> Owner -> Bool
== :: Owner -> Owner -> Bool
$c== :: Owner -> Owner -> Bool
Prelude.Eq, ReadPrec [Owner]
ReadPrec Owner
Int -> ReadS Owner
ReadS [Owner]
(Int -> ReadS Owner)
-> ReadS [Owner]
-> ReadPrec Owner
-> ReadPrec [Owner]
-> Read Owner
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Owner]
$creadListPrec :: ReadPrec [Owner]
readPrec :: ReadPrec Owner
$creadPrec :: ReadPrec Owner
readList :: ReadS [Owner]
$creadList :: ReadS [Owner]
readsPrec :: Int -> ReadS Owner
$creadsPrec :: Int -> ReadS Owner
Prelude.Read, Int -> Owner -> ShowS
[Owner] -> ShowS
Owner -> String
(Int -> Owner -> ShowS)
-> (Owner -> String) -> ([Owner] -> ShowS) -> Show Owner
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Owner] -> ShowS
$cshowList :: [Owner] -> ShowS
show :: Owner -> String
$cshow :: Owner -> String
showsPrec :: Int -> Owner -> ShowS
$cshowsPrec :: Int -> Owner -> ShowS
Prelude.Show, (forall x. Owner -> Rep Owner x)
-> (forall x. Rep Owner x -> Owner) -> Generic Owner
forall x. Rep Owner x -> Owner
forall x. Owner -> Rep Owner x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Owner x -> Owner
$cfrom :: forall x. Owner -> Rep Owner x
Prelude.Generic)

-- |
-- Create a value of 'Owner' 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', 'owner_displayName' - Container for the display name of the owner.
--
-- 'id', 'owner_id' - Container for the ID of the owner.
newOwner ::
  Owner
newOwner :: Owner
newOwner =
  Owner' :: Maybe Text -> Maybe Text -> Owner
Owner'
    { $sel:displayName:Owner' :: Maybe Text
displayName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Owner' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Container for the display name of the owner.
owner_displayName :: Lens.Lens' Owner (Prelude.Maybe Prelude.Text)
owner_displayName :: (Maybe Text -> f (Maybe Text)) -> Owner -> f Owner
owner_displayName = (Owner -> Maybe Text)
-> (Owner -> Maybe Text -> Owner)
-> Lens Owner Owner (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Owner' {Maybe Text
displayName :: Maybe Text
$sel:displayName:Owner' :: Owner -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: Owner
s@Owner' {} Maybe Text
a -> Owner
s {$sel:displayName:Owner' :: Maybe Text
displayName = Maybe Text
a} :: Owner)

-- | Container for the ID of the owner.
owner_id :: Lens.Lens' Owner (Prelude.Maybe Prelude.Text)
owner_id :: (Maybe Text -> f (Maybe Text)) -> Owner -> f Owner
owner_id = (Owner -> Maybe Text)
-> (Owner -> Maybe Text -> Owner)
-> Lens Owner Owner (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Owner' {Maybe Text
id :: Maybe Text
$sel:id:Owner' :: Owner -> Maybe Text
id} -> Maybe Text
id) (\s :: Owner
s@Owner' {} Maybe Text
a -> Owner
s {$sel:id:Owner' :: Maybe Text
id = Maybe Text
a} :: Owner)

instance Core.FromXML Owner where
  parseXML :: [Node] -> Either String Owner
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Owner
Owner'
      (Maybe Text -> Maybe Text -> Owner)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Owner)
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
"DisplayName")
      Either String (Maybe Text -> Owner)
-> Either String (Maybe Text) -> Either String Owner
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
"ID")

instance Prelude.Hashable Owner

instance Prelude.NFData Owner

instance Core.ToXML Owner where
  toXML :: Owner -> XML
toXML Owner' {Maybe Text
id :: Maybe Text
displayName :: Maybe Text
$sel:id:Owner' :: Owner -> Maybe Text
$sel:displayName:Owner' :: Owner -> Maybe Text
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [Name
"DisplayName" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
displayName, Name
"ID" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
id]