{-# 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.ListDeviceEvents
-- 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)
--
-- Using a device ID, returns a DeviceEventsResponse object containing an
-- array of events for the device.
--
-- This operation returns paginated results.
module Amazonka.IoT1ClickDevices.ListDeviceEvents
  ( -- * Creating a Request
    ListDeviceEvents (..),
    newListDeviceEvents,

    -- * Request Lenses
    listDeviceEvents_nextToken,
    listDeviceEvents_maxResults,
    listDeviceEvents_deviceId,
    listDeviceEvents_fromTimeStamp,
    listDeviceEvents_toTimeStamp,

    -- * Destructuring the Response
    ListDeviceEventsResponse (..),
    newListDeviceEventsResponse,

    -- * Response Lenses
    listDeviceEventsResponse_nextToken,
    listDeviceEventsResponse_events,
    listDeviceEventsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT1ClickDevices.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:/ 'newListDeviceEvents' smart constructor.
data ListDeviceEvents = ListDeviceEvents'
  { -- | The token to retrieve the next set of results.
    ListDeviceEvents -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return per request. If not set, a
    -- default value of 100 is used.
    ListDeviceEvents -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The unique identifier of the device.
    ListDeviceEvents -> Text
deviceId :: Prelude.Text,
    -- | The start date for the device event query, in ISO8061 format. For
    -- example, 2018-03-28T15:45:12.880Z
    ListDeviceEvents -> POSIX
fromTimeStamp :: Core.POSIX,
    -- | The end date for the device event query, in ISO8061 format. For example,
    -- 2018-03-28T15:45:12.880Z
    ListDeviceEvents -> POSIX
toTimeStamp :: Core.POSIX
  }
  deriving (ListDeviceEvents -> ListDeviceEvents -> Bool
(ListDeviceEvents -> ListDeviceEvents -> Bool)
-> (ListDeviceEvents -> ListDeviceEvents -> Bool)
-> Eq ListDeviceEvents
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDeviceEvents -> ListDeviceEvents -> Bool
$c/= :: ListDeviceEvents -> ListDeviceEvents -> Bool
== :: ListDeviceEvents -> ListDeviceEvents -> Bool
$c== :: ListDeviceEvents -> ListDeviceEvents -> Bool
Prelude.Eq, ReadPrec [ListDeviceEvents]
ReadPrec ListDeviceEvents
Int -> ReadS ListDeviceEvents
ReadS [ListDeviceEvents]
(Int -> ReadS ListDeviceEvents)
-> ReadS [ListDeviceEvents]
-> ReadPrec ListDeviceEvents
-> ReadPrec [ListDeviceEvents]
-> Read ListDeviceEvents
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDeviceEvents]
$creadListPrec :: ReadPrec [ListDeviceEvents]
readPrec :: ReadPrec ListDeviceEvents
$creadPrec :: ReadPrec ListDeviceEvents
readList :: ReadS [ListDeviceEvents]
$creadList :: ReadS [ListDeviceEvents]
readsPrec :: Int -> ReadS ListDeviceEvents
$creadsPrec :: Int -> ReadS ListDeviceEvents
Prelude.Read, Int -> ListDeviceEvents -> ShowS
[ListDeviceEvents] -> ShowS
ListDeviceEvents -> String
(Int -> ListDeviceEvents -> ShowS)
-> (ListDeviceEvents -> String)
-> ([ListDeviceEvents] -> ShowS)
-> Show ListDeviceEvents
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDeviceEvents] -> ShowS
$cshowList :: [ListDeviceEvents] -> ShowS
show :: ListDeviceEvents -> String
$cshow :: ListDeviceEvents -> String
showsPrec :: Int -> ListDeviceEvents -> ShowS
$cshowsPrec :: Int -> ListDeviceEvents -> ShowS
Prelude.Show, (forall x. ListDeviceEvents -> Rep ListDeviceEvents x)
-> (forall x. Rep ListDeviceEvents x -> ListDeviceEvents)
-> Generic ListDeviceEvents
forall x. Rep ListDeviceEvents x -> ListDeviceEvents
forall x. ListDeviceEvents -> Rep ListDeviceEvents x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDeviceEvents x -> ListDeviceEvents
$cfrom :: forall x. ListDeviceEvents -> Rep ListDeviceEvents x
Prelude.Generic)

-- |
-- Create a value of 'ListDeviceEvents' 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:
--
-- 'nextToken', 'listDeviceEvents_nextToken' - The token to retrieve the next set of results.
--
-- 'maxResults', 'listDeviceEvents_maxResults' - The maximum number of results to return per request. If not set, a
-- default value of 100 is used.
--
-- 'deviceId', 'listDeviceEvents_deviceId' - The unique identifier of the device.
--
-- 'fromTimeStamp', 'listDeviceEvents_fromTimeStamp' - The start date for the device event query, in ISO8061 format. For
-- example, 2018-03-28T15:45:12.880Z
--
-- 'toTimeStamp', 'listDeviceEvents_toTimeStamp' - The end date for the device event query, in ISO8061 format. For example,
-- 2018-03-28T15:45:12.880Z
newListDeviceEvents ::
  -- | 'deviceId'
  Prelude.Text ->
  -- | 'fromTimeStamp'
  Prelude.UTCTime ->
  -- | 'toTimeStamp'
  Prelude.UTCTime ->
  ListDeviceEvents
newListDeviceEvents :: Text -> UTCTime -> UTCTime -> ListDeviceEvents
newListDeviceEvents
  Text
pDeviceId_
  UTCTime
pFromTimeStamp_
  UTCTime
pToTimeStamp_ =
    ListDeviceEvents' :: Maybe Text
-> Maybe Natural -> Text -> POSIX -> POSIX -> ListDeviceEvents
ListDeviceEvents'
      { $sel:nextToken:ListDeviceEvents' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:maxResults:ListDeviceEvents' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:deviceId:ListDeviceEvents' :: Text
deviceId = Text
pDeviceId_,
        $sel:fromTimeStamp:ListDeviceEvents' :: POSIX
fromTimeStamp = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pFromTimeStamp_,
        $sel:toTimeStamp:ListDeviceEvents' :: POSIX
toTimeStamp = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pToTimeStamp_
      }

-- | The token to retrieve the next set of results.
listDeviceEvents_nextToken :: Lens.Lens' ListDeviceEvents (Prelude.Maybe Prelude.Text)
listDeviceEvents_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListDeviceEvents -> f ListDeviceEvents
listDeviceEvents_nextToken = (ListDeviceEvents -> Maybe Text)
-> (ListDeviceEvents -> Maybe Text -> ListDeviceEvents)
-> Lens ListDeviceEvents ListDeviceEvents (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeviceEvents' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDeviceEvents' :: ListDeviceEvents -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDeviceEvents
s@ListDeviceEvents' {} Maybe Text
a -> ListDeviceEvents
s {$sel:nextToken:ListDeviceEvents' :: Maybe Text
nextToken = Maybe Text
a} :: ListDeviceEvents)

-- | The maximum number of results to return per request. If not set, a
-- default value of 100 is used.
listDeviceEvents_maxResults :: Lens.Lens' ListDeviceEvents (Prelude.Maybe Prelude.Natural)
listDeviceEvents_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListDeviceEvents -> f ListDeviceEvents
listDeviceEvents_maxResults = (ListDeviceEvents -> Maybe Natural)
-> (ListDeviceEvents -> Maybe Natural -> ListDeviceEvents)
-> Lens
     ListDeviceEvents ListDeviceEvents (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeviceEvents' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListDeviceEvents' :: ListDeviceEvents -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListDeviceEvents
s@ListDeviceEvents' {} Maybe Natural
a -> ListDeviceEvents
s {$sel:maxResults:ListDeviceEvents' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListDeviceEvents)

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

-- | The start date for the device event query, in ISO8061 format. For
-- example, 2018-03-28T15:45:12.880Z
listDeviceEvents_fromTimeStamp :: Lens.Lens' ListDeviceEvents Prelude.UTCTime
listDeviceEvents_fromTimeStamp :: (UTCTime -> f UTCTime) -> ListDeviceEvents -> f ListDeviceEvents
listDeviceEvents_fromTimeStamp = (ListDeviceEvents -> POSIX)
-> (ListDeviceEvents -> POSIX -> ListDeviceEvents)
-> Lens ListDeviceEvents ListDeviceEvents POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeviceEvents' {POSIX
fromTimeStamp :: POSIX
$sel:fromTimeStamp:ListDeviceEvents' :: ListDeviceEvents -> POSIX
fromTimeStamp} -> POSIX
fromTimeStamp) (\s :: ListDeviceEvents
s@ListDeviceEvents' {} POSIX
a -> ListDeviceEvents
s {$sel:fromTimeStamp:ListDeviceEvents' :: POSIX
fromTimeStamp = POSIX
a} :: ListDeviceEvents) ((POSIX -> f POSIX) -> ListDeviceEvents -> f ListDeviceEvents)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ListDeviceEvents
-> f ListDeviceEvents
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The end date for the device event query, in ISO8061 format. For example,
-- 2018-03-28T15:45:12.880Z
listDeviceEvents_toTimeStamp :: Lens.Lens' ListDeviceEvents Prelude.UTCTime
listDeviceEvents_toTimeStamp :: (UTCTime -> f UTCTime) -> ListDeviceEvents -> f ListDeviceEvents
listDeviceEvents_toTimeStamp = (ListDeviceEvents -> POSIX)
-> (ListDeviceEvents -> POSIX -> ListDeviceEvents)
-> Lens ListDeviceEvents ListDeviceEvents POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeviceEvents' {POSIX
toTimeStamp :: POSIX
$sel:toTimeStamp:ListDeviceEvents' :: ListDeviceEvents -> POSIX
toTimeStamp} -> POSIX
toTimeStamp) (\s :: ListDeviceEvents
s@ListDeviceEvents' {} POSIX
a -> ListDeviceEvents
s {$sel:toTimeStamp:ListDeviceEvents' :: POSIX
toTimeStamp = POSIX
a} :: ListDeviceEvents) ((POSIX -> f POSIX) -> ListDeviceEvents -> f ListDeviceEvents)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ListDeviceEvents
-> f ListDeviceEvents
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.AWSPager ListDeviceEvents where
  page :: ListDeviceEvents
-> AWSResponse ListDeviceEvents -> Maybe ListDeviceEvents
page ListDeviceEvents
rq AWSResponse ListDeviceEvents
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListDeviceEvents
ListDeviceEventsResponse
rs
            ListDeviceEventsResponse
-> Getting (First Text) ListDeviceEventsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListDeviceEventsResponse
-> Const (First Text) ListDeviceEventsResponse
Lens' ListDeviceEventsResponse (Maybe Text)
listDeviceEventsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListDeviceEventsResponse
 -> Const (First Text) ListDeviceEventsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListDeviceEventsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListDeviceEvents
forall a. Maybe a
Prelude.Nothing
    | Maybe [DeviceEvent] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListDeviceEvents
ListDeviceEventsResponse
rs
            ListDeviceEventsResponse
-> Getting
     (First [DeviceEvent]) ListDeviceEventsResponse [DeviceEvent]
-> Maybe [DeviceEvent]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [DeviceEvent]
 -> Const (First [DeviceEvent]) (Maybe [DeviceEvent]))
-> ListDeviceEventsResponse
-> Const (First [DeviceEvent]) ListDeviceEventsResponse
Lens' ListDeviceEventsResponse (Maybe [DeviceEvent])
listDeviceEventsResponse_events ((Maybe [DeviceEvent]
  -> Const (First [DeviceEvent]) (Maybe [DeviceEvent]))
 -> ListDeviceEventsResponse
 -> Const (First [DeviceEvent]) ListDeviceEventsResponse)
-> (([DeviceEvent] -> Const (First [DeviceEvent]) [DeviceEvent])
    -> Maybe [DeviceEvent]
    -> Const (First [DeviceEvent]) (Maybe [DeviceEvent]))
-> Getting
     (First [DeviceEvent]) ListDeviceEventsResponse [DeviceEvent]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([DeviceEvent] -> Const (First [DeviceEvent]) [DeviceEvent])
-> Maybe [DeviceEvent]
-> Const (First [DeviceEvent]) (Maybe [DeviceEvent])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListDeviceEvents
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListDeviceEvents -> Maybe ListDeviceEvents
forall a. a -> Maybe a
Prelude.Just (ListDeviceEvents -> Maybe ListDeviceEvents)
-> ListDeviceEvents -> Maybe ListDeviceEvents
forall a b. (a -> b) -> a -> b
Prelude.$
        ListDeviceEvents
rq
          ListDeviceEvents
-> (ListDeviceEvents -> ListDeviceEvents) -> ListDeviceEvents
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListDeviceEvents -> Identity ListDeviceEvents
Lens ListDeviceEvents ListDeviceEvents (Maybe Text) (Maybe Text)
listDeviceEvents_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListDeviceEvents -> Identity ListDeviceEvents)
-> Maybe Text -> ListDeviceEvents -> ListDeviceEvents
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListDeviceEvents
ListDeviceEventsResponse
rs
          ListDeviceEventsResponse
-> Getting (First Text) ListDeviceEventsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListDeviceEventsResponse
-> Const (First Text) ListDeviceEventsResponse
Lens' ListDeviceEventsResponse (Maybe Text)
listDeviceEventsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListDeviceEventsResponse
 -> Const (First Text) ListDeviceEventsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListDeviceEventsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListDeviceEvents where
  type
    AWSResponse ListDeviceEvents =
      ListDeviceEventsResponse
  request :: ListDeviceEvents -> Request ListDeviceEvents
request = Service -> ListDeviceEvents -> Request ListDeviceEvents
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListDeviceEvents
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDeviceEvents)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListDeviceEvents))
-> Logger
-> Service
-> Proxy ListDeviceEvents
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDeviceEvents)))
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
-> Maybe [DeviceEvent] -> Int -> ListDeviceEventsResponse
ListDeviceEventsResponse'
            (Maybe Text
 -> Maybe [DeviceEvent] -> Int -> ListDeviceEventsResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [DeviceEvent] -> Int -> ListDeviceEventsResponse)
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
"nextToken")
            Either
  String (Maybe [DeviceEvent] -> Int -> ListDeviceEventsResponse)
-> Either String (Maybe [DeviceEvent])
-> Either String (Int -> ListDeviceEventsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [DeviceEvent]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"events" Either String (Maybe (Maybe [DeviceEvent]))
-> Maybe [DeviceEvent] -> Either String (Maybe [DeviceEvent])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [DeviceEvent]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListDeviceEventsResponse)
-> Either String Int -> Either String ListDeviceEventsResponse
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 ListDeviceEvents

instance Prelude.NFData ListDeviceEvents

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

instance Core.ToPath ListDeviceEvents where
  toPath :: ListDeviceEvents -> ByteString
toPath ListDeviceEvents' {Maybe Natural
Maybe Text
Text
POSIX
toTimeStamp :: POSIX
fromTimeStamp :: POSIX
deviceId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:toTimeStamp:ListDeviceEvents' :: ListDeviceEvents -> POSIX
$sel:fromTimeStamp:ListDeviceEvents' :: ListDeviceEvents -> POSIX
$sel:deviceId:ListDeviceEvents' :: ListDeviceEvents -> Text
$sel:maxResults:ListDeviceEvents' :: ListDeviceEvents -> Maybe Natural
$sel:nextToken:ListDeviceEvents' :: ListDeviceEvents -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/devices/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
deviceId, ByteString
"/events"]

instance Core.ToQuery ListDeviceEvents where
  toQuery :: ListDeviceEvents -> QueryString
toQuery ListDeviceEvents' {Maybe Natural
Maybe Text
Text
POSIX
toTimeStamp :: POSIX
fromTimeStamp :: POSIX
deviceId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:toTimeStamp:ListDeviceEvents' :: ListDeviceEvents -> POSIX
$sel:fromTimeStamp:ListDeviceEvents' :: ListDeviceEvents -> POSIX
$sel:deviceId:ListDeviceEvents' :: ListDeviceEvents -> Text
$sel:maxResults:ListDeviceEvents' :: ListDeviceEvents -> Maybe Natural
$sel:nextToken:ListDeviceEvents' :: ListDeviceEvents -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"nextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"maxResults" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults,
        ByteString
"fromTimeStamp" ByteString -> POSIX -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: POSIX
fromTimeStamp,
        ByteString
"toTimeStamp" ByteString -> POSIX -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: POSIX
toTimeStamp
      ]

-- | /See:/ 'newListDeviceEventsResponse' smart constructor.
data ListDeviceEventsResponse = ListDeviceEventsResponse'
  { -- | The token to retrieve the next set of results.
    ListDeviceEventsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of zero or more elements describing the event(s) associated
    -- with the device.
    ListDeviceEventsResponse -> Maybe [DeviceEvent]
events :: Prelude.Maybe [DeviceEvent],
    -- | The response's http status code.
    ListDeviceEventsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDeviceEventsResponse -> ListDeviceEventsResponse -> Bool
(ListDeviceEventsResponse -> ListDeviceEventsResponse -> Bool)
-> (ListDeviceEventsResponse -> ListDeviceEventsResponse -> Bool)
-> Eq ListDeviceEventsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDeviceEventsResponse -> ListDeviceEventsResponse -> Bool
$c/= :: ListDeviceEventsResponse -> ListDeviceEventsResponse -> Bool
== :: ListDeviceEventsResponse -> ListDeviceEventsResponse -> Bool
$c== :: ListDeviceEventsResponse -> ListDeviceEventsResponse -> Bool
Prelude.Eq, ReadPrec [ListDeviceEventsResponse]
ReadPrec ListDeviceEventsResponse
Int -> ReadS ListDeviceEventsResponse
ReadS [ListDeviceEventsResponse]
(Int -> ReadS ListDeviceEventsResponse)
-> ReadS [ListDeviceEventsResponse]
-> ReadPrec ListDeviceEventsResponse
-> ReadPrec [ListDeviceEventsResponse]
-> Read ListDeviceEventsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDeviceEventsResponse]
$creadListPrec :: ReadPrec [ListDeviceEventsResponse]
readPrec :: ReadPrec ListDeviceEventsResponse
$creadPrec :: ReadPrec ListDeviceEventsResponse
readList :: ReadS [ListDeviceEventsResponse]
$creadList :: ReadS [ListDeviceEventsResponse]
readsPrec :: Int -> ReadS ListDeviceEventsResponse
$creadsPrec :: Int -> ReadS ListDeviceEventsResponse
Prelude.Read, Int -> ListDeviceEventsResponse -> ShowS
[ListDeviceEventsResponse] -> ShowS
ListDeviceEventsResponse -> String
(Int -> ListDeviceEventsResponse -> ShowS)
-> (ListDeviceEventsResponse -> String)
-> ([ListDeviceEventsResponse] -> ShowS)
-> Show ListDeviceEventsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDeviceEventsResponse] -> ShowS
$cshowList :: [ListDeviceEventsResponse] -> ShowS
show :: ListDeviceEventsResponse -> String
$cshow :: ListDeviceEventsResponse -> String
showsPrec :: Int -> ListDeviceEventsResponse -> ShowS
$cshowsPrec :: Int -> ListDeviceEventsResponse -> ShowS
Prelude.Show, (forall x.
 ListDeviceEventsResponse -> Rep ListDeviceEventsResponse x)
-> (forall x.
    Rep ListDeviceEventsResponse x -> ListDeviceEventsResponse)
-> Generic ListDeviceEventsResponse
forall x.
Rep ListDeviceEventsResponse x -> ListDeviceEventsResponse
forall x.
ListDeviceEventsResponse -> Rep ListDeviceEventsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListDeviceEventsResponse x -> ListDeviceEventsResponse
$cfrom :: forall x.
ListDeviceEventsResponse -> Rep ListDeviceEventsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDeviceEventsResponse' 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:
--
-- 'nextToken', 'listDeviceEventsResponse_nextToken' - The token to retrieve the next set of results.
--
-- 'events', 'listDeviceEventsResponse_events' - An array of zero or more elements describing the event(s) associated
-- with the device.
--
-- 'httpStatus', 'listDeviceEventsResponse_httpStatus' - The response's http status code.
newListDeviceEventsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDeviceEventsResponse
newListDeviceEventsResponse :: Int -> ListDeviceEventsResponse
newListDeviceEventsResponse Int
pHttpStatus_ =
  ListDeviceEventsResponse' :: Maybe Text
-> Maybe [DeviceEvent] -> Int -> ListDeviceEventsResponse
ListDeviceEventsResponse'
    { $sel:nextToken:ListDeviceEventsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:events:ListDeviceEventsResponse' :: Maybe [DeviceEvent]
events = Maybe [DeviceEvent]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDeviceEventsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token to retrieve the next set of results.
listDeviceEventsResponse_nextToken :: Lens.Lens' ListDeviceEventsResponse (Prelude.Maybe Prelude.Text)
listDeviceEventsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListDeviceEventsResponse -> f ListDeviceEventsResponse
listDeviceEventsResponse_nextToken = (ListDeviceEventsResponse -> Maybe Text)
-> (ListDeviceEventsResponse
    -> Maybe Text -> ListDeviceEventsResponse)
-> Lens' ListDeviceEventsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeviceEventsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDeviceEventsResponse' :: ListDeviceEventsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDeviceEventsResponse
s@ListDeviceEventsResponse' {} Maybe Text
a -> ListDeviceEventsResponse
s {$sel:nextToken:ListDeviceEventsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDeviceEventsResponse)

-- | An array of zero or more elements describing the event(s) associated
-- with the device.
listDeviceEventsResponse_events :: Lens.Lens' ListDeviceEventsResponse (Prelude.Maybe [DeviceEvent])
listDeviceEventsResponse_events :: (Maybe [DeviceEvent] -> f (Maybe [DeviceEvent]))
-> ListDeviceEventsResponse -> f ListDeviceEventsResponse
listDeviceEventsResponse_events = (ListDeviceEventsResponse -> Maybe [DeviceEvent])
-> (ListDeviceEventsResponse
    -> Maybe [DeviceEvent] -> ListDeviceEventsResponse)
-> Lens' ListDeviceEventsResponse (Maybe [DeviceEvent])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeviceEventsResponse' {Maybe [DeviceEvent]
events :: Maybe [DeviceEvent]
$sel:events:ListDeviceEventsResponse' :: ListDeviceEventsResponse -> Maybe [DeviceEvent]
events} -> Maybe [DeviceEvent]
events) (\s :: ListDeviceEventsResponse
s@ListDeviceEventsResponse' {} Maybe [DeviceEvent]
a -> ListDeviceEventsResponse
s {$sel:events:ListDeviceEventsResponse' :: Maybe [DeviceEvent]
events = Maybe [DeviceEvent]
a} :: ListDeviceEventsResponse) ((Maybe [DeviceEvent] -> f (Maybe [DeviceEvent]))
 -> ListDeviceEventsResponse -> f ListDeviceEventsResponse)
-> ((Maybe [DeviceEvent] -> f (Maybe [DeviceEvent]))
    -> Maybe [DeviceEvent] -> f (Maybe [DeviceEvent]))
-> (Maybe [DeviceEvent] -> f (Maybe [DeviceEvent]))
-> ListDeviceEventsResponse
-> f ListDeviceEventsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [DeviceEvent] [DeviceEvent] [DeviceEvent] [DeviceEvent]
-> Iso
     (Maybe [DeviceEvent])
     (Maybe [DeviceEvent])
     (Maybe [DeviceEvent])
     (Maybe [DeviceEvent])
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 AnIso [DeviceEvent] [DeviceEvent] [DeviceEvent] [DeviceEvent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListDeviceEventsResponse