{-# 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.ListSamples
-- 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 samples, given an AWS Device Farm job ARN.
--
-- This operation returns paginated results.
module Amazonka.DeviceFarm.ListSamples
  ( -- * Creating a Request
    ListSamples (..),
    newListSamples,

    -- * Request Lenses
    listSamples_nextToken,
    listSamples_arn,

    -- * Destructuring the Response
    ListSamplesResponse (..),
    newListSamplesResponse,

    -- * Response Lenses
    listSamplesResponse_nextToken,
    listSamplesResponse_samples,
    listSamplesResponse_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 samples operation.
--
-- /See:/ 'newListSamples' smart constructor.
data ListSamples = ListSamples'
  { -- | 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.
    ListSamples -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the job used to list samples.
    ListSamples -> Text
arn :: Prelude.Text
  }
  deriving (ListSamples -> ListSamples -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListSamples -> ListSamples -> Bool
$c/= :: ListSamples -> ListSamples -> Bool
== :: ListSamples -> ListSamples -> Bool
$c== :: ListSamples -> ListSamples -> Bool
Prelude.Eq, ReadPrec [ListSamples]
ReadPrec ListSamples
Int -> ReadS ListSamples
ReadS [ListSamples]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListSamples]
$creadListPrec :: ReadPrec [ListSamples]
readPrec :: ReadPrec ListSamples
$creadPrec :: ReadPrec ListSamples
readList :: ReadS [ListSamples]
$creadList :: ReadS [ListSamples]
readsPrec :: Int -> ReadS ListSamples
$creadsPrec :: Int -> ReadS ListSamples
Prelude.Read, Int -> ListSamples -> ShowS
[ListSamples] -> ShowS
ListSamples -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListSamples] -> ShowS
$cshowList :: [ListSamples] -> ShowS
show :: ListSamples -> String
$cshow :: ListSamples -> String
showsPrec :: Int -> ListSamples -> ShowS
$cshowsPrec :: Int -> ListSamples -> ShowS
Prelude.Show, forall x. Rep ListSamples x -> ListSamples
forall x. ListSamples -> Rep ListSamples x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListSamples x -> ListSamples
$cfrom :: forall x. ListSamples -> Rep ListSamples x
Prelude.Generic)

-- |
-- Create a value of 'ListSamples' 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', 'listSamples_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', 'listSamples_arn' - The Amazon Resource Name (ARN) of the job used to list samples.
newListSamples ::
  -- | 'arn'
  Prelude.Text ->
  ListSamples
newListSamples :: Text -> ListSamples
newListSamples Text
pArn_ =
  ListSamples'
    { $sel:nextToken:ListSamples' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:arn:ListSamples' :: Text
arn = Text
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.
listSamples_nextToken :: Lens.Lens' ListSamples (Prelude.Maybe Prelude.Text)
listSamples_nextToken :: Lens' ListSamples (Maybe Text)
listSamples_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSamples' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListSamples' :: ListSamples -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListSamples
s@ListSamples' {} Maybe Text
a -> ListSamples
s {$sel:nextToken:ListSamples' :: Maybe Text
nextToken = Maybe Text
a} :: ListSamples)

-- | The Amazon Resource Name (ARN) of the job used to list samples.
listSamples_arn :: Lens.Lens' ListSamples Prelude.Text
listSamples_arn :: Lens' ListSamples Text
listSamples_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSamples' {Text
arn :: Text
$sel:arn:ListSamples' :: ListSamples -> Text
arn} -> Text
arn) (\s :: ListSamples
s@ListSamples' {} Text
a -> ListSamples
s {$sel:arn:ListSamples' :: Text
arn = Text
a} :: ListSamples)

instance Core.AWSPager ListSamples where
  page :: ListSamples -> AWSResponse ListSamples -> Maybe ListSamples
page ListSamples
rq AWSResponse ListSamples
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListSamples
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListSamplesResponse (Maybe Text)
listSamplesResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListSamples
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListSamplesResponse (Maybe [Sample])
listSamplesResponse_samples
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListSamples
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListSamples (Maybe Text)
listSamples_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListSamples
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListSamplesResponse (Maybe Text)
listSamplesResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListSamples where
  type AWSResponse ListSamples = ListSamplesResponse
  request :: (Service -> Service) -> ListSamples -> Request ListSamples
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListSamples
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListSamples)))
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 Text -> Maybe [Sample] -> Int -> ListSamplesResponse
ListSamplesResponse'
            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
"nextToken")
            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
"samples" 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 ListSamples where
  hashWithSalt :: Int -> ListSamples -> Int
hashWithSalt Int
_salt ListSamples' {Maybe Text
Text
arn :: Text
nextToken :: Maybe Text
$sel:arn:ListSamples' :: ListSamples -> Text
$sel:nextToken:ListSamples' :: ListSamples -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

instance Prelude.NFData ListSamples where
  rnf :: ListSamples -> ()
rnf ListSamples' {Maybe Text
Text
arn :: Text
nextToken :: Maybe Text
$sel:arn:ListSamples' :: ListSamples -> Text
$sel:nextToken:ListSamples' :: ListSamples -> Maybe Text
..} =
    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 Text
arn

instance Data.ToHeaders ListSamples where
  toHeaders :: ListSamples -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"DeviceFarm_20150623.ListSamples" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON ListSamples where
  toJSON :: ListSamples -> Value
toJSON ListSamples' {Maybe Text
Text
arn :: Text
nextToken :: Maybe Text
$sel:arn:ListSamples' :: ListSamples -> Text
$sel:nextToken:ListSamples' :: ListSamples -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"nextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            forall a. a -> Maybe a
Prelude.Just (Key
"arn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
arn)
          ]
      )

instance Data.ToPath ListSamples where
  toPath :: ListSamples -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | Represents the result of a list samples request.
--
-- /See:/ 'newListSamplesResponse' smart constructor.
data ListSamplesResponse = ListSamplesResponse'
  { -- | 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.
    ListSamplesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Information about the samples.
    ListSamplesResponse -> Maybe [Sample]
samples :: Prelude.Maybe [Sample],
    -- | The response's http status code.
    ListSamplesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListSamplesResponse -> ListSamplesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListSamplesResponse -> ListSamplesResponse -> Bool
$c/= :: ListSamplesResponse -> ListSamplesResponse -> Bool
== :: ListSamplesResponse -> ListSamplesResponse -> Bool
$c== :: ListSamplesResponse -> ListSamplesResponse -> Bool
Prelude.Eq, ReadPrec [ListSamplesResponse]
ReadPrec ListSamplesResponse
Int -> ReadS ListSamplesResponse
ReadS [ListSamplesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListSamplesResponse]
$creadListPrec :: ReadPrec [ListSamplesResponse]
readPrec :: ReadPrec ListSamplesResponse
$creadPrec :: ReadPrec ListSamplesResponse
readList :: ReadS [ListSamplesResponse]
$creadList :: ReadS [ListSamplesResponse]
readsPrec :: Int -> ReadS ListSamplesResponse
$creadsPrec :: Int -> ReadS ListSamplesResponse
Prelude.Read, Int -> ListSamplesResponse -> ShowS
[ListSamplesResponse] -> ShowS
ListSamplesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListSamplesResponse] -> ShowS
$cshowList :: [ListSamplesResponse] -> ShowS
show :: ListSamplesResponse -> String
$cshow :: ListSamplesResponse -> String
showsPrec :: Int -> ListSamplesResponse -> ShowS
$cshowsPrec :: Int -> ListSamplesResponse -> ShowS
Prelude.Show, forall x. Rep ListSamplesResponse x -> ListSamplesResponse
forall x. ListSamplesResponse -> Rep ListSamplesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListSamplesResponse x -> ListSamplesResponse
$cfrom :: forall x. ListSamplesResponse -> Rep ListSamplesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListSamplesResponse' 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', 'listSamplesResponse_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.
--
-- 'samples', 'listSamplesResponse_samples' - Information about the samples.
--
-- 'httpStatus', 'listSamplesResponse_httpStatus' - The response's http status code.
newListSamplesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListSamplesResponse
newListSamplesResponse :: Int -> ListSamplesResponse
newListSamplesResponse Int
pHttpStatus_ =
  ListSamplesResponse'
    { $sel:nextToken:ListSamplesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:samples:ListSamplesResponse' :: Maybe [Sample]
samples = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListSamplesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | 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.
listSamplesResponse_nextToken :: Lens.Lens' ListSamplesResponse (Prelude.Maybe Prelude.Text)
listSamplesResponse_nextToken :: Lens' ListSamplesResponse (Maybe Text)
listSamplesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSamplesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListSamplesResponse' :: ListSamplesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListSamplesResponse
s@ListSamplesResponse' {} Maybe Text
a -> ListSamplesResponse
s {$sel:nextToken:ListSamplesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListSamplesResponse)

-- | Information about the samples.
listSamplesResponse_samples :: Lens.Lens' ListSamplesResponse (Prelude.Maybe [Sample])
listSamplesResponse_samples :: Lens' ListSamplesResponse (Maybe [Sample])
listSamplesResponse_samples = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSamplesResponse' {Maybe [Sample]
samples :: Maybe [Sample]
$sel:samples:ListSamplesResponse' :: ListSamplesResponse -> Maybe [Sample]
samples} -> Maybe [Sample]
samples) (\s :: ListSamplesResponse
s@ListSamplesResponse' {} Maybe [Sample]
a -> ListSamplesResponse
s {$sel:samples:ListSamplesResponse' :: Maybe [Sample]
samples = Maybe [Sample]
a} :: ListSamplesResponse) 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.
listSamplesResponse_httpStatus :: Lens.Lens' ListSamplesResponse Prelude.Int
listSamplesResponse_httpStatus :: Lens' ListSamplesResponse Int
listSamplesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSamplesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListSamplesResponse' :: ListSamplesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListSamplesResponse
s@ListSamplesResponse' {} Int
a -> ListSamplesResponse
s {$sel:httpStatus:ListSamplesResponse' :: Int
httpStatus = Int
a} :: ListSamplesResponse)

instance Prelude.NFData ListSamplesResponse where
  rnf :: ListSamplesResponse -> ()
rnf ListSamplesResponse' {Int
Maybe [Sample]
Maybe Text
httpStatus :: Int
samples :: Maybe [Sample]
nextToken :: Maybe Text
$sel:httpStatus:ListSamplesResponse' :: ListSamplesResponse -> Int
$sel:samples:ListSamplesResponse' :: ListSamplesResponse -> Maybe [Sample]
$sel:nextToken:ListSamplesResponse' :: ListSamplesResponse -> Maybe Text
..} =
    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 Maybe [Sample]
samples
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus