{-# 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-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)
--
-- 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 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 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
(InstallToRemoteAccessSession
 -> InstallToRemoteAccessSession -> Bool)
-> (InstallToRemoteAccessSession
    -> InstallToRemoteAccessSession -> Bool)
-> Eq InstallToRemoteAccessSession
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]
(Int -> ReadS InstallToRemoteAccessSession)
-> ReadS [InstallToRemoteAccessSession]
-> ReadPrec InstallToRemoteAccessSession
-> ReadPrec [InstallToRemoteAccessSession]
-> Read 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
(Int -> InstallToRemoteAccessSession -> ShowS)
-> (InstallToRemoteAccessSession -> String)
-> ([InstallToRemoteAccessSession] -> ShowS)
-> Show InstallToRemoteAccessSession
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.
 InstallToRemoteAccessSession -> Rep InstallToRemoteAccessSession x)
-> (forall x.
    Rep InstallToRemoteAccessSession x -> InstallToRemoteAccessSession)
-> Generic InstallToRemoteAccessSession
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' :: Text -> Text -> InstallToRemoteAccessSession
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 :: (Text -> f Text)
-> InstallToRemoteAccessSession -> f InstallToRemoteAccessSession
installToRemoteAccessSession_remoteAccessSessionArn = (InstallToRemoteAccessSession -> Text)
-> (InstallToRemoteAccessSession
    -> Text -> InstallToRemoteAccessSession)
-> Lens
     InstallToRemoteAccessSession InstallToRemoteAccessSession Text Text
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 :: (Text -> f Text)
-> InstallToRemoteAccessSession -> f InstallToRemoteAccessSession
installToRemoteAccessSession_appArn = (InstallToRemoteAccessSession -> Text)
-> (InstallToRemoteAccessSession
    -> Text -> InstallToRemoteAccessSession)
-> Lens
     InstallToRemoteAccessSession InstallToRemoteAccessSession Text Text
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 :: InstallToRemoteAccessSession
-> Request InstallToRemoteAccessSession
request = Service
-> InstallToRemoteAccessSession
-> Request InstallToRemoteAccessSession
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy InstallToRemoteAccessSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse InstallToRemoteAccessSession)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse InstallToRemoteAccessSession))
-> Logger
-> Service
-> Proxy InstallToRemoteAccessSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse InstallToRemoteAccessSession)))
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 Upload -> Int -> InstallToRemoteAccessSessionResponse
InstallToRemoteAccessSessionResponse'
            (Maybe Upload -> Int -> InstallToRemoteAccessSessionResponse)
-> Either String (Maybe Upload)
-> Either String (Int -> InstallToRemoteAccessSessionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Upload)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"appUpload")
            Either String (Int -> InstallToRemoteAccessSessionResponse)
-> Either String Int
-> Either String InstallToRemoteAccessSessionResponse
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
    InstallToRemoteAccessSession

instance Prelude.NFData InstallToRemoteAccessSession

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

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

instance Core.ToQuery InstallToRemoteAccessSession where
  toQuery :: InstallToRemoteAccessSession -> QueryString
toQuery = QueryString -> InstallToRemoteAccessSession -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(InstallToRemoteAccessSessionResponse
 -> InstallToRemoteAccessSessionResponse -> Bool)
-> (InstallToRemoteAccessSessionResponse
    -> InstallToRemoteAccessSessionResponse -> Bool)
-> Eq InstallToRemoteAccessSessionResponse
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
(Int -> InstallToRemoteAccessSessionResponse -> ShowS)
-> (InstallToRemoteAccessSessionResponse -> String)
-> ([InstallToRemoteAccessSessionResponse] -> ShowS)
-> Show InstallToRemoteAccessSessionResponse
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.
 InstallToRemoteAccessSessionResponse
 -> Rep InstallToRemoteAccessSessionResponse x)
-> (forall x.
    Rep InstallToRemoteAccessSessionResponse x
    -> InstallToRemoteAccessSessionResponse)
-> Generic InstallToRemoteAccessSessionResponse
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' :: Maybe Upload -> Int -> InstallToRemoteAccessSessionResponse
InstallToRemoteAccessSessionResponse'
    { $sel:appUpload:InstallToRemoteAccessSessionResponse' :: Maybe Upload
appUpload =
        Maybe Upload
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 :: (Maybe Upload -> f (Maybe Upload))
-> InstallToRemoteAccessSessionResponse
-> f InstallToRemoteAccessSessionResponse
installToRemoteAccessSessionResponse_appUpload = (InstallToRemoteAccessSessionResponse -> Maybe Upload)
-> (InstallToRemoteAccessSessionResponse
    -> Maybe Upload -> InstallToRemoteAccessSessionResponse)
-> Lens
     InstallToRemoteAccessSessionResponse
     InstallToRemoteAccessSessionResponse
     (Maybe Upload)
     (Maybe Upload)
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 :: (Int -> f Int)
-> InstallToRemoteAccessSessionResponse
-> f InstallToRemoteAccessSessionResponse
installToRemoteAccessSessionResponse_httpStatus = (InstallToRemoteAccessSessionResponse -> Int)
-> (InstallToRemoteAccessSessionResponse
    -> Int -> InstallToRemoteAccessSessionResponse)
-> Lens
     InstallToRemoteAccessSessionResponse
     InstallToRemoteAccessSessionResponse
     Int
     Int
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