{-# 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-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.SSM.Types.PatchFilterGroup where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(PatchFilterGroup -> PatchFilterGroup -> Bool)
-> (PatchFilterGroup -> PatchFilterGroup -> Bool)
-> Eq PatchFilterGroup
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]
(Int -> ReadS PatchFilterGroup)
-> ReadS [PatchFilterGroup]
-> ReadPrec PatchFilterGroup
-> ReadPrec [PatchFilterGroup]
-> Read 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
(Int -> PatchFilterGroup -> ShowS)
-> (PatchFilterGroup -> String)
-> ([PatchFilterGroup] -> ShowS)
-> Show PatchFilterGroup
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. PatchFilterGroup -> Rep PatchFilterGroup x)
-> (forall x. Rep PatchFilterGroup x -> PatchFilterGroup)
-> Generic PatchFilterGroup
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' :: [PatchFilter] -> PatchFilterGroup
PatchFilterGroup' {$sel:patchFilters:PatchFilterGroup' :: [PatchFilter]
patchFilters = [PatchFilter]
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 :: ([PatchFilter] -> f [PatchFilter])
-> PatchFilterGroup -> f PatchFilterGroup
patchFilterGroup_patchFilters = (PatchFilterGroup -> [PatchFilter])
-> (PatchFilterGroup -> [PatchFilter] -> PatchFilterGroup)
-> Lens
     PatchFilterGroup PatchFilterGroup [PatchFilter] [PatchFilter]
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) (([PatchFilter] -> f [PatchFilter])
 -> PatchFilterGroup -> f PatchFilterGroup)
-> (([PatchFilter] -> f [PatchFilter])
    -> [PatchFilter] -> f [PatchFilter])
-> ([PatchFilter] -> f [PatchFilter])
-> PatchFilterGroup
-> f PatchFilterGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([PatchFilter] -> f [PatchFilter])
-> [PatchFilter] -> f [PatchFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON PatchFilterGroup where
  parseJSON :: Value -> Parser PatchFilterGroup
parseJSON =
    String
-> (Object -> Parser PatchFilterGroup)
-> Value
-> Parser PatchFilterGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PatchFilterGroup"
      ( \Object
x ->
          [PatchFilter] -> PatchFilterGroup
PatchFilterGroup'
            ([PatchFilter] -> PatchFilterGroup)
-> Parser [PatchFilter] -> Parser PatchFilterGroup
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe [PatchFilter])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PatchFilters" Parser (Maybe [PatchFilter])
-> [PatchFilter] -> Parser [PatchFilter]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [PatchFilter]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable PatchFilterGroup

instance Prelude.NFData PatchFilterGroup

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