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

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

-- | Describes a filter for Session Manager information.
--
-- /See:/ 'newSessionFilter' smart constructor.
data SessionFilter = SessionFilter'
  { -- | The name of the filter.
    SessionFilter -> SessionFilterKey
key :: SessionFilterKey,
    -- | The filter value. Valid values for each filter key are as follows:
    --
    -- -   InvokedAfter: Specify a timestamp to limit your results. For
    --     example, specify 2018-08-29T00:00:00Z to see sessions that started
    --     August 29, 2018, and later.
    --
    -- -   InvokedBefore: Specify a timestamp to limit your results. For
    --     example, specify 2018-08-29T00:00:00Z to see sessions that started
    --     before August 29, 2018.
    --
    -- -   Target: Specify an instance to which session connections have been
    --     made.
    --
    -- -   Owner: Specify an Amazon Web Services user account to see a list of
    --     sessions started by that user.
    --
    -- -   Status: Specify a valid session status to see a list of all sessions
    --     with that status. Status values you can specify include:
    --
    --     -   Connected
    --
    --     -   Connecting
    --
    --     -   Disconnected
    --
    --     -   Terminated
    --
    --     -   Terminating
    --
    --     -   Failed
    --
    -- -   SessionId: Specify a session ID to return details about the session.
    SessionFilter -> Text
value :: Prelude.Text
  }
  deriving (SessionFilter -> SessionFilter -> Bool
(SessionFilter -> SessionFilter -> Bool)
-> (SessionFilter -> SessionFilter -> Bool) -> Eq SessionFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SessionFilter -> SessionFilter -> Bool
$c/= :: SessionFilter -> SessionFilter -> Bool
== :: SessionFilter -> SessionFilter -> Bool
$c== :: SessionFilter -> SessionFilter -> Bool
Prelude.Eq, ReadPrec [SessionFilter]
ReadPrec SessionFilter
Int -> ReadS SessionFilter
ReadS [SessionFilter]
(Int -> ReadS SessionFilter)
-> ReadS [SessionFilter]
-> ReadPrec SessionFilter
-> ReadPrec [SessionFilter]
-> Read SessionFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SessionFilter]
$creadListPrec :: ReadPrec [SessionFilter]
readPrec :: ReadPrec SessionFilter
$creadPrec :: ReadPrec SessionFilter
readList :: ReadS [SessionFilter]
$creadList :: ReadS [SessionFilter]
readsPrec :: Int -> ReadS SessionFilter
$creadsPrec :: Int -> ReadS SessionFilter
Prelude.Read, Int -> SessionFilter -> ShowS
[SessionFilter] -> ShowS
SessionFilter -> String
(Int -> SessionFilter -> ShowS)
-> (SessionFilter -> String)
-> ([SessionFilter] -> ShowS)
-> Show SessionFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SessionFilter] -> ShowS
$cshowList :: [SessionFilter] -> ShowS
show :: SessionFilter -> String
$cshow :: SessionFilter -> String
showsPrec :: Int -> SessionFilter -> ShowS
$cshowsPrec :: Int -> SessionFilter -> ShowS
Prelude.Show, (forall x. SessionFilter -> Rep SessionFilter x)
-> (forall x. Rep SessionFilter x -> SessionFilter)
-> Generic SessionFilter
forall x. Rep SessionFilter x -> SessionFilter
forall x. SessionFilter -> Rep SessionFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SessionFilter x -> SessionFilter
$cfrom :: forall x. SessionFilter -> Rep SessionFilter x
Prelude.Generic)

-- |
-- Create a value of 'SessionFilter' 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', 'sessionFilter_key' - The name of the filter.
--
-- 'value', 'sessionFilter_value' - The filter value. Valid values for each filter key are as follows:
--
-- -   InvokedAfter: Specify a timestamp to limit your results. For
--     example, specify 2018-08-29T00:00:00Z to see sessions that started
--     August 29, 2018, and later.
--
-- -   InvokedBefore: Specify a timestamp to limit your results. For
--     example, specify 2018-08-29T00:00:00Z to see sessions that started
--     before August 29, 2018.
--
-- -   Target: Specify an instance to which session connections have been
--     made.
--
-- -   Owner: Specify an Amazon Web Services user account to see a list of
--     sessions started by that user.
--
-- -   Status: Specify a valid session status to see a list of all sessions
--     with that status. Status values you can specify include:
--
--     -   Connected
--
--     -   Connecting
--
--     -   Disconnected
--
--     -   Terminated
--
--     -   Terminating
--
--     -   Failed
--
-- -   SessionId: Specify a session ID to return details about the session.
newSessionFilter ::
  -- | 'key'
  SessionFilterKey ->
  -- | 'value'
  Prelude.Text ->
  SessionFilter
newSessionFilter :: SessionFilterKey -> Text -> SessionFilter
newSessionFilter SessionFilterKey
pKey_ Text
pValue_ =
  SessionFilter' :: SessionFilterKey -> Text -> SessionFilter
SessionFilter' {$sel:key:SessionFilter' :: SessionFilterKey
key = SessionFilterKey
pKey_, $sel:value:SessionFilter' :: Text
value = Text
pValue_}

-- | The name of the filter.
sessionFilter_key :: Lens.Lens' SessionFilter SessionFilterKey
sessionFilter_key :: (SessionFilterKey -> f SessionFilterKey)
-> SessionFilter -> f SessionFilter
sessionFilter_key = (SessionFilter -> SessionFilterKey)
-> (SessionFilter -> SessionFilterKey -> SessionFilter)
-> Lens
     SessionFilter SessionFilter SessionFilterKey SessionFilterKey
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionFilter' {SessionFilterKey
key :: SessionFilterKey
$sel:key:SessionFilter' :: SessionFilter -> SessionFilterKey
key} -> SessionFilterKey
key) (\s :: SessionFilter
s@SessionFilter' {} SessionFilterKey
a -> SessionFilter
s {$sel:key:SessionFilter' :: SessionFilterKey
key = SessionFilterKey
a} :: SessionFilter)

-- | The filter value. Valid values for each filter key are as follows:
--
-- -   InvokedAfter: Specify a timestamp to limit your results. For
--     example, specify 2018-08-29T00:00:00Z to see sessions that started
--     August 29, 2018, and later.
--
-- -   InvokedBefore: Specify a timestamp to limit your results. For
--     example, specify 2018-08-29T00:00:00Z to see sessions that started
--     before August 29, 2018.
--
-- -   Target: Specify an instance to which session connections have been
--     made.
--
-- -   Owner: Specify an Amazon Web Services user account to see a list of
--     sessions started by that user.
--
-- -   Status: Specify a valid session status to see a list of all sessions
--     with that status. Status values you can specify include:
--
--     -   Connected
--
--     -   Connecting
--
--     -   Disconnected
--
--     -   Terminated
--
--     -   Terminating
--
--     -   Failed
--
-- -   SessionId: Specify a session ID to return details about the session.
sessionFilter_value :: Lens.Lens' SessionFilter Prelude.Text
sessionFilter_value :: (Text -> f Text) -> SessionFilter -> f SessionFilter
sessionFilter_value = (SessionFilter -> Text)
-> (SessionFilter -> Text -> SessionFilter)
-> Lens SessionFilter SessionFilter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SessionFilter' {Text
value :: Text
$sel:value:SessionFilter' :: SessionFilter -> Text
value} -> Text
value) (\s :: SessionFilter
s@SessionFilter' {} Text
a -> SessionFilter
s {$sel:value:SessionFilter' :: Text
value = Text
a} :: SessionFilter)

instance Prelude.Hashable SessionFilter

instance Prelude.NFData SessionFilter

instance Core.ToJSON SessionFilter where
  toJSON :: SessionFilter -> Value
toJSON SessionFilter' {Text
SessionFilterKey
value :: Text
key :: SessionFilterKey
$sel:value:SessionFilter' :: SessionFilter -> Text
$sel:key:SessionFilter' :: SessionFilter -> SessionFilterKey
..} =
    [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 -> SessionFilterKey -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SessionFilterKey
key),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
value)
          ]
      )