{-# 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.SageMaker.ListTrials
-- 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 trials in your account. Specify an experiment name to limit
-- the list to the trials that are part of that experiment. Specify a trial
-- component name to limit the list to the trials that associated with that
-- trial component. The list can be filtered to show only trials that were
-- created in a specific time range. The list can be sorted by trial name
-- or creation time.
--
-- This operation returns paginated results.
module Amazonka.SageMaker.ListTrials
  ( -- * Creating a Request
    ListTrials (..),
    newListTrials,

    -- * Request Lenses
    listTrials_createdAfter,
    listTrials_experimentName,
    listTrials_nextToken,
    listTrials_sortOrder,
    listTrials_trialComponentName,
    listTrials_maxResults,
    listTrials_createdBefore,
    listTrials_sortBy,

    -- * Destructuring the Response
    ListTrialsResponse (..),
    newListTrialsResponse,

    -- * Response Lenses
    listTrialsResponse_nextToken,
    listTrialsResponse_trialSummaries,
    listTrialsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SageMaker.Types

-- | /See:/ 'newListTrials' smart constructor.
data ListTrials = ListTrials'
  { -- | A filter that returns only trials created after the specified time.
    ListTrials -> Maybe POSIX
createdAfter :: Prelude.Maybe Core.POSIX,
    -- | A filter that returns only trials that are part of the specified
    -- experiment.
    ListTrials -> Maybe Text
experimentName :: Prelude.Maybe Prelude.Text,
    -- | If the previous call to @ListTrials@ didn\'t return the full set of
    -- trials, the call returns a token for getting the next set of trials.
    ListTrials -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The sort order. The default value is @Descending@.
    ListTrials -> Maybe SortOrder
sortOrder :: Prelude.Maybe SortOrder,
    -- | A filter that returns only trials that are associated with the specified
    -- trial component.
    ListTrials -> Maybe Text
trialComponentName :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of trials to return in the response. The default
    -- value is 10.
    ListTrials -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A filter that returns only trials created before the specified time.
    ListTrials -> Maybe POSIX
createdBefore :: Prelude.Maybe Core.POSIX,
    -- | The property used to sort results. The default value is @CreationTime@.
    ListTrials -> Maybe SortTrialsBy
sortBy :: Prelude.Maybe SortTrialsBy
  }
  deriving (ListTrials -> ListTrials -> Bool
(ListTrials -> ListTrials -> Bool)
-> (ListTrials -> ListTrials -> Bool) -> Eq ListTrials
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTrials -> ListTrials -> Bool
$c/= :: ListTrials -> ListTrials -> Bool
== :: ListTrials -> ListTrials -> Bool
$c== :: ListTrials -> ListTrials -> Bool
Prelude.Eq, ReadPrec [ListTrials]
ReadPrec ListTrials
Int -> ReadS ListTrials
ReadS [ListTrials]
(Int -> ReadS ListTrials)
-> ReadS [ListTrials]
-> ReadPrec ListTrials
-> ReadPrec [ListTrials]
-> Read ListTrials
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTrials]
$creadListPrec :: ReadPrec [ListTrials]
readPrec :: ReadPrec ListTrials
$creadPrec :: ReadPrec ListTrials
readList :: ReadS [ListTrials]
$creadList :: ReadS [ListTrials]
readsPrec :: Int -> ReadS ListTrials
$creadsPrec :: Int -> ReadS ListTrials
Prelude.Read, Int -> ListTrials -> ShowS
[ListTrials] -> ShowS
ListTrials -> String
(Int -> ListTrials -> ShowS)
-> (ListTrials -> String)
-> ([ListTrials] -> ShowS)
-> Show ListTrials
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTrials] -> ShowS
$cshowList :: [ListTrials] -> ShowS
show :: ListTrials -> String
$cshow :: ListTrials -> String
showsPrec :: Int -> ListTrials -> ShowS
$cshowsPrec :: Int -> ListTrials -> ShowS
Prelude.Show, (forall x. ListTrials -> Rep ListTrials x)
-> (forall x. Rep ListTrials x -> ListTrials) -> Generic ListTrials
forall x. Rep ListTrials x -> ListTrials
forall x. ListTrials -> Rep ListTrials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTrials x -> ListTrials
$cfrom :: forall x. ListTrials -> Rep ListTrials x
Prelude.Generic)

-- |
-- Create a value of 'ListTrials' 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:
--
-- 'createdAfter', 'listTrials_createdAfter' - A filter that returns only trials created after the specified time.
--
-- 'experimentName', 'listTrials_experimentName' - A filter that returns only trials that are part of the specified
-- experiment.
--
-- 'nextToken', 'listTrials_nextToken' - If the previous call to @ListTrials@ didn\'t return the full set of
-- trials, the call returns a token for getting the next set of trials.
--
-- 'sortOrder', 'listTrials_sortOrder' - The sort order. The default value is @Descending@.
--
-- 'trialComponentName', 'listTrials_trialComponentName' - A filter that returns only trials that are associated with the specified
-- trial component.
--
-- 'maxResults', 'listTrials_maxResults' - The maximum number of trials to return in the response. The default
-- value is 10.
--
-- 'createdBefore', 'listTrials_createdBefore' - A filter that returns only trials created before the specified time.
--
-- 'sortBy', 'listTrials_sortBy' - The property used to sort results. The default value is @CreationTime@.
newListTrials ::
  ListTrials
newListTrials :: ListTrials
newListTrials =
  ListTrials' :: Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe SortOrder
-> Maybe Text
-> Maybe Natural
-> Maybe POSIX
-> Maybe SortTrialsBy
-> ListTrials
ListTrials'
    { $sel:createdAfter:ListTrials' :: Maybe POSIX
createdAfter = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:experimentName:ListTrials' :: Maybe Text
experimentName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListTrials' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sortOrder:ListTrials' :: Maybe SortOrder
sortOrder = Maybe SortOrder
forall a. Maybe a
Prelude.Nothing,
      $sel:trialComponentName:ListTrials' :: Maybe Text
trialComponentName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListTrials' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:createdBefore:ListTrials' :: Maybe POSIX
createdBefore = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:sortBy:ListTrials' :: Maybe SortTrialsBy
sortBy = Maybe SortTrialsBy
forall a. Maybe a
Prelude.Nothing
    }

-- | A filter that returns only trials created after the specified time.
listTrials_createdAfter :: Lens.Lens' ListTrials (Prelude.Maybe Prelude.UTCTime)
listTrials_createdAfter :: (Maybe UTCTime -> f (Maybe UTCTime)) -> ListTrials -> f ListTrials
listTrials_createdAfter = (ListTrials -> Maybe POSIX)
-> (ListTrials -> Maybe POSIX -> ListTrials)
-> Lens ListTrials ListTrials (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrials' {Maybe POSIX
createdAfter :: Maybe POSIX
$sel:createdAfter:ListTrials' :: ListTrials -> Maybe POSIX
createdAfter} -> Maybe POSIX
createdAfter) (\s :: ListTrials
s@ListTrials' {} Maybe POSIX
a -> ListTrials
s {$sel:createdAfter:ListTrials' :: Maybe POSIX
createdAfter = Maybe POSIX
a} :: ListTrials) ((Maybe POSIX -> f (Maybe POSIX)) -> ListTrials -> f ListTrials)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListTrials
-> f ListTrials
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

-- | A filter that returns only trials that are part of the specified
-- experiment.
listTrials_experimentName :: Lens.Lens' ListTrials (Prelude.Maybe Prelude.Text)
listTrials_experimentName :: (Maybe Text -> f (Maybe Text)) -> ListTrials -> f ListTrials
listTrials_experimentName = (ListTrials -> Maybe Text)
-> (ListTrials -> Maybe Text -> ListTrials)
-> Lens ListTrials ListTrials (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrials' {Maybe Text
experimentName :: Maybe Text
$sel:experimentName:ListTrials' :: ListTrials -> Maybe Text
experimentName} -> Maybe Text
experimentName) (\s :: ListTrials
s@ListTrials' {} Maybe Text
a -> ListTrials
s {$sel:experimentName:ListTrials' :: Maybe Text
experimentName = Maybe Text
a} :: ListTrials)

-- | If the previous call to @ListTrials@ didn\'t return the full set of
-- trials, the call returns a token for getting the next set of trials.
listTrials_nextToken :: Lens.Lens' ListTrials (Prelude.Maybe Prelude.Text)
listTrials_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListTrials -> f ListTrials
listTrials_nextToken = (ListTrials -> Maybe Text)
-> (ListTrials -> Maybe Text -> ListTrials)
-> Lens ListTrials ListTrials (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrials' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTrials' :: ListTrials -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTrials
s@ListTrials' {} Maybe Text
a -> ListTrials
s {$sel:nextToken:ListTrials' :: Maybe Text
nextToken = Maybe Text
a} :: ListTrials)

-- | The sort order. The default value is @Descending@.
listTrials_sortOrder :: Lens.Lens' ListTrials (Prelude.Maybe SortOrder)
listTrials_sortOrder :: (Maybe SortOrder -> f (Maybe SortOrder))
-> ListTrials -> f ListTrials
listTrials_sortOrder = (ListTrials -> Maybe SortOrder)
-> (ListTrials -> Maybe SortOrder -> ListTrials)
-> Lens ListTrials ListTrials (Maybe SortOrder) (Maybe SortOrder)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrials' {Maybe SortOrder
sortOrder :: Maybe SortOrder
$sel:sortOrder:ListTrials' :: ListTrials -> Maybe SortOrder
sortOrder} -> Maybe SortOrder
sortOrder) (\s :: ListTrials
s@ListTrials' {} Maybe SortOrder
a -> ListTrials
s {$sel:sortOrder:ListTrials' :: Maybe SortOrder
sortOrder = Maybe SortOrder
a} :: ListTrials)

-- | A filter that returns only trials that are associated with the specified
-- trial component.
listTrials_trialComponentName :: Lens.Lens' ListTrials (Prelude.Maybe Prelude.Text)
listTrials_trialComponentName :: (Maybe Text -> f (Maybe Text)) -> ListTrials -> f ListTrials
listTrials_trialComponentName = (ListTrials -> Maybe Text)
-> (ListTrials -> Maybe Text -> ListTrials)
-> Lens ListTrials ListTrials (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrials' {Maybe Text
trialComponentName :: Maybe Text
$sel:trialComponentName:ListTrials' :: ListTrials -> Maybe Text
trialComponentName} -> Maybe Text
trialComponentName) (\s :: ListTrials
s@ListTrials' {} Maybe Text
a -> ListTrials
s {$sel:trialComponentName:ListTrials' :: Maybe Text
trialComponentName = Maybe Text
a} :: ListTrials)

-- | The maximum number of trials to return in the response. The default
-- value is 10.
listTrials_maxResults :: Lens.Lens' ListTrials (Prelude.Maybe Prelude.Natural)
listTrials_maxResults :: (Maybe Natural -> f (Maybe Natural)) -> ListTrials -> f ListTrials
listTrials_maxResults = (ListTrials -> Maybe Natural)
-> (ListTrials -> Maybe Natural -> ListTrials)
-> Lens ListTrials ListTrials (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrials' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListTrials' :: ListTrials -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListTrials
s@ListTrials' {} Maybe Natural
a -> ListTrials
s {$sel:maxResults:ListTrials' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListTrials)

-- | A filter that returns only trials created before the specified time.
listTrials_createdBefore :: Lens.Lens' ListTrials (Prelude.Maybe Prelude.UTCTime)
listTrials_createdBefore :: (Maybe UTCTime -> f (Maybe UTCTime)) -> ListTrials -> f ListTrials
listTrials_createdBefore = (ListTrials -> Maybe POSIX)
-> (ListTrials -> Maybe POSIX -> ListTrials)
-> Lens ListTrials ListTrials (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrials' {Maybe POSIX
createdBefore :: Maybe POSIX
$sel:createdBefore:ListTrials' :: ListTrials -> Maybe POSIX
createdBefore} -> Maybe POSIX
createdBefore) (\s :: ListTrials
s@ListTrials' {} Maybe POSIX
a -> ListTrials
s {$sel:createdBefore:ListTrials' :: Maybe POSIX
createdBefore = Maybe POSIX
a} :: ListTrials) ((Maybe POSIX -> f (Maybe POSIX)) -> ListTrials -> f ListTrials)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListTrials
-> f ListTrials
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

-- | The property used to sort results. The default value is @CreationTime@.
listTrials_sortBy :: Lens.Lens' ListTrials (Prelude.Maybe SortTrialsBy)
listTrials_sortBy :: (Maybe SortTrialsBy -> f (Maybe SortTrialsBy))
-> ListTrials -> f ListTrials
listTrials_sortBy = (ListTrials -> Maybe SortTrialsBy)
-> (ListTrials -> Maybe SortTrialsBy -> ListTrials)
-> Lens
     ListTrials ListTrials (Maybe SortTrialsBy) (Maybe SortTrialsBy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrials' {Maybe SortTrialsBy
sortBy :: Maybe SortTrialsBy
$sel:sortBy:ListTrials' :: ListTrials -> Maybe SortTrialsBy
sortBy} -> Maybe SortTrialsBy
sortBy) (\s :: ListTrials
s@ListTrials' {} Maybe SortTrialsBy
a -> ListTrials
s {$sel:sortBy:ListTrials' :: Maybe SortTrialsBy
sortBy = Maybe SortTrialsBy
a} :: ListTrials)

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

instance Prelude.NFData ListTrials

instance Core.ToHeaders ListTrials where
  toHeaders :: ListTrials -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListTrials -> 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
"SageMaker.ListTrials" :: 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 ListTrials where
  toJSON :: ListTrials -> Value
toJSON ListTrials' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe SortOrder
Maybe SortTrialsBy
sortBy :: Maybe SortTrialsBy
createdBefore :: Maybe POSIX
maxResults :: Maybe Natural
trialComponentName :: Maybe Text
sortOrder :: Maybe SortOrder
nextToken :: Maybe Text
experimentName :: Maybe Text
createdAfter :: Maybe POSIX
$sel:sortBy:ListTrials' :: ListTrials -> Maybe SortTrialsBy
$sel:createdBefore:ListTrials' :: ListTrials -> Maybe POSIX
$sel:maxResults:ListTrials' :: ListTrials -> Maybe Natural
$sel:trialComponentName:ListTrials' :: ListTrials -> Maybe Text
$sel:sortOrder:ListTrials' :: ListTrials -> Maybe SortOrder
$sel:nextToken:ListTrials' :: ListTrials -> Maybe Text
$sel:experimentName:ListTrials' :: ListTrials -> Maybe Text
$sel:createdAfter:ListTrials' :: ListTrials -> Maybe POSIX
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CreatedAfter" 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
createdAfter,
            (Text
"ExperimentName" 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
experimentName,
            (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
"SortOrder" Text -> SortOrder -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SortOrder -> Pair) -> Maybe SortOrder -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SortOrder
sortOrder,
            (Text
"TrialComponentName" 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
trialComponentName,
            (Text
"MaxResults" 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
maxResults,
            (Text
"CreatedBefore" 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
createdBefore,
            (Text
"SortBy" Text -> SortTrialsBy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SortTrialsBy -> Pair) -> Maybe SortTrialsBy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SortTrialsBy
sortBy
          ]
      )

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

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

-- | /See:/ 'newListTrialsResponse' smart constructor.
data ListTrialsResponse = ListTrialsResponse'
  { -- | A token for getting the next set of trials, if there are any.
    ListTrialsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of the summaries of your trials.
    ListTrialsResponse -> Maybe [TrialSummary]
trialSummaries :: Prelude.Maybe [TrialSummary],
    -- | The response's http status code.
    ListTrialsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListTrialsResponse -> ListTrialsResponse -> Bool
(ListTrialsResponse -> ListTrialsResponse -> Bool)
-> (ListTrialsResponse -> ListTrialsResponse -> Bool)
-> Eq ListTrialsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTrialsResponse -> ListTrialsResponse -> Bool
$c/= :: ListTrialsResponse -> ListTrialsResponse -> Bool
== :: ListTrialsResponse -> ListTrialsResponse -> Bool
$c== :: ListTrialsResponse -> ListTrialsResponse -> Bool
Prelude.Eq, ReadPrec [ListTrialsResponse]
ReadPrec ListTrialsResponse
Int -> ReadS ListTrialsResponse
ReadS [ListTrialsResponse]
(Int -> ReadS ListTrialsResponse)
-> ReadS [ListTrialsResponse]
-> ReadPrec ListTrialsResponse
-> ReadPrec [ListTrialsResponse]
-> Read ListTrialsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTrialsResponse]
$creadListPrec :: ReadPrec [ListTrialsResponse]
readPrec :: ReadPrec ListTrialsResponse
$creadPrec :: ReadPrec ListTrialsResponse
readList :: ReadS [ListTrialsResponse]
$creadList :: ReadS [ListTrialsResponse]
readsPrec :: Int -> ReadS ListTrialsResponse
$creadsPrec :: Int -> ReadS ListTrialsResponse
Prelude.Read, Int -> ListTrialsResponse -> ShowS
[ListTrialsResponse] -> ShowS
ListTrialsResponse -> String
(Int -> ListTrialsResponse -> ShowS)
-> (ListTrialsResponse -> String)
-> ([ListTrialsResponse] -> ShowS)
-> Show ListTrialsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTrialsResponse] -> ShowS
$cshowList :: [ListTrialsResponse] -> ShowS
show :: ListTrialsResponse -> String
$cshow :: ListTrialsResponse -> String
showsPrec :: Int -> ListTrialsResponse -> ShowS
$cshowsPrec :: Int -> ListTrialsResponse -> ShowS
Prelude.Show, (forall x. ListTrialsResponse -> Rep ListTrialsResponse x)
-> (forall x. Rep ListTrialsResponse x -> ListTrialsResponse)
-> Generic ListTrialsResponse
forall x. Rep ListTrialsResponse x -> ListTrialsResponse
forall x. ListTrialsResponse -> Rep ListTrialsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTrialsResponse x -> ListTrialsResponse
$cfrom :: forall x. ListTrialsResponse -> Rep ListTrialsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListTrialsResponse' 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', 'listTrialsResponse_nextToken' - A token for getting the next set of trials, if there are any.
--
-- 'trialSummaries', 'listTrialsResponse_trialSummaries' - A list of the summaries of your trials.
--
-- 'httpStatus', 'listTrialsResponse_httpStatus' - The response's http status code.
newListTrialsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListTrialsResponse
newListTrialsResponse :: Int -> ListTrialsResponse
newListTrialsResponse Int
pHttpStatus_ =
  ListTrialsResponse' :: Maybe Text -> Maybe [TrialSummary] -> Int -> ListTrialsResponse
ListTrialsResponse'
    { $sel:nextToken:ListTrialsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:trialSummaries:ListTrialsResponse' :: Maybe [TrialSummary]
trialSummaries = Maybe [TrialSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListTrialsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A token for getting the next set of trials, if there are any.
listTrialsResponse_nextToken :: Lens.Lens' ListTrialsResponse (Prelude.Maybe Prelude.Text)
listTrialsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListTrialsResponse -> f ListTrialsResponse
listTrialsResponse_nextToken = (ListTrialsResponse -> Maybe Text)
-> (ListTrialsResponse -> Maybe Text -> ListTrialsResponse)
-> Lens' ListTrialsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrialsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTrialsResponse' :: ListTrialsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTrialsResponse
s@ListTrialsResponse' {} Maybe Text
a -> ListTrialsResponse
s {$sel:nextToken:ListTrialsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListTrialsResponse)

-- | A list of the summaries of your trials.
listTrialsResponse_trialSummaries :: Lens.Lens' ListTrialsResponse (Prelude.Maybe [TrialSummary])
listTrialsResponse_trialSummaries :: (Maybe [TrialSummary] -> f (Maybe [TrialSummary]))
-> ListTrialsResponse -> f ListTrialsResponse
listTrialsResponse_trialSummaries = (ListTrialsResponse -> Maybe [TrialSummary])
-> (ListTrialsResponse
    -> Maybe [TrialSummary] -> ListTrialsResponse)
-> Lens' ListTrialsResponse (Maybe [TrialSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrialsResponse' {Maybe [TrialSummary]
trialSummaries :: Maybe [TrialSummary]
$sel:trialSummaries:ListTrialsResponse' :: ListTrialsResponse -> Maybe [TrialSummary]
trialSummaries} -> Maybe [TrialSummary]
trialSummaries) (\s :: ListTrialsResponse
s@ListTrialsResponse' {} Maybe [TrialSummary]
a -> ListTrialsResponse
s {$sel:trialSummaries:ListTrialsResponse' :: Maybe [TrialSummary]
trialSummaries = Maybe [TrialSummary]
a} :: ListTrialsResponse) ((Maybe [TrialSummary] -> f (Maybe [TrialSummary]))
 -> ListTrialsResponse -> f ListTrialsResponse)
-> ((Maybe [TrialSummary] -> f (Maybe [TrialSummary]))
    -> Maybe [TrialSummary] -> f (Maybe [TrialSummary]))
-> (Maybe [TrialSummary] -> f (Maybe [TrialSummary]))
-> ListTrialsResponse
-> f ListTrialsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [TrialSummary] [TrialSummary] [TrialSummary] [TrialSummary]
-> Iso
     (Maybe [TrialSummary])
     (Maybe [TrialSummary])
     (Maybe [TrialSummary])
     (Maybe [TrialSummary])
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 [TrialSummary] [TrialSummary] [TrialSummary] [TrialSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListTrialsResponse