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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.NetworkFirewall.Types.Attachment
import Amazonka.NetworkFirewall.Types.PerObjectStatus
import qualified Amazonka.Prelude as Prelude

-- | The status of the firewall endpoint and firewall policy configuration
-- for a single VPC subnet.
--
-- For each VPC subnet that you associate with a firewall, Network Firewall
-- does the following:
--
-- -   Instantiates a firewall endpoint in the subnet, ready to take
--     traffic.
--
-- -   Configures the endpoint with the current firewall policy settings,
--     to provide the filtering behavior for the endpoint.
--
-- When you update a firewall, for example to add a subnet association or
-- change a rule group in the firewall policy, the affected sync states
-- reflect out-of-sync or not ready status until the changes are complete.
--
-- /See:/ 'newSyncState' smart constructor.
data SyncState = SyncState'
  { -- | The attachment status of the firewall\'s association with a single VPC
    -- subnet. For each configured subnet, Network Firewall creates the
    -- attachment by instantiating the firewall endpoint in the subnet so that
    -- it\'s ready to take traffic. This is part of the FirewallStatus.
    SyncState -> Maybe Attachment
attachment :: Prelude.Maybe Attachment,
    -- | The configuration status of the firewall endpoint in a single VPC
    -- subnet. 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 the FirewallStatus.
    SyncState -> Maybe (HashMap Text PerObjectStatus)
config :: Prelude.Maybe (Prelude.HashMap Prelude.Text PerObjectStatus)
  }
  deriving (SyncState -> SyncState -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SyncState -> SyncState -> Bool
$c/= :: SyncState -> SyncState -> Bool
== :: SyncState -> SyncState -> Bool
$c== :: SyncState -> SyncState -> Bool
Prelude.Eq, ReadPrec [SyncState]
ReadPrec SyncState
Int -> ReadS SyncState
ReadS [SyncState]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SyncState]
$creadListPrec :: ReadPrec [SyncState]
readPrec :: ReadPrec SyncState
$creadPrec :: ReadPrec SyncState
readList :: ReadS [SyncState]
$creadList :: ReadS [SyncState]
readsPrec :: Int -> ReadS SyncState
$creadsPrec :: Int -> ReadS SyncState
Prelude.Read, Int -> SyncState -> ShowS
[SyncState] -> ShowS
SyncState -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SyncState] -> ShowS
$cshowList :: [SyncState] -> ShowS
show :: SyncState -> String
$cshow :: SyncState -> String
showsPrec :: Int -> SyncState -> ShowS
$cshowsPrec :: Int -> SyncState -> ShowS
Prelude.Show, forall x. Rep SyncState x -> SyncState
forall x. SyncState -> Rep SyncState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SyncState x -> SyncState
$cfrom :: forall x. SyncState -> Rep SyncState x
Prelude.Generic)

-- |
-- Create a value of 'SyncState' 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:
--
-- 'attachment', 'syncState_attachment' - The attachment status of the firewall\'s association with a single VPC
-- subnet. For each configured subnet, Network Firewall creates the
-- attachment by instantiating the firewall endpoint in the subnet so that
-- it\'s ready to take traffic. This is part of the FirewallStatus.
--
-- 'config', 'syncState_config' - The configuration status of the firewall endpoint in a single VPC
-- subnet. 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 the FirewallStatus.
newSyncState ::
  SyncState
newSyncState :: SyncState
newSyncState =
  SyncState'
    { $sel:attachment:SyncState' :: Maybe Attachment
attachment = forall a. Maybe a
Prelude.Nothing,
      $sel:config:SyncState' :: Maybe (HashMap Text PerObjectStatus)
config = forall a. Maybe a
Prelude.Nothing
    }

-- | The attachment status of the firewall\'s association with a single VPC
-- subnet. For each configured subnet, Network Firewall creates the
-- attachment by instantiating the firewall endpoint in the subnet so that
-- it\'s ready to take traffic. This is part of the FirewallStatus.
syncState_attachment :: Lens.Lens' SyncState (Prelude.Maybe Attachment)
syncState_attachment :: Lens' SyncState (Maybe Attachment)
syncState_attachment = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SyncState' {Maybe Attachment
attachment :: Maybe Attachment
$sel:attachment:SyncState' :: SyncState -> Maybe Attachment
attachment} -> Maybe Attachment
attachment) (\s :: SyncState
s@SyncState' {} Maybe Attachment
a -> SyncState
s {$sel:attachment:SyncState' :: Maybe Attachment
attachment = Maybe Attachment
a} :: SyncState)

-- | The configuration status of the firewall endpoint in a single VPC
-- subnet. 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 the FirewallStatus.
syncState_config :: Lens.Lens' SyncState (Prelude.Maybe (Prelude.HashMap Prelude.Text PerObjectStatus))
syncState_config :: Lens' SyncState (Maybe (HashMap Text PerObjectStatus))
syncState_config = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SyncState' {Maybe (HashMap Text PerObjectStatus)
config :: Maybe (HashMap Text PerObjectStatus)
$sel:config:SyncState' :: SyncState -> Maybe (HashMap Text PerObjectStatus)
config} -> Maybe (HashMap Text PerObjectStatus)
config) (\s :: SyncState
s@SyncState' {} Maybe (HashMap Text PerObjectStatus)
a -> SyncState
s {$sel:config:SyncState' :: Maybe (HashMap Text PerObjectStatus)
config = Maybe (HashMap Text PerObjectStatus)
a} :: SyncState) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON SyncState where
  parseJSON :: Value -> Parser SyncState
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SyncState"
      ( \Object
x ->
          Maybe Attachment
-> Maybe (HashMap Text PerObjectStatus) -> SyncState
SyncState'
            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
"Attachment")
            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
"Config" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable SyncState where
  hashWithSalt :: Int -> SyncState -> Int
hashWithSalt Int
_salt SyncState' {Maybe (HashMap Text PerObjectStatus)
Maybe Attachment
config :: Maybe (HashMap Text PerObjectStatus)
attachment :: Maybe Attachment
$sel:config:SyncState' :: SyncState -> Maybe (HashMap Text PerObjectStatus)
$sel:attachment:SyncState' :: SyncState -> Maybe Attachment
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Attachment
attachment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text PerObjectStatus)
config

instance Prelude.NFData SyncState where
  rnf :: SyncState -> ()
rnf SyncState' {Maybe (HashMap Text PerObjectStatus)
Maybe Attachment
config :: Maybe (HashMap Text PerObjectStatus)
attachment :: Maybe Attachment
$sel:config:SyncState' :: SyncState -> Maybe (HashMap Text PerObjectStatus)
$sel:attachment:SyncState' :: SyncState -> Maybe Attachment
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Attachment
attachment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text PerObjectStatus)
config