{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 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

-- | /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
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]
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
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. 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' {$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 :: Lens' GetDeviceInstance Text
getDeviceInstance_arn = 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 :: (Service -> Service)
-> GetDeviceInstance -> Request GetDeviceInstance
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 GetDeviceInstance
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDeviceInstance)))
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 DeviceInstance -> Int -> GetDeviceInstanceResponse
GetDeviceInstanceResponse'
            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
"deviceInstance")
            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 GetDeviceInstance where
  hashWithSalt :: Int -> GetDeviceInstance -> Int
hashWithSalt Int
_salt GetDeviceInstance' {Text
arn :: Text
$sel:arn:GetDeviceInstance' :: GetDeviceInstance -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

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

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

instance Data.ToQuery GetDeviceInstance where
  toQuery :: GetDeviceInstance -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:deviceInstance:GetDeviceInstanceResponse' :: Maybe DeviceInstance
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 :: Lens' GetDeviceInstanceResponse (Maybe DeviceInstance)
getDeviceInstanceResponse_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 :: Lens' GetDeviceInstanceResponse Int
getDeviceInstanceResponse_httpStatus = 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 where
  rnf :: GetDeviceInstanceResponse -> ()
rnf GetDeviceInstanceResponse' {Int
Maybe DeviceInstance
httpStatus :: Int
deviceInstance :: Maybe DeviceInstance
$sel:httpStatus:GetDeviceInstanceResponse' :: GetDeviceInstanceResponse -> Int
$sel:deviceInstance:GetDeviceInstanceResponse' :: GetDeviceInstanceResponse -> Maybe DeviceInstance
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DeviceInstance
deviceInstance
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus