{-# 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.CloudWatchEvents.Types.Archive
-- 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.CloudWatchEvents.Types.Archive where

import Amazonka.CloudWatchEvents.Types.ArchiveState
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An @Archive@ object that contains details about an archive.
--
-- /See:/ 'newArchive' smart constructor.
data Archive = Archive'
  { -- | The time stamp for the time that the archive was created.
    Archive -> Maybe POSIX
creationTime :: Prelude.Maybe Core.POSIX,
    -- | The size of the archive, in bytes.
    Archive -> Maybe Integer
sizeBytes :: Prelude.Maybe Prelude.Integer,
    -- | The ARN of the event bus associated with the archive. Only events from
    -- this event bus are sent to the archive.
    Archive -> Maybe Text
eventSourceArn :: Prelude.Maybe Prelude.Text,
    -- | The current state of the archive.
    Archive -> Maybe ArchiveState
state :: Prelude.Maybe ArchiveState,
    -- | The number of events in the archive.
    Archive -> Maybe Integer
eventCount :: Prelude.Maybe Prelude.Integer,
    -- | The name of the archive.
    Archive -> Maybe Text
archiveName :: Prelude.Maybe Prelude.Text,
    -- | The number of days to retain events in the archive before they are
    -- deleted.
    Archive -> Maybe Natural
retentionDays :: Prelude.Maybe Prelude.Natural,
    -- | A description for the reason that the archive is in the current state.
    Archive -> Maybe Text
stateReason :: Prelude.Maybe Prelude.Text
  }
  deriving (Archive -> Archive -> Bool
(Archive -> Archive -> Bool)
-> (Archive -> Archive -> Bool) -> Eq Archive
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Archive -> Archive -> Bool
$c/= :: Archive -> Archive -> Bool
== :: Archive -> Archive -> Bool
$c== :: Archive -> Archive -> Bool
Prelude.Eq, ReadPrec [Archive]
ReadPrec Archive
Int -> ReadS Archive
ReadS [Archive]
(Int -> ReadS Archive)
-> ReadS [Archive]
-> ReadPrec Archive
-> ReadPrec [Archive]
-> Read Archive
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Archive]
$creadListPrec :: ReadPrec [Archive]
readPrec :: ReadPrec Archive
$creadPrec :: ReadPrec Archive
readList :: ReadS [Archive]
$creadList :: ReadS [Archive]
readsPrec :: Int -> ReadS Archive
$creadsPrec :: Int -> ReadS Archive
Prelude.Read, Int -> Archive -> ShowS
[Archive] -> ShowS
Archive -> String
(Int -> Archive -> ShowS)
-> (Archive -> String) -> ([Archive] -> ShowS) -> Show Archive
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Archive] -> ShowS
$cshowList :: [Archive] -> ShowS
show :: Archive -> String
$cshow :: Archive -> String
showsPrec :: Int -> Archive -> ShowS
$cshowsPrec :: Int -> Archive -> ShowS
Prelude.Show, (forall x. Archive -> Rep Archive x)
-> (forall x. Rep Archive x -> Archive) -> Generic Archive
forall x. Rep Archive x -> Archive
forall x. Archive -> Rep Archive x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Archive x -> Archive
$cfrom :: forall x. Archive -> Rep Archive x
Prelude.Generic)

-- |
-- Create a value of 'Archive' 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:
--
-- 'creationTime', 'archive_creationTime' - The time stamp for the time that the archive was created.
--
-- 'sizeBytes', 'archive_sizeBytes' - The size of the archive, in bytes.
--
-- 'eventSourceArn', 'archive_eventSourceArn' - The ARN of the event bus associated with the archive. Only events from
-- this event bus are sent to the archive.
--
-- 'state', 'archive_state' - The current state of the archive.
--
-- 'eventCount', 'archive_eventCount' - The number of events in the archive.
--
-- 'archiveName', 'archive_archiveName' - The name of the archive.
--
-- 'retentionDays', 'archive_retentionDays' - The number of days to retain events in the archive before they are
-- deleted.
--
-- 'stateReason', 'archive_stateReason' - A description for the reason that the archive is in the current state.
newArchive ::
  Archive
newArchive :: Archive
newArchive =
  Archive' :: Maybe POSIX
-> Maybe Integer
-> Maybe Text
-> Maybe ArchiveState
-> Maybe Integer
-> Maybe Text
-> Maybe Natural
-> Maybe Text
-> Archive
Archive'
    { $sel:creationTime:Archive' :: Maybe POSIX
creationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:sizeBytes:Archive' :: Maybe Integer
sizeBytes = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:eventSourceArn:Archive' :: Maybe Text
eventSourceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:state:Archive' :: Maybe ArchiveState
state = Maybe ArchiveState
forall a. Maybe a
Prelude.Nothing,
      $sel:eventCount:Archive' :: Maybe Integer
eventCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:archiveName:Archive' :: Maybe Text
archiveName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:retentionDays:Archive' :: Maybe Natural
retentionDays = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:stateReason:Archive' :: Maybe Text
stateReason = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The time stamp for the time that the archive was created.
archive_creationTime :: Lens.Lens' Archive (Prelude.Maybe Prelude.UTCTime)
archive_creationTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Archive -> f Archive
archive_creationTime = (Archive -> Maybe POSIX)
-> (Archive -> Maybe POSIX -> Archive)
-> Lens Archive Archive (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Archive' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:Archive' :: Archive -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: Archive
s@Archive' {} Maybe POSIX
a -> Archive
s {$sel:creationTime:Archive' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: Archive) ((Maybe POSIX -> f (Maybe POSIX)) -> Archive -> f Archive)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Archive
-> f Archive
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The size of the archive, in bytes.
archive_sizeBytes :: Lens.Lens' Archive (Prelude.Maybe Prelude.Integer)
archive_sizeBytes :: (Maybe Integer -> f (Maybe Integer)) -> Archive -> f Archive
archive_sizeBytes = (Archive -> Maybe Integer)
-> (Archive -> Maybe Integer -> Archive)
-> Lens Archive Archive (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Archive' {Maybe Integer
sizeBytes :: Maybe Integer
$sel:sizeBytes:Archive' :: Archive -> Maybe Integer
sizeBytes} -> Maybe Integer
sizeBytes) (\s :: Archive
s@Archive' {} Maybe Integer
a -> Archive
s {$sel:sizeBytes:Archive' :: Maybe Integer
sizeBytes = Maybe Integer
a} :: Archive)

-- | The ARN of the event bus associated with the archive. Only events from
-- this event bus are sent to the archive.
archive_eventSourceArn :: Lens.Lens' Archive (Prelude.Maybe Prelude.Text)
archive_eventSourceArn :: (Maybe Text -> f (Maybe Text)) -> Archive -> f Archive
archive_eventSourceArn = (Archive -> Maybe Text)
-> (Archive -> Maybe Text -> Archive)
-> Lens Archive Archive (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Archive' {Maybe Text
eventSourceArn :: Maybe Text
$sel:eventSourceArn:Archive' :: Archive -> Maybe Text
eventSourceArn} -> Maybe Text
eventSourceArn) (\s :: Archive
s@Archive' {} Maybe Text
a -> Archive
s {$sel:eventSourceArn:Archive' :: Maybe Text
eventSourceArn = Maybe Text
a} :: Archive)

-- | The current state of the archive.
archive_state :: Lens.Lens' Archive (Prelude.Maybe ArchiveState)
archive_state :: (Maybe ArchiveState -> f (Maybe ArchiveState))
-> Archive -> f Archive
archive_state = (Archive -> Maybe ArchiveState)
-> (Archive -> Maybe ArchiveState -> Archive)
-> Lens Archive Archive (Maybe ArchiveState) (Maybe ArchiveState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Archive' {Maybe ArchiveState
state :: Maybe ArchiveState
$sel:state:Archive' :: Archive -> Maybe ArchiveState
state} -> Maybe ArchiveState
state) (\s :: Archive
s@Archive' {} Maybe ArchiveState
a -> Archive
s {$sel:state:Archive' :: Maybe ArchiveState
state = Maybe ArchiveState
a} :: Archive)

-- | The number of events in the archive.
archive_eventCount :: Lens.Lens' Archive (Prelude.Maybe Prelude.Integer)
archive_eventCount :: (Maybe Integer -> f (Maybe Integer)) -> Archive -> f Archive
archive_eventCount = (Archive -> Maybe Integer)
-> (Archive -> Maybe Integer -> Archive)
-> Lens Archive Archive (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Archive' {Maybe Integer
eventCount :: Maybe Integer
$sel:eventCount:Archive' :: Archive -> Maybe Integer
eventCount} -> Maybe Integer
eventCount) (\s :: Archive
s@Archive' {} Maybe Integer
a -> Archive
s {$sel:eventCount:Archive' :: Maybe Integer
eventCount = Maybe Integer
a} :: Archive)

-- | The name of the archive.
archive_archiveName :: Lens.Lens' Archive (Prelude.Maybe Prelude.Text)
archive_archiveName :: (Maybe Text -> f (Maybe Text)) -> Archive -> f Archive
archive_archiveName = (Archive -> Maybe Text)
-> (Archive -> Maybe Text -> Archive)
-> Lens Archive Archive (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Archive' {Maybe Text
archiveName :: Maybe Text
$sel:archiveName:Archive' :: Archive -> Maybe Text
archiveName} -> Maybe Text
archiveName) (\s :: Archive
s@Archive' {} Maybe Text
a -> Archive
s {$sel:archiveName:Archive' :: Maybe Text
archiveName = Maybe Text
a} :: Archive)

-- | The number of days to retain events in the archive before they are
-- deleted.
archive_retentionDays :: Lens.Lens' Archive (Prelude.Maybe Prelude.Natural)
archive_retentionDays :: (Maybe Natural -> f (Maybe Natural)) -> Archive -> f Archive
archive_retentionDays = (Archive -> Maybe Natural)
-> (Archive -> Maybe Natural -> Archive)
-> Lens Archive Archive (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Archive' {Maybe Natural
retentionDays :: Maybe Natural
$sel:retentionDays:Archive' :: Archive -> Maybe Natural
retentionDays} -> Maybe Natural
retentionDays) (\s :: Archive
s@Archive' {} Maybe Natural
a -> Archive
s {$sel:retentionDays:Archive' :: Maybe Natural
retentionDays = Maybe Natural
a} :: Archive)

-- | A description for the reason that the archive is in the current state.
archive_stateReason :: Lens.Lens' Archive (Prelude.Maybe Prelude.Text)
archive_stateReason :: (Maybe Text -> f (Maybe Text)) -> Archive -> f Archive
archive_stateReason = (Archive -> Maybe Text)
-> (Archive -> Maybe Text -> Archive)
-> Lens Archive Archive (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Archive' {Maybe Text
stateReason :: Maybe Text
$sel:stateReason:Archive' :: Archive -> Maybe Text
stateReason} -> Maybe Text
stateReason) (\s :: Archive
s@Archive' {} Maybe Text
a -> Archive
s {$sel:stateReason:Archive' :: Maybe Text
stateReason = Maybe Text
a} :: Archive)

instance Core.FromJSON Archive where
  parseJSON :: Value -> Parser Archive
parseJSON =
    String -> (Object -> Parser Archive) -> Value -> Parser Archive
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Archive"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Integer
-> Maybe Text
-> Maybe ArchiveState
-> Maybe Integer
-> Maybe Text
-> Maybe Natural
-> Maybe Text
-> Archive
Archive'
            (Maybe POSIX
 -> Maybe Integer
 -> Maybe Text
 -> Maybe ArchiveState
 -> Maybe Integer
 -> Maybe Text
 -> Maybe Natural
 -> Maybe Text
 -> Archive)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Integer
      -> Maybe Text
      -> Maybe ArchiveState
      -> Maybe Integer
      -> Maybe Text
      -> Maybe Natural
      -> Maybe Text
      -> Archive)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreationTime")
            Parser
  (Maybe Integer
   -> Maybe Text
   -> Maybe ArchiveState
   -> Maybe Integer
   -> Maybe Text
   -> Maybe Natural
   -> Maybe Text
   -> Archive)
-> Parser (Maybe Integer)
-> Parser
     (Maybe Text
      -> Maybe ArchiveState
      -> Maybe Integer
      -> Maybe Text
      -> Maybe Natural
      -> Maybe Text
      -> Archive)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SizeBytes")
            Parser
  (Maybe Text
   -> Maybe ArchiveState
   -> Maybe Integer
   -> Maybe Text
   -> Maybe Natural
   -> Maybe Text
   -> Archive)
-> Parser (Maybe Text)
-> Parser
     (Maybe ArchiveState
      -> Maybe Integer
      -> Maybe Text
      -> Maybe Natural
      -> Maybe Text
      -> Archive)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EventSourceArn")
            Parser
  (Maybe ArchiveState
   -> Maybe Integer
   -> Maybe Text
   -> Maybe Natural
   -> Maybe Text
   -> Archive)
-> Parser (Maybe ArchiveState)
-> Parser
     (Maybe Integer
      -> Maybe Text -> Maybe Natural -> Maybe Text -> Archive)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ArchiveState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser
  (Maybe Integer
   -> Maybe Text -> Maybe Natural -> Maybe Text -> Archive)
-> Parser (Maybe Integer)
-> Parser (Maybe Text -> Maybe Natural -> Maybe Text -> Archive)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EventCount")
            Parser (Maybe Text -> Maybe Natural -> Maybe Text -> Archive)
-> Parser (Maybe Text)
-> Parser (Maybe Natural -> Maybe Text -> Archive)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ArchiveName")
            Parser (Maybe Natural -> Maybe Text -> Archive)
-> Parser (Maybe Natural) -> Parser (Maybe Text -> Archive)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RetentionDays")
            Parser (Maybe Text -> Archive)
-> Parser (Maybe Text) -> Parser Archive
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StateReason")
      )

instance Prelude.Hashable Archive

instance Prelude.NFData Archive