{-# 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.ListModels
-- 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 models created with the @CreateModel@ API.
--
-- This operation returns paginated results.
module Amazonka.SageMaker.ListModels
  ( -- * Creating a Request
    ListModels (..),
    newListModels,

    -- * Request Lenses
    listModels_nameContains,
    listModels_creationTimeAfter,
    listModels_nextToken,
    listModels_sortOrder,
    listModels_creationTimeBefore,
    listModels_maxResults,
    listModels_sortBy,

    -- * Destructuring the Response
    ListModelsResponse (..),
    newListModelsResponse,

    -- * Response Lenses
    listModelsResponse_nextToken,
    listModelsResponse_httpStatus,
    listModelsResponse_models,
  )
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:/ 'newListModels' smart constructor.
data ListModels = ListModels'
  { -- | A string in the model name. This filter returns only models whose name
    -- contains the specified string.
    ListModels -> Maybe Text
nameContains :: Prelude.Maybe Prelude.Text,
    -- | A filter that returns only models with a creation time greater than or
    -- equal to the specified time (timestamp).
    ListModels -> Maybe POSIX
creationTimeAfter :: Prelude.Maybe Core.POSIX,
    -- | If the response to a previous @ListModels@ request was truncated, the
    -- response includes a @NextToken@. To retrieve the next set of models, use
    -- the token in the next request.
    ListModels -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The sort order for results. The default is @Descending@.
    ListModels -> Maybe OrderKey
sortOrder :: Prelude.Maybe OrderKey,
    -- | A filter that returns only models created before the specified time
    -- (timestamp).
    ListModels -> Maybe POSIX
creationTimeBefore :: Prelude.Maybe Core.POSIX,
    -- | The maximum number of models to return in the response.
    ListModels -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | Sorts the list of results. The default is @CreationTime@.
    ListModels -> Maybe ModelSortKey
sortBy :: Prelude.Maybe ModelSortKey
  }
  deriving (ListModels -> ListModels -> Bool
(ListModels -> ListModels -> Bool)
-> (ListModels -> ListModels -> Bool) -> Eq ListModels
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListModels -> ListModels -> Bool
$c/= :: ListModels -> ListModels -> Bool
== :: ListModels -> ListModels -> Bool
$c== :: ListModels -> ListModels -> Bool
Prelude.Eq, ReadPrec [ListModels]
ReadPrec ListModels
Int -> ReadS ListModels
ReadS [ListModels]
(Int -> ReadS ListModels)
-> ReadS [ListModels]
-> ReadPrec ListModels
-> ReadPrec [ListModels]
-> Read ListModels
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListModels]
$creadListPrec :: ReadPrec [ListModels]
readPrec :: ReadPrec ListModels
$creadPrec :: ReadPrec ListModels
readList :: ReadS [ListModels]
$creadList :: ReadS [ListModels]
readsPrec :: Int -> ReadS ListModels
$creadsPrec :: Int -> ReadS ListModels
Prelude.Read, Int -> ListModels -> ShowS
[ListModels] -> ShowS
ListModels -> String
(Int -> ListModels -> ShowS)
-> (ListModels -> String)
-> ([ListModels] -> ShowS)
-> Show ListModels
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListModels] -> ShowS
$cshowList :: [ListModels] -> ShowS
show :: ListModels -> String
$cshow :: ListModels -> String
showsPrec :: Int -> ListModels -> ShowS
$cshowsPrec :: Int -> ListModels -> ShowS
Prelude.Show, (forall x. ListModels -> Rep ListModels x)
-> (forall x. Rep ListModels x -> ListModels) -> Generic ListModels
forall x. Rep ListModels x -> ListModels
forall x. ListModels -> Rep ListModels x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListModels x -> ListModels
$cfrom :: forall x. ListModels -> Rep ListModels x
Prelude.Generic)

-- |
-- Create a value of 'ListModels' 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', 'listModels_nameContains' - A string in the model name. This filter returns only models whose name
-- contains the specified string.
--
-- 'creationTimeAfter', 'listModels_creationTimeAfter' - A filter that returns only models with a creation time greater than or
-- equal to the specified time (timestamp).
--
-- 'nextToken', 'listModels_nextToken' - If the response to a previous @ListModels@ request was truncated, the
-- response includes a @NextToken@. To retrieve the next set of models, use
-- the token in the next request.
--
-- 'sortOrder', 'listModels_sortOrder' - The sort order for results. The default is @Descending@.
--
-- 'creationTimeBefore', 'listModels_creationTimeBefore' - A filter that returns only models created before the specified time
-- (timestamp).
--
-- 'maxResults', 'listModels_maxResults' - The maximum number of models to return in the response.
--
-- 'sortBy', 'listModels_sortBy' - Sorts the list of results. The default is @CreationTime@.
newListModels ::
  ListModels
newListModels :: ListModels
newListModels =
  ListModels' :: Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe OrderKey
-> Maybe POSIX
-> Maybe Natural
-> Maybe ModelSortKey
-> ListModels
ListModels'
    { $sel:nameContains:ListModels' :: Maybe Text
nameContains = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTimeAfter:ListModels' :: Maybe POSIX
creationTimeAfter = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListModels' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sortOrder:ListModels' :: Maybe OrderKey
sortOrder = Maybe OrderKey
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTimeBefore:ListModels' :: Maybe POSIX
creationTimeBefore = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListModels' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:sortBy:ListModels' :: Maybe ModelSortKey
sortBy = Maybe ModelSortKey
forall a. Maybe a
Prelude.Nothing
    }

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

-- | A filter that returns only models with a creation time greater than or
-- equal to the specified time (timestamp).
listModels_creationTimeAfter :: Lens.Lens' ListModels (Prelude.Maybe Prelude.UTCTime)
listModels_creationTimeAfter :: (Maybe UTCTime -> f (Maybe UTCTime)) -> ListModels -> f ListModels
listModels_creationTimeAfter = (ListModels -> Maybe POSIX)
-> (ListModels -> Maybe POSIX -> ListModels)
-> Lens ListModels ListModels (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListModels' {Maybe POSIX
creationTimeAfter :: Maybe POSIX
$sel:creationTimeAfter:ListModels' :: ListModels -> Maybe POSIX
creationTimeAfter} -> Maybe POSIX
creationTimeAfter) (\s :: ListModels
s@ListModels' {} Maybe POSIX
a -> ListModels
s {$sel:creationTimeAfter:ListModels' :: Maybe POSIX
creationTimeAfter = Maybe POSIX
a} :: ListModels) ((Maybe POSIX -> f (Maybe POSIX)) -> ListModels -> f ListModels)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListModels
-> f ListModels
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 @ListModels@ request was truncated, the
-- response includes a @NextToken@. To retrieve the next set of models, use
-- the token in the next request.
listModels_nextToken :: Lens.Lens' ListModels (Prelude.Maybe Prelude.Text)
listModels_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListModels -> f ListModels
listModels_nextToken = (ListModels -> Maybe Text)
-> (ListModels -> Maybe Text -> ListModels)
-> Lens ListModels ListModels (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListModels' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListModels' :: ListModels -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListModels
s@ListModels' {} Maybe Text
a -> ListModels
s {$sel:nextToken:ListModels' :: Maybe Text
nextToken = Maybe Text
a} :: ListModels)

-- | The sort order for results. The default is @Descending@.
listModels_sortOrder :: Lens.Lens' ListModels (Prelude.Maybe OrderKey)
listModels_sortOrder :: (Maybe OrderKey -> f (Maybe OrderKey))
-> ListModels -> f ListModels
listModels_sortOrder = (ListModels -> Maybe OrderKey)
-> (ListModels -> Maybe OrderKey -> ListModels)
-> Lens ListModels ListModels (Maybe OrderKey) (Maybe OrderKey)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListModels' {Maybe OrderKey
sortOrder :: Maybe OrderKey
$sel:sortOrder:ListModels' :: ListModels -> Maybe OrderKey
sortOrder} -> Maybe OrderKey
sortOrder) (\s :: ListModels
s@ListModels' {} Maybe OrderKey
a -> ListModels
s {$sel:sortOrder:ListModels' :: Maybe OrderKey
sortOrder = Maybe OrderKey
a} :: ListModels)

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

-- | Sorts the list of results. The default is @CreationTime@.
listModels_sortBy :: Lens.Lens' ListModels (Prelude.Maybe ModelSortKey)
listModels_sortBy :: (Maybe ModelSortKey -> f (Maybe ModelSortKey))
-> ListModels -> f ListModels
listModels_sortBy = (ListModels -> Maybe ModelSortKey)
-> (ListModels -> Maybe ModelSortKey -> ListModels)
-> Lens
     ListModels ListModels (Maybe ModelSortKey) (Maybe ModelSortKey)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListModels' {Maybe ModelSortKey
sortBy :: Maybe ModelSortKey
$sel:sortBy:ListModels' :: ListModels -> Maybe ModelSortKey
sortBy} -> Maybe ModelSortKey
sortBy) (\s :: ListModels
s@ListModels' {} Maybe ModelSortKey
a -> ListModels
s {$sel:sortBy:ListModels' :: Maybe ModelSortKey
sortBy = Maybe ModelSortKey
a} :: ListModels)

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

instance Prelude.Hashable ListModels

instance Prelude.NFData ListModels

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

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

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

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

-- |
-- Create a value of 'ListModelsResponse' 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', 'listModelsResponse_nextToken' - If the response is truncated, Amazon SageMaker returns this token. To
-- retrieve the next set of models, use it in the subsequent request.
--
-- 'httpStatus', 'listModelsResponse_httpStatus' - The response's http status code.
--
-- 'models', 'listModelsResponse_models' - An array of @ModelSummary@ objects, each of which lists a model.
newListModelsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListModelsResponse
newListModelsResponse :: Int -> ListModelsResponse
newListModelsResponse Int
pHttpStatus_ =
  ListModelsResponse' :: Maybe Text -> Int -> [ModelSummary] -> ListModelsResponse
ListModelsResponse'
    { $sel:nextToken:ListModelsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListModelsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:models:ListModelsResponse' :: [ModelSummary]
models = [ModelSummary]
forall a. Monoid a => a
Prelude.mempty
    }

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

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

-- | An array of @ModelSummary@ objects, each of which lists a model.
listModelsResponse_models :: Lens.Lens' ListModelsResponse [ModelSummary]
listModelsResponse_models :: ([ModelSummary] -> f [ModelSummary])
-> ListModelsResponse -> f ListModelsResponse
listModelsResponse_models = (ListModelsResponse -> [ModelSummary])
-> (ListModelsResponse -> [ModelSummary] -> ListModelsResponse)
-> Lens' ListModelsResponse [ModelSummary]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListModelsResponse' {[ModelSummary]
models :: [ModelSummary]
$sel:models:ListModelsResponse' :: ListModelsResponse -> [ModelSummary]
models} -> [ModelSummary]
models) (\s :: ListModelsResponse
s@ListModelsResponse' {} [ModelSummary]
a -> ListModelsResponse
s {$sel:models:ListModelsResponse' :: [ModelSummary]
models = [ModelSummary]
a} :: ListModelsResponse) (([ModelSummary] -> f [ModelSummary])
 -> ListModelsResponse -> f ListModelsResponse)
-> (([ModelSummary] -> f [ModelSummary])
    -> [ModelSummary] -> f [ModelSummary])
-> ([ModelSummary] -> f [ModelSummary])
-> ListModelsResponse
-> f ListModelsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ModelSummary] -> f [ModelSummary])
-> [ModelSummary] -> f [ModelSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListModelsResponse