{-# 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.AccessControlTranslation
-- 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.AccessControlTranslation 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.OwnerOverride

-- | A container for information about access control for replicas.
--
-- /See:/ 'newAccessControlTranslation' smart constructor.
data AccessControlTranslation = AccessControlTranslation'
  { -- | Specifies the replica ownership. For default and valid values, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTreplication.html PUT bucket replication>
    -- in the /Amazon S3 API Reference/.
    AccessControlTranslation -> OwnerOverride
owner :: OwnerOverride
  }
  deriving (AccessControlTranslation -> AccessControlTranslation -> Bool
(AccessControlTranslation -> AccessControlTranslation -> Bool)
-> (AccessControlTranslation -> AccessControlTranslation -> Bool)
-> Eq AccessControlTranslation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccessControlTranslation -> AccessControlTranslation -> Bool
$c/= :: AccessControlTranslation -> AccessControlTranslation -> Bool
== :: AccessControlTranslation -> AccessControlTranslation -> Bool
$c== :: AccessControlTranslation -> AccessControlTranslation -> Bool
Prelude.Eq, ReadPrec [AccessControlTranslation]
ReadPrec AccessControlTranslation
Int -> ReadS AccessControlTranslation
ReadS [AccessControlTranslation]
(Int -> ReadS AccessControlTranslation)
-> ReadS [AccessControlTranslation]
-> ReadPrec AccessControlTranslation
-> ReadPrec [AccessControlTranslation]
-> Read AccessControlTranslation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccessControlTranslation]
$creadListPrec :: ReadPrec [AccessControlTranslation]
readPrec :: ReadPrec AccessControlTranslation
$creadPrec :: ReadPrec AccessControlTranslation
readList :: ReadS [AccessControlTranslation]
$creadList :: ReadS [AccessControlTranslation]
readsPrec :: Int -> ReadS AccessControlTranslation
$creadsPrec :: Int -> ReadS AccessControlTranslation
Prelude.Read, Int -> AccessControlTranslation -> ShowS
[AccessControlTranslation] -> ShowS
AccessControlTranslation -> String
(Int -> AccessControlTranslation -> ShowS)
-> (AccessControlTranslation -> String)
-> ([AccessControlTranslation] -> ShowS)
-> Show AccessControlTranslation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccessControlTranslation] -> ShowS
$cshowList :: [AccessControlTranslation] -> ShowS
show :: AccessControlTranslation -> String
$cshow :: AccessControlTranslation -> String
showsPrec :: Int -> AccessControlTranslation -> ShowS
$cshowsPrec :: Int -> AccessControlTranslation -> ShowS
Prelude.Show, (forall x.
 AccessControlTranslation -> Rep AccessControlTranslation x)
-> (forall x.
    Rep AccessControlTranslation x -> AccessControlTranslation)
-> Generic AccessControlTranslation
forall x.
Rep AccessControlTranslation x -> AccessControlTranslation
forall x.
AccessControlTranslation -> Rep AccessControlTranslation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AccessControlTranslation x -> AccessControlTranslation
$cfrom :: forall x.
AccessControlTranslation -> Rep AccessControlTranslation x
Prelude.Generic)

-- |
-- Create a value of 'AccessControlTranslation' 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:
--
-- 'owner', 'accessControlTranslation_owner' - Specifies the replica ownership. For default and valid values, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTreplication.html PUT bucket replication>
-- in the /Amazon S3 API Reference/.
newAccessControlTranslation ::
  -- | 'owner'
  OwnerOverride ->
  AccessControlTranslation
newAccessControlTranslation :: OwnerOverride -> AccessControlTranslation
newAccessControlTranslation OwnerOverride
pOwner_ =
  AccessControlTranslation' :: OwnerOverride -> AccessControlTranslation
AccessControlTranslation' {$sel:owner:AccessControlTranslation' :: OwnerOverride
owner = OwnerOverride
pOwner_}

-- | Specifies the replica ownership. For default and valid values, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTreplication.html PUT bucket replication>
-- in the /Amazon S3 API Reference/.
accessControlTranslation_owner :: Lens.Lens' AccessControlTranslation OwnerOverride
accessControlTranslation_owner :: (OwnerOverride -> f OwnerOverride)
-> AccessControlTranslation -> f AccessControlTranslation
accessControlTranslation_owner = (AccessControlTranslation -> OwnerOverride)
-> (AccessControlTranslation
    -> OwnerOverride -> AccessControlTranslation)
-> Lens
     AccessControlTranslation
     AccessControlTranslation
     OwnerOverride
     OwnerOverride
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessControlTranslation' {OwnerOverride
owner :: OwnerOverride
$sel:owner:AccessControlTranslation' :: AccessControlTranslation -> OwnerOverride
owner} -> OwnerOverride
owner) (\s :: AccessControlTranslation
s@AccessControlTranslation' {} OwnerOverride
a -> AccessControlTranslation
s {$sel:owner:AccessControlTranslation' :: OwnerOverride
owner = OwnerOverride
a} :: AccessControlTranslation)

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

instance Prelude.Hashable AccessControlTranslation

instance Prelude.NFData AccessControlTranslation

instance Core.ToXML AccessControlTranslation where
  toXML :: AccessControlTranslation -> XML
toXML AccessControlTranslation' {OwnerOverride
owner :: OwnerOverride
$sel:owner:AccessControlTranslation' :: AccessControlTranslation -> OwnerOverride
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat [Name
"Owner" Name -> OwnerOverride -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= OwnerOverride
owner]