{-# 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.IoTWireless.TestWirelessDevice
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Simulates a provisioned device by sending an uplink data payload of
-- @Hello@.
module Amazonka.IoTWireless.TestWirelessDevice
  ( -- * Creating a Request
    TestWirelessDevice (..),
    newTestWirelessDevice,

    -- * Request Lenses
    testWirelessDevice_id,

    -- * Destructuring the Response
    TestWirelessDeviceResponse (..),
    newTestWirelessDeviceResponse,

    -- * Response Lenses
    testWirelessDeviceResponse_result,
    testWirelessDeviceResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'TestWirelessDevice' 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:
--
-- 'id', 'testWirelessDevice_id' - The ID of the wireless device to test.
newTestWirelessDevice ::
  -- | 'id'
  Prelude.Text ->
  TestWirelessDevice
newTestWirelessDevice :: Text -> TestWirelessDevice
newTestWirelessDevice Text
pId_ =
  TestWirelessDevice' {$sel:id:TestWirelessDevice' :: Text
id = Text
pId_}

-- | The ID of the wireless device to test.
testWirelessDevice_id :: Lens.Lens' TestWirelessDevice Prelude.Text
testWirelessDevice_id :: Lens' TestWirelessDevice Text
testWirelessDevice_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestWirelessDevice' {Text
id :: Text
$sel:id:TestWirelessDevice' :: TestWirelessDevice -> Text
id} -> Text
id) (\s :: TestWirelessDevice
s@TestWirelessDevice' {} Text
a -> TestWirelessDevice
s {$sel:id:TestWirelessDevice' :: Text
id = Text
a} :: TestWirelessDevice)

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

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

instance Data.ToHeaders TestWirelessDevice where
  toHeaders :: TestWirelessDevice -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToJSON TestWirelessDevice where
  toJSON :: TestWirelessDevice -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath TestWirelessDevice where
  toPath :: TestWirelessDevice -> ByteString
toPath TestWirelessDevice' {Text
id :: Text
$sel:id:TestWirelessDevice' :: TestWirelessDevice -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/wireless-devices/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id, ByteString
"/test"]

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

-- | /See:/ 'newTestWirelessDeviceResponse' smart constructor.
data TestWirelessDeviceResponse = TestWirelessDeviceResponse'
  { -- | The result returned by the test.
    TestWirelessDeviceResponse -> Maybe Text
result :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    TestWirelessDeviceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (TestWirelessDeviceResponse -> TestWirelessDeviceResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestWirelessDeviceResponse -> TestWirelessDeviceResponse -> Bool
$c/= :: TestWirelessDeviceResponse -> TestWirelessDeviceResponse -> Bool
== :: TestWirelessDeviceResponse -> TestWirelessDeviceResponse -> Bool
$c== :: TestWirelessDeviceResponse -> TestWirelessDeviceResponse -> Bool
Prelude.Eq, ReadPrec [TestWirelessDeviceResponse]
ReadPrec TestWirelessDeviceResponse
Int -> ReadS TestWirelessDeviceResponse
ReadS [TestWirelessDeviceResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestWirelessDeviceResponse]
$creadListPrec :: ReadPrec [TestWirelessDeviceResponse]
readPrec :: ReadPrec TestWirelessDeviceResponse
$creadPrec :: ReadPrec TestWirelessDeviceResponse
readList :: ReadS [TestWirelessDeviceResponse]
$creadList :: ReadS [TestWirelessDeviceResponse]
readsPrec :: Int -> ReadS TestWirelessDeviceResponse
$creadsPrec :: Int -> ReadS TestWirelessDeviceResponse
Prelude.Read, Int -> TestWirelessDeviceResponse -> ShowS
[TestWirelessDeviceResponse] -> ShowS
TestWirelessDeviceResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestWirelessDeviceResponse] -> ShowS
$cshowList :: [TestWirelessDeviceResponse] -> ShowS
show :: TestWirelessDeviceResponse -> String
$cshow :: TestWirelessDeviceResponse -> String
showsPrec :: Int -> TestWirelessDeviceResponse -> ShowS
$cshowsPrec :: Int -> TestWirelessDeviceResponse -> ShowS
Prelude.Show, forall x.
Rep TestWirelessDeviceResponse x -> TestWirelessDeviceResponse
forall x.
TestWirelessDeviceResponse -> Rep TestWirelessDeviceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TestWirelessDeviceResponse x -> TestWirelessDeviceResponse
$cfrom :: forall x.
TestWirelessDeviceResponse -> Rep TestWirelessDeviceResponse x
Prelude.Generic)

-- |
-- Create a value of 'TestWirelessDeviceResponse' 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:
--
-- 'result', 'testWirelessDeviceResponse_result' - The result returned by the test.
--
-- 'httpStatus', 'testWirelessDeviceResponse_httpStatus' - The response's http status code.
newTestWirelessDeviceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  TestWirelessDeviceResponse
newTestWirelessDeviceResponse :: Int -> TestWirelessDeviceResponse
newTestWirelessDeviceResponse Int
pHttpStatus_ =
  TestWirelessDeviceResponse'
    { $sel:result:TestWirelessDeviceResponse' :: Maybe Text
result =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:TestWirelessDeviceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The result returned by the test.
testWirelessDeviceResponse_result :: Lens.Lens' TestWirelessDeviceResponse (Prelude.Maybe Prelude.Text)
testWirelessDeviceResponse_result :: Lens' TestWirelessDeviceResponse (Maybe Text)
testWirelessDeviceResponse_result = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestWirelessDeviceResponse' {Maybe Text
result :: Maybe Text
$sel:result:TestWirelessDeviceResponse' :: TestWirelessDeviceResponse -> Maybe Text
result} -> Maybe Text
result) (\s :: TestWirelessDeviceResponse
s@TestWirelessDeviceResponse' {} Maybe Text
a -> TestWirelessDeviceResponse
s {$sel:result:TestWirelessDeviceResponse' :: Maybe Text
result = Maybe Text
a} :: TestWirelessDeviceResponse)

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

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