{-# 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.StopRemoteAccessSession
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Ends a specified remote access session.
module Amazonka.DeviceFarm.StopRemoteAccessSession
  ( -- * Creating a Request
    StopRemoteAccessSession (..),
    newStopRemoteAccessSession,

    -- * Request Lenses
    stopRemoteAccessSession_arn,

    -- * Destructuring the Response
    StopRemoteAccessSessionResponse (..),
    newStopRemoteAccessSessionResponse,

    -- * Response Lenses
    stopRemoteAccessSessionResponse_remoteAccessSession,
    stopRemoteAccessSessionResponse_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 stop the remote access session.
--
-- /See:/ 'newStopRemoteAccessSession' smart constructor.
data StopRemoteAccessSession = StopRemoteAccessSession'
  { -- | The Amazon Resource Name (ARN) of the remote access session to stop.
    StopRemoteAccessSession -> Text
arn :: Prelude.Text
  }
  deriving (StopRemoteAccessSession -> StopRemoteAccessSession -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopRemoteAccessSession -> StopRemoteAccessSession -> Bool
$c/= :: StopRemoteAccessSession -> StopRemoteAccessSession -> Bool
== :: StopRemoteAccessSession -> StopRemoteAccessSession -> Bool
$c== :: StopRemoteAccessSession -> StopRemoteAccessSession -> Bool
Prelude.Eq, ReadPrec [StopRemoteAccessSession]
ReadPrec StopRemoteAccessSession
Int -> ReadS StopRemoteAccessSession
ReadS [StopRemoteAccessSession]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopRemoteAccessSession]
$creadListPrec :: ReadPrec [StopRemoteAccessSession]
readPrec :: ReadPrec StopRemoteAccessSession
$creadPrec :: ReadPrec StopRemoteAccessSession
readList :: ReadS [StopRemoteAccessSession]
$creadList :: ReadS [StopRemoteAccessSession]
readsPrec :: Int -> ReadS StopRemoteAccessSession
$creadsPrec :: Int -> ReadS StopRemoteAccessSession
Prelude.Read, Int -> StopRemoteAccessSession -> ShowS
[StopRemoteAccessSession] -> ShowS
StopRemoteAccessSession -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopRemoteAccessSession] -> ShowS
$cshowList :: [StopRemoteAccessSession] -> ShowS
show :: StopRemoteAccessSession -> String
$cshow :: StopRemoteAccessSession -> String
showsPrec :: Int -> StopRemoteAccessSession -> ShowS
$cshowsPrec :: Int -> StopRemoteAccessSession -> ShowS
Prelude.Show, forall x. Rep StopRemoteAccessSession x -> StopRemoteAccessSession
forall x. StopRemoteAccessSession -> Rep StopRemoteAccessSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopRemoteAccessSession x -> StopRemoteAccessSession
$cfrom :: forall x. StopRemoteAccessSession -> Rep StopRemoteAccessSession x
Prelude.Generic)

-- |
-- Create a value of 'StopRemoteAccessSession' 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', 'stopRemoteAccessSession_arn' - The Amazon Resource Name (ARN) of the remote access session to stop.
newStopRemoteAccessSession ::
  -- | 'arn'
  Prelude.Text ->
  StopRemoteAccessSession
newStopRemoteAccessSession :: Text -> StopRemoteAccessSession
newStopRemoteAccessSession Text
pArn_ =
  StopRemoteAccessSession' {$sel:arn:StopRemoteAccessSession' :: Text
arn = Text
pArn_}

-- | The Amazon Resource Name (ARN) of the remote access session to stop.
stopRemoteAccessSession_arn :: Lens.Lens' StopRemoteAccessSession Prelude.Text
stopRemoteAccessSession_arn :: Lens' StopRemoteAccessSession Text
stopRemoteAccessSession_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopRemoteAccessSession' {Text
arn :: Text
$sel:arn:StopRemoteAccessSession' :: StopRemoteAccessSession -> Text
arn} -> Text
arn) (\s :: StopRemoteAccessSession
s@StopRemoteAccessSession' {} Text
a -> StopRemoteAccessSession
s {$sel:arn:StopRemoteAccessSession' :: Text
arn = Text
a} :: StopRemoteAccessSession)

instance Core.AWSRequest StopRemoteAccessSession where
  type
    AWSResponse StopRemoteAccessSession =
      StopRemoteAccessSessionResponse
  request :: (Service -> Service)
-> StopRemoteAccessSession -> Request StopRemoteAccessSession
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 StopRemoteAccessSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopRemoteAccessSession)))
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 -> StopRemoteAccessSessionResponse
StopRemoteAccessSessionResponse'
            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 StopRemoteAccessSession where
  hashWithSalt :: Int -> StopRemoteAccessSession -> Int
hashWithSalt Int
_salt StopRemoteAccessSession' {Text
arn :: Text
$sel:arn:StopRemoteAccessSession' :: StopRemoteAccessSession -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

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

instance Data.ToHeaders StopRemoteAccessSession where
  toHeaders :: StopRemoteAccessSession -> 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.StopRemoteAccessSession" ::
                          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 StopRemoteAccessSession where
  toJSON :: StopRemoteAccessSession -> Value
toJSON StopRemoteAccessSession' {Text
arn :: Text
$sel:arn:StopRemoteAccessSession' :: StopRemoteAccessSession -> 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 StopRemoteAccessSession where
  toPath :: StopRemoteAccessSession -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | Represents the response from the server that describes the remote access
-- session when AWS Device Farm stops the session.
--
-- /See:/ 'newStopRemoteAccessSessionResponse' smart constructor.
data StopRemoteAccessSessionResponse = StopRemoteAccessSessionResponse'
  { -- | A container that represents the metadata from the service about the
    -- remote access session you are stopping.
    StopRemoteAccessSessionResponse -> Maybe RemoteAccessSession
remoteAccessSession :: Prelude.Maybe RemoteAccessSession,
    -- | The response's http status code.
    StopRemoteAccessSessionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StopRemoteAccessSessionResponse
-> StopRemoteAccessSessionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopRemoteAccessSessionResponse
-> StopRemoteAccessSessionResponse -> Bool
$c/= :: StopRemoteAccessSessionResponse
-> StopRemoteAccessSessionResponse -> Bool
== :: StopRemoteAccessSessionResponse
-> StopRemoteAccessSessionResponse -> Bool
$c== :: StopRemoteAccessSessionResponse
-> StopRemoteAccessSessionResponse -> Bool
Prelude.Eq, ReadPrec [StopRemoteAccessSessionResponse]
ReadPrec StopRemoteAccessSessionResponse
Int -> ReadS StopRemoteAccessSessionResponse
ReadS [StopRemoteAccessSessionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopRemoteAccessSessionResponse]
$creadListPrec :: ReadPrec [StopRemoteAccessSessionResponse]
readPrec :: ReadPrec StopRemoteAccessSessionResponse
$creadPrec :: ReadPrec StopRemoteAccessSessionResponse
readList :: ReadS [StopRemoteAccessSessionResponse]
$creadList :: ReadS [StopRemoteAccessSessionResponse]
readsPrec :: Int -> ReadS StopRemoteAccessSessionResponse
$creadsPrec :: Int -> ReadS StopRemoteAccessSessionResponse
Prelude.Read, Int -> StopRemoteAccessSessionResponse -> ShowS
[StopRemoteAccessSessionResponse] -> ShowS
StopRemoteAccessSessionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopRemoteAccessSessionResponse] -> ShowS
$cshowList :: [StopRemoteAccessSessionResponse] -> ShowS
show :: StopRemoteAccessSessionResponse -> String
$cshow :: StopRemoteAccessSessionResponse -> String
showsPrec :: Int -> StopRemoteAccessSessionResponse -> ShowS
$cshowsPrec :: Int -> StopRemoteAccessSessionResponse -> ShowS
Prelude.Show, forall x.
Rep StopRemoteAccessSessionResponse x
-> StopRemoteAccessSessionResponse
forall x.
StopRemoteAccessSessionResponse
-> Rep StopRemoteAccessSessionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopRemoteAccessSessionResponse x
-> StopRemoteAccessSessionResponse
$cfrom :: forall x.
StopRemoteAccessSessionResponse
-> Rep StopRemoteAccessSessionResponse x
Prelude.Generic)

-- |
-- Create a value of 'StopRemoteAccessSessionResponse' 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', 'stopRemoteAccessSessionResponse_remoteAccessSession' - A container that represents the metadata from the service about the
-- remote access session you are stopping.
--
-- 'httpStatus', 'stopRemoteAccessSessionResponse_httpStatus' - The response's http status code.
newStopRemoteAccessSessionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopRemoteAccessSessionResponse
newStopRemoteAccessSessionResponse :: Int -> StopRemoteAccessSessionResponse
newStopRemoteAccessSessionResponse Int
pHttpStatus_ =
  StopRemoteAccessSessionResponse'
    { $sel:remoteAccessSession:StopRemoteAccessSessionResponse' :: Maybe RemoteAccessSession
remoteAccessSession =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopRemoteAccessSessionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A container that represents the metadata from the service about the
-- remote access session you are stopping.
stopRemoteAccessSessionResponse_remoteAccessSession :: Lens.Lens' StopRemoteAccessSessionResponse (Prelude.Maybe RemoteAccessSession)
stopRemoteAccessSessionResponse_remoteAccessSession :: Lens' StopRemoteAccessSessionResponse (Maybe RemoteAccessSession)
stopRemoteAccessSessionResponse_remoteAccessSession = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopRemoteAccessSessionResponse' {Maybe RemoteAccessSession
remoteAccessSession :: Maybe RemoteAccessSession
$sel:remoteAccessSession:StopRemoteAccessSessionResponse' :: StopRemoteAccessSessionResponse -> Maybe RemoteAccessSession
remoteAccessSession} -> Maybe RemoteAccessSession
remoteAccessSession) (\s :: StopRemoteAccessSessionResponse
s@StopRemoteAccessSessionResponse' {} Maybe RemoteAccessSession
a -> StopRemoteAccessSessionResponse
s {$sel:remoteAccessSession:StopRemoteAccessSessionResponse' :: Maybe RemoteAccessSession
remoteAccessSession = Maybe RemoteAccessSession
a} :: StopRemoteAccessSessionResponse)

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

instance
  Prelude.NFData
    StopRemoteAccessSessionResponse
  where
  rnf :: StopRemoteAccessSessionResponse -> ()
rnf StopRemoteAccessSessionResponse' {Int
Maybe RemoteAccessSession
httpStatus :: Int
remoteAccessSession :: Maybe RemoteAccessSession
$sel:httpStatus:StopRemoteAccessSessionResponse' :: StopRemoteAccessSessionResponse -> Int
$sel:remoteAccessSession:StopRemoteAccessSessionResponse' :: StopRemoteAccessSessionResponse -> 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