{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.GetTestGridSession
-- 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)
--
-- A session is an instance of a browser created through a
-- @RemoteWebDriver@ with the URL from CreateTestGridUrlResult$url. You can
-- use the following to look up sessions:
--
-- -   The session ARN (GetTestGridSessionRequest$sessionArn).
--
-- -   The project ARN and a session ID
--     (GetTestGridSessionRequest$projectArn and
--     GetTestGridSessionRequest$sessionId).
module Amazonka.DeviceFarm.GetTestGridSession
  ( -- * Creating a Request
    GetTestGridSession (..),
    newGetTestGridSession,

    -- * Request Lenses
    getTestGridSession_sessionArn,
    getTestGridSession_projectArn,
    getTestGridSession_sessionId,

    -- * Destructuring the Response
    GetTestGridSessionResponse (..),
    newGetTestGridSessionResponse,

    -- * Response Lenses
    getTestGridSessionResponse_testGridSession,
    getTestGridSessionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DeviceFarm.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetTestGridSession' smart constructor.
data GetTestGridSession = GetTestGridSession'
  { -- | An ARN that uniquely identifies a TestGridSession.
    GetTestGridSession -> Maybe Text
sessionArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN for the project that this session belongs to. See
    -- CreateTestGridProject and ListTestGridProjects.
    GetTestGridSession -> Maybe Text
projectArn :: Prelude.Maybe Prelude.Text,
    -- | An ID associated with this session.
    GetTestGridSession -> Maybe Text
sessionId :: Prelude.Maybe Prelude.Text
  }
  deriving (GetTestGridSession -> GetTestGridSession -> Bool
(GetTestGridSession -> GetTestGridSession -> Bool)
-> (GetTestGridSession -> GetTestGridSession -> Bool)
-> Eq GetTestGridSession
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTestGridSession -> GetTestGridSession -> Bool
$c/= :: GetTestGridSession -> GetTestGridSession -> Bool
== :: GetTestGridSession -> GetTestGridSession -> Bool
$c== :: GetTestGridSession -> GetTestGridSession -> Bool
Prelude.Eq, ReadPrec [GetTestGridSession]
ReadPrec GetTestGridSession
Int -> ReadS GetTestGridSession
ReadS [GetTestGridSession]
(Int -> ReadS GetTestGridSession)
-> ReadS [GetTestGridSession]
-> ReadPrec GetTestGridSession
-> ReadPrec [GetTestGridSession]
-> Read GetTestGridSession
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTestGridSession]
$creadListPrec :: ReadPrec [GetTestGridSession]
readPrec :: ReadPrec GetTestGridSession
$creadPrec :: ReadPrec GetTestGridSession
readList :: ReadS [GetTestGridSession]
$creadList :: ReadS [GetTestGridSession]
readsPrec :: Int -> ReadS GetTestGridSession
$creadsPrec :: Int -> ReadS GetTestGridSession
Prelude.Read, Int -> GetTestGridSession -> ShowS
[GetTestGridSession] -> ShowS
GetTestGridSession -> String
(Int -> GetTestGridSession -> ShowS)
-> (GetTestGridSession -> String)
-> ([GetTestGridSession] -> ShowS)
-> Show GetTestGridSession
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTestGridSession] -> ShowS
$cshowList :: [GetTestGridSession] -> ShowS
show :: GetTestGridSession -> String
$cshow :: GetTestGridSession -> String
showsPrec :: Int -> GetTestGridSession -> ShowS
$cshowsPrec :: Int -> GetTestGridSession -> ShowS
Prelude.Show, (forall x. GetTestGridSession -> Rep GetTestGridSession x)
-> (forall x. Rep GetTestGridSession x -> GetTestGridSession)
-> Generic GetTestGridSession
forall x. Rep GetTestGridSession x -> GetTestGridSession
forall x. GetTestGridSession -> Rep GetTestGridSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetTestGridSession x -> GetTestGridSession
$cfrom :: forall x. GetTestGridSession -> Rep GetTestGridSession x
Prelude.Generic)

-- |
-- Create a value of 'GetTestGridSession' 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:
--
-- 'sessionArn', 'getTestGridSession_sessionArn' - An ARN that uniquely identifies a TestGridSession.
--
-- 'projectArn', 'getTestGridSession_projectArn' - The ARN for the project that this session belongs to. See
-- CreateTestGridProject and ListTestGridProjects.
--
-- 'sessionId', 'getTestGridSession_sessionId' - An ID associated with this session.
newGetTestGridSession ::
  GetTestGridSession
newGetTestGridSession :: GetTestGridSession
newGetTestGridSession =
  GetTestGridSession' :: Maybe Text -> Maybe Text -> Maybe Text -> GetTestGridSession
GetTestGridSession'
    { $sel:sessionArn:GetTestGridSession' :: Maybe Text
sessionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:projectArn:GetTestGridSession' :: Maybe Text
projectArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sessionId:GetTestGridSession' :: Maybe Text
sessionId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | An ARN that uniquely identifies a TestGridSession.
getTestGridSession_sessionArn :: Lens.Lens' GetTestGridSession (Prelude.Maybe Prelude.Text)
getTestGridSession_sessionArn :: (Maybe Text -> f (Maybe Text))
-> GetTestGridSession -> f GetTestGridSession
getTestGridSession_sessionArn = (GetTestGridSession -> Maybe Text)
-> (GetTestGridSession -> Maybe Text -> GetTestGridSession)
-> Lens
     GetTestGridSession GetTestGridSession (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTestGridSession' {Maybe Text
sessionArn :: Maybe Text
$sel:sessionArn:GetTestGridSession' :: GetTestGridSession -> Maybe Text
sessionArn} -> Maybe Text
sessionArn) (\s :: GetTestGridSession
s@GetTestGridSession' {} Maybe Text
a -> GetTestGridSession
s {$sel:sessionArn:GetTestGridSession' :: Maybe Text
sessionArn = Maybe Text
a} :: GetTestGridSession)

-- | The ARN for the project that this session belongs to. See
-- CreateTestGridProject and ListTestGridProjects.
getTestGridSession_projectArn :: Lens.Lens' GetTestGridSession (Prelude.Maybe Prelude.Text)
getTestGridSession_projectArn :: (Maybe Text -> f (Maybe Text))
-> GetTestGridSession -> f GetTestGridSession
getTestGridSession_projectArn = (GetTestGridSession -> Maybe Text)
-> (GetTestGridSession -> Maybe Text -> GetTestGridSession)
-> Lens
     GetTestGridSession GetTestGridSession (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTestGridSession' {Maybe Text
projectArn :: Maybe Text
$sel:projectArn:GetTestGridSession' :: GetTestGridSession -> Maybe Text
projectArn} -> Maybe Text
projectArn) (\s :: GetTestGridSession
s@GetTestGridSession' {} Maybe Text
a -> GetTestGridSession
s {$sel:projectArn:GetTestGridSession' :: Maybe Text
projectArn = Maybe Text
a} :: GetTestGridSession)

-- | An ID associated with this session.
getTestGridSession_sessionId :: Lens.Lens' GetTestGridSession (Prelude.Maybe Prelude.Text)
getTestGridSession_sessionId :: (Maybe Text -> f (Maybe Text))
-> GetTestGridSession -> f GetTestGridSession
getTestGridSession_sessionId = (GetTestGridSession -> Maybe Text)
-> (GetTestGridSession -> Maybe Text -> GetTestGridSession)
-> Lens
     GetTestGridSession GetTestGridSession (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTestGridSession' {Maybe Text
sessionId :: Maybe Text
$sel:sessionId:GetTestGridSession' :: GetTestGridSession -> Maybe Text
sessionId} -> Maybe Text
sessionId) (\s :: GetTestGridSession
s@GetTestGridSession' {} Maybe Text
a -> GetTestGridSession
s {$sel:sessionId:GetTestGridSession' :: Maybe Text
sessionId = Maybe Text
a} :: GetTestGridSession)

instance Core.AWSRequest GetTestGridSession where
  type
    AWSResponse GetTestGridSession =
      GetTestGridSessionResponse
  request :: GetTestGridSession -> Request GetTestGridSession
request = Service -> GetTestGridSession -> Request GetTestGridSession
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetTestGridSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetTestGridSession)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetTestGridSession))
-> Logger
-> Service
-> Proxy GetTestGridSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetTestGridSession)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe TestGridSession -> Int -> GetTestGridSessionResponse
GetTestGridSessionResponse'
            (Maybe TestGridSession -> Int -> GetTestGridSessionResponse)
-> Either String (Maybe TestGridSession)
-> Either String (Int -> GetTestGridSessionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe TestGridSession)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"testGridSession")
            Either String (Int -> GetTestGridSessionResponse)
-> Either String Int -> Either String GetTestGridSessionResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetTestGridSession

instance Prelude.NFData GetTestGridSession

instance Core.ToHeaders GetTestGridSession where
  toHeaders :: GetTestGridSession -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetTestGridSession -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"DeviceFarm_20150623.GetTestGridSession" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON GetTestGridSession where
  toJSON :: GetTestGridSession -> Value
toJSON GetTestGridSession' {Maybe Text
sessionId :: Maybe Text
projectArn :: Maybe Text
sessionArn :: Maybe Text
$sel:sessionId:GetTestGridSession' :: GetTestGridSession -> Maybe Text
$sel:projectArn:GetTestGridSession' :: GetTestGridSession -> Maybe Text
$sel:sessionArn:GetTestGridSession' :: GetTestGridSession -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"sessionArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sessionArn,
            (Text
"projectArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
projectArn,
            (Text
"sessionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sessionId
          ]
      )

instance Core.ToPath GetTestGridSession where
  toPath :: GetTestGridSession -> ByteString
toPath = ByteString -> GetTestGridSession -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery GetTestGridSession where
  toQuery :: GetTestGridSession -> QueryString
toQuery = QueryString -> GetTestGridSession -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetTestGridSessionResponse' smart constructor.
data GetTestGridSessionResponse = GetTestGridSessionResponse'
  { -- | The TestGridSession that was requested.
    GetTestGridSessionResponse -> Maybe TestGridSession
testGridSession :: Prelude.Maybe TestGridSession,
    -- | The response's http status code.
    GetTestGridSessionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetTestGridSessionResponse -> GetTestGridSessionResponse -> Bool
(GetTestGridSessionResponse -> GetTestGridSessionResponse -> Bool)
-> (GetTestGridSessionResponse
    -> GetTestGridSessionResponse -> Bool)
-> Eq GetTestGridSessionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTestGridSessionResponse -> GetTestGridSessionResponse -> Bool
$c/= :: GetTestGridSessionResponse -> GetTestGridSessionResponse -> Bool
== :: GetTestGridSessionResponse -> GetTestGridSessionResponse -> Bool
$c== :: GetTestGridSessionResponse -> GetTestGridSessionResponse -> Bool
Prelude.Eq, ReadPrec [GetTestGridSessionResponse]
ReadPrec GetTestGridSessionResponse
Int -> ReadS GetTestGridSessionResponse
ReadS [GetTestGridSessionResponse]
(Int -> ReadS GetTestGridSessionResponse)
-> ReadS [GetTestGridSessionResponse]
-> ReadPrec GetTestGridSessionResponse
-> ReadPrec [GetTestGridSessionResponse]
-> Read GetTestGridSessionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTestGridSessionResponse]
$creadListPrec :: ReadPrec [GetTestGridSessionResponse]
readPrec :: ReadPrec GetTestGridSessionResponse
$creadPrec :: ReadPrec GetTestGridSessionResponse
readList :: ReadS [GetTestGridSessionResponse]
$creadList :: ReadS [GetTestGridSessionResponse]
readsPrec :: Int -> ReadS GetTestGridSessionResponse
$creadsPrec :: Int -> ReadS GetTestGridSessionResponse
Prelude.Read, Int -> GetTestGridSessionResponse -> ShowS
[GetTestGridSessionResponse] -> ShowS
GetTestGridSessionResponse -> String
(Int -> GetTestGridSessionResponse -> ShowS)
-> (GetTestGridSessionResponse -> String)
-> ([GetTestGridSessionResponse] -> ShowS)
-> Show GetTestGridSessionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTestGridSessionResponse] -> ShowS
$cshowList :: [GetTestGridSessionResponse] -> ShowS
show :: GetTestGridSessionResponse -> String
$cshow :: GetTestGridSessionResponse -> String
showsPrec :: Int -> GetTestGridSessionResponse -> ShowS
$cshowsPrec :: Int -> GetTestGridSessionResponse -> ShowS
Prelude.Show, (forall x.
 GetTestGridSessionResponse -> Rep GetTestGridSessionResponse x)
-> (forall x.
    Rep GetTestGridSessionResponse x -> GetTestGridSessionResponse)
-> Generic GetTestGridSessionResponse
forall x.
Rep GetTestGridSessionResponse x -> GetTestGridSessionResponse
forall x.
GetTestGridSessionResponse -> Rep GetTestGridSessionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetTestGridSessionResponse x -> GetTestGridSessionResponse
$cfrom :: forall x.
GetTestGridSessionResponse -> Rep GetTestGridSessionResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetTestGridSessionResponse' 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:
--
-- 'testGridSession', 'getTestGridSessionResponse_testGridSession' - The TestGridSession that was requested.
--
-- 'httpStatus', 'getTestGridSessionResponse_httpStatus' - The response's http status code.
newGetTestGridSessionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetTestGridSessionResponse
newGetTestGridSessionResponse :: Int -> GetTestGridSessionResponse
newGetTestGridSessionResponse Int
pHttpStatus_ =
  GetTestGridSessionResponse' :: Maybe TestGridSession -> Int -> GetTestGridSessionResponse
GetTestGridSessionResponse'
    { $sel:testGridSession:GetTestGridSessionResponse' :: Maybe TestGridSession
testGridSession =
        Maybe TestGridSession
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetTestGridSessionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The TestGridSession that was requested.
getTestGridSessionResponse_testGridSession :: Lens.Lens' GetTestGridSessionResponse (Prelude.Maybe TestGridSession)
getTestGridSessionResponse_testGridSession :: (Maybe TestGridSession -> f (Maybe TestGridSession))
-> GetTestGridSessionResponse -> f GetTestGridSessionResponse
getTestGridSessionResponse_testGridSession = (GetTestGridSessionResponse -> Maybe TestGridSession)
-> (GetTestGridSessionResponse
    -> Maybe TestGridSession -> GetTestGridSessionResponse)
-> Lens
     GetTestGridSessionResponse
     GetTestGridSessionResponse
     (Maybe TestGridSession)
     (Maybe TestGridSession)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTestGridSessionResponse' {Maybe TestGridSession
testGridSession :: Maybe TestGridSession
$sel:testGridSession:GetTestGridSessionResponse' :: GetTestGridSessionResponse -> Maybe TestGridSession
testGridSession} -> Maybe TestGridSession
testGridSession) (\s :: GetTestGridSessionResponse
s@GetTestGridSessionResponse' {} Maybe TestGridSession
a -> GetTestGridSessionResponse
s {$sel:testGridSession:GetTestGridSessionResponse' :: Maybe TestGridSession
testGridSession = Maybe TestGridSession
a} :: GetTestGridSessionResponse)

-- | The response's http status code.
getTestGridSessionResponse_httpStatus :: Lens.Lens' GetTestGridSessionResponse Prelude.Int
getTestGridSessionResponse_httpStatus :: (Int -> f Int)
-> GetTestGridSessionResponse -> f GetTestGridSessionResponse
getTestGridSessionResponse_httpStatus = (GetTestGridSessionResponse -> Int)
-> (GetTestGridSessionResponse
    -> Int -> GetTestGridSessionResponse)
-> Lens
     GetTestGridSessionResponse GetTestGridSessionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTestGridSessionResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetTestGridSessionResponse' :: GetTestGridSessionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetTestGridSessionResponse
s@GetTestGridSessionResponse' {} Int
a -> GetTestGridSessionResponse
s {$sel:httpStatus:GetTestGridSessionResponse' :: Int
httpStatus = Int
a} :: GetTestGridSessionResponse)

instance Prelude.NFData GetTestGridSessionResponse