{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DeviceFarm.Types
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
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]
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
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. 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' {$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 :: Lens' GetRemoteAccessSession Text
getRemoteAccessSession_arn = 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 :: (Service -> Service)
-> GetRemoteAccessSession -> Request GetRemoteAccessSession
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetRemoteAccessSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetRemoteAccessSession)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe RemoteAccessSession -> Int -> GetRemoteAccessSessionResponse
GetRemoteAccessSessionResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"remoteAccessSession")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetRemoteAccessSession where
  hashWithSalt :: Int -> GetRemoteAccessSession -> Int
hashWithSalt Int
_salt GetRemoteAccessSession' {Text
arn :: Text
$sel:arn:GetRemoteAccessSession' :: GetRemoteAccessSession -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

instance Prelude.NFData GetRemoteAccessSession where
  rnf :: GetRemoteAccessSession -> ()
rnf GetRemoteAccessSession' {Text
arn :: Text
$sel:arn:GetRemoteAccessSession' :: GetRemoteAccessSession -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
arn

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

instance Data.ToJSON GetRemoteAccessSession where
  toJSON :: GetRemoteAccessSession -> Value
toJSON GetRemoteAccessSession' {Text
arn :: Text
$sel:arn:GetRemoteAccessSession' :: GetRemoteAccessSession -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"arn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
arn)]
      )

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

instance Data.ToQuery GetRemoteAccessSession where
  toQuery :: GetRemoteAccessSession -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:remoteAccessSession:GetRemoteAccessSessionResponse' :: Maybe RemoteAccessSession
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 :: Lens' GetRemoteAccessSessionResponse (Maybe RemoteAccessSession)
getRemoteAccessSessionResponse_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 :: Lens' GetRemoteAccessSessionResponse Int
getRemoteAccessSessionResponse_httpStatus = 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
  where
  rnf :: GetRemoteAccessSessionResponse -> ()
rnf GetRemoteAccessSessionResponse' {Int
Maybe RemoteAccessSession
httpStatus :: Int
remoteAccessSession :: Maybe RemoteAccessSession
$sel:httpStatus:GetRemoteAccessSessionResponse' :: GetRemoteAccessSessionResponse -> Int
$sel:remoteAccessSession:GetRemoteAccessSessionResponse' :: GetRemoteAccessSessionResponse -> Maybe RemoteAccessSession
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RemoteAccessSession
remoteAccessSession
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus