{-# 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.InstallToRemoteAccessSession
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Installs an application to the device in a remote access session. For
-- Android applications, the file must be in .apk format. For iOS
-- applications, the file must be in .ipa format.
module Amazonka.DeviceFarm.InstallToRemoteAccessSession
  ( -- * Creating a Request
    InstallToRemoteAccessSession (..),
    newInstallToRemoteAccessSession,

    -- * Request Lenses
    installToRemoteAccessSession_remoteAccessSessionArn,
    installToRemoteAccessSession_appArn,

    -- * Destructuring the Response
    InstallToRemoteAccessSessionResponse (..),
    newInstallToRemoteAccessSessionResponse,

    -- * Response Lenses
    installToRemoteAccessSessionResponse_appUpload,
    installToRemoteAccessSessionResponse_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 install an Android application (in .apk
-- format) or an iOS application (in .ipa format) as part of a remote
-- access session.
--
-- /See:/ 'newInstallToRemoteAccessSession' smart constructor.
data InstallToRemoteAccessSession = InstallToRemoteAccessSession'
  { -- | The Amazon Resource Name (ARN) of the remote access session about which
    -- you are requesting information.
    InstallToRemoteAccessSession -> Text
remoteAccessSessionArn :: Prelude.Text,
    -- | The ARN of the app about which you are requesting information.
    InstallToRemoteAccessSession -> Text
appArn :: Prelude.Text
  }
  deriving (InstallToRemoteAccessSession
-> InstallToRemoteAccessSession -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstallToRemoteAccessSession
-> InstallToRemoteAccessSession -> Bool
$c/= :: InstallToRemoteAccessSession
-> InstallToRemoteAccessSession -> Bool
== :: InstallToRemoteAccessSession
-> InstallToRemoteAccessSession -> Bool
$c== :: InstallToRemoteAccessSession
-> InstallToRemoteAccessSession -> Bool
Prelude.Eq, ReadPrec [InstallToRemoteAccessSession]
ReadPrec InstallToRemoteAccessSession
Int -> ReadS InstallToRemoteAccessSession
ReadS [InstallToRemoteAccessSession]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstallToRemoteAccessSession]
$creadListPrec :: ReadPrec [InstallToRemoteAccessSession]
readPrec :: ReadPrec InstallToRemoteAccessSession
$creadPrec :: ReadPrec InstallToRemoteAccessSession
readList :: ReadS [InstallToRemoteAccessSession]
$creadList :: ReadS [InstallToRemoteAccessSession]
readsPrec :: Int -> ReadS InstallToRemoteAccessSession
$creadsPrec :: Int -> ReadS InstallToRemoteAccessSession
Prelude.Read, Int -> InstallToRemoteAccessSession -> ShowS
[InstallToRemoteAccessSession] -> ShowS
InstallToRemoteAccessSession -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstallToRemoteAccessSession] -> ShowS
$cshowList :: [InstallToRemoteAccessSession] -> ShowS
show :: InstallToRemoteAccessSession -> String
$cshow :: InstallToRemoteAccessSession -> String
showsPrec :: Int -> InstallToRemoteAccessSession -> ShowS
$cshowsPrec :: Int -> InstallToRemoteAccessSession -> ShowS
Prelude.Show, forall x.
Rep InstallToRemoteAccessSession x -> InstallToRemoteAccessSession
forall x.
InstallToRemoteAccessSession -> Rep InstallToRemoteAccessSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InstallToRemoteAccessSession x -> InstallToRemoteAccessSession
$cfrom :: forall x.
InstallToRemoteAccessSession -> Rep InstallToRemoteAccessSession x
Prelude.Generic)

-- |
-- Create a value of 'InstallToRemoteAccessSession' 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:
--
-- 'remoteAccessSessionArn', 'installToRemoteAccessSession_remoteAccessSessionArn' - The Amazon Resource Name (ARN) of the remote access session about which
-- you are requesting information.
--
-- 'appArn', 'installToRemoteAccessSession_appArn' - The ARN of the app about which you are requesting information.
newInstallToRemoteAccessSession ::
  -- | 'remoteAccessSessionArn'
  Prelude.Text ->
  -- | 'appArn'
  Prelude.Text ->
  InstallToRemoteAccessSession
newInstallToRemoteAccessSession :: Text -> Text -> InstallToRemoteAccessSession
newInstallToRemoteAccessSession
  Text
pRemoteAccessSessionArn_
  Text
pAppArn_ =
    InstallToRemoteAccessSession'
      { $sel:remoteAccessSessionArn:InstallToRemoteAccessSession' :: Text
remoteAccessSessionArn =
          Text
pRemoteAccessSessionArn_,
        $sel:appArn:InstallToRemoteAccessSession' :: Text
appArn = Text
pAppArn_
      }

-- | The Amazon Resource Name (ARN) of the remote access session about which
-- you are requesting information.
installToRemoteAccessSession_remoteAccessSessionArn :: Lens.Lens' InstallToRemoteAccessSession Prelude.Text
installToRemoteAccessSession_remoteAccessSessionArn :: Lens' InstallToRemoteAccessSession Text
installToRemoteAccessSession_remoteAccessSessionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstallToRemoteAccessSession' {Text
remoteAccessSessionArn :: Text
$sel:remoteAccessSessionArn:InstallToRemoteAccessSession' :: InstallToRemoteAccessSession -> Text
remoteAccessSessionArn} -> Text
remoteAccessSessionArn) (\s :: InstallToRemoteAccessSession
s@InstallToRemoteAccessSession' {} Text
a -> InstallToRemoteAccessSession
s {$sel:remoteAccessSessionArn:InstallToRemoteAccessSession' :: Text
remoteAccessSessionArn = Text
a} :: InstallToRemoteAccessSession)

-- | The ARN of the app about which you are requesting information.
installToRemoteAccessSession_appArn :: Lens.Lens' InstallToRemoteAccessSession Prelude.Text
installToRemoteAccessSession_appArn :: Lens' InstallToRemoteAccessSession Text
installToRemoteAccessSession_appArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstallToRemoteAccessSession' {Text
appArn :: Text
$sel:appArn:InstallToRemoteAccessSession' :: InstallToRemoteAccessSession -> Text
appArn} -> Text
appArn) (\s :: InstallToRemoteAccessSession
s@InstallToRemoteAccessSession' {} Text
a -> InstallToRemoteAccessSession
s {$sel:appArn:InstallToRemoteAccessSession' :: Text
appArn = Text
a} :: InstallToRemoteAccessSession)

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

instance Prelude.NFData InstallToRemoteAccessSession where
  rnf :: InstallToRemoteAccessSession -> ()
rnf InstallToRemoteAccessSession' {Text
appArn :: Text
remoteAccessSessionArn :: Text
$sel:appArn:InstallToRemoteAccessSession' :: InstallToRemoteAccessSession -> Text
$sel:remoteAccessSessionArn:InstallToRemoteAccessSession' :: InstallToRemoteAccessSession -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
remoteAccessSessionArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
appArn

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

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

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

-- | Represents the response from the server after AWS Device Farm makes a
-- request to install to a remote access session.
--
-- /See:/ 'newInstallToRemoteAccessSessionResponse' smart constructor.
data InstallToRemoteAccessSessionResponse = InstallToRemoteAccessSessionResponse'
  { -- | An app to upload or that has been uploaded.
    InstallToRemoteAccessSessionResponse -> Maybe Upload
appUpload :: Prelude.Maybe Upload,
    -- | The response's http status code.
    InstallToRemoteAccessSessionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (InstallToRemoteAccessSessionResponse
-> InstallToRemoteAccessSessionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstallToRemoteAccessSessionResponse
-> InstallToRemoteAccessSessionResponse -> Bool
$c/= :: InstallToRemoteAccessSessionResponse
-> InstallToRemoteAccessSessionResponse -> Bool
== :: InstallToRemoteAccessSessionResponse
-> InstallToRemoteAccessSessionResponse -> Bool
$c== :: InstallToRemoteAccessSessionResponse
-> InstallToRemoteAccessSessionResponse -> Bool
Prelude.Eq, Int -> InstallToRemoteAccessSessionResponse -> ShowS
[InstallToRemoteAccessSessionResponse] -> ShowS
InstallToRemoteAccessSessionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstallToRemoteAccessSessionResponse] -> ShowS
$cshowList :: [InstallToRemoteAccessSessionResponse] -> ShowS
show :: InstallToRemoteAccessSessionResponse -> String
$cshow :: InstallToRemoteAccessSessionResponse -> String
showsPrec :: Int -> InstallToRemoteAccessSessionResponse -> ShowS
$cshowsPrec :: Int -> InstallToRemoteAccessSessionResponse -> ShowS
Prelude.Show, forall x.
Rep InstallToRemoteAccessSessionResponse x
-> InstallToRemoteAccessSessionResponse
forall x.
InstallToRemoteAccessSessionResponse
-> Rep InstallToRemoteAccessSessionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InstallToRemoteAccessSessionResponse x
-> InstallToRemoteAccessSessionResponse
$cfrom :: forall x.
InstallToRemoteAccessSessionResponse
-> Rep InstallToRemoteAccessSessionResponse x
Prelude.Generic)

-- |
-- Create a value of 'InstallToRemoteAccessSessionResponse' 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:
--
-- 'appUpload', 'installToRemoteAccessSessionResponse_appUpload' - An app to upload or that has been uploaded.
--
-- 'httpStatus', 'installToRemoteAccessSessionResponse_httpStatus' - The response's http status code.
newInstallToRemoteAccessSessionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  InstallToRemoteAccessSessionResponse
newInstallToRemoteAccessSessionResponse :: Int -> InstallToRemoteAccessSessionResponse
newInstallToRemoteAccessSessionResponse Int
pHttpStatus_ =
  InstallToRemoteAccessSessionResponse'
    { $sel:appUpload:InstallToRemoteAccessSessionResponse' :: Maybe Upload
appUpload =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:InstallToRemoteAccessSessionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An app to upload or that has been uploaded.
installToRemoteAccessSessionResponse_appUpload :: Lens.Lens' InstallToRemoteAccessSessionResponse (Prelude.Maybe Upload)
installToRemoteAccessSessionResponse_appUpload :: Lens' InstallToRemoteAccessSessionResponse (Maybe Upload)
installToRemoteAccessSessionResponse_appUpload = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstallToRemoteAccessSessionResponse' {Maybe Upload
appUpload :: Maybe Upload
$sel:appUpload:InstallToRemoteAccessSessionResponse' :: InstallToRemoteAccessSessionResponse -> Maybe Upload
appUpload} -> Maybe Upload
appUpload) (\s :: InstallToRemoteAccessSessionResponse
s@InstallToRemoteAccessSessionResponse' {} Maybe Upload
a -> InstallToRemoteAccessSessionResponse
s {$sel:appUpload:InstallToRemoteAccessSessionResponse' :: Maybe Upload
appUpload = Maybe Upload
a} :: InstallToRemoteAccessSessionResponse)

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

instance
  Prelude.NFData
    InstallToRemoteAccessSessionResponse
  where
  rnf :: InstallToRemoteAccessSessionResponse -> ()
rnf InstallToRemoteAccessSessionResponse' {Int
Maybe Upload
httpStatus :: Int
appUpload :: Maybe Upload
$sel:httpStatus:InstallToRemoteAccessSessionResponse' :: InstallToRemoteAccessSessionResponse -> Int
$sel:appUpload:InstallToRemoteAccessSessionResponse' :: InstallToRemoteAccessSessionResponse -> Maybe Upload
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Upload
appUpload
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus