{-# 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.CopyObjectResult
-- 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.CopyObjectResult where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal

-- | Container for all response elements.
--
-- /See:/ 'newCopyObjectResult' smart constructor.
data CopyObjectResult = CopyObjectResult'
  { -- | Returns the ETag of the new object. The ETag reflects only changes to
    -- the contents of an object, not its metadata.
    CopyObjectResult -> Maybe ETag
eTag :: Prelude.Maybe ETag,
    -- | Creation date of the object.
    CopyObjectResult -> Maybe ISO8601
lastModified :: Prelude.Maybe Core.ISO8601
  }
  deriving (CopyObjectResult -> CopyObjectResult -> Bool
(CopyObjectResult -> CopyObjectResult -> Bool)
-> (CopyObjectResult -> CopyObjectResult -> Bool)
-> Eq CopyObjectResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CopyObjectResult -> CopyObjectResult -> Bool
$c/= :: CopyObjectResult -> CopyObjectResult -> Bool
== :: CopyObjectResult -> CopyObjectResult -> Bool
$c== :: CopyObjectResult -> CopyObjectResult -> Bool
Prelude.Eq, ReadPrec [CopyObjectResult]
ReadPrec CopyObjectResult
Int -> ReadS CopyObjectResult
ReadS [CopyObjectResult]
(Int -> ReadS CopyObjectResult)
-> ReadS [CopyObjectResult]
-> ReadPrec CopyObjectResult
-> ReadPrec [CopyObjectResult]
-> Read CopyObjectResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CopyObjectResult]
$creadListPrec :: ReadPrec [CopyObjectResult]
readPrec :: ReadPrec CopyObjectResult
$creadPrec :: ReadPrec CopyObjectResult
readList :: ReadS [CopyObjectResult]
$creadList :: ReadS [CopyObjectResult]
readsPrec :: Int -> ReadS CopyObjectResult
$creadsPrec :: Int -> ReadS CopyObjectResult
Prelude.Read, Int -> CopyObjectResult -> ShowS
[CopyObjectResult] -> ShowS
CopyObjectResult -> String
(Int -> CopyObjectResult -> ShowS)
-> (CopyObjectResult -> String)
-> ([CopyObjectResult] -> ShowS)
-> Show CopyObjectResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CopyObjectResult] -> ShowS
$cshowList :: [CopyObjectResult] -> ShowS
show :: CopyObjectResult -> String
$cshow :: CopyObjectResult -> String
showsPrec :: Int -> CopyObjectResult -> ShowS
$cshowsPrec :: Int -> CopyObjectResult -> ShowS
Prelude.Show, (forall x. CopyObjectResult -> Rep CopyObjectResult x)
-> (forall x. Rep CopyObjectResult x -> CopyObjectResult)
-> Generic CopyObjectResult
forall x. Rep CopyObjectResult x -> CopyObjectResult
forall x. CopyObjectResult -> Rep CopyObjectResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CopyObjectResult x -> CopyObjectResult
$cfrom :: forall x. CopyObjectResult -> Rep CopyObjectResult x
Prelude.Generic)

-- |
-- Create a value of 'CopyObjectResult' 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:
--
-- 'eTag', 'copyObjectResult_eTag' - Returns the ETag of the new object. The ETag reflects only changes to
-- the contents of an object, not its metadata.
--
-- 'lastModified', 'copyObjectResult_lastModified' - Creation date of the object.
newCopyObjectResult ::
  CopyObjectResult
newCopyObjectResult :: CopyObjectResult
newCopyObjectResult =
  CopyObjectResult' :: Maybe ETag -> Maybe ISO8601 -> CopyObjectResult
CopyObjectResult'
    { $sel:eTag:CopyObjectResult' :: Maybe ETag
eTag = Maybe ETag
forall a. Maybe a
Prelude.Nothing,
      $sel:lastModified:CopyObjectResult' :: Maybe ISO8601
lastModified = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing
    }

-- | Returns the ETag of the new object. The ETag reflects only changes to
-- the contents of an object, not its metadata.
copyObjectResult_eTag :: Lens.Lens' CopyObjectResult (Prelude.Maybe ETag)
copyObjectResult_eTag :: (Maybe ETag -> f (Maybe ETag))
-> CopyObjectResult -> f CopyObjectResult
copyObjectResult_eTag = (CopyObjectResult -> Maybe ETag)
-> (CopyObjectResult -> Maybe ETag -> CopyObjectResult)
-> Lens CopyObjectResult CopyObjectResult (Maybe ETag) (Maybe ETag)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopyObjectResult' {Maybe ETag
eTag :: Maybe ETag
$sel:eTag:CopyObjectResult' :: CopyObjectResult -> Maybe ETag
eTag} -> Maybe ETag
eTag) (\s :: CopyObjectResult
s@CopyObjectResult' {} Maybe ETag
a -> CopyObjectResult
s {$sel:eTag:CopyObjectResult' :: Maybe ETag
eTag = Maybe ETag
a} :: CopyObjectResult)

-- | Creation date of the object.
copyObjectResult_lastModified :: Lens.Lens' CopyObjectResult (Prelude.Maybe Prelude.UTCTime)
copyObjectResult_lastModified :: (Maybe UTCTime -> f (Maybe UTCTime))
-> CopyObjectResult -> f CopyObjectResult
copyObjectResult_lastModified = (CopyObjectResult -> Maybe ISO8601)
-> (CopyObjectResult -> Maybe ISO8601 -> CopyObjectResult)
-> Lens
     CopyObjectResult CopyObjectResult (Maybe ISO8601) (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopyObjectResult' {Maybe ISO8601
lastModified :: Maybe ISO8601
$sel:lastModified:CopyObjectResult' :: CopyObjectResult -> Maybe ISO8601
lastModified} -> Maybe ISO8601
lastModified) (\s :: CopyObjectResult
s@CopyObjectResult' {} Maybe ISO8601
a -> CopyObjectResult
s {$sel:lastModified:CopyObjectResult' :: Maybe ISO8601
lastModified = Maybe ISO8601
a} :: CopyObjectResult) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> CopyObjectResult -> f CopyObjectResult)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> CopyObjectResult
-> f CopyObjectResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromXML CopyObjectResult where
  parseXML :: [Node] -> Either String CopyObjectResult
parseXML [Node]
x =
    Maybe ETag -> Maybe ISO8601 -> CopyObjectResult
CopyObjectResult'
      (Maybe ETag -> Maybe ISO8601 -> CopyObjectResult)
-> Either String (Maybe ETag)
-> Either String (Maybe ISO8601 -> CopyObjectResult)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe ETag)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ETag")
      Either String (Maybe ISO8601 -> CopyObjectResult)
-> Either String (Maybe ISO8601) -> Either String CopyObjectResult
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LastModified")

instance Prelude.Hashable CopyObjectResult

instance Prelude.NFData CopyObjectResult