{-# 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.SearchInsights
-- 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 insights in your AWS account. You can specify which
-- insights are returned by their start time, one or more statuses
-- (@ONGOING@, @CLOSED@, and @CLOSED@), one or more severities (@LOW@,
-- @MEDIUM@, and @HIGH@), and type (@REACTIVE@ or @PROACTIVE@).
--
-- Use the @Filters@ parameter to specify status and severity search
-- parameters. Use the @Type@ parameter to specify @REACTIVE@ or
-- @PROACTIVE@ in your search.
--
-- This operation returns paginated results.
module Amazonka.DevOpsGuru.SearchInsights
  ( -- * Creating a Request
    SearchInsights (..),
    newSearchInsights,

    -- * Request Lenses
    searchInsights_filters,
    searchInsights_nextToken,
    searchInsights_maxResults,
    searchInsights_startTimeRange,
    searchInsights_type,

    -- * Destructuring the Response
    SearchInsightsResponse (..),
    newSearchInsightsResponse,

    -- * Response Lenses
    searchInsightsResponse_reactiveInsights,
    searchInsightsResponse_nextToken,
    searchInsightsResponse_proactiveInsights,
    searchInsightsResponse_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:/ 'newSearchInsights' smart constructor.
data SearchInsights = SearchInsights'
  { -- | A @SearchInsightsFilters@ object that is used to set the severity and
    -- status filters on your insight search.
    SearchInsights -> Maybe SearchInsightsFilters
filters :: Prelude.Maybe SearchInsightsFilters,
    -- | 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.
    SearchInsights -> 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.
    SearchInsights -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The start of the time range passed in. Returned insights occurred after
    -- this time.
    SearchInsights -> StartTimeRange
startTimeRange :: StartTimeRange,
    -- | The type of insights you are searching for (@REACTIVE@ or @PROACTIVE@).
    SearchInsights -> InsightType
type' :: InsightType
  }
  deriving (SearchInsights -> SearchInsights -> Bool
(SearchInsights -> SearchInsights -> Bool)
-> (SearchInsights -> SearchInsights -> Bool) -> Eq SearchInsights
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchInsights -> SearchInsights -> Bool
$c/= :: SearchInsights -> SearchInsights -> Bool
== :: SearchInsights -> SearchInsights -> Bool
$c== :: SearchInsights -> SearchInsights -> Bool
Prelude.Eq, ReadPrec [SearchInsights]
ReadPrec SearchInsights
Int -> ReadS SearchInsights
ReadS [SearchInsights]
(Int -> ReadS SearchInsights)
-> ReadS [SearchInsights]
-> ReadPrec SearchInsights
-> ReadPrec [SearchInsights]
-> Read SearchInsights
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchInsights]
$creadListPrec :: ReadPrec [SearchInsights]
readPrec :: ReadPrec SearchInsights
$creadPrec :: ReadPrec SearchInsights
readList :: ReadS [SearchInsights]
$creadList :: ReadS [SearchInsights]
readsPrec :: Int -> ReadS SearchInsights
$creadsPrec :: Int -> ReadS SearchInsights
Prelude.Read, Int -> SearchInsights -> ShowS
[SearchInsights] -> ShowS
SearchInsights -> String
(Int -> SearchInsights -> ShowS)
-> (SearchInsights -> String)
-> ([SearchInsights] -> ShowS)
-> Show SearchInsights
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchInsights] -> ShowS
$cshowList :: [SearchInsights] -> ShowS
show :: SearchInsights -> String
$cshow :: SearchInsights -> String
showsPrec :: Int -> SearchInsights -> ShowS
$cshowsPrec :: Int -> SearchInsights -> ShowS
Prelude.Show, (forall x. SearchInsights -> Rep SearchInsights x)
-> (forall x. Rep SearchInsights x -> SearchInsights)
-> Generic SearchInsights
forall x. Rep SearchInsights x -> SearchInsights
forall x. SearchInsights -> Rep SearchInsights x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchInsights x -> SearchInsights
$cfrom :: forall x. SearchInsights -> Rep SearchInsights x
Prelude.Generic)

-- |
-- Create a value of 'SearchInsights' 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:
--
-- 'filters', 'searchInsights_filters' - A @SearchInsightsFilters@ object that is used to set the severity and
-- status filters on your insight search.
--
-- 'nextToken', 'searchInsights_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', 'searchInsights_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.
--
-- 'startTimeRange', 'searchInsights_startTimeRange' - The start of the time range passed in. Returned insights occurred after
-- this time.
--
-- 'type'', 'searchInsights_type' - The type of insights you are searching for (@REACTIVE@ or @PROACTIVE@).
newSearchInsights ::
  -- | 'startTimeRange'
  StartTimeRange ->
  -- | 'type''
  InsightType ->
  SearchInsights
newSearchInsights :: StartTimeRange -> InsightType -> SearchInsights
newSearchInsights StartTimeRange
pStartTimeRange_ InsightType
pType_ =
  SearchInsights' :: Maybe SearchInsightsFilters
-> Maybe Text
-> Maybe Natural
-> StartTimeRange
-> InsightType
-> SearchInsights
SearchInsights'
    { $sel:filters:SearchInsights' :: Maybe SearchInsightsFilters
filters = Maybe SearchInsightsFilters
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:SearchInsights' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:SearchInsights' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:startTimeRange:SearchInsights' :: StartTimeRange
startTimeRange = StartTimeRange
pStartTimeRange_,
      $sel:type':SearchInsights' :: InsightType
type' = InsightType
pType_
    }

-- | A @SearchInsightsFilters@ object that is used to set the severity and
-- status filters on your insight search.
searchInsights_filters :: Lens.Lens' SearchInsights (Prelude.Maybe SearchInsightsFilters)
searchInsights_filters :: (Maybe SearchInsightsFilters -> f (Maybe SearchInsightsFilters))
-> SearchInsights -> f SearchInsights
searchInsights_filters = (SearchInsights -> Maybe SearchInsightsFilters)
-> (SearchInsights
    -> Maybe SearchInsightsFilters -> SearchInsights)
-> Lens
     SearchInsights
     SearchInsights
     (Maybe SearchInsightsFilters)
     (Maybe SearchInsightsFilters)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchInsights' {Maybe SearchInsightsFilters
filters :: Maybe SearchInsightsFilters
$sel:filters:SearchInsights' :: SearchInsights -> Maybe SearchInsightsFilters
filters} -> Maybe SearchInsightsFilters
filters) (\s :: SearchInsights
s@SearchInsights' {} Maybe SearchInsightsFilters
a -> SearchInsights
s {$sel:filters:SearchInsights' :: Maybe SearchInsightsFilters
filters = Maybe SearchInsightsFilters
a} :: SearchInsights)

-- | 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.
searchInsights_nextToken :: Lens.Lens' SearchInsights (Prelude.Maybe Prelude.Text)
searchInsights_nextToken :: (Maybe Text -> f (Maybe Text))
-> SearchInsights -> f SearchInsights
searchInsights_nextToken = (SearchInsights -> Maybe Text)
-> (SearchInsights -> Maybe Text -> SearchInsights)
-> Lens SearchInsights SearchInsights (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchInsights' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchInsights' :: SearchInsights -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchInsights
s@SearchInsights' {} Maybe Text
a -> SearchInsights
s {$sel:nextToken:SearchInsights' :: Maybe Text
nextToken = Maybe Text
a} :: SearchInsights)

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

-- | The start of the time range passed in. Returned insights occurred after
-- this time.
searchInsights_startTimeRange :: Lens.Lens' SearchInsights StartTimeRange
searchInsights_startTimeRange :: (StartTimeRange -> f StartTimeRange)
-> SearchInsights -> f SearchInsights
searchInsights_startTimeRange = (SearchInsights -> StartTimeRange)
-> (SearchInsights -> StartTimeRange -> SearchInsights)
-> Lens SearchInsights SearchInsights StartTimeRange StartTimeRange
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchInsights' {StartTimeRange
startTimeRange :: StartTimeRange
$sel:startTimeRange:SearchInsights' :: SearchInsights -> StartTimeRange
startTimeRange} -> StartTimeRange
startTimeRange) (\s :: SearchInsights
s@SearchInsights' {} StartTimeRange
a -> SearchInsights
s {$sel:startTimeRange:SearchInsights' :: StartTimeRange
startTimeRange = StartTimeRange
a} :: SearchInsights)

-- | The type of insights you are searching for (@REACTIVE@ or @PROACTIVE@).
searchInsights_type :: Lens.Lens' SearchInsights InsightType
searchInsights_type :: (InsightType -> f InsightType)
-> SearchInsights -> f SearchInsights
searchInsights_type = (SearchInsights -> InsightType)
-> (SearchInsights -> InsightType -> SearchInsights)
-> Lens SearchInsights SearchInsights InsightType InsightType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchInsights' {InsightType
type' :: InsightType
$sel:type':SearchInsights' :: SearchInsights -> InsightType
type'} -> InsightType
type') (\s :: SearchInsights
s@SearchInsights' {} InsightType
a -> SearchInsights
s {$sel:type':SearchInsights' :: InsightType
type' = InsightType
a} :: SearchInsights)

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

instance Prelude.NFData SearchInsights

instance Core.ToHeaders SearchInsights where
  toHeaders :: SearchInsights -> ResponseHeaders
toHeaders =
    ResponseHeaders -> SearchInsights -> 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 SearchInsights where
  toJSON :: SearchInsights -> Value
toJSON SearchInsights' {Maybe Natural
Maybe Text
Maybe SearchInsightsFilters
InsightType
StartTimeRange
type' :: InsightType
startTimeRange :: StartTimeRange
maxResults :: Maybe Natural
nextToken :: Maybe Text
filters :: Maybe SearchInsightsFilters
$sel:type':SearchInsights' :: SearchInsights -> InsightType
$sel:startTimeRange:SearchInsights' :: SearchInsights -> StartTimeRange
$sel:maxResults:SearchInsights' :: SearchInsights -> Maybe Natural
$sel:nextToken:SearchInsights' :: SearchInsights -> Maybe Text
$sel:filters:SearchInsights' :: SearchInsights -> Maybe SearchInsightsFilters
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Filters" Text -> SearchInsightsFilters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SearchInsightsFilters -> Pair)
-> Maybe SearchInsightsFilters -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SearchInsightsFilters
filters,
            (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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"StartTimeRange" Text -> StartTimeRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= StartTimeRange
startTimeRange),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> InsightType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= InsightType
type')
          ]
      )

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

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

-- | /See:/ 'newSearchInsightsResponse' smart constructor.
data SearchInsightsResponse = SearchInsightsResponse'
  { -- | The returned reactive insights.
    SearchInsightsResponse -> Maybe [ReactiveInsightSummary]
reactiveInsights :: Prelude.Maybe [ReactiveInsightSummary],
    -- | 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.
    SearchInsightsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The returned proactive insights.
    SearchInsightsResponse -> Maybe [ProactiveInsightSummary]
proactiveInsights :: Prelude.Maybe [ProactiveInsightSummary],
    -- | The response's http status code.
    SearchInsightsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SearchInsightsResponse -> SearchInsightsResponse -> Bool
(SearchInsightsResponse -> SearchInsightsResponse -> Bool)
-> (SearchInsightsResponse -> SearchInsightsResponse -> Bool)
-> Eq SearchInsightsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchInsightsResponse -> SearchInsightsResponse -> Bool
$c/= :: SearchInsightsResponse -> SearchInsightsResponse -> Bool
== :: SearchInsightsResponse -> SearchInsightsResponse -> Bool
$c== :: SearchInsightsResponse -> SearchInsightsResponse -> Bool
Prelude.Eq, ReadPrec [SearchInsightsResponse]
ReadPrec SearchInsightsResponse
Int -> ReadS SearchInsightsResponse
ReadS [SearchInsightsResponse]
(Int -> ReadS SearchInsightsResponse)
-> ReadS [SearchInsightsResponse]
-> ReadPrec SearchInsightsResponse
-> ReadPrec [SearchInsightsResponse]
-> Read SearchInsightsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchInsightsResponse]
$creadListPrec :: ReadPrec [SearchInsightsResponse]
readPrec :: ReadPrec SearchInsightsResponse
$creadPrec :: ReadPrec SearchInsightsResponse
readList :: ReadS [SearchInsightsResponse]
$creadList :: ReadS [SearchInsightsResponse]
readsPrec :: Int -> ReadS SearchInsightsResponse
$creadsPrec :: Int -> ReadS SearchInsightsResponse
Prelude.Read, Int -> SearchInsightsResponse -> ShowS
[SearchInsightsResponse] -> ShowS
SearchInsightsResponse -> String
(Int -> SearchInsightsResponse -> ShowS)
-> (SearchInsightsResponse -> String)
-> ([SearchInsightsResponse] -> ShowS)
-> Show SearchInsightsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchInsightsResponse] -> ShowS
$cshowList :: [SearchInsightsResponse] -> ShowS
show :: SearchInsightsResponse -> String
$cshow :: SearchInsightsResponse -> String
showsPrec :: Int -> SearchInsightsResponse -> ShowS
$cshowsPrec :: Int -> SearchInsightsResponse -> ShowS
Prelude.Show, (forall x. SearchInsightsResponse -> Rep SearchInsightsResponse x)
-> (forall x.
    Rep SearchInsightsResponse x -> SearchInsightsResponse)
-> Generic SearchInsightsResponse
forall x. Rep SearchInsightsResponse x -> SearchInsightsResponse
forall x. SearchInsightsResponse -> Rep SearchInsightsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchInsightsResponse x -> SearchInsightsResponse
$cfrom :: forall x. SearchInsightsResponse -> Rep SearchInsightsResponse x
Prelude.Generic)

-- |
-- Create a value of 'SearchInsightsResponse' 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:
--
-- 'reactiveInsights', 'searchInsightsResponse_reactiveInsights' - The returned reactive insights.
--
-- 'nextToken', 'searchInsightsResponse_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.
--
-- 'proactiveInsights', 'searchInsightsResponse_proactiveInsights' - The returned proactive insights.
--
-- 'httpStatus', 'searchInsightsResponse_httpStatus' - The response's http status code.
newSearchInsightsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SearchInsightsResponse
newSearchInsightsResponse :: Int -> SearchInsightsResponse
newSearchInsightsResponse Int
pHttpStatus_ =
  SearchInsightsResponse' :: Maybe [ReactiveInsightSummary]
-> Maybe Text
-> Maybe [ProactiveInsightSummary]
-> Int
-> SearchInsightsResponse
SearchInsightsResponse'
    { $sel:reactiveInsights:SearchInsightsResponse' :: Maybe [ReactiveInsightSummary]
reactiveInsights =
        Maybe [ReactiveInsightSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:SearchInsightsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:proactiveInsights:SearchInsightsResponse' :: Maybe [ProactiveInsightSummary]
proactiveInsights = Maybe [ProactiveInsightSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SearchInsightsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The returned reactive insights.
searchInsightsResponse_reactiveInsights :: Lens.Lens' SearchInsightsResponse (Prelude.Maybe [ReactiveInsightSummary])
searchInsightsResponse_reactiveInsights :: (Maybe [ReactiveInsightSummary]
 -> f (Maybe [ReactiveInsightSummary]))
-> SearchInsightsResponse -> f SearchInsightsResponse
searchInsightsResponse_reactiveInsights = (SearchInsightsResponse -> Maybe [ReactiveInsightSummary])
-> (SearchInsightsResponse
    -> Maybe [ReactiveInsightSummary] -> SearchInsightsResponse)
-> Lens' SearchInsightsResponse (Maybe [ReactiveInsightSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchInsightsResponse' {Maybe [ReactiveInsightSummary]
reactiveInsights :: Maybe [ReactiveInsightSummary]
$sel:reactiveInsights:SearchInsightsResponse' :: SearchInsightsResponse -> Maybe [ReactiveInsightSummary]
reactiveInsights} -> Maybe [ReactiveInsightSummary]
reactiveInsights) (\s :: SearchInsightsResponse
s@SearchInsightsResponse' {} Maybe [ReactiveInsightSummary]
a -> SearchInsightsResponse
s {$sel:reactiveInsights:SearchInsightsResponse' :: Maybe [ReactiveInsightSummary]
reactiveInsights = Maybe [ReactiveInsightSummary]
a} :: SearchInsightsResponse) ((Maybe [ReactiveInsightSummary]
  -> f (Maybe [ReactiveInsightSummary]))
 -> SearchInsightsResponse -> f SearchInsightsResponse)
-> ((Maybe [ReactiveInsightSummary]
     -> f (Maybe [ReactiveInsightSummary]))
    -> Maybe [ReactiveInsightSummary]
    -> f (Maybe [ReactiveInsightSummary]))
-> (Maybe [ReactiveInsightSummary]
    -> f (Maybe [ReactiveInsightSummary]))
-> SearchInsightsResponse
-> f SearchInsightsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ReactiveInsightSummary]
  [ReactiveInsightSummary]
  [ReactiveInsightSummary]
  [ReactiveInsightSummary]
-> Iso
     (Maybe [ReactiveInsightSummary])
     (Maybe [ReactiveInsightSummary])
     (Maybe [ReactiveInsightSummary])
     (Maybe [ReactiveInsightSummary])
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
  [ReactiveInsightSummary]
  [ReactiveInsightSummary]
  [ReactiveInsightSummary]
  [ReactiveInsightSummary]
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.
searchInsightsResponse_nextToken :: Lens.Lens' SearchInsightsResponse (Prelude.Maybe Prelude.Text)
searchInsightsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> SearchInsightsResponse -> f SearchInsightsResponse
searchInsightsResponse_nextToken = (SearchInsightsResponse -> Maybe Text)
-> (SearchInsightsResponse -> Maybe Text -> SearchInsightsResponse)
-> Lens' SearchInsightsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchInsightsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchInsightsResponse' :: SearchInsightsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchInsightsResponse
s@SearchInsightsResponse' {} Maybe Text
a -> SearchInsightsResponse
s {$sel:nextToken:SearchInsightsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: SearchInsightsResponse)

-- | The returned proactive insights.
searchInsightsResponse_proactiveInsights :: Lens.Lens' SearchInsightsResponse (Prelude.Maybe [ProactiveInsightSummary])
searchInsightsResponse_proactiveInsights :: (Maybe [ProactiveInsightSummary]
 -> f (Maybe [ProactiveInsightSummary]))
-> SearchInsightsResponse -> f SearchInsightsResponse
searchInsightsResponse_proactiveInsights = (SearchInsightsResponse -> Maybe [ProactiveInsightSummary])
-> (SearchInsightsResponse
    -> Maybe [ProactiveInsightSummary] -> SearchInsightsResponse)
-> Lens' SearchInsightsResponse (Maybe [ProactiveInsightSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchInsightsResponse' {Maybe [ProactiveInsightSummary]
proactiveInsights :: Maybe [ProactiveInsightSummary]
$sel:proactiveInsights:SearchInsightsResponse' :: SearchInsightsResponse -> Maybe [ProactiveInsightSummary]
proactiveInsights} -> Maybe [ProactiveInsightSummary]
proactiveInsights) (\s :: SearchInsightsResponse
s@SearchInsightsResponse' {} Maybe [ProactiveInsightSummary]
a -> SearchInsightsResponse
s {$sel:proactiveInsights:SearchInsightsResponse' :: Maybe [ProactiveInsightSummary]
proactiveInsights = Maybe [ProactiveInsightSummary]
a} :: SearchInsightsResponse) ((Maybe [ProactiveInsightSummary]
  -> f (Maybe [ProactiveInsightSummary]))
 -> SearchInsightsResponse -> f SearchInsightsResponse)
-> ((Maybe [ProactiveInsightSummary]
     -> f (Maybe [ProactiveInsightSummary]))
    -> Maybe [ProactiveInsightSummary]
    -> f (Maybe [ProactiveInsightSummary]))
-> (Maybe [ProactiveInsightSummary]
    -> f (Maybe [ProactiveInsightSummary]))
-> SearchInsightsResponse
-> f SearchInsightsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ProactiveInsightSummary]
  [ProactiveInsightSummary]
  [ProactiveInsightSummary]
  [ProactiveInsightSummary]
-> Iso
     (Maybe [ProactiveInsightSummary])
     (Maybe [ProactiveInsightSummary])
     (Maybe [ProactiveInsightSummary])
     (Maybe [ProactiveInsightSummary])
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
  [ProactiveInsightSummary]
  [ProactiveInsightSummary]
  [ProactiveInsightSummary]
  [ProactiveInsightSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData SearchInsightsResponse