{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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_contextType,
    listContexts_createdAfter,
    listContexts_createdBefore,
    listContexts_maxResults,
    listContexts_nextToken,
    listContexts_sortBy,
    listContexts_sortOrder,
    listContexts_sourceUri,

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

    -- * Response Lenses
    listContextsResponse_contextSummaries,
    listContextsResponse_nextToken,
    listContextsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 of the specified type.
    ListContexts -> Maybe Text
contextType :: Prelude.Maybe Prelude.Text,
    -- | A filter that returns only contexts created on or after the specified
    -- time.
    ListContexts -> Maybe POSIX
createdAfter :: Prelude.Maybe Data.POSIX,
    -- | A filter that returns only contexts created on or before the specified
    -- time.
    ListContexts -> Maybe POSIX
createdBefore :: Prelude.Maybe Data.POSIX,
    -- | The maximum number of contexts to return in the response. The default
    -- value is 10.
    ListContexts -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | 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 property used to sort results. The default value is @CreationTime@.
    ListContexts -> Maybe SortContextsBy
sortBy :: Prelude.Maybe SortContextsBy,
    -- | The sort order. The default value is @Descending@.
    ListContexts -> Maybe SortOrder
sortOrder :: Prelude.Maybe SortOrder,
    -- | A filter that returns only contexts with the specified source URI.
    ListContexts -> Maybe Text
sourceUri :: Prelude.Maybe Prelude.Text
  }
  deriving (ListContexts -> ListContexts -> Bool
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]
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
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. 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:
--
-- 'contextType', 'listContexts_contextType' - A filter that returns only contexts of the specified type.
--
-- 'createdAfter', 'listContexts_createdAfter' - A filter that returns only contexts created on or after the specified
-- time.
--
-- 'createdBefore', 'listContexts_createdBefore' - A filter that returns only contexts created on or before the specified
-- time.
--
-- 'maxResults', 'listContexts_maxResults' - The maximum number of contexts to return in the response. The default
-- value is 10.
--
-- '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.
--
-- 'sortBy', 'listContexts_sortBy' - The property used to sort results. The default value is @CreationTime@.
--
-- 'sortOrder', 'listContexts_sortOrder' - The sort order. The default value is @Descending@.
--
-- 'sourceUri', 'listContexts_sourceUri' - A filter that returns only contexts with the specified source URI.
newListContexts ::
  ListContexts
newListContexts :: ListContexts
newListContexts =
  ListContexts'
    { $sel:contextType:ListContexts' :: Maybe Text
contextType = forall a. Maybe a
Prelude.Nothing,
      $sel:createdAfter:ListContexts' :: Maybe POSIX
createdAfter = forall a. Maybe a
Prelude.Nothing,
      $sel:createdBefore:ListContexts' :: Maybe POSIX
createdBefore = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListContexts' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListContexts' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:sortBy:ListContexts' :: Maybe SortContextsBy
sortBy = forall a. Maybe a
Prelude.Nothing,
      $sel:sortOrder:ListContexts' :: Maybe SortOrder
sortOrder = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceUri:ListContexts' :: Maybe Text
sourceUri = forall a. Maybe a
Prelude.Nothing
    }

-- | A filter that returns only contexts of the specified type.
listContexts_contextType :: Lens.Lens' ListContexts (Prelude.Maybe Prelude.Text)
listContexts_contextType :: Lens' ListContexts (Maybe Text)
listContexts_contextType = 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 created on or after the specified
-- time.
listContexts_createdAfter :: Lens.Lens' ListContexts (Prelude.Maybe Prelude.UTCTime)
listContexts_createdAfter :: Lens' ListContexts (Maybe UTCTime)
listContexts_createdAfter = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | A filter that returns only contexts created on or before the specified
-- time.
listContexts_createdBefore :: Lens.Lens' ListContexts (Prelude.Maybe Prelude.UTCTime)
listContexts_createdBefore :: Lens' ListContexts (Maybe UTCTime)
listContexts_createdBefore = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | 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 :: Lens' ListContexts (Maybe Natural)
listContexts_maxResults = 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)

-- | 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 :: Lens' ListContexts (Maybe Text)
listContexts_nextToken = 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 property used to sort results. The default value is @CreationTime@.
listContexts_sortBy :: Lens.Lens' ListContexts (Prelude.Maybe SortContextsBy)
listContexts_sortBy :: Lens' ListContexts (Maybe SortContextsBy)
listContexts_sortBy = 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)

-- | The sort order. The default value is @Descending@.
listContexts_sortOrder :: Lens.Lens' ListContexts (Prelude.Maybe SortOrder)
listContexts_sortOrder :: Lens' ListContexts (Maybe SortOrder)
listContexts_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 with the specified source URI.
listContexts_sourceUri :: Lens.Lens' ListContexts (Prelude.Maybe Prelude.Text)
listContexts_sourceUri :: Lens' ListContexts (Maybe Text)
listContexts_sourceUri = 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)

instance Core.AWSPager ListContexts where
  page :: ListContexts -> AWSResponse ListContexts -> Maybe ListContexts
page ListContexts
rq AWSResponse ListContexts
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListContexts
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListContextsResponse (Maybe Text)
listContextsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListContexts
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListContextsResponse (Maybe [ContextSummary])
listContextsResponse_contextSummaries
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListContexts
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListContexts (Maybe Text)
listContexts_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListContexts
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListContextsResponse (Maybe Text)
listContextsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListContexts where
  type AWSResponse ListContexts = ListContextsResponse
  request :: (Service -> Service) -> ListContexts -> Request ListContexts
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListContexts
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListContexts)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> 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'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ContextSummaries"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NextToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListContexts where
  hashWithSalt :: Int -> ListContexts -> Int
hashWithSalt Int
_salt ListContexts' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe SortContextsBy
Maybe SortOrder
sourceUri :: Maybe Text
sortOrder :: Maybe SortOrder
sortBy :: Maybe SortContextsBy
nextToken :: Maybe Text
maxResults :: Maybe Natural
createdBefore :: Maybe POSIX
createdAfter :: Maybe POSIX
contextType :: Maybe Text
$sel:sourceUri:ListContexts' :: ListContexts -> Maybe Text
$sel:sortOrder:ListContexts' :: ListContexts -> Maybe SortOrder
$sel:sortBy:ListContexts' :: ListContexts -> Maybe SortContextsBy
$sel:nextToken:ListContexts' :: ListContexts -> Maybe Text
$sel:maxResults:ListContexts' :: ListContexts -> Maybe Natural
$sel:createdBefore:ListContexts' :: ListContexts -> Maybe POSIX
$sel:createdAfter:ListContexts' :: ListContexts -> Maybe POSIX
$sel:contextType:ListContexts' :: ListContexts -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
contextType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
createdAfter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
createdBefore
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SortContextsBy
sortBy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SortOrder
sortOrder
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceUri

instance Prelude.NFData ListContexts where
  rnf :: ListContexts -> ()
rnf ListContexts' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe SortContextsBy
Maybe SortOrder
sourceUri :: Maybe Text
sortOrder :: Maybe SortOrder
sortBy :: Maybe SortContextsBy
nextToken :: Maybe Text
maxResults :: Maybe Natural
createdBefore :: Maybe POSIX
createdAfter :: Maybe POSIX
contextType :: Maybe Text
$sel:sourceUri:ListContexts' :: ListContexts -> Maybe Text
$sel:sortOrder:ListContexts' :: ListContexts -> Maybe SortOrder
$sel:sortBy:ListContexts' :: ListContexts -> Maybe SortContextsBy
$sel:nextToken:ListContexts' :: ListContexts -> Maybe Text
$sel:maxResults:ListContexts' :: ListContexts -> Maybe Natural
$sel:createdBefore:ListContexts' :: ListContexts -> Maybe POSIX
$sel:createdAfter:ListContexts' :: ListContexts -> Maybe POSIX
$sel:contextType:ListContexts' :: ListContexts -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
contextType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
createdAfter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
createdBefore
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SortContextsBy
sortBy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SortOrder
sortOrder
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceUri

instance Data.ToHeaders ListContexts where
  toHeaders :: ListContexts -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"SageMaker.ListContexts" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

instance Data.ToQuery ListContexts where
  toQuery :: ListContexts -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
    { $sel:contextSummaries:ListContextsResponse' :: Maybe [ContextSummary]
contextSummaries =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListContextsResponse' :: Maybe Text
nextToken = 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 :: Lens' ListContextsResponse (Maybe [ContextSummary])
listContextsResponse_contextSummaries = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' ListContextsResponse (Maybe Text)
listContextsResponse_nextToken = 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 :: Lens' ListContextsResponse Int
listContextsResponse_httpStatus = 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 where
  rnf :: ListContextsResponse -> ()
rnf ListContextsResponse' {Int
Maybe [ContextSummary]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
contextSummaries :: Maybe [ContextSummary]
$sel:httpStatus:ListContextsResponse' :: ListContextsResponse -> Int
$sel:nextToken:ListContextsResponse' :: ListContextsResponse -> Maybe Text
$sel:contextSummaries:ListContextsResponse' :: ListContextsResponse -> Maybe [ContextSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ContextSummary]
contextSummaries
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus