{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

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

-- | The name of the archive.
archive_archiveName :: Lens.Lens' Archive (Prelude.Maybe Prelude.Text)
archive_archiveName :: Lens' Archive (Maybe Text)
archive_archiveName = 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 time stamp for the time that the archive was created.
archive_creationTime :: Lens.Lens' Archive (Prelude.Maybe Prelude.UTCTime)
archive_creationTime :: Lens' Archive (Maybe UTCTime)
archive_creationTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The number of events in the archive.
archive_eventCount :: Lens.Lens' Archive (Prelude.Maybe Prelude.Integer)
archive_eventCount :: Lens' Archive (Maybe Integer)
archive_eventCount = 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 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 :: Lens' Archive (Maybe Text)
archive_eventSourceArn = 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 number of days to retain events in the archive before they are
-- deleted.
archive_retentionDays :: Lens.Lens' Archive (Prelude.Maybe Prelude.Natural)
archive_retentionDays :: Lens' Archive (Maybe Natural)
archive_retentionDays = 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)

-- | The size of the archive, in bytes.
archive_sizeBytes :: Lens.Lens' Archive (Prelude.Maybe Prelude.Integer)
archive_sizeBytes :: Lens' Archive (Maybe Integer)
archive_sizeBytes = 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 current state of the archive.
archive_state :: Lens.Lens' Archive (Prelude.Maybe ArchiveState)
archive_state :: Lens' Archive (Maybe ArchiveState)
archive_state = 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)

-- | A description for the reason that the archive is in the current state.
archive_stateReason :: Lens.Lens' Archive (Prelude.Maybe Prelude.Text)
archive_stateReason :: Lens' Archive (Maybe Text)
archive_stateReason = 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 Data.FromJSON Archive where
  parseJSON :: Value -> Parser Archive
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Archive"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX
-> Maybe Integer
-> Maybe Text
-> Maybe Natural
-> Maybe Integer
-> Maybe ArchiveState
-> Maybe Text
-> Archive
Archive'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ArchiveName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CreationTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"EventCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"EventSourceArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RetentionDays")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SizeBytes")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"State")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StateReason")
      )

instance Prelude.Hashable Archive where
  hashWithSalt :: Int -> Archive -> Int
hashWithSalt Int
_salt Archive' {Maybe Integer
Maybe Natural
Maybe Text
Maybe POSIX
Maybe ArchiveState
stateReason :: Maybe Text
state :: Maybe ArchiveState
sizeBytes :: Maybe Integer
retentionDays :: Maybe Natural
eventSourceArn :: Maybe Text
eventCount :: Maybe Integer
creationTime :: Maybe POSIX
archiveName :: Maybe Text
$sel:stateReason:Archive' :: Archive -> Maybe Text
$sel:state:Archive' :: Archive -> Maybe ArchiveState
$sel:sizeBytes:Archive' :: Archive -> Maybe Integer
$sel:retentionDays:Archive' :: Archive -> Maybe Natural
$sel:eventSourceArn:Archive' :: Archive -> Maybe Text
$sel:eventCount:Archive' :: Archive -> Maybe Integer
$sel:creationTime:Archive' :: Archive -> Maybe POSIX
$sel:archiveName:Archive' :: Archive -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
archiveName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
eventCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
eventSourceArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
retentionDays
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
sizeBytes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ArchiveState
state
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
stateReason

instance Prelude.NFData Archive where
  rnf :: Archive -> ()
rnf Archive' {Maybe Integer
Maybe Natural
Maybe Text
Maybe POSIX
Maybe ArchiveState
stateReason :: Maybe Text
state :: Maybe ArchiveState
sizeBytes :: Maybe Integer
retentionDays :: Maybe Natural
eventSourceArn :: Maybe Text
eventCount :: Maybe Integer
creationTime :: Maybe POSIX
archiveName :: Maybe Text
$sel:stateReason:Archive' :: Archive -> Maybe Text
$sel:state:Archive' :: Archive -> Maybe ArchiveState
$sel:sizeBytes:Archive' :: Archive -> Maybe Integer
$sel:retentionDays:Archive' :: Archive -> Maybe Natural
$sel:eventSourceArn:Archive' :: Archive -> Maybe Text
$sel:eventCount:Archive' :: Archive -> Maybe Integer
$sel:creationTime:Archive' :: Archive -> Maybe POSIX
$sel:archiveName:Archive' :: Archive -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
archiveName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
eventCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
eventSourceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
retentionDays
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
sizeBytes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ArchiveState
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
stateReason