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

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

-- |
-- Create a value of 'OwnershipControls' 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:
--
-- 'rules', 'ownershipControls_rules' - The container element for an ownership control rule.
newOwnershipControls ::
  OwnershipControls
newOwnershipControls :: OwnershipControls
newOwnershipControls =
  OwnershipControls' :: [OwnershipControlsRule] -> OwnershipControls
OwnershipControls' {$sel:rules:OwnershipControls' :: [OwnershipControlsRule]
rules = [OwnershipControlsRule]
forall a. Monoid a => a
Prelude.mempty}

-- | The container element for an ownership control rule.
ownershipControls_rules :: Lens.Lens' OwnershipControls [OwnershipControlsRule]
ownershipControls_rules :: ([OwnershipControlsRule] -> f [OwnershipControlsRule])
-> OwnershipControls -> f OwnershipControls
ownershipControls_rules = (OwnershipControls -> [OwnershipControlsRule])
-> (OwnershipControls
    -> [OwnershipControlsRule] -> OwnershipControls)
-> Lens
     OwnershipControls
     OwnershipControls
     [OwnershipControlsRule]
     [OwnershipControlsRule]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OwnershipControls' {[OwnershipControlsRule]
rules :: [OwnershipControlsRule]
$sel:rules:OwnershipControls' :: OwnershipControls -> [OwnershipControlsRule]
rules} -> [OwnershipControlsRule]
rules) (\s :: OwnershipControls
s@OwnershipControls' {} [OwnershipControlsRule]
a -> OwnershipControls
s {$sel:rules:OwnershipControls' :: [OwnershipControlsRule]
rules = [OwnershipControlsRule]
a} :: OwnershipControls) (([OwnershipControlsRule] -> f [OwnershipControlsRule])
 -> OwnershipControls -> f OwnershipControls)
-> (([OwnershipControlsRule] -> f [OwnershipControlsRule])
    -> [OwnershipControlsRule] -> f [OwnershipControlsRule])
-> ([OwnershipControlsRule] -> f [OwnershipControlsRule])
-> OwnershipControls
-> f OwnershipControls
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([OwnershipControlsRule] -> f [OwnershipControlsRule])
-> [OwnershipControlsRule] -> f [OwnershipControlsRule]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable OwnershipControls

instance Prelude.NFData OwnershipControls

instance Core.ToXML OwnershipControls where
  toXML :: OwnershipControls -> XML
toXML OwnershipControls' {[OwnershipControlsRule]
rules :: [OwnershipControlsRule]
$sel:rules:OwnershipControls' :: OwnershipControls -> [OwnershipControlsRule]
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat [Name -> [OwnershipControlsRule] -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"Rule" [OwnershipControlsRule]
rules]