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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(DebugSession -> DebugSession -> Bool)
-> (DebugSession -> DebugSession -> Bool) -> Eq DebugSession
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]
(Int -> ReadS DebugSession)
-> ReadS [DebugSession]
-> ReadPrec DebugSession
-> ReadPrec [DebugSession]
-> Read 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
(Int -> DebugSession -> ShowS)
-> (DebugSession -> String)
-> ([DebugSession] -> ShowS)
-> Show DebugSession
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. DebugSession -> Rep DebugSession x)
-> (forall x. Rep DebugSession x -> DebugSession)
-> Generic DebugSession
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' :: Maybe Bool -> Maybe Text -> DebugSession
DebugSession'
    { $sel:sessionEnabled:DebugSession' :: Maybe Bool
sessionEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:sessionTarget:DebugSession' :: Maybe Text
sessionTarget = Maybe Text
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 :: (Maybe Bool -> f (Maybe Bool)) -> DebugSession -> f DebugSession
debugSession_sessionEnabled = (DebugSession -> Maybe Bool)
-> (DebugSession -> Maybe Bool -> DebugSession)
-> Lens DebugSession DebugSession (Maybe Bool) (Maybe Bool)
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 :: (Maybe Text -> f (Maybe Text)) -> DebugSession -> f DebugSession
debugSession_sessionTarget = (DebugSession -> Maybe Text)
-> (DebugSession -> Maybe Text -> DebugSession)
-> Lens DebugSession DebugSession (Maybe Text) (Maybe Text)
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 Core.FromJSON DebugSession where
  parseJSON :: Value -> Parser DebugSession
parseJSON =
    String
-> (Object -> Parser DebugSession) -> Value -> Parser DebugSession
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DebugSession"
      ( \Object
x ->
          Maybe Bool -> Maybe Text -> DebugSession
DebugSession'
            (Maybe Bool -> Maybe Text -> DebugSession)
-> Parser (Maybe Bool) -> Parser (Maybe Text -> DebugSession)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sessionEnabled")
            Parser (Maybe Text -> DebugSession)
-> Parser (Maybe Text) -> Parser DebugSession
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
"sessionTarget")
      )

instance Prelude.Hashable DebugSession

instance Prelude.NFData DebugSession