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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(StepExecutionFilter -> StepExecutionFilter -> Bool)
-> (StepExecutionFilter -> StepExecutionFilter -> Bool)
-> Eq StepExecutionFilter
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]
(Int -> ReadS StepExecutionFilter)
-> ReadS [StepExecutionFilter]
-> ReadPrec StepExecutionFilter
-> ReadPrec [StepExecutionFilter]
-> Read 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
(Int -> StepExecutionFilter -> ShowS)
-> (StepExecutionFilter -> String)
-> ([StepExecutionFilter] -> ShowS)
-> Show StepExecutionFilter
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. StepExecutionFilter -> Rep StepExecutionFilter x)
-> (forall x. Rep StepExecutionFilter x -> StepExecutionFilter)
-> Generic StepExecutionFilter
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' :: StepExecutionFilterKey -> NonEmpty Text -> StepExecutionFilter
StepExecutionFilter'
    { $sel:key:StepExecutionFilter' :: StepExecutionFilterKey
key = StepExecutionFilterKey
pKey_,
      $sel:values:StepExecutionFilter' :: 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_
    }

-- | 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 :: (StepExecutionFilterKey -> f StepExecutionFilterKey)
-> StepExecutionFilter -> f StepExecutionFilter
stepExecutionFilter_key = (StepExecutionFilter -> StepExecutionFilterKey)
-> (StepExecutionFilter
    -> StepExecutionFilterKey -> StepExecutionFilter)
-> Lens
     StepExecutionFilter
     StepExecutionFilter
     StepExecutionFilterKey
     StepExecutionFilterKey
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 :: (NonEmpty Text -> f (NonEmpty Text))
-> StepExecutionFilter -> f StepExecutionFilter
stepExecutionFilter_values = (StepExecutionFilter -> NonEmpty Text)
-> (StepExecutionFilter -> NonEmpty Text -> StepExecutionFilter)
-> Lens
     StepExecutionFilter
     StepExecutionFilter
     (NonEmpty Text)
     (NonEmpty Text)
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) ((NonEmpty Text -> f (NonEmpty Text))
 -> StepExecutionFilter -> f StepExecutionFilter)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> StepExecutionFilter
-> f StepExecutionFilter
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

instance Prelude.Hashable StepExecutionFilter

instance Prelude.NFData StepExecutionFilter

instance Core.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
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 -> StepExecutionFilterKey -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= StepExecutionFilterKey
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)
          ]
      )