{-# 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.ListAlgorithms
-- 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 machine learning algorithms that have been created.
--
-- This operation returns paginated results.
module Amazonka.SageMaker.ListAlgorithms
  ( -- * Creating a Request
    ListAlgorithms (..),
    newListAlgorithms,

    -- * Request Lenses
    listAlgorithms_nameContains,
    listAlgorithms_creationTimeAfter,
    listAlgorithms_nextToken,
    listAlgorithms_sortOrder,
    listAlgorithms_creationTimeBefore,
    listAlgorithms_maxResults,
    listAlgorithms_sortBy,

    -- * Destructuring the Response
    ListAlgorithmsResponse (..),
    newListAlgorithmsResponse,

    -- * Response Lenses
    listAlgorithmsResponse_nextToken,
    listAlgorithmsResponse_httpStatus,
    listAlgorithmsResponse_algorithmSummaryList,
  )
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:/ 'newListAlgorithms' smart constructor.
data ListAlgorithms = ListAlgorithms'
  { -- | A string in the algorithm name. This filter returns only algorithms
    -- whose name contains the specified string.
    ListAlgorithms -> Maybe Text
nameContains :: Prelude.Maybe Prelude.Text,
    -- | A filter that returns only algorithms created after the specified time
    -- (timestamp).
    ListAlgorithms -> Maybe POSIX
creationTimeAfter :: Prelude.Maybe Core.POSIX,
    -- | If the response to a previous @ListAlgorithms@ request was truncated,
    -- the response includes a @NextToken@. To retrieve the next set of
    -- algorithms, use the token in the next request.
    ListAlgorithms -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The sort order for the results. The default is @Ascending@.
    ListAlgorithms -> Maybe SortOrder
sortOrder :: Prelude.Maybe SortOrder,
    -- | A filter that returns only algorithms created before the specified time
    -- (timestamp).
    ListAlgorithms -> Maybe POSIX
creationTimeBefore :: Prelude.Maybe Core.POSIX,
    -- | The maximum number of algorithms to return in the response.
    ListAlgorithms -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The parameter by which to sort the results. The default is
    -- @CreationTime@.
    ListAlgorithms -> Maybe AlgorithmSortBy
sortBy :: Prelude.Maybe AlgorithmSortBy
  }
  deriving (ListAlgorithms -> ListAlgorithms -> Bool
(ListAlgorithms -> ListAlgorithms -> Bool)
-> (ListAlgorithms -> ListAlgorithms -> Bool) -> Eq ListAlgorithms
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAlgorithms -> ListAlgorithms -> Bool
$c/= :: ListAlgorithms -> ListAlgorithms -> Bool
== :: ListAlgorithms -> ListAlgorithms -> Bool
$c== :: ListAlgorithms -> ListAlgorithms -> Bool
Prelude.Eq, ReadPrec [ListAlgorithms]
ReadPrec ListAlgorithms
Int -> ReadS ListAlgorithms
ReadS [ListAlgorithms]
(Int -> ReadS ListAlgorithms)
-> ReadS [ListAlgorithms]
-> ReadPrec ListAlgorithms
-> ReadPrec [ListAlgorithms]
-> Read ListAlgorithms
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAlgorithms]
$creadListPrec :: ReadPrec [ListAlgorithms]
readPrec :: ReadPrec ListAlgorithms
$creadPrec :: ReadPrec ListAlgorithms
readList :: ReadS [ListAlgorithms]
$creadList :: ReadS [ListAlgorithms]
readsPrec :: Int -> ReadS ListAlgorithms
$creadsPrec :: Int -> ReadS ListAlgorithms
Prelude.Read, Int -> ListAlgorithms -> ShowS
[ListAlgorithms] -> ShowS
ListAlgorithms -> String
(Int -> ListAlgorithms -> ShowS)
-> (ListAlgorithms -> String)
-> ([ListAlgorithms] -> ShowS)
-> Show ListAlgorithms
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAlgorithms] -> ShowS
$cshowList :: [ListAlgorithms] -> ShowS
show :: ListAlgorithms -> String
$cshow :: ListAlgorithms -> String
showsPrec :: Int -> ListAlgorithms -> ShowS
$cshowsPrec :: Int -> ListAlgorithms -> ShowS
Prelude.Show, (forall x. ListAlgorithms -> Rep ListAlgorithms x)
-> (forall x. Rep ListAlgorithms x -> ListAlgorithms)
-> Generic ListAlgorithms
forall x. Rep ListAlgorithms x -> ListAlgorithms
forall x. ListAlgorithms -> Rep ListAlgorithms x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAlgorithms x -> ListAlgorithms
$cfrom :: forall x. ListAlgorithms -> Rep ListAlgorithms x
Prelude.Generic)

-- |
-- Create a value of 'ListAlgorithms' 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:
--
-- 'nameContains', 'listAlgorithms_nameContains' - A string in the algorithm name. This filter returns only algorithms
-- whose name contains the specified string.
--
-- 'creationTimeAfter', 'listAlgorithms_creationTimeAfter' - A filter that returns only algorithms created after the specified time
-- (timestamp).
--
-- 'nextToken', 'listAlgorithms_nextToken' - If the response to a previous @ListAlgorithms@ request was truncated,
-- the response includes a @NextToken@. To retrieve the next set of
-- algorithms, use the token in the next request.
--
-- 'sortOrder', 'listAlgorithms_sortOrder' - The sort order for the results. The default is @Ascending@.
--
-- 'creationTimeBefore', 'listAlgorithms_creationTimeBefore' - A filter that returns only algorithms created before the specified time
-- (timestamp).
--
-- 'maxResults', 'listAlgorithms_maxResults' - The maximum number of algorithms to return in the response.
--
-- 'sortBy', 'listAlgorithms_sortBy' - The parameter by which to sort the results. The default is
-- @CreationTime@.
newListAlgorithms ::
  ListAlgorithms
newListAlgorithms :: ListAlgorithms
newListAlgorithms =
  ListAlgorithms' :: Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe SortOrder
-> Maybe POSIX
-> Maybe Natural
-> Maybe AlgorithmSortBy
-> ListAlgorithms
ListAlgorithms'
    { $sel:nameContains:ListAlgorithms' :: Maybe Text
nameContains = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTimeAfter:ListAlgorithms' :: Maybe POSIX
creationTimeAfter = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAlgorithms' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sortOrder:ListAlgorithms' :: Maybe SortOrder
sortOrder = Maybe SortOrder
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTimeBefore:ListAlgorithms' :: Maybe POSIX
creationTimeBefore = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListAlgorithms' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:sortBy:ListAlgorithms' :: Maybe AlgorithmSortBy
sortBy = Maybe AlgorithmSortBy
forall a. Maybe a
Prelude.Nothing
    }

-- | A string in the algorithm name. This filter returns only algorithms
-- whose name contains the specified string.
listAlgorithms_nameContains :: Lens.Lens' ListAlgorithms (Prelude.Maybe Prelude.Text)
listAlgorithms_nameContains :: (Maybe Text -> f (Maybe Text))
-> ListAlgorithms -> f ListAlgorithms
listAlgorithms_nameContains = (ListAlgorithms -> Maybe Text)
-> (ListAlgorithms -> Maybe Text -> ListAlgorithms)
-> Lens ListAlgorithms ListAlgorithms (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAlgorithms' {Maybe Text
nameContains :: Maybe Text
$sel:nameContains:ListAlgorithms' :: ListAlgorithms -> Maybe Text
nameContains} -> Maybe Text
nameContains) (\s :: ListAlgorithms
s@ListAlgorithms' {} Maybe Text
a -> ListAlgorithms
s {$sel:nameContains:ListAlgorithms' :: Maybe Text
nameContains = Maybe Text
a} :: ListAlgorithms)

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

-- | If the response to a previous @ListAlgorithms@ request was truncated,
-- the response includes a @NextToken@. To retrieve the next set of
-- algorithms, use the token in the next request.
listAlgorithms_nextToken :: Lens.Lens' ListAlgorithms (Prelude.Maybe Prelude.Text)
listAlgorithms_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAlgorithms -> f ListAlgorithms
listAlgorithms_nextToken = (ListAlgorithms -> Maybe Text)
-> (ListAlgorithms -> Maybe Text -> ListAlgorithms)
-> Lens ListAlgorithms ListAlgorithms (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAlgorithms' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAlgorithms' :: ListAlgorithms -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAlgorithms
s@ListAlgorithms' {} Maybe Text
a -> ListAlgorithms
s {$sel:nextToken:ListAlgorithms' :: Maybe Text
nextToken = Maybe Text
a} :: ListAlgorithms)

-- | The sort order for the results. The default is @Ascending@.
listAlgorithms_sortOrder :: Lens.Lens' ListAlgorithms (Prelude.Maybe SortOrder)
listAlgorithms_sortOrder :: (Maybe SortOrder -> f (Maybe SortOrder))
-> ListAlgorithms -> f ListAlgorithms
listAlgorithms_sortOrder = (ListAlgorithms -> Maybe SortOrder)
-> (ListAlgorithms -> Maybe SortOrder -> ListAlgorithms)
-> Lens
     ListAlgorithms ListAlgorithms (Maybe SortOrder) (Maybe SortOrder)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAlgorithms' {Maybe SortOrder
sortOrder :: Maybe SortOrder
$sel:sortOrder:ListAlgorithms' :: ListAlgorithms -> Maybe SortOrder
sortOrder} -> Maybe SortOrder
sortOrder) (\s :: ListAlgorithms
s@ListAlgorithms' {} Maybe SortOrder
a -> ListAlgorithms
s {$sel:sortOrder:ListAlgorithms' :: Maybe SortOrder
sortOrder = Maybe SortOrder
a} :: ListAlgorithms)

-- | A filter that returns only algorithms created before the specified time
-- (timestamp).
listAlgorithms_creationTimeBefore :: Lens.Lens' ListAlgorithms (Prelude.Maybe Prelude.UTCTime)
listAlgorithms_creationTimeBefore :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListAlgorithms -> f ListAlgorithms
listAlgorithms_creationTimeBefore = (ListAlgorithms -> Maybe POSIX)
-> (ListAlgorithms -> Maybe POSIX -> ListAlgorithms)
-> Lens ListAlgorithms ListAlgorithms (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAlgorithms' {Maybe POSIX
creationTimeBefore :: Maybe POSIX
$sel:creationTimeBefore:ListAlgorithms' :: ListAlgorithms -> Maybe POSIX
creationTimeBefore} -> Maybe POSIX
creationTimeBefore) (\s :: ListAlgorithms
s@ListAlgorithms' {} Maybe POSIX
a -> ListAlgorithms
s {$sel:creationTimeBefore:ListAlgorithms' :: Maybe POSIX
creationTimeBefore = Maybe POSIX
a} :: ListAlgorithms) ((Maybe POSIX -> f (Maybe POSIX))
 -> ListAlgorithms -> f ListAlgorithms)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListAlgorithms
-> f ListAlgorithms
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 maximum number of algorithms to return in the response.
listAlgorithms_maxResults :: Lens.Lens' ListAlgorithms (Prelude.Maybe Prelude.Natural)
listAlgorithms_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListAlgorithms -> f ListAlgorithms
listAlgorithms_maxResults = (ListAlgorithms -> Maybe Natural)
-> (ListAlgorithms -> Maybe Natural -> ListAlgorithms)
-> Lens
     ListAlgorithms ListAlgorithms (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAlgorithms' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAlgorithms' :: ListAlgorithms -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAlgorithms
s@ListAlgorithms' {} Maybe Natural
a -> ListAlgorithms
s {$sel:maxResults:ListAlgorithms' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAlgorithms)

-- | The parameter by which to sort the results. The default is
-- @CreationTime@.
listAlgorithms_sortBy :: Lens.Lens' ListAlgorithms (Prelude.Maybe AlgorithmSortBy)
listAlgorithms_sortBy :: (Maybe AlgorithmSortBy -> f (Maybe AlgorithmSortBy))
-> ListAlgorithms -> f ListAlgorithms
listAlgorithms_sortBy = (ListAlgorithms -> Maybe AlgorithmSortBy)
-> (ListAlgorithms -> Maybe AlgorithmSortBy -> ListAlgorithms)
-> Lens
     ListAlgorithms
     ListAlgorithms
     (Maybe AlgorithmSortBy)
     (Maybe AlgorithmSortBy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAlgorithms' {Maybe AlgorithmSortBy
sortBy :: Maybe AlgorithmSortBy
$sel:sortBy:ListAlgorithms' :: ListAlgorithms -> Maybe AlgorithmSortBy
sortBy} -> Maybe AlgorithmSortBy
sortBy) (\s :: ListAlgorithms
s@ListAlgorithms' {} Maybe AlgorithmSortBy
a -> ListAlgorithms
s {$sel:sortBy:ListAlgorithms' :: Maybe AlgorithmSortBy
sortBy = Maybe AlgorithmSortBy
a} :: ListAlgorithms)

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

instance Prelude.Hashable ListAlgorithms

instance Prelude.NFData ListAlgorithms

instance Core.ToHeaders ListAlgorithms where
  toHeaders :: ListAlgorithms -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListAlgorithms -> 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.ListAlgorithms" :: 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 ListAlgorithms where
  toJSON :: ListAlgorithms -> Value
toJSON ListAlgorithms' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe AlgorithmSortBy
Maybe SortOrder
sortBy :: Maybe AlgorithmSortBy
maxResults :: Maybe Natural
creationTimeBefore :: Maybe POSIX
sortOrder :: Maybe SortOrder
nextToken :: Maybe Text
creationTimeAfter :: Maybe POSIX
nameContains :: Maybe Text
$sel:sortBy:ListAlgorithms' :: ListAlgorithms -> Maybe AlgorithmSortBy
$sel:maxResults:ListAlgorithms' :: ListAlgorithms -> Maybe Natural
$sel:creationTimeBefore:ListAlgorithms' :: ListAlgorithms -> Maybe POSIX
$sel:sortOrder:ListAlgorithms' :: ListAlgorithms -> Maybe SortOrder
$sel:nextToken:ListAlgorithms' :: ListAlgorithms -> Maybe Text
$sel:creationTimeAfter:ListAlgorithms' :: ListAlgorithms -> Maybe POSIX
$sel:nameContains:ListAlgorithms' :: ListAlgorithms -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NameContains" 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
nameContains,
            (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
"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
"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,
            (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
"SortBy" Text -> AlgorithmSortBy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AlgorithmSortBy -> Pair) -> Maybe AlgorithmSortBy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AlgorithmSortBy
sortBy
          ]
      )

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

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

-- | /See:/ 'newListAlgorithmsResponse' smart constructor.
data ListAlgorithmsResponse = ListAlgorithmsResponse'
  { -- | If the response is truncated, Amazon SageMaker returns this token. To
    -- retrieve the next set of algorithms, use it in the subsequent request.
    ListAlgorithmsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListAlgorithmsResponse -> Int
httpStatus :: Prelude.Int,
    -- | >An array of @AlgorithmSummary@ objects, each of which lists an
    -- algorithm.
    ListAlgorithmsResponse -> [AlgorithmSummary]
algorithmSummaryList :: [AlgorithmSummary]
  }
  deriving (ListAlgorithmsResponse -> ListAlgorithmsResponse -> Bool
(ListAlgorithmsResponse -> ListAlgorithmsResponse -> Bool)
-> (ListAlgorithmsResponse -> ListAlgorithmsResponse -> Bool)
-> Eq ListAlgorithmsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAlgorithmsResponse -> ListAlgorithmsResponse -> Bool
$c/= :: ListAlgorithmsResponse -> ListAlgorithmsResponse -> Bool
== :: ListAlgorithmsResponse -> ListAlgorithmsResponse -> Bool
$c== :: ListAlgorithmsResponse -> ListAlgorithmsResponse -> Bool
Prelude.Eq, ReadPrec [ListAlgorithmsResponse]
ReadPrec ListAlgorithmsResponse
Int -> ReadS ListAlgorithmsResponse
ReadS [ListAlgorithmsResponse]
(Int -> ReadS ListAlgorithmsResponse)
-> ReadS [ListAlgorithmsResponse]
-> ReadPrec ListAlgorithmsResponse
-> ReadPrec [ListAlgorithmsResponse]
-> Read ListAlgorithmsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAlgorithmsResponse]
$creadListPrec :: ReadPrec [ListAlgorithmsResponse]
readPrec :: ReadPrec ListAlgorithmsResponse
$creadPrec :: ReadPrec ListAlgorithmsResponse
readList :: ReadS [ListAlgorithmsResponse]
$creadList :: ReadS [ListAlgorithmsResponse]
readsPrec :: Int -> ReadS ListAlgorithmsResponse
$creadsPrec :: Int -> ReadS ListAlgorithmsResponse
Prelude.Read, Int -> ListAlgorithmsResponse -> ShowS
[ListAlgorithmsResponse] -> ShowS
ListAlgorithmsResponse -> String
(Int -> ListAlgorithmsResponse -> ShowS)
-> (ListAlgorithmsResponse -> String)
-> ([ListAlgorithmsResponse] -> ShowS)
-> Show ListAlgorithmsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAlgorithmsResponse] -> ShowS
$cshowList :: [ListAlgorithmsResponse] -> ShowS
show :: ListAlgorithmsResponse -> String
$cshow :: ListAlgorithmsResponse -> String
showsPrec :: Int -> ListAlgorithmsResponse -> ShowS
$cshowsPrec :: Int -> ListAlgorithmsResponse -> ShowS
Prelude.Show, (forall x. ListAlgorithmsResponse -> Rep ListAlgorithmsResponse x)
-> (forall x.
    Rep ListAlgorithmsResponse x -> ListAlgorithmsResponse)
-> Generic ListAlgorithmsResponse
forall x. Rep ListAlgorithmsResponse x -> ListAlgorithmsResponse
forall x. ListAlgorithmsResponse -> Rep ListAlgorithmsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAlgorithmsResponse x -> ListAlgorithmsResponse
$cfrom :: forall x. ListAlgorithmsResponse -> Rep ListAlgorithmsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAlgorithmsResponse' 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', 'listAlgorithmsResponse_nextToken' - If the response is truncated, Amazon SageMaker returns this token. To
-- retrieve the next set of algorithms, use it in the subsequent request.
--
-- 'httpStatus', 'listAlgorithmsResponse_httpStatus' - The response's http status code.
--
-- 'algorithmSummaryList', 'listAlgorithmsResponse_algorithmSummaryList' - >An array of @AlgorithmSummary@ objects, each of which lists an
-- algorithm.
newListAlgorithmsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAlgorithmsResponse
newListAlgorithmsResponse :: Int -> ListAlgorithmsResponse
newListAlgorithmsResponse Int
pHttpStatus_ =
  ListAlgorithmsResponse' :: Maybe Text -> Int -> [AlgorithmSummary] -> ListAlgorithmsResponse
ListAlgorithmsResponse'
    { $sel:nextToken:ListAlgorithmsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAlgorithmsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:algorithmSummaryList:ListAlgorithmsResponse' :: [AlgorithmSummary]
algorithmSummaryList = [AlgorithmSummary]
forall a. Monoid a => a
Prelude.mempty
    }

-- | If the response is truncated, Amazon SageMaker returns this token. To
-- retrieve the next set of algorithms, use it in the subsequent request.
listAlgorithmsResponse_nextToken :: Lens.Lens' ListAlgorithmsResponse (Prelude.Maybe Prelude.Text)
listAlgorithmsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAlgorithmsResponse -> f ListAlgorithmsResponse
listAlgorithmsResponse_nextToken = (ListAlgorithmsResponse -> Maybe Text)
-> (ListAlgorithmsResponse -> Maybe Text -> ListAlgorithmsResponse)
-> Lens' ListAlgorithmsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAlgorithmsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAlgorithmsResponse' :: ListAlgorithmsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAlgorithmsResponse
s@ListAlgorithmsResponse' {} Maybe Text
a -> ListAlgorithmsResponse
s {$sel:nextToken:ListAlgorithmsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAlgorithmsResponse)

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

-- | >An array of @AlgorithmSummary@ objects, each of which lists an
-- algorithm.
listAlgorithmsResponse_algorithmSummaryList :: Lens.Lens' ListAlgorithmsResponse [AlgorithmSummary]
listAlgorithmsResponse_algorithmSummaryList :: ([AlgorithmSummary] -> f [AlgorithmSummary])
-> ListAlgorithmsResponse -> f ListAlgorithmsResponse
listAlgorithmsResponse_algorithmSummaryList = (ListAlgorithmsResponse -> [AlgorithmSummary])
-> (ListAlgorithmsResponse
    -> [AlgorithmSummary] -> ListAlgorithmsResponse)
-> Lens' ListAlgorithmsResponse [AlgorithmSummary]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAlgorithmsResponse' {[AlgorithmSummary]
algorithmSummaryList :: [AlgorithmSummary]
$sel:algorithmSummaryList:ListAlgorithmsResponse' :: ListAlgorithmsResponse -> [AlgorithmSummary]
algorithmSummaryList} -> [AlgorithmSummary]
algorithmSummaryList) (\s :: ListAlgorithmsResponse
s@ListAlgorithmsResponse' {} [AlgorithmSummary]
a -> ListAlgorithmsResponse
s {$sel:algorithmSummaryList:ListAlgorithmsResponse' :: [AlgorithmSummary]
algorithmSummaryList = [AlgorithmSummary]
a} :: ListAlgorithmsResponse) (([AlgorithmSummary] -> f [AlgorithmSummary])
 -> ListAlgorithmsResponse -> f ListAlgorithmsResponse)
-> (([AlgorithmSummary] -> f [AlgorithmSummary])
    -> [AlgorithmSummary] -> f [AlgorithmSummary])
-> ([AlgorithmSummary] -> f [AlgorithmSummary])
-> ListAlgorithmsResponse
-> f ListAlgorithmsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AlgorithmSummary] -> f [AlgorithmSummary])
-> [AlgorithmSummary] -> f [AlgorithmSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListAlgorithmsResponse