{-# 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.ECS.Types.Session
-- 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.ECS.Types.Session where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The details of the execute command session.
--
-- /See:/ 'newSession' smart constructor.
data Session = Session'
  { -- | A URL back to managed agent on the container that the SSM Session
    -- Manager client uses to send commands and receive output from the
    -- container.
    Session -> Maybe Text
streamUrl :: Prelude.Maybe Prelude.Text,
    -- | An encrypted token value containing session and caller information. Used
    -- to authenticate the connection to the container.
    Session -> Maybe (Sensitive Text)
tokenValue :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The ID of the execute command session.
    Session -> Maybe Text
sessionId :: Prelude.Maybe Prelude.Text
  }
  deriving (Session -> Session -> Bool
(Session -> Session -> Bool)
-> (Session -> Session -> Bool) -> Eq Session
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Session -> Session -> Bool
$c/= :: Session -> Session -> Bool
== :: Session -> Session -> Bool
$c== :: Session -> Session -> Bool
Prelude.Eq, Int -> Session -> ShowS
[Session] -> ShowS
Session -> String
(Int -> Session -> ShowS)
-> (Session -> String) -> ([Session] -> ShowS) -> Show Session
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Session] -> ShowS
$cshowList :: [Session] -> ShowS
show :: Session -> String
$cshow :: Session -> String
showsPrec :: Int -> Session -> ShowS
$cshowsPrec :: Int -> Session -> ShowS
Prelude.Show, (forall x. Session -> Rep Session x)
-> (forall x. Rep Session x -> Session) -> Generic Session
forall x. Rep Session x -> Session
forall x. Session -> Rep Session x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Session x -> Session
$cfrom :: forall x. Session -> Rep Session x
Prelude.Generic)

-- |
-- Create a value of 'Session' 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:
--
-- 'streamUrl', 'session_streamUrl' - A URL back to managed agent on the container that the SSM Session
-- Manager client uses to send commands and receive output from the
-- container.
--
-- 'tokenValue', 'session_tokenValue' - An encrypted token value containing session and caller information. Used
-- to authenticate the connection to the container.
--
-- 'sessionId', 'session_sessionId' - The ID of the execute command session.
newSession ::
  Session
newSession :: Session
newSession =
  Session' :: Maybe Text -> Maybe (Sensitive Text) -> Maybe Text -> Session
Session'
    { $sel:streamUrl:Session' :: Maybe Text
streamUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tokenValue:Session' :: Maybe (Sensitive Text)
tokenValue = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:sessionId:Session' :: Maybe Text
sessionId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A URL back to managed agent on the container that the SSM Session
-- Manager client uses to send commands and receive output from the
-- container.
session_streamUrl :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_streamUrl :: (Maybe Text -> f (Maybe Text)) -> Session -> f Session
session_streamUrl = (Session -> Maybe Text)
-> (Session -> Maybe Text -> Session)
-> Lens Session Session (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe Text
streamUrl :: Maybe Text
$sel:streamUrl:Session' :: Session -> Maybe Text
streamUrl} -> Maybe Text
streamUrl) (\s :: Session
s@Session' {} Maybe Text
a -> Session
s {$sel:streamUrl:Session' :: Maybe Text
streamUrl = Maybe Text
a} :: Session)

-- | An encrypted token value containing session and caller information. Used
-- to authenticate the connection to the container.
session_tokenValue :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_tokenValue :: (Maybe Text -> f (Maybe Text)) -> Session -> f Session
session_tokenValue = (Session -> Maybe (Sensitive Text))
-> (Session -> Maybe (Sensitive Text) -> Session)
-> Lens
     Session Session (Maybe (Sensitive Text)) (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe (Sensitive Text)
tokenValue :: Maybe (Sensitive Text)
$sel:tokenValue:Session' :: Session -> Maybe (Sensitive Text)
tokenValue} -> Maybe (Sensitive Text)
tokenValue) (\s :: Session
s@Session' {} Maybe (Sensitive Text)
a -> Session
s {$sel:tokenValue:Session' :: Maybe (Sensitive Text)
tokenValue = Maybe (Sensitive Text)
a} :: Session) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> Session -> f Session)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> Session
-> f Session
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The ID of the execute command session.
session_sessionId :: Lens.Lens' Session (Prelude.Maybe Prelude.Text)
session_sessionId :: (Maybe Text -> f (Maybe Text)) -> Session -> f Session
session_sessionId = (Session -> Maybe Text)
-> (Session -> Maybe Text -> Session)
-> Lens Session Session (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Session' {Maybe Text
sessionId :: Maybe Text
$sel:sessionId:Session' :: Session -> Maybe Text
sessionId} -> Maybe Text
sessionId) (\s :: Session
s@Session' {} Maybe Text
a -> Session
s {$sel:sessionId:Session' :: Maybe Text
sessionId = Maybe Text
a} :: Session)

instance Core.FromJSON Session where
  parseJSON :: Value -> Parser Session
parseJSON =
    String -> (Object -> Parser Session) -> Value -> Parser Session
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Session"
      ( \Object
x ->
          Maybe Text -> Maybe (Sensitive Text) -> Maybe Text -> Session
Session'
            (Maybe Text -> Maybe (Sensitive Text) -> Maybe Text -> Session)
-> Parser (Maybe Text)
-> Parser (Maybe (Sensitive Text) -> Maybe Text -> Session)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"streamUrl")
            Parser (Maybe (Sensitive Text) -> Maybe Text -> Session)
-> Parser (Maybe (Sensitive Text))
-> Parser (Maybe Text -> Session)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tokenValue")
            Parser (Maybe Text -> Session)
-> Parser (Maybe Text) -> Parser Session
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sessionId")
      )

instance Prelude.Hashable Session

instance Prelude.NFData Session