{-# 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.AccessAnalyzer.Types.ArchiveRuleSummary
-- 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.AccessAnalyzer.Types.ArchiveRuleSummary where

import Amazonka.AccessAnalyzer.Types.Criterion
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about an archive rule.
--
-- /See:/ 'newArchiveRuleSummary' smart constructor.
data ArchiveRuleSummary = ArchiveRuleSummary'
  { -- | The time at which the archive rule was created.
    ArchiveRuleSummary -> POSIX
createdAt :: Core.POSIX,
    -- | A filter used to define the archive rule.
    ArchiveRuleSummary -> HashMap Text Criterion
filter' :: Prelude.HashMap Prelude.Text Criterion,
    -- | The name of the archive rule.
    ArchiveRuleSummary -> Text
ruleName :: Prelude.Text,
    -- | The time at which the archive rule was last updated.
    ArchiveRuleSummary -> POSIX
updatedAt :: Core.POSIX
  }
  deriving (ArchiveRuleSummary -> ArchiveRuleSummary -> Bool
(ArchiveRuleSummary -> ArchiveRuleSummary -> Bool)
-> (ArchiveRuleSummary -> ArchiveRuleSummary -> Bool)
-> Eq ArchiveRuleSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ArchiveRuleSummary -> ArchiveRuleSummary -> Bool
$c/= :: ArchiveRuleSummary -> ArchiveRuleSummary -> Bool
== :: ArchiveRuleSummary -> ArchiveRuleSummary -> Bool
$c== :: ArchiveRuleSummary -> ArchiveRuleSummary -> Bool
Prelude.Eq, ReadPrec [ArchiveRuleSummary]
ReadPrec ArchiveRuleSummary
Int -> ReadS ArchiveRuleSummary
ReadS [ArchiveRuleSummary]
(Int -> ReadS ArchiveRuleSummary)
-> ReadS [ArchiveRuleSummary]
-> ReadPrec ArchiveRuleSummary
-> ReadPrec [ArchiveRuleSummary]
-> Read ArchiveRuleSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ArchiveRuleSummary]
$creadListPrec :: ReadPrec [ArchiveRuleSummary]
readPrec :: ReadPrec ArchiveRuleSummary
$creadPrec :: ReadPrec ArchiveRuleSummary
readList :: ReadS [ArchiveRuleSummary]
$creadList :: ReadS [ArchiveRuleSummary]
readsPrec :: Int -> ReadS ArchiveRuleSummary
$creadsPrec :: Int -> ReadS ArchiveRuleSummary
Prelude.Read, Int -> ArchiveRuleSummary -> ShowS
[ArchiveRuleSummary] -> ShowS
ArchiveRuleSummary -> String
(Int -> ArchiveRuleSummary -> ShowS)
-> (ArchiveRuleSummary -> String)
-> ([ArchiveRuleSummary] -> ShowS)
-> Show ArchiveRuleSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ArchiveRuleSummary] -> ShowS
$cshowList :: [ArchiveRuleSummary] -> ShowS
show :: ArchiveRuleSummary -> String
$cshow :: ArchiveRuleSummary -> String
showsPrec :: Int -> ArchiveRuleSummary -> ShowS
$cshowsPrec :: Int -> ArchiveRuleSummary -> ShowS
Prelude.Show, (forall x. ArchiveRuleSummary -> Rep ArchiveRuleSummary x)
-> (forall x. Rep ArchiveRuleSummary x -> ArchiveRuleSummary)
-> Generic ArchiveRuleSummary
forall x. Rep ArchiveRuleSummary x -> ArchiveRuleSummary
forall x. ArchiveRuleSummary -> Rep ArchiveRuleSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ArchiveRuleSummary x -> ArchiveRuleSummary
$cfrom :: forall x. ArchiveRuleSummary -> Rep ArchiveRuleSummary x
Prelude.Generic)

-- |
-- Create a value of 'ArchiveRuleSummary' 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:
--
-- 'createdAt', 'archiveRuleSummary_createdAt' - The time at which the archive rule was created.
--
-- 'filter'', 'archiveRuleSummary_filter' - A filter used to define the archive rule.
--
-- 'ruleName', 'archiveRuleSummary_ruleName' - The name of the archive rule.
--
-- 'updatedAt', 'archiveRuleSummary_updatedAt' - The time at which the archive rule was last updated.
newArchiveRuleSummary ::
  -- | 'createdAt'
  Prelude.UTCTime ->
  -- | 'ruleName'
  Prelude.Text ->
  -- | 'updatedAt'
  Prelude.UTCTime ->
  ArchiveRuleSummary
newArchiveRuleSummary :: UTCTime -> Text -> UTCTime -> ArchiveRuleSummary
newArchiveRuleSummary
  UTCTime
pCreatedAt_
  Text
pRuleName_
  UTCTime
pUpdatedAt_ =
    ArchiveRuleSummary' :: POSIX
-> HashMap Text Criterion -> Text -> POSIX -> ArchiveRuleSummary
ArchiveRuleSummary'
      { $sel:createdAt:ArchiveRuleSummary' :: POSIX
createdAt =
          Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreatedAt_,
        $sel:filter':ArchiveRuleSummary' :: HashMap Text Criterion
filter' = HashMap Text Criterion
forall a. Monoid a => a
Prelude.mempty,
        $sel:ruleName:ArchiveRuleSummary' :: Text
ruleName = Text
pRuleName_,
        $sel:updatedAt:ArchiveRuleSummary' :: POSIX
updatedAt = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pUpdatedAt_
      }

-- | The time at which the archive rule was created.
archiveRuleSummary_createdAt :: Lens.Lens' ArchiveRuleSummary Prelude.UTCTime
archiveRuleSummary_createdAt :: (UTCTime -> f UTCTime)
-> ArchiveRuleSummary -> f ArchiveRuleSummary
archiveRuleSummary_createdAt = (ArchiveRuleSummary -> POSIX)
-> (ArchiveRuleSummary -> POSIX -> ArchiveRuleSummary)
-> Lens ArchiveRuleSummary ArchiveRuleSummary POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArchiveRuleSummary' {POSIX
createdAt :: POSIX
$sel:createdAt:ArchiveRuleSummary' :: ArchiveRuleSummary -> POSIX
createdAt} -> POSIX
createdAt) (\s :: ArchiveRuleSummary
s@ArchiveRuleSummary' {} POSIX
a -> ArchiveRuleSummary
s {$sel:createdAt:ArchiveRuleSummary' :: POSIX
createdAt = POSIX
a} :: ArchiveRuleSummary) ((POSIX -> f POSIX) -> ArchiveRuleSummary -> f ArchiveRuleSummary)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ArchiveRuleSummary
-> f ArchiveRuleSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | A filter used to define the archive rule.
archiveRuleSummary_filter :: Lens.Lens' ArchiveRuleSummary (Prelude.HashMap Prelude.Text Criterion)
archiveRuleSummary_filter :: (HashMap Text Criterion -> f (HashMap Text Criterion))
-> ArchiveRuleSummary -> f ArchiveRuleSummary
archiveRuleSummary_filter = (ArchiveRuleSummary -> HashMap Text Criterion)
-> (ArchiveRuleSummary
    -> HashMap Text Criterion -> ArchiveRuleSummary)
-> Lens
     ArchiveRuleSummary
     ArchiveRuleSummary
     (HashMap Text Criterion)
     (HashMap Text Criterion)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArchiveRuleSummary' {HashMap Text Criterion
filter' :: HashMap Text Criterion
$sel:filter':ArchiveRuleSummary' :: ArchiveRuleSummary -> HashMap Text Criterion
filter'} -> HashMap Text Criterion
filter') (\s :: ArchiveRuleSummary
s@ArchiveRuleSummary' {} HashMap Text Criterion
a -> ArchiveRuleSummary
s {$sel:filter':ArchiveRuleSummary' :: HashMap Text Criterion
filter' = HashMap Text Criterion
a} :: ArchiveRuleSummary) ((HashMap Text Criterion -> f (HashMap Text Criterion))
 -> ArchiveRuleSummary -> f ArchiveRuleSummary)
-> ((HashMap Text Criterion -> f (HashMap Text Criterion))
    -> HashMap Text Criterion -> f (HashMap Text Criterion))
-> (HashMap Text Criterion -> f (HashMap Text Criterion))
-> ArchiveRuleSummary
-> f ArchiveRuleSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Criterion -> f (HashMap Text Criterion))
-> HashMap Text Criterion -> f (HashMap Text Criterion)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the archive rule.
archiveRuleSummary_ruleName :: Lens.Lens' ArchiveRuleSummary Prelude.Text
archiveRuleSummary_ruleName :: (Text -> f Text) -> ArchiveRuleSummary -> f ArchiveRuleSummary
archiveRuleSummary_ruleName = (ArchiveRuleSummary -> Text)
-> (ArchiveRuleSummary -> Text -> ArchiveRuleSummary)
-> Lens ArchiveRuleSummary ArchiveRuleSummary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArchiveRuleSummary' {Text
ruleName :: Text
$sel:ruleName:ArchiveRuleSummary' :: ArchiveRuleSummary -> Text
ruleName} -> Text
ruleName) (\s :: ArchiveRuleSummary
s@ArchiveRuleSummary' {} Text
a -> ArchiveRuleSummary
s {$sel:ruleName:ArchiveRuleSummary' :: Text
ruleName = Text
a} :: ArchiveRuleSummary)

-- | The time at which the archive rule was last updated.
archiveRuleSummary_updatedAt :: Lens.Lens' ArchiveRuleSummary Prelude.UTCTime
archiveRuleSummary_updatedAt :: (UTCTime -> f UTCTime)
-> ArchiveRuleSummary -> f ArchiveRuleSummary
archiveRuleSummary_updatedAt = (ArchiveRuleSummary -> POSIX)
-> (ArchiveRuleSummary -> POSIX -> ArchiveRuleSummary)
-> Lens ArchiveRuleSummary ArchiveRuleSummary POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArchiveRuleSummary' {POSIX
updatedAt :: POSIX
$sel:updatedAt:ArchiveRuleSummary' :: ArchiveRuleSummary -> POSIX
updatedAt} -> POSIX
updatedAt) (\s :: ArchiveRuleSummary
s@ArchiveRuleSummary' {} POSIX
a -> ArchiveRuleSummary
s {$sel:updatedAt:ArchiveRuleSummary' :: POSIX
updatedAt = POSIX
a} :: ArchiveRuleSummary) ((POSIX -> f POSIX) -> ArchiveRuleSummary -> f ArchiveRuleSummary)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ArchiveRuleSummary
-> f ArchiveRuleSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON ArchiveRuleSummary where
  parseJSON :: Value -> Parser ArchiveRuleSummary
parseJSON =
    String
-> (Object -> Parser ArchiveRuleSummary)
-> Value
-> Parser ArchiveRuleSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ArchiveRuleSummary"
      ( \Object
x ->
          POSIX
-> HashMap Text Criterion -> Text -> POSIX -> ArchiveRuleSummary
ArchiveRuleSummary'
            (POSIX
 -> HashMap Text Criterion -> Text -> POSIX -> ArchiveRuleSummary)
-> Parser POSIX
-> Parser
     (HashMap Text Criterion -> Text -> POSIX -> ArchiveRuleSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"createdAt")
            Parser
  (HashMap Text Criterion -> Text -> POSIX -> ArchiveRuleSummary)
-> Parser (HashMap Text Criterion)
-> Parser (Text -> POSIX -> ArchiveRuleSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (HashMap Text Criterion))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"filter" Parser (Maybe (HashMap Text Criterion))
-> HashMap Text Criterion -> Parser (HashMap Text Criterion)
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= HashMap Text Criterion
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> POSIX -> ArchiveRuleSummary)
-> Parser Text -> Parser (POSIX -> ArchiveRuleSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ruleName")
            Parser (POSIX -> ArchiveRuleSummary)
-> Parser POSIX -> Parser ArchiveRuleSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"updatedAt")
      )

instance Prelude.Hashable ArchiveRuleSummary

instance Prelude.NFData ArchiveRuleSummary