{-# 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-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)
--
-- 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 Amazonka.IoTWireless.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:/ 'newTestWirelessDevice' smart constructor.
data TestWirelessDevice = TestWirelessDevice'
  { -- | The ID of the wireless device to test.
    TestWirelessDevice -> Text
id :: Prelude.Text
  }
  deriving (TestWirelessDevice -> TestWirelessDevice -> Bool
(TestWirelessDevice -> TestWirelessDevice -> Bool)
-> (TestWirelessDevice -> TestWirelessDevice -> Bool)
-> Eq TestWirelessDevice
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]
(Int -> ReadS TestWirelessDevice)
-> ReadS [TestWirelessDevice]
-> ReadPrec TestWirelessDevice
-> ReadPrec [TestWirelessDevice]
-> Read 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
(Int -> TestWirelessDevice -> ShowS)
-> (TestWirelessDevice -> String)
-> ([TestWirelessDevice] -> ShowS)
-> Show TestWirelessDevice
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. TestWirelessDevice -> Rep TestWirelessDevice x)
-> (forall x. Rep TestWirelessDevice x -> TestWirelessDevice)
-> Generic TestWirelessDevice
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' :: Text -> TestWirelessDevice
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 :: (Text -> f Text) -> TestWirelessDevice -> f TestWirelessDevice
testWirelessDevice_id = (TestWirelessDevice -> Text)
-> (TestWirelessDevice -> Text -> TestWirelessDevice)
-> Lens TestWirelessDevice TestWirelessDevice Text Text
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 :: TestWirelessDevice -> Request TestWirelessDevice
request = Service -> TestWirelessDevice -> Request TestWirelessDevice
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy TestWirelessDevice
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse TestWirelessDevice)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse TestWirelessDevice))
-> Logger
-> Service
-> Proxy TestWirelessDevice
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse TestWirelessDevice)))
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 Text -> Int -> TestWirelessDeviceResponse
TestWirelessDeviceResponse'
            (Maybe Text -> Int -> TestWirelessDeviceResponse)
-> Either String (Maybe Text)
-> Either String (Int -> TestWirelessDeviceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Result")
            Either String (Int -> TestWirelessDeviceResponse)
-> Either String Int -> Either String TestWirelessDeviceResponse
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 TestWirelessDevice

instance Prelude.NFData TestWirelessDevice

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

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

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

instance Core.ToQuery TestWirelessDevice where
  toQuery :: TestWirelessDevice -> QueryString
toQuery = QueryString -> TestWirelessDevice -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(TestWirelessDeviceResponse -> TestWirelessDeviceResponse -> Bool)
-> (TestWirelessDeviceResponse
    -> TestWirelessDeviceResponse -> Bool)
-> Eq TestWirelessDeviceResponse
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]
(Int -> ReadS TestWirelessDeviceResponse)
-> ReadS [TestWirelessDeviceResponse]
-> ReadPrec TestWirelessDeviceResponse
-> ReadPrec [TestWirelessDeviceResponse]
-> Read 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
(Int -> TestWirelessDeviceResponse -> ShowS)
-> (TestWirelessDeviceResponse -> String)
-> ([TestWirelessDeviceResponse] -> ShowS)
-> Show TestWirelessDeviceResponse
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.
 TestWirelessDeviceResponse -> Rep TestWirelessDeviceResponse x)
-> (forall x.
    Rep TestWirelessDeviceResponse x -> TestWirelessDeviceResponse)
-> Generic TestWirelessDeviceResponse
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' :: Maybe Text -> Int -> TestWirelessDeviceResponse
TestWirelessDeviceResponse'
    { $sel:result:TestWirelessDeviceResponse' :: Maybe Text
result =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> TestWirelessDeviceResponse -> f TestWirelessDeviceResponse
testWirelessDeviceResponse_result = (TestWirelessDeviceResponse -> Maybe Text)
-> (TestWirelessDeviceResponse
    -> Maybe Text -> TestWirelessDeviceResponse)
-> Lens
     TestWirelessDeviceResponse
     TestWirelessDeviceResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> TestWirelessDeviceResponse -> f TestWirelessDeviceResponse
testWirelessDeviceResponse_httpStatus = (TestWirelessDeviceResponse -> Int)
-> (TestWirelessDeviceResponse
    -> Int -> TestWirelessDeviceResponse)
-> Lens
     TestWirelessDeviceResponse TestWirelessDeviceResponse Int Int
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