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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSM.Types.InstancePatchStateOperatorType

-- | Defines a filter used in DescribeInstancePatchStatesForPatchGroup to
-- scope down the information returned by the API.
--
-- __Example__: To filter for all instances in a patch group having more
-- than three patches with a @FailedCount@ status, use the following for
-- the filter:
--
-- -   Value for @Key@: @FailedCount@
--
-- -   Value for @Type@: @GreaterThan@
--
-- -   Value for @Values@: @3@
--
-- /See:/ 'newInstancePatchStateFilter' smart constructor.
data InstancePatchStateFilter = InstancePatchStateFilter'
  { -- | The key for the filter. Supported values include the following:
    --
    -- -   @InstalledCount@
    --
    -- -   @InstalledOtherCount@
    --
    -- -   @InstalledPendingRebootCount@
    --
    -- -   @InstalledRejectedCount@
    --
    -- -   @MissingCount@
    --
    -- -   @FailedCount@
    --
    -- -   @UnreportedNotApplicableCount@
    --
    -- -   @NotApplicableCount@
    InstancePatchStateFilter -> Text
key :: Prelude.Text,
    -- | The value for the filter. Must be an integer greater than or equal to 0.
    InstancePatchStateFilter -> NonEmpty Text
values :: Prelude.NonEmpty Prelude.Text,
    -- | The type of comparison that should be performed for the value.
    InstancePatchStateFilter -> InstancePatchStateOperatorType
type' :: InstancePatchStateOperatorType
  }
  deriving (InstancePatchStateFilter -> InstancePatchStateFilter -> Bool
(InstancePatchStateFilter -> InstancePatchStateFilter -> Bool)
-> (InstancePatchStateFilter -> InstancePatchStateFilter -> Bool)
-> Eq InstancePatchStateFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstancePatchStateFilter -> InstancePatchStateFilter -> Bool
$c/= :: InstancePatchStateFilter -> InstancePatchStateFilter -> Bool
== :: InstancePatchStateFilter -> InstancePatchStateFilter -> Bool
$c== :: InstancePatchStateFilter -> InstancePatchStateFilter -> Bool
Prelude.Eq, ReadPrec [InstancePatchStateFilter]
ReadPrec InstancePatchStateFilter
Int -> ReadS InstancePatchStateFilter
ReadS [InstancePatchStateFilter]
(Int -> ReadS InstancePatchStateFilter)
-> ReadS [InstancePatchStateFilter]
-> ReadPrec InstancePatchStateFilter
-> ReadPrec [InstancePatchStateFilter]
-> Read InstancePatchStateFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstancePatchStateFilter]
$creadListPrec :: ReadPrec [InstancePatchStateFilter]
readPrec :: ReadPrec InstancePatchStateFilter
$creadPrec :: ReadPrec InstancePatchStateFilter
readList :: ReadS [InstancePatchStateFilter]
$creadList :: ReadS [InstancePatchStateFilter]
readsPrec :: Int -> ReadS InstancePatchStateFilter
$creadsPrec :: Int -> ReadS InstancePatchStateFilter
Prelude.Read, Int -> InstancePatchStateFilter -> ShowS
[InstancePatchStateFilter] -> ShowS
InstancePatchStateFilter -> String
(Int -> InstancePatchStateFilter -> ShowS)
-> (InstancePatchStateFilter -> String)
-> ([InstancePatchStateFilter] -> ShowS)
-> Show InstancePatchStateFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstancePatchStateFilter] -> ShowS
$cshowList :: [InstancePatchStateFilter] -> ShowS
show :: InstancePatchStateFilter -> String
$cshow :: InstancePatchStateFilter -> String
showsPrec :: Int -> InstancePatchStateFilter -> ShowS
$cshowsPrec :: Int -> InstancePatchStateFilter -> ShowS
Prelude.Show, (forall x.
 InstancePatchStateFilter -> Rep InstancePatchStateFilter x)
-> (forall x.
    Rep InstancePatchStateFilter x -> InstancePatchStateFilter)
-> Generic InstancePatchStateFilter
forall x.
Rep InstancePatchStateFilter x -> InstancePatchStateFilter
forall x.
InstancePatchStateFilter -> Rep InstancePatchStateFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InstancePatchStateFilter x -> InstancePatchStateFilter
$cfrom :: forall x.
InstancePatchStateFilter -> Rep InstancePatchStateFilter x
Prelude.Generic)

-- |
-- Create a value of 'InstancePatchStateFilter' 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:
--
-- 'key', 'instancePatchStateFilter_key' - The key for the filter. Supported values include the following:
--
-- -   @InstalledCount@
--
-- -   @InstalledOtherCount@
--
-- -   @InstalledPendingRebootCount@
--
-- -   @InstalledRejectedCount@
--
-- -   @MissingCount@
--
-- -   @FailedCount@
--
-- -   @UnreportedNotApplicableCount@
--
-- -   @NotApplicableCount@
--
-- 'values', 'instancePatchStateFilter_values' - The value for the filter. Must be an integer greater than or equal to 0.
--
-- 'type'', 'instancePatchStateFilter_type' - The type of comparison that should be performed for the value.
newInstancePatchStateFilter ::
  -- | 'key'
  Prelude.Text ->
  -- | 'values'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'type''
  InstancePatchStateOperatorType ->
  InstancePatchStateFilter
newInstancePatchStateFilter :: Text
-> NonEmpty Text
-> InstancePatchStateOperatorType
-> InstancePatchStateFilter
newInstancePatchStateFilter Text
pKey_ NonEmpty Text
pValues_ InstancePatchStateOperatorType
pType_ =
  InstancePatchStateFilter' :: Text
-> NonEmpty Text
-> InstancePatchStateOperatorType
-> InstancePatchStateFilter
InstancePatchStateFilter'
    { $sel:key:InstancePatchStateFilter' :: Text
key = Text
pKey_,
      $sel:values:InstancePatchStateFilter' :: NonEmpty Text
values = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pValues_,
      $sel:type':InstancePatchStateFilter' :: InstancePatchStateOperatorType
type' = InstancePatchStateOperatorType
pType_
    }

-- | The key for the filter. Supported values include the following:
--
-- -   @InstalledCount@
--
-- -   @InstalledOtherCount@
--
-- -   @InstalledPendingRebootCount@
--
-- -   @InstalledRejectedCount@
--
-- -   @MissingCount@
--
-- -   @FailedCount@
--
-- -   @UnreportedNotApplicableCount@
--
-- -   @NotApplicableCount@
instancePatchStateFilter_key :: Lens.Lens' InstancePatchStateFilter Prelude.Text
instancePatchStateFilter_key :: (Text -> f Text)
-> InstancePatchStateFilter -> f InstancePatchStateFilter
instancePatchStateFilter_key = (InstancePatchStateFilter -> Text)
-> (InstancePatchStateFilter -> Text -> InstancePatchStateFilter)
-> Lens InstancePatchStateFilter InstancePatchStateFilter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancePatchStateFilter' {Text
key :: Text
$sel:key:InstancePatchStateFilter' :: InstancePatchStateFilter -> Text
key} -> Text
key) (\s :: InstancePatchStateFilter
s@InstancePatchStateFilter' {} Text
a -> InstancePatchStateFilter
s {$sel:key:InstancePatchStateFilter' :: Text
key = Text
a} :: InstancePatchStateFilter)

-- | The value for the filter. Must be an integer greater than or equal to 0.
instancePatchStateFilter_values :: Lens.Lens' InstancePatchStateFilter (Prelude.NonEmpty Prelude.Text)
instancePatchStateFilter_values :: (NonEmpty Text -> f (NonEmpty Text))
-> InstancePatchStateFilter -> f InstancePatchStateFilter
instancePatchStateFilter_values = (InstancePatchStateFilter -> NonEmpty Text)
-> (InstancePatchStateFilter
    -> NonEmpty Text -> InstancePatchStateFilter)
-> Lens
     InstancePatchStateFilter
     InstancePatchStateFilter
     (NonEmpty Text)
     (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancePatchStateFilter' {NonEmpty Text
values :: NonEmpty Text
$sel:values:InstancePatchStateFilter' :: InstancePatchStateFilter -> NonEmpty Text
values} -> NonEmpty Text
values) (\s :: InstancePatchStateFilter
s@InstancePatchStateFilter' {} NonEmpty Text
a -> InstancePatchStateFilter
s {$sel:values:InstancePatchStateFilter' :: NonEmpty Text
values = NonEmpty Text
a} :: InstancePatchStateFilter) ((NonEmpty Text -> f (NonEmpty Text))
 -> InstancePatchStateFilter -> f InstancePatchStateFilter)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> InstancePatchStateFilter
-> f InstancePatchStateFilter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The type of comparison that should be performed for the value.
instancePatchStateFilter_type :: Lens.Lens' InstancePatchStateFilter InstancePatchStateOperatorType
instancePatchStateFilter_type :: (InstancePatchStateOperatorType
 -> f InstancePatchStateOperatorType)
-> InstancePatchStateFilter -> f InstancePatchStateFilter
instancePatchStateFilter_type = (InstancePatchStateFilter -> InstancePatchStateOperatorType)
-> (InstancePatchStateFilter
    -> InstancePatchStateOperatorType -> InstancePatchStateFilter)
-> Lens
     InstancePatchStateFilter
     InstancePatchStateFilter
     InstancePatchStateOperatorType
     InstancePatchStateOperatorType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancePatchStateFilter' {InstancePatchStateOperatorType
type' :: InstancePatchStateOperatorType
$sel:type':InstancePatchStateFilter' :: InstancePatchStateFilter -> InstancePatchStateOperatorType
type'} -> InstancePatchStateOperatorType
type') (\s :: InstancePatchStateFilter
s@InstancePatchStateFilter' {} InstancePatchStateOperatorType
a -> InstancePatchStateFilter
s {$sel:type':InstancePatchStateFilter' :: InstancePatchStateOperatorType
type' = InstancePatchStateOperatorType
a} :: InstancePatchStateFilter)

instance Prelude.Hashable InstancePatchStateFilter

instance Prelude.NFData InstancePatchStateFilter

instance Core.ToJSON InstancePatchStateFilter where
  toJSON :: InstancePatchStateFilter -> Value
toJSON InstancePatchStateFilter' {NonEmpty Text
Text
InstancePatchStateOperatorType
type' :: InstancePatchStateOperatorType
values :: NonEmpty Text
key :: Text
$sel:type':InstancePatchStateFilter' :: InstancePatchStateFilter -> InstancePatchStateOperatorType
$sel:values:InstancePatchStateFilter' :: InstancePatchStateFilter -> NonEmpty Text
$sel:key:InstancePatchStateFilter' :: InstancePatchStateFilter -> Text
..} =
    [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
"Key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
key),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Values" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
values),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> InstancePatchStateOperatorType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= InstancePatchStateOperatorType
type')
          ]
      )