{-# 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.OwnershipControlsRule
-- 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.OwnershipControlsRule 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.ObjectOwnership

-- | The container element for an ownership control rule.
--
-- /See:/ 'newOwnershipControlsRule' smart constructor.
data OwnershipControlsRule = OwnershipControlsRule'
  { OwnershipControlsRule -> ObjectOwnership
objectOwnership :: ObjectOwnership
  }
  deriving (OwnershipControlsRule -> OwnershipControlsRule -> Bool
(OwnershipControlsRule -> OwnershipControlsRule -> Bool)
-> (OwnershipControlsRule -> OwnershipControlsRule -> Bool)
-> Eq OwnershipControlsRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OwnershipControlsRule -> OwnershipControlsRule -> Bool
$c/= :: OwnershipControlsRule -> OwnershipControlsRule -> Bool
== :: OwnershipControlsRule -> OwnershipControlsRule -> Bool
$c== :: OwnershipControlsRule -> OwnershipControlsRule -> Bool
Prelude.Eq, ReadPrec [OwnershipControlsRule]
ReadPrec OwnershipControlsRule
Int -> ReadS OwnershipControlsRule
ReadS [OwnershipControlsRule]
(Int -> ReadS OwnershipControlsRule)
-> ReadS [OwnershipControlsRule]
-> ReadPrec OwnershipControlsRule
-> ReadPrec [OwnershipControlsRule]
-> Read OwnershipControlsRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OwnershipControlsRule]
$creadListPrec :: ReadPrec [OwnershipControlsRule]
readPrec :: ReadPrec OwnershipControlsRule
$creadPrec :: ReadPrec OwnershipControlsRule
readList :: ReadS [OwnershipControlsRule]
$creadList :: ReadS [OwnershipControlsRule]
readsPrec :: Int -> ReadS OwnershipControlsRule
$creadsPrec :: Int -> ReadS OwnershipControlsRule
Prelude.Read, Int -> OwnershipControlsRule -> ShowS
[OwnershipControlsRule] -> ShowS
OwnershipControlsRule -> String
(Int -> OwnershipControlsRule -> ShowS)
-> (OwnershipControlsRule -> String)
-> ([OwnershipControlsRule] -> ShowS)
-> Show OwnershipControlsRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OwnershipControlsRule] -> ShowS
$cshowList :: [OwnershipControlsRule] -> ShowS
show :: OwnershipControlsRule -> String
$cshow :: OwnershipControlsRule -> String
showsPrec :: Int -> OwnershipControlsRule -> ShowS
$cshowsPrec :: Int -> OwnershipControlsRule -> ShowS
Prelude.Show, (forall x. OwnershipControlsRule -> Rep OwnershipControlsRule x)
-> (forall x. Rep OwnershipControlsRule x -> OwnershipControlsRule)
-> Generic OwnershipControlsRule
forall x. Rep OwnershipControlsRule x -> OwnershipControlsRule
forall x. OwnershipControlsRule -> Rep OwnershipControlsRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OwnershipControlsRule x -> OwnershipControlsRule
$cfrom :: forall x. OwnershipControlsRule -> Rep OwnershipControlsRule x
Prelude.Generic)

-- |
-- Create a value of 'OwnershipControlsRule' 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:
--
-- 'objectOwnership', 'ownershipControlsRule_objectOwnership' - Undocumented member.
newOwnershipControlsRule ::
  -- | 'objectOwnership'
  ObjectOwnership ->
  OwnershipControlsRule
newOwnershipControlsRule :: ObjectOwnership -> OwnershipControlsRule
newOwnershipControlsRule ObjectOwnership
pObjectOwnership_ =
  OwnershipControlsRule' :: ObjectOwnership -> OwnershipControlsRule
OwnershipControlsRule'
    { $sel:objectOwnership:OwnershipControlsRule' :: ObjectOwnership
objectOwnership =
        ObjectOwnership
pObjectOwnership_
    }

-- | Undocumented member.
ownershipControlsRule_objectOwnership :: Lens.Lens' OwnershipControlsRule ObjectOwnership
ownershipControlsRule_objectOwnership :: (ObjectOwnership -> f ObjectOwnership)
-> OwnershipControlsRule -> f OwnershipControlsRule
ownershipControlsRule_objectOwnership = (OwnershipControlsRule -> ObjectOwnership)
-> (OwnershipControlsRule
    -> ObjectOwnership -> OwnershipControlsRule)
-> Lens
     OwnershipControlsRule
     OwnershipControlsRule
     ObjectOwnership
     ObjectOwnership
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OwnershipControlsRule' {ObjectOwnership
objectOwnership :: ObjectOwnership
$sel:objectOwnership:OwnershipControlsRule' :: OwnershipControlsRule -> ObjectOwnership
objectOwnership} -> ObjectOwnership
objectOwnership) (\s :: OwnershipControlsRule
s@OwnershipControlsRule' {} ObjectOwnership
a -> OwnershipControlsRule
s {$sel:objectOwnership:OwnershipControlsRule' :: ObjectOwnership
objectOwnership = ObjectOwnership
a} :: OwnershipControlsRule)

instance Core.FromXML OwnershipControlsRule where
  parseXML :: [Node] -> Either String OwnershipControlsRule
parseXML [Node]
x =
    ObjectOwnership -> OwnershipControlsRule
OwnershipControlsRule'
      (ObjectOwnership -> OwnershipControlsRule)
-> Either String ObjectOwnership
-> Either String OwnershipControlsRule
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String ObjectOwnership
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"ObjectOwnership")

instance Prelude.Hashable OwnershipControlsRule

instance Prelude.NFData OwnershipControlsRule

instance Core.ToXML OwnershipControlsRule where
  toXML :: OwnershipControlsRule -> XML
toXML OwnershipControlsRule' {ObjectOwnership
objectOwnership :: ObjectOwnership
$sel:objectOwnership:OwnershipControlsRule' :: OwnershipControlsRule -> ObjectOwnership
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [Name
"ObjectOwnership" Name -> ObjectOwnership -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= ObjectOwnership
objectOwnership]