{-# 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.IoT1ClickDevices.GetDeviceMethods
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Given a device ID, returns the invokable methods associated with the
-- device.
module Amazonka.IoT1ClickDevices.GetDeviceMethods
  ( -- * Creating a Request
    GetDeviceMethods (..),
    newGetDeviceMethods,

    -- * Request Lenses
    getDeviceMethods_deviceId,

    -- * Destructuring the Response
    GetDeviceMethodsResponse (..),
    newGetDeviceMethodsResponse,

    -- * Response Lenses
    getDeviceMethodsResponse_deviceMethods,
    getDeviceMethodsResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'GetDeviceMethods' 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:
--
-- 'deviceId', 'getDeviceMethods_deviceId' - The unique identifier of the device.
newGetDeviceMethods ::
  -- | 'deviceId'
  Prelude.Text ->
  GetDeviceMethods
newGetDeviceMethods :: Text -> GetDeviceMethods
newGetDeviceMethods Text
pDeviceId_ =
  GetDeviceMethods' {$sel:deviceId:GetDeviceMethods' :: Text
deviceId = Text
pDeviceId_}

-- | The unique identifier of the device.
getDeviceMethods_deviceId :: Lens.Lens' GetDeviceMethods Prelude.Text
getDeviceMethods_deviceId :: Lens' GetDeviceMethods Text
getDeviceMethods_deviceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeviceMethods' {Text
deviceId :: Text
$sel:deviceId:GetDeviceMethods' :: GetDeviceMethods -> Text
deviceId} -> Text
deviceId) (\s :: GetDeviceMethods
s@GetDeviceMethods' {} Text
a -> GetDeviceMethods
s {$sel:deviceId:GetDeviceMethods' :: Text
deviceId = Text
a} :: GetDeviceMethods)

instance Core.AWSRequest GetDeviceMethods where
  type
    AWSResponse GetDeviceMethods =
      GetDeviceMethodsResponse
  request :: (Service -> Service)
-> GetDeviceMethods -> Request GetDeviceMethods
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 GetDeviceMethods
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDeviceMethods)))
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 [DeviceMethod] -> Int -> GetDeviceMethodsResponse
GetDeviceMethodsResponse'
            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
"deviceMethods" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 GetDeviceMethods where
  hashWithSalt :: Int -> GetDeviceMethods -> Int
hashWithSalt Int
_salt GetDeviceMethods' {Text
deviceId :: Text
$sel:deviceId:GetDeviceMethods' :: GetDeviceMethods -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
deviceId

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

instance Data.ToHeaders GetDeviceMethods where
  toHeaders :: GetDeviceMethods -> 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 GetDeviceMethods where
  toPath :: GetDeviceMethods -> ByteString
toPath GetDeviceMethods' {Text
deviceId :: Text
$sel:deviceId:GetDeviceMethods' :: GetDeviceMethods -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/devices/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
deviceId, ByteString
"/methods"]

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

-- | /See:/ 'newGetDeviceMethodsResponse' smart constructor.
data GetDeviceMethodsResponse = GetDeviceMethodsResponse'
  { -- | List of available device APIs.
    GetDeviceMethodsResponse -> Maybe [DeviceMethod]
deviceMethods :: Prelude.Maybe [DeviceMethod],
    -- | The response's http status code.
    GetDeviceMethodsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDeviceMethodsResponse -> GetDeviceMethodsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDeviceMethodsResponse -> GetDeviceMethodsResponse -> Bool
$c/= :: GetDeviceMethodsResponse -> GetDeviceMethodsResponse -> Bool
== :: GetDeviceMethodsResponse -> GetDeviceMethodsResponse -> Bool
$c== :: GetDeviceMethodsResponse -> GetDeviceMethodsResponse -> Bool
Prelude.Eq, ReadPrec [GetDeviceMethodsResponse]
ReadPrec GetDeviceMethodsResponse
Int -> ReadS GetDeviceMethodsResponse
ReadS [GetDeviceMethodsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDeviceMethodsResponse]
$creadListPrec :: ReadPrec [GetDeviceMethodsResponse]
readPrec :: ReadPrec GetDeviceMethodsResponse
$creadPrec :: ReadPrec GetDeviceMethodsResponse
readList :: ReadS [GetDeviceMethodsResponse]
$creadList :: ReadS [GetDeviceMethodsResponse]
readsPrec :: Int -> ReadS GetDeviceMethodsResponse
$creadsPrec :: Int -> ReadS GetDeviceMethodsResponse
Prelude.Read, Int -> GetDeviceMethodsResponse -> ShowS
[GetDeviceMethodsResponse] -> ShowS
GetDeviceMethodsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDeviceMethodsResponse] -> ShowS
$cshowList :: [GetDeviceMethodsResponse] -> ShowS
show :: GetDeviceMethodsResponse -> String
$cshow :: GetDeviceMethodsResponse -> String
showsPrec :: Int -> GetDeviceMethodsResponse -> ShowS
$cshowsPrec :: Int -> GetDeviceMethodsResponse -> ShowS
Prelude.Show, forall x.
Rep GetDeviceMethodsResponse x -> GetDeviceMethodsResponse
forall x.
GetDeviceMethodsResponse -> Rep GetDeviceMethodsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDeviceMethodsResponse x -> GetDeviceMethodsResponse
$cfrom :: forall x.
GetDeviceMethodsResponse -> Rep GetDeviceMethodsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDeviceMethodsResponse' 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:
--
-- 'deviceMethods', 'getDeviceMethodsResponse_deviceMethods' - List of available device APIs.
--
-- 'httpStatus', 'getDeviceMethodsResponse_httpStatus' - The response's http status code.
newGetDeviceMethodsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDeviceMethodsResponse
newGetDeviceMethodsResponse :: Int -> GetDeviceMethodsResponse
newGetDeviceMethodsResponse Int
pHttpStatus_ =
  GetDeviceMethodsResponse'
    { $sel:deviceMethods:GetDeviceMethodsResponse' :: Maybe [DeviceMethod]
deviceMethods =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDeviceMethodsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | List of available device APIs.
getDeviceMethodsResponse_deviceMethods :: Lens.Lens' GetDeviceMethodsResponse (Prelude.Maybe [DeviceMethod])
getDeviceMethodsResponse_deviceMethods :: Lens' GetDeviceMethodsResponse (Maybe [DeviceMethod])
getDeviceMethodsResponse_deviceMethods = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeviceMethodsResponse' {Maybe [DeviceMethod]
deviceMethods :: Maybe [DeviceMethod]
$sel:deviceMethods:GetDeviceMethodsResponse' :: GetDeviceMethodsResponse -> Maybe [DeviceMethod]
deviceMethods} -> Maybe [DeviceMethod]
deviceMethods) (\s :: GetDeviceMethodsResponse
s@GetDeviceMethodsResponse' {} Maybe [DeviceMethod]
a -> GetDeviceMethodsResponse
s {$sel:deviceMethods:GetDeviceMethodsResponse' :: Maybe [DeviceMethod]
deviceMethods = Maybe [DeviceMethod]
a} :: GetDeviceMethodsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData GetDeviceMethodsResponse where
  rnf :: GetDeviceMethodsResponse -> ()
rnf GetDeviceMethodsResponse' {Int
Maybe [DeviceMethod]
httpStatus :: Int
deviceMethods :: Maybe [DeviceMethod]
$sel:httpStatus:GetDeviceMethodsResponse' :: GetDeviceMethodsResponse -> Int
$sel:deviceMethods:GetDeviceMethodsResponse' :: GetDeviceMethodsResponse -> Maybe [DeviceMethod]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DeviceMethod]
deviceMethods
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus