{-# 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.DevOpsGuru.ListAnomaliesForInsight
-- 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 the anomalies that belong to an insight that you
-- specify using its ID.
--
-- This operation returns paginated results.
module Amazonka.DevOpsGuru.ListAnomaliesForInsight
  ( -- * Creating a Request
    ListAnomaliesForInsight (..),
    newListAnomaliesForInsight,

    -- * Request Lenses
    listAnomaliesForInsight_startTimeRange,
    listAnomaliesForInsight_nextToken,
    listAnomaliesForInsight_maxResults,
    listAnomaliesForInsight_insightId,

    -- * Destructuring the Response
    ListAnomaliesForInsightResponse (..),
    newListAnomaliesForInsightResponse,

    -- * Response Lenses
    listAnomaliesForInsightResponse_proactiveAnomalies,
    listAnomaliesForInsightResponse_nextToken,
    listAnomaliesForInsightResponse_reactiveAnomalies,
    listAnomaliesForInsightResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DevOpsGuru.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:/ 'newListAnomaliesForInsight' smart constructor.
data ListAnomaliesForInsight = ListAnomaliesForInsight'
  { -- | A time range used to specify when the requested anomalies started. All
    -- returned anomalies started during this time range.
    ListAnomaliesForInsight -> Maybe StartTimeRange
startTimeRange :: Prelude.Maybe StartTimeRange,
    -- | The pagination token to use to retrieve the next page of results for
    -- this operation. If this value is null, it retrieves the first page.
    ListAnomaliesForInsight -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return with a single call. To retrieve
    -- the remaining results, make another call with the returned @nextToken@
    -- value.
    ListAnomaliesForInsight -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The ID of the insight. The returned anomalies belong to this insight.
    ListAnomaliesForInsight -> Text
insightId :: Prelude.Text
  }
  deriving (ListAnomaliesForInsight -> ListAnomaliesForInsight -> Bool
(ListAnomaliesForInsight -> ListAnomaliesForInsight -> Bool)
-> (ListAnomaliesForInsight -> ListAnomaliesForInsight -> Bool)
-> Eq ListAnomaliesForInsight
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAnomaliesForInsight -> ListAnomaliesForInsight -> Bool
$c/= :: ListAnomaliesForInsight -> ListAnomaliesForInsight -> Bool
== :: ListAnomaliesForInsight -> ListAnomaliesForInsight -> Bool
$c== :: ListAnomaliesForInsight -> ListAnomaliesForInsight -> Bool
Prelude.Eq, ReadPrec [ListAnomaliesForInsight]
ReadPrec ListAnomaliesForInsight
Int -> ReadS ListAnomaliesForInsight
ReadS [ListAnomaliesForInsight]
(Int -> ReadS ListAnomaliesForInsight)
-> ReadS [ListAnomaliesForInsight]
-> ReadPrec ListAnomaliesForInsight
-> ReadPrec [ListAnomaliesForInsight]
-> Read ListAnomaliesForInsight
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAnomaliesForInsight]
$creadListPrec :: ReadPrec [ListAnomaliesForInsight]
readPrec :: ReadPrec ListAnomaliesForInsight
$creadPrec :: ReadPrec ListAnomaliesForInsight
readList :: ReadS [ListAnomaliesForInsight]
$creadList :: ReadS [ListAnomaliesForInsight]
readsPrec :: Int -> ReadS ListAnomaliesForInsight
$creadsPrec :: Int -> ReadS ListAnomaliesForInsight
Prelude.Read, Int -> ListAnomaliesForInsight -> ShowS
[ListAnomaliesForInsight] -> ShowS
ListAnomaliesForInsight -> String
(Int -> ListAnomaliesForInsight -> ShowS)
-> (ListAnomaliesForInsight -> String)
-> ([ListAnomaliesForInsight] -> ShowS)
-> Show ListAnomaliesForInsight
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAnomaliesForInsight] -> ShowS
$cshowList :: [ListAnomaliesForInsight] -> ShowS
show :: ListAnomaliesForInsight -> String
$cshow :: ListAnomaliesForInsight -> String
showsPrec :: Int -> ListAnomaliesForInsight -> ShowS
$cshowsPrec :: Int -> ListAnomaliesForInsight -> ShowS
Prelude.Show, (forall x.
 ListAnomaliesForInsight -> Rep ListAnomaliesForInsight x)
-> (forall x.
    Rep ListAnomaliesForInsight x -> ListAnomaliesForInsight)
-> Generic ListAnomaliesForInsight
forall x. Rep ListAnomaliesForInsight x -> ListAnomaliesForInsight
forall x. ListAnomaliesForInsight -> Rep ListAnomaliesForInsight x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAnomaliesForInsight x -> ListAnomaliesForInsight
$cfrom :: forall x. ListAnomaliesForInsight -> Rep ListAnomaliesForInsight x
Prelude.Generic)

-- |
-- Create a value of 'ListAnomaliesForInsight' 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:
--
-- 'startTimeRange', 'listAnomaliesForInsight_startTimeRange' - A time range used to specify when the requested anomalies started. All
-- returned anomalies started during this time range.
--
-- 'nextToken', 'listAnomaliesForInsight_nextToken' - The pagination token to use to retrieve the next page of results for
-- this operation. If this value is null, it retrieves the first page.
--
-- 'maxResults', 'listAnomaliesForInsight_maxResults' - The maximum number of results to return with a single call. To retrieve
-- the remaining results, make another call with the returned @nextToken@
-- value.
--
-- 'insightId', 'listAnomaliesForInsight_insightId' - The ID of the insight. The returned anomalies belong to this insight.
newListAnomaliesForInsight ::
  -- | 'insightId'
  Prelude.Text ->
  ListAnomaliesForInsight
newListAnomaliesForInsight :: Text -> ListAnomaliesForInsight
newListAnomaliesForInsight Text
pInsightId_ =
  ListAnomaliesForInsight' :: Maybe StartTimeRange
-> Maybe Text -> Maybe Natural -> Text -> ListAnomaliesForInsight
ListAnomaliesForInsight'
    { $sel:startTimeRange:ListAnomaliesForInsight' :: Maybe StartTimeRange
startTimeRange =
        Maybe StartTimeRange
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAnomaliesForInsight' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListAnomaliesForInsight' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:insightId:ListAnomaliesForInsight' :: Text
insightId = Text
pInsightId_
    }

-- | A time range used to specify when the requested anomalies started. All
-- returned anomalies started during this time range.
listAnomaliesForInsight_startTimeRange :: Lens.Lens' ListAnomaliesForInsight (Prelude.Maybe StartTimeRange)
listAnomaliesForInsight_startTimeRange :: (Maybe StartTimeRange -> f (Maybe StartTimeRange))
-> ListAnomaliesForInsight -> f ListAnomaliesForInsight
listAnomaliesForInsight_startTimeRange = (ListAnomaliesForInsight -> Maybe StartTimeRange)
-> (ListAnomaliesForInsight
    -> Maybe StartTimeRange -> ListAnomaliesForInsight)
-> Lens
     ListAnomaliesForInsight
     ListAnomaliesForInsight
     (Maybe StartTimeRange)
     (Maybe StartTimeRange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAnomaliesForInsight' {Maybe StartTimeRange
startTimeRange :: Maybe StartTimeRange
$sel:startTimeRange:ListAnomaliesForInsight' :: ListAnomaliesForInsight -> Maybe StartTimeRange
startTimeRange} -> Maybe StartTimeRange
startTimeRange) (\s :: ListAnomaliesForInsight
s@ListAnomaliesForInsight' {} Maybe StartTimeRange
a -> ListAnomaliesForInsight
s {$sel:startTimeRange:ListAnomaliesForInsight' :: Maybe StartTimeRange
startTimeRange = Maybe StartTimeRange
a} :: ListAnomaliesForInsight)

-- | The pagination token to use to retrieve the next page of results for
-- this operation. If this value is null, it retrieves the first page.
listAnomaliesForInsight_nextToken :: Lens.Lens' ListAnomaliesForInsight (Prelude.Maybe Prelude.Text)
listAnomaliesForInsight_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAnomaliesForInsight -> f ListAnomaliesForInsight
listAnomaliesForInsight_nextToken = (ListAnomaliesForInsight -> Maybe Text)
-> (ListAnomaliesForInsight
    -> Maybe Text -> ListAnomaliesForInsight)
-> Lens
     ListAnomaliesForInsight
     ListAnomaliesForInsight
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAnomaliesForInsight' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAnomaliesForInsight' :: ListAnomaliesForInsight -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAnomaliesForInsight
s@ListAnomaliesForInsight' {} Maybe Text
a -> ListAnomaliesForInsight
s {$sel:nextToken:ListAnomaliesForInsight' :: Maybe Text
nextToken = Maybe Text
a} :: ListAnomaliesForInsight)

-- | The maximum number of results to return with a single call. To retrieve
-- the remaining results, make another call with the returned @nextToken@
-- value.
listAnomaliesForInsight_maxResults :: Lens.Lens' ListAnomaliesForInsight (Prelude.Maybe Prelude.Natural)
listAnomaliesForInsight_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListAnomaliesForInsight -> f ListAnomaliesForInsight
listAnomaliesForInsight_maxResults = (ListAnomaliesForInsight -> Maybe Natural)
-> (ListAnomaliesForInsight
    -> Maybe Natural -> ListAnomaliesForInsight)
-> Lens
     ListAnomaliesForInsight
     ListAnomaliesForInsight
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAnomaliesForInsight' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAnomaliesForInsight' :: ListAnomaliesForInsight -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAnomaliesForInsight
s@ListAnomaliesForInsight' {} Maybe Natural
a -> ListAnomaliesForInsight
s {$sel:maxResults:ListAnomaliesForInsight' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAnomaliesForInsight)

-- | The ID of the insight. The returned anomalies belong to this insight.
listAnomaliesForInsight_insightId :: Lens.Lens' ListAnomaliesForInsight Prelude.Text
listAnomaliesForInsight_insightId :: (Text -> f Text)
-> ListAnomaliesForInsight -> f ListAnomaliesForInsight
listAnomaliesForInsight_insightId = (ListAnomaliesForInsight -> Text)
-> (ListAnomaliesForInsight -> Text -> ListAnomaliesForInsight)
-> Lens ListAnomaliesForInsight ListAnomaliesForInsight Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAnomaliesForInsight' {Text
insightId :: Text
$sel:insightId:ListAnomaliesForInsight' :: ListAnomaliesForInsight -> Text
insightId} -> Text
insightId) (\s :: ListAnomaliesForInsight
s@ListAnomaliesForInsight' {} Text
a -> ListAnomaliesForInsight
s {$sel:insightId:ListAnomaliesForInsight' :: Text
insightId = Text
a} :: ListAnomaliesForInsight)

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

instance Prelude.NFData ListAnomaliesForInsight

instance Core.ToHeaders ListAnomaliesForInsight where
  toHeaders :: ListAnomaliesForInsight -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListAnomaliesForInsight -> 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.ToJSON ListAnomaliesForInsight where
  toJSON :: ListAnomaliesForInsight -> Value
toJSON ListAnomaliesForInsight' {Maybe Natural
Maybe Text
Maybe StartTimeRange
Text
insightId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
startTimeRange :: Maybe StartTimeRange
$sel:insightId:ListAnomaliesForInsight' :: ListAnomaliesForInsight -> Text
$sel:maxResults:ListAnomaliesForInsight' :: ListAnomaliesForInsight -> Maybe Natural
$sel:nextToken:ListAnomaliesForInsight' :: ListAnomaliesForInsight -> Maybe Text
$sel:startTimeRange:ListAnomaliesForInsight' :: ListAnomaliesForInsight -> Maybe StartTimeRange
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"StartTimeRange" Text -> StartTimeRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (StartTimeRange -> Pair) -> Maybe StartTimeRange -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StartTimeRange
startTimeRange,
            (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
"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 ListAnomaliesForInsight where
  toPath :: ListAnomaliesForInsight -> ByteString
toPath ListAnomaliesForInsight' {Maybe Natural
Maybe Text
Maybe StartTimeRange
Text
insightId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
startTimeRange :: Maybe StartTimeRange
$sel:insightId:ListAnomaliesForInsight' :: ListAnomaliesForInsight -> Text
$sel:maxResults:ListAnomaliesForInsight' :: ListAnomaliesForInsight -> Maybe Natural
$sel:nextToken:ListAnomaliesForInsight' :: ListAnomaliesForInsight -> Maybe Text
$sel:startTimeRange:ListAnomaliesForInsight' :: ListAnomaliesForInsight -> Maybe StartTimeRange
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/anomalies/insight/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
insightId]

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

-- | /See:/ 'newListAnomaliesForInsightResponse' smart constructor.
data ListAnomaliesForInsightResponse = ListAnomaliesForInsightResponse'
  { -- | An array of @ProactiveAnomalySummary@ objects that represent the
    -- requested anomalies
    ListAnomaliesForInsightResponse -> Maybe [ProactiveAnomalySummary]
proactiveAnomalies :: Prelude.Maybe [ProactiveAnomalySummary],
    -- | The pagination token to use to retrieve the next page of results for
    -- this operation. If there are no more pages, this value is null.
    ListAnomaliesForInsightResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of @ReactiveAnomalySummary@ objects that represent the
    -- requested anomalies
    ListAnomaliesForInsightResponse -> Maybe [ReactiveAnomalySummary]
reactiveAnomalies :: Prelude.Maybe [ReactiveAnomalySummary],
    -- | The response's http status code.
    ListAnomaliesForInsightResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAnomaliesForInsightResponse
-> ListAnomaliesForInsightResponse -> Bool
(ListAnomaliesForInsightResponse
 -> ListAnomaliesForInsightResponse -> Bool)
-> (ListAnomaliesForInsightResponse
    -> ListAnomaliesForInsightResponse -> Bool)
-> Eq ListAnomaliesForInsightResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAnomaliesForInsightResponse
-> ListAnomaliesForInsightResponse -> Bool
$c/= :: ListAnomaliesForInsightResponse
-> ListAnomaliesForInsightResponse -> Bool
== :: ListAnomaliesForInsightResponse
-> ListAnomaliesForInsightResponse -> Bool
$c== :: ListAnomaliesForInsightResponse
-> ListAnomaliesForInsightResponse -> Bool
Prelude.Eq, ReadPrec [ListAnomaliesForInsightResponse]
ReadPrec ListAnomaliesForInsightResponse
Int -> ReadS ListAnomaliesForInsightResponse
ReadS [ListAnomaliesForInsightResponse]
(Int -> ReadS ListAnomaliesForInsightResponse)
-> ReadS [ListAnomaliesForInsightResponse]
-> ReadPrec ListAnomaliesForInsightResponse
-> ReadPrec [ListAnomaliesForInsightResponse]
-> Read ListAnomaliesForInsightResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAnomaliesForInsightResponse]
$creadListPrec :: ReadPrec [ListAnomaliesForInsightResponse]
readPrec :: ReadPrec ListAnomaliesForInsightResponse
$creadPrec :: ReadPrec ListAnomaliesForInsightResponse
readList :: ReadS [ListAnomaliesForInsightResponse]
$creadList :: ReadS [ListAnomaliesForInsightResponse]
readsPrec :: Int -> ReadS ListAnomaliesForInsightResponse
$creadsPrec :: Int -> ReadS ListAnomaliesForInsightResponse
Prelude.Read, Int -> ListAnomaliesForInsightResponse -> ShowS
[ListAnomaliesForInsightResponse] -> ShowS
ListAnomaliesForInsightResponse -> String
(Int -> ListAnomaliesForInsightResponse -> ShowS)
-> (ListAnomaliesForInsightResponse -> String)
-> ([ListAnomaliesForInsightResponse] -> ShowS)
-> Show ListAnomaliesForInsightResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAnomaliesForInsightResponse] -> ShowS
$cshowList :: [ListAnomaliesForInsightResponse] -> ShowS
show :: ListAnomaliesForInsightResponse -> String
$cshow :: ListAnomaliesForInsightResponse -> String
showsPrec :: Int -> ListAnomaliesForInsightResponse -> ShowS
$cshowsPrec :: Int -> ListAnomaliesForInsightResponse -> ShowS
Prelude.Show, (forall x.
 ListAnomaliesForInsightResponse
 -> Rep ListAnomaliesForInsightResponse x)
-> (forall x.
    Rep ListAnomaliesForInsightResponse x
    -> ListAnomaliesForInsightResponse)
-> Generic ListAnomaliesForInsightResponse
forall x.
Rep ListAnomaliesForInsightResponse x
-> ListAnomaliesForInsightResponse
forall x.
ListAnomaliesForInsightResponse
-> Rep ListAnomaliesForInsightResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAnomaliesForInsightResponse x
-> ListAnomaliesForInsightResponse
$cfrom :: forall x.
ListAnomaliesForInsightResponse
-> Rep ListAnomaliesForInsightResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAnomaliesForInsightResponse' 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:
--
-- 'proactiveAnomalies', 'listAnomaliesForInsightResponse_proactiveAnomalies' - An array of @ProactiveAnomalySummary@ objects that represent the
-- requested anomalies
--
-- 'nextToken', 'listAnomaliesForInsightResponse_nextToken' - The pagination token to use to retrieve the next page of results for
-- this operation. If there are no more pages, this value is null.
--
-- 'reactiveAnomalies', 'listAnomaliesForInsightResponse_reactiveAnomalies' - An array of @ReactiveAnomalySummary@ objects that represent the
-- requested anomalies
--
-- 'httpStatus', 'listAnomaliesForInsightResponse_httpStatus' - The response's http status code.
newListAnomaliesForInsightResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAnomaliesForInsightResponse
newListAnomaliesForInsightResponse :: Int -> ListAnomaliesForInsightResponse
newListAnomaliesForInsightResponse Int
pHttpStatus_ =
  ListAnomaliesForInsightResponse' :: Maybe [ProactiveAnomalySummary]
-> Maybe Text
-> Maybe [ReactiveAnomalySummary]
-> Int
-> ListAnomaliesForInsightResponse
ListAnomaliesForInsightResponse'
    { $sel:proactiveAnomalies:ListAnomaliesForInsightResponse' :: Maybe [ProactiveAnomalySummary]
proactiveAnomalies =
        Maybe [ProactiveAnomalySummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAnomaliesForInsightResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:reactiveAnomalies:ListAnomaliesForInsightResponse' :: Maybe [ReactiveAnomalySummary]
reactiveAnomalies = Maybe [ReactiveAnomalySummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAnomaliesForInsightResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of @ProactiveAnomalySummary@ objects that represent the
-- requested anomalies
listAnomaliesForInsightResponse_proactiveAnomalies :: Lens.Lens' ListAnomaliesForInsightResponse (Prelude.Maybe [ProactiveAnomalySummary])
listAnomaliesForInsightResponse_proactiveAnomalies :: (Maybe [ProactiveAnomalySummary]
 -> f (Maybe [ProactiveAnomalySummary]))
-> ListAnomaliesForInsightResponse
-> f ListAnomaliesForInsightResponse
listAnomaliesForInsightResponse_proactiveAnomalies = (ListAnomaliesForInsightResponse
 -> Maybe [ProactiveAnomalySummary])
-> (ListAnomaliesForInsightResponse
    -> Maybe [ProactiveAnomalySummary]
    -> ListAnomaliesForInsightResponse)
-> Lens'
     ListAnomaliesForInsightResponse (Maybe [ProactiveAnomalySummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAnomaliesForInsightResponse' {Maybe [ProactiveAnomalySummary]
proactiveAnomalies :: Maybe [ProactiveAnomalySummary]
$sel:proactiveAnomalies:ListAnomaliesForInsightResponse' :: ListAnomaliesForInsightResponse -> Maybe [ProactiveAnomalySummary]
proactiveAnomalies} -> Maybe [ProactiveAnomalySummary]
proactiveAnomalies) (\s :: ListAnomaliesForInsightResponse
s@ListAnomaliesForInsightResponse' {} Maybe [ProactiveAnomalySummary]
a -> ListAnomaliesForInsightResponse
s {$sel:proactiveAnomalies:ListAnomaliesForInsightResponse' :: Maybe [ProactiveAnomalySummary]
proactiveAnomalies = Maybe [ProactiveAnomalySummary]
a} :: ListAnomaliesForInsightResponse) ((Maybe [ProactiveAnomalySummary]
  -> f (Maybe [ProactiveAnomalySummary]))
 -> ListAnomaliesForInsightResponse
 -> f ListAnomaliesForInsightResponse)
-> ((Maybe [ProactiveAnomalySummary]
     -> f (Maybe [ProactiveAnomalySummary]))
    -> Maybe [ProactiveAnomalySummary]
    -> f (Maybe [ProactiveAnomalySummary]))
-> (Maybe [ProactiveAnomalySummary]
    -> f (Maybe [ProactiveAnomalySummary]))
-> ListAnomaliesForInsightResponse
-> f ListAnomaliesForInsightResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ProactiveAnomalySummary]
  [ProactiveAnomalySummary]
  [ProactiveAnomalySummary]
  [ProactiveAnomalySummary]
-> Iso
     (Maybe [ProactiveAnomalySummary])
     (Maybe [ProactiveAnomalySummary])
     (Maybe [ProactiveAnomalySummary])
     (Maybe [ProactiveAnomalySummary])
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
  [ProactiveAnomalySummary]
  [ProactiveAnomalySummary]
  [ProactiveAnomalySummary]
  [ProactiveAnomalySummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The pagination token to use to retrieve the next page of results for
-- this operation. If there are no more pages, this value is null.
listAnomaliesForInsightResponse_nextToken :: Lens.Lens' ListAnomaliesForInsightResponse (Prelude.Maybe Prelude.Text)
listAnomaliesForInsightResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAnomaliesForInsightResponse
-> f ListAnomaliesForInsightResponse
listAnomaliesForInsightResponse_nextToken = (ListAnomaliesForInsightResponse -> Maybe Text)
-> (ListAnomaliesForInsightResponse
    -> Maybe Text -> ListAnomaliesForInsightResponse)
-> Lens' ListAnomaliesForInsightResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAnomaliesForInsightResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAnomaliesForInsightResponse' :: ListAnomaliesForInsightResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAnomaliesForInsightResponse
s@ListAnomaliesForInsightResponse' {} Maybe Text
a -> ListAnomaliesForInsightResponse
s {$sel:nextToken:ListAnomaliesForInsightResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAnomaliesForInsightResponse)

-- | An array of @ReactiveAnomalySummary@ objects that represent the
-- requested anomalies
listAnomaliesForInsightResponse_reactiveAnomalies :: Lens.Lens' ListAnomaliesForInsightResponse (Prelude.Maybe [ReactiveAnomalySummary])
listAnomaliesForInsightResponse_reactiveAnomalies :: (Maybe [ReactiveAnomalySummary]
 -> f (Maybe [ReactiveAnomalySummary]))
-> ListAnomaliesForInsightResponse
-> f ListAnomaliesForInsightResponse
listAnomaliesForInsightResponse_reactiveAnomalies = (ListAnomaliesForInsightResponse -> Maybe [ReactiveAnomalySummary])
-> (ListAnomaliesForInsightResponse
    -> Maybe [ReactiveAnomalySummary]
    -> ListAnomaliesForInsightResponse)
-> Lens'
     ListAnomaliesForInsightResponse (Maybe [ReactiveAnomalySummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAnomaliesForInsightResponse' {Maybe [ReactiveAnomalySummary]
reactiveAnomalies :: Maybe [ReactiveAnomalySummary]
$sel:reactiveAnomalies:ListAnomaliesForInsightResponse' :: ListAnomaliesForInsightResponse -> Maybe [ReactiveAnomalySummary]
reactiveAnomalies} -> Maybe [ReactiveAnomalySummary]
reactiveAnomalies) (\s :: ListAnomaliesForInsightResponse
s@ListAnomaliesForInsightResponse' {} Maybe [ReactiveAnomalySummary]
a -> ListAnomaliesForInsightResponse
s {$sel:reactiveAnomalies:ListAnomaliesForInsightResponse' :: Maybe [ReactiveAnomalySummary]
reactiveAnomalies = Maybe [ReactiveAnomalySummary]
a} :: ListAnomaliesForInsightResponse) ((Maybe [ReactiveAnomalySummary]
  -> f (Maybe [ReactiveAnomalySummary]))
 -> ListAnomaliesForInsightResponse
 -> f ListAnomaliesForInsightResponse)
-> ((Maybe [ReactiveAnomalySummary]
     -> f (Maybe [ReactiveAnomalySummary]))
    -> Maybe [ReactiveAnomalySummary]
    -> f (Maybe [ReactiveAnomalySummary]))
-> (Maybe [ReactiveAnomalySummary]
    -> f (Maybe [ReactiveAnomalySummary]))
-> ListAnomaliesForInsightResponse
-> f ListAnomaliesForInsightResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ReactiveAnomalySummary]
  [ReactiveAnomalySummary]
  [ReactiveAnomalySummary]
  [ReactiveAnomalySummary]
-> Iso
     (Maybe [ReactiveAnomalySummary])
     (Maybe [ReactiveAnomalySummary])
     (Maybe [ReactiveAnomalySummary])
     (Maybe [ReactiveAnomalySummary])
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
  [ReactiveAnomalySummary]
  [ReactiveAnomalySummary]
  [ReactiveAnomalySummary]
  [ReactiveAnomalySummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    ListAnomaliesForInsightResponse