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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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, AWS 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 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),
    -- | 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
  }
  deriving (SyncState -> SyncState -> Bool
(SyncState -> SyncState -> Bool)
-> (SyncState -> SyncState -> Bool) -> Eq SyncState
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]
(Int -> ReadS SyncState)
-> ReadS [SyncState]
-> ReadPrec SyncState
-> ReadPrec [SyncState]
-> Read 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
(Int -> SyncState -> ShowS)
-> (SyncState -> String)
-> ([SyncState] -> ShowS)
-> Show SyncState
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. SyncState -> Rep SyncState x)
-> (forall x. Rep SyncState x -> SyncState) -> Generic SyncState
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:
--
-- '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.
--
-- '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.
newSyncState ::
  SyncState
newSyncState :: SyncState
newSyncState =
  SyncState' :: Maybe (HashMap Text PerObjectStatus)
-> Maybe Attachment -> SyncState
SyncState'
    { $sel:config:SyncState' :: Maybe (HashMap Text PerObjectStatus)
config = Maybe (HashMap Text PerObjectStatus)
forall a. Maybe a
Prelude.Nothing,
      $sel:attachment:SyncState' :: Maybe Attachment
attachment = Maybe Attachment
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe (HashMap Text PerObjectStatus)
 -> f (Maybe (HashMap Text PerObjectStatus)))
-> SyncState -> f SyncState
syncState_config = (SyncState -> Maybe (HashMap Text PerObjectStatus))
-> (SyncState -> Maybe (HashMap Text PerObjectStatus) -> SyncState)
-> Lens
     SyncState
     SyncState
     (Maybe (HashMap Text PerObjectStatus))
     (Maybe (HashMap Text PerObjectStatus))
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) ((Maybe (HashMap Text PerObjectStatus)
  -> f (Maybe (HashMap Text PerObjectStatus)))
 -> SyncState -> f SyncState)
-> ((Maybe (HashMap Text PerObjectStatus)
     -> f (Maybe (HashMap Text PerObjectStatus)))
    -> Maybe (HashMap Text PerObjectStatus)
    -> f (Maybe (HashMap Text PerObjectStatus)))
-> (Maybe (HashMap Text PerObjectStatus)
    -> f (Maybe (HashMap Text PerObjectStatus)))
-> SyncState
-> f SyncState
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text PerObjectStatus)
  (HashMap Text PerObjectStatus)
  (HashMap Text PerObjectStatus)
  (HashMap Text PerObjectStatus)
-> Iso
     (Maybe (HashMap Text PerObjectStatus))
     (Maybe (HashMap Text PerObjectStatus))
     (Maybe (HashMap Text PerObjectStatus))
     (Maybe (HashMap Text PerObjectStatus))
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
  (HashMap Text PerObjectStatus)
  (HashMap Text PerObjectStatus)
  (HashMap Text PerObjectStatus)
  (HashMap Text PerObjectStatus)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe Attachment -> f (Maybe Attachment))
-> SyncState -> f SyncState
syncState_attachment = (SyncState -> Maybe Attachment)
-> (SyncState -> Maybe Attachment -> SyncState)
-> Lens SyncState SyncState (Maybe Attachment) (Maybe 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)

instance Core.FromJSON SyncState where
  parseJSON :: Value -> Parser SyncState
parseJSON =
    String -> (Object -> Parser SyncState) -> Value -> Parser SyncState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SyncState"
      ( \Object
x ->
          Maybe (HashMap Text PerObjectStatus)
-> Maybe Attachment -> SyncState
SyncState'
            (Maybe (HashMap Text PerObjectStatus)
 -> Maybe Attachment -> SyncState)
-> Parser (Maybe (HashMap Text PerObjectStatus))
-> Parser (Maybe Attachment -> SyncState)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Parser (Maybe (Maybe (HashMap Text PerObjectStatus)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Config" Parser (Maybe (Maybe (HashMap Text PerObjectStatus)))
-> Maybe (HashMap Text PerObjectStatus)
-> Parser (Maybe (HashMap Text PerObjectStatus))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text PerObjectStatus)
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Attachment -> SyncState)
-> Parser (Maybe Attachment) -> Parser SyncState
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Attachment)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Attachment")
      )

instance Prelude.Hashable SyncState

instance Prelude.NFData SyncState