{-# 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.DeviceFarm.Types.TestGridSessionAction
-- 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.DeviceFarm.Types.TestGridSessionAction where

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

-- | An action taken by a TestGridSession browser instance.
--
-- /See:/ 'newTestGridSessionAction' smart constructor.
data TestGridSessionAction = TestGridSessionAction'
  { -- | The action taken by the session.
    TestGridSessionAction -> Maybe Text
action :: Prelude.Maybe Prelude.Text,
    -- | The time, in milliseconds, that the action took to complete in the
    -- browser.
    TestGridSessionAction -> Maybe Integer
duration :: Prelude.Maybe Prelude.Integer,
    -- | HTTP method that the browser used to make the request.
    TestGridSessionAction -> Maybe Text
requestMethod :: Prelude.Maybe Prelude.Text,
    -- | The time that the session invoked the action.
    TestGridSessionAction -> Maybe POSIX
started :: Prelude.Maybe Core.POSIX,
    -- | HTTP status code returned to the browser when the action was taken.
    TestGridSessionAction -> Maybe Text
statusCode :: Prelude.Maybe Prelude.Text
  }
  deriving (TestGridSessionAction -> TestGridSessionAction -> Bool
(TestGridSessionAction -> TestGridSessionAction -> Bool)
-> (TestGridSessionAction -> TestGridSessionAction -> Bool)
-> Eq TestGridSessionAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestGridSessionAction -> TestGridSessionAction -> Bool
$c/= :: TestGridSessionAction -> TestGridSessionAction -> Bool
== :: TestGridSessionAction -> TestGridSessionAction -> Bool
$c== :: TestGridSessionAction -> TestGridSessionAction -> Bool
Prelude.Eq, ReadPrec [TestGridSessionAction]
ReadPrec TestGridSessionAction
Int -> ReadS TestGridSessionAction
ReadS [TestGridSessionAction]
(Int -> ReadS TestGridSessionAction)
-> ReadS [TestGridSessionAction]
-> ReadPrec TestGridSessionAction
-> ReadPrec [TestGridSessionAction]
-> Read TestGridSessionAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestGridSessionAction]
$creadListPrec :: ReadPrec [TestGridSessionAction]
readPrec :: ReadPrec TestGridSessionAction
$creadPrec :: ReadPrec TestGridSessionAction
readList :: ReadS [TestGridSessionAction]
$creadList :: ReadS [TestGridSessionAction]
readsPrec :: Int -> ReadS TestGridSessionAction
$creadsPrec :: Int -> ReadS TestGridSessionAction
Prelude.Read, Int -> TestGridSessionAction -> ShowS
[TestGridSessionAction] -> ShowS
TestGridSessionAction -> String
(Int -> TestGridSessionAction -> ShowS)
-> (TestGridSessionAction -> String)
-> ([TestGridSessionAction] -> ShowS)
-> Show TestGridSessionAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestGridSessionAction] -> ShowS
$cshowList :: [TestGridSessionAction] -> ShowS
show :: TestGridSessionAction -> String
$cshow :: TestGridSessionAction -> String
showsPrec :: Int -> TestGridSessionAction -> ShowS
$cshowsPrec :: Int -> TestGridSessionAction -> ShowS
Prelude.Show, (forall x. TestGridSessionAction -> Rep TestGridSessionAction x)
-> (forall x. Rep TestGridSessionAction x -> TestGridSessionAction)
-> Generic TestGridSessionAction
forall x. Rep TestGridSessionAction x -> TestGridSessionAction
forall x. TestGridSessionAction -> Rep TestGridSessionAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TestGridSessionAction x -> TestGridSessionAction
$cfrom :: forall x. TestGridSessionAction -> Rep TestGridSessionAction x
Prelude.Generic)

-- |
-- Create a value of 'TestGridSessionAction' 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:
--
-- 'action', 'testGridSessionAction_action' - The action taken by the session.
--
-- 'duration', 'testGridSessionAction_duration' - The time, in milliseconds, that the action took to complete in the
-- browser.
--
-- 'requestMethod', 'testGridSessionAction_requestMethod' - HTTP method that the browser used to make the request.
--
-- 'started', 'testGridSessionAction_started' - The time that the session invoked the action.
--
-- 'statusCode', 'testGridSessionAction_statusCode' - HTTP status code returned to the browser when the action was taken.
newTestGridSessionAction ::
  TestGridSessionAction
newTestGridSessionAction :: TestGridSessionAction
newTestGridSessionAction =
  TestGridSessionAction' :: Maybe Text
-> Maybe Integer
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> TestGridSessionAction
TestGridSessionAction'
    { $sel:action:TestGridSessionAction' :: Maybe Text
action = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:duration:TestGridSessionAction' :: Maybe Integer
duration = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:requestMethod:TestGridSessionAction' :: Maybe Text
requestMethod = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:started:TestGridSessionAction' :: Maybe POSIX
started = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:statusCode:TestGridSessionAction' :: Maybe Text
statusCode = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The action taken by the session.
testGridSessionAction_action :: Lens.Lens' TestGridSessionAction (Prelude.Maybe Prelude.Text)
testGridSessionAction_action :: (Maybe Text -> f (Maybe Text))
-> TestGridSessionAction -> f TestGridSessionAction
testGridSessionAction_action = (TestGridSessionAction -> Maybe Text)
-> (TestGridSessionAction -> Maybe Text -> TestGridSessionAction)
-> Lens
     TestGridSessionAction
     TestGridSessionAction
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestGridSessionAction' {Maybe Text
action :: Maybe Text
$sel:action:TestGridSessionAction' :: TestGridSessionAction -> Maybe Text
action} -> Maybe Text
action) (\s :: TestGridSessionAction
s@TestGridSessionAction' {} Maybe Text
a -> TestGridSessionAction
s {$sel:action:TestGridSessionAction' :: Maybe Text
action = Maybe Text
a} :: TestGridSessionAction)

-- | The time, in milliseconds, that the action took to complete in the
-- browser.
testGridSessionAction_duration :: Lens.Lens' TestGridSessionAction (Prelude.Maybe Prelude.Integer)
testGridSessionAction_duration :: (Maybe Integer -> f (Maybe Integer))
-> TestGridSessionAction -> f TestGridSessionAction
testGridSessionAction_duration = (TestGridSessionAction -> Maybe Integer)
-> (TestGridSessionAction
    -> Maybe Integer -> TestGridSessionAction)
-> Lens
     TestGridSessionAction
     TestGridSessionAction
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestGridSessionAction' {Maybe Integer
duration :: Maybe Integer
$sel:duration:TestGridSessionAction' :: TestGridSessionAction -> Maybe Integer
duration} -> Maybe Integer
duration) (\s :: TestGridSessionAction
s@TestGridSessionAction' {} Maybe Integer
a -> TestGridSessionAction
s {$sel:duration:TestGridSessionAction' :: Maybe Integer
duration = Maybe Integer
a} :: TestGridSessionAction)

-- | HTTP method that the browser used to make the request.
testGridSessionAction_requestMethod :: Lens.Lens' TestGridSessionAction (Prelude.Maybe Prelude.Text)
testGridSessionAction_requestMethod :: (Maybe Text -> f (Maybe Text))
-> TestGridSessionAction -> f TestGridSessionAction
testGridSessionAction_requestMethod = (TestGridSessionAction -> Maybe Text)
-> (TestGridSessionAction -> Maybe Text -> TestGridSessionAction)
-> Lens
     TestGridSessionAction
     TestGridSessionAction
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestGridSessionAction' {Maybe Text
requestMethod :: Maybe Text
$sel:requestMethod:TestGridSessionAction' :: TestGridSessionAction -> Maybe Text
requestMethod} -> Maybe Text
requestMethod) (\s :: TestGridSessionAction
s@TestGridSessionAction' {} Maybe Text
a -> TestGridSessionAction
s {$sel:requestMethod:TestGridSessionAction' :: Maybe Text
requestMethod = Maybe Text
a} :: TestGridSessionAction)

-- | The time that the session invoked the action.
testGridSessionAction_started :: Lens.Lens' TestGridSessionAction (Prelude.Maybe Prelude.UTCTime)
testGridSessionAction_started :: (Maybe UTCTime -> f (Maybe UTCTime))
-> TestGridSessionAction -> f TestGridSessionAction
testGridSessionAction_started = (TestGridSessionAction -> Maybe POSIX)
-> (TestGridSessionAction -> Maybe POSIX -> TestGridSessionAction)
-> Lens
     TestGridSessionAction
     TestGridSessionAction
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestGridSessionAction' {Maybe POSIX
started :: Maybe POSIX
$sel:started:TestGridSessionAction' :: TestGridSessionAction -> Maybe POSIX
started} -> Maybe POSIX
started) (\s :: TestGridSessionAction
s@TestGridSessionAction' {} Maybe POSIX
a -> TestGridSessionAction
s {$sel:started:TestGridSessionAction' :: Maybe POSIX
started = Maybe POSIX
a} :: TestGridSessionAction) ((Maybe POSIX -> f (Maybe POSIX))
 -> TestGridSessionAction -> f TestGridSessionAction)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TestGridSessionAction
-> f TestGridSessionAction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | HTTP status code returned to the browser when the action was taken.
testGridSessionAction_statusCode :: Lens.Lens' TestGridSessionAction (Prelude.Maybe Prelude.Text)
testGridSessionAction_statusCode :: (Maybe Text -> f (Maybe Text))
-> TestGridSessionAction -> f TestGridSessionAction
testGridSessionAction_statusCode = (TestGridSessionAction -> Maybe Text)
-> (TestGridSessionAction -> Maybe Text -> TestGridSessionAction)
-> Lens
     TestGridSessionAction
     TestGridSessionAction
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestGridSessionAction' {Maybe Text
statusCode :: Maybe Text
$sel:statusCode:TestGridSessionAction' :: TestGridSessionAction -> Maybe Text
statusCode} -> Maybe Text
statusCode) (\s :: TestGridSessionAction
s@TestGridSessionAction' {} Maybe Text
a -> TestGridSessionAction
s {$sel:statusCode:TestGridSessionAction' :: Maybe Text
statusCode = Maybe Text
a} :: TestGridSessionAction)

instance Core.FromJSON TestGridSessionAction where
  parseJSON :: Value -> Parser TestGridSessionAction
parseJSON =
    String
-> (Object -> Parser TestGridSessionAction)
-> Value
-> Parser TestGridSessionAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TestGridSessionAction"
      ( \Object
x ->
          Maybe Text
-> Maybe Integer
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> TestGridSessionAction
TestGridSessionAction'
            (Maybe Text
 -> Maybe Integer
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> TestGridSessionAction)
-> Parser (Maybe Text)
-> Parser
     (Maybe Integer
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> TestGridSessionAction)
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
"action")
            Parser
  (Maybe Integer
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> TestGridSessionAction)
-> Parser (Maybe Integer)
-> Parser
     (Maybe Text -> Maybe POSIX -> Maybe Text -> TestGridSessionAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"duration")
            Parser
  (Maybe Text -> Maybe POSIX -> Maybe Text -> TestGridSessionAction)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Text -> TestGridSessionAction)
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
"requestMethod")
            Parser (Maybe POSIX -> Maybe Text -> TestGridSessionAction)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> TestGridSessionAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"started")
            Parser (Maybe Text -> TestGridSessionAction)
-> Parser (Maybe Text) -> Parser TestGridSessionAction
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
"statusCode")
      )

instance Prelude.Hashable TestGridSessionAction

instance Prelude.NFData TestGridSessionAction