amazonka-devicefarm-2.0: gen/Amazonka/DeviceFarm/ListJobs.hs
{-# 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.DeviceFarm.ListJobs
-- Copyright : (c) 2013-2023 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets information about jobs for a given test run.
--
-- This operation returns paginated results.
module Amazonka.DeviceFarm.ListJobs
( -- * Creating a Request
ListJobs (..),
newListJobs,
-- * Request Lenses
listJobs_nextToken,
listJobs_arn,
-- * Destructuring the Response
ListJobsResponse (..),
newListJobsResponse,
-- * Response Lenses
listJobsResponse_jobs,
listJobsResponse_nextToken,
listJobsResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DeviceFarm.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
-- | Represents a request to the list jobs operation.
--
-- /See:/ 'newListJobs' smart constructor.
data ListJobs = ListJobs'
{ -- | An identifier that was returned from the previous call to this
-- operation, which can be used to return the next set of items in the
-- list.
nextToken :: Prelude.Maybe Prelude.Text,
-- | The run\'s Amazon Resource Name (ARN).
arn :: Prelude.Text
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'ListJobs' 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', 'listJobs_nextToken' - An identifier that was returned from the previous call to this
-- operation, which can be used to return the next set of items in the
-- list.
--
-- 'arn', 'listJobs_arn' - The run\'s Amazon Resource Name (ARN).
newListJobs ::
-- | 'arn'
Prelude.Text ->
ListJobs
newListJobs pArn_ =
ListJobs' {nextToken = Prelude.Nothing, arn = pArn_}
-- | An identifier that was returned from the previous call to this
-- operation, which can be used to return the next set of items in the
-- list.
listJobs_nextToken :: Lens.Lens' ListJobs (Prelude.Maybe Prelude.Text)
listJobs_nextToken = Lens.lens (\ListJobs' {nextToken} -> nextToken) (\s@ListJobs' {} a -> s {nextToken = a} :: ListJobs)
-- | The run\'s Amazon Resource Name (ARN).
listJobs_arn :: Lens.Lens' ListJobs Prelude.Text
listJobs_arn = Lens.lens (\ListJobs' {arn} -> arn) (\s@ListJobs' {} a -> s {arn = a} :: ListJobs)
instance Core.AWSPager ListJobs where
page rq rs
| Core.stop
( rs
Lens.^? listJobsResponse_nextToken
Prelude.. Lens._Just
) =
Prelude.Nothing
| Core.stop
( rs
Lens.^? listJobsResponse_jobs
Prelude.. Lens._Just
) =
Prelude.Nothing
| Prelude.otherwise =
Prelude.Just
Prelude.$ rq
Prelude.& listJobs_nextToken
Lens..~ rs
Lens.^? listJobsResponse_nextToken
Prelude.. Lens._Just
instance Core.AWSRequest ListJobs where
type AWSResponse ListJobs = ListJobsResponse
request overrides =
Request.postJSON (overrides defaultService)
response =
Response.receiveJSON
( \s h x ->
ListJobsResponse'
Prelude.<$> (x Data..?> "jobs" Core..!@ Prelude.mempty)
Prelude.<*> (x Data..?> "nextToken")
Prelude.<*> (Prelude.pure (Prelude.fromEnum s))
)
instance Prelude.Hashable ListJobs where
hashWithSalt _salt ListJobs' {..} =
_salt
`Prelude.hashWithSalt` nextToken
`Prelude.hashWithSalt` arn
instance Prelude.NFData ListJobs where
rnf ListJobs' {..} =
Prelude.rnf nextToken `Prelude.seq` Prelude.rnf arn
instance Data.ToHeaders ListJobs where
toHeaders =
Prelude.const
( Prelude.mconcat
[ "X-Amz-Target"
Data.=# ( "DeviceFarm_20150623.ListJobs" ::
Prelude.ByteString
),
"Content-Type"
Data.=# ( "application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON ListJobs where
toJSON ListJobs' {..} =
Data.object
( Prelude.catMaybes
[ ("nextToken" Data..=) Prelude.<$> nextToken,
Prelude.Just ("arn" Data..= arn)
]
)
instance Data.ToPath ListJobs where
toPath = Prelude.const "/"
instance Data.ToQuery ListJobs where
toQuery = Prelude.const Prelude.mempty
-- | Represents the result of a list jobs request.
--
-- /See:/ 'newListJobsResponse' smart constructor.
data ListJobsResponse = ListJobsResponse'
{ -- | Information about the jobs.
jobs :: Prelude.Maybe [Job],
-- | If the number of items that are returned is significantly large, this is
-- an identifier that is also returned. It can be used in a subsequent call
-- to this operation to return the next set of items in the list.
nextToken :: Prelude.Maybe Prelude.Text,
-- | The response's http status code.
httpStatus :: Prelude.Int
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'ListJobsResponse' 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:
--
-- 'jobs', 'listJobsResponse_jobs' - Information about the jobs.
--
-- 'nextToken', 'listJobsResponse_nextToken' - If the number of items that are returned is significantly large, this is
-- an identifier that is also returned. It can be used in a subsequent call
-- to this operation to return the next set of items in the list.
--
-- 'httpStatus', 'listJobsResponse_httpStatus' - The response's http status code.
newListJobsResponse ::
-- | 'httpStatus'
Prelude.Int ->
ListJobsResponse
newListJobsResponse pHttpStatus_ =
ListJobsResponse'
{ jobs = Prelude.Nothing,
nextToken = Prelude.Nothing,
httpStatus = pHttpStatus_
}
-- | Information about the jobs.
listJobsResponse_jobs :: Lens.Lens' ListJobsResponse (Prelude.Maybe [Job])
listJobsResponse_jobs = Lens.lens (\ListJobsResponse' {jobs} -> jobs) (\s@ListJobsResponse' {} a -> s {jobs = a} :: ListJobsResponse) Prelude.. Lens.mapping Lens.coerced
-- | If the number of items that are returned is significantly large, this is
-- an identifier that is also returned. It can be used in a subsequent call
-- to this operation to return the next set of items in the list.
listJobsResponse_nextToken :: Lens.Lens' ListJobsResponse (Prelude.Maybe Prelude.Text)
listJobsResponse_nextToken = Lens.lens (\ListJobsResponse' {nextToken} -> nextToken) (\s@ListJobsResponse' {} a -> s {nextToken = a} :: ListJobsResponse)
-- | The response's http status code.
listJobsResponse_httpStatus :: Lens.Lens' ListJobsResponse Prelude.Int
listJobsResponse_httpStatus = Lens.lens (\ListJobsResponse' {httpStatus} -> httpStatus) (\s@ListJobsResponse' {} a -> s {httpStatus = a} :: ListJobsResponse)
instance Prelude.NFData ListJobsResponse where
rnf ListJobsResponse' {..} =
Prelude.rnf jobs
`Prelude.seq` Prelude.rnf nextToken
`Prelude.seq` Prelude.rnf httpStatus