{-# 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.CodeGuruProfiler.ListProfileTimes
-- 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 start times of the available aggregated profiles of a
-- profiling group for an aggregation period within the specified time
-- range.
--
-- This operation returns paginated results.
module Amazonka.CodeGuruProfiler.ListProfileTimes
  ( -- * Creating a Request
    ListProfileTimes (..),
    newListProfileTimes,

    -- * Request Lenses
    listProfileTimes_orderBy,
    listProfileTimes_nextToken,
    listProfileTimes_maxResults,
    listProfileTimes_endTime,
    listProfileTimes_period,
    listProfileTimes_profilingGroupName,
    listProfileTimes_startTime,

    -- * Destructuring the Response
    ListProfileTimesResponse (..),
    newListProfileTimesResponse,

    -- * Response Lenses
    listProfileTimesResponse_nextToken,
    listProfileTimesResponse_httpStatus,
    listProfileTimesResponse_profileTimes,
  )
where

import Amazonka.CodeGuruProfiler.Types
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

-- | The structure representing the listProfileTimesRequest.
--
-- /See:/ 'newListProfileTimes' smart constructor.
data ListProfileTimes = ListProfileTimes'
  { -- | The order (ascending or descending by start time of the profile) to use
    -- when listing profiles. Defaults to @TIMESTAMP_DESCENDING@.
    ListProfileTimes -> Maybe OrderBy
orderBy :: Prelude.Maybe OrderBy,
    -- | The @nextToken@ value returned from a previous paginated
    -- @ListProfileTimes@ request where @maxResults@ was used and the results
    -- exceeded the value of that parameter. Pagination continues from the end
    -- of the previous results that returned the @nextToken@ value.
    --
    -- This token should be treated as an opaque identifier that is only used
    -- to retrieve the next items in a list and not for other programmatic
    -- purposes.
    ListProfileTimes -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of profile time results returned by
    -- @ListProfileTimes@ in paginated output. When this parameter is used,
    -- @ListProfileTimes@ only returns @maxResults@ results in a single page
    -- with a @nextToken@ response element. The remaining results of the
    -- initial request can be seen by sending another @ListProfileTimes@
    -- request with the returned @nextToken@ value.
    ListProfileTimes -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The end time of the time range from which to list the profiles.
    ListProfileTimes -> POSIX
endTime :: Core.POSIX,
    -- | The aggregation period. This specifies the period during which an
    -- aggregation profile collects posted agent profiles for a profiling
    -- group. There are 3 valid values.
    --
    -- -   @P1D@ — 1 day
    --
    -- -   @PT1H@ — 1 hour
    --
    -- -   @PT5M@ — 5 minutes
    ListProfileTimes -> AggregationPeriod
period :: AggregationPeriod,
    -- | The name of the profiling group.
    ListProfileTimes -> Text
profilingGroupName :: Prelude.Text,
    -- | The start time of the time range from which to list the profiles.
    ListProfileTimes -> POSIX
startTime :: Core.POSIX
  }
  deriving (ListProfileTimes -> ListProfileTimes -> Bool
(ListProfileTimes -> ListProfileTimes -> Bool)
-> (ListProfileTimes -> ListProfileTimes -> Bool)
-> Eq ListProfileTimes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListProfileTimes -> ListProfileTimes -> Bool
$c/= :: ListProfileTimes -> ListProfileTimes -> Bool
== :: ListProfileTimes -> ListProfileTimes -> Bool
$c== :: ListProfileTimes -> ListProfileTimes -> Bool
Prelude.Eq, ReadPrec [ListProfileTimes]
ReadPrec ListProfileTimes
Int -> ReadS ListProfileTimes
ReadS [ListProfileTimes]
(Int -> ReadS ListProfileTimes)
-> ReadS [ListProfileTimes]
-> ReadPrec ListProfileTimes
-> ReadPrec [ListProfileTimes]
-> Read ListProfileTimes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListProfileTimes]
$creadListPrec :: ReadPrec [ListProfileTimes]
readPrec :: ReadPrec ListProfileTimes
$creadPrec :: ReadPrec ListProfileTimes
readList :: ReadS [ListProfileTimes]
$creadList :: ReadS [ListProfileTimes]
readsPrec :: Int -> ReadS ListProfileTimes
$creadsPrec :: Int -> ReadS ListProfileTimes
Prelude.Read, Int -> ListProfileTimes -> ShowS
[ListProfileTimes] -> ShowS
ListProfileTimes -> String
(Int -> ListProfileTimes -> ShowS)
-> (ListProfileTimes -> String)
-> ([ListProfileTimes] -> ShowS)
-> Show ListProfileTimes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListProfileTimes] -> ShowS
$cshowList :: [ListProfileTimes] -> ShowS
show :: ListProfileTimes -> String
$cshow :: ListProfileTimes -> String
showsPrec :: Int -> ListProfileTimes -> ShowS
$cshowsPrec :: Int -> ListProfileTimes -> ShowS
Prelude.Show, (forall x. ListProfileTimes -> Rep ListProfileTimes x)
-> (forall x. Rep ListProfileTimes x -> ListProfileTimes)
-> Generic ListProfileTimes
forall x. Rep ListProfileTimes x -> ListProfileTimes
forall x. ListProfileTimes -> Rep ListProfileTimes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListProfileTimes x -> ListProfileTimes
$cfrom :: forall x. ListProfileTimes -> Rep ListProfileTimes x
Prelude.Generic)

-- |
-- Create a value of 'ListProfileTimes' 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:
--
-- 'orderBy', 'listProfileTimes_orderBy' - The order (ascending or descending by start time of the profile) to use
-- when listing profiles. Defaults to @TIMESTAMP_DESCENDING@.
--
-- 'nextToken', 'listProfileTimes_nextToken' - The @nextToken@ value returned from a previous paginated
-- @ListProfileTimes@ request where @maxResults@ was used and the results
-- exceeded the value of that parameter. Pagination continues from the end
-- of the previous results that returned the @nextToken@ value.
--
-- This token should be treated as an opaque identifier that is only used
-- to retrieve the next items in a list and not for other programmatic
-- purposes.
--
-- 'maxResults', 'listProfileTimes_maxResults' - The maximum number of profile time results returned by
-- @ListProfileTimes@ in paginated output. When this parameter is used,
-- @ListProfileTimes@ only returns @maxResults@ results in a single page
-- with a @nextToken@ response element. The remaining results of the
-- initial request can be seen by sending another @ListProfileTimes@
-- request with the returned @nextToken@ value.
--
-- 'endTime', 'listProfileTimes_endTime' - The end time of the time range from which to list the profiles.
--
-- 'period', 'listProfileTimes_period' - The aggregation period. This specifies the period during which an
-- aggregation profile collects posted agent profiles for a profiling
-- group. There are 3 valid values.
--
-- -   @P1D@ — 1 day
--
-- -   @PT1H@ — 1 hour
--
-- -   @PT5M@ — 5 minutes
--
-- 'profilingGroupName', 'listProfileTimes_profilingGroupName' - The name of the profiling group.
--
-- 'startTime', 'listProfileTimes_startTime' - The start time of the time range from which to list the profiles.
newListProfileTimes ::
  -- | 'endTime'
  Prelude.UTCTime ->
  -- | 'period'
  AggregationPeriod ->
  -- | 'profilingGroupName'
  Prelude.Text ->
  -- | 'startTime'
  Prelude.UTCTime ->
  ListProfileTimes
newListProfileTimes :: UTCTime -> AggregationPeriod -> Text -> UTCTime -> ListProfileTimes
newListProfileTimes
  UTCTime
pEndTime_
  AggregationPeriod
pPeriod_
  Text
pProfilingGroupName_
  UTCTime
pStartTime_ =
    ListProfileTimes' :: Maybe OrderBy
-> Maybe Text
-> Maybe Natural
-> POSIX
-> AggregationPeriod
-> Text
-> POSIX
-> ListProfileTimes
ListProfileTimes'
      { $sel:orderBy:ListProfileTimes' :: Maybe OrderBy
orderBy = Maybe OrderBy
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:ListProfileTimes' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:maxResults:ListProfileTimes' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:endTime:ListProfileTimes' :: POSIX
endTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTime_,
        $sel:period:ListProfileTimes' :: AggregationPeriod
period = AggregationPeriod
pPeriod_,
        $sel:profilingGroupName:ListProfileTimes' :: Text
profilingGroupName = Text
pProfilingGroupName_,
        $sel:startTime:ListProfileTimes' :: POSIX
startTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_
      }

-- | The order (ascending or descending by start time of the profile) to use
-- when listing profiles. Defaults to @TIMESTAMP_DESCENDING@.
listProfileTimes_orderBy :: Lens.Lens' ListProfileTimes (Prelude.Maybe OrderBy)
listProfileTimes_orderBy :: (Maybe OrderBy -> f (Maybe OrderBy))
-> ListProfileTimes -> f ListProfileTimes
listProfileTimes_orderBy = (ListProfileTimes -> Maybe OrderBy)
-> (ListProfileTimes -> Maybe OrderBy -> ListProfileTimes)
-> Lens
     ListProfileTimes ListProfileTimes (Maybe OrderBy) (Maybe OrderBy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProfileTimes' {Maybe OrderBy
orderBy :: Maybe OrderBy
$sel:orderBy:ListProfileTimes' :: ListProfileTimes -> Maybe OrderBy
orderBy} -> Maybe OrderBy
orderBy) (\s :: ListProfileTimes
s@ListProfileTimes' {} Maybe OrderBy
a -> ListProfileTimes
s {$sel:orderBy:ListProfileTimes' :: Maybe OrderBy
orderBy = Maybe OrderBy
a} :: ListProfileTimes)

-- | The @nextToken@ value returned from a previous paginated
-- @ListProfileTimes@ request where @maxResults@ was used and the results
-- exceeded the value of that parameter. Pagination continues from the end
-- of the previous results that returned the @nextToken@ value.
--
-- This token should be treated as an opaque identifier that is only used
-- to retrieve the next items in a list and not for other programmatic
-- purposes.
listProfileTimes_nextToken :: Lens.Lens' ListProfileTimes (Prelude.Maybe Prelude.Text)
listProfileTimes_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListProfileTimes -> f ListProfileTimes
listProfileTimes_nextToken = (ListProfileTimes -> Maybe Text)
-> (ListProfileTimes -> Maybe Text -> ListProfileTimes)
-> Lens ListProfileTimes ListProfileTimes (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProfileTimes' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListProfileTimes' :: ListProfileTimes -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListProfileTimes
s@ListProfileTimes' {} Maybe Text
a -> ListProfileTimes
s {$sel:nextToken:ListProfileTimes' :: Maybe Text
nextToken = Maybe Text
a} :: ListProfileTimes)

-- | The maximum number of profile time results returned by
-- @ListProfileTimes@ in paginated output. When this parameter is used,
-- @ListProfileTimes@ only returns @maxResults@ results in a single page
-- with a @nextToken@ response element. The remaining results of the
-- initial request can be seen by sending another @ListProfileTimes@
-- request with the returned @nextToken@ value.
listProfileTimes_maxResults :: Lens.Lens' ListProfileTimes (Prelude.Maybe Prelude.Natural)
listProfileTimes_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListProfileTimes -> f ListProfileTimes
listProfileTimes_maxResults = (ListProfileTimes -> Maybe Natural)
-> (ListProfileTimes -> Maybe Natural -> ListProfileTimes)
-> Lens
     ListProfileTimes ListProfileTimes (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProfileTimes' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListProfileTimes' :: ListProfileTimes -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListProfileTimes
s@ListProfileTimes' {} Maybe Natural
a -> ListProfileTimes
s {$sel:maxResults:ListProfileTimes' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListProfileTimes)

-- | The end time of the time range from which to list the profiles.
listProfileTimes_endTime :: Lens.Lens' ListProfileTimes Prelude.UTCTime
listProfileTimes_endTime :: (UTCTime -> f UTCTime) -> ListProfileTimes -> f ListProfileTimes
listProfileTimes_endTime = (ListProfileTimes -> POSIX)
-> (ListProfileTimes -> POSIX -> ListProfileTimes)
-> Lens ListProfileTimes ListProfileTimes POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProfileTimes' {POSIX
endTime :: POSIX
$sel:endTime:ListProfileTimes' :: ListProfileTimes -> POSIX
endTime} -> POSIX
endTime) (\s :: ListProfileTimes
s@ListProfileTimes' {} POSIX
a -> ListProfileTimes
s {$sel:endTime:ListProfileTimes' :: POSIX
endTime = POSIX
a} :: ListProfileTimes) ((POSIX -> f POSIX) -> ListProfileTimes -> f ListProfileTimes)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ListProfileTimes
-> f ListProfileTimes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The aggregation period. This specifies the period during which an
-- aggregation profile collects posted agent profiles for a profiling
-- group. There are 3 valid values.
--
-- -   @P1D@ — 1 day
--
-- -   @PT1H@ — 1 hour
--
-- -   @PT5M@ — 5 minutes
listProfileTimes_period :: Lens.Lens' ListProfileTimes AggregationPeriod
listProfileTimes_period :: (AggregationPeriod -> f AggregationPeriod)
-> ListProfileTimes -> f ListProfileTimes
listProfileTimes_period = (ListProfileTimes -> AggregationPeriod)
-> (ListProfileTimes -> AggregationPeriod -> ListProfileTimes)
-> Lens
     ListProfileTimes
     ListProfileTimes
     AggregationPeriod
     AggregationPeriod
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProfileTimes' {AggregationPeriod
period :: AggregationPeriod
$sel:period:ListProfileTimes' :: ListProfileTimes -> AggregationPeriod
period} -> AggregationPeriod
period) (\s :: ListProfileTimes
s@ListProfileTimes' {} AggregationPeriod
a -> ListProfileTimes
s {$sel:period:ListProfileTimes' :: AggregationPeriod
period = AggregationPeriod
a} :: ListProfileTimes)

-- | The name of the profiling group.
listProfileTimes_profilingGroupName :: Lens.Lens' ListProfileTimes Prelude.Text
listProfileTimes_profilingGroupName :: (Text -> f Text) -> ListProfileTimes -> f ListProfileTimes
listProfileTimes_profilingGroupName = (ListProfileTimes -> Text)
-> (ListProfileTimes -> Text -> ListProfileTimes)
-> Lens ListProfileTimes ListProfileTimes Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProfileTimes' {Text
profilingGroupName :: Text
$sel:profilingGroupName:ListProfileTimes' :: ListProfileTimes -> Text
profilingGroupName} -> Text
profilingGroupName) (\s :: ListProfileTimes
s@ListProfileTimes' {} Text
a -> ListProfileTimes
s {$sel:profilingGroupName:ListProfileTimes' :: Text
profilingGroupName = Text
a} :: ListProfileTimes)

-- | The start time of the time range from which to list the profiles.
listProfileTimes_startTime :: Lens.Lens' ListProfileTimes Prelude.UTCTime
listProfileTimes_startTime :: (UTCTime -> f UTCTime) -> ListProfileTimes -> f ListProfileTimes
listProfileTimes_startTime = (ListProfileTimes -> POSIX)
-> (ListProfileTimes -> POSIX -> ListProfileTimes)
-> Lens ListProfileTimes ListProfileTimes POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProfileTimes' {POSIX
startTime :: POSIX
$sel:startTime:ListProfileTimes' :: ListProfileTimes -> POSIX
startTime} -> POSIX
startTime) (\s :: ListProfileTimes
s@ListProfileTimes' {} POSIX
a -> ListProfileTimes
s {$sel:startTime:ListProfileTimes' :: POSIX
startTime = POSIX
a} :: ListProfileTimes) ((POSIX -> f POSIX) -> ListProfileTimes -> f ListProfileTimes)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ListProfileTimes
-> f ListProfileTimes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.AWSPager ListProfileTimes where
  page :: ListProfileTimes
-> AWSResponse ListProfileTimes -> Maybe ListProfileTimes
page ListProfileTimes
rq AWSResponse ListProfileTimes
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListProfileTimes
ListProfileTimesResponse
rs
            ListProfileTimesResponse
-> Getting (First Text) ListProfileTimesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListProfileTimesResponse
-> Const (First Text) ListProfileTimesResponse
Lens' ListProfileTimesResponse (Maybe Text)
listProfileTimesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListProfileTimesResponse
 -> Const (First Text) ListProfileTimesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListProfileTimesResponse 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 ListProfileTimes
forall a. Maybe a
Prelude.Nothing
    | [ProfileTime] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        (AWSResponse ListProfileTimes
ListProfileTimesResponse
rs ListProfileTimesResponse
-> Getting [ProfileTime] ListProfileTimesResponse [ProfileTime]
-> [ProfileTime]
forall s a. s -> Getting a s a -> a
Lens.^. Getting [ProfileTime] ListProfileTimesResponse [ProfileTime]
Lens' ListProfileTimesResponse [ProfileTime]
listProfileTimesResponse_profileTimes) =
      Maybe ListProfileTimes
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListProfileTimes -> Maybe ListProfileTimes
forall a. a -> Maybe a
Prelude.Just (ListProfileTimes -> Maybe ListProfileTimes)
-> ListProfileTimes -> Maybe ListProfileTimes
forall a b. (a -> b) -> a -> b
Prelude.$
        ListProfileTimes
rq
          ListProfileTimes
-> (ListProfileTimes -> ListProfileTimes) -> ListProfileTimes
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListProfileTimes -> Identity ListProfileTimes
Lens ListProfileTimes ListProfileTimes (Maybe Text) (Maybe Text)
listProfileTimes_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListProfileTimes -> Identity ListProfileTimes)
-> Maybe Text -> ListProfileTimes -> ListProfileTimes
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListProfileTimes
ListProfileTimesResponse
rs
          ListProfileTimesResponse
-> Getting (First Text) ListProfileTimesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListProfileTimesResponse
-> Const (First Text) ListProfileTimesResponse
Lens' ListProfileTimesResponse (Maybe Text)
listProfileTimesResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListProfileTimesResponse
 -> Const (First Text) ListProfileTimesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListProfileTimesResponse 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 ListProfileTimes where
  type
    AWSResponse ListProfileTimes =
      ListProfileTimesResponse
  request :: ListProfileTimes -> Request ListProfileTimes
request = Service -> ListProfileTimes -> Request ListProfileTimes
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListProfileTimes
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListProfileTimes)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListProfileTimes))
-> Logger
-> Service
-> Proxy ListProfileTimes
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListProfileTimes)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> [ProfileTime] -> ListProfileTimesResponse
ListProfileTimesResponse'
            (Maybe Text -> Int -> [ProfileTime] -> ListProfileTimesResponse)
-> Either String (Maybe Text)
-> Either String (Int -> [ProfileTime] -> ListProfileTimesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextToken")
            Either String (Int -> [ProfileTime] -> ListProfileTimesResponse)
-> Either String Int
-> Either String ([ProfileTime] -> ListProfileTimesResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either String ([ProfileTime] -> ListProfileTimesResponse)
-> Either String [ProfileTime]
-> Either String ListProfileTimesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [ProfileTime])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"profileTimes" Either String (Maybe [ProfileTime])
-> [ProfileTime] -> Either String [ProfileTime]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [ProfileTime]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListProfileTimes

instance Prelude.NFData ListProfileTimes

instance Core.ToHeaders ListProfileTimes where
  toHeaders :: ListProfileTimes -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListProfileTimes -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath ListProfileTimes where
  toPath :: ListProfileTimes -> ByteString
toPath ListProfileTimes' {Maybe Natural
Maybe Text
Maybe OrderBy
Text
POSIX
AggregationPeriod
startTime :: POSIX
profilingGroupName :: Text
period :: AggregationPeriod
endTime :: POSIX
maxResults :: Maybe Natural
nextToken :: Maybe Text
orderBy :: Maybe OrderBy
$sel:startTime:ListProfileTimes' :: ListProfileTimes -> POSIX
$sel:profilingGroupName:ListProfileTimes' :: ListProfileTimes -> Text
$sel:period:ListProfileTimes' :: ListProfileTimes -> AggregationPeriod
$sel:endTime:ListProfileTimes' :: ListProfileTimes -> POSIX
$sel:maxResults:ListProfileTimes' :: ListProfileTimes -> Maybe Natural
$sel:nextToken:ListProfileTimes' :: ListProfileTimes -> Maybe Text
$sel:orderBy:ListProfileTimes' :: ListProfileTimes -> Maybe OrderBy
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/profilingGroups/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
profilingGroupName,
        ByteString
"/profileTimes"
      ]

instance Core.ToQuery ListProfileTimes where
  toQuery :: ListProfileTimes -> QueryString
toQuery ListProfileTimes' {Maybe Natural
Maybe Text
Maybe OrderBy
Text
POSIX
AggregationPeriod
startTime :: POSIX
profilingGroupName :: Text
period :: AggregationPeriod
endTime :: POSIX
maxResults :: Maybe Natural
nextToken :: Maybe Text
orderBy :: Maybe OrderBy
$sel:startTime:ListProfileTimes' :: ListProfileTimes -> POSIX
$sel:profilingGroupName:ListProfileTimes' :: ListProfileTimes -> Text
$sel:period:ListProfileTimes' :: ListProfileTimes -> AggregationPeriod
$sel:endTime:ListProfileTimes' :: ListProfileTimes -> POSIX
$sel:maxResults:ListProfileTimes' :: ListProfileTimes -> Maybe Natural
$sel:nextToken:ListProfileTimes' :: ListProfileTimes -> Maybe Text
$sel:orderBy:ListProfileTimes' :: ListProfileTimes -> Maybe OrderBy
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"orderBy" ByteString -> Maybe OrderBy -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe OrderBy
orderBy,
        ByteString
"nextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"maxResults" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults,
        ByteString
"endTime" ByteString -> POSIX -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: POSIX
endTime,
        ByteString
"period" ByteString -> AggregationPeriod -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: AggregationPeriod
period,
        ByteString
"startTime" ByteString -> POSIX -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: POSIX
startTime
      ]

-- | The structure representing the listProfileTimesResponse.
--
-- /See:/ 'newListProfileTimesResponse' smart constructor.
data ListProfileTimesResponse = ListProfileTimesResponse'
  { -- | The @nextToken@ value to include in a future @ListProfileTimes@ request.
    -- When the results of a @ListProfileTimes@ request exceed @maxResults@,
    -- this value can be used to retrieve the next page of results. This value
    -- is @null@ when there are no more results to return.
    ListProfileTimesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListProfileTimesResponse -> Int
httpStatus :: Prelude.Int,
    -- | The list of start times of the available profiles for the aggregation
    -- period in the specified time range.
    ListProfileTimesResponse -> [ProfileTime]
profileTimes :: [ProfileTime]
  }
  deriving (ListProfileTimesResponse -> ListProfileTimesResponse -> Bool
(ListProfileTimesResponse -> ListProfileTimesResponse -> Bool)
-> (ListProfileTimesResponse -> ListProfileTimesResponse -> Bool)
-> Eq ListProfileTimesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListProfileTimesResponse -> ListProfileTimesResponse -> Bool
$c/= :: ListProfileTimesResponse -> ListProfileTimesResponse -> Bool
== :: ListProfileTimesResponse -> ListProfileTimesResponse -> Bool
$c== :: ListProfileTimesResponse -> ListProfileTimesResponse -> Bool
Prelude.Eq, ReadPrec [ListProfileTimesResponse]
ReadPrec ListProfileTimesResponse
Int -> ReadS ListProfileTimesResponse
ReadS [ListProfileTimesResponse]
(Int -> ReadS ListProfileTimesResponse)
-> ReadS [ListProfileTimesResponse]
-> ReadPrec ListProfileTimesResponse
-> ReadPrec [ListProfileTimesResponse]
-> Read ListProfileTimesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListProfileTimesResponse]
$creadListPrec :: ReadPrec [ListProfileTimesResponse]
readPrec :: ReadPrec ListProfileTimesResponse
$creadPrec :: ReadPrec ListProfileTimesResponse
readList :: ReadS [ListProfileTimesResponse]
$creadList :: ReadS [ListProfileTimesResponse]
readsPrec :: Int -> ReadS ListProfileTimesResponse
$creadsPrec :: Int -> ReadS ListProfileTimesResponse
Prelude.Read, Int -> ListProfileTimesResponse -> ShowS
[ListProfileTimesResponse] -> ShowS
ListProfileTimesResponse -> String
(Int -> ListProfileTimesResponse -> ShowS)
-> (ListProfileTimesResponse -> String)
-> ([ListProfileTimesResponse] -> ShowS)
-> Show ListProfileTimesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListProfileTimesResponse] -> ShowS
$cshowList :: [ListProfileTimesResponse] -> ShowS
show :: ListProfileTimesResponse -> String
$cshow :: ListProfileTimesResponse -> String
showsPrec :: Int -> ListProfileTimesResponse -> ShowS
$cshowsPrec :: Int -> ListProfileTimesResponse -> ShowS
Prelude.Show, (forall x.
 ListProfileTimesResponse -> Rep ListProfileTimesResponse x)
-> (forall x.
    Rep ListProfileTimesResponse x -> ListProfileTimesResponse)
-> Generic ListProfileTimesResponse
forall x.
Rep ListProfileTimesResponse x -> ListProfileTimesResponse
forall x.
ListProfileTimesResponse -> Rep ListProfileTimesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListProfileTimesResponse x -> ListProfileTimesResponse
$cfrom :: forall x.
ListProfileTimesResponse -> Rep ListProfileTimesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListProfileTimesResponse' 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', 'listProfileTimesResponse_nextToken' - The @nextToken@ value to include in a future @ListProfileTimes@ request.
-- When the results of a @ListProfileTimes@ request exceed @maxResults@,
-- this value can be used to retrieve the next page of results. This value
-- is @null@ when there are no more results to return.
--
-- 'httpStatus', 'listProfileTimesResponse_httpStatus' - The response's http status code.
--
-- 'profileTimes', 'listProfileTimesResponse_profileTimes' - The list of start times of the available profiles for the aggregation
-- period in the specified time range.
newListProfileTimesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListProfileTimesResponse
newListProfileTimesResponse :: Int -> ListProfileTimesResponse
newListProfileTimesResponse Int
pHttpStatus_ =
  ListProfileTimesResponse' :: Maybe Text -> Int -> [ProfileTime] -> ListProfileTimesResponse
ListProfileTimesResponse'
    { $sel:nextToken:ListProfileTimesResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListProfileTimesResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:profileTimes:ListProfileTimesResponse' :: [ProfileTime]
profileTimes = [ProfileTime]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The @nextToken@ value to include in a future @ListProfileTimes@ request.
-- When the results of a @ListProfileTimes@ request exceed @maxResults@,
-- this value can be used to retrieve the next page of results. This value
-- is @null@ when there are no more results to return.
listProfileTimesResponse_nextToken :: Lens.Lens' ListProfileTimesResponse (Prelude.Maybe Prelude.Text)
listProfileTimesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListProfileTimesResponse -> f ListProfileTimesResponse
listProfileTimesResponse_nextToken = (ListProfileTimesResponse -> Maybe Text)
-> (ListProfileTimesResponse
    -> Maybe Text -> ListProfileTimesResponse)
-> Lens' ListProfileTimesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProfileTimesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListProfileTimesResponse' :: ListProfileTimesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListProfileTimesResponse
s@ListProfileTimesResponse' {} Maybe Text
a -> ListProfileTimesResponse
s {$sel:nextToken:ListProfileTimesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListProfileTimesResponse)

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

-- | The list of start times of the available profiles for the aggregation
-- period in the specified time range.
listProfileTimesResponse_profileTimes :: Lens.Lens' ListProfileTimesResponse [ProfileTime]
listProfileTimesResponse_profileTimes :: ([ProfileTime] -> f [ProfileTime])
-> ListProfileTimesResponse -> f ListProfileTimesResponse
listProfileTimesResponse_profileTimes = (ListProfileTimesResponse -> [ProfileTime])
-> (ListProfileTimesResponse
    -> [ProfileTime] -> ListProfileTimesResponse)
-> Lens' ListProfileTimesResponse [ProfileTime]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProfileTimesResponse' {[ProfileTime]
profileTimes :: [ProfileTime]
$sel:profileTimes:ListProfileTimesResponse' :: ListProfileTimesResponse -> [ProfileTime]
profileTimes} -> [ProfileTime]
profileTimes) (\s :: ListProfileTimesResponse
s@ListProfileTimesResponse' {} [ProfileTime]
a -> ListProfileTimesResponse
s {$sel:profileTimes:ListProfileTimesResponse' :: [ProfileTime]
profileTimes = [ProfileTime]
a} :: ListProfileTimesResponse) (([ProfileTime] -> f [ProfileTime])
 -> ListProfileTimesResponse -> f ListProfileTimesResponse)
-> (([ProfileTime] -> f [ProfileTime])
    -> [ProfileTime] -> f [ProfileTime])
-> ([ProfileTime] -> f [ProfileTime])
-> ListProfileTimesResponse
-> f ListProfileTimesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ProfileTime] -> f [ProfileTime])
-> [ProfileTime] -> f [ProfileTime]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListProfileTimesResponse