{-# 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-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)
--
-- 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 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 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
(StopRemoteAccessSession -> StopRemoteAccessSession -> Bool)
-> (StopRemoteAccessSession -> StopRemoteAccessSession -> Bool)
-> Eq StopRemoteAccessSession
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]
(Int -> ReadS StopRemoteAccessSession)
-> ReadS [StopRemoteAccessSession]
-> ReadPrec StopRemoteAccessSession
-> ReadPrec [StopRemoteAccessSession]
-> Read 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
(Int -> StopRemoteAccessSession -> ShowS)
-> (StopRemoteAccessSession -> String)
-> ([StopRemoteAccessSession] -> ShowS)
-> Show StopRemoteAccessSession
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.
 StopRemoteAccessSession -> Rep StopRemoteAccessSession x)
-> (forall x.
    Rep StopRemoteAccessSession x -> StopRemoteAccessSession)
-> Generic StopRemoteAccessSession
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' :: Text -> StopRemoteAccessSession
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 :: (Text -> f Text)
-> StopRemoteAccessSession -> f StopRemoteAccessSession
stopRemoteAccessSession_arn = (StopRemoteAccessSession -> Text)
-> (StopRemoteAccessSession -> Text -> StopRemoteAccessSession)
-> Lens StopRemoteAccessSession StopRemoteAccessSession Text Text
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 :: StopRemoteAccessSession -> Request StopRemoteAccessSession
request = Service
-> StopRemoteAccessSession -> Request StopRemoteAccessSession
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopRemoteAccessSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopRemoteAccessSession)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StopRemoteAccessSession))
-> Logger
-> Service
-> Proxy StopRemoteAccessSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopRemoteAccessSession)))
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 -> StopRemoteAccessSessionResponse
StopRemoteAccessSessionResponse'
            (Maybe RemoteAccessSession
 -> Int -> StopRemoteAccessSessionResponse)
-> Either String (Maybe RemoteAccessSession)
-> Either String (Int -> StopRemoteAccessSessionResponse)
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 -> StopRemoteAccessSessionResponse)
-> Either String Int
-> Either String StopRemoteAccessSessionResponse
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 StopRemoteAccessSession

instance Prelude.NFData StopRemoteAccessSession

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

instance Core.ToQuery StopRemoteAccessSession where
  toQuery :: StopRemoteAccessSession -> QueryString
toQuery = QueryString -> StopRemoteAccessSession -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(StopRemoteAccessSessionResponse
 -> StopRemoteAccessSessionResponse -> Bool)
-> (StopRemoteAccessSessionResponse
    -> StopRemoteAccessSessionResponse -> Bool)
-> Eq StopRemoteAccessSessionResponse
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]
(Int -> ReadS StopRemoteAccessSessionResponse)
-> ReadS [StopRemoteAccessSessionResponse]
-> ReadPrec StopRemoteAccessSessionResponse
-> ReadPrec [StopRemoteAccessSessionResponse]
-> Read 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
(Int -> StopRemoteAccessSessionResponse -> ShowS)
-> (StopRemoteAccessSessionResponse -> String)
-> ([StopRemoteAccessSessionResponse] -> ShowS)
-> Show StopRemoteAccessSessionResponse
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.
 StopRemoteAccessSessionResponse
 -> Rep StopRemoteAccessSessionResponse x)
-> (forall x.
    Rep StopRemoteAccessSessionResponse x
    -> StopRemoteAccessSessionResponse)
-> Generic StopRemoteAccessSessionResponse
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' :: Maybe RemoteAccessSession -> Int -> StopRemoteAccessSessionResponse
StopRemoteAccessSessionResponse'
    { $sel:remoteAccessSession:StopRemoteAccessSessionResponse' :: Maybe RemoteAccessSession
remoteAccessSession =
        Maybe 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 :: (Maybe RemoteAccessSession -> f (Maybe RemoteAccessSession))
-> StopRemoteAccessSessionResponse
-> f StopRemoteAccessSessionResponse
stopRemoteAccessSessionResponse_remoteAccessSession = (StopRemoteAccessSessionResponse -> Maybe RemoteAccessSession)
-> (StopRemoteAccessSessionResponse
    -> Maybe RemoteAccessSession -> StopRemoteAccessSessionResponse)
-> Lens
     StopRemoteAccessSessionResponse
     StopRemoteAccessSessionResponse
     (Maybe RemoteAccessSession)
     (Maybe 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 :: (Int -> f Int)
-> StopRemoteAccessSessionResponse
-> f StopRemoteAccessSessionResponse
stopRemoteAccessSessionResponse_httpStatus = (StopRemoteAccessSessionResponse -> Int)
-> (StopRemoteAccessSessionResponse
    -> Int -> StopRemoteAccessSessionResponse)
-> Lens
     StopRemoteAccessSessionResponse
     StopRemoteAccessSessionResponse
     Int
     Int
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