{-# 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.Braket.GetDevice
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the devices available in Amazon Braket.
--
-- For backwards compatibility with older versions of BraketSchemas,
-- OpenQASM information is omitted from GetDevice API calls. To get this
-- information the user-agent needs to present a recent version of the
-- BraketSchemas (1.8.0 or later). The Braket SDK automatically reports
-- this for you. If you do not see OpenQASM results in the GetDevice
-- response when using a Braket SDK, you may need to set AWS_EXECUTION_ENV
-- environment variable to configure user-agent. See the code examples
-- provided below for how to do this for the AWS CLI, Boto3, and the Go,
-- Java, and JavaScript\/TypeScript SDKs.
module Amazonka.Braket.GetDevice
  ( -- * Creating a Request
    GetDevice (..),
    newGetDevice,

    -- * Request Lenses
    getDevice_deviceArn,

    -- * Destructuring the Response
    GetDeviceResponse (..),
    newGetDeviceResponse,

    -- * Response Lenses
    getDeviceResponse_httpStatus,
    getDeviceResponse_deviceArn,
    getDeviceResponse_deviceCapabilities,
    getDeviceResponse_deviceName,
    getDeviceResponse_deviceStatus,
    getDeviceResponse_deviceType,
    getDeviceResponse_providerName,
  )
where

import Amazonka.Braket.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetDevice' smart constructor.
data GetDevice = GetDevice'
  { -- | The ARN of the device to retrieve.
    GetDevice -> Text
deviceArn :: Prelude.Text
  }
  deriving (GetDevice -> GetDevice -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDevice -> GetDevice -> Bool
$c/= :: GetDevice -> GetDevice -> Bool
== :: GetDevice -> GetDevice -> Bool
$c== :: GetDevice -> GetDevice -> Bool
Prelude.Eq, ReadPrec [GetDevice]
ReadPrec GetDevice
Int -> ReadS GetDevice
ReadS [GetDevice]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDevice]
$creadListPrec :: ReadPrec [GetDevice]
readPrec :: ReadPrec GetDevice
$creadPrec :: ReadPrec GetDevice
readList :: ReadS [GetDevice]
$creadList :: ReadS [GetDevice]
readsPrec :: Int -> ReadS GetDevice
$creadsPrec :: Int -> ReadS GetDevice
Prelude.Read, Int -> GetDevice -> ShowS
[GetDevice] -> ShowS
GetDevice -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDevice] -> ShowS
$cshowList :: [GetDevice] -> ShowS
show :: GetDevice -> String
$cshow :: GetDevice -> String
showsPrec :: Int -> GetDevice -> ShowS
$cshowsPrec :: Int -> GetDevice -> ShowS
Prelude.Show, forall x. Rep GetDevice x -> GetDevice
forall x. GetDevice -> Rep GetDevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDevice x -> GetDevice
$cfrom :: forall x. GetDevice -> Rep GetDevice x
Prelude.Generic)

-- |
-- Create a value of 'GetDevice' 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:
--
-- 'deviceArn', 'getDevice_deviceArn' - The ARN of the device to retrieve.
newGetDevice ::
  -- | 'deviceArn'
  Prelude.Text ->
  GetDevice
newGetDevice :: Text -> GetDevice
newGetDevice Text
pDeviceArn_ =
  GetDevice' {$sel:deviceArn:GetDevice' :: Text
deviceArn = Text
pDeviceArn_}

-- | The ARN of the device to retrieve.
getDevice_deviceArn :: Lens.Lens' GetDevice Prelude.Text
getDevice_deviceArn :: Lens' GetDevice Text
getDevice_deviceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDevice' {Text
deviceArn :: Text
$sel:deviceArn:GetDevice' :: GetDevice -> Text
deviceArn} -> Text
deviceArn) (\s :: GetDevice
s@GetDevice' {} Text
a -> GetDevice
s {$sel:deviceArn:GetDevice' :: Text
deviceArn = Text
a} :: GetDevice)

instance Core.AWSRequest GetDevice where
  type AWSResponse GetDevice = GetDeviceResponse
  request :: (Service -> Service) -> GetDevice -> Request GetDevice
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetDevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDevice)))
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 ->
          Int
-> Text
-> Text
-> Text
-> DeviceStatus
-> DeviceType
-> Text
-> GetDeviceResponse
GetDeviceResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"deviceArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"deviceCapabilities")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"deviceName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"deviceStatus")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"deviceType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"providerName")
      )

instance Prelude.Hashable GetDevice where
  hashWithSalt :: Int -> GetDevice -> Int
hashWithSalt Int
_salt GetDevice' {Text
deviceArn :: Text
$sel:deviceArn:GetDevice' :: GetDevice -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
deviceArn

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

instance Data.ToHeaders GetDevice where
  toHeaders :: GetDevice -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath GetDevice where
  toPath :: GetDevice -> ByteString
toPath GetDevice' {Text
deviceArn :: Text
$sel:deviceArn:GetDevice' :: GetDevice -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/device/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
deviceArn]

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

-- | /See:/ 'newGetDeviceResponse' smart constructor.
data GetDeviceResponse = GetDeviceResponse'
  { -- | The response's http status code.
    GetDeviceResponse -> Int
httpStatus :: Prelude.Int,
    -- | The ARN of the device.
    GetDeviceResponse -> Text
deviceArn :: Prelude.Text,
    -- | Details about the capabilities of the device.
    GetDeviceResponse -> Text
deviceCapabilities :: Prelude.Text,
    -- | The name of the device.
    GetDeviceResponse -> Text
deviceName :: Prelude.Text,
    -- | The status of the device.
    GetDeviceResponse -> DeviceStatus
deviceStatus :: DeviceStatus,
    -- | The type of the device.
    GetDeviceResponse -> DeviceType
deviceType :: DeviceType,
    -- | The name of the partner company for the device.
    GetDeviceResponse -> Text
providerName :: Prelude.Text
  }
  deriving (GetDeviceResponse -> GetDeviceResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDeviceResponse -> GetDeviceResponse -> Bool
$c/= :: GetDeviceResponse -> GetDeviceResponse -> Bool
== :: GetDeviceResponse -> GetDeviceResponse -> Bool
$c== :: GetDeviceResponse -> GetDeviceResponse -> Bool
Prelude.Eq, ReadPrec [GetDeviceResponse]
ReadPrec GetDeviceResponse
Int -> ReadS GetDeviceResponse
ReadS [GetDeviceResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDeviceResponse]
$creadListPrec :: ReadPrec [GetDeviceResponse]
readPrec :: ReadPrec GetDeviceResponse
$creadPrec :: ReadPrec GetDeviceResponse
readList :: ReadS [GetDeviceResponse]
$creadList :: ReadS [GetDeviceResponse]
readsPrec :: Int -> ReadS GetDeviceResponse
$creadsPrec :: Int -> ReadS GetDeviceResponse
Prelude.Read, Int -> GetDeviceResponse -> ShowS
[GetDeviceResponse] -> ShowS
GetDeviceResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDeviceResponse] -> ShowS
$cshowList :: [GetDeviceResponse] -> ShowS
show :: GetDeviceResponse -> String
$cshow :: GetDeviceResponse -> String
showsPrec :: Int -> GetDeviceResponse -> ShowS
$cshowsPrec :: Int -> GetDeviceResponse -> ShowS
Prelude.Show, forall x. Rep GetDeviceResponse x -> GetDeviceResponse
forall x. GetDeviceResponse -> Rep GetDeviceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDeviceResponse x -> GetDeviceResponse
$cfrom :: forall x. GetDeviceResponse -> Rep GetDeviceResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDeviceResponse' 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:
--
-- 'httpStatus', 'getDeviceResponse_httpStatus' - The response's http status code.
--
-- 'deviceArn', 'getDeviceResponse_deviceArn' - The ARN of the device.
--
-- 'deviceCapabilities', 'getDeviceResponse_deviceCapabilities' - Details about the capabilities of the device.
--
-- 'deviceName', 'getDeviceResponse_deviceName' - The name of the device.
--
-- 'deviceStatus', 'getDeviceResponse_deviceStatus' - The status of the device.
--
-- 'deviceType', 'getDeviceResponse_deviceType' - The type of the device.
--
-- 'providerName', 'getDeviceResponse_providerName' - The name of the partner company for the device.
newGetDeviceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'deviceArn'
  Prelude.Text ->
  -- | 'deviceCapabilities'
  Prelude.Text ->
  -- | 'deviceName'
  Prelude.Text ->
  -- | 'deviceStatus'
  DeviceStatus ->
  -- | 'deviceType'
  DeviceType ->
  -- | 'providerName'
  Prelude.Text ->
  GetDeviceResponse
newGetDeviceResponse :: Int
-> Text
-> Text
-> Text
-> DeviceStatus
-> DeviceType
-> Text
-> GetDeviceResponse
newGetDeviceResponse
  Int
pHttpStatus_
  Text
pDeviceArn_
  Text
pDeviceCapabilities_
  Text
pDeviceName_
  DeviceStatus
pDeviceStatus_
  DeviceType
pDeviceType_
  Text
pProviderName_ =
    GetDeviceResponse'
      { $sel:httpStatus:GetDeviceResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:deviceArn:GetDeviceResponse' :: Text
deviceArn = Text
pDeviceArn_,
        $sel:deviceCapabilities:GetDeviceResponse' :: Text
deviceCapabilities = Text
pDeviceCapabilities_,
        $sel:deviceName:GetDeviceResponse' :: Text
deviceName = Text
pDeviceName_,
        $sel:deviceStatus:GetDeviceResponse' :: DeviceStatus
deviceStatus = DeviceStatus
pDeviceStatus_,
        $sel:deviceType:GetDeviceResponse' :: DeviceType
deviceType = DeviceType
pDeviceType_,
        $sel:providerName:GetDeviceResponse' :: Text
providerName = Text
pProviderName_
      }

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

-- | The ARN of the device.
getDeviceResponse_deviceArn :: Lens.Lens' GetDeviceResponse Prelude.Text
getDeviceResponse_deviceArn :: Lens' GetDeviceResponse Text
getDeviceResponse_deviceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeviceResponse' {Text
deviceArn :: Text
$sel:deviceArn:GetDeviceResponse' :: GetDeviceResponse -> Text
deviceArn} -> Text
deviceArn) (\s :: GetDeviceResponse
s@GetDeviceResponse' {} Text
a -> GetDeviceResponse
s {$sel:deviceArn:GetDeviceResponse' :: Text
deviceArn = Text
a} :: GetDeviceResponse)

-- | Details about the capabilities of the device.
getDeviceResponse_deviceCapabilities :: Lens.Lens' GetDeviceResponse Prelude.Text
getDeviceResponse_deviceCapabilities :: Lens' GetDeviceResponse Text
getDeviceResponse_deviceCapabilities = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeviceResponse' {Text
deviceCapabilities :: Text
$sel:deviceCapabilities:GetDeviceResponse' :: GetDeviceResponse -> Text
deviceCapabilities} -> Text
deviceCapabilities) (\s :: GetDeviceResponse
s@GetDeviceResponse' {} Text
a -> GetDeviceResponse
s {$sel:deviceCapabilities:GetDeviceResponse' :: Text
deviceCapabilities = Text
a} :: GetDeviceResponse)

-- | The name of the device.
getDeviceResponse_deviceName :: Lens.Lens' GetDeviceResponse Prelude.Text
getDeviceResponse_deviceName :: Lens' GetDeviceResponse Text
getDeviceResponse_deviceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeviceResponse' {Text
deviceName :: Text
$sel:deviceName:GetDeviceResponse' :: GetDeviceResponse -> Text
deviceName} -> Text
deviceName) (\s :: GetDeviceResponse
s@GetDeviceResponse' {} Text
a -> GetDeviceResponse
s {$sel:deviceName:GetDeviceResponse' :: Text
deviceName = Text
a} :: GetDeviceResponse)

-- | The status of the device.
getDeviceResponse_deviceStatus :: Lens.Lens' GetDeviceResponse DeviceStatus
getDeviceResponse_deviceStatus :: Lens' GetDeviceResponse DeviceStatus
getDeviceResponse_deviceStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeviceResponse' {DeviceStatus
deviceStatus :: DeviceStatus
$sel:deviceStatus:GetDeviceResponse' :: GetDeviceResponse -> DeviceStatus
deviceStatus} -> DeviceStatus
deviceStatus) (\s :: GetDeviceResponse
s@GetDeviceResponse' {} DeviceStatus
a -> GetDeviceResponse
s {$sel:deviceStatus:GetDeviceResponse' :: DeviceStatus
deviceStatus = DeviceStatus
a} :: GetDeviceResponse)

-- | The type of the device.
getDeviceResponse_deviceType :: Lens.Lens' GetDeviceResponse DeviceType
getDeviceResponse_deviceType :: Lens' GetDeviceResponse DeviceType
getDeviceResponse_deviceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeviceResponse' {DeviceType
deviceType :: DeviceType
$sel:deviceType:GetDeviceResponse' :: GetDeviceResponse -> DeviceType
deviceType} -> DeviceType
deviceType) (\s :: GetDeviceResponse
s@GetDeviceResponse' {} DeviceType
a -> GetDeviceResponse
s {$sel:deviceType:GetDeviceResponse' :: DeviceType
deviceType = DeviceType
a} :: GetDeviceResponse)

-- | The name of the partner company for the device.
getDeviceResponse_providerName :: Lens.Lens' GetDeviceResponse Prelude.Text
getDeviceResponse_providerName :: Lens' GetDeviceResponse Text
getDeviceResponse_providerName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeviceResponse' {Text
providerName :: Text
$sel:providerName:GetDeviceResponse' :: GetDeviceResponse -> Text
providerName} -> Text
providerName) (\s :: GetDeviceResponse
s@GetDeviceResponse' {} Text
a -> GetDeviceResponse
s {$sel:providerName:GetDeviceResponse' :: Text
providerName = Text
a} :: GetDeviceResponse)

instance Prelude.NFData GetDeviceResponse where
  rnf :: GetDeviceResponse -> ()
rnf GetDeviceResponse' {Int
Text
DeviceStatus
DeviceType
providerName :: Text
deviceType :: DeviceType
deviceStatus :: DeviceStatus
deviceName :: Text
deviceCapabilities :: Text
deviceArn :: Text
httpStatus :: Int
$sel:providerName:GetDeviceResponse' :: GetDeviceResponse -> Text
$sel:deviceType:GetDeviceResponse' :: GetDeviceResponse -> DeviceType
$sel:deviceStatus:GetDeviceResponse' :: GetDeviceResponse -> DeviceStatus
$sel:deviceName:GetDeviceResponse' :: GetDeviceResponse -> Text
$sel:deviceCapabilities:GetDeviceResponse' :: GetDeviceResponse -> Text
$sel:deviceArn:GetDeviceResponse' :: GetDeviceResponse -> Text
$sel:httpStatus:GetDeviceResponse' :: GetDeviceResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
deviceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
deviceCapabilities
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
deviceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DeviceStatus
deviceStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DeviceType
deviceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
providerName