{-# 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.ListContexts
-- 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 contexts in your account and their properties.
--
-- This operation returns paginated results.
module Amazonka.SageMaker.ListContexts
  ( -- * Creating a Request
    ListContexts (..),
    newListContexts,

    -- * Request Lenses
    listContexts_createdAfter,
    listContexts_nextToken,
    listContexts_sortOrder,
    listContexts_contextType,
    listContexts_sourceUri,
    listContexts_maxResults,
    listContexts_createdBefore,
    listContexts_sortBy,

    -- * Destructuring the Response
    ListContextsResponse (..),
    newListContextsResponse,

    -- * Response Lenses
    listContextsResponse_contextSummaries,
    listContextsResponse_nextToken,
    listContextsResponse_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:/ 'newListContexts' smart constructor.
data ListContexts = ListContexts'
  { -- | A filter that returns only contexts created on or after the specified
    -- time.
    ListContexts -> Maybe POSIX
createdAfter :: Prelude.Maybe Core.POSIX,
    -- | If the previous call to @ListContexts@ didn\'t return the full set of
    -- contexts, the call returns a token for getting the next set of contexts.
    ListContexts -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The sort order. The default value is @Descending@.
    ListContexts -> Maybe SortOrder
sortOrder :: Prelude.Maybe SortOrder,
    -- | A filter that returns only contexts of the specified type.
    ListContexts -> Maybe Text
contextType :: Prelude.Maybe Prelude.Text,
    -- | A filter that returns only contexts with the specified source URI.
    ListContexts -> Maybe Text
sourceUri :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of contexts to return in the response. The default
    -- value is 10.
    ListContexts -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A filter that returns only contexts created on or before the specified
    -- time.
    ListContexts -> Maybe POSIX
createdBefore :: Prelude.Maybe Core.POSIX,
    -- | The property used to sort results. The default value is @CreationTime@.
    ListContexts -> Maybe SortContextsBy
sortBy :: Prelude.Maybe SortContextsBy
  }
  deriving (ListContexts -> ListContexts -> Bool
(ListContexts -> ListContexts -> Bool)
-> (ListContexts -> ListContexts -> Bool) -> Eq ListContexts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListContexts -> ListContexts -> Bool
$c/= :: ListContexts -> ListContexts -> Bool
== :: ListContexts -> ListContexts -> Bool
$c== :: ListContexts -> ListContexts -> Bool
Prelude.Eq, ReadPrec [ListContexts]
ReadPrec ListContexts
Int -> ReadS ListContexts
ReadS [ListContexts]
(Int -> ReadS ListContexts)
-> ReadS [ListContexts]
-> ReadPrec ListContexts
-> ReadPrec [ListContexts]
-> Read ListContexts
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListContexts]
$creadListPrec :: ReadPrec [ListContexts]
readPrec :: ReadPrec ListContexts
$creadPrec :: ReadPrec ListContexts
readList :: ReadS [ListContexts]
$creadList :: ReadS [ListContexts]
readsPrec :: Int -> ReadS ListContexts
$creadsPrec :: Int -> ReadS ListContexts
Prelude.Read, Int -> ListContexts -> ShowS
[ListContexts] -> ShowS
ListContexts -> String
(Int -> ListContexts -> ShowS)
-> (ListContexts -> String)
-> ([ListContexts] -> ShowS)
-> Show ListContexts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListContexts] -> ShowS
$cshowList :: [ListContexts] -> ShowS
show :: ListContexts -> String
$cshow :: ListContexts -> String
showsPrec :: Int -> ListContexts -> ShowS
$cshowsPrec :: Int -> ListContexts -> ShowS
Prelude.Show, (forall x. ListContexts -> Rep ListContexts x)
-> (forall x. Rep ListContexts x -> ListContexts)
-> Generic ListContexts
forall x. Rep ListContexts x -> ListContexts
forall x. ListContexts -> Rep ListContexts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListContexts x -> ListContexts
$cfrom :: forall x. ListContexts -> Rep ListContexts x
Prelude.Generic)

-- |
-- Create a value of 'ListContexts' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'createdAfter', 'listContexts_createdAfter' - A filter that returns only contexts created on or after the specified
-- time.
--
-- 'nextToken', 'listContexts_nextToken' - If the previous call to @ListContexts@ didn\'t return the full set of
-- contexts, the call returns a token for getting the next set of contexts.
--
-- 'sortOrder', 'listContexts_sortOrder' - The sort order. The default value is @Descending@.
--
-- 'contextType', 'listContexts_contextType' - A filter that returns only contexts of the specified type.
--
-- 'sourceUri', 'listContexts_sourceUri' - A filter that returns only contexts with the specified source URI.
--
-- 'maxResults', 'listContexts_maxResults' - The maximum number of contexts to return in the response. The default
-- value is 10.
--
-- 'createdBefore', 'listContexts_createdBefore' - A filter that returns only contexts created on or before the specified
-- time.
--
-- 'sortBy', 'listContexts_sortBy' - The property used to sort results. The default value is @CreationTime@.
newListContexts ::
  ListContexts
newListContexts :: ListContexts
newListContexts =
  ListContexts' :: Maybe POSIX
-> Maybe Text
-> Maybe SortOrder
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Maybe POSIX
-> Maybe SortContextsBy
-> ListContexts
ListContexts'
    { $sel:createdAfter:ListContexts' :: Maybe POSIX
createdAfter = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListContexts' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sortOrder:ListContexts' :: Maybe SortOrder
sortOrder = Maybe SortOrder
forall a. Maybe a
Prelude.Nothing,
      $sel:contextType:ListContexts' :: Maybe Text
contextType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceUri:ListContexts' :: Maybe Text
sourceUri = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListContexts' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:createdBefore:ListContexts' :: Maybe POSIX
createdBefore = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:sortBy:ListContexts' :: Maybe SortContextsBy
sortBy = Maybe SortContextsBy
forall a. Maybe a
Prelude.Nothing
    }

-- | A filter that returns only contexts created on or after the specified
-- time.
listContexts_createdAfter :: Lens.Lens' ListContexts (Prelude.Maybe Prelude.UTCTime)
listContexts_createdAfter :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListContexts -> f ListContexts
listContexts_createdAfter = (ListContexts -> Maybe POSIX)
-> (ListContexts -> Maybe POSIX -> ListContexts)
-> Lens ListContexts ListContexts (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContexts' {Maybe POSIX
createdAfter :: Maybe POSIX
$sel:createdAfter:ListContexts' :: ListContexts -> Maybe POSIX
createdAfter} -> Maybe POSIX
createdAfter) (\s :: ListContexts
s@ListContexts' {} Maybe POSIX
a -> ListContexts
s {$sel:createdAfter:ListContexts' :: Maybe POSIX
createdAfter = Maybe POSIX
a} :: ListContexts) ((Maybe POSIX -> f (Maybe POSIX))
 -> ListContexts -> f ListContexts)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListContexts
-> f ListContexts
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 @ListContexts@ didn\'t return the full set of
-- contexts, the call returns a token for getting the next set of contexts.
listContexts_nextToken :: Lens.Lens' ListContexts (Prelude.Maybe Prelude.Text)
listContexts_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListContexts -> f ListContexts
listContexts_nextToken = (ListContexts -> Maybe Text)
-> (ListContexts -> Maybe Text -> ListContexts)
-> Lens ListContexts ListContexts (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContexts' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListContexts' :: ListContexts -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListContexts
s@ListContexts' {} Maybe Text
a -> ListContexts
s {$sel:nextToken:ListContexts' :: Maybe Text
nextToken = Maybe Text
a} :: ListContexts)

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

-- | A filter that returns only contexts of the specified type.
listContexts_contextType :: Lens.Lens' ListContexts (Prelude.Maybe Prelude.Text)
listContexts_contextType :: (Maybe Text -> f (Maybe Text)) -> ListContexts -> f ListContexts
listContexts_contextType = (ListContexts -> Maybe Text)
-> (ListContexts -> Maybe Text -> ListContexts)
-> Lens ListContexts ListContexts (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContexts' {Maybe Text
contextType :: Maybe Text
$sel:contextType:ListContexts' :: ListContexts -> Maybe Text
contextType} -> Maybe Text
contextType) (\s :: ListContexts
s@ListContexts' {} Maybe Text
a -> ListContexts
s {$sel:contextType:ListContexts' :: Maybe Text
contextType = Maybe Text
a} :: ListContexts)

-- | A filter that returns only contexts with the specified source URI.
listContexts_sourceUri :: Lens.Lens' ListContexts (Prelude.Maybe Prelude.Text)
listContexts_sourceUri :: (Maybe Text -> f (Maybe Text)) -> ListContexts -> f ListContexts
listContexts_sourceUri = (ListContexts -> Maybe Text)
-> (ListContexts -> Maybe Text -> ListContexts)
-> Lens ListContexts ListContexts (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContexts' {Maybe Text
sourceUri :: Maybe Text
$sel:sourceUri:ListContexts' :: ListContexts -> Maybe Text
sourceUri} -> Maybe Text
sourceUri) (\s :: ListContexts
s@ListContexts' {} Maybe Text
a -> ListContexts
s {$sel:sourceUri:ListContexts' :: Maybe Text
sourceUri = Maybe Text
a} :: ListContexts)

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

-- | A filter that returns only contexts created on or before the specified
-- time.
listContexts_createdBefore :: Lens.Lens' ListContexts (Prelude.Maybe Prelude.UTCTime)
listContexts_createdBefore :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListContexts -> f ListContexts
listContexts_createdBefore = (ListContexts -> Maybe POSIX)
-> (ListContexts -> Maybe POSIX -> ListContexts)
-> Lens ListContexts ListContexts (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContexts' {Maybe POSIX
createdBefore :: Maybe POSIX
$sel:createdBefore:ListContexts' :: ListContexts -> Maybe POSIX
createdBefore} -> Maybe POSIX
createdBefore) (\s :: ListContexts
s@ListContexts' {} Maybe POSIX
a -> ListContexts
s {$sel:createdBefore:ListContexts' :: Maybe POSIX
createdBefore = Maybe POSIX
a} :: ListContexts) ((Maybe POSIX -> f (Maybe POSIX))
 -> ListContexts -> f ListContexts)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListContexts
-> f ListContexts
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

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

instance Prelude.NFData ListContexts

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

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

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

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

-- |
-- Create a value of 'ListContextsResponse' 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:
--
-- 'contextSummaries', 'listContextsResponse_contextSummaries' - A list of contexts and their properties.
--
-- 'nextToken', 'listContextsResponse_nextToken' - A token for getting the next set of contexts, if there are any.
--
-- 'httpStatus', 'listContextsResponse_httpStatus' - The response's http status code.
newListContextsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListContextsResponse
newListContextsResponse :: Int -> ListContextsResponse
newListContextsResponse Int
pHttpStatus_ =
  ListContextsResponse' :: Maybe [ContextSummary] -> Maybe Text -> Int -> ListContextsResponse
ListContextsResponse'
    { $sel:contextSummaries:ListContextsResponse' :: Maybe [ContextSummary]
contextSummaries =
        Maybe [ContextSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListContextsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListContextsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of contexts and their properties.
listContextsResponse_contextSummaries :: Lens.Lens' ListContextsResponse (Prelude.Maybe [ContextSummary])
listContextsResponse_contextSummaries :: (Maybe [ContextSummary] -> f (Maybe [ContextSummary]))
-> ListContextsResponse -> f ListContextsResponse
listContextsResponse_contextSummaries = (ListContextsResponse -> Maybe [ContextSummary])
-> (ListContextsResponse
    -> Maybe [ContextSummary] -> ListContextsResponse)
-> Lens' ListContextsResponse (Maybe [ContextSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContextsResponse' {Maybe [ContextSummary]
contextSummaries :: Maybe [ContextSummary]
$sel:contextSummaries:ListContextsResponse' :: ListContextsResponse -> Maybe [ContextSummary]
contextSummaries} -> Maybe [ContextSummary]
contextSummaries) (\s :: ListContextsResponse
s@ListContextsResponse' {} Maybe [ContextSummary]
a -> ListContextsResponse
s {$sel:contextSummaries:ListContextsResponse' :: Maybe [ContextSummary]
contextSummaries = Maybe [ContextSummary]
a} :: ListContextsResponse) ((Maybe [ContextSummary] -> f (Maybe [ContextSummary]))
 -> ListContextsResponse -> f ListContextsResponse)
-> ((Maybe [ContextSummary] -> f (Maybe [ContextSummary]))
    -> Maybe [ContextSummary] -> f (Maybe [ContextSummary]))
-> (Maybe [ContextSummary] -> f (Maybe [ContextSummary]))
-> ListContextsResponse
-> f ListContextsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ContextSummary] [ContextSummary] [ContextSummary] [ContextSummary]
-> Iso
     (Maybe [ContextSummary])
     (Maybe [ContextSummary])
     (Maybe [ContextSummary])
     (Maybe [ContextSummary])
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
  [ContextSummary] [ContextSummary] [ContextSummary] [ContextSummary]
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 contexts, if there are any.
listContextsResponse_nextToken :: Lens.Lens' ListContextsResponse (Prelude.Maybe Prelude.Text)
listContextsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListContextsResponse -> f ListContextsResponse
listContextsResponse_nextToken = (ListContextsResponse -> Maybe Text)
-> (ListContextsResponse -> Maybe Text -> ListContextsResponse)
-> Lens' ListContextsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListContextsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListContextsResponse' :: ListContextsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListContextsResponse
s@ListContextsResponse' {} Maybe Text
a -> ListContextsResponse
s {$sel:nextToken:ListContextsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListContextsResponse)

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

instance Prelude.NFData ListContextsResponse