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

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

-- | High-level information about the managed rule group that your own rule
-- group is copied from. You can use the the metadata to track version
-- updates made to the originating rule group. You can retrieve all objects
-- for a rule group by calling
-- <https://docs.aws.amazon.com/network-firewall/latest/APIReference/API_DescribeRuleGroup.html DescribeRuleGroup>.
--
-- /See:/ 'newSourceMetadata' smart constructor.
data SourceMetadata = SourceMetadata'
  { -- | The Amazon Resource Name (ARN) of the rule group that your own rule
    -- group is copied from.
    SourceMetadata -> Maybe Text
sourceArn :: Prelude.Maybe Prelude.Text,
    -- | The update token of the Amazon Web Services managed rule group that your
    -- own rule group is copied from. To determine the update token for the
    -- managed rule group, call
    -- <https://docs.aws.amazon.com/network-firewall/latest/APIReference/API_DescribeRuleGroup.html#networkfirewall-DescribeRuleGroup-response-UpdateToken DescribeRuleGroup>.
    SourceMetadata -> Maybe Text
sourceUpdateToken :: Prelude.Maybe Prelude.Text
  }
  deriving (SourceMetadata -> SourceMetadata -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceMetadata -> SourceMetadata -> Bool
$c/= :: SourceMetadata -> SourceMetadata -> Bool
== :: SourceMetadata -> SourceMetadata -> Bool
$c== :: SourceMetadata -> SourceMetadata -> Bool
Prelude.Eq, ReadPrec [SourceMetadata]
ReadPrec SourceMetadata
Int -> ReadS SourceMetadata
ReadS [SourceMetadata]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceMetadata]
$creadListPrec :: ReadPrec [SourceMetadata]
readPrec :: ReadPrec SourceMetadata
$creadPrec :: ReadPrec SourceMetadata
readList :: ReadS [SourceMetadata]
$creadList :: ReadS [SourceMetadata]
readsPrec :: Int -> ReadS SourceMetadata
$creadsPrec :: Int -> ReadS SourceMetadata
Prelude.Read, Int -> SourceMetadata -> ShowS
[SourceMetadata] -> ShowS
SourceMetadata -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceMetadata] -> ShowS
$cshowList :: [SourceMetadata] -> ShowS
show :: SourceMetadata -> String
$cshow :: SourceMetadata -> String
showsPrec :: Int -> SourceMetadata -> ShowS
$cshowsPrec :: Int -> SourceMetadata -> ShowS
Prelude.Show, forall x. Rep SourceMetadata x -> SourceMetadata
forall x. SourceMetadata -> Rep SourceMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceMetadata x -> SourceMetadata
$cfrom :: forall x. SourceMetadata -> Rep SourceMetadata x
Prelude.Generic)

-- |
-- Create a value of 'SourceMetadata' 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:
--
-- 'sourceArn', 'sourceMetadata_sourceArn' - The Amazon Resource Name (ARN) of the rule group that your own rule
-- group is copied from.
--
-- 'sourceUpdateToken', 'sourceMetadata_sourceUpdateToken' - The update token of the Amazon Web Services managed rule group that your
-- own rule group is copied from. To determine the update token for the
-- managed rule group, call
-- <https://docs.aws.amazon.com/network-firewall/latest/APIReference/API_DescribeRuleGroup.html#networkfirewall-DescribeRuleGroup-response-UpdateToken DescribeRuleGroup>.
newSourceMetadata ::
  SourceMetadata
newSourceMetadata :: SourceMetadata
newSourceMetadata =
  SourceMetadata'
    { $sel:sourceArn:SourceMetadata' :: Maybe Text
sourceArn = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceUpdateToken:SourceMetadata' :: Maybe Text
sourceUpdateToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the rule group that your own rule
-- group is copied from.
sourceMetadata_sourceArn :: Lens.Lens' SourceMetadata (Prelude.Maybe Prelude.Text)
sourceMetadata_sourceArn :: Lens' SourceMetadata (Maybe Text)
sourceMetadata_sourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceMetadata' {Maybe Text
sourceArn :: Maybe Text
$sel:sourceArn:SourceMetadata' :: SourceMetadata -> Maybe Text
sourceArn} -> Maybe Text
sourceArn) (\s :: SourceMetadata
s@SourceMetadata' {} Maybe Text
a -> SourceMetadata
s {$sel:sourceArn:SourceMetadata' :: Maybe Text
sourceArn = Maybe Text
a} :: SourceMetadata)

-- | The update token of the Amazon Web Services managed rule group that your
-- own rule group is copied from. To determine the update token for the
-- managed rule group, call
-- <https://docs.aws.amazon.com/network-firewall/latest/APIReference/API_DescribeRuleGroup.html#networkfirewall-DescribeRuleGroup-response-UpdateToken DescribeRuleGroup>.
sourceMetadata_sourceUpdateToken :: Lens.Lens' SourceMetadata (Prelude.Maybe Prelude.Text)
sourceMetadata_sourceUpdateToken :: Lens' SourceMetadata (Maybe Text)
sourceMetadata_sourceUpdateToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceMetadata' {Maybe Text
sourceUpdateToken :: Maybe Text
$sel:sourceUpdateToken:SourceMetadata' :: SourceMetadata -> Maybe Text
sourceUpdateToken} -> Maybe Text
sourceUpdateToken) (\s :: SourceMetadata
s@SourceMetadata' {} Maybe Text
a -> SourceMetadata
s {$sel:sourceUpdateToken:SourceMetadata' :: Maybe Text
sourceUpdateToken = Maybe Text
a} :: SourceMetadata)

instance Data.FromJSON SourceMetadata where
  parseJSON :: Value -> Parser SourceMetadata
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SourceMetadata"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> SourceMetadata
SourceMetadata'
            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
"SourceArn")
            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
"SourceUpdateToken")
      )

instance Prelude.Hashable SourceMetadata where
  hashWithSalt :: Int -> SourceMetadata -> Int
hashWithSalt Int
_salt SourceMetadata' {Maybe Text
sourceUpdateToken :: Maybe Text
sourceArn :: Maybe Text
$sel:sourceUpdateToken:SourceMetadata' :: SourceMetadata -> Maybe Text
$sel:sourceArn:SourceMetadata' :: SourceMetadata -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceUpdateToken

instance Prelude.NFData SourceMetadata where
  rnf :: SourceMetadata -> ()
rnf SourceMetadata' {Maybe Text
sourceUpdateToken :: Maybe Text
sourceArn :: Maybe Text
$sel:sourceUpdateToken:SourceMetadata' :: SourceMetadata -> Maybe Text
$sel:sourceArn:SourceMetadata' :: SourceMetadata -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceUpdateToken

instance Data.ToJSON SourceMetadata where
  toJSON :: SourceMetadata -> Value
toJSON SourceMetadata' {Maybe Text
sourceUpdateToken :: Maybe Text
sourceArn :: Maybe Text
$sel:sourceUpdateToken:SourceMetadata' :: SourceMetadata -> Maybe Text
$sel:sourceArn:SourceMetadata' :: SourceMetadata -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"SourceArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sourceArn,
            (Key
"SourceUpdateToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sourceUpdateToken
          ]
      )