{-# 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.ObjectVersion
-- 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.ObjectVersion 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.ObjectVersionStorageClass
import Amazonka.S3.Types.Owner

-- | The version of an object.
--
-- /See:/ 'newObjectVersion' smart constructor.
data ObjectVersion = ObjectVersion'
  { -- | The entity tag is an MD5 hash of that version of the object.
    ObjectVersion -> Maybe ETag
eTag :: Prelude.Maybe ETag,
    -- | Version ID of an object.
    ObjectVersion -> Maybe ObjectVersionId
versionId :: Prelude.Maybe ObjectVersionId,
    -- | Size in bytes of the object.
    ObjectVersion -> Maybe Integer
size :: Prelude.Maybe Prelude.Integer,
    -- | Specifies whether the object is (true) or is not (false) the latest
    -- version of an object.
    ObjectVersion -> Maybe Bool
isLatest :: Prelude.Maybe Prelude.Bool,
    -- | Specifies the owner of the object.
    ObjectVersion -> Maybe Owner
owner :: Prelude.Maybe Owner,
    -- | The object key.
    ObjectVersion -> Maybe ObjectKey
key :: Prelude.Maybe ObjectKey,
    -- | The class of storage used to store the object.
    ObjectVersion -> Maybe ObjectVersionStorageClass
storageClass :: Prelude.Maybe ObjectVersionStorageClass,
    -- | Date and time the object was last modified.
    ObjectVersion -> Maybe ISO8601
lastModified :: Prelude.Maybe Core.ISO8601
  }
  deriving (ObjectVersion -> ObjectVersion -> Bool
(ObjectVersion -> ObjectVersion -> Bool)
-> (ObjectVersion -> ObjectVersion -> Bool) -> Eq ObjectVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ObjectVersion -> ObjectVersion -> Bool
$c/= :: ObjectVersion -> ObjectVersion -> Bool
== :: ObjectVersion -> ObjectVersion -> Bool
$c== :: ObjectVersion -> ObjectVersion -> Bool
Prelude.Eq, ReadPrec [ObjectVersion]
ReadPrec ObjectVersion
Int -> ReadS ObjectVersion
ReadS [ObjectVersion]
(Int -> ReadS ObjectVersion)
-> ReadS [ObjectVersion]
-> ReadPrec ObjectVersion
-> ReadPrec [ObjectVersion]
-> Read ObjectVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ObjectVersion]
$creadListPrec :: ReadPrec [ObjectVersion]
readPrec :: ReadPrec ObjectVersion
$creadPrec :: ReadPrec ObjectVersion
readList :: ReadS [ObjectVersion]
$creadList :: ReadS [ObjectVersion]
readsPrec :: Int -> ReadS ObjectVersion
$creadsPrec :: Int -> ReadS ObjectVersion
Prelude.Read, Int -> ObjectVersion -> ShowS
[ObjectVersion] -> ShowS
ObjectVersion -> String
(Int -> ObjectVersion -> ShowS)
-> (ObjectVersion -> String)
-> ([ObjectVersion] -> ShowS)
-> Show ObjectVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ObjectVersion] -> ShowS
$cshowList :: [ObjectVersion] -> ShowS
show :: ObjectVersion -> String
$cshow :: ObjectVersion -> String
showsPrec :: Int -> ObjectVersion -> ShowS
$cshowsPrec :: Int -> ObjectVersion -> ShowS
Prelude.Show, (forall x. ObjectVersion -> Rep ObjectVersion x)
-> (forall x. Rep ObjectVersion x -> ObjectVersion)
-> Generic ObjectVersion
forall x. Rep ObjectVersion x -> ObjectVersion
forall x. ObjectVersion -> Rep ObjectVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ObjectVersion x -> ObjectVersion
$cfrom :: forall x. ObjectVersion -> Rep ObjectVersion x
Prelude.Generic)

-- |
-- Create a value of 'ObjectVersion' 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', 'objectVersion_eTag' - The entity tag is an MD5 hash of that version of the object.
--
-- 'versionId', 'objectVersion_versionId' - Version ID of an object.
--
-- 'size', 'objectVersion_size' - Size in bytes of the object.
--
-- 'isLatest', 'objectVersion_isLatest' - Specifies whether the object is (true) or is not (false) the latest
-- version of an object.
--
-- 'owner', 'objectVersion_owner' - Specifies the owner of the object.
--
-- 'key', 'objectVersion_key' - The object key.
--
-- 'storageClass', 'objectVersion_storageClass' - The class of storage used to store the object.
--
-- 'lastModified', 'objectVersion_lastModified' - Date and time the object was last modified.
newObjectVersion ::
  ObjectVersion
newObjectVersion :: ObjectVersion
newObjectVersion =
  ObjectVersion' :: Maybe ETag
-> Maybe ObjectVersionId
-> Maybe Integer
-> Maybe Bool
-> Maybe Owner
-> Maybe ObjectKey
-> Maybe ObjectVersionStorageClass
-> Maybe ISO8601
-> ObjectVersion
ObjectVersion'
    { $sel:eTag:ObjectVersion' :: Maybe ETag
eTag = Maybe ETag
forall a. Maybe a
Prelude.Nothing,
      $sel:versionId:ObjectVersion' :: Maybe ObjectVersionId
versionId = Maybe ObjectVersionId
forall a. Maybe a
Prelude.Nothing,
      $sel:size:ObjectVersion' :: Maybe Integer
size = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:isLatest:ObjectVersion' :: Maybe Bool
isLatest = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:owner:ObjectVersion' :: Maybe Owner
owner = Maybe Owner
forall a. Maybe a
Prelude.Nothing,
      $sel:key:ObjectVersion' :: Maybe ObjectKey
key = Maybe ObjectKey
forall a. Maybe a
Prelude.Nothing,
      $sel:storageClass:ObjectVersion' :: Maybe ObjectVersionStorageClass
storageClass = Maybe ObjectVersionStorageClass
forall a. Maybe a
Prelude.Nothing,
      $sel:lastModified:ObjectVersion' :: Maybe ISO8601
lastModified = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing
    }

-- | The entity tag is an MD5 hash of that version of the object.
objectVersion_eTag :: Lens.Lens' ObjectVersion (Prelude.Maybe ETag)
objectVersion_eTag :: (Maybe ETag -> f (Maybe ETag)) -> ObjectVersion -> f ObjectVersion
objectVersion_eTag = (ObjectVersion -> Maybe ETag)
-> (ObjectVersion -> Maybe ETag -> ObjectVersion)
-> Lens ObjectVersion ObjectVersion (Maybe ETag) (Maybe ETag)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectVersion' {Maybe ETag
eTag :: Maybe ETag
$sel:eTag:ObjectVersion' :: ObjectVersion -> Maybe ETag
eTag} -> Maybe ETag
eTag) (\s :: ObjectVersion
s@ObjectVersion' {} Maybe ETag
a -> ObjectVersion
s {$sel:eTag:ObjectVersion' :: Maybe ETag
eTag = Maybe ETag
a} :: ObjectVersion)

-- | Version ID of an object.
objectVersion_versionId :: Lens.Lens' ObjectVersion (Prelude.Maybe ObjectVersionId)
objectVersion_versionId :: (Maybe ObjectVersionId -> f (Maybe ObjectVersionId))
-> ObjectVersion -> f ObjectVersion
objectVersion_versionId = (ObjectVersion -> Maybe ObjectVersionId)
-> (ObjectVersion -> Maybe ObjectVersionId -> ObjectVersion)
-> Lens
     ObjectVersion
     ObjectVersion
     (Maybe ObjectVersionId)
     (Maybe ObjectVersionId)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectVersion' {Maybe ObjectVersionId
versionId :: Maybe ObjectVersionId
$sel:versionId:ObjectVersion' :: ObjectVersion -> Maybe ObjectVersionId
versionId} -> Maybe ObjectVersionId
versionId) (\s :: ObjectVersion
s@ObjectVersion' {} Maybe ObjectVersionId
a -> ObjectVersion
s {$sel:versionId:ObjectVersion' :: Maybe ObjectVersionId
versionId = Maybe ObjectVersionId
a} :: ObjectVersion)

-- | Size in bytes of the object.
objectVersion_size :: Lens.Lens' ObjectVersion (Prelude.Maybe Prelude.Integer)
objectVersion_size :: (Maybe Integer -> f (Maybe Integer))
-> ObjectVersion -> f ObjectVersion
objectVersion_size = (ObjectVersion -> Maybe Integer)
-> (ObjectVersion -> Maybe Integer -> ObjectVersion)
-> Lens ObjectVersion ObjectVersion (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectVersion' {Maybe Integer
size :: Maybe Integer
$sel:size:ObjectVersion' :: ObjectVersion -> Maybe Integer
size} -> Maybe Integer
size) (\s :: ObjectVersion
s@ObjectVersion' {} Maybe Integer
a -> ObjectVersion
s {$sel:size:ObjectVersion' :: Maybe Integer
size = Maybe Integer
a} :: ObjectVersion)

-- | Specifies whether the object is (true) or is not (false) the latest
-- version of an object.
objectVersion_isLatest :: Lens.Lens' ObjectVersion (Prelude.Maybe Prelude.Bool)
objectVersion_isLatest :: (Maybe Bool -> f (Maybe Bool)) -> ObjectVersion -> f ObjectVersion
objectVersion_isLatest = (ObjectVersion -> Maybe Bool)
-> (ObjectVersion -> Maybe Bool -> ObjectVersion)
-> Lens ObjectVersion ObjectVersion (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectVersion' {Maybe Bool
isLatest :: Maybe Bool
$sel:isLatest:ObjectVersion' :: ObjectVersion -> Maybe Bool
isLatest} -> Maybe Bool
isLatest) (\s :: ObjectVersion
s@ObjectVersion' {} Maybe Bool
a -> ObjectVersion
s {$sel:isLatest:ObjectVersion' :: Maybe Bool
isLatest = Maybe Bool
a} :: ObjectVersion)

-- | Specifies the owner of the object.
objectVersion_owner :: Lens.Lens' ObjectVersion (Prelude.Maybe Owner)
objectVersion_owner :: (Maybe Owner -> f (Maybe Owner))
-> ObjectVersion -> f ObjectVersion
objectVersion_owner = (ObjectVersion -> Maybe Owner)
-> (ObjectVersion -> Maybe Owner -> ObjectVersion)
-> Lens ObjectVersion ObjectVersion (Maybe Owner) (Maybe Owner)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectVersion' {Maybe Owner
owner :: Maybe Owner
$sel:owner:ObjectVersion' :: ObjectVersion -> Maybe Owner
owner} -> Maybe Owner
owner) (\s :: ObjectVersion
s@ObjectVersion' {} Maybe Owner
a -> ObjectVersion
s {$sel:owner:ObjectVersion' :: Maybe Owner
owner = Maybe Owner
a} :: ObjectVersion)

-- | The object key.
objectVersion_key :: Lens.Lens' ObjectVersion (Prelude.Maybe ObjectKey)
objectVersion_key :: (Maybe ObjectKey -> f (Maybe ObjectKey))
-> ObjectVersion -> f ObjectVersion
objectVersion_key = (ObjectVersion -> Maybe ObjectKey)
-> (ObjectVersion -> Maybe ObjectKey -> ObjectVersion)
-> Lens
     ObjectVersion ObjectVersion (Maybe ObjectKey) (Maybe ObjectKey)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectVersion' {Maybe ObjectKey
key :: Maybe ObjectKey
$sel:key:ObjectVersion' :: ObjectVersion -> Maybe ObjectKey
key} -> Maybe ObjectKey
key) (\s :: ObjectVersion
s@ObjectVersion' {} Maybe ObjectKey
a -> ObjectVersion
s {$sel:key:ObjectVersion' :: Maybe ObjectKey
key = Maybe ObjectKey
a} :: ObjectVersion)

-- | The class of storage used to store the object.
objectVersion_storageClass :: Lens.Lens' ObjectVersion (Prelude.Maybe ObjectVersionStorageClass)
objectVersion_storageClass :: (Maybe ObjectVersionStorageClass
 -> f (Maybe ObjectVersionStorageClass))
-> ObjectVersion -> f ObjectVersion
objectVersion_storageClass = (ObjectVersion -> Maybe ObjectVersionStorageClass)
-> (ObjectVersion
    -> Maybe ObjectVersionStorageClass -> ObjectVersion)
-> Lens
     ObjectVersion
     ObjectVersion
     (Maybe ObjectVersionStorageClass)
     (Maybe ObjectVersionStorageClass)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectVersion' {Maybe ObjectVersionStorageClass
storageClass :: Maybe ObjectVersionStorageClass
$sel:storageClass:ObjectVersion' :: ObjectVersion -> Maybe ObjectVersionStorageClass
storageClass} -> Maybe ObjectVersionStorageClass
storageClass) (\s :: ObjectVersion
s@ObjectVersion' {} Maybe ObjectVersionStorageClass
a -> ObjectVersion
s {$sel:storageClass:ObjectVersion' :: Maybe ObjectVersionStorageClass
storageClass = Maybe ObjectVersionStorageClass
a} :: ObjectVersion)

-- | Date and time the object was last modified.
objectVersion_lastModified :: Lens.Lens' ObjectVersion (Prelude.Maybe Prelude.UTCTime)
objectVersion_lastModified :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ObjectVersion -> f ObjectVersion
objectVersion_lastModified = (ObjectVersion -> Maybe ISO8601)
-> (ObjectVersion -> Maybe ISO8601 -> ObjectVersion)
-> Lens ObjectVersion ObjectVersion (Maybe ISO8601) (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectVersion' {Maybe ISO8601
lastModified :: Maybe ISO8601
$sel:lastModified:ObjectVersion' :: ObjectVersion -> Maybe ISO8601
lastModified} -> Maybe ISO8601
lastModified) (\s :: ObjectVersion
s@ObjectVersion' {} Maybe ISO8601
a -> ObjectVersion
s {$sel:lastModified:ObjectVersion' :: Maybe ISO8601
lastModified = Maybe ISO8601
a} :: ObjectVersion) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> ObjectVersion -> f ObjectVersion)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ObjectVersion
-> f ObjectVersion
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 ObjectVersion where
  parseXML :: [Node] -> Either String ObjectVersion
parseXML [Node]
x =
    Maybe ETag
-> Maybe ObjectVersionId
-> Maybe Integer
-> Maybe Bool
-> Maybe Owner
-> Maybe ObjectKey
-> Maybe ObjectVersionStorageClass
-> Maybe ISO8601
-> ObjectVersion
ObjectVersion'
      (Maybe ETag
 -> Maybe ObjectVersionId
 -> Maybe Integer
 -> Maybe Bool
 -> Maybe Owner
 -> Maybe ObjectKey
 -> Maybe ObjectVersionStorageClass
 -> Maybe ISO8601
 -> ObjectVersion)
-> Either String (Maybe ETag)
-> Either
     String
     (Maybe ObjectVersionId
      -> Maybe Integer
      -> Maybe Bool
      -> Maybe Owner
      -> Maybe ObjectKey
      -> Maybe ObjectVersionStorageClass
      -> Maybe ISO8601
      -> ObjectVersion)
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 ObjectVersionId
   -> Maybe Integer
   -> Maybe Bool
   -> Maybe Owner
   -> Maybe ObjectKey
   -> Maybe ObjectVersionStorageClass
   -> Maybe ISO8601
   -> ObjectVersion)
-> Either String (Maybe ObjectVersionId)
-> Either
     String
     (Maybe Integer
      -> Maybe Bool
      -> Maybe Owner
      -> Maybe ObjectKey
      -> Maybe ObjectVersionStorageClass
      -> Maybe ISO8601
      -> ObjectVersion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ObjectVersionId)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"VersionId")
      Either
  String
  (Maybe Integer
   -> Maybe Bool
   -> Maybe Owner
   -> Maybe ObjectKey
   -> Maybe ObjectVersionStorageClass
   -> Maybe ISO8601
   -> ObjectVersion)
-> Either String (Maybe Integer)
-> Either
     String
     (Maybe Bool
      -> Maybe Owner
      -> Maybe ObjectKey
      -> Maybe ObjectVersionStorageClass
      -> Maybe ISO8601
      -> ObjectVersion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Integer)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Size")
      Either
  String
  (Maybe Bool
   -> Maybe Owner
   -> Maybe ObjectKey
   -> Maybe ObjectVersionStorageClass
   -> Maybe ISO8601
   -> ObjectVersion)
-> Either String (Maybe Bool)
-> Either
     String
     (Maybe Owner
      -> Maybe ObjectKey
      -> Maybe ObjectVersionStorageClass
      -> Maybe ISO8601
      -> ObjectVersion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"IsLatest")
      Either
  String
  (Maybe Owner
   -> Maybe ObjectKey
   -> Maybe ObjectVersionStorageClass
   -> Maybe ISO8601
   -> ObjectVersion)
-> Either String (Maybe Owner)
-> Either
     String
     (Maybe ObjectKey
      -> Maybe ObjectVersionStorageClass
      -> Maybe ISO8601
      -> ObjectVersion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Owner)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Owner")
      Either
  String
  (Maybe ObjectKey
   -> Maybe ObjectVersionStorageClass
   -> Maybe ISO8601
   -> ObjectVersion)
-> Either String (Maybe ObjectKey)
-> Either
     String
     (Maybe ObjectVersionStorageClass -> Maybe ISO8601 -> ObjectVersion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ObjectKey)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Key")
      Either
  String
  (Maybe ObjectVersionStorageClass -> Maybe ISO8601 -> ObjectVersion)
-> Either String (Maybe ObjectVersionStorageClass)
-> Either String (Maybe ISO8601 -> ObjectVersion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ObjectVersionStorageClass)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"StorageClass")
      Either String (Maybe ISO8601 -> ObjectVersion)
-> Either String (Maybe ISO8601) -> Either String ObjectVersion
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 ObjectVersion

instance Prelude.NFData ObjectVersion