{-# 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.StepExecutionFilter
-- 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.StepExecutionFilter 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.StepExecutionFilterKey

-- | A filter to limit the amount of step execution information returned by
-- the call.
--
-- /See:/ 'newStepExecutionFilter' smart constructor.
data StepExecutionFilter = StepExecutionFilter'
  { -- | One or more keys to limit the results. Valid filter keys include the
    -- following: StepName, Action, StepExecutionId, StepExecutionStatus,
    -- StartTimeBefore, StartTimeAfter.
    StepExecutionFilter -> StepExecutionFilterKey
key :: StepExecutionFilterKey,
    -- | The values of the filter key.
    StepExecutionFilter -> NonEmpty Text
values :: Prelude.NonEmpty Prelude.Text
  }
  deriving (StepExecutionFilter -> StepExecutionFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StepExecutionFilter -> StepExecutionFilter -> Bool
$c/= :: StepExecutionFilter -> StepExecutionFilter -> Bool
== :: StepExecutionFilter -> StepExecutionFilter -> Bool
$c== :: StepExecutionFilter -> StepExecutionFilter -> Bool
Prelude.Eq, ReadPrec [StepExecutionFilter]
ReadPrec StepExecutionFilter
Int -> ReadS StepExecutionFilter
ReadS [StepExecutionFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StepExecutionFilter]
$creadListPrec :: ReadPrec [StepExecutionFilter]
readPrec :: ReadPrec StepExecutionFilter
$creadPrec :: ReadPrec StepExecutionFilter
readList :: ReadS [StepExecutionFilter]
$creadList :: ReadS [StepExecutionFilter]
readsPrec :: Int -> ReadS StepExecutionFilter
$creadsPrec :: Int -> ReadS StepExecutionFilter
Prelude.Read, Int -> StepExecutionFilter -> ShowS
[StepExecutionFilter] -> ShowS
StepExecutionFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StepExecutionFilter] -> ShowS
$cshowList :: [StepExecutionFilter] -> ShowS
show :: StepExecutionFilter -> String
$cshow :: StepExecutionFilter -> String
showsPrec :: Int -> StepExecutionFilter -> ShowS
$cshowsPrec :: Int -> StepExecutionFilter -> ShowS
Prelude.Show, forall x. Rep StepExecutionFilter x -> StepExecutionFilter
forall x. StepExecutionFilter -> Rep StepExecutionFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StepExecutionFilter x -> StepExecutionFilter
$cfrom :: forall x. StepExecutionFilter -> Rep StepExecutionFilter x
Prelude.Generic)

-- |
-- Create a value of 'StepExecutionFilter' 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', 'stepExecutionFilter_key' - One or more keys to limit the results. Valid filter keys include the
-- following: StepName, Action, StepExecutionId, StepExecutionStatus,
-- StartTimeBefore, StartTimeAfter.
--
-- 'values', 'stepExecutionFilter_values' - The values of the filter key.
newStepExecutionFilter ::
  -- | 'key'
  StepExecutionFilterKey ->
  -- | 'values'
  Prelude.NonEmpty Prelude.Text ->
  StepExecutionFilter
newStepExecutionFilter :: StepExecutionFilterKey -> NonEmpty Text -> StepExecutionFilter
newStepExecutionFilter StepExecutionFilterKey
pKey_ NonEmpty Text
pValues_ =
  StepExecutionFilter'
    { $sel:key:StepExecutionFilter' :: StepExecutionFilterKey
key = StepExecutionFilterKey
pKey_,
      $sel:values:StepExecutionFilter' :: 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_
    }

-- | One or more keys to limit the results. Valid filter keys include the
-- following: StepName, Action, StepExecutionId, StepExecutionStatus,
-- StartTimeBefore, StartTimeAfter.
stepExecutionFilter_key :: Lens.Lens' StepExecutionFilter StepExecutionFilterKey
stepExecutionFilter_key :: Lens' StepExecutionFilter StepExecutionFilterKey
stepExecutionFilter_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepExecutionFilter' {StepExecutionFilterKey
key :: StepExecutionFilterKey
$sel:key:StepExecutionFilter' :: StepExecutionFilter -> StepExecutionFilterKey
key} -> StepExecutionFilterKey
key) (\s :: StepExecutionFilter
s@StepExecutionFilter' {} StepExecutionFilterKey
a -> StepExecutionFilter
s {$sel:key:StepExecutionFilter' :: StepExecutionFilterKey
key = StepExecutionFilterKey
a} :: StepExecutionFilter)

-- | The values of the filter key.
stepExecutionFilter_values :: Lens.Lens' StepExecutionFilter (Prelude.NonEmpty Prelude.Text)
stepExecutionFilter_values :: Lens' StepExecutionFilter (NonEmpty Text)
stepExecutionFilter_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepExecutionFilter' {NonEmpty Text
values :: NonEmpty Text
$sel:values:StepExecutionFilter' :: StepExecutionFilter -> NonEmpty Text
values} -> NonEmpty Text
values) (\s :: StepExecutionFilter
s@StepExecutionFilter' {} NonEmpty Text
a -> StepExecutionFilter
s {$sel:values:StepExecutionFilter' :: NonEmpty Text
values = NonEmpty Text
a} :: StepExecutionFilter) 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 Prelude.Hashable StepExecutionFilter where
  hashWithSalt :: Int -> StepExecutionFilter -> Int
hashWithSalt Int
_salt StepExecutionFilter' {NonEmpty Text
StepExecutionFilterKey
values :: NonEmpty Text
key :: StepExecutionFilterKey
$sel:values:StepExecutionFilter' :: StepExecutionFilter -> NonEmpty Text
$sel:key:StepExecutionFilter' :: StepExecutionFilter -> StepExecutionFilterKey
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` StepExecutionFilterKey
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
values

instance Prelude.NFData StepExecutionFilter where
  rnf :: StepExecutionFilter -> ()
rnf StepExecutionFilter' {NonEmpty Text
StepExecutionFilterKey
values :: NonEmpty Text
key :: StepExecutionFilterKey
$sel:values:StepExecutionFilter' :: StepExecutionFilter -> NonEmpty Text
$sel:key:StepExecutionFilter' :: StepExecutionFilter -> StepExecutionFilterKey
..} =
    forall a. NFData a => a -> ()
Prelude.rnf StepExecutionFilterKey
key seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
values

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