{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.PutObjectRetention
-- 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)
--
-- Places an Object Retention configuration on an object. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock.html Locking Objects>.
-- Users or accounts require the @s3:PutObjectRetention@ permission in
-- order to place an Object Retention configuration on objects. Bypassing a
-- Governance Retention configuration requires the
-- @s3:BypassGovernanceRetention@ permission.
--
-- This action is not supported by Amazon S3 on Outposts.
--
-- __Permissions__
--
-- When the Object Lock retention mode is set to compliance, you need
-- @s3:PutObjectRetention@ and @s3:BypassGovernanceRetention@ permissions.
-- For other requests to @PutObjectRetention@, only @s3:PutObjectRetention@
-- permissions are required.
module Amazonka.S3.PutObjectRetention
  ( -- * Creating a Request
    PutObjectRetention (..),
    newPutObjectRetention,

    -- * Request Lenses
    putObjectRetention_retention,
    putObjectRetention_versionId,
    putObjectRetention_requestPayer,
    putObjectRetention_contentMD5,
    putObjectRetention_bypassGovernanceRetention,
    putObjectRetention_expectedBucketOwner,
    putObjectRetention_bucket,
    putObjectRetention_key,

    -- * Destructuring the Response
    PutObjectRetentionResponse (..),
    newPutObjectRetentionResponse,

    -- * Response Lenses
    putObjectRetentionResponse_requestCharged,
    putObjectRetentionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.S3.Types

-- | /See:/ 'newPutObjectRetention' smart constructor.
data PutObjectRetention = PutObjectRetention'
  { -- | The container element for the Object Retention configuration.
    PutObjectRetention -> Maybe ObjectLockRetention
retention :: Prelude.Maybe ObjectLockRetention,
    -- | The version ID for the object that you want to apply this Object
    -- Retention configuration to.
    PutObjectRetention -> Maybe ObjectVersionId
versionId :: Prelude.Maybe ObjectVersionId,
    PutObjectRetention -> Maybe RequestPayer
requestPayer :: Prelude.Maybe RequestPayer,
    -- | The MD5 hash for the request body.
    --
    -- For requests made using the Amazon Web Services Command Line Interface
    -- (CLI) or Amazon Web Services SDKs, this field is calculated
    -- automatically.
    PutObjectRetention -> Maybe Text
contentMD5 :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether this action should bypass Governance-mode
    -- restrictions.
    PutObjectRetention -> Maybe Bool
bypassGovernanceRetention :: Prelude.Maybe Prelude.Bool,
    -- | The account ID of the expected bucket owner. If the bucket is owned by a
    -- different account, the request will fail with an HTTP
    -- @403 (Access Denied)@ error.
    PutObjectRetention -> Maybe Text
expectedBucketOwner :: Prelude.Maybe Prelude.Text,
    -- | The bucket name that contains the object you want to apply this Object
    -- Retention configuration to.
    --
    -- When using this action with an access point, you must direct requests to
    -- the access point hostname. The access point hostname takes the form
    -- /AccessPointName/-/AccountId/.s3-accesspoint./Region/.amazonaws.com.
    -- When using this action with an access point through the Amazon Web
    -- Services SDKs, you provide the access point ARN in place of the bucket
    -- name. For more information about access point ARNs, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html Using access points>
    -- in the /Amazon S3 User Guide/.
    PutObjectRetention -> BucketName
bucket :: BucketName,
    -- | The key name for the object that you want to apply this Object Retention
    -- configuration to.
    PutObjectRetention -> ObjectKey
key :: ObjectKey
  }
  deriving (PutObjectRetention -> PutObjectRetention -> Bool
(PutObjectRetention -> PutObjectRetention -> Bool)
-> (PutObjectRetention -> PutObjectRetention -> Bool)
-> Eq PutObjectRetention
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutObjectRetention -> PutObjectRetention -> Bool
$c/= :: PutObjectRetention -> PutObjectRetention -> Bool
== :: PutObjectRetention -> PutObjectRetention -> Bool
$c== :: PutObjectRetention -> PutObjectRetention -> Bool
Prelude.Eq, ReadPrec [PutObjectRetention]
ReadPrec PutObjectRetention
Int -> ReadS PutObjectRetention
ReadS [PutObjectRetention]
(Int -> ReadS PutObjectRetention)
-> ReadS [PutObjectRetention]
-> ReadPrec PutObjectRetention
-> ReadPrec [PutObjectRetention]
-> Read PutObjectRetention
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutObjectRetention]
$creadListPrec :: ReadPrec [PutObjectRetention]
readPrec :: ReadPrec PutObjectRetention
$creadPrec :: ReadPrec PutObjectRetention
readList :: ReadS [PutObjectRetention]
$creadList :: ReadS [PutObjectRetention]
readsPrec :: Int -> ReadS PutObjectRetention
$creadsPrec :: Int -> ReadS PutObjectRetention
Prelude.Read, Int -> PutObjectRetention -> ShowS
[PutObjectRetention] -> ShowS
PutObjectRetention -> String
(Int -> PutObjectRetention -> ShowS)
-> (PutObjectRetention -> String)
-> ([PutObjectRetention] -> ShowS)
-> Show PutObjectRetention
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutObjectRetention] -> ShowS
$cshowList :: [PutObjectRetention] -> ShowS
show :: PutObjectRetention -> String
$cshow :: PutObjectRetention -> String
showsPrec :: Int -> PutObjectRetention -> ShowS
$cshowsPrec :: Int -> PutObjectRetention -> ShowS
Prelude.Show, (forall x. PutObjectRetention -> Rep PutObjectRetention x)
-> (forall x. Rep PutObjectRetention x -> PutObjectRetention)
-> Generic PutObjectRetention
forall x. Rep PutObjectRetention x -> PutObjectRetention
forall x. PutObjectRetention -> Rep PutObjectRetention x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutObjectRetention x -> PutObjectRetention
$cfrom :: forall x. PutObjectRetention -> Rep PutObjectRetention x
Prelude.Generic)

-- |
-- Create a value of 'PutObjectRetention' 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:
--
-- 'retention', 'putObjectRetention_retention' - The container element for the Object Retention configuration.
--
-- 'versionId', 'putObjectRetention_versionId' - The version ID for the object that you want to apply this Object
-- Retention configuration to.
--
-- 'requestPayer', 'putObjectRetention_requestPayer' - Undocumented member.
--
-- 'contentMD5', 'putObjectRetention_contentMD5' - The MD5 hash for the request body.
--
-- For requests made using the Amazon Web Services Command Line Interface
-- (CLI) or Amazon Web Services SDKs, this field is calculated
-- automatically.
--
-- 'bypassGovernanceRetention', 'putObjectRetention_bypassGovernanceRetention' - Indicates whether this action should bypass Governance-mode
-- restrictions.
--
-- 'expectedBucketOwner', 'putObjectRetention_expectedBucketOwner' - The account ID of the expected bucket owner. If the bucket is owned by a
-- different account, the request will fail with an HTTP
-- @403 (Access Denied)@ error.
--
-- 'bucket', 'putObjectRetention_bucket' - The bucket name that contains the object you want to apply this Object
-- Retention configuration to.
--
-- When using this action with an access point, you must direct requests to
-- the access point hostname. The access point hostname takes the form
-- /AccessPointName/-/AccountId/.s3-accesspoint./Region/.amazonaws.com.
-- When using this action with an access point through the Amazon Web
-- Services SDKs, you provide the access point ARN in place of the bucket
-- name. For more information about access point ARNs, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html Using access points>
-- in the /Amazon S3 User Guide/.
--
-- 'key', 'putObjectRetention_key' - The key name for the object that you want to apply this Object Retention
-- configuration to.
newPutObjectRetention ::
  -- | 'bucket'
  BucketName ->
  -- | 'key'
  ObjectKey ->
  PutObjectRetention
newPutObjectRetention :: BucketName -> ObjectKey -> PutObjectRetention
newPutObjectRetention BucketName
pBucket_ ObjectKey
pKey_ =
  PutObjectRetention' :: Maybe ObjectLockRetention
-> Maybe ObjectVersionId
-> Maybe RequestPayer
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> BucketName
-> ObjectKey
-> PutObjectRetention
PutObjectRetention'
    { $sel:retention:PutObjectRetention' :: Maybe ObjectLockRetention
retention = Maybe ObjectLockRetention
forall a. Maybe a
Prelude.Nothing,
      $sel:versionId:PutObjectRetention' :: Maybe ObjectVersionId
versionId = Maybe ObjectVersionId
forall a. Maybe a
Prelude.Nothing,
      $sel:requestPayer:PutObjectRetention' :: Maybe RequestPayer
requestPayer = Maybe RequestPayer
forall a. Maybe a
Prelude.Nothing,
      $sel:contentMD5:PutObjectRetention' :: Maybe Text
contentMD5 = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bypassGovernanceRetention:PutObjectRetention' :: Maybe Bool
bypassGovernanceRetention = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:expectedBucketOwner:PutObjectRetention' :: Maybe Text
expectedBucketOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:PutObjectRetention' :: BucketName
bucket = BucketName
pBucket_,
      $sel:key:PutObjectRetention' :: ObjectKey
key = ObjectKey
pKey_
    }

-- | The container element for the Object Retention configuration.
putObjectRetention_retention :: Lens.Lens' PutObjectRetention (Prelude.Maybe ObjectLockRetention)
putObjectRetention_retention :: (Maybe ObjectLockRetention -> f (Maybe ObjectLockRetention))
-> PutObjectRetention -> f PutObjectRetention
putObjectRetention_retention = (PutObjectRetention -> Maybe ObjectLockRetention)
-> (PutObjectRetention
    -> Maybe ObjectLockRetention -> PutObjectRetention)
-> Lens
     PutObjectRetention
     PutObjectRetention
     (Maybe ObjectLockRetention)
     (Maybe ObjectLockRetention)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectRetention' {Maybe ObjectLockRetention
retention :: Maybe ObjectLockRetention
$sel:retention:PutObjectRetention' :: PutObjectRetention -> Maybe ObjectLockRetention
retention} -> Maybe ObjectLockRetention
retention) (\s :: PutObjectRetention
s@PutObjectRetention' {} Maybe ObjectLockRetention
a -> PutObjectRetention
s {$sel:retention:PutObjectRetention' :: Maybe ObjectLockRetention
retention = Maybe ObjectLockRetention
a} :: PutObjectRetention)

-- | The version ID for the object that you want to apply this Object
-- Retention configuration to.
putObjectRetention_versionId :: Lens.Lens' PutObjectRetention (Prelude.Maybe ObjectVersionId)
putObjectRetention_versionId :: (Maybe ObjectVersionId -> f (Maybe ObjectVersionId))
-> PutObjectRetention -> f PutObjectRetention
putObjectRetention_versionId = (PutObjectRetention -> Maybe ObjectVersionId)
-> (PutObjectRetention
    -> Maybe ObjectVersionId -> PutObjectRetention)
-> Lens
     PutObjectRetention
     PutObjectRetention
     (Maybe ObjectVersionId)
     (Maybe ObjectVersionId)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectRetention' {Maybe ObjectVersionId
versionId :: Maybe ObjectVersionId
$sel:versionId:PutObjectRetention' :: PutObjectRetention -> Maybe ObjectVersionId
versionId} -> Maybe ObjectVersionId
versionId) (\s :: PutObjectRetention
s@PutObjectRetention' {} Maybe ObjectVersionId
a -> PutObjectRetention
s {$sel:versionId:PutObjectRetention' :: Maybe ObjectVersionId
versionId = Maybe ObjectVersionId
a} :: PutObjectRetention)

-- | Undocumented member.
putObjectRetention_requestPayer :: Lens.Lens' PutObjectRetention (Prelude.Maybe RequestPayer)
putObjectRetention_requestPayer :: (Maybe RequestPayer -> f (Maybe RequestPayer))
-> PutObjectRetention -> f PutObjectRetention
putObjectRetention_requestPayer = (PutObjectRetention -> Maybe RequestPayer)
-> (PutObjectRetention -> Maybe RequestPayer -> PutObjectRetention)
-> Lens
     PutObjectRetention
     PutObjectRetention
     (Maybe RequestPayer)
     (Maybe RequestPayer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectRetention' {Maybe RequestPayer
requestPayer :: Maybe RequestPayer
$sel:requestPayer:PutObjectRetention' :: PutObjectRetention -> Maybe RequestPayer
requestPayer} -> Maybe RequestPayer
requestPayer) (\s :: PutObjectRetention
s@PutObjectRetention' {} Maybe RequestPayer
a -> PutObjectRetention
s {$sel:requestPayer:PutObjectRetention' :: Maybe RequestPayer
requestPayer = Maybe RequestPayer
a} :: PutObjectRetention)

-- | The MD5 hash for the request body.
--
-- For requests made using the Amazon Web Services Command Line Interface
-- (CLI) or Amazon Web Services SDKs, this field is calculated
-- automatically.
putObjectRetention_contentMD5 :: Lens.Lens' PutObjectRetention (Prelude.Maybe Prelude.Text)
putObjectRetention_contentMD5 :: (Maybe Text -> f (Maybe Text))
-> PutObjectRetention -> f PutObjectRetention
putObjectRetention_contentMD5 = (PutObjectRetention -> Maybe Text)
-> (PutObjectRetention -> Maybe Text -> PutObjectRetention)
-> Lens
     PutObjectRetention PutObjectRetention (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectRetention' {Maybe Text
contentMD5 :: Maybe Text
$sel:contentMD5:PutObjectRetention' :: PutObjectRetention -> Maybe Text
contentMD5} -> Maybe Text
contentMD5) (\s :: PutObjectRetention
s@PutObjectRetention' {} Maybe Text
a -> PutObjectRetention
s {$sel:contentMD5:PutObjectRetention' :: Maybe Text
contentMD5 = Maybe Text
a} :: PutObjectRetention)

-- | Indicates whether this action should bypass Governance-mode
-- restrictions.
putObjectRetention_bypassGovernanceRetention :: Lens.Lens' PutObjectRetention (Prelude.Maybe Prelude.Bool)
putObjectRetention_bypassGovernanceRetention :: (Maybe Bool -> f (Maybe Bool))
-> PutObjectRetention -> f PutObjectRetention
putObjectRetention_bypassGovernanceRetention = (PutObjectRetention -> Maybe Bool)
-> (PutObjectRetention -> Maybe Bool -> PutObjectRetention)
-> Lens
     PutObjectRetention PutObjectRetention (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectRetention' {Maybe Bool
bypassGovernanceRetention :: Maybe Bool
$sel:bypassGovernanceRetention:PutObjectRetention' :: PutObjectRetention -> Maybe Bool
bypassGovernanceRetention} -> Maybe Bool
bypassGovernanceRetention) (\s :: PutObjectRetention
s@PutObjectRetention' {} Maybe Bool
a -> PutObjectRetention
s {$sel:bypassGovernanceRetention:PutObjectRetention' :: Maybe Bool
bypassGovernanceRetention = Maybe Bool
a} :: PutObjectRetention)

-- | The account ID of the expected bucket owner. If the bucket is owned by a
-- different account, the request will fail with an HTTP
-- @403 (Access Denied)@ error.
putObjectRetention_expectedBucketOwner :: Lens.Lens' PutObjectRetention (Prelude.Maybe Prelude.Text)
putObjectRetention_expectedBucketOwner :: (Maybe Text -> f (Maybe Text))
-> PutObjectRetention -> f PutObjectRetention
putObjectRetention_expectedBucketOwner = (PutObjectRetention -> Maybe Text)
-> (PutObjectRetention -> Maybe Text -> PutObjectRetention)
-> Lens
     PutObjectRetention PutObjectRetention (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectRetention' {Maybe Text
expectedBucketOwner :: Maybe Text
$sel:expectedBucketOwner:PutObjectRetention' :: PutObjectRetention -> Maybe Text
expectedBucketOwner} -> Maybe Text
expectedBucketOwner) (\s :: PutObjectRetention
s@PutObjectRetention' {} Maybe Text
a -> PutObjectRetention
s {$sel:expectedBucketOwner:PutObjectRetention' :: Maybe Text
expectedBucketOwner = Maybe Text
a} :: PutObjectRetention)

-- | The bucket name that contains the object you want to apply this Object
-- Retention configuration to.
--
-- When using this action with an access point, you must direct requests to
-- the access point hostname. The access point hostname takes the form
-- /AccessPointName/-/AccountId/.s3-accesspoint./Region/.amazonaws.com.
-- When using this action with an access point through the Amazon Web
-- Services SDKs, you provide the access point ARN in place of the bucket
-- name. For more information about access point ARNs, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html Using access points>
-- in the /Amazon S3 User Guide/.
putObjectRetention_bucket :: Lens.Lens' PutObjectRetention BucketName
putObjectRetention_bucket :: (BucketName -> f BucketName)
-> PutObjectRetention -> f PutObjectRetention
putObjectRetention_bucket = (PutObjectRetention -> BucketName)
-> (PutObjectRetention -> BucketName -> PutObjectRetention)
-> Lens PutObjectRetention PutObjectRetention BucketName BucketName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectRetention' {BucketName
bucket :: BucketName
$sel:bucket:PutObjectRetention' :: PutObjectRetention -> BucketName
bucket} -> BucketName
bucket) (\s :: PutObjectRetention
s@PutObjectRetention' {} BucketName
a -> PutObjectRetention
s {$sel:bucket:PutObjectRetention' :: BucketName
bucket = BucketName
a} :: PutObjectRetention)

-- | The key name for the object that you want to apply this Object Retention
-- configuration to.
putObjectRetention_key :: Lens.Lens' PutObjectRetention ObjectKey
putObjectRetention_key :: (ObjectKey -> f ObjectKey)
-> PutObjectRetention -> f PutObjectRetention
putObjectRetention_key = (PutObjectRetention -> ObjectKey)
-> (PutObjectRetention -> ObjectKey -> PutObjectRetention)
-> Lens PutObjectRetention PutObjectRetention ObjectKey ObjectKey
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectRetention' {ObjectKey
key :: ObjectKey
$sel:key:PutObjectRetention' :: PutObjectRetention -> ObjectKey
key} -> ObjectKey
key) (\s :: PutObjectRetention
s@PutObjectRetention' {} ObjectKey
a -> PutObjectRetention
s {$sel:key:PutObjectRetention' :: ObjectKey
key = ObjectKey
a} :: PutObjectRetention)

instance Core.AWSRequest PutObjectRetention where
  type
    AWSResponse PutObjectRetention =
      PutObjectRetentionResponse
  request :: PutObjectRetention -> Request PutObjectRetention
request =
    Request PutObjectRetention -> Request PutObjectRetention
forall a. Request a -> Request a
Request.s3vhost
      (Request PutObjectRetention -> Request PutObjectRetention)
-> (PutObjectRetention -> Request PutObjectRetention)
-> PutObjectRetention
-> Request PutObjectRetention
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> PutObjectRetention -> Request PutObjectRetention
forall a. (ToRequest a, ToElement a) => Service -> a -> Request a
Request.putXML Service
defaultService
  response :: Logger
-> Service
-> Proxy PutObjectRetention
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutObjectRetention)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutObjectRetention))
-> Logger
-> Service
-> Proxy PutObjectRetention
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutObjectRetention)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Maybe RequestCharged -> Int -> PutObjectRetentionResponse
PutObjectRetentionResponse'
            (Maybe RequestCharged -> Int -> PutObjectRetentionResponse)
-> Either String (Maybe RequestCharged)
-> Either String (Int -> PutObjectRetentionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h ResponseHeaders
-> HeaderName -> Either String (Maybe RequestCharged)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"x-amz-request-charged")
            Either String (Int -> PutObjectRetentionResponse)
-> Either String Int -> Either String PutObjectRetentionResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable PutObjectRetention

instance Prelude.NFData PutObjectRetention

instance Core.ToElement PutObjectRetention where
  toElement :: PutObjectRetention -> Element
toElement PutObjectRetention' {Maybe Bool
Maybe Text
Maybe ObjectVersionId
Maybe ObjectLockRetention
Maybe RequestPayer
ObjectKey
BucketName
key :: ObjectKey
bucket :: BucketName
expectedBucketOwner :: Maybe Text
bypassGovernanceRetention :: Maybe Bool
contentMD5 :: Maybe Text
requestPayer :: Maybe RequestPayer
versionId :: Maybe ObjectVersionId
retention :: Maybe ObjectLockRetention
$sel:key:PutObjectRetention' :: PutObjectRetention -> ObjectKey
$sel:bucket:PutObjectRetention' :: PutObjectRetention -> BucketName
$sel:expectedBucketOwner:PutObjectRetention' :: PutObjectRetention -> Maybe Text
$sel:bypassGovernanceRetention:PutObjectRetention' :: PutObjectRetention -> Maybe Bool
$sel:contentMD5:PutObjectRetention' :: PutObjectRetention -> Maybe Text
$sel:requestPayer:PutObjectRetention' :: PutObjectRetention -> Maybe RequestPayer
$sel:versionId:PutObjectRetention' :: PutObjectRetention -> Maybe ObjectVersionId
$sel:retention:PutObjectRetention' :: PutObjectRetention -> Maybe ObjectLockRetention
..} =
    Name -> Maybe ObjectLockRetention -> Element
forall a. ToXML a => Name -> a -> Element
Core.mkElement
      Name
"{http://s3.amazonaws.com/doc/2006-03-01/}Retention"
      Maybe ObjectLockRetention
retention

instance Core.ToHeaders PutObjectRetention where
  toHeaders :: PutObjectRetention -> ResponseHeaders
toHeaders PutObjectRetention' {Maybe Bool
Maybe Text
Maybe ObjectVersionId
Maybe ObjectLockRetention
Maybe RequestPayer
ObjectKey
BucketName
key :: ObjectKey
bucket :: BucketName
expectedBucketOwner :: Maybe Text
bypassGovernanceRetention :: Maybe Bool
contentMD5 :: Maybe Text
requestPayer :: Maybe RequestPayer
versionId :: Maybe ObjectVersionId
retention :: Maybe ObjectLockRetention
$sel:key:PutObjectRetention' :: PutObjectRetention -> ObjectKey
$sel:bucket:PutObjectRetention' :: PutObjectRetention -> BucketName
$sel:expectedBucketOwner:PutObjectRetention' :: PutObjectRetention -> Maybe Text
$sel:bypassGovernanceRetention:PutObjectRetention' :: PutObjectRetention -> Maybe Bool
$sel:contentMD5:PutObjectRetention' :: PutObjectRetention -> Maybe Text
$sel:requestPayer:PutObjectRetention' :: PutObjectRetention -> Maybe RequestPayer
$sel:versionId:PutObjectRetention' :: PutObjectRetention -> Maybe ObjectVersionId
$sel:retention:PutObjectRetention' :: PutObjectRetention -> Maybe ObjectLockRetention
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"x-amz-request-payer" HeaderName -> Maybe RequestPayer -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe RequestPayer
requestPayer,
        HeaderName
"Content-MD5" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
contentMD5,
        HeaderName
"x-amz-bypass-governance-retention"
          HeaderName -> Maybe Bool -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Bool
bypassGovernanceRetention,
        HeaderName
"x-amz-expected-bucket-owner"
          HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
expectedBucketOwner
      ]

instance Core.ToPath PutObjectRetention where
  toPath :: PutObjectRetention -> ByteString
toPath PutObjectRetention' {Maybe Bool
Maybe Text
Maybe ObjectVersionId
Maybe ObjectLockRetention
Maybe RequestPayer
ObjectKey
BucketName
key :: ObjectKey
bucket :: BucketName
expectedBucketOwner :: Maybe Text
bypassGovernanceRetention :: Maybe Bool
contentMD5 :: Maybe Text
requestPayer :: Maybe RequestPayer
versionId :: Maybe ObjectVersionId
retention :: Maybe ObjectLockRetention
$sel:key:PutObjectRetention' :: PutObjectRetention -> ObjectKey
$sel:bucket:PutObjectRetention' :: PutObjectRetention -> BucketName
$sel:expectedBucketOwner:PutObjectRetention' :: PutObjectRetention -> Maybe Text
$sel:bypassGovernanceRetention:PutObjectRetention' :: PutObjectRetention -> Maybe Bool
$sel:contentMD5:PutObjectRetention' :: PutObjectRetention -> Maybe Text
$sel:requestPayer:PutObjectRetention' :: PutObjectRetention -> Maybe RequestPayer
$sel:versionId:PutObjectRetention' :: PutObjectRetention -> Maybe ObjectVersionId
$sel:retention:PutObjectRetention' :: PutObjectRetention -> Maybe ObjectLockRetention
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/", BucketName -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS BucketName
bucket, ByteString
"/", ObjectKey -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS ObjectKey
key]

instance Core.ToQuery PutObjectRetention where
  toQuery :: PutObjectRetention -> QueryString
toQuery PutObjectRetention' {Maybe Bool
Maybe Text
Maybe ObjectVersionId
Maybe ObjectLockRetention
Maybe RequestPayer
ObjectKey
BucketName
key :: ObjectKey
bucket :: BucketName
expectedBucketOwner :: Maybe Text
bypassGovernanceRetention :: Maybe Bool
contentMD5 :: Maybe Text
requestPayer :: Maybe RequestPayer
versionId :: Maybe ObjectVersionId
retention :: Maybe ObjectLockRetention
$sel:key:PutObjectRetention' :: PutObjectRetention -> ObjectKey
$sel:bucket:PutObjectRetention' :: PutObjectRetention -> BucketName
$sel:expectedBucketOwner:PutObjectRetention' :: PutObjectRetention -> Maybe Text
$sel:bypassGovernanceRetention:PutObjectRetention' :: PutObjectRetention -> Maybe Bool
$sel:contentMD5:PutObjectRetention' :: PutObjectRetention -> Maybe Text
$sel:requestPayer:PutObjectRetention' :: PutObjectRetention -> Maybe RequestPayer
$sel:versionId:PutObjectRetention' :: PutObjectRetention -> Maybe ObjectVersionId
$sel:retention:PutObjectRetention' :: PutObjectRetention -> Maybe ObjectLockRetention
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"versionId" ByteString -> Maybe ObjectVersionId -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe ObjectVersionId
versionId, QueryString
"retention"]

-- | /See:/ 'newPutObjectRetentionResponse' smart constructor.
data PutObjectRetentionResponse = PutObjectRetentionResponse'
  { PutObjectRetentionResponse -> Maybe RequestCharged
requestCharged :: Prelude.Maybe RequestCharged,
    -- | The response's http status code.
    PutObjectRetentionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutObjectRetentionResponse -> PutObjectRetentionResponse -> Bool
(PutObjectRetentionResponse -> PutObjectRetentionResponse -> Bool)
-> (PutObjectRetentionResponse
    -> PutObjectRetentionResponse -> Bool)
-> Eq PutObjectRetentionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutObjectRetentionResponse -> PutObjectRetentionResponse -> Bool
$c/= :: PutObjectRetentionResponse -> PutObjectRetentionResponse -> Bool
== :: PutObjectRetentionResponse -> PutObjectRetentionResponse -> Bool
$c== :: PutObjectRetentionResponse -> PutObjectRetentionResponse -> Bool
Prelude.Eq, ReadPrec [PutObjectRetentionResponse]
ReadPrec PutObjectRetentionResponse
Int -> ReadS PutObjectRetentionResponse
ReadS [PutObjectRetentionResponse]
(Int -> ReadS PutObjectRetentionResponse)
-> ReadS [PutObjectRetentionResponse]
-> ReadPrec PutObjectRetentionResponse
-> ReadPrec [PutObjectRetentionResponse]
-> Read PutObjectRetentionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutObjectRetentionResponse]
$creadListPrec :: ReadPrec [PutObjectRetentionResponse]
readPrec :: ReadPrec PutObjectRetentionResponse
$creadPrec :: ReadPrec PutObjectRetentionResponse
readList :: ReadS [PutObjectRetentionResponse]
$creadList :: ReadS [PutObjectRetentionResponse]
readsPrec :: Int -> ReadS PutObjectRetentionResponse
$creadsPrec :: Int -> ReadS PutObjectRetentionResponse
Prelude.Read, Int -> PutObjectRetentionResponse -> ShowS
[PutObjectRetentionResponse] -> ShowS
PutObjectRetentionResponse -> String
(Int -> PutObjectRetentionResponse -> ShowS)
-> (PutObjectRetentionResponse -> String)
-> ([PutObjectRetentionResponse] -> ShowS)
-> Show PutObjectRetentionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutObjectRetentionResponse] -> ShowS
$cshowList :: [PutObjectRetentionResponse] -> ShowS
show :: PutObjectRetentionResponse -> String
$cshow :: PutObjectRetentionResponse -> String
showsPrec :: Int -> PutObjectRetentionResponse -> ShowS
$cshowsPrec :: Int -> PutObjectRetentionResponse -> ShowS
Prelude.Show, (forall x.
 PutObjectRetentionResponse -> Rep PutObjectRetentionResponse x)
-> (forall x.
    Rep PutObjectRetentionResponse x -> PutObjectRetentionResponse)
-> Generic PutObjectRetentionResponse
forall x.
Rep PutObjectRetentionResponse x -> PutObjectRetentionResponse
forall x.
PutObjectRetentionResponse -> Rep PutObjectRetentionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutObjectRetentionResponse x -> PutObjectRetentionResponse
$cfrom :: forall x.
PutObjectRetentionResponse -> Rep PutObjectRetentionResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutObjectRetentionResponse' 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:
--
-- 'requestCharged', 'putObjectRetentionResponse_requestCharged' - Undocumented member.
--
-- 'httpStatus', 'putObjectRetentionResponse_httpStatus' - The response's http status code.
newPutObjectRetentionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutObjectRetentionResponse
newPutObjectRetentionResponse :: Int -> PutObjectRetentionResponse
newPutObjectRetentionResponse Int
pHttpStatus_ =
  PutObjectRetentionResponse' :: Maybe RequestCharged -> Int -> PutObjectRetentionResponse
PutObjectRetentionResponse'
    { $sel:requestCharged:PutObjectRetentionResponse' :: Maybe RequestCharged
requestCharged =
        Maybe RequestCharged
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutObjectRetentionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
putObjectRetentionResponse_requestCharged :: Lens.Lens' PutObjectRetentionResponse (Prelude.Maybe RequestCharged)
putObjectRetentionResponse_requestCharged :: (Maybe RequestCharged -> f (Maybe RequestCharged))
-> PutObjectRetentionResponse -> f PutObjectRetentionResponse
putObjectRetentionResponse_requestCharged = (PutObjectRetentionResponse -> Maybe RequestCharged)
-> (PutObjectRetentionResponse
    -> Maybe RequestCharged -> PutObjectRetentionResponse)
-> Lens
     PutObjectRetentionResponse
     PutObjectRetentionResponse
     (Maybe RequestCharged)
     (Maybe RequestCharged)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectRetentionResponse' {Maybe RequestCharged
requestCharged :: Maybe RequestCharged
$sel:requestCharged:PutObjectRetentionResponse' :: PutObjectRetentionResponse -> Maybe RequestCharged
requestCharged} -> Maybe RequestCharged
requestCharged) (\s :: PutObjectRetentionResponse
s@PutObjectRetentionResponse' {} Maybe RequestCharged
a -> PutObjectRetentionResponse
s {$sel:requestCharged:PutObjectRetentionResponse' :: Maybe RequestCharged
requestCharged = Maybe RequestCharged
a} :: PutObjectRetentionResponse)

-- | The response's http status code.
putObjectRetentionResponse_httpStatus :: Lens.Lens' PutObjectRetentionResponse Prelude.Int
putObjectRetentionResponse_httpStatus :: (Int -> f Int)
-> PutObjectRetentionResponse -> f PutObjectRetentionResponse
putObjectRetentionResponse_httpStatus = (PutObjectRetentionResponse -> Int)
-> (PutObjectRetentionResponse
    -> Int -> PutObjectRetentionResponse)
-> Lens
     PutObjectRetentionResponse PutObjectRetentionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectRetentionResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutObjectRetentionResponse' :: PutObjectRetentionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutObjectRetentionResponse
s@PutObjectRetentionResponse' {} Int
a -> PutObjectRetentionResponse
s {$sel:httpStatus:PutObjectRetentionResponse' :: Int
httpStatus = Int
a} :: PutObjectRetentionResponse)

instance Prelude.NFData PutObjectRetentionResponse