{-# 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.SSM.Types.PatchRuleGroup
-- 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.SSM.Types.PatchRuleGroup 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
import Amazonka.SSM.Types.PatchRule

-- | A set of rules defining the approval rules for a patch baseline.
--
-- /See:/ 'newPatchRuleGroup' smart constructor.
data PatchRuleGroup = PatchRuleGroup'
  { -- | The rules that make up the rule group.
    PatchRuleGroup -> [PatchRule]
patchRules :: [PatchRule]
  }
  deriving (PatchRuleGroup -> PatchRuleGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PatchRuleGroup -> PatchRuleGroup -> Bool
$c/= :: PatchRuleGroup -> PatchRuleGroup -> Bool
== :: PatchRuleGroup -> PatchRuleGroup -> Bool
$c== :: PatchRuleGroup -> PatchRuleGroup -> Bool
Prelude.Eq, ReadPrec [PatchRuleGroup]
ReadPrec PatchRuleGroup
Int -> ReadS PatchRuleGroup
ReadS [PatchRuleGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PatchRuleGroup]
$creadListPrec :: ReadPrec [PatchRuleGroup]
readPrec :: ReadPrec PatchRuleGroup
$creadPrec :: ReadPrec PatchRuleGroup
readList :: ReadS [PatchRuleGroup]
$creadList :: ReadS [PatchRuleGroup]
readsPrec :: Int -> ReadS PatchRuleGroup
$creadsPrec :: Int -> ReadS PatchRuleGroup
Prelude.Read, Int -> PatchRuleGroup -> ShowS
[PatchRuleGroup] -> ShowS
PatchRuleGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PatchRuleGroup] -> ShowS
$cshowList :: [PatchRuleGroup] -> ShowS
show :: PatchRuleGroup -> String
$cshow :: PatchRuleGroup -> String
showsPrec :: Int -> PatchRuleGroup -> ShowS
$cshowsPrec :: Int -> PatchRuleGroup -> ShowS
Prelude.Show, forall x. Rep PatchRuleGroup x -> PatchRuleGroup
forall x. PatchRuleGroup -> Rep PatchRuleGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PatchRuleGroup x -> PatchRuleGroup
$cfrom :: forall x. PatchRuleGroup -> Rep PatchRuleGroup x
Prelude.Generic)

-- |
-- Create a value of 'PatchRuleGroup' 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:
--
-- 'patchRules', 'patchRuleGroup_patchRules' - The rules that make up the rule group.
newPatchRuleGroup ::
  PatchRuleGroup
newPatchRuleGroup :: PatchRuleGroup
newPatchRuleGroup =
  PatchRuleGroup' {$sel:patchRules:PatchRuleGroup' :: [PatchRule]
patchRules = forall a. Monoid a => a
Prelude.mempty}

-- | The rules that make up the rule group.
patchRuleGroup_patchRules :: Lens.Lens' PatchRuleGroup [PatchRule]
patchRuleGroup_patchRules :: Lens' PatchRuleGroup [PatchRule]
patchRuleGroup_patchRules = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PatchRuleGroup' {[PatchRule]
patchRules :: [PatchRule]
$sel:patchRules:PatchRuleGroup' :: PatchRuleGroup -> [PatchRule]
patchRules} -> [PatchRule]
patchRules) (\s :: PatchRuleGroup
s@PatchRuleGroup' {} [PatchRule]
a -> PatchRuleGroup
s {$sel:patchRules:PatchRuleGroup' :: [PatchRule]
patchRules = [PatchRule]
a} :: PatchRuleGroup) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON PatchRuleGroup where
  parseJSON :: Value -> Parser PatchRuleGroup
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PatchRuleGroup"
      ( \Object
x ->
          [PatchRule] -> PatchRuleGroup
PatchRuleGroup'
            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
"PatchRules" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable PatchRuleGroup where
  hashWithSalt :: Int -> PatchRuleGroup -> Int
hashWithSalt Int
_salt PatchRuleGroup' {[PatchRule]
patchRules :: [PatchRule]
$sel:patchRules:PatchRuleGroup' :: PatchRuleGroup -> [PatchRule]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [PatchRule]
patchRules

instance Prelude.NFData PatchRuleGroup where
  rnf :: PatchRuleGroup -> ()
rnf PatchRuleGroup' {[PatchRule]
patchRules :: [PatchRule]
$sel:patchRules:PatchRuleGroup' :: PatchRuleGroup -> [PatchRule]
..} = forall a. NFData a => a -> ()
Prelude.rnf [PatchRule]
patchRules

instance Data.ToJSON PatchRuleGroup where
  toJSON :: PatchRuleGroup -> Value
toJSON PatchRuleGroup' {[PatchRule]
patchRules :: [PatchRule]
$sel:patchRules:PatchRuleGroup' :: PatchRuleGroup -> [PatchRule]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"PatchRules" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [PatchRule]
patchRules)]
      )