{-# 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.GetRemoteAccessSession
-- 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)
--
-- Returns a link to a currently running remote access session.
module Amazonka.DeviceFarm.GetRemoteAccessSession
  ( -- * Creating a Request
    GetRemoteAccessSession (..),
    newGetRemoteAccessSession,

    -- * Request Lenses
    getRemoteAccessSession_arn,

    -- * Destructuring the Response
    GetRemoteAccessSessionResponse (..),
    newGetRemoteAccessSessionResponse,

    -- * Response Lenses
    getRemoteAccessSessionResponse_remoteAccessSession,
    getRemoteAccessSessionResponse_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

-- | Represents the request to get information about the specified remote
-- access session.
--
-- /See:/ 'newGetRemoteAccessSession' smart constructor.
data GetRemoteAccessSession = GetRemoteAccessSession'
  { -- | The Amazon Resource Name (ARN) of the remote access session about which
    -- you want to get session information.
    GetRemoteAccessSession -> Text
arn :: Prelude.Text
  }
  deriving (GetRemoteAccessSession -> GetRemoteAccessSession -> Bool
(GetRemoteAccessSession -> GetRemoteAccessSession -> Bool)
-> (GetRemoteAccessSession -> GetRemoteAccessSession -> Bool)
-> Eq GetRemoteAccessSession
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRemoteAccessSession -> GetRemoteAccessSession -> Bool
$c/= :: GetRemoteAccessSession -> GetRemoteAccessSession -> Bool
== :: GetRemoteAccessSession -> GetRemoteAccessSession -> Bool
$c== :: GetRemoteAccessSession -> GetRemoteAccessSession -> Bool
Prelude.Eq, ReadPrec [GetRemoteAccessSession]
ReadPrec GetRemoteAccessSession
Int -> ReadS GetRemoteAccessSession
ReadS [GetRemoteAccessSession]
(Int -> ReadS GetRemoteAccessSession)
-> ReadS [GetRemoteAccessSession]
-> ReadPrec GetRemoteAccessSession
-> ReadPrec [GetRemoteAccessSession]
-> Read GetRemoteAccessSession
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRemoteAccessSession]
$creadListPrec :: ReadPrec [GetRemoteAccessSession]
readPrec :: ReadPrec GetRemoteAccessSession
$creadPrec :: ReadPrec GetRemoteAccessSession
readList :: ReadS [GetRemoteAccessSession]
$creadList :: ReadS [GetRemoteAccessSession]
readsPrec :: Int -> ReadS GetRemoteAccessSession
$creadsPrec :: Int -> ReadS GetRemoteAccessSession
Prelude.Read, Int -> GetRemoteAccessSession -> ShowS
[GetRemoteAccessSession] -> ShowS
GetRemoteAccessSession -> String
(Int -> GetRemoteAccessSession -> ShowS)
-> (GetRemoteAccessSession -> String)
-> ([GetRemoteAccessSession] -> ShowS)
-> Show GetRemoteAccessSession
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRemoteAccessSession] -> ShowS
$cshowList :: [GetRemoteAccessSession] -> ShowS
show :: GetRemoteAccessSession -> String
$cshow :: GetRemoteAccessSession -> String
showsPrec :: Int -> GetRemoteAccessSession -> ShowS
$cshowsPrec :: Int -> GetRemoteAccessSession -> ShowS
Prelude.Show, (forall x. GetRemoteAccessSession -> Rep GetRemoteAccessSession x)
-> (forall x.
    Rep GetRemoteAccessSession x -> GetRemoteAccessSession)
-> Generic GetRemoteAccessSession
forall x. Rep GetRemoteAccessSession x -> GetRemoteAccessSession
forall x. GetRemoteAccessSession -> Rep GetRemoteAccessSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRemoteAccessSession x -> GetRemoteAccessSession
$cfrom :: forall x. GetRemoteAccessSession -> Rep GetRemoteAccessSession x
Prelude.Generic)

-- |
-- Create a value of 'GetRemoteAccessSession' 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:
--
-- 'arn', 'getRemoteAccessSession_arn' - The Amazon Resource Name (ARN) of the remote access session about which
-- you want to get session information.
newGetRemoteAccessSession ::
  -- | 'arn'
  Prelude.Text ->
  GetRemoteAccessSession
newGetRemoteAccessSession :: Text -> GetRemoteAccessSession
newGetRemoteAccessSession Text
pArn_ =
  GetRemoteAccessSession' :: Text -> GetRemoteAccessSession
GetRemoteAccessSession' {$sel:arn:GetRemoteAccessSession' :: Text
arn = Text
pArn_}

-- | The Amazon Resource Name (ARN) of the remote access session about which
-- you want to get session information.
getRemoteAccessSession_arn :: Lens.Lens' GetRemoteAccessSession Prelude.Text
getRemoteAccessSession_arn :: (Text -> f Text)
-> GetRemoteAccessSession -> f GetRemoteAccessSession
getRemoteAccessSession_arn = (GetRemoteAccessSession -> Text)
-> (GetRemoteAccessSession -> Text -> GetRemoteAccessSession)
-> Lens GetRemoteAccessSession GetRemoteAccessSession Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRemoteAccessSession' {Text
arn :: Text
$sel:arn:GetRemoteAccessSession' :: GetRemoteAccessSession -> Text
arn} -> Text
arn) (\s :: GetRemoteAccessSession
s@GetRemoteAccessSession' {} Text
a -> GetRemoteAccessSession
s {$sel:arn:GetRemoteAccessSession' :: Text
arn = Text
a} :: GetRemoteAccessSession)

instance Core.AWSRequest GetRemoteAccessSession where
  type
    AWSResponse GetRemoteAccessSession =
      GetRemoteAccessSessionResponse
  request :: GetRemoteAccessSession -> Request GetRemoteAccessSession
request = Service -> GetRemoteAccessSession -> Request GetRemoteAccessSession
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetRemoteAccessSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetRemoteAccessSession)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetRemoteAccessSession))
-> Logger
-> Service
-> Proxy GetRemoteAccessSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetRemoteAccessSession)))
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 RemoteAccessSession -> Int -> GetRemoteAccessSessionResponse
GetRemoteAccessSessionResponse'
            (Maybe RemoteAccessSession
 -> Int -> GetRemoteAccessSessionResponse)
-> Either String (Maybe RemoteAccessSession)
-> Either String (Int -> GetRemoteAccessSessionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe RemoteAccessSession)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"remoteAccessSession")
            Either String (Int -> GetRemoteAccessSessionResponse)
-> Either String Int
-> Either String GetRemoteAccessSessionResponse
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 GetRemoteAccessSession

instance Prelude.NFData GetRemoteAccessSession

instance Core.ToHeaders GetRemoteAccessSession where
  toHeaders :: GetRemoteAccessSession -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetRemoteAccessSession -> 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.GetRemoteAccessSession" ::
                          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 GetRemoteAccessSession where
  toJSON :: GetRemoteAccessSession -> Value
toJSON GetRemoteAccessSession' {Text
arn :: Text
$sel:arn:GetRemoteAccessSession' :: GetRemoteAccessSession -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"arn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
arn)]
      )

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

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

-- | Represents the response from the server that lists detailed information
-- about the remote access session.
--
-- /See:/ 'newGetRemoteAccessSessionResponse' smart constructor.
data GetRemoteAccessSessionResponse = GetRemoteAccessSessionResponse'
  { -- | A container that lists detailed information about the remote access
    -- session.
    GetRemoteAccessSessionResponse -> Maybe RemoteAccessSession
remoteAccessSession :: Prelude.Maybe RemoteAccessSession,
    -- | The response's http status code.
    GetRemoteAccessSessionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetRemoteAccessSessionResponse
-> GetRemoteAccessSessionResponse -> Bool
(GetRemoteAccessSessionResponse
 -> GetRemoteAccessSessionResponse -> Bool)
-> (GetRemoteAccessSessionResponse
    -> GetRemoteAccessSessionResponse -> Bool)
-> Eq GetRemoteAccessSessionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRemoteAccessSessionResponse
-> GetRemoteAccessSessionResponse -> Bool
$c/= :: GetRemoteAccessSessionResponse
-> GetRemoteAccessSessionResponse -> Bool
== :: GetRemoteAccessSessionResponse
-> GetRemoteAccessSessionResponse -> Bool
$c== :: GetRemoteAccessSessionResponse
-> GetRemoteAccessSessionResponse -> Bool
Prelude.Eq, ReadPrec [GetRemoteAccessSessionResponse]
ReadPrec GetRemoteAccessSessionResponse
Int -> ReadS GetRemoteAccessSessionResponse
ReadS [GetRemoteAccessSessionResponse]
(Int -> ReadS GetRemoteAccessSessionResponse)
-> ReadS [GetRemoteAccessSessionResponse]
-> ReadPrec GetRemoteAccessSessionResponse
-> ReadPrec [GetRemoteAccessSessionResponse]
-> Read GetRemoteAccessSessionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRemoteAccessSessionResponse]
$creadListPrec :: ReadPrec [GetRemoteAccessSessionResponse]
readPrec :: ReadPrec GetRemoteAccessSessionResponse
$creadPrec :: ReadPrec GetRemoteAccessSessionResponse
readList :: ReadS [GetRemoteAccessSessionResponse]
$creadList :: ReadS [GetRemoteAccessSessionResponse]
readsPrec :: Int -> ReadS GetRemoteAccessSessionResponse
$creadsPrec :: Int -> ReadS GetRemoteAccessSessionResponse
Prelude.Read, Int -> GetRemoteAccessSessionResponse -> ShowS
[GetRemoteAccessSessionResponse] -> ShowS
GetRemoteAccessSessionResponse -> String
(Int -> GetRemoteAccessSessionResponse -> ShowS)
-> (GetRemoteAccessSessionResponse -> String)
-> ([GetRemoteAccessSessionResponse] -> ShowS)
-> Show GetRemoteAccessSessionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRemoteAccessSessionResponse] -> ShowS
$cshowList :: [GetRemoteAccessSessionResponse] -> ShowS
show :: GetRemoteAccessSessionResponse -> String
$cshow :: GetRemoteAccessSessionResponse -> String
showsPrec :: Int -> GetRemoteAccessSessionResponse -> ShowS
$cshowsPrec :: Int -> GetRemoteAccessSessionResponse -> ShowS
Prelude.Show, (forall x.
 GetRemoteAccessSessionResponse
 -> Rep GetRemoteAccessSessionResponse x)
-> (forall x.
    Rep GetRemoteAccessSessionResponse x
    -> GetRemoteAccessSessionResponse)
-> Generic GetRemoteAccessSessionResponse
forall x.
Rep GetRemoteAccessSessionResponse x
-> GetRemoteAccessSessionResponse
forall x.
GetRemoteAccessSessionResponse
-> Rep GetRemoteAccessSessionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetRemoteAccessSessionResponse x
-> GetRemoteAccessSessionResponse
$cfrom :: forall x.
GetRemoteAccessSessionResponse
-> Rep GetRemoteAccessSessionResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetRemoteAccessSessionResponse' 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:
--
-- 'remoteAccessSession', 'getRemoteAccessSessionResponse_remoteAccessSession' - A container that lists detailed information about the remote access
-- session.
--
-- 'httpStatus', 'getRemoteAccessSessionResponse_httpStatus' - The response's http status code.
newGetRemoteAccessSessionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetRemoteAccessSessionResponse
newGetRemoteAccessSessionResponse :: Int -> GetRemoteAccessSessionResponse
newGetRemoteAccessSessionResponse Int
pHttpStatus_ =
  GetRemoteAccessSessionResponse' :: Maybe RemoteAccessSession -> Int -> GetRemoteAccessSessionResponse
GetRemoteAccessSessionResponse'
    { $sel:remoteAccessSession:GetRemoteAccessSessionResponse' :: Maybe RemoteAccessSession
remoteAccessSession =
        Maybe RemoteAccessSession
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetRemoteAccessSessionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A container that lists detailed information about the remote access
-- session.
getRemoteAccessSessionResponse_remoteAccessSession :: Lens.Lens' GetRemoteAccessSessionResponse (Prelude.Maybe RemoteAccessSession)
getRemoteAccessSessionResponse_remoteAccessSession :: (Maybe RemoteAccessSession -> f (Maybe RemoteAccessSession))
-> GetRemoteAccessSessionResponse
-> f GetRemoteAccessSessionResponse
getRemoteAccessSessionResponse_remoteAccessSession = (GetRemoteAccessSessionResponse -> Maybe RemoteAccessSession)
-> (GetRemoteAccessSessionResponse
    -> Maybe RemoteAccessSession -> GetRemoteAccessSessionResponse)
-> Lens
     GetRemoteAccessSessionResponse
     GetRemoteAccessSessionResponse
     (Maybe RemoteAccessSession)
     (Maybe RemoteAccessSession)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRemoteAccessSessionResponse' {Maybe RemoteAccessSession
remoteAccessSession :: Maybe RemoteAccessSession
$sel:remoteAccessSession:GetRemoteAccessSessionResponse' :: GetRemoteAccessSessionResponse -> Maybe RemoteAccessSession
remoteAccessSession} -> Maybe RemoteAccessSession
remoteAccessSession) (\s :: GetRemoteAccessSessionResponse
s@GetRemoteAccessSessionResponse' {} Maybe RemoteAccessSession
a -> GetRemoteAccessSessionResponse
s {$sel:remoteAccessSession:GetRemoteAccessSessionResponse' :: Maybe RemoteAccessSession
remoteAccessSession = Maybe RemoteAccessSession
a} :: GetRemoteAccessSessionResponse)

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

instance
  Prelude.NFData
    GetRemoteAccessSessionResponse