{-# 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.ListTestGridSessions
-- 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)
--
-- Retrieves a list of sessions for a TestGridProject.
module Amazonka.DeviceFarm.ListTestGridSessions
  ( -- * Creating a Request
    ListTestGridSessions (..),
    newListTestGridSessions,

    -- * Request Lenses
    listTestGridSessions_status,
    listTestGridSessions_maxResult,
    listTestGridSessions_creationTimeAfter,
    listTestGridSessions_endTimeBefore,
    listTestGridSessions_endTimeAfter,
    listTestGridSessions_nextToken,
    listTestGridSessions_creationTimeBefore,
    listTestGridSessions_projectArn,

    -- * Destructuring the Response
    ListTestGridSessionsResponse (..),
    newListTestGridSessionsResponse,

    -- * Response Lenses
    listTestGridSessionsResponse_nextToken,
    listTestGridSessionsResponse_testGridSessions,
    listTestGridSessionsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DeviceFarm.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:/ 'newListTestGridSessions' smart constructor.
data ListTestGridSessions = ListTestGridSessions'
  { -- | Return only sessions in this state.
    ListTestGridSessions -> Maybe TestGridSessionStatus
status :: Prelude.Maybe TestGridSessionStatus,
    -- | Return only this many results at a time.
    ListTestGridSessions -> Maybe Natural
maxResult :: Prelude.Maybe Prelude.Natural,
    -- | Return only sessions created after this time.
    ListTestGridSessions -> Maybe POSIX
creationTimeAfter :: Prelude.Maybe Core.POSIX,
    -- | Return only sessions that ended before this time.
    ListTestGridSessions -> Maybe POSIX
endTimeBefore :: Prelude.Maybe Core.POSIX,
    -- | Return only sessions that ended after this time.
    ListTestGridSessions -> Maybe POSIX
endTimeAfter :: Prelude.Maybe Core.POSIX,
    -- | Pagination token.
    ListTestGridSessions -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Return only sessions created before this time.
    ListTestGridSessions -> Maybe POSIX
creationTimeBefore :: Prelude.Maybe Core.POSIX,
    -- | ARN of a TestGridProject.
    ListTestGridSessions -> Text
projectArn :: Prelude.Text
  }
  deriving (ListTestGridSessions -> ListTestGridSessions -> Bool
(ListTestGridSessions -> ListTestGridSessions -> Bool)
-> (ListTestGridSessions -> ListTestGridSessions -> Bool)
-> Eq ListTestGridSessions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTestGridSessions -> ListTestGridSessions -> Bool
$c/= :: ListTestGridSessions -> ListTestGridSessions -> Bool
== :: ListTestGridSessions -> ListTestGridSessions -> Bool
$c== :: ListTestGridSessions -> ListTestGridSessions -> Bool
Prelude.Eq, ReadPrec [ListTestGridSessions]
ReadPrec ListTestGridSessions
Int -> ReadS ListTestGridSessions
ReadS [ListTestGridSessions]
(Int -> ReadS ListTestGridSessions)
-> ReadS [ListTestGridSessions]
-> ReadPrec ListTestGridSessions
-> ReadPrec [ListTestGridSessions]
-> Read ListTestGridSessions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTestGridSessions]
$creadListPrec :: ReadPrec [ListTestGridSessions]
readPrec :: ReadPrec ListTestGridSessions
$creadPrec :: ReadPrec ListTestGridSessions
readList :: ReadS [ListTestGridSessions]
$creadList :: ReadS [ListTestGridSessions]
readsPrec :: Int -> ReadS ListTestGridSessions
$creadsPrec :: Int -> ReadS ListTestGridSessions
Prelude.Read, Int -> ListTestGridSessions -> ShowS
[ListTestGridSessions] -> ShowS
ListTestGridSessions -> String
(Int -> ListTestGridSessions -> ShowS)
-> (ListTestGridSessions -> String)
-> ([ListTestGridSessions] -> ShowS)
-> Show ListTestGridSessions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTestGridSessions] -> ShowS
$cshowList :: [ListTestGridSessions] -> ShowS
show :: ListTestGridSessions -> String
$cshow :: ListTestGridSessions -> String
showsPrec :: Int -> ListTestGridSessions -> ShowS
$cshowsPrec :: Int -> ListTestGridSessions -> ShowS
Prelude.Show, (forall x. ListTestGridSessions -> Rep ListTestGridSessions x)
-> (forall x. Rep ListTestGridSessions x -> ListTestGridSessions)
-> Generic ListTestGridSessions
forall x. Rep ListTestGridSessions x -> ListTestGridSessions
forall x. ListTestGridSessions -> Rep ListTestGridSessions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTestGridSessions x -> ListTestGridSessions
$cfrom :: forall x. ListTestGridSessions -> Rep ListTestGridSessions x
Prelude.Generic)

-- |
-- Create a value of 'ListTestGridSessions' 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', 'listTestGridSessions_status' - Return only sessions in this state.
--
-- 'maxResult', 'listTestGridSessions_maxResult' - Return only this many results at a time.
--
-- 'creationTimeAfter', 'listTestGridSessions_creationTimeAfter' - Return only sessions created after this time.
--
-- 'endTimeBefore', 'listTestGridSessions_endTimeBefore' - Return only sessions that ended before this time.
--
-- 'endTimeAfter', 'listTestGridSessions_endTimeAfter' - Return only sessions that ended after this time.
--
-- 'nextToken', 'listTestGridSessions_nextToken' - Pagination token.
--
-- 'creationTimeBefore', 'listTestGridSessions_creationTimeBefore' - Return only sessions created before this time.
--
-- 'projectArn', 'listTestGridSessions_projectArn' - ARN of a TestGridProject.
newListTestGridSessions ::
  -- | 'projectArn'
  Prelude.Text ->
  ListTestGridSessions
newListTestGridSessions :: Text -> ListTestGridSessions
newListTestGridSessions Text
pProjectArn_ =
  ListTestGridSessions' :: Maybe TestGridSessionStatus
-> Maybe Natural
-> Maybe POSIX
-> Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Text
-> ListTestGridSessions
ListTestGridSessions'
    { $sel:status:ListTestGridSessions' :: Maybe TestGridSessionStatus
status = Maybe TestGridSessionStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResult:ListTestGridSessions' :: Maybe Natural
maxResult = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTimeAfter:ListTestGridSessions' :: Maybe POSIX
creationTimeAfter = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:endTimeBefore:ListTestGridSessions' :: Maybe POSIX
endTimeBefore = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:endTimeAfter:ListTestGridSessions' :: Maybe POSIX
endTimeAfter = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListTestGridSessions' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTimeBefore:ListTestGridSessions' :: Maybe POSIX
creationTimeBefore = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:projectArn:ListTestGridSessions' :: Text
projectArn = Text
pProjectArn_
    }

-- | Return only sessions in this state.
listTestGridSessions_status :: Lens.Lens' ListTestGridSessions (Prelude.Maybe TestGridSessionStatus)
listTestGridSessions_status :: (Maybe TestGridSessionStatus -> f (Maybe TestGridSessionStatus))
-> ListTestGridSessions -> f ListTestGridSessions
listTestGridSessions_status = (ListTestGridSessions -> Maybe TestGridSessionStatus)
-> (ListTestGridSessions
    -> Maybe TestGridSessionStatus -> ListTestGridSessions)
-> Lens
     ListTestGridSessions
     ListTestGridSessions
     (Maybe TestGridSessionStatus)
     (Maybe TestGridSessionStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTestGridSessions' {Maybe TestGridSessionStatus
status :: Maybe TestGridSessionStatus
$sel:status:ListTestGridSessions' :: ListTestGridSessions -> Maybe TestGridSessionStatus
status} -> Maybe TestGridSessionStatus
status) (\s :: ListTestGridSessions
s@ListTestGridSessions' {} Maybe TestGridSessionStatus
a -> ListTestGridSessions
s {$sel:status:ListTestGridSessions' :: Maybe TestGridSessionStatus
status = Maybe TestGridSessionStatus
a} :: ListTestGridSessions)

-- | Return only this many results at a time.
listTestGridSessions_maxResult :: Lens.Lens' ListTestGridSessions (Prelude.Maybe Prelude.Natural)
listTestGridSessions_maxResult :: (Maybe Natural -> f (Maybe Natural))
-> ListTestGridSessions -> f ListTestGridSessions
listTestGridSessions_maxResult = (ListTestGridSessions -> Maybe Natural)
-> (ListTestGridSessions -> Maybe Natural -> ListTestGridSessions)
-> Lens
     ListTestGridSessions
     ListTestGridSessions
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTestGridSessions' {Maybe Natural
maxResult :: Maybe Natural
$sel:maxResult:ListTestGridSessions' :: ListTestGridSessions -> Maybe Natural
maxResult} -> Maybe Natural
maxResult) (\s :: ListTestGridSessions
s@ListTestGridSessions' {} Maybe Natural
a -> ListTestGridSessions
s {$sel:maxResult:ListTestGridSessions' :: Maybe Natural
maxResult = Maybe Natural
a} :: ListTestGridSessions)

-- | Return only sessions created after this time.
listTestGridSessions_creationTimeAfter :: Lens.Lens' ListTestGridSessions (Prelude.Maybe Prelude.UTCTime)
listTestGridSessions_creationTimeAfter :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListTestGridSessions -> f ListTestGridSessions
listTestGridSessions_creationTimeAfter = (ListTestGridSessions -> Maybe POSIX)
-> (ListTestGridSessions -> Maybe POSIX -> ListTestGridSessions)
-> Lens
     ListTestGridSessions
     ListTestGridSessions
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTestGridSessions' {Maybe POSIX
creationTimeAfter :: Maybe POSIX
$sel:creationTimeAfter:ListTestGridSessions' :: ListTestGridSessions -> Maybe POSIX
creationTimeAfter} -> Maybe POSIX
creationTimeAfter) (\s :: ListTestGridSessions
s@ListTestGridSessions' {} Maybe POSIX
a -> ListTestGridSessions
s {$sel:creationTimeAfter:ListTestGridSessions' :: Maybe POSIX
creationTimeAfter = Maybe POSIX
a} :: ListTestGridSessions) ((Maybe POSIX -> f (Maybe POSIX))
 -> ListTestGridSessions -> f ListTestGridSessions)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListTestGridSessions
-> f ListTestGridSessions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Return only sessions that ended before this time.
listTestGridSessions_endTimeBefore :: Lens.Lens' ListTestGridSessions (Prelude.Maybe Prelude.UTCTime)
listTestGridSessions_endTimeBefore :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListTestGridSessions -> f ListTestGridSessions
listTestGridSessions_endTimeBefore = (ListTestGridSessions -> Maybe POSIX)
-> (ListTestGridSessions -> Maybe POSIX -> ListTestGridSessions)
-> Lens
     ListTestGridSessions
     ListTestGridSessions
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTestGridSessions' {Maybe POSIX
endTimeBefore :: Maybe POSIX
$sel:endTimeBefore:ListTestGridSessions' :: ListTestGridSessions -> Maybe POSIX
endTimeBefore} -> Maybe POSIX
endTimeBefore) (\s :: ListTestGridSessions
s@ListTestGridSessions' {} Maybe POSIX
a -> ListTestGridSessions
s {$sel:endTimeBefore:ListTestGridSessions' :: Maybe POSIX
endTimeBefore = Maybe POSIX
a} :: ListTestGridSessions) ((Maybe POSIX -> f (Maybe POSIX))
 -> ListTestGridSessions -> f ListTestGridSessions)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListTestGridSessions
-> f ListTestGridSessions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Return only sessions that ended after this time.
listTestGridSessions_endTimeAfter :: Lens.Lens' ListTestGridSessions (Prelude.Maybe Prelude.UTCTime)
listTestGridSessions_endTimeAfter :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListTestGridSessions -> f ListTestGridSessions
listTestGridSessions_endTimeAfter = (ListTestGridSessions -> Maybe POSIX)
-> (ListTestGridSessions -> Maybe POSIX -> ListTestGridSessions)
-> Lens
     ListTestGridSessions
     ListTestGridSessions
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTestGridSessions' {Maybe POSIX
endTimeAfter :: Maybe POSIX
$sel:endTimeAfter:ListTestGridSessions' :: ListTestGridSessions -> Maybe POSIX
endTimeAfter} -> Maybe POSIX
endTimeAfter) (\s :: ListTestGridSessions
s@ListTestGridSessions' {} Maybe POSIX
a -> ListTestGridSessions
s {$sel:endTimeAfter:ListTestGridSessions' :: Maybe POSIX
endTimeAfter = Maybe POSIX
a} :: ListTestGridSessions) ((Maybe POSIX -> f (Maybe POSIX))
 -> ListTestGridSessions -> f ListTestGridSessions)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListTestGridSessions
-> f ListTestGridSessions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Pagination token.
listTestGridSessions_nextToken :: Lens.Lens' ListTestGridSessions (Prelude.Maybe Prelude.Text)
listTestGridSessions_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListTestGridSessions -> f ListTestGridSessions
listTestGridSessions_nextToken = (ListTestGridSessions -> Maybe Text)
-> (ListTestGridSessions -> Maybe Text -> ListTestGridSessions)
-> Lens
     ListTestGridSessions ListTestGridSessions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTestGridSessions' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTestGridSessions' :: ListTestGridSessions -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTestGridSessions
s@ListTestGridSessions' {} Maybe Text
a -> ListTestGridSessions
s {$sel:nextToken:ListTestGridSessions' :: Maybe Text
nextToken = Maybe Text
a} :: ListTestGridSessions)

-- | Return only sessions created before this time.
listTestGridSessions_creationTimeBefore :: Lens.Lens' ListTestGridSessions (Prelude.Maybe Prelude.UTCTime)
listTestGridSessions_creationTimeBefore :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListTestGridSessions -> f ListTestGridSessions
listTestGridSessions_creationTimeBefore = (ListTestGridSessions -> Maybe POSIX)
-> (ListTestGridSessions -> Maybe POSIX -> ListTestGridSessions)
-> Lens
     ListTestGridSessions
     ListTestGridSessions
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTestGridSessions' {Maybe POSIX
creationTimeBefore :: Maybe POSIX
$sel:creationTimeBefore:ListTestGridSessions' :: ListTestGridSessions -> Maybe POSIX
creationTimeBefore} -> Maybe POSIX
creationTimeBefore) (\s :: ListTestGridSessions
s@ListTestGridSessions' {} Maybe POSIX
a -> ListTestGridSessions
s {$sel:creationTimeBefore:ListTestGridSessions' :: Maybe POSIX
creationTimeBefore = Maybe POSIX
a} :: ListTestGridSessions) ((Maybe POSIX -> f (Maybe POSIX))
 -> ListTestGridSessions -> f ListTestGridSessions)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListTestGridSessions
-> f ListTestGridSessions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | ARN of a TestGridProject.
listTestGridSessions_projectArn :: Lens.Lens' ListTestGridSessions Prelude.Text
listTestGridSessions_projectArn :: (Text -> f Text) -> ListTestGridSessions -> f ListTestGridSessions
listTestGridSessions_projectArn = (ListTestGridSessions -> Text)
-> (ListTestGridSessions -> Text -> ListTestGridSessions)
-> Lens ListTestGridSessions ListTestGridSessions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTestGridSessions' {Text
projectArn :: Text
$sel:projectArn:ListTestGridSessions' :: ListTestGridSessions -> Text
projectArn} -> Text
projectArn) (\s :: ListTestGridSessions
s@ListTestGridSessions' {} Text
a -> ListTestGridSessions
s {$sel:projectArn:ListTestGridSessions' :: Text
projectArn = Text
a} :: ListTestGridSessions)

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

instance Prelude.NFData ListTestGridSessions

instance Core.ToHeaders ListTestGridSessions where
  toHeaders :: ListTestGridSessions -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListTestGridSessions -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"DeviceFarm_20150623.ListTestGridSessions" ::
                          Prelude.ByteString
                      ),
            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.ToJSON ListTestGridSessions where
  toJSON :: ListTestGridSessions -> Value
toJSON ListTestGridSessions' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe TestGridSessionStatus
Text
projectArn :: Text
creationTimeBefore :: Maybe POSIX
nextToken :: Maybe Text
endTimeAfter :: Maybe POSIX
endTimeBefore :: Maybe POSIX
creationTimeAfter :: Maybe POSIX
maxResult :: Maybe Natural
status :: Maybe TestGridSessionStatus
$sel:projectArn:ListTestGridSessions' :: ListTestGridSessions -> Text
$sel:creationTimeBefore:ListTestGridSessions' :: ListTestGridSessions -> Maybe POSIX
$sel:nextToken:ListTestGridSessions' :: ListTestGridSessions -> Maybe Text
$sel:endTimeAfter:ListTestGridSessions' :: ListTestGridSessions -> Maybe POSIX
$sel:endTimeBefore:ListTestGridSessions' :: ListTestGridSessions -> Maybe POSIX
$sel:creationTimeAfter:ListTestGridSessions' :: ListTestGridSessions -> Maybe POSIX
$sel:maxResult:ListTestGridSessions' :: ListTestGridSessions -> Maybe Natural
$sel:status:ListTestGridSessions' :: ListTestGridSessions -> Maybe TestGridSessionStatus
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"status" Text -> TestGridSessionStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TestGridSessionStatus -> Pair)
-> Maybe TestGridSessionStatus -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TestGridSessionStatus
status,
            (Text
"maxResult" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResult,
            (Text
"creationTimeAfter" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
creationTimeAfter,
            (Text
"endTimeBefore" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
endTimeBefore,
            (Text
"endTimeAfter" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
endTimeAfter,
            (Text
"nextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"creationTimeBefore" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
creationTimeBefore,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"projectArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
projectArn)
          ]
      )

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

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

-- | /See:/ 'newListTestGridSessionsResponse' smart constructor.
data ListTestGridSessionsResponse = ListTestGridSessionsResponse'
  { -- | Pagination token.
    ListTestGridSessionsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The sessions that match the criteria in a ListTestGridSessionsRequest.
    ListTestGridSessionsResponse -> Maybe [TestGridSession]
testGridSessions :: Prelude.Maybe [TestGridSession],
    -- | The response's http status code.
    ListTestGridSessionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListTestGridSessionsResponse
-> ListTestGridSessionsResponse -> Bool
(ListTestGridSessionsResponse
 -> ListTestGridSessionsResponse -> Bool)
-> (ListTestGridSessionsResponse
    -> ListTestGridSessionsResponse -> Bool)
-> Eq ListTestGridSessionsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTestGridSessionsResponse
-> ListTestGridSessionsResponse -> Bool
$c/= :: ListTestGridSessionsResponse
-> ListTestGridSessionsResponse -> Bool
== :: ListTestGridSessionsResponse
-> ListTestGridSessionsResponse -> Bool
$c== :: ListTestGridSessionsResponse
-> ListTestGridSessionsResponse -> Bool
Prelude.Eq, ReadPrec [ListTestGridSessionsResponse]
ReadPrec ListTestGridSessionsResponse
Int -> ReadS ListTestGridSessionsResponse
ReadS [ListTestGridSessionsResponse]
(Int -> ReadS ListTestGridSessionsResponse)
-> ReadS [ListTestGridSessionsResponse]
-> ReadPrec ListTestGridSessionsResponse
-> ReadPrec [ListTestGridSessionsResponse]
-> Read ListTestGridSessionsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTestGridSessionsResponse]
$creadListPrec :: ReadPrec [ListTestGridSessionsResponse]
readPrec :: ReadPrec ListTestGridSessionsResponse
$creadPrec :: ReadPrec ListTestGridSessionsResponse
readList :: ReadS [ListTestGridSessionsResponse]
$creadList :: ReadS [ListTestGridSessionsResponse]
readsPrec :: Int -> ReadS ListTestGridSessionsResponse
$creadsPrec :: Int -> ReadS ListTestGridSessionsResponse
Prelude.Read, Int -> ListTestGridSessionsResponse -> ShowS
[ListTestGridSessionsResponse] -> ShowS
ListTestGridSessionsResponse -> String
(Int -> ListTestGridSessionsResponse -> ShowS)
-> (ListTestGridSessionsResponse -> String)
-> ([ListTestGridSessionsResponse] -> ShowS)
-> Show ListTestGridSessionsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTestGridSessionsResponse] -> ShowS
$cshowList :: [ListTestGridSessionsResponse] -> ShowS
show :: ListTestGridSessionsResponse -> String
$cshow :: ListTestGridSessionsResponse -> String
showsPrec :: Int -> ListTestGridSessionsResponse -> ShowS
$cshowsPrec :: Int -> ListTestGridSessionsResponse -> ShowS
Prelude.Show, (forall x.
 ListTestGridSessionsResponse -> Rep ListTestGridSessionsResponse x)
-> (forall x.
    Rep ListTestGridSessionsResponse x -> ListTestGridSessionsResponse)
-> Generic ListTestGridSessionsResponse
forall x.
Rep ListTestGridSessionsResponse x -> ListTestGridSessionsResponse
forall x.
ListTestGridSessionsResponse -> Rep ListTestGridSessionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListTestGridSessionsResponse x -> ListTestGridSessionsResponse
$cfrom :: forall x.
ListTestGridSessionsResponse -> Rep ListTestGridSessionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListTestGridSessionsResponse' 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', 'listTestGridSessionsResponse_nextToken' - Pagination token.
--
-- 'testGridSessions', 'listTestGridSessionsResponse_testGridSessions' - The sessions that match the criteria in a ListTestGridSessionsRequest.
--
-- 'httpStatus', 'listTestGridSessionsResponse_httpStatus' - The response's http status code.
newListTestGridSessionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListTestGridSessionsResponse
newListTestGridSessionsResponse :: Int -> ListTestGridSessionsResponse
newListTestGridSessionsResponse Int
pHttpStatus_ =
  ListTestGridSessionsResponse' :: Maybe Text
-> Maybe [TestGridSession] -> Int -> ListTestGridSessionsResponse
ListTestGridSessionsResponse'
    { $sel:nextToken:ListTestGridSessionsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:testGridSessions:ListTestGridSessionsResponse' :: Maybe [TestGridSession]
testGridSessions = Maybe [TestGridSession]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListTestGridSessionsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Pagination token.
listTestGridSessionsResponse_nextToken :: Lens.Lens' ListTestGridSessionsResponse (Prelude.Maybe Prelude.Text)
listTestGridSessionsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListTestGridSessionsResponse -> f ListTestGridSessionsResponse
listTestGridSessionsResponse_nextToken = (ListTestGridSessionsResponse -> Maybe Text)
-> (ListTestGridSessionsResponse
    -> Maybe Text -> ListTestGridSessionsResponse)
-> Lens
     ListTestGridSessionsResponse
     ListTestGridSessionsResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTestGridSessionsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTestGridSessionsResponse' :: ListTestGridSessionsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTestGridSessionsResponse
s@ListTestGridSessionsResponse' {} Maybe Text
a -> ListTestGridSessionsResponse
s {$sel:nextToken:ListTestGridSessionsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListTestGridSessionsResponse)

-- | The sessions that match the criteria in a ListTestGridSessionsRequest.
listTestGridSessionsResponse_testGridSessions :: Lens.Lens' ListTestGridSessionsResponse (Prelude.Maybe [TestGridSession])
listTestGridSessionsResponse_testGridSessions :: (Maybe [TestGridSession] -> f (Maybe [TestGridSession]))
-> ListTestGridSessionsResponse -> f ListTestGridSessionsResponse
listTestGridSessionsResponse_testGridSessions = (ListTestGridSessionsResponse -> Maybe [TestGridSession])
-> (ListTestGridSessionsResponse
    -> Maybe [TestGridSession] -> ListTestGridSessionsResponse)
-> Lens
     ListTestGridSessionsResponse
     ListTestGridSessionsResponse
     (Maybe [TestGridSession])
     (Maybe [TestGridSession])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTestGridSessionsResponse' {Maybe [TestGridSession]
testGridSessions :: Maybe [TestGridSession]
$sel:testGridSessions:ListTestGridSessionsResponse' :: ListTestGridSessionsResponse -> Maybe [TestGridSession]
testGridSessions} -> Maybe [TestGridSession]
testGridSessions) (\s :: ListTestGridSessionsResponse
s@ListTestGridSessionsResponse' {} Maybe [TestGridSession]
a -> ListTestGridSessionsResponse
s {$sel:testGridSessions:ListTestGridSessionsResponse' :: Maybe [TestGridSession]
testGridSessions = Maybe [TestGridSession]
a} :: ListTestGridSessionsResponse) ((Maybe [TestGridSession] -> f (Maybe [TestGridSession]))
 -> ListTestGridSessionsResponse -> f ListTestGridSessionsResponse)
-> ((Maybe [TestGridSession] -> f (Maybe [TestGridSession]))
    -> Maybe [TestGridSession] -> f (Maybe [TestGridSession]))
-> (Maybe [TestGridSession] -> f (Maybe [TestGridSession]))
-> ListTestGridSessionsResponse
-> f ListTestGridSessionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [TestGridSession]
  [TestGridSession]
  [TestGridSession]
  [TestGridSession]
-> Iso
     (Maybe [TestGridSession])
     (Maybe [TestGridSession])
     (Maybe [TestGridSession])
     (Maybe [TestGridSession])
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
  [TestGridSession]
  [TestGridSession]
  [TestGridSession]
  [TestGridSession]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListTestGridSessionsResponse