{-# 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.PatchFilterGroup
-- 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.PatchFilterGroup 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.PatchFilter

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

-- |
-- Create a value of 'PatchFilterGroup' 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:
--
-- 'patchFilters', 'patchFilterGroup_patchFilters' - The set of patch filters that make up the group.
newPatchFilterGroup ::
  PatchFilterGroup
newPatchFilterGroup :: PatchFilterGroup
newPatchFilterGroup =
  PatchFilterGroup' {$sel:patchFilters:PatchFilterGroup' :: [PatchFilter]
patchFilters = forall a. Monoid a => a
Prelude.mempty}

-- | The set of patch filters that make up the group.
patchFilterGroup_patchFilters :: Lens.Lens' PatchFilterGroup [PatchFilter]
patchFilterGroup_patchFilters :: Lens' PatchFilterGroup [PatchFilter]
patchFilterGroup_patchFilters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PatchFilterGroup' {[PatchFilter]
patchFilters :: [PatchFilter]
$sel:patchFilters:PatchFilterGroup' :: PatchFilterGroup -> [PatchFilter]
patchFilters} -> [PatchFilter]
patchFilters) (\s :: PatchFilterGroup
s@PatchFilterGroup' {} [PatchFilter]
a -> PatchFilterGroup
s {$sel:patchFilters:PatchFilterGroup' :: [PatchFilter]
patchFilters = [PatchFilter]
a} :: PatchFilterGroup) 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 PatchFilterGroup where
  parseJSON :: Value -> Parser PatchFilterGroup
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PatchFilterGroup"
      ( \Object
x ->
          [PatchFilter] -> PatchFilterGroup
PatchFilterGroup'
            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
"PatchFilters" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable PatchFilterGroup where
  hashWithSalt :: Int -> PatchFilterGroup -> Int
hashWithSalt Int
_salt PatchFilterGroup' {[PatchFilter]
patchFilters :: [PatchFilter]
$sel:patchFilters:PatchFilterGroup' :: PatchFilterGroup -> [PatchFilter]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [PatchFilter]
patchFilters

instance Prelude.NFData PatchFilterGroup where
  rnf :: PatchFilterGroup -> ()
rnf PatchFilterGroup' {[PatchFilter]
patchFilters :: [PatchFilter]
$sel:patchFilters:PatchFilterGroup' :: PatchFilterGroup -> [PatchFilter]
..} = forall a. NFData a => a -> ()
Prelude.rnf [PatchFilter]
patchFilters

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