{-# 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.Panorama.ListDevicesJobs
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a list of jobs.
module Amazonka.Panorama.ListDevicesJobs
  ( -- * Creating a Request
    ListDevicesJobs (..),
    newListDevicesJobs,

    -- * Request Lenses
    listDevicesJobs_deviceId,
    listDevicesJobs_maxResults,
    listDevicesJobs_nextToken,

    -- * Destructuring the Response
    ListDevicesJobsResponse (..),
    newListDevicesJobsResponse,

    -- * Response Lenses
    listDevicesJobsResponse_deviceJobs,
    listDevicesJobsResponse_nextToken,
    listDevicesJobsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListDevicesJobs' smart constructor.
data ListDevicesJobs = ListDevicesJobs'
  { -- | Filter results by the job\'s target device ID.
    ListDevicesJobs -> Maybe Text
deviceId :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of device jobs to return in one page of results.
    ListDevicesJobs -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | Specify the pagination token from a previous request to retrieve the
    -- next page of results.
    ListDevicesJobs -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListDevicesJobs -> ListDevicesJobs -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDevicesJobs -> ListDevicesJobs -> Bool
$c/= :: ListDevicesJobs -> ListDevicesJobs -> Bool
== :: ListDevicesJobs -> ListDevicesJobs -> Bool
$c== :: ListDevicesJobs -> ListDevicesJobs -> Bool
Prelude.Eq, ReadPrec [ListDevicesJobs]
ReadPrec ListDevicesJobs
Int -> ReadS ListDevicesJobs
ReadS [ListDevicesJobs]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDevicesJobs]
$creadListPrec :: ReadPrec [ListDevicesJobs]
readPrec :: ReadPrec ListDevicesJobs
$creadPrec :: ReadPrec ListDevicesJobs
readList :: ReadS [ListDevicesJobs]
$creadList :: ReadS [ListDevicesJobs]
readsPrec :: Int -> ReadS ListDevicesJobs
$creadsPrec :: Int -> ReadS ListDevicesJobs
Prelude.Read, Int -> ListDevicesJobs -> ShowS
[ListDevicesJobs] -> ShowS
ListDevicesJobs -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDevicesJobs] -> ShowS
$cshowList :: [ListDevicesJobs] -> ShowS
show :: ListDevicesJobs -> String
$cshow :: ListDevicesJobs -> String
showsPrec :: Int -> ListDevicesJobs -> ShowS
$cshowsPrec :: Int -> ListDevicesJobs -> ShowS
Prelude.Show, forall x. Rep ListDevicesJobs x -> ListDevicesJobs
forall x. ListDevicesJobs -> Rep ListDevicesJobs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDevicesJobs x -> ListDevicesJobs
$cfrom :: forall x. ListDevicesJobs -> Rep ListDevicesJobs x
Prelude.Generic)

-- |
-- Create a value of 'ListDevicesJobs' 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', 'listDevicesJobs_deviceId' - Filter results by the job\'s target device ID.
--
-- 'maxResults', 'listDevicesJobs_maxResults' - The maximum number of device jobs to return in one page of results.
--
-- 'nextToken', 'listDevicesJobs_nextToken' - Specify the pagination token from a previous request to retrieve the
-- next page of results.
newListDevicesJobs ::
  ListDevicesJobs
newListDevicesJobs :: ListDevicesJobs
newListDevicesJobs =
  ListDevicesJobs'
    { $sel:deviceId:ListDevicesJobs' :: Maybe Text
deviceId = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListDevicesJobs' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDevicesJobs' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | Filter results by the job\'s target device ID.
listDevicesJobs_deviceId :: Lens.Lens' ListDevicesJobs (Prelude.Maybe Prelude.Text)
listDevicesJobs_deviceId :: Lens' ListDevicesJobs (Maybe Text)
listDevicesJobs_deviceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDevicesJobs' {Maybe Text
deviceId :: Maybe Text
$sel:deviceId:ListDevicesJobs' :: ListDevicesJobs -> Maybe Text
deviceId} -> Maybe Text
deviceId) (\s :: ListDevicesJobs
s@ListDevicesJobs' {} Maybe Text
a -> ListDevicesJobs
s {$sel:deviceId:ListDevicesJobs' :: Maybe Text
deviceId = Maybe Text
a} :: ListDevicesJobs)

-- | The maximum number of device jobs to return in one page of results.
listDevicesJobs_maxResults :: Lens.Lens' ListDevicesJobs (Prelude.Maybe Prelude.Natural)
listDevicesJobs_maxResults :: Lens' ListDevicesJobs (Maybe Natural)
listDevicesJobs_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDevicesJobs' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListDevicesJobs' :: ListDevicesJobs -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListDevicesJobs
s@ListDevicesJobs' {} Maybe Natural
a -> ListDevicesJobs
s {$sel:maxResults:ListDevicesJobs' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListDevicesJobs)

-- | Specify the pagination token from a previous request to retrieve the
-- next page of results.
listDevicesJobs_nextToken :: Lens.Lens' ListDevicesJobs (Prelude.Maybe Prelude.Text)
listDevicesJobs_nextToken :: Lens' ListDevicesJobs (Maybe Text)
listDevicesJobs_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDevicesJobs' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDevicesJobs' :: ListDevicesJobs -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDevicesJobs
s@ListDevicesJobs' {} Maybe Text
a -> ListDevicesJobs
s {$sel:nextToken:ListDevicesJobs' :: Maybe Text
nextToken = Maybe Text
a} :: ListDevicesJobs)

instance Core.AWSRequest ListDevicesJobs where
  type
    AWSResponse ListDevicesJobs =
      ListDevicesJobsResponse
  request :: (Service -> Service) -> ListDevicesJobs -> Request ListDevicesJobs
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 ListDevicesJobs
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDevicesJobs)))
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 [DeviceJob] -> Maybe Text -> Int -> ListDevicesJobsResponse
ListDevicesJobsResponse'
            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
"DeviceJobs" 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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NextToken")
            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 ListDevicesJobs where
  hashWithSalt :: Int -> ListDevicesJobs -> Int
hashWithSalt Int
_salt ListDevicesJobs' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
deviceId :: Maybe Text
$sel:nextToken:ListDevicesJobs' :: ListDevicesJobs -> Maybe Text
$sel:maxResults:ListDevicesJobs' :: ListDevicesJobs -> Maybe Natural
$sel:deviceId:ListDevicesJobs' :: ListDevicesJobs -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
deviceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListDevicesJobs where
  rnf :: ListDevicesJobs -> ()
rnf ListDevicesJobs' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
deviceId :: Maybe Text
$sel:nextToken:ListDevicesJobs' :: ListDevicesJobs -> Maybe Text
$sel:maxResults:ListDevicesJobs' :: ListDevicesJobs -> Maybe Natural
$sel:deviceId:ListDevicesJobs' :: ListDevicesJobs -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
deviceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

instance Data.ToHeaders ListDevicesJobs where
  toHeaders :: ListDevicesJobs -> 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 ListDevicesJobs where
  toPath :: ListDevicesJobs -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/jobs"

instance Data.ToQuery ListDevicesJobs where
  toQuery :: ListDevicesJobs -> QueryString
toQuery ListDevicesJobs' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
deviceId :: Maybe Text
$sel:nextToken:ListDevicesJobs' :: ListDevicesJobs -> Maybe Text
$sel:maxResults:ListDevicesJobs' :: ListDevicesJobs -> Maybe Natural
$sel:deviceId:ListDevicesJobs' :: ListDevicesJobs -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"DeviceId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
deviceId,
        ByteString
"MaxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"NextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListDevicesJobsResponse' smart constructor.
data ListDevicesJobsResponse = ListDevicesJobsResponse'
  { -- | A list of jobs.
    ListDevicesJobsResponse -> Maybe [DeviceJob]
deviceJobs :: Prelude.Maybe [DeviceJob],
    -- | A pagination token that\'s included if more results are available.
    ListDevicesJobsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListDevicesJobsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDevicesJobsResponse -> ListDevicesJobsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDevicesJobsResponse -> ListDevicesJobsResponse -> Bool
$c/= :: ListDevicesJobsResponse -> ListDevicesJobsResponse -> Bool
== :: ListDevicesJobsResponse -> ListDevicesJobsResponse -> Bool
$c== :: ListDevicesJobsResponse -> ListDevicesJobsResponse -> Bool
Prelude.Eq, ReadPrec [ListDevicesJobsResponse]
ReadPrec ListDevicesJobsResponse
Int -> ReadS ListDevicesJobsResponse
ReadS [ListDevicesJobsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDevicesJobsResponse]
$creadListPrec :: ReadPrec [ListDevicesJobsResponse]
readPrec :: ReadPrec ListDevicesJobsResponse
$creadPrec :: ReadPrec ListDevicesJobsResponse
readList :: ReadS [ListDevicesJobsResponse]
$creadList :: ReadS [ListDevicesJobsResponse]
readsPrec :: Int -> ReadS ListDevicesJobsResponse
$creadsPrec :: Int -> ReadS ListDevicesJobsResponse
Prelude.Read, Int -> ListDevicesJobsResponse -> ShowS
[ListDevicesJobsResponse] -> ShowS
ListDevicesJobsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDevicesJobsResponse] -> ShowS
$cshowList :: [ListDevicesJobsResponse] -> ShowS
show :: ListDevicesJobsResponse -> String
$cshow :: ListDevicesJobsResponse -> String
showsPrec :: Int -> ListDevicesJobsResponse -> ShowS
$cshowsPrec :: Int -> ListDevicesJobsResponse -> ShowS
Prelude.Show, forall x. Rep ListDevicesJobsResponse x -> ListDevicesJobsResponse
forall x. ListDevicesJobsResponse -> Rep ListDevicesJobsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDevicesJobsResponse x -> ListDevicesJobsResponse
$cfrom :: forall x. ListDevicesJobsResponse -> Rep ListDevicesJobsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDevicesJobsResponse' 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:
--
-- 'deviceJobs', 'listDevicesJobsResponse_deviceJobs' - A list of jobs.
--
-- 'nextToken', 'listDevicesJobsResponse_nextToken' - A pagination token that\'s included if more results are available.
--
-- 'httpStatus', 'listDevicesJobsResponse_httpStatus' - The response's http status code.
newListDevicesJobsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDevicesJobsResponse
newListDevicesJobsResponse :: Int -> ListDevicesJobsResponse
newListDevicesJobsResponse Int
pHttpStatus_ =
  ListDevicesJobsResponse'
    { $sel:deviceJobs:ListDevicesJobsResponse' :: Maybe [DeviceJob]
deviceJobs =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDevicesJobsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDevicesJobsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of jobs.
listDevicesJobsResponse_deviceJobs :: Lens.Lens' ListDevicesJobsResponse (Prelude.Maybe [DeviceJob])
listDevicesJobsResponse_deviceJobs :: Lens' ListDevicesJobsResponse (Maybe [DeviceJob])
listDevicesJobsResponse_deviceJobs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDevicesJobsResponse' {Maybe [DeviceJob]
deviceJobs :: Maybe [DeviceJob]
$sel:deviceJobs:ListDevicesJobsResponse' :: ListDevicesJobsResponse -> Maybe [DeviceJob]
deviceJobs} -> Maybe [DeviceJob]
deviceJobs) (\s :: ListDevicesJobsResponse
s@ListDevicesJobsResponse' {} Maybe [DeviceJob]
a -> ListDevicesJobsResponse
s {$sel:deviceJobs:ListDevicesJobsResponse' :: Maybe [DeviceJob]
deviceJobs = Maybe [DeviceJob]
a} :: ListDevicesJobsResponse) 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

-- | A pagination token that\'s included if more results are available.
listDevicesJobsResponse_nextToken :: Lens.Lens' ListDevicesJobsResponse (Prelude.Maybe Prelude.Text)
listDevicesJobsResponse_nextToken :: Lens' ListDevicesJobsResponse (Maybe Text)
listDevicesJobsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDevicesJobsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDevicesJobsResponse' :: ListDevicesJobsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDevicesJobsResponse
s@ListDevicesJobsResponse' {} Maybe Text
a -> ListDevicesJobsResponse
s {$sel:nextToken:ListDevicesJobsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDevicesJobsResponse)

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

instance Prelude.NFData ListDevicesJobsResponse where
  rnf :: ListDevicesJobsResponse -> ()
rnf ListDevicesJobsResponse' {Int
Maybe [DeviceJob]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
deviceJobs :: Maybe [DeviceJob]
$sel:httpStatus:ListDevicesJobsResponse' :: ListDevicesJobsResponse -> Int
$sel:nextToken:ListDevicesJobsResponse' :: ListDevicesJobsResponse -> Maybe Text
$sel:deviceJobs:ListDevicesJobsResponse' :: ListDevicesJobsResponse -> Maybe [DeviceJob]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DeviceJob]
deviceJobs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus