{-# 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.CodeBuild.Types.DebugSession
-- 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.CodeBuild.Types.DebugSession 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

-- | Contains information about the debug session for a build. For more
-- information, see
-- <https://docs.aws.amazon.com/codebuild/latest/userguide/session-manager.html Viewing a running build in Session Manager>.
--
-- /See:/ 'newDebugSession' smart constructor.
data DebugSession = DebugSession'
  { -- | Specifies if session debugging is enabled for this build.
    DebugSession -> Maybe Bool
sessionEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Contains the identifier of the Session Manager session used for the
    -- build. To work with the paused build, you open this session to examine,
    -- control, and resume the build.
    DebugSession -> Maybe Text
sessionTarget :: Prelude.Maybe Prelude.Text
  }
  deriving (DebugSession -> DebugSession -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DebugSession -> DebugSession -> Bool
$c/= :: DebugSession -> DebugSession -> Bool
== :: DebugSession -> DebugSession -> Bool
$c== :: DebugSession -> DebugSession -> Bool
Prelude.Eq, ReadPrec [DebugSession]
ReadPrec DebugSession
Int -> ReadS DebugSession
ReadS [DebugSession]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DebugSession]
$creadListPrec :: ReadPrec [DebugSession]
readPrec :: ReadPrec DebugSession
$creadPrec :: ReadPrec DebugSession
readList :: ReadS [DebugSession]
$creadList :: ReadS [DebugSession]
readsPrec :: Int -> ReadS DebugSession
$creadsPrec :: Int -> ReadS DebugSession
Prelude.Read, Int -> DebugSession -> ShowS
[DebugSession] -> ShowS
DebugSession -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DebugSession] -> ShowS
$cshowList :: [DebugSession] -> ShowS
show :: DebugSession -> String
$cshow :: DebugSession -> String
showsPrec :: Int -> DebugSession -> ShowS
$cshowsPrec :: Int -> DebugSession -> ShowS
Prelude.Show, forall x. Rep DebugSession x -> DebugSession
forall x. DebugSession -> Rep DebugSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DebugSession x -> DebugSession
$cfrom :: forall x. DebugSession -> Rep DebugSession x
Prelude.Generic)

-- |
-- Create a value of 'DebugSession' 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:
--
-- 'sessionEnabled', 'debugSession_sessionEnabled' - Specifies if session debugging is enabled for this build.
--
-- 'sessionTarget', 'debugSession_sessionTarget' - Contains the identifier of the Session Manager session used for the
-- build. To work with the paused build, you open this session to examine,
-- control, and resume the build.
newDebugSession ::
  DebugSession
newDebugSession :: DebugSession
newDebugSession =
  DebugSession'
    { $sel:sessionEnabled:DebugSession' :: Maybe Bool
sessionEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:sessionTarget:DebugSession' :: Maybe Text
sessionTarget = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies if session debugging is enabled for this build.
debugSession_sessionEnabled :: Lens.Lens' DebugSession (Prelude.Maybe Prelude.Bool)
debugSession_sessionEnabled :: Lens' DebugSession (Maybe Bool)
debugSession_sessionEnabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DebugSession' {Maybe Bool
sessionEnabled :: Maybe Bool
$sel:sessionEnabled:DebugSession' :: DebugSession -> Maybe Bool
sessionEnabled} -> Maybe Bool
sessionEnabled) (\s :: DebugSession
s@DebugSession' {} Maybe Bool
a -> DebugSession
s {$sel:sessionEnabled:DebugSession' :: Maybe Bool
sessionEnabled = Maybe Bool
a} :: DebugSession)

-- | Contains the identifier of the Session Manager session used for the
-- build. To work with the paused build, you open this session to examine,
-- control, and resume the build.
debugSession_sessionTarget :: Lens.Lens' DebugSession (Prelude.Maybe Prelude.Text)
debugSession_sessionTarget :: Lens' DebugSession (Maybe Text)
debugSession_sessionTarget = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DebugSession' {Maybe Text
sessionTarget :: Maybe Text
$sel:sessionTarget:DebugSession' :: DebugSession -> Maybe Text
sessionTarget} -> Maybe Text
sessionTarget) (\s :: DebugSession
s@DebugSession' {} Maybe Text
a -> DebugSession
s {$sel:sessionTarget:DebugSession' :: Maybe Text
sessionTarget = Maybe Text
a} :: DebugSession)

instance Data.FromJSON DebugSession where
  parseJSON :: Value -> Parser DebugSession
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DebugSession"
      ( \Object
x ->
          Maybe Bool -> Maybe Text -> DebugSession
DebugSession'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"sessionEnabled")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"sessionTarget")
      )

instance Prelude.Hashable DebugSession where
  hashWithSalt :: Int -> DebugSession -> Int
hashWithSalt Int
_salt DebugSession' {Maybe Bool
Maybe Text
sessionTarget :: Maybe Text
sessionEnabled :: Maybe Bool
$sel:sessionTarget:DebugSession' :: DebugSession -> Maybe Text
$sel:sessionEnabled:DebugSession' :: DebugSession -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
sessionEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sessionTarget

instance Prelude.NFData DebugSession where
  rnf :: DebugSession -> ()
rnf DebugSession' {Maybe Bool
Maybe Text
sessionTarget :: Maybe Text
sessionEnabled :: Maybe Bool
$sel:sessionTarget:DebugSession' :: DebugSession -> Maybe Text
$sel:sessionEnabled:DebugSession' :: DebugSession -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
sessionEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sessionTarget