{-# 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.PutObjectTagging
-- 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)
--
-- Sets the supplied tag-set to an object that already exists in a bucket.
--
-- A tag is a key-value pair. You can associate tags with an object by
-- sending a PUT request against the tagging subresource that is associated
-- with the object. You can retrieve tags by sending a GET request. For
-- more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectTagging.html GetObjectTagging>.
--
-- For tagging-related restrictions related to characters and encodings,
-- see
-- <https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/allocation-tag-restrictions.html Tag Restrictions>.
-- Note that Amazon S3 limits the maximum number of tags to 10 tags per
-- object.
--
-- To use this operation, you must have permission to perform the
-- @s3:PutObjectTagging@ action. By default, the bucket owner has this
-- permission and can grant this permission to others.
--
-- To put tags of any other version, use the @versionId@ query parameter.
-- You also need permission for the @s3:PutObjectVersionTagging@ action.
--
-- For information about the Amazon S3 object tagging feature, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/object-tagging.html Object Tagging>.
--
-- __Special Errors__
--
-- -   -   /Code: InvalidTagError/
--
--     -   /Cause: The tag provided was not a valid tag. This error can
--         occur if the tag did not pass input validation. For more
--         information, see
--         <https://docs.aws.amazon.com/AmazonS3/latest/dev/object-tagging.html Object Tagging>./
--
-- -   -   /Code: MalformedXMLError/
--
--     -   /Cause: The XML provided does not match the schema./
--
-- -   -   /Code: OperationAbortedError/
--
--     -   /Cause: A conflicting conditional action is currently in
--         progress against this resource. Please try again./
--
-- -   -   /Code: InternalError/
--
--     -   /Cause: The service was unable to apply the provided tag to the
--         object./
--
-- __Related Resources__
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectTagging.html GetObjectTagging>
--
-- -   <https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjectTagging.html DeleteObjectTagging>
module Amazonka.S3.PutObjectTagging
  ( -- * Creating a Request
    PutObjectTagging (..),
    newPutObjectTagging,

    -- * Request Lenses
    putObjectTagging_versionId,
    putObjectTagging_requestPayer,
    putObjectTagging_contentMD5,
    putObjectTagging_expectedBucketOwner,
    putObjectTagging_bucket,
    putObjectTagging_key,
    putObjectTagging_tagging,

    -- * Destructuring the Response
    PutObjectTaggingResponse (..),
    newPutObjectTaggingResponse,

    -- * Response Lenses
    putObjectTaggingResponse_versionId,
    putObjectTaggingResponse_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:/ 'newPutObjectTagging' smart constructor.
data PutObjectTagging = PutObjectTagging'
  { -- | The versionId of the object that the tag-set will be added to.
    PutObjectTagging -> Maybe ObjectVersionId
versionId :: Prelude.Maybe ObjectVersionId,
    PutObjectTagging -> 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.
    PutObjectTagging -> Maybe Text
contentMD5 :: Prelude.Maybe Prelude.Text,
    -- | 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.
    PutObjectTagging -> Maybe Text
expectedBucketOwner :: Prelude.Maybe Prelude.Text,
    -- | The bucket name containing the object.
    --
    -- 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/.
    --
    -- When using this action with Amazon S3 on Outposts, you must direct
    -- requests to the S3 on Outposts hostname. The S3 on Outposts hostname
    -- takes the form
    -- /AccessPointName/-/AccountId/./outpostID/.s3-outposts./Region/.amazonaws.com.
    -- When using this action using S3 on Outposts through the Amazon Web
    -- Services SDKs, you provide the Outposts bucket ARN in place of the
    -- bucket name. For more information about S3 on Outposts ARNs, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html Using S3 on Outposts>
    -- in the /Amazon S3 User Guide/.
    PutObjectTagging -> BucketName
bucket :: BucketName,
    -- | Name of the object key.
    PutObjectTagging -> ObjectKey
key :: ObjectKey,
    -- | Container for the @TagSet@ and @Tag@ elements
    PutObjectTagging -> Tagging
tagging :: Tagging
  }
  deriving (PutObjectTagging -> PutObjectTagging -> Bool
(PutObjectTagging -> PutObjectTagging -> Bool)
-> (PutObjectTagging -> PutObjectTagging -> Bool)
-> Eq PutObjectTagging
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutObjectTagging -> PutObjectTagging -> Bool
$c/= :: PutObjectTagging -> PutObjectTagging -> Bool
== :: PutObjectTagging -> PutObjectTagging -> Bool
$c== :: PutObjectTagging -> PutObjectTagging -> Bool
Prelude.Eq, ReadPrec [PutObjectTagging]
ReadPrec PutObjectTagging
Int -> ReadS PutObjectTagging
ReadS [PutObjectTagging]
(Int -> ReadS PutObjectTagging)
-> ReadS [PutObjectTagging]
-> ReadPrec PutObjectTagging
-> ReadPrec [PutObjectTagging]
-> Read PutObjectTagging
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutObjectTagging]
$creadListPrec :: ReadPrec [PutObjectTagging]
readPrec :: ReadPrec PutObjectTagging
$creadPrec :: ReadPrec PutObjectTagging
readList :: ReadS [PutObjectTagging]
$creadList :: ReadS [PutObjectTagging]
readsPrec :: Int -> ReadS PutObjectTagging
$creadsPrec :: Int -> ReadS PutObjectTagging
Prelude.Read, Int -> PutObjectTagging -> ShowS
[PutObjectTagging] -> ShowS
PutObjectTagging -> String
(Int -> PutObjectTagging -> ShowS)
-> (PutObjectTagging -> String)
-> ([PutObjectTagging] -> ShowS)
-> Show PutObjectTagging
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutObjectTagging] -> ShowS
$cshowList :: [PutObjectTagging] -> ShowS
show :: PutObjectTagging -> String
$cshow :: PutObjectTagging -> String
showsPrec :: Int -> PutObjectTagging -> ShowS
$cshowsPrec :: Int -> PutObjectTagging -> ShowS
Prelude.Show, (forall x. PutObjectTagging -> Rep PutObjectTagging x)
-> (forall x. Rep PutObjectTagging x -> PutObjectTagging)
-> Generic PutObjectTagging
forall x. Rep PutObjectTagging x -> PutObjectTagging
forall x. PutObjectTagging -> Rep PutObjectTagging x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutObjectTagging x -> PutObjectTagging
$cfrom :: forall x. PutObjectTagging -> Rep PutObjectTagging x
Prelude.Generic)

-- |
-- Create a value of 'PutObjectTagging' 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:
--
-- 'versionId', 'putObjectTagging_versionId' - The versionId of the object that the tag-set will be added to.
--
-- 'requestPayer', 'putObjectTagging_requestPayer' - Undocumented member.
--
-- 'contentMD5', 'putObjectTagging_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.
--
-- 'expectedBucketOwner', 'putObjectTagging_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', 'putObjectTagging_bucket' - The bucket name containing the object.
--
-- 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/.
--
-- When using this action with Amazon S3 on Outposts, you must direct
-- requests to the S3 on Outposts hostname. The S3 on Outposts hostname
-- takes the form
-- /AccessPointName/-/AccountId/./outpostID/.s3-outposts./Region/.amazonaws.com.
-- When using this action using S3 on Outposts through the Amazon Web
-- Services SDKs, you provide the Outposts bucket ARN in place of the
-- bucket name. For more information about S3 on Outposts ARNs, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html Using S3 on Outposts>
-- in the /Amazon S3 User Guide/.
--
-- 'key', 'putObjectTagging_key' - Name of the object key.
--
-- 'tagging', 'putObjectTagging_tagging' - Container for the @TagSet@ and @Tag@ elements
newPutObjectTagging ::
  -- | 'bucket'
  BucketName ->
  -- | 'key'
  ObjectKey ->
  -- | 'tagging'
  Tagging ->
  PutObjectTagging
newPutObjectTagging :: BucketName -> ObjectKey -> Tagging -> PutObjectTagging
newPutObjectTagging BucketName
pBucket_ ObjectKey
pKey_ Tagging
pTagging_ =
  PutObjectTagging' :: Maybe ObjectVersionId
-> Maybe RequestPayer
-> Maybe Text
-> Maybe Text
-> BucketName
-> ObjectKey
-> Tagging
-> PutObjectTagging
PutObjectTagging'
    { $sel:versionId:PutObjectTagging' :: Maybe ObjectVersionId
versionId = Maybe ObjectVersionId
forall a. Maybe a
Prelude.Nothing,
      $sel:requestPayer:PutObjectTagging' :: Maybe RequestPayer
requestPayer = Maybe RequestPayer
forall a. Maybe a
Prelude.Nothing,
      $sel:contentMD5:PutObjectTagging' :: Maybe Text
contentMD5 = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:expectedBucketOwner:PutObjectTagging' :: Maybe Text
expectedBucketOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:PutObjectTagging' :: BucketName
bucket = BucketName
pBucket_,
      $sel:key:PutObjectTagging' :: ObjectKey
key = ObjectKey
pKey_,
      $sel:tagging:PutObjectTagging' :: Tagging
tagging = Tagging
pTagging_
    }

-- | The versionId of the object that the tag-set will be added to.
putObjectTagging_versionId :: Lens.Lens' PutObjectTagging (Prelude.Maybe ObjectVersionId)
putObjectTagging_versionId :: (Maybe ObjectVersionId -> f (Maybe ObjectVersionId))
-> PutObjectTagging -> f PutObjectTagging
putObjectTagging_versionId = (PutObjectTagging -> Maybe ObjectVersionId)
-> (PutObjectTagging -> Maybe ObjectVersionId -> PutObjectTagging)
-> Lens
     PutObjectTagging
     PutObjectTagging
     (Maybe ObjectVersionId)
     (Maybe ObjectVersionId)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectTagging' {Maybe ObjectVersionId
versionId :: Maybe ObjectVersionId
$sel:versionId:PutObjectTagging' :: PutObjectTagging -> Maybe ObjectVersionId
versionId} -> Maybe ObjectVersionId
versionId) (\s :: PutObjectTagging
s@PutObjectTagging' {} Maybe ObjectVersionId
a -> PutObjectTagging
s {$sel:versionId:PutObjectTagging' :: Maybe ObjectVersionId
versionId = Maybe ObjectVersionId
a} :: PutObjectTagging)

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

-- | 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.
putObjectTagging_contentMD5 :: Lens.Lens' PutObjectTagging (Prelude.Maybe Prelude.Text)
putObjectTagging_contentMD5 :: (Maybe Text -> f (Maybe Text))
-> PutObjectTagging -> f PutObjectTagging
putObjectTagging_contentMD5 = (PutObjectTagging -> Maybe Text)
-> (PutObjectTagging -> Maybe Text -> PutObjectTagging)
-> Lens PutObjectTagging PutObjectTagging (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectTagging' {Maybe Text
contentMD5 :: Maybe Text
$sel:contentMD5:PutObjectTagging' :: PutObjectTagging -> Maybe Text
contentMD5} -> Maybe Text
contentMD5) (\s :: PutObjectTagging
s@PutObjectTagging' {} Maybe Text
a -> PutObjectTagging
s {$sel:contentMD5:PutObjectTagging' :: Maybe Text
contentMD5 = Maybe Text
a} :: PutObjectTagging)

-- | 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.
putObjectTagging_expectedBucketOwner :: Lens.Lens' PutObjectTagging (Prelude.Maybe Prelude.Text)
putObjectTagging_expectedBucketOwner :: (Maybe Text -> f (Maybe Text))
-> PutObjectTagging -> f PutObjectTagging
putObjectTagging_expectedBucketOwner = (PutObjectTagging -> Maybe Text)
-> (PutObjectTagging -> Maybe Text -> PutObjectTagging)
-> Lens PutObjectTagging PutObjectTagging (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectTagging' {Maybe Text
expectedBucketOwner :: Maybe Text
$sel:expectedBucketOwner:PutObjectTagging' :: PutObjectTagging -> Maybe Text
expectedBucketOwner} -> Maybe Text
expectedBucketOwner) (\s :: PutObjectTagging
s@PutObjectTagging' {} Maybe Text
a -> PutObjectTagging
s {$sel:expectedBucketOwner:PutObjectTagging' :: Maybe Text
expectedBucketOwner = Maybe Text
a} :: PutObjectTagging)

-- | The bucket name containing the object.
--
-- 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/.
--
-- When using this action with Amazon S3 on Outposts, you must direct
-- requests to the S3 on Outposts hostname. The S3 on Outposts hostname
-- takes the form
-- /AccessPointName/-/AccountId/./outpostID/.s3-outposts./Region/.amazonaws.com.
-- When using this action using S3 on Outposts through the Amazon Web
-- Services SDKs, you provide the Outposts bucket ARN in place of the
-- bucket name. For more information about S3 on Outposts ARNs, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html Using S3 on Outposts>
-- in the /Amazon S3 User Guide/.
putObjectTagging_bucket :: Lens.Lens' PutObjectTagging BucketName
putObjectTagging_bucket :: (BucketName -> f BucketName)
-> PutObjectTagging -> f PutObjectTagging
putObjectTagging_bucket = (PutObjectTagging -> BucketName)
-> (PutObjectTagging -> BucketName -> PutObjectTagging)
-> Lens PutObjectTagging PutObjectTagging BucketName BucketName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectTagging' {BucketName
bucket :: BucketName
$sel:bucket:PutObjectTagging' :: PutObjectTagging -> BucketName
bucket} -> BucketName
bucket) (\s :: PutObjectTagging
s@PutObjectTagging' {} BucketName
a -> PutObjectTagging
s {$sel:bucket:PutObjectTagging' :: BucketName
bucket = BucketName
a} :: PutObjectTagging)

-- | Name of the object key.
putObjectTagging_key :: Lens.Lens' PutObjectTagging ObjectKey
putObjectTagging_key :: (ObjectKey -> f ObjectKey)
-> PutObjectTagging -> f PutObjectTagging
putObjectTagging_key = (PutObjectTagging -> ObjectKey)
-> (PutObjectTagging -> ObjectKey -> PutObjectTagging)
-> Lens PutObjectTagging PutObjectTagging ObjectKey ObjectKey
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectTagging' {ObjectKey
key :: ObjectKey
$sel:key:PutObjectTagging' :: PutObjectTagging -> ObjectKey
key} -> ObjectKey
key) (\s :: PutObjectTagging
s@PutObjectTagging' {} ObjectKey
a -> PutObjectTagging
s {$sel:key:PutObjectTagging' :: ObjectKey
key = ObjectKey
a} :: PutObjectTagging)

-- | Container for the @TagSet@ and @Tag@ elements
putObjectTagging_tagging :: Lens.Lens' PutObjectTagging Tagging
putObjectTagging_tagging :: (Tagging -> f Tagging) -> PutObjectTagging -> f PutObjectTagging
putObjectTagging_tagging = (PutObjectTagging -> Tagging)
-> (PutObjectTagging -> Tagging -> PutObjectTagging)
-> Lens PutObjectTagging PutObjectTagging Tagging Tagging
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectTagging' {Tagging
tagging :: Tagging
$sel:tagging:PutObjectTagging' :: PutObjectTagging -> Tagging
tagging} -> Tagging
tagging) (\s :: PutObjectTagging
s@PutObjectTagging' {} Tagging
a -> PutObjectTagging
s {$sel:tagging:PutObjectTagging' :: Tagging
tagging = Tagging
a} :: PutObjectTagging)

instance Core.AWSRequest PutObjectTagging where
  type
    AWSResponse PutObjectTagging =
      PutObjectTaggingResponse
  request :: PutObjectTagging -> Request PutObjectTagging
request =
    Request PutObjectTagging -> Request PutObjectTagging
forall a. Request a -> Request a
Request.s3vhost
      (Request PutObjectTagging -> Request PutObjectTagging)
-> (PutObjectTagging -> Request PutObjectTagging)
-> PutObjectTagging
-> Request PutObjectTagging
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> PutObjectTagging -> Request PutObjectTagging
forall a. (ToRequest a, ToElement a) => Service -> a -> Request a
Request.putXML Service
defaultService
  response :: Logger
-> Service
-> Proxy PutObjectTagging
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutObjectTagging)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutObjectTagging))
-> Logger
-> Service
-> Proxy PutObjectTagging
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutObjectTagging)))
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 ObjectVersionId -> Int -> PutObjectTaggingResponse
PutObjectTaggingResponse'
            (Maybe ObjectVersionId -> Int -> PutObjectTaggingResponse)
-> Either String (Maybe ObjectVersionId)
-> Either String (Int -> PutObjectTaggingResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h ResponseHeaders
-> HeaderName -> Either String (Maybe ObjectVersionId)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"x-amz-version-id")
            Either String (Int -> PutObjectTaggingResponse)
-> Either String Int -> Either String PutObjectTaggingResponse
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 PutObjectTagging

instance Prelude.NFData PutObjectTagging

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

instance Core.ToHeaders PutObjectTagging where
  toHeaders :: PutObjectTagging -> ResponseHeaders
toHeaders PutObjectTagging' {Maybe Text
Maybe ObjectVersionId
Maybe RequestPayer
ObjectKey
BucketName
Tagging
tagging :: Tagging
key :: ObjectKey
bucket :: BucketName
expectedBucketOwner :: Maybe Text
contentMD5 :: Maybe Text
requestPayer :: Maybe RequestPayer
versionId :: Maybe ObjectVersionId
$sel:tagging:PutObjectTagging' :: PutObjectTagging -> Tagging
$sel:key:PutObjectTagging' :: PutObjectTagging -> ObjectKey
$sel:bucket:PutObjectTagging' :: PutObjectTagging -> BucketName
$sel:expectedBucketOwner:PutObjectTagging' :: PutObjectTagging -> Maybe Text
$sel:contentMD5:PutObjectTagging' :: PutObjectTagging -> Maybe Text
$sel:requestPayer:PutObjectTagging' :: PutObjectTagging -> Maybe RequestPayer
$sel:versionId:PutObjectTagging' :: PutObjectTagging -> Maybe ObjectVersionId
..} =
    [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-expected-bucket-owner"
          HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
expectedBucketOwner
      ]

instance Core.ToPath PutObjectTagging where
  toPath :: PutObjectTagging -> ByteString
toPath PutObjectTagging' {Maybe Text
Maybe ObjectVersionId
Maybe RequestPayer
ObjectKey
BucketName
Tagging
tagging :: Tagging
key :: ObjectKey
bucket :: BucketName
expectedBucketOwner :: Maybe Text
contentMD5 :: Maybe Text
requestPayer :: Maybe RequestPayer
versionId :: Maybe ObjectVersionId
$sel:tagging:PutObjectTagging' :: PutObjectTagging -> Tagging
$sel:key:PutObjectTagging' :: PutObjectTagging -> ObjectKey
$sel:bucket:PutObjectTagging' :: PutObjectTagging -> BucketName
$sel:expectedBucketOwner:PutObjectTagging' :: PutObjectTagging -> Maybe Text
$sel:contentMD5:PutObjectTagging' :: PutObjectTagging -> Maybe Text
$sel:requestPayer:PutObjectTagging' :: PutObjectTagging -> Maybe RequestPayer
$sel:versionId:PutObjectTagging' :: PutObjectTagging -> Maybe ObjectVersionId
..} =
    [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 PutObjectTagging where
  toQuery :: PutObjectTagging -> QueryString
toQuery PutObjectTagging' {Maybe Text
Maybe ObjectVersionId
Maybe RequestPayer
ObjectKey
BucketName
Tagging
tagging :: Tagging
key :: ObjectKey
bucket :: BucketName
expectedBucketOwner :: Maybe Text
contentMD5 :: Maybe Text
requestPayer :: Maybe RequestPayer
versionId :: Maybe ObjectVersionId
$sel:tagging:PutObjectTagging' :: PutObjectTagging -> Tagging
$sel:key:PutObjectTagging' :: PutObjectTagging -> ObjectKey
$sel:bucket:PutObjectTagging' :: PutObjectTagging -> BucketName
$sel:expectedBucketOwner:PutObjectTagging' :: PutObjectTagging -> Maybe Text
$sel:contentMD5:PutObjectTagging' :: PutObjectTagging -> Maybe Text
$sel:requestPayer:PutObjectTagging' :: PutObjectTagging -> Maybe RequestPayer
$sel:versionId:PutObjectTagging' :: PutObjectTagging -> Maybe ObjectVersionId
..} =
    [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
"tagging"]

-- | /See:/ 'newPutObjectTaggingResponse' smart constructor.
data PutObjectTaggingResponse = PutObjectTaggingResponse'
  { -- | The versionId of the object the tag-set was added to.
    PutObjectTaggingResponse -> Maybe ObjectVersionId
versionId :: Prelude.Maybe ObjectVersionId,
    -- | The response's http status code.
    PutObjectTaggingResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutObjectTaggingResponse -> PutObjectTaggingResponse -> Bool
(PutObjectTaggingResponse -> PutObjectTaggingResponse -> Bool)
-> (PutObjectTaggingResponse -> PutObjectTaggingResponse -> Bool)
-> Eq PutObjectTaggingResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutObjectTaggingResponse -> PutObjectTaggingResponse -> Bool
$c/= :: PutObjectTaggingResponse -> PutObjectTaggingResponse -> Bool
== :: PutObjectTaggingResponse -> PutObjectTaggingResponse -> Bool
$c== :: PutObjectTaggingResponse -> PutObjectTaggingResponse -> Bool
Prelude.Eq, ReadPrec [PutObjectTaggingResponse]
ReadPrec PutObjectTaggingResponse
Int -> ReadS PutObjectTaggingResponse
ReadS [PutObjectTaggingResponse]
(Int -> ReadS PutObjectTaggingResponse)
-> ReadS [PutObjectTaggingResponse]
-> ReadPrec PutObjectTaggingResponse
-> ReadPrec [PutObjectTaggingResponse]
-> Read PutObjectTaggingResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutObjectTaggingResponse]
$creadListPrec :: ReadPrec [PutObjectTaggingResponse]
readPrec :: ReadPrec PutObjectTaggingResponse
$creadPrec :: ReadPrec PutObjectTaggingResponse
readList :: ReadS [PutObjectTaggingResponse]
$creadList :: ReadS [PutObjectTaggingResponse]
readsPrec :: Int -> ReadS PutObjectTaggingResponse
$creadsPrec :: Int -> ReadS PutObjectTaggingResponse
Prelude.Read, Int -> PutObjectTaggingResponse -> ShowS
[PutObjectTaggingResponse] -> ShowS
PutObjectTaggingResponse -> String
(Int -> PutObjectTaggingResponse -> ShowS)
-> (PutObjectTaggingResponse -> String)
-> ([PutObjectTaggingResponse] -> ShowS)
-> Show PutObjectTaggingResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutObjectTaggingResponse] -> ShowS
$cshowList :: [PutObjectTaggingResponse] -> ShowS
show :: PutObjectTaggingResponse -> String
$cshow :: PutObjectTaggingResponse -> String
showsPrec :: Int -> PutObjectTaggingResponse -> ShowS
$cshowsPrec :: Int -> PutObjectTaggingResponse -> ShowS
Prelude.Show, (forall x.
 PutObjectTaggingResponse -> Rep PutObjectTaggingResponse x)
-> (forall x.
    Rep PutObjectTaggingResponse x -> PutObjectTaggingResponse)
-> Generic PutObjectTaggingResponse
forall x.
Rep PutObjectTaggingResponse x -> PutObjectTaggingResponse
forall x.
PutObjectTaggingResponse -> Rep PutObjectTaggingResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutObjectTaggingResponse x -> PutObjectTaggingResponse
$cfrom :: forall x.
PutObjectTaggingResponse -> Rep PutObjectTaggingResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutObjectTaggingResponse' 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:
--
-- 'versionId', 'putObjectTaggingResponse_versionId' - The versionId of the object the tag-set was added to.
--
-- 'httpStatus', 'putObjectTaggingResponse_httpStatus' - The response's http status code.
newPutObjectTaggingResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutObjectTaggingResponse
newPutObjectTaggingResponse :: Int -> PutObjectTaggingResponse
newPutObjectTaggingResponse Int
pHttpStatus_ =
  PutObjectTaggingResponse' :: Maybe ObjectVersionId -> Int -> PutObjectTaggingResponse
PutObjectTaggingResponse'
    { $sel:versionId:PutObjectTaggingResponse' :: Maybe ObjectVersionId
versionId =
        Maybe ObjectVersionId
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutObjectTaggingResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The versionId of the object the tag-set was added to.
putObjectTaggingResponse_versionId :: Lens.Lens' PutObjectTaggingResponse (Prelude.Maybe ObjectVersionId)
putObjectTaggingResponse_versionId :: (Maybe ObjectVersionId -> f (Maybe ObjectVersionId))
-> PutObjectTaggingResponse -> f PutObjectTaggingResponse
putObjectTaggingResponse_versionId = (PutObjectTaggingResponse -> Maybe ObjectVersionId)
-> (PutObjectTaggingResponse
    -> Maybe ObjectVersionId -> PutObjectTaggingResponse)
-> Lens
     PutObjectTaggingResponse
     PutObjectTaggingResponse
     (Maybe ObjectVersionId)
     (Maybe ObjectVersionId)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutObjectTaggingResponse' {Maybe ObjectVersionId
versionId :: Maybe ObjectVersionId
$sel:versionId:PutObjectTaggingResponse' :: PutObjectTaggingResponse -> Maybe ObjectVersionId
versionId} -> Maybe ObjectVersionId
versionId) (\s :: PutObjectTaggingResponse
s@PutObjectTaggingResponse' {} Maybe ObjectVersionId
a -> PutObjectTaggingResponse
s {$sel:versionId:PutObjectTaggingResponse' :: Maybe ObjectVersionId
versionId = Maybe ObjectVersionId
a} :: PutObjectTaggingResponse)

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

instance Prelude.NFData PutObjectTaggingResponse