{-# 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.OpsItemEventFilter
-- 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.OpsItemEventFilter 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.OpsItemEventFilterKey
import Amazonka.SSM.Types.OpsItemEventFilterOperator

-- | Describes a filter for a specific list of OpsItem events. You can filter
-- event information by using tags. You specify tags by using a key-value
-- pair mapping.
--
-- /See:/ 'newOpsItemEventFilter' smart constructor.
data OpsItemEventFilter = OpsItemEventFilter'
  { -- | The name of the filter key. Currently, the only supported value is
    -- @OpsItemId@.
    OpsItemEventFilter -> OpsItemEventFilterKey
key :: OpsItemEventFilterKey,
    -- | The values for the filter, consisting of one or more OpsItem IDs.
    OpsItemEventFilter -> [Text]
values :: [Prelude.Text],
    -- | The operator used by the filter call. Currently, the only supported
    -- value is @Equal@.
    OpsItemEventFilter -> OpsItemEventFilterOperator
operator :: OpsItemEventFilterOperator
  }
  deriving (OpsItemEventFilter -> OpsItemEventFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OpsItemEventFilter -> OpsItemEventFilter -> Bool
$c/= :: OpsItemEventFilter -> OpsItemEventFilter -> Bool
== :: OpsItemEventFilter -> OpsItemEventFilter -> Bool
$c== :: OpsItemEventFilter -> OpsItemEventFilter -> Bool
Prelude.Eq, ReadPrec [OpsItemEventFilter]
ReadPrec OpsItemEventFilter
Int -> ReadS OpsItemEventFilter
ReadS [OpsItemEventFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OpsItemEventFilter]
$creadListPrec :: ReadPrec [OpsItemEventFilter]
readPrec :: ReadPrec OpsItemEventFilter
$creadPrec :: ReadPrec OpsItemEventFilter
readList :: ReadS [OpsItemEventFilter]
$creadList :: ReadS [OpsItemEventFilter]
readsPrec :: Int -> ReadS OpsItemEventFilter
$creadsPrec :: Int -> ReadS OpsItemEventFilter
Prelude.Read, Int -> OpsItemEventFilter -> ShowS
[OpsItemEventFilter] -> ShowS
OpsItemEventFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OpsItemEventFilter] -> ShowS
$cshowList :: [OpsItemEventFilter] -> ShowS
show :: OpsItemEventFilter -> String
$cshow :: OpsItemEventFilter -> String
showsPrec :: Int -> OpsItemEventFilter -> ShowS
$cshowsPrec :: Int -> OpsItemEventFilter -> ShowS
Prelude.Show, forall x. Rep OpsItemEventFilter x -> OpsItemEventFilter
forall x. OpsItemEventFilter -> Rep OpsItemEventFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OpsItemEventFilter x -> OpsItemEventFilter
$cfrom :: forall x. OpsItemEventFilter -> Rep OpsItemEventFilter x
Prelude.Generic)

-- |
-- Create a value of 'OpsItemEventFilter' 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', 'opsItemEventFilter_key' - The name of the filter key. Currently, the only supported value is
-- @OpsItemId@.
--
-- 'values', 'opsItemEventFilter_values' - The values for the filter, consisting of one or more OpsItem IDs.
--
-- 'operator', 'opsItemEventFilter_operator' - The operator used by the filter call. Currently, the only supported
-- value is @Equal@.
newOpsItemEventFilter ::
  -- | 'key'
  OpsItemEventFilterKey ->
  -- | 'operator'
  OpsItemEventFilterOperator ->
  OpsItemEventFilter
newOpsItemEventFilter :: OpsItemEventFilterKey
-> OpsItemEventFilterOperator -> OpsItemEventFilter
newOpsItemEventFilter OpsItemEventFilterKey
pKey_ OpsItemEventFilterOperator
pOperator_ =
  OpsItemEventFilter'
    { $sel:key:OpsItemEventFilter' :: OpsItemEventFilterKey
key = OpsItemEventFilterKey
pKey_,
      $sel:values:OpsItemEventFilter' :: [Text]
values = forall a. Monoid a => a
Prelude.mempty,
      $sel:operator:OpsItemEventFilter' :: OpsItemEventFilterOperator
operator = OpsItemEventFilterOperator
pOperator_
    }

-- | The name of the filter key. Currently, the only supported value is
-- @OpsItemId@.
opsItemEventFilter_key :: Lens.Lens' OpsItemEventFilter OpsItemEventFilterKey
opsItemEventFilter_key :: Lens' OpsItemEventFilter OpsItemEventFilterKey
opsItemEventFilter_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsItemEventFilter' {OpsItemEventFilterKey
key :: OpsItemEventFilterKey
$sel:key:OpsItemEventFilter' :: OpsItemEventFilter -> OpsItemEventFilterKey
key} -> OpsItemEventFilterKey
key) (\s :: OpsItemEventFilter
s@OpsItemEventFilter' {} OpsItemEventFilterKey
a -> OpsItemEventFilter
s {$sel:key:OpsItemEventFilter' :: OpsItemEventFilterKey
key = OpsItemEventFilterKey
a} :: OpsItemEventFilter)

-- | The values for the filter, consisting of one or more OpsItem IDs.
opsItemEventFilter_values :: Lens.Lens' OpsItemEventFilter [Prelude.Text]
opsItemEventFilter_values :: Lens' OpsItemEventFilter [Text]
opsItemEventFilter_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsItemEventFilter' {[Text]
values :: [Text]
$sel:values:OpsItemEventFilter' :: OpsItemEventFilter -> [Text]
values} -> [Text]
values) (\s :: OpsItemEventFilter
s@OpsItemEventFilter' {} [Text]
a -> OpsItemEventFilter
s {$sel:values:OpsItemEventFilter' :: [Text]
values = [Text]
a} :: OpsItemEventFilter) 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 operator used by the filter call. Currently, the only supported
-- value is @Equal@.
opsItemEventFilter_operator :: Lens.Lens' OpsItemEventFilter OpsItemEventFilterOperator
opsItemEventFilter_operator :: Lens' OpsItemEventFilter OpsItemEventFilterOperator
opsItemEventFilter_operator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsItemEventFilter' {OpsItemEventFilterOperator
operator :: OpsItemEventFilterOperator
$sel:operator:OpsItemEventFilter' :: OpsItemEventFilter -> OpsItemEventFilterOperator
operator} -> OpsItemEventFilterOperator
operator) (\s :: OpsItemEventFilter
s@OpsItemEventFilter' {} OpsItemEventFilterOperator
a -> OpsItemEventFilter
s {$sel:operator:OpsItemEventFilter' :: OpsItemEventFilterOperator
operator = OpsItemEventFilterOperator
a} :: OpsItemEventFilter)

instance Prelude.Hashable OpsItemEventFilter where
  hashWithSalt :: Int -> OpsItemEventFilter -> Int
hashWithSalt Int
_salt OpsItemEventFilter' {[Text]
OpsItemEventFilterKey
OpsItemEventFilterOperator
operator :: OpsItemEventFilterOperator
values :: [Text]
key :: OpsItemEventFilterKey
$sel:operator:OpsItemEventFilter' :: OpsItemEventFilter -> OpsItemEventFilterOperator
$sel:values:OpsItemEventFilter' :: OpsItemEventFilter -> [Text]
$sel:key:OpsItemEventFilter' :: OpsItemEventFilter -> OpsItemEventFilterKey
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` OpsItemEventFilterKey
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
values
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` OpsItemEventFilterOperator
operator

instance Prelude.NFData OpsItemEventFilter where
  rnf :: OpsItemEventFilter -> ()
rnf OpsItemEventFilter' {[Text]
OpsItemEventFilterKey
OpsItemEventFilterOperator
operator :: OpsItemEventFilterOperator
values :: [Text]
key :: OpsItemEventFilterKey
$sel:operator:OpsItemEventFilter' :: OpsItemEventFilter -> OpsItemEventFilterOperator
$sel:values:OpsItemEventFilter' :: OpsItemEventFilter -> [Text]
$sel:key:OpsItemEventFilter' :: OpsItemEventFilter -> OpsItemEventFilterKey
..} =
    forall a. NFData a => a -> ()
Prelude.rnf OpsItemEventFilterKey
key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
values
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf OpsItemEventFilterOperator
operator

instance Data.ToJSON OpsItemEventFilter where
  toJSON :: OpsItemEventFilter -> Value
toJSON OpsItemEventFilter' {[Text]
OpsItemEventFilterKey
OpsItemEventFilterOperator
operator :: OpsItemEventFilterOperator
values :: [Text]
key :: OpsItemEventFilterKey
$sel:operator:OpsItemEventFilter' :: OpsItemEventFilter -> OpsItemEventFilterOperator
$sel:values:OpsItemEventFilter' :: OpsItemEventFilter -> [Text]
$sel:key:OpsItemEventFilter' :: OpsItemEventFilter -> OpsItemEventFilterKey
..} =
    [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..= OpsItemEventFilterKey
key),
            forall a. a -> Maybe a
Prelude.Just (Key
"Values" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
values),
            forall a. a -> Maybe a
Prelude.Just (Key
"Operator" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= OpsItemEventFilterOperator
operator)
          ]
      )