{-# 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.ListImages
-- 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 images in your account and their properties. The list can be
-- filtered by creation time or modified time, and whether the image name
-- contains a specified string.
--
-- This operation returns paginated results.
module Amazonka.SageMaker.ListImages
  ( -- * Creating a Request
    ListImages (..),
    newListImages,

    -- * Request Lenses
    listImages_nameContains,
    listImages_lastModifiedTimeBefore,
    listImages_creationTimeAfter,
    listImages_nextToken,
    listImages_sortOrder,
    listImages_lastModifiedTimeAfter,
    listImages_creationTimeBefore,
    listImages_maxResults,
    listImages_sortBy,

    -- * Destructuring the Response
    ListImagesResponse (..),
    newListImagesResponse,

    -- * Response Lenses
    listImagesResponse_images,
    listImagesResponse_nextToken,
    listImagesResponse_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:/ 'newListImages' smart constructor.
data ListImages = ListImages'
  { -- | A filter that returns only images whose name contains the specified
    -- string.
    ListImages -> Maybe Text
nameContains :: Prelude.Maybe Prelude.Text,
    -- | A filter that returns only images modified on or before the specified
    -- time.
    ListImages -> Maybe POSIX
lastModifiedTimeBefore :: Prelude.Maybe Core.POSIX,
    -- | A filter that returns only images created on or after the specified
    -- time.
    ListImages -> Maybe POSIX
creationTimeAfter :: Prelude.Maybe Core.POSIX,
    -- | If the previous call to @ListImages@ didn\'t return the full set of
    -- images, the call returns a token for getting the next set of images.
    ListImages -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The sort order. The default value is @DESCENDING@.
    ListImages -> Maybe ImageSortOrder
sortOrder :: Prelude.Maybe ImageSortOrder,
    -- | A filter that returns only images modified on or after the specified
    -- time.
    ListImages -> Maybe POSIX
lastModifiedTimeAfter :: Prelude.Maybe Core.POSIX,
    -- | A filter that returns only images created on or before the specified
    -- time.
    ListImages -> Maybe POSIX
creationTimeBefore :: Prelude.Maybe Core.POSIX,
    -- | The maximum number of images to return in the response. The default
    -- value is 10.
    ListImages -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The property used to sort results. The default value is @CREATION_TIME@.
    ListImages -> Maybe ImageSortBy
sortBy :: Prelude.Maybe ImageSortBy
  }
  deriving (ListImages -> ListImages -> Bool
(ListImages -> ListImages -> Bool)
-> (ListImages -> ListImages -> Bool) -> Eq ListImages
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListImages -> ListImages -> Bool
$c/= :: ListImages -> ListImages -> Bool
== :: ListImages -> ListImages -> Bool
$c== :: ListImages -> ListImages -> Bool
Prelude.Eq, ReadPrec [ListImages]
ReadPrec ListImages
Int -> ReadS ListImages
ReadS [ListImages]
(Int -> ReadS ListImages)
-> ReadS [ListImages]
-> ReadPrec ListImages
-> ReadPrec [ListImages]
-> Read ListImages
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListImages]
$creadListPrec :: ReadPrec [ListImages]
readPrec :: ReadPrec ListImages
$creadPrec :: ReadPrec ListImages
readList :: ReadS [ListImages]
$creadList :: ReadS [ListImages]
readsPrec :: Int -> ReadS ListImages
$creadsPrec :: Int -> ReadS ListImages
Prelude.Read, Int -> ListImages -> ShowS
[ListImages] -> ShowS
ListImages -> String
(Int -> ListImages -> ShowS)
-> (ListImages -> String)
-> ([ListImages] -> ShowS)
-> Show ListImages
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListImages] -> ShowS
$cshowList :: [ListImages] -> ShowS
show :: ListImages -> String
$cshow :: ListImages -> String
showsPrec :: Int -> ListImages -> ShowS
$cshowsPrec :: Int -> ListImages -> ShowS
Prelude.Show, (forall x. ListImages -> Rep ListImages x)
-> (forall x. Rep ListImages x -> ListImages) -> Generic ListImages
forall x. Rep ListImages x -> ListImages
forall x. ListImages -> Rep ListImages x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListImages x -> ListImages
$cfrom :: forall x. ListImages -> Rep ListImages x
Prelude.Generic)

-- |
-- Create a value of 'ListImages' 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', 'listImages_nameContains' - A filter that returns only images whose name contains the specified
-- string.
--
-- 'lastModifiedTimeBefore', 'listImages_lastModifiedTimeBefore' - A filter that returns only images modified on or before the specified
-- time.
--
-- 'creationTimeAfter', 'listImages_creationTimeAfter' - A filter that returns only images created on or after the specified
-- time.
--
-- 'nextToken', 'listImages_nextToken' - If the previous call to @ListImages@ didn\'t return the full set of
-- images, the call returns a token for getting the next set of images.
--
-- 'sortOrder', 'listImages_sortOrder' - The sort order. The default value is @DESCENDING@.
--
-- 'lastModifiedTimeAfter', 'listImages_lastModifiedTimeAfter' - A filter that returns only images modified on or after the specified
-- time.
--
-- 'creationTimeBefore', 'listImages_creationTimeBefore' - A filter that returns only images created on or before the specified
-- time.
--
-- 'maxResults', 'listImages_maxResults' - The maximum number of images to return in the response. The default
-- value is 10.
--
-- 'sortBy', 'listImages_sortBy' - The property used to sort results. The default value is @CREATION_TIME@.
newListImages ::
  ListImages
newListImages :: ListImages
newListImages =
  ListImages' :: Maybe Text
-> Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe ImageSortOrder
-> Maybe POSIX
-> Maybe POSIX
-> Maybe Natural
-> Maybe ImageSortBy
-> ListImages
ListImages'
    { $sel:nameContains:ListImages' :: Maybe Text
nameContains = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastModifiedTimeBefore:ListImages' :: Maybe POSIX
lastModifiedTimeBefore = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTimeAfter:ListImages' :: Maybe POSIX
creationTimeAfter = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListImages' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sortOrder:ListImages' :: Maybe ImageSortOrder
sortOrder = Maybe ImageSortOrder
forall a. Maybe a
Prelude.Nothing,
      $sel:lastModifiedTimeAfter:ListImages' :: Maybe POSIX
lastModifiedTimeAfter = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTimeBefore:ListImages' :: Maybe POSIX
creationTimeBefore = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListImages' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:sortBy:ListImages' :: Maybe ImageSortBy
sortBy = Maybe ImageSortBy
forall a. Maybe a
Prelude.Nothing
    }

-- | A filter that returns only images whose name contains the specified
-- string.
listImages_nameContains :: Lens.Lens' ListImages (Prelude.Maybe Prelude.Text)
listImages_nameContains :: (Maybe Text -> f (Maybe Text)) -> ListImages -> f ListImages
listImages_nameContains = (ListImages -> Maybe Text)
-> (ListImages -> Maybe Text -> ListImages)
-> Lens ListImages ListImages (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListImages' {Maybe Text
nameContains :: Maybe Text
$sel:nameContains:ListImages' :: ListImages -> Maybe Text
nameContains} -> Maybe Text
nameContains) (\s :: ListImages
s@ListImages' {} Maybe Text
a -> ListImages
s {$sel:nameContains:ListImages' :: Maybe Text
nameContains = Maybe Text
a} :: ListImages)

-- | A filter that returns only images modified on or before the specified
-- time.
listImages_lastModifiedTimeBefore :: Lens.Lens' ListImages (Prelude.Maybe Prelude.UTCTime)
listImages_lastModifiedTimeBefore :: (Maybe UTCTime -> f (Maybe UTCTime)) -> ListImages -> f ListImages
listImages_lastModifiedTimeBefore = (ListImages -> Maybe POSIX)
-> (ListImages -> Maybe POSIX -> ListImages)
-> Lens ListImages ListImages (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListImages' {Maybe POSIX
lastModifiedTimeBefore :: Maybe POSIX
$sel:lastModifiedTimeBefore:ListImages' :: ListImages -> Maybe POSIX
lastModifiedTimeBefore} -> Maybe POSIX
lastModifiedTimeBefore) (\s :: ListImages
s@ListImages' {} Maybe POSIX
a -> ListImages
s {$sel:lastModifiedTimeBefore:ListImages' :: Maybe POSIX
lastModifiedTimeBefore = Maybe POSIX
a} :: ListImages) ((Maybe POSIX -> f (Maybe POSIX)) -> ListImages -> f ListImages)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListImages
-> f ListImages
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 images created on or after the specified
-- time.
listImages_creationTimeAfter :: Lens.Lens' ListImages (Prelude.Maybe Prelude.UTCTime)
listImages_creationTimeAfter :: (Maybe UTCTime -> f (Maybe UTCTime)) -> ListImages -> f ListImages
listImages_creationTimeAfter = (ListImages -> Maybe POSIX)
-> (ListImages -> Maybe POSIX -> ListImages)
-> Lens ListImages ListImages (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListImages' {Maybe POSIX
creationTimeAfter :: Maybe POSIX
$sel:creationTimeAfter:ListImages' :: ListImages -> Maybe POSIX
creationTimeAfter} -> Maybe POSIX
creationTimeAfter) (\s :: ListImages
s@ListImages' {} Maybe POSIX
a -> ListImages
s {$sel:creationTimeAfter:ListImages' :: Maybe POSIX
creationTimeAfter = Maybe POSIX
a} :: ListImages) ((Maybe POSIX -> f (Maybe POSIX)) -> ListImages -> f ListImages)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListImages
-> f ListImages
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 previous call to @ListImages@ didn\'t return the full set of
-- images, the call returns a token for getting the next set of images.
listImages_nextToken :: Lens.Lens' ListImages (Prelude.Maybe Prelude.Text)
listImages_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListImages -> f ListImages
listImages_nextToken = (ListImages -> Maybe Text)
-> (ListImages -> Maybe Text -> ListImages)
-> Lens ListImages ListImages (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListImages' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListImages' :: ListImages -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListImages
s@ListImages' {} Maybe Text
a -> ListImages
s {$sel:nextToken:ListImages' :: Maybe Text
nextToken = Maybe Text
a} :: ListImages)

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

-- | A filter that returns only images modified on or after the specified
-- time.
listImages_lastModifiedTimeAfter :: Lens.Lens' ListImages (Prelude.Maybe Prelude.UTCTime)
listImages_lastModifiedTimeAfter :: (Maybe UTCTime -> f (Maybe UTCTime)) -> ListImages -> f ListImages
listImages_lastModifiedTimeAfter = (ListImages -> Maybe POSIX)
-> (ListImages -> Maybe POSIX -> ListImages)
-> Lens ListImages ListImages (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListImages' {Maybe POSIX
lastModifiedTimeAfter :: Maybe POSIX
$sel:lastModifiedTimeAfter:ListImages' :: ListImages -> Maybe POSIX
lastModifiedTimeAfter} -> Maybe POSIX
lastModifiedTimeAfter) (\s :: ListImages
s@ListImages' {} Maybe POSIX
a -> ListImages
s {$sel:lastModifiedTimeAfter:ListImages' :: Maybe POSIX
lastModifiedTimeAfter = Maybe POSIX
a} :: ListImages) ((Maybe POSIX -> f (Maybe POSIX)) -> ListImages -> f ListImages)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListImages
-> f ListImages
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 images created on or before the specified
-- time.
listImages_creationTimeBefore :: Lens.Lens' ListImages (Prelude.Maybe Prelude.UTCTime)
listImages_creationTimeBefore :: (Maybe UTCTime -> f (Maybe UTCTime)) -> ListImages -> f ListImages
listImages_creationTimeBefore = (ListImages -> Maybe POSIX)
-> (ListImages -> Maybe POSIX -> ListImages)
-> Lens ListImages ListImages (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListImages' {Maybe POSIX
creationTimeBefore :: Maybe POSIX
$sel:creationTimeBefore:ListImages' :: ListImages -> Maybe POSIX
creationTimeBefore} -> Maybe POSIX
creationTimeBefore) (\s :: ListImages
s@ListImages' {} Maybe POSIX
a -> ListImages
s {$sel:creationTimeBefore:ListImages' :: Maybe POSIX
creationTimeBefore = Maybe POSIX
a} :: ListImages) ((Maybe POSIX -> f (Maybe POSIX)) -> ListImages -> f ListImages)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListImages
-> f ListImages
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 images to return in the response. The default
-- value is 10.
listImages_maxResults :: Lens.Lens' ListImages (Prelude.Maybe Prelude.Natural)
listImages_maxResults :: (Maybe Natural -> f (Maybe Natural)) -> ListImages -> f ListImages
listImages_maxResults = (ListImages -> Maybe Natural)
-> (ListImages -> Maybe Natural -> ListImages)
-> Lens ListImages ListImages (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListImages' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListImages' :: ListImages -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListImages
s@ListImages' {} Maybe Natural
a -> ListImages
s {$sel:maxResults:ListImages' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListImages)

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

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

instance Prelude.NFData ListImages

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

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

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

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

-- |
-- Create a value of 'ListImagesResponse' 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:
--
-- 'images', 'listImagesResponse_images' - A list of images and their properties.
--
-- 'nextToken', 'listImagesResponse_nextToken' - A token for getting the next set of images, if there are any.
--
-- 'httpStatus', 'listImagesResponse_httpStatus' - The response's http status code.
newListImagesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListImagesResponse
newListImagesResponse :: Int -> ListImagesResponse
newListImagesResponse Int
pHttpStatus_ =
  ListImagesResponse' :: Maybe [Image] -> Maybe Text -> Int -> ListImagesResponse
ListImagesResponse'
    { $sel:images:ListImagesResponse' :: Maybe [Image]
images = Maybe [Image]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListImagesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListImagesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of images and their properties.
listImagesResponse_images :: Lens.Lens' ListImagesResponse (Prelude.Maybe [Image])
listImagesResponse_images :: (Maybe [Image] -> f (Maybe [Image]))
-> ListImagesResponse -> f ListImagesResponse
listImagesResponse_images = (ListImagesResponse -> Maybe [Image])
-> (ListImagesResponse -> Maybe [Image] -> ListImagesResponse)
-> Lens' ListImagesResponse (Maybe [Image])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListImagesResponse' {Maybe [Image]
images :: Maybe [Image]
$sel:images:ListImagesResponse' :: ListImagesResponse -> Maybe [Image]
images} -> Maybe [Image]
images) (\s :: ListImagesResponse
s@ListImagesResponse' {} Maybe [Image]
a -> ListImagesResponse
s {$sel:images:ListImagesResponse' :: Maybe [Image]
images = Maybe [Image]
a} :: ListImagesResponse) ((Maybe [Image] -> f (Maybe [Image]))
 -> ListImagesResponse -> f ListImagesResponse)
-> ((Maybe [Image] -> f (Maybe [Image]))
    -> Maybe [Image] -> f (Maybe [Image]))
-> (Maybe [Image] -> f (Maybe [Image]))
-> ListImagesResponse
-> f ListImagesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Image] [Image] [Image] [Image]
-> Iso
     (Maybe [Image]) (Maybe [Image]) (Maybe [Image]) (Maybe [Image])
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 [Image] [Image] [Image] [Image]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance Prelude.NFData ListImagesResponse