{-# 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.IoT.ListJobExecutionsForThing
-- 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)
--
-- Lists the job executions for the specified thing.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions ListJobExecutionsForThing>
-- action.
--
-- This operation returns paginated results.
module Amazonka.IoT.ListJobExecutionsForThing
  ( -- * Creating a Request
    ListJobExecutionsForThing (..),
    newListJobExecutionsForThing,

    -- * Request Lenses
    listJobExecutionsForThing_status,
    listJobExecutionsForThing_namespaceId,
    listJobExecutionsForThing_nextToken,
    listJobExecutionsForThing_maxResults,
    listJobExecutionsForThing_thingName,

    -- * Destructuring the Response
    ListJobExecutionsForThingResponse (..),
    newListJobExecutionsForThingResponse,

    -- * Response Lenses
    listJobExecutionsForThingResponse_executionSummaries,
    listJobExecutionsForThingResponse_nextToken,
    listJobExecutionsForThingResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.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:/ 'newListJobExecutionsForThing' smart constructor.
data ListJobExecutionsForThing = ListJobExecutionsForThing'
  { -- | An optional filter that lets you search for jobs that have the specified
    -- status.
    ListJobExecutionsForThing -> Maybe JobExecutionStatus
status :: Prelude.Maybe JobExecutionStatus,
    -- | The namespace used to indicate that a job is a customer-managed job.
    --
    -- When you specify a value for this parameter, Amazon Web Services IoT
    -- Core sends jobs notifications to MQTT topics that contain the value in
    -- the following format.
    --
    -- @$aws\/things\/THING_NAME\/jobs\/JOB_ID\/notify-namespace-NAMESPACE_ID\/@
    --
    -- The @namespaceId@ feature is in public preview.
    ListJobExecutionsForThing -> Maybe Text
namespaceId :: Prelude.Maybe Prelude.Text,
    -- | The token to retrieve the next set of results.
    ListJobExecutionsForThing -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to be returned per request.
    ListJobExecutionsForThing -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The thing name.
    ListJobExecutionsForThing -> Text
thingName :: Prelude.Text
  }
  deriving (ListJobExecutionsForThing -> ListJobExecutionsForThing -> Bool
(ListJobExecutionsForThing -> ListJobExecutionsForThing -> Bool)
-> (ListJobExecutionsForThing -> ListJobExecutionsForThing -> Bool)
-> Eq ListJobExecutionsForThing
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListJobExecutionsForThing -> ListJobExecutionsForThing -> Bool
$c/= :: ListJobExecutionsForThing -> ListJobExecutionsForThing -> Bool
== :: ListJobExecutionsForThing -> ListJobExecutionsForThing -> Bool
$c== :: ListJobExecutionsForThing -> ListJobExecutionsForThing -> Bool
Prelude.Eq, ReadPrec [ListJobExecutionsForThing]
ReadPrec ListJobExecutionsForThing
Int -> ReadS ListJobExecutionsForThing
ReadS [ListJobExecutionsForThing]
(Int -> ReadS ListJobExecutionsForThing)
-> ReadS [ListJobExecutionsForThing]
-> ReadPrec ListJobExecutionsForThing
-> ReadPrec [ListJobExecutionsForThing]
-> Read ListJobExecutionsForThing
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListJobExecutionsForThing]
$creadListPrec :: ReadPrec [ListJobExecutionsForThing]
readPrec :: ReadPrec ListJobExecutionsForThing
$creadPrec :: ReadPrec ListJobExecutionsForThing
readList :: ReadS [ListJobExecutionsForThing]
$creadList :: ReadS [ListJobExecutionsForThing]
readsPrec :: Int -> ReadS ListJobExecutionsForThing
$creadsPrec :: Int -> ReadS ListJobExecutionsForThing
Prelude.Read, Int -> ListJobExecutionsForThing -> ShowS
[ListJobExecutionsForThing] -> ShowS
ListJobExecutionsForThing -> String
(Int -> ListJobExecutionsForThing -> ShowS)
-> (ListJobExecutionsForThing -> String)
-> ([ListJobExecutionsForThing] -> ShowS)
-> Show ListJobExecutionsForThing
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListJobExecutionsForThing] -> ShowS
$cshowList :: [ListJobExecutionsForThing] -> ShowS
show :: ListJobExecutionsForThing -> String
$cshow :: ListJobExecutionsForThing -> String
showsPrec :: Int -> ListJobExecutionsForThing -> ShowS
$cshowsPrec :: Int -> ListJobExecutionsForThing -> ShowS
Prelude.Show, (forall x.
 ListJobExecutionsForThing -> Rep ListJobExecutionsForThing x)
-> (forall x.
    Rep ListJobExecutionsForThing x -> ListJobExecutionsForThing)
-> Generic ListJobExecutionsForThing
forall x.
Rep ListJobExecutionsForThing x -> ListJobExecutionsForThing
forall x.
ListJobExecutionsForThing -> Rep ListJobExecutionsForThing x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListJobExecutionsForThing x -> ListJobExecutionsForThing
$cfrom :: forall x.
ListJobExecutionsForThing -> Rep ListJobExecutionsForThing x
Prelude.Generic)

-- |
-- Create a value of 'ListJobExecutionsForThing' 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:
--
-- 'status', 'listJobExecutionsForThing_status' - An optional filter that lets you search for jobs that have the specified
-- status.
--
-- 'namespaceId', 'listJobExecutionsForThing_namespaceId' - The namespace used to indicate that a job is a customer-managed job.
--
-- When you specify a value for this parameter, Amazon Web Services IoT
-- Core sends jobs notifications to MQTT topics that contain the value in
-- the following format.
--
-- @$aws\/things\/THING_NAME\/jobs\/JOB_ID\/notify-namespace-NAMESPACE_ID\/@
--
-- The @namespaceId@ feature is in public preview.
--
-- 'nextToken', 'listJobExecutionsForThing_nextToken' - The token to retrieve the next set of results.
--
-- 'maxResults', 'listJobExecutionsForThing_maxResults' - The maximum number of results to be returned per request.
--
-- 'thingName', 'listJobExecutionsForThing_thingName' - The thing name.
newListJobExecutionsForThing ::
  -- | 'thingName'
  Prelude.Text ->
  ListJobExecutionsForThing
newListJobExecutionsForThing :: Text -> ListJobExecutionsForThing
newListJobExecutionsForThing Text
pThingName_ =
  ListJobExecutionsForThing' :: Maybe JobExecutionStatus
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Text
-> ListJobExecutionsForThing
ListJobExecutionsForThing'
    { $sel:status:ListJobExecutionsForThing' :: Maybe JobExecutionStatus
status =
        Maybe JobExecutionStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:namespaceId:ListJobExecutionsForThing' :: Maybe Text
namespaceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListJobExecutionsForThing' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListJobExecutionsForThing' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:thingName:ListJobExecutionsForThing' :: Text
thingName = Text
pThingName_
    }

-- | An optional filter that lets you search for jobs that have the specified
-- status.
listJobExecutionsForThing_status :: Lens.Lens' ListJobExecutionsForThing (Prelude.Maybe JobExecutionStatus)
listJobExecutionsForThing_status :: (Maybe JobExecutionStatus -> f (Maybe JobExecutionStatus))
-> ListJobExecutionsForThing -> f ListJobExecutionsForThing
listJobExecutionsForThing_status = (ListJobExecutionsForThing -> Maybe JobExecutionStatus)
-> (ListJobExecutionsForThing
    -> Maybe JobExecutionStatus -> ListJobExecutionsForThing)
-> Lens
     ListJobExecutionsForThing
     ListJobExecutionsForThing
     (Maybe JobExecutionStatus)
     (Maybe JobExecutionStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobExecutionsForThing' {Maybe JobExecutionStatus
status :: Maybe JobExecutionStatus
$sel:status:ListJobExecutionsForThing' :: ListJobExecutionsForThing -> Maybe JobExecutionStatus
status} -> Maybe JobExecutionStatus
status) (\s :: ListJobExecutionsForThing
s@ListJobExecutionsForThing' {} Maybe JobExecutionStatus
a -> ListJobExecutionsForThing
s {$sel:status:ListJobExecutionsForThing' :: Maybe JobExecutionStatus
status = Maybe JobExecutionStatus
a} :: ListJobExecutionsForThing)

-- | The namespace used to indicate that a job is a customer-managed job.
--
-- When you specify a value for this parameter, Amazon Web Services IoT
-- Core sends jobs notifications to MQTT topics that contain the value in
-- the following format.
--
-- @$aws\/things\/THING_NAME\/jobs\/JOB_ID\/notify-namespace-NAMESPACE_ID\/@
--
-- The @namespaceId@ feature is in public preview.
listJobExecutionsForThing_namespaceId :: Lens.Lens' ListJobExecutionsForThing (Prelude.Maybe Prelude.Text)
listJobExecutionsForThing_namespaceId :: (Maybe Text -> f (Maybe Text))
-> ListJobExecutionsForThing -> f ListJobExecutionsForThing
listJobExecutionsForThing_namespaceId = (ListJobExecutionsForThing -> Maybe Text)
-> (ListJobExecutionsForThing
    -> Maybe Text -> ListJobExecutionsForThing)
-> Lens
     ListJobExecutionsForThing
     ListJobExecutionsForThing
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobExecutionsForThing' {Maybe Text
namespaceId :: Maybe Text
$sel:namespaceId:ListJobExecutionsForThing' :: ListJobExecutionsForThing -> Maybe Text
namespaceId} -> Maybe Text
namespaceId) (\s :: ListJobExecutionsForThing
s@ListJobExecutionsForThing' {} Maybe Text
a -> ListJobExecutionsForThing
s {$sel:namespaceId:ListJobExecutionsForThing' :: Maybe Text
namespaceId = Maybe Text
a} :: ListJobExecutionsForThing)

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

-- | The maximum number of results to be returned per request.
listJobExecutionsForThing_maxResults :: Lens.Lens' ListJobExecutionsForThing (Prelude.Maybe Prelude.Natural)
listJobExecutionsForThing_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListJobExecutionsForThing -> f ListJobExecutionsForThing
listJobExecutionsForThing_maxResults = (ListJobExecutionsForThing -> Maybe Natural)
-> (ListJobExecutionsForThing
    -> Maybe Natural -> ListJobExecutionsForThing)
-> Lens
     ListJobExecutionsForThing
     ListJobExecutionsForThing
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobExecutionsForThing' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListJobExecutionsForThing' :: ListJobExecutionsForThing -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListJobExecutionsForThing
s@ListJobExecutionsForThing' {} Maybe Natural
a -> ListJobExecutionsForThing
s {$sel:maxResults:ListJobExecutionsForThing' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListJobExecutionsForThing)

-- | The thing name.
listJobExecutionsForThing_thingName :: Lens.Lens' ListJobExecutionsForThing Prelude.Text
listJobExecutionsForThing_thingName :: (Text -> f Text)
-> ListJobExecutionsForThing -> f ListJobExecutionsForThing
listJobExecutionsForThing_thingName = (ListJobExecutionsForThing -> Text)
-> (ListJobExecutionsForThing -> Text -> ListJobExecutionsForThing)
-> Lens
     ListJobExecutionsForThing ListJobExecutionsForThing Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobExecutionsForThing' {Text
thingName :: Text
$sel:thingName:ListJobExecutionsForThing' :: ListJobExecutionsForThing -> Text
thingName} -> Text
thingName) (\s :: ListJobExecutionsForThing
s@ListJobExecutionsForThing' {} Text
a -> ListJobExecutionsForThing
s {$sel:thingName:ListJobExecutionsForThing' :: Text
thingName = Text
a} :: ListJobExecutionsForThing)

instance Core.AWSPager ListJobExecutionsForThing where
  page :: ListJobExecutionsForThing
-> AWSResponse ListJobExecutionsForThing
-> Maybe ListJobExecutionsForThing
page ListJobExecutionsForThing
rq AWSResponse ListJobExecutionsForThing
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListJobExecutionsForThing
ListJobExecutionsForThingResponse
rs
            ListJobExecutionsForThingResponse
-> Getting (First Text) ListJobExecutionsForThingResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListJobExecutionsForThingResponse
-> Const (First Text) ListJobExecutionsForThingResponse
Lens' ListJobExecutionsForThingResponse (Maybe Text)
listJobExecutionsForThingResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListJobExecutionsForThingResponse
 -> Const (First Text) ListJobExecutionsForThingResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListJobExecutionsForThingResponse 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 ListJobExecutionsForThing
forall a. Maybe a
Prelude.Nothing
    | Maybe [JobExecutionSummaryForThing] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListJobExecutionsForThing
ListJobExecutionsForThingResponse
rs
            ListJobExecutionsForThingResponse
-> Getting
     (First [JobExecutionSummaryForThing])
     ListJobExecutionsForThingResponse
     [JobExecutionSummaryForThing]
-> Maybe [JobExecutionSummaryForThing]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [JobExecutionSummaryForThing]
 -> Const
      (First [JobExecutionSummaryForThing])
      (Maybe [JobExecutionSummaryForThing]))
-> ListJobExecutionsForThingResponse
-> Const
     (First [JobExecutionSummaryForThing])
     ListJobExecutionsForThingResponse
Lens'
  ListJobExecutionsForThingResponse
  (Maybe [JobExecutionSummaryForThing])
listJobExecutionsForThingResponse_executionSummaries
              ((Maybe [JobExecutionSummaryForThing]
  -> Const
       (First [JobExecutionSummaryForThing])
       (Maybe [JobExecutionSummaryForThing]))
 -> ListJobExecutionsForThingResponse
 -> Const
      (First [JobExecutionSummaryForThing])
      ListJobExecutionsForThingResponse)
-> (([JobExecutionSummaryForThing]
     -> Const
          (First [JobExecutionSummaryForThing])
          [JobExecutionSummaryForThing])
    -> Maybe [JobExecutionSummaryForThing]
    -> Const
         (First [JobExecutionSummaryForThing])
         (Maybe [JobExecutionSummaryForThing]))
-> Getting
     (First [JobExecutionSummaryForThing])
     ListJobExecutionsForThingResponse
     [JobExecutionSummaryForThing]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([JobExecutionSummaryForThing]
 -> Const
      (First [JobExecutionSummaryForThing])
      [JobExecutionSummaryForThing])
-> Maybe [JobExecutionSummaryForThing]
-> Const
     (First [JobExecutionSummaryForThing])
     (Maybe [JobExecutionSummaryForThing])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListJobExecutionsForThing
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListJobExecutionsForThing -> Maybe ListJobExecutionsForThing
forall a. a -> Maybe a
Prelude.Just (ListJobExecutionsForThing -> Maybe ListJobExecutionsForThing)
-> ListJobExecutionsForThing -> Maybe ListJobExecutionsForThing
forall a b. (a -> b) -> a -> b
Prelude.$
        ListJobExecutionsForThing
rq
          ListJobExecutionsForThing
-> (ListJobExecutionsForThing -> ListJobExecutionsForThing)
-> ListJobExecutionsForThing
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListJobExecutionsForThing -> Identity ListJobExecutionsForThing
Lens
  ListJobExecutionsForThing
  ListJobExecutionsForThing
  (Maybe Text)
  (Maybe Text)
listJobExecutionsForThing_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListJobExecutionsForThing -> Identity ListJobExecutionsForThing)
-> Maybe Text
-> ListJobExecutionsForThing
-> ListJobExecutionsForThing
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListJobExecutionsForThing
ListJobExecutionsForThingResponse
rs
          ListJobExecutionsForThingResponse
-> Getting (First Text) ListJobExecutionsForThingResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListJobExecutionsForThingResponse
-> Const (First Text) ListJobExecutionsForThingResponse
Lens' ListJobExecutionsForThingResponse (Maybe Text)
listJobExecutionsForThingResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListJobExecutionsForThingResponse
 -> Const (First Text) ListJobExecutionsForThingResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListJobExecutionsForThingResponse 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 ListJobExecutionsForThing where
  type
    AWSResponse ListJobExecutionsForThing =
      ListJobExecutionsForThingResponse
  request :: ListJobExecutionsForThing -> Request ListJobExecutionsForThing
request = Service
-> ListJobExecutionsForThing -> Request ListJobExecutionsForThing
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListJobExecutionsForThing
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListJobExecutionsForThing)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListJobExecutionsForThing))
-> Logger
-> Service
-> Proxy ListJobExecutionsForThing
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListJobExecutionsForThing)))
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 [JobExecutionSummaryForThing]
-> Maybe Text -> Int -> ListJobExecutionsForThingResponse
ListJobExecutionsForThingResponse'
            (Maybe [JobExecutionSummaryForThing]
 -> Maybe Text -> Int -> ListJobExecutionsForThingResponse)
-> Either String (Maybe [JobExecutionSummaryForThing])
-> Either
     String (Maybe Text -> Int -> ListJobExecutionsForThingResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text
-> Either String (Maybe (Maybe [JobExecutionSummaryForThing]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"executionSummaries"
                            Either String (Maybe (Maybe [JobExecutionSummaryForThing]))
-> Maybe [JobExecutionSummaryForThing]
-> Either String (Maybe [JobExecutionSummaryForThing])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [JobExecutionSummaryForThing]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either
  String (Maybe Text -> Int -> ListJobExecutionsForThingResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListJobExecutionsForThingResponse)
forall (f :: * -> *) a b. Applicative f => 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 (Int -> ListJobExecutionsForThingResponse)
-> Either String Int
-> Either String ListJobExecutionsForThingResponse
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 ListJobExecutionsForThing

instance Prelude.NFData ListJobExecutionsForThing

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

instance Core.ToPath ListJobExecutionsForThing where
  toPath :: ListJobExecutionsForThing -> ByteString
toPath ListJobExecutionsForThing' {Maybe Natural
Maybe Text
Maybe JobExecutionStatus
Text
thingName :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
namespaceId :: Maybe Text
status :: Maybe JobExecutionStatus
$sel:thingName:ListJobExecutionsForThing' :: ListJobExecutionsForThing -> Text
$sel:maxResults:ListJobExecutionsForThing' :: ListJobExecutionsForThing -> Maybe Natural
$sel:nextToken:ListJobExecutionsForThing' :: ListJobExecutionsForThing -> Maybe Text
$sel:namespaceId:ListJobExecutionsForThing' :: ListJobExecutionsForThing -> Maybe Text
$sel:status:ListJobExecutionsForThing' :: ListJobExecutionsForThing -> Maybe JobExecutionStatus
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/things/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
thingName, ByteString
"/jobs"]

instance Core.ToQuery ListJobExecutionsForThing where
  toQuery :: ListJobExecutionsForThing -> QueryString
toQuery ListJobExecutionsForThing' {Maybe Natural
Maybe Text
Maybe JobExecutionStatus
Text
thingName :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
namespaceId :: Maybe Text
status :: Maybe JobExecutionStatus
$sel:thingName:ListJobExecutionsForThing' :: ListJobExecutionsForThing -> Text
$sel:maxResults:ListJobExecutionsForThing' :: ListJobExecutionsForThing -> Maybe Natural
$sel:nextToken:ListJobExecutionsForThing' :: ListJobExecutionsForThing -> Maybe Text
$sel:namespaceId:ListJobExecutionsForThing' :: ListJobExecutionsForThing -> Maybe Text
$sel:status:ListJobExecutionsForThing' :: ListJobExecutionsForThing -> Maybe JobExecutionStatus
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"status" ByteString -> Maybe JobExecutionStatus -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe JobExecutionStatus
status,
        ByteString
"namespaceId" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
namespaceId,
        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
      ]

-- | /See:/ 'newListJobExecutionsForThingResponse' smart constructor.
data ListJobExecutionsForThingResponse = ListJobExecutionsForThingResponse'
  { -- | A list of job execution summaries.
    ListJobExecutionsForThingResponse
-> Maybe [JobExecutionSummaryForThing]
executionSummaries :: Prelude.Maybe [JobExecutionSummaryForThing],
    -- | The token for the next set of results, or __null__ if there are no
    -- additional results.
    ListJobExecutionsForThingResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListJobExecutionsForThingResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListJobExecutionsForThingResponse
-> ListJobExecutionsForThingResponse -> Bool
(ListJobExecutionsForThingResponse
 -> ListJobExecutionsForThingResponse -> Bool)
-> (ListJobExecutionsForThingResponse
    -> ListJobExecutionsForThingResponse -> Bool)
-> Eq ListJobExecutionsForThingResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListJobExecutionsForThingResponse
-> ListJobExecutionsForThingResponse -> Bool
$c/= :: ListJobExecutionsForThingResponse
-> ListJobExecutionsForThingResponse -> Bool
== :: ListJobExecutionsForThingResponse
-> ListJobExecutionsForThingResponse -> Bool
$c== :: ListJobExecutionsForThingResponse
-> ListJobExecutionsForThingResponse -> Bool
Prelude.Eq, ReadPrec [ListJobExecutionsForThingResponse]
ReadPrec ListJobExecutionsForThingResponse
Int -> ReadS ListJobExecutionsForThingResponse
ReadS [ListJobExecutionsForThingResponse]
(Int -> ReadS ListJobExecutionsForThingResponse)
-> ReadS [ListJobExecutionsForThingResponse]
-> ReadPrec ListJobExecutionsForThingResponse
-> ReadPrec [ListJobExecutionsForThingResponse]
-> Read ListJobExecutionsForThingResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListJobExecutionsForThingResponse]
$creadListPrec :: ReadPrec [ListJobExecutionsForThingResponse]
readPrec :: ReadPrec ListJobExecutionsForThingResponse
$creadPrec :: ReadPrec ListJobExecutionsForThingResponse
readList :: ReadS [ListJobExecutionsForThingResponse]
$creadList :: ReadS [ListJobExecutionsForThingResponse]
readsPrec :: Int -> ReadS ListJobExecutionsForThingResponse
$creadsPrec :: Int -> ReadS ListJobExecutionsForThingResponse
Prelude.Read, Int -> ListJobExecutionsForThingResponse -> ShowS
[ListJobExecutionsForThingResponse] -> ShowS
ListJobExecutionsForThingResponse -> String
(Int -> ListJobExecutionsForThingResponse -> ShowS)
-> (ListJobExecutionsForThingResponse -> String)
-> ([ListJobExecutionsForThingResponse] -> ShowS)
-> Show ListJobExecutionsForThingResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListJobExecutionsForThingResponse] -> ShowS
$cshowList :: [ListJobExecutionsForThingResponse] -> ShowS
show :: ListJobExecutionsForThingResponse -> String
$cshow :: ListJobExecutionsForThingResponse -> String
showsPrec :: Int -> ListJobExecutionsForThingResponse -> ShowS
$cshowsPrec :: Int -> ListJobExecutionsForThingResponse -> ShowS
Prelude.Show, (forall x.
 ListJobExecutionsForThingResponse
 -> Rep ListJobExecutionsForThingResponse x)
-> (forall x.
    Rep ListJobExecutionsForThingResponse x
    -> ListJobExecutionsForThingResponse)
-> Generic ListJobExecutionsForThingResponse
forall x.
Rep ListJobExecutionsForThingResponse x
-> ListJobExecutionsForThingResponse
forall x.
ListJobExecutionsForThingResponse
-> Rep ListJobExecutionsForThingResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListJobExecutionsForThingResponse x
-> ListJobExecutionsForThingResponse
$cfrom :: forall x.
ListJobExecutionsForThingResponse
-> Rep ListJobExecutionsForThingResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListJobExecutionsForThingResponse' 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:
--
-- 'executionSummaries', 'listJobExecutionsForThingResponse_executionSummaries' - A list of job execution summaries.
--
-- 'nextToken', 'listJobExecutionsForThingResponse_nextToken' - The token for the next set of results, or __null__ if there are no
-- additional results.
--
-- 'httpStatus', 'listJobExecutionsForThingResponse_httpStatus' - The response's http status code.
newListJobExecutionsForThingResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListJobExecutionsForThingResponse
newListJobExecutionsForThingResponse :: Int -> ListJobExecutionsForThingResponse
newListJobExecutionsForThingResponse Int
pHttpStatus_ =
  ListJobExecutionsForThingResponse' :: Maybe [JobExecutionSummaryForThing]
-> Maybe Text -> Int -> ListJobExecutionsForThingResponse
ListJobExecutionsForThingResponse'
    { $sel:executionSummaries:ListJobExecutionsForThingResponse' :: Maybe [JobExecutionSummaryForThing]
executionSummaries =
        Maybe [JobExecutionSummaryForThing]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListJobExecutionsForThingResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListJobExecutionsForThingResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of job execution summaries.
listJobExecutionsForThingResponse_executionSummaries :: Lens.Lens' ListJobExecutionsForThingResponse (Prelude.Maybe [JobExecutionSummaryForThing])
listJobExecutionsForThingResponse_executionSummaries :: (Maybe [JobExecutionSummaryForThing]
 -> f (Maybe [JobExecutionSummaryForThing]))
-> ListJobExecutionsForThingResponse
-> f ListJobExecutionsForThingResponse
listJobExecutionsForThingResponse_executionSummaries = (ListJobExecutionsForThingResponse
 -> Maybe [JobExecutionSummaryForThing])
-> (ListJobExecutionsForThingResponse
    -> Maybe [JobExecutionSummaryForThing]
    -> ListJobExecutionsForThingResponse)
-> Lens'
     ListJobExecutionsForThingResponse
     (Maybe [JobExecutionSummaryForThing])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobExecutionsForThingResponse' {Maybe [JobExecutionSummaryForThing]
executionSummaries :: Maybe [JobExecutionSummaryForThing]
$sel:executionSummaries:ListJobExecutionsForThingResponse' :: ListJobExecutionsForThingResponse
-> Maybe [JobExecutionSummaryForThing]
executionSummaries} -> Maybe [JobExecutionSummaryForThing]
executionSummaries) (\s :: ListJobExecutionsForThingResponse
s@ListJobExecutionsForThingResponse' {} Maybe [JobExecutionSummaryForThing]
a -> ListJobExecutionsForThingResponse
s {$sel:executionSummaries:ListJobExecutionsForThingResponse' :: Maybe [JobExecutionSummaryForThing]
executionSummaries = Maybe [JobExecutionSummaryForThing]
a} :: ListJobExecutionsForThingResponse) ((Maybe [JobExecutionSummaryForThing]
  -> f (Maybe [JobExecutionSummaryForThing]))
 -> ListJobExecutionsForThingResponse
 -> f ListJobExecutionsForThingResponse)
-> ((Maybe [JobExecutionSummaryForThing]
     -> f (Maybe [JobExecutionSummaryForThing]))
    -> Maybe [JobExecutionSummaryForThing]
    -> f (Maybe [JobExecutionSummaryForThing]))
-> (Maybe [JobExecutionSummaryForThing]
    -> f (Maybe [JobExecutionSummaryForThing]))
-> ListJobExecutionsForThingResponse
-> f ListJobExecutionsForThingResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [JobExecutionSummaryForThing]
  [JobExecutionSummaryForThing]
  [JobExecutionSummaryForThing]
  [JobExecutionSummaryForThing]
-> Iso
     (Maybe [JobExecutionSummaryForThing])
     (Maybe [JobExecutionSummaryForThing])
     (Maybe [JobExecutionSummaryForThing])
     (Maybe [JobExecutionSummaryForThing])
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
  [JobExecutionSummaryForThing]
  [JobExecutionSummaryForThing]
  [JobExecutionSummaryForThing]
  [JobExecutionSummaryForThing]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token for the next set of results, or __null__ if there are no
-- additional results.
listJobExecutionsForThingResponse_nextToken :: Lens.Lens' ListJobExecutionsForThingResponse (Prelude.Maybe Prelude.Text)
listJobExecutionsForThingResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListJobExecutionsForThingResponse
-> f ListJobExecutionsForThingResponse
listJobExecutionsForThingResponse_nextToken = (ListJobExecutionsForThingResponse -> Maybe Text)
-> (ListJobExecutionsForThingResponse
    -> Maybe Text -> ListJobExecutionsForThingResponse)
-> Lens' ListJobExecutionsForThingResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJobExecutionsForThingResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListJobExecutionsForThingResponse' :: ListJobExecutionsForThingResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListJobExecutionsForThingResponse
s@ListJobExecutionsForThingResponse' {} Maybe Text
a -> ListJobExecutionsForThingResponse
s {$sel:nextToken:ListJobExecutionsForThingResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListJobExecutionsForThingResponse)

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

instance
  Prelude.NFData
    ListJobExecutionsForThingResponse