{-# 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.KinesisVideoArchivedMedia.ListFragments
-- 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)
--
-- Returns a list of Fragment objects from the specified stream and
-- timestamp range within the archived data.
--
-- Listing fragments is eventually consistent. This means that even if the
-- producer receives an acknowledgment that a fragment is persisted, the
-- result might not be returned immediately from a request to
-- @ListFragments@. However, results are typically available in less than
-- one second.
--
-- You must first call the @GetDataEndpoint@ API to get an endpoint. Then
-- send the @ListFragments@ requests to this endpoint using the
-- <https://docs.aws.amazon.com/cli/latest/reference/ --endpoint-url parameter>.
--
-- If an error is thrown after invoking a Kinesis Video Streams archived
-- media API, in addition to the HTTP status code and the response body, it
-- includes the following pieces of information:
--
-- -   @x-amz-ErrorType@ HTTP header – contains a more specific error type
--     in addition to what the HTTP status code provides.
--
-- -   @x-amz-RequestId@ HTTP header – if you want to report an issue to
--     AWS, the support team can better diagnose the problem if given the
--     Request Id.
--
-- Both the HTTP status code and the ErrorType header can be utilized to
-- make programmatic decisions about whether errors are retry-able and
-- under what conditions, as well as provide information on what actions
-- the client programmer might need to take in order to successfully try
-- again.
--
-- For more information, see the __Errors__ section at the bottom of this
-- topic, as well as
-- <https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/CommonErrors.html Common Errors>.
--
-- This operation returns paginated results.
module Amazonka.KinesisVideoArchivedMedia.ListFragments
  ( -- * Creating a Request
    ListFragments (..),
    newListFragments,

    -- * Request Lenses
    listFragments_fragmentSelector,
    listFragments_streamARN,
    listFragments_nextToken,
    listFragments_streamName,
    listFragments_maxResults,

    -- * Destructuring the Response
    ListFragmentsResponse (..),
    newListFragmentsResponse,

    -- * Response Lenses
    listFragmentsResponse_nextToken,
    listFragmentsResponse_fragments,
    listFragmentsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.KinesisVideoArchivedMedia.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListFragments' smart constructor.
data ListFragments = ListFragments'
  { -- | Describes the timestamp range and timestamp origin for the range of
    -- fragments to return.
    ListFragments -> Maybe FragmentSelector
fragmentSelector :: Prelude.Maybe FragmentSelector,
    -- | The Amazon Resource Name (ARN) of the stream from which to retrieve a
    -- fragment list. Specify either this parameter or the @StreamName@
    -- parameter.
    ListFragments -> Maybe Text
streamARN :: Prelude.Maybe Prelude.Text,
    -- | A token to specify where to start paginating. This is the
    -- ListFragmentsOutput$NextToken from a previously truncated response.
    ListFragments -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the stream from which to retrieve a fragment list. Specify
    -- either this parameter or the @StreamARN@ parameter.
    ListFragments -> Maybe Text
streamName :: Prelude.Maybe Prelude.Text,
    -- | The total number of fragments to return. If the total number of
    -- fragments available is more than the value specified in @max-results@,
    -- then a ListFragmentsOutput$NextToken is provided in the output that you
    -- can use to resume pagination.
    ListFragments -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListFragments -> ListFragments -> Bool
(ListFragments -> ListFragments -> Bool)
-> (ListFragments -> ListFragments -> Bool) -> Eq ListFragments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListFragments -> ListFragments -> Bool
$c/= :: ListFragments -> ListFragments -> Bool
== :: ListFragments -> ListFragments -> Bool
$c== :: ListFragments -> ListFragments -> Bool
Prelude.Eq, ReadPrec [ListFragments]
ReadPrec ListFragments
Int -> ReadS ListFragments
ReadS [ListFragments]
(Int -> ReadS ListFragments)
-> ReadS [ListFragments]
-> ReadPrec ListFragments
-> ReadPrec [ListFragments]
-> Read ListFragments
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListFragments]
$creadListPrec :: ReadPrec [ListFragments]
readPrec :: ReadPrec ListFragments
$creadPrec :: ReadPrec ListFragments
readList :: ReadS [ListFragments]
$creadList :: ReadS [ListFragments]
readsPrec :: Int -> ReadS ListFragments
$creadsPrec :: Int -> ReadS ListFragments
Prelude.Read, Int -> ListFragments -> ShowS
[ListFragments] -> ShowS
ListFragments -> String
(Int -> ListFragments -> ShowS)
-> (ListFragments -> String)
-> ([ListFragments] -> ShowS)
-> Show ListFragments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListFragments] -> ShowS
$cshowList :: [ListFragments] -> ShowS
show :: ListFragments -> String
$cshow :: ListFragments -> String
showsPrec :: Int -> ListFragments -> ShowS
$cshowsPrec :: Int -> ListFragments -> ShowS
Prelude.Show, (forall x. ListFragments -> Rep ListFragments x)
-> (forall x. Rep ListFragments x -> ListFragments)
-> Generic ListFragments
forall x. Rep ListFragments x -> ListFragments
forall x. ListFragments -> Rep ListFragments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListFragments x -> ListFragments
$cfrom :: forall x. ListFragments -> Rep ListFragments x
Prelude.Generic)

-- |
-- Create a value of 'ListFragments' 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:
--
-- 'fragmentSelector', 'listFragments_fragmentSelector' - Describes the timestamp range and timestamp origin for the range of
-- fragments to return.
--
-- 'streamARN', 'listFragments_streamARN' - The Amazon Resource Name (ARN) of the stream from which to retrieve a
-- fragment list. Specify either this parameter or the @StreamName@
-- parameter.
--
-- 'nextToken', 'listFragments_nextToken' - A token to specify where to start paginating. This is the
-- ListFragmentsOutput$NextToken from a previously truncated response.
--
-- 'streamName', 'listFragments_streamName' - The name of the stream from which to retrieve a fragment list. Specify
-- either this parameter or the @StreamARN@ parameter.
--
-- 'maxResults', 'listFragments_maxResults' - The total number of fragments to return. If the total number of
-- fragments available is more than the value specified in @max-results@,
-- then a ListFragmentsOutput$NextToken is provided in the output that you
-- can use to resume pagination.
newListFragments ::
  ListFragments
newListFragments :: ListFragments
newListFragments =
  ListFragments' :: Maybe FragmentSelector
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> ListFragments
ListFragments'
    { $sel:fragmentSelector:ListFragments' :: Maybe FragmentSelector
fragmentSelector = Maybe FragmentSelector
forall a. Maybe a
Prelude.Nothing,
      $sel:streamARN:ListFragments' :: Maybe Text
streamARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListFragments' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:streamName:ListFragments' :: Maybe Text
streamName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListFragments' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Describes the timestamp range and timestamp origin for the range of
-- fragments to return.
listFragments_fragmentSelector :: Lens.Lens' ListFragments (Prelude.Maybe FragmentSelector)
listFragments_fragmentSelector :: (Maybe FragmentSelector -> f (Maybe FragmentSelector))
-> ListFragments -> f ListFragments
listFragments_fragmentSelector = (ListFragments -> Maybe FragmentSelector)
-> (ListFragments -> Maybe FragmentSelector -> ListFragments)
-> Lens
     ListFragments
     ListFragments
     (Maybe FragmentSelector)
     (Maybe FragmentSelector)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFragments' {Maybe FragmentSelector
fragmentSelector :: Maybe FragmentSelector
$sel:fragmentSelector:ListFragments' :: ListFragments -> Maybe FragmentSelector
fragmentSelector} -> Maybe FragmentSelector
fragmentSelector) (\s :: ListFragments
s@ListFragments' {} Maybe FragmentSelector
a -> ListFragments
s {$sel:fragmentSelector:ListFragments' :: Maybe FragmentSelector
fragmentSelector = Maybe FragmentSelector
a} :: ListFragments)

-- | The Amazon Resource Name (ARN) of the stream from which to retrieve a
-- fragment list. Specify either this parameter or the @StreamName@
-- parameter.
listFragments_streamARN :: Lens.Lens' ListFragments (Prelude.Maybe Prelude.Text)
listFragments_streamARN :: (Maybe Text -> f (Maybe Text)) -> ListFragments -> f ListFragments
listFragments_streamARN = (ListFragments -> Maybe Text)
-> (ListFragments -> Maybe Text -> ListFragments)
-> Lens ListFragments ListFragments (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFragments' {Maybe Text
streamARN :: Maybe Text
$sel:streamARN:ListFragments' :: ListFragments -> Maybe Text
streamARN} -> Maybe Text
streamARN) (\s :: ListFragments
s@ListFragments' {} Maybe Text
a -> ListFragments
s {$sel:streamARN:ListFragments' :: Maybe Text
streamARN = Maybe Text
a} :: ListFragments)

-- | A token to specify where to start paginating. This is the
-- ListFragmentsOutput$NextToken from a previously truncated response.
listFragments_nextToken :: Lens.Lens' ListFragments (Prelude.Maybe Prelude.Text)
listFragments_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListFragments -> f ListFragments
listFragments_nextToken = (ListFragments -> Maybe Text)
-> (ListFragments -> Maybe Text -> ListFragments)
-> Lens ListFragments ListFragments (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFragments' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListFragments' :: ListFragments -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListFragments
s@ListFragments' {} Maybe Text
a -> ListFragments
s {$sel:nextToken:ListFragments' :: Maybe Text
nextToken = Maybe Text
a} :: ListFragments)

-- | The name of the stream from which to retrieve a fragment list. Specify
-- either this parameter or the @StreamARN@ parameter.
listFragments_streamName :: Lens.Lens' ListFragments (Prelude.Maybe Prelude.Text)
listFragments_streamName :: (Maybe Text -> f (Maybe Text)) -> ListFragments -> f ListFragments
listFragments_streamName = (ListFragments -> Maybe Text)
-> (ListFragments -> Maybe Text -> ListFragments)
-> Lens ListFragments ListFragments (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFragments' {Maybe Text
streamName :: Maybe Text
$sel:streamName:ListFragments' :: ListFragments -> Maybe Text
streamName} -> Maybe Text
streamName) (\s :: ListFragments
s@ListFragments' {} Maybe Text
a -> ListFragments
s {$sel:streamName:ListFragments' :: Maybe Text
streamName = Maybe Text
a} :: ListFragments)

-- | The total number of fragments to return. If the total number of
-- fragments available is more than the value specified in @max-results@,
-- then a ListFragmentsOutput$NextToken is provided in the output that you
-- can use to resume pagination.
listFragments_maxResults :: Lens.Lens' ListFragments (Prelude.Maybe Prelude.Natural)
listFragments_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListFragments -> f ListFragments
listFragments_maxResults = (ListFragments -> Maybe Natural)
-> (ListFragments -> Maybe Natural -> ListFragments)
-> Lens ListFragments ListFragments (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFragments' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListFragments' :: ListFragments -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListFragments
s@ListFragments' {} Maybe Natural
a -> ListFragments
s {$sel:maxResults:ListFragments' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListFragments)

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

instance Prelude.NFData ListFragments

instance Core.ToHeaders ListFragments where
  toHeaders :: ListFragments -> ResponseHeaders
toHeaders = ResponseHeaders -> ListFragments -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON ListFragments where
  toJSON :: ListFragments -> Value
toJSON ListFragments' {Maybe Natural
Maybe Text
Maybe FragmentSelector
maxResults :: Maybe Natural
streamName :: Maybe Text
nextToken :: Maybe Text
streamARN :: Maybe Text
fragmentSelector :: Maybe FragmentSelector
$sel:maxResults:ListFragments' :: ListFragments -> Maybe Natural
$sel:streamName:ListFragments' :: ListFragments -> Maybe Text
$sel:nextToken:ListFragments' :: ListFragments -> Maybe Text
$sel:streamARN:ListFragments' :: ListFragments -> Maybe Text
$sel:fragmentSelector:ListFragments' :: ListFragments -> Maybe FragmentSelector
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FragmentSelector" Text -> FragmentSelector -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (FragmentSelector -> Pair) -> Maybe FragmentSelector -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FragmentSelector
fragmentSelector,
            (Text
"StreamARN" 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
streamARN,
            (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
"StreamName" 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
streamName,
            (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
          ]
      )

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

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

-- | /See:/ 'newListFragmentsResponse' smart constructor.
data ListFragmentsResponse = ListFragmentsResponse'
  { -- | If the returned list is truncated, the operation returns this token to
    -- use to retrieve the next page of results. This value is @null@ when
    -- there are no more results to return.
    ListFragmentsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of archived Fragment objects from the stream that meet the
    -- selector criteria. Results are in no specific order, even across pages.
    ListFragmentsResponse -> Maybe [Fragment]
fragments :: Prelude.Maybe [Fragment],
    -- | The response's http status code.
    ListFragmentsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListFragmentsResponse -> ListFragmentsResponse -> Bool
(ListFragmentsResponse -> ListFragmentsResponse -> Bool)
-> (ListFragmentsResponse -> ListFragmentsResponse -> Bool)
-> Eq ListFragmentsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListFragmentsResponse -> ListFragmentsResponse -> Bool
$c/= :: ListFragmentsResponse -> ListFragmentsResponse -> Bool
== :: ListFragmentsResponse -> ListFragmentsResponse -> Bool
$c== :: ListFragmentsResponse -> ListFragmentsResponse -> Bool
Prelude.Eq, ReadPrec [ListFragmentsResponse]
ReadPrec ListFragmentsResponse
Int -> ReadS ListFragmentsResponse
ReadS [ListFragmentsResponse]
(Int -> ReadS ListFragmentsResponse)
-> ReadS [ListFragmentsResponse]
-> ReadPrec ListFragmentsResponse
-> ReadPrec [ListFragmentsResponse]
-> Read ListFragmentsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListFragmentsResponse]
$creadListPrec :: ReadPrec [ListFragmentsResponse]
readPrec :: ReadPrec ListFragmentsResponse
$creadPrec :: ReadPrec ListFragmentsResponse
readList :: ReadS [ListFragmentsResponse]
$creadList :: ReadS [ListFragmentsResponse]
readsPrec :: Int -> ReadS ListFragmentsResponse
$creadsPrec :: Int -> ReadS ListFragmentsResponse
Prelude.Read, Int -> ListFragmentsResponse -> ShowS
[ListFragmentsResponse] -> ShowS
ListFragmentsResponse -> String
(Int -> ListFragmentsResponse -> ShowS)
-> (ListFragmentsResponse -> String)
-> ([ListFragmentsResponse] -> ShowS)
-> Show ListFragmentsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListFragmentsResponse] -> ShowS
$cshowList :: [ListFragmentsResponse] -> ShowS
show :: ListFragmentsResponse -> String
$cshow :: ListFragmentsResponse -> String
showsPrec :: Int -> ListFragmentsResponse -> ShowS
$cshowsPrec :: Int -> ListFragmentsResponse -> ShowS
Prelude.Show, (forall x. ListFragmentsResponse -> Rep ListFragmentsResponse x)
-> (forall x. Rep ListFragmentsResponse x -> ListFragmentsResponse)
-> Generic ListFragmentsResponse
forall x. Rep ListFragmentsResponse x -> ListFragmentsResponse
forall x. ListFragmentsResponse -> Rep ListFragmentsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListFragmentsResponse x -> ListFragmentsResponse
$cfrom :: forall x. ListFragmentsResponse -> Rep ListFragmentsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListFragmentsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'nextToken', 'listFragmentsResponse_nextToken' - If the returned list is truncated, the operation returns this token to
-- use to retrieve the next page of results. This value is @null@ when
-- there are no more results to return.
--
-- 'fragments', 'listFragmentsResponse_fragments' - A list of archived Fragment objects from the stream that meet the
-- selector criteria. Results are in no specific order, even across pages.
--
-- 'httpStatus', 'listFragmentsResponse_httpStatus' - The response's http status code.
newListFragmentsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListFragmentsResponse
newListFragmentsResponse :: Int -> ListFragmentsResponse
newListFragmentsResponse Int
pHttpStatus_ =
  ListFragmentsResponse' :: Maybe Text -> Maybe [Fragment] -> Int -> ListFragmentsResponse
ListFragmentsResponse'
    { $sel:nextToken:ListFragmentsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fragments:ListFragmentsResponse' :: Maybe [Fragment]
fragments = Maybe [Fragment]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListFragmentsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If the returned list is truncated, the operation returns this token to
-- use to retrieve the next page of results. This value is @null@ when
-- there are no more results to return.
listFragmentsResponse_nextToken :: Lens.Lens' ListFragmentsResponse (Prelude.Maybe Prelude.Text)
listFragmentsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListFragmentsResponse -> f ListFragmentsResponse
listFragmentsResponse_nextToken = (ListFragmentsResponse -> Maybe Text)
-> (ListFragmentsResponse -> Maybe Text -> ListFragmentsResponse)
-> Lens' ListFragmentsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFragmentsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListFragmentsResponse' :: ListFragmentsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListFragmentsResponse
s@ListFragmentsResponse' {} Maybe Text
a -> ListFragmentsResponse
s {$sel:nextToken:ListFragmentsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListFragmentsResponse)

-- | A list of archived Fragment objects from the stream that meet the
-- selector criteria. Results are in no specific order, even across pages.
listFragmentsResponse_fragments :: Lens.Lens' ListFragmentsResponse (Prelude.Maybe [Fragment])
listFragmentsResponse_fragments :: (Maybe [Fragment] -> f (Maybe [Fragment]))
-> ListFragmentsResponse -> f ListFragmentsResponse
listFragmentsResponse_fragments = (ListFragmentsResponse -> Maybe [Fragment])
-> (ListFragmentsResponse
    -> Maybe [Fragment] -> ListFragmentsResponse)
-> Lens' ListFragmentsResponse (Maybe [Fragment])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFragmentsResponse' {Maybe [Fragment]
fragments :: Maybe [Fragment]
$sel:fragments:ListFragmentsResponse' :: ListFragmentsResponse -> Maybe [Fragment]
fragments} -> Maybe [Fragment]
fragments) (\s :: ListFragmentsResponse
s@ListFragmentsResponse' {} Maybe [Fragment]
a -> ListFragmentsResponse
s {$sel:fragments:ListFragmentsResponse' :: Maybe [Fragment]
fragments = Maybe [Fragment]
a} :: ListFragmentsResponse) ((Maybe [Fragment] -> f (Maybe [Fragment]))
 -> ListFragmentsResponse -> f ListFragmentsResponse)
-> ((Maybe [Fragment] -> f (Maybe [Fragment]))
    -> Maybe [Fragment] -> f (Maybe [Fragment]))
-> (Maybe [Fragment] -> f (Maybe [Fragment]))
-> ListFragmentsResponse
-> f ListFragmentsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Fragment] [Fragment] [Fragment] [Fragment]
-> Iso
     (Maybe [Fragment])
     (Maybe [Fragment])
     (Maybe [Fragment])
     (Maybe [Fragment])
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 [Fragment] [Fragment] [Fragment] [Fragment]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListFragmentsResponse