{-# 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.NetworkFirewall.Types.PerObjectStatus
-- 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.NetworkFirewall.Types.PerObjectStatus where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.NetworkFirewall.Types.PerObjectSyncStatus
import qualified Amazonka.Prelude as Prelude

-- | Provides configuration status for a single policy or rule group that is
-- used for a firewall endpoint. Network Firewall provides each endpoint
-- with the rules that are configured in the firewall policy. Each time you
-- add a subnet or modify the associated firewall policy, Network Firewall
-- synchronizes the rules in the endpoint, so it can properly filter
-- network traffic. This is part of a SyncState for a firewall.
--
-- /See:/ 'newPerObjectStatus' smart constructor.
data PerObjectStatus = PerObjectStatus'
  { -- | The current version of the object that is either in sync or pending
    -- synchronization.
    PerObjectStatus -> Maybe Text
updateToken :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether this object is in sync with the version indicated in
    -- the update token.
    PerObjectStatus -> Maybe PerObjectSyncStatus
syncStatus :: Prelude.Maybe PerObjectSyncStatus
  }
  deriving (PerObjectStatus -> PerObjectStatus -> Bool
(PerObjectStatus -> PerObjectStatus -> Bool)
-> (PerObjectStatus -> PerObjectStatus -> Bool)
-> Eq PerObjectStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PerObjectStatus -> PerObjectStatus -> Bool
$c/= :: PerObjectStatus -> PerObjectStatus -> Bool
== :: PerObjectStatus -> PerObjectStatus -> Bool
$c== :: PerObjectStatus -> PerObjectStatus -> Bool
Prelude.Eq, ReadPrec [PerObjectStatus]
ReadPrec PerObjectStatus
Int -> ReadS PerObjectStatus
ReadS [PerObjectStatus]
(Int -> ReadS PerObjectStatus)
-> ReadS [PerObjectStatus]
-> ReadPrec PerObjectStatus
-> ReadPrec [PerObjectStatus]
-> Read PerObjectStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PerObjectStatus]
$creadListPrec :: ReadPrec [PerObjectStatus]
readPrec :: ReadPrec PerObjectStatus
$creadPrec :: ReadPrec PerObjectStatus
readList :: ReadS [PerObjectStatus]
$creadList :: ReadS [PerObjectStatus]
readsPrec :: Int -> ReadS PerObjectStatus
$creadsPrec :: Int -> ReadS PerObjectStatus
Prelude.Read, Int -> PerObjectStatus -> ShowS
[PerObjectStatus] -> ShowS
PerObjectStatus -> String
(Int -> PerObjectStatus -> ShowS)
-> (PerObjectStatus -> String)
-> ([PerObjectStatus] -> ShowS)
-> Show PerObjectStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PerObjectStatus] -> ShowS
$cshowList :: [PerObjectStatus] -> ShowS
show :: PerObjectStatus -> String
$cshow :: PerObjectStatus -> String
showsPrec :: Int -> PerObjectStatus -> ShowS
$cshowsPrec :: Int -> PerObjectStatus -> ShowS
Prelude.Show, (forall x. PerObjectStatus -> Rep PerObjectStatus x)
-> (forall x. Rep PerObjectStatus x -> PerObjectStatus)
-> Generic PerObjectStatus
forall x. Rep PerObjectStatus x -> PerObjectStatus
forall x. PerObjectStatus -> Rep PerObjectStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PerObjectStatus x -> PerObjectStatus
$cfrom :: forall x. PerObjectStatus -> Rep PerObjectStatus x
Prelude.Generic)

-- |
-- Create a value of 'PerObjectStatus' 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:
--
-- 'updateToken', 'perObjectStatus_updateToken' - The current version of the object that is either in sync or pending
-- synchronization.
--
-- 'syncStatus', 'perObjectStatus_syncStatus' - Indicates whether this object is in sync with the version indicated in
-- the update token.
newPerObjectStatus ::
  PerObjectStatus
newPerObjectStatus :: PerObjectStatus
newPerObjectStatus =
  PerObjectStatus' :: Maybe Text -> Maybe PerObjectSyncStatus -> PerObjectStatus
PerObjectStatus'
    { $sel:updateToken:PerObjectStatus' :: Maybe Text
updateToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:syncStatus:PerObjectStatus' :: Maybe PerObjectSyncStatus
syncStatus = Maybe PerObjectSyncStatus
forall a. Maybe a
Prelude.Nothing
    }

-- | The current version of the object that is either in sync or pending
-- synchronization.
perObjectStatus_updateToken :: Lens.Lens' PerObjectStatus (Prelude.Maybe Prelude.Text)
perObjectStatus_updateToken :: (Maybe Text -> f (Maybe Text))
-> PerObjectStatus -> f PerObjectStatus
perObjectStatus_updateToken = (PerObjectStatus -> Maybe Text)
-> (PerObjectStatus -> Maybe Text -> PerObjectStatus)
-> Lens PerObjectStatus PerObjectStatus (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PerObjectStatus' {Maybe Text
updateToken :: Maybe Text
$sel:updateToken:PerObjectStatus' :: PerObjectStatus -> Maybe Text
updateToken} -> Maybe Text
updateToken) (\s :: PerObjectStatus
s@PerObjectStatus' {} Maybe Text
a -> PerObjectStatus
s {$sel:updateToken:PerObjectStatus' :: Maybe Text
updateToken = Maybe Text
a} :: PerObjectStatus)

-- | Indicates whether this object is in sync with the version indicated in
-- the update token.
perObjectStatus_syncStatus :: Lens.Lens' PerObjectStatus (Prelude.Maybe PerObjectSyncStatus)
perObjectStatus_syncStatus :: (Maybe PerObjectSyncStatus -> f (Maybe PerObjectSyncStatus))
-> PerObjectStatus -> f PerObjectStatus
perObjectStatus_syncStatus = (PerObjectStatus -> Maybe PerObjectSyncStatus)
-> (PerObjectStatus
    -> Maybe PerObjectSyncStatus -> PerObjectStatus)
-> Lens
     PerObjectStatus
     PerObjectStatus
     (Maybe PerObjectSyncStatus)
     (Maybe PerObjectSyncStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PerObjectStatus' {Maybe PerObjectSyncStatus
syncStatus :: Maybe PerObjectSyncStatus
$sel:syncStatus:PerObjectStatus' :: PerObjectStatus -> Maybe PerObjectSyncStatus
syncStatus} -> Maybe PerObjectSyncStatus
syncStatus) (\s :: PerObjectStatus
s@PerObjectStatus' {} Maybe PerObjectSyncStatus
a -> PerObjectStatus
s {$sel:syncStatus:PerObjectStatus' :: Maybe PerObjectSyncStatus
syncStatus = Maybe PerObjectSyncStatus
a} :: PerObjectStatus)

instance Core.FromJSON PerObjectStatus where
  parseJSON :: Value -> Parser PerObjectStatus
parseJSON =
    String
-> (Object -> Parser PerObjectStatus)
-> Value
-> Parser PerObjectStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PerObjectStatus"
      ( \Object
x ->
          Maybe Text -> Maybe PerObjectSyncStatus -> PerObjectStatus
PerObjectStatus'
            (Maybe Text -> Maybe PerObjectSyncStatus -> PerObjectStatus)
-> Parser (Maybe Text)
-> Parser (Maybe PerObjectSyncStatus -> PerObjectStatus)
forall (f :: * -> *) a b. Functor 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
"UpdateToken")
            Parser (Maybe PerObjectSyncStatus -> PerObjectStatus)
-> Parser (Maybe PerObjectSyncStatus) -> Parser PerObjectStatus
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe PerObjectSyncStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SyncStatus")
      )

instance Prelude.Hashable PerObjectStatus

instance Prelude.NFData PerObjectStatus