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

-- | Defines a filter used in DescribeInstancePatchStatesForPatchGroup to
-- scope down the information returned by the API.
--
-- __Example__: To filter for all managed nodes 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
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]
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
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.
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'
    { $sel:key:InstancePatchStateFilter' :: Text
key = Text
pKey_,
      $sel:values:InstancePatchStateFilter' :: NonEmpty Text
values = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced 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 :: Lens' InstancePatchStateFilter Text
instancePatchStateFilter_key = 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 :: Lens' InstancePatchStateFilter (NonEmpty Text)
instancePatchStateFilter_values = 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) 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

-- | The type of comparison that should be performed for the value.
instancePatchStateFilter_type :: Lens.Lens' InstancePatchStateFilter InstancePatchStateOperatorType
instancePatchStateFilter_type :: Lens' InstancePatchStateFilter InstancePatchStateOperatorType
instancePatchStateFilter_type = 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 where
  hashWithSalt :: Int -> InstancePatchStateFilter -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
values
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` InstancePatchStateOperatorType
type'

instance Prelude.NFData InstancePatchStateFilter where
  rnf :: InstancePatchStateFilter -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
values
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf InstancePatchStateOperatorType
type'

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
key),
            forall a. a -> Maybe a
Prelude.Just (Key
"Values" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
values),
            forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= InstancePatchStateOperatorType
type')
          ]
      )