{-# 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.GetDeviceInstance
-- 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)
--
-- Returns information about a device instance that belongs to a private
-- device fleet.
module Amazonka.DeviceFarm.GetDeviceInstance
  ( -- * Creating a Request
    GetDeviceInstance (..),
    newGetDeviceInstance,

    -- * Request Lenses
    getDeviceInstance_arn,

    -- * Destructuring the Response
    GetDeviceInstanceResponse (..),
    newGetDeviceInstanceResponse,

    -- * Response Lenses
    getDeviceInstanceResponse_deviceInstance,
    getDeviceInstanceResponse_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

-- | /See:/ 'newGetDeviceInstance' smart constructor.
data GetDeviceInstance = GetDeviceInstance'
  { -- | The Amazon Resource Name (ARN) of the instance you\'re requesting
    -- information about.
    GetDeviceInstance -> Text
arn :: Prelude.Text
  }
  deriving (GetDeviceInstance -> GetDeviceInstance -> Bool
(GetDeviceInstance -> GetDeviceInstance -> Bool)
-> (GetDeviceInstance -> GetDeviceInstance -> Bool)
-> Eq GetDeviceInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDeviceInstance -> GetDeviceInstance -> Bool
$c/= :: GetDeviceInstance -> GetDeviceInstance -> Bool
== :: GetDeviceInstance -> GetDeviceInstance -> Bool
$c== :: GetDeviceInstance -> GetDeviceInstance -> Bool
Prelude.Eq, ReadPrec [GetDeviceInstance]
ReadPrec GetDeviceInstance
Int -> ReadS GetDeviceInstance
ReadS [GetDeviceInstance]
(Int -> ReadS GetDeviceInstance)
-> ReadS [GetDeviceInstance]
-> ReadPrec GetDeviceInstance
-> ReadPrec [GetDeviceInstance]
-> Read GetDeviceInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDeviceInstance]
$creadListPrec :: ReadPrec [GetDeviceInstance]
readPrec :: ReadPrec GetDeviceInstance
$creadPrec :: ReadPrec GetDeviceInstance
readList :: ReadS [GetDeviceInstance]
$creadList :: ReadS [GetDeviceInstance]
readsPrec :: Int -> ReadS GetDeviceInstance
$creadsPrec :: Int -> ReadS GetDeviceInstance
Prelude.Read, Int -> GetDeviceInstance -> ShowS
[GetDeviceInstance] -> ShowS
GetDeviceInstance -> String
(Int -> GetDeviceInstance -> ShowS)
-> (GetDeviceInstance -> String)
-> ([GetDeviceInstance] -> ShowS)
-> Show GetDeviceInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDeviceInstance] -> ShowS
$cshowList :: [GetDeviceInstance] -> ShowS
show :: GetDeviceInstance -> String
$cshow :: GetDeviceInstance -> String
showsPrec :: Int -> GetDeviceInstance -> ShowS
$cshowsPrec :: Int -> GetDeviceInstance -> ShowS
Prelude.Show, (forall x. GetDeviceInstance -> Rep GetDeviceInstance x)
-> (forall x. Rep GetDeviceInstance x -> GetDeviceInstance)
-> Generic GetDeviceInstance
forall x. Rep GetDeviceInstance x -> GetDeviceInstance
forall x. GetDeviceInstance -> Rep GetDeviceInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDeviceInstance x -> GetDeviceInstance
$cfrom :: forall x. GetDeviceInstance -> Rep GetDeviceInstance x
Prelude.Generic)

-- |
-- Create a value of 'GetDeviceInstance' 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', 'getDeviceInstance_arn' - The Amazon Resource Name (ARN) of the instance you\'re requesting
-- information about.
newGetDeviceInstance ::
  -- | 'arn'
  Prelude.Text ->
  GetDeviceInstance
newGetDeviceInstance :: Text -> GetDeviceInstance
newGetDeviceInstance Text
pArn_ =
  GetDeviceInstance' :: Text -> GetDeviceInstance
GetDeviceInstance' {$sel:arn:GetDeviceInstance' :: Text
arn = Text
pArn_}

-- | The Amazon Resource Name (ARN) of the instance you\'re requesting
-- information about.
getDeviceInstance_arn :: Lens.Lens' GetDeviceInstance Prelude.Text
getDeviceInstance_arn :: (Text -> f Text) -> GetDeviceInstance -> f GetDeviceInstance
getDeviceInstance_arn = (GetDeviceInstance -> Text)
-> (GetDeviceInstance -> Text -> GetDeviceInstance)
-> Lens GetDeviceInstance GetDeviceInstance Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeviceInstance' {Text
arn :: Text
$sel:arn:GetDeviceInstance' :: GetDeviceInstance -> Text
arn} -> Text
arn) (\s :: GetDeviceInstance
s@GetDeviceInstance' {} Text
a -> GetDeviceInstance
s {$sel:arn:GetDeviceInstance' :: Text
arn = Text
a} :: GetDeviceInstance)

instance Core.AWSRequest GetDeviceInstance where
  type
    AWSResponse GetDeviceInstance =
      GetDeviceInstanceResponse
  request :: GetDeviceInstance -> Request GetDeviceInstance
request = Service -> GetDeviceInstance -> Request GetDeviceInstance
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDeviceInstance
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDeviceInstance)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDeviceInstance))
-> Logger
-> Service
-> Proxy GetDeviceInstance
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDeviceInstance)))
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 DeviceInstance -> Int -> GetDeviceInstanceResponse
GetDeviceInstanceResponse'
            (Maybe DeviceInstance -> Int -> GetDeviceInstanceResponse)
-> Either String (Maybe DeviceInstance)
-> Either String (Int -> GetDeviceInstanceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DeviceInstance)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"deviceInstance")
            Either String (Int -> GetDeviceInstanceResponse)
-> Either String Int -> Either String GetDeviceInstanceResponse
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 GetDeviceInstance

instance Prelude.NFData GetDeviceInstance

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

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

-- | /See:/ 'newGetDeviceInstanceResponse' smart constructor.
data GetDeviceInstanceResponse = GetDeviceInstanceResponse'
  { -- | An object that contains information about your device instance.
    GetDeviceInstanceResponse -> Maybe DeviceInstance
deviceInstance :: Prelude.Maybe DeviceInstance,
    -- | The response's http status code.
    GetDeviceInstanceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDeviceInstanceResponse -> GetDeviceInstanceResponse -> Bool
(GetDeviceInstanceResponse -> GetDeviceInstanceResponse -> Bool)
-> (GetDeviceInstanceResponse -> GetDeviceInstanceResponse -> Bool)
-> Eq GetDeviceInstanceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDeviceInstanceResponse -> GetDeviceInstanceResponse -> Bool
$c/= :: GetDeviceInstanceResponse -> GetDeviceInstanceResponse -> Bool
== :: GetDeviceInstanceResponse -> GetDeviceInstanceResponse -> Bool
$c== :: GetDeviceInstanceResponse -> GetDeviceInstanceResponse -> Bool
Prelude.Eq, ReadPrec [GetDeviceInstanceResponse]
ReadPrec GetDeviceInstanceResponse
Int -> ReadS GetDeviceInstanceResponse
ReadS [GetDeviceInstanceResponse]
(Int -> ReadS GetDeviceInstanceResponse)
-> ReadS [GetDeviceInstanceResponse]
-> ReadPrec GetDeviceInstanceResponse
-> ReadPrec [GetDeviceInstanceResponse]
-> Read GetDeviceInstanceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDeviceInstanceResponse]
$creadListPrec :: ReadPrec [GetDeviceInstanceResponse]
readPrec :: ReadPrec GetDeviceInstanceResponse
$creadPrec :: ReadPrec GetDeviceInstanceResponse
readList :: ReadS [GetDeviceInstanceResponse]
$creadList :: ReadS [GetDeviceInstanceResponse]
readsPrec :: Int -> ReadS GetDeviceInstanceResponse
$creadsPrec :: Int -> ReadS GetDeviceInstanceResponse
Prelude.Read, Int -> GetDeviceInstanceResponse -> ShowS
[GetDeviceInstanceResponse] -> ShowS
GetDeviceInstanceResponse -> String
(Int -> GetDeviceInstanceResponse -> ShowS)
-> (GetDeviceInstanceResponse -> String)
-> ([GetDeviceInstanceResponse] -> ShowS)
-> Show GetDeviceInstanceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDeviceInstanceResponse] -> ShowS
$cshowList :: [GetDeviceInstanceResponse] -> ShowS
show :: GetDeviceInstanceResponse -> String
$cshow :: GetDeviceInstanceResponse -> String
showsPrec :: Int -> GetDeviceInstanceResponse -> ShowS
$cshowsPrec :: Int -> GetDeviceInstanceResponse -> ShowS
Prelude.Show, (forall x.
 GetDeviceInstanceResponse -> Rep GetDeviceInstanceResponse x)
-> (forall x.
    Rep GetDeviceInstanceResponse x -> GetDeviceInstanceResponse)
-> Generic GetDeviceInstanceResponse
forall x.
Rep GetDeviceInstanceResponse x -> GetDeviceInstanceResponse
forall x.
GetDeviceInstanceResponse -> Rep GetDeviceInstanceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDeviceInstanceResponse x -> GetDeviceInstanceResponse
$cfrom :: forall x.
GetDeviceInstanceResponse -> Rep GetDeviceInstanceResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDeviceInstanceResponse' 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:
--
-- 'deviceInstance', 'getDeviceInstanceResponse_deviceInstance' - An object that contains information about your device instance.
--
-- 'httpStatus', 'getDeviceInstanceResponse_httpStatus' - The response's http status code.
newGetDeviceInstanceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDeviceInstanceResponse
newGetDeviceInstanceResponse :: Int -> GetDeviceInstanceResponse
newGetDeviceInstanceResponse Int
pHttpStatus_ =
  GetDeviceInstanceResponse' :: Maybe DeviceInstance -> Int -> GetDeviceInstanceResponse
GetDeviceInstanceResponse'
    { $sel:deviceInstance:GetDeviceInstanceResponse' :: Maybe DeviceInstance
deviceInstance =
        Maybe DeviceInstance
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDeviceInstanceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object that contains information about your device instance.
getDeviceInstanceResponse_deviceInstance :: Lens.Lens' GetDeviceInstanceResponse (Prelude.Maybe DeviceInstance)
getDeviceInstanceResponse_deviceInstance :: (Maybe DeviceInstance -> f (Maybe DeviceInstance))
-> GetDeviceInstanceResponse -> f GetDeviceInstanceResponse
getDeviceInstanceResponse_deviceInstance = (GetDeviceInstanceResponse -> Maybe DeviceInstance)
-> (GetDeviceInstanceResponse
    -> Maybe DeviceInstance -> GetDeviceInstanceResponse)
-> Lens
     GetDeviceInstanceResponse
     GetDeviceInstanceResponse
     (Maybe DeviceInstance)
     (Maybe DeviceInstance)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeviceInstanceResponse' {Maybe DeviceInstance
deviceInstance :: Maybe DeviceInstance
$sel:deviceInstance:GetDeviceInstanceResponse' :: GetDeviceInstanceResponse -> Maybe DeviceInstance
deviceInstance} -> Maybe DeviceInstance
deviceInstance) (\s :: GetDeviceInstanceResponse
s@GetDeviceInstanceResponse' {} Maybe DeviceInstance
a -> GetDeviceInstanceResponse
s {$sel:deviceInstance:GetDeviceInstanceResponse' :: Maybe DeviceInstance
deviceInstance = Maybe DeviceInstance
a} :: GetDeviceInstanceResponse)

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

instance Prelude.NFData GetDeviceInstanceResponse