{-# 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.QuickSight.SearchAnalyses
-- 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)
--
-- Searches for analyses that belong to the user specified in the filter.
--
-- This operation is eventually consistent. The results are best effort and
-- may not reflect very recent updates and changes.
--
-- This operation returns paginated results.
module Amazonka.QuickSight.SearchAnalyses
  ( -- * Creating a Request
    SearchAnalyses (..),
    newSearchAnalyses,

    -- * Request Lenses
    searchAnalyses_nextToken,
    searchAnalyses_maxResults,
    searchAnalyses_awsAccountId,
    searchAnalyses_filters,

    -- * Destructuring the Response
    SearchAnalysesResponse (..),
    newSearchAnalysesResponse,

    -- * Response Lenses
    searchAnalysesResponse_requestId,
    searchAnalysesResponse_nextToken,
    searchAnalysesResponse_analysisSummaryList,
    searchAnalysesResponse_status,
  )
where

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

-- | /See:/ 'newSearchAnalyses' smart constructor.
data SearchAnalyses = SearchAnalyses'
  { -- | A pagination token that can be used in a subsequent request.
    SearchAnalyses -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return.
    SearchAnalyses -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The ID of the Amazon Web Services account that contains the analyses
    -- that you\'re searching for.
    SearchAnalyses -> Text
awsAccountId :: Prelude.Text,
    -- | The structure for the search filters that you want to apply to your
    -- search.
    SearchAnalyses -> NonEmpty AnalysisSearchFilter
filters :: Prelude.NonEmpty AnalysisSearchFilter
  }
  deriving (SearchAnalyses -> SearchAnalyses -> Bool
(SearchAnalyses -> SearchAnalyses -> Bool)
-> (SearchAnalyses -> SearchAnalyses -> Bool) -> Eq SearchAnalyses
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchAnalyses -> SearchAnalyses -> Bool
$c/= :: SearchAnalyses -> SearchAnalyses -> Bool
== :: SearchAnalyses -> SearchAnalyses -> Bool
$c== :: SearchAnalyses -> SearchAnalyses -> Bool
Prelude.Eq, ReadPrec [SearchAnalyses]
ReadPrec SearchAnalyses
Int -> ReadS SearchAnalyses
ReadS [SearchAnalyses]
(Int -> ReadS SearchAnalyses)
-> ReadS [SearchAnalyses]
-> ReadPrec SearchAnalyses
-> ReadPrec [SearchAnalyses]
-> Read SearchAnalyses
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchAnalyses]
$creadListPrec :: ReadPrec [SearchAnalyses]
readPrec :: ReadPrec SearchAnalyses
$creadPrec :: ReadPrec SearchAnalyses
readList :: ReadS [SearchAnalyses]
$creadList :: ReadS [SearchAnalyses]
readsPrec :: Int -> ReadS SearchAnalyses
$creadsPrec :: Int -> ReadS SearchAnalyses
Prelude.Read, Int -> SearchAnalyses -> ShowS
[SearchAnalyses] -> ShowS
SearchAnalyses -> String
(Int -> SearchAnalyses -> ShowS)
-> (SearchAnalyses -> String)
-> ([SearchAnalyses] -> ShowS)
-> Show SearchAnalyses
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchAnalyses] -> ShowS
$cshowList :: [SearchAnalyses] -> ShowS
show :: SearchAnalyses -> String
$cshow :: SearchAnalyses -> String
showsPrec :: Int -> SearchAnalyses -> ShowS
$cshowsPrec :: Int -> SearchAnalyses -> ShowS
Prelude.Show, (forall x. SearchAnalyses -> Rep SearchAnalyses x)
-> (forall x. Rep SearchAnalyses x -> SearchAnalyses)
-> Generic SearchAnalyses
forall x. Rep SearchAnalyses x -> SearchAnalyses
forall x. SearchAnalyses -> Rep SearchAnalyses x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchAnalyses x -> SearchAnalyses
$cfrom :: forall x. SearchAnalyses -> Rep SearchAnalyses x
Prelude.Generic)

-- |
-- Create a value of 'SearchAnalyses' 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', 'searchAnalyses_nextToken' - A pagination token that can be used in a subsequent request.
--
-- 'maxResults', 'searchAnalyses_maxResults' - The maximum number of results to return.
--
-- 'awsAccountId', 'searchAnalyses_awsAccountId' - The ID of the Amazon Web Services account that contains the analyses
-- that you\'re searching for.
--
-- 'filters', 'searchAnalyses_filters' - The structure for the search filters that you want to apply to your
-- search.
newSearchAnalyses ::
  -- | 'awsAccountId'
  Prelude.Text ->
  -- | 'filters'
  Prelude.NonEmpty AnalysisSearchFilter ->
  SearchAnalyses
newSearchAnalyses :: Text -> NonEmpty AnalysisSearchFilter -> SearchAnalyses
newSearchAnalyses Text
pAwsAccountId_ NonEmpty AnalysisSearchFilter
pFilters_ =
  SearchAnalyses' :: Maybe Text
-> Maybe Natural
-> Text
-> NonEmpty AnalysisSearchFilter
-> SearchAnalyses
SearchAnalyses'
    { $sel:nextToken:SearchAnalyses' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:SearchAnalyses' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:awsAccountId:SearchAnalyses' :: Text
awsAccountId = Text
pAwsAccountId_,
      $sel:filters:SearchAnalyses' :: NonEmpty AnalysisSearchFilter
filters = Tagged
  (NonEmpty AnalysisSearchFilter)
  (Identity (NonEmpty AnalysisSearchFilter))
-> Tagged
     (NonEmpty AnalysisSearchFilter)
     (Identity (NonEmpty AnalysisSearchFilter))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty AnalysisSearchFilter)
   (Identity (NonEmpty AnalysisSearchFilter))
 -> Tagged
      (NonEmpty AnalysisSearchFilter)
      (Identity (NonEmpty AnalysisSearchFilter)))
-> NonEmpty AnalysisSearchFilter -> NonEmpty AnalysisSearchFilter
forall t b. AReview t b -> b -> t
Lens.# NonEmpty AnalysisSearchFilter
pFilters_
    }

-- | A pagination token that can be used in a subsequent request.
searchAnalyses_nextToken :: Lens.Lens' SearchAnalyses (Prelude.Maybe Prelude.Text)
searchAnalyses_nextToken :: (Maybe Text -> f (Maybe Text))
-> SearchAnalyses -> f SearchAnalyses
searchAnalyses_nextToken = (SearchAnalyses -> Maybe Text)
-> (SearchAnalyses -> Maybe Text -> SearchAnalyses)
-> Lens SearchAnalyses SearchAnalyses (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAnalyses' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchAnalyses' :: SearchAnalyses -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchAnalyses
s@SearchAnalyses' {} Maybe Text
a -> SearchAnalyses
s {$sel:nextToken:SearchAnalyses' :: Maybe Text
nextToken = Maybe Text
a} :: SearchAnalyses)

-- | The maximum number of results to return.
searchAnalyses_maxResults :: Lens.Lens' SearchAnalyses (Prelude.Maybe Prelude.Natural)
searchAnalyses_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> SearchAnalyses -> f SearchAnalyses
searchAnalyses_maxResults = (SearchAnalyses -> Maybe Natural)
-> (SearchAnalyses -> Maybe Natural -> SearchAnalyses)
-> Lens
     SearchAnalyses SearchAnalyses (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAnalyses' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:SearchAnalyses' :: SearchAnalyses -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: SearchAnalyses
s@SearchAnalyses' {} Maybe Natural
a -> SearchAnalyses
s {$sel:maxResults:SearchAnalyses' :: Maybe Natural
maxResults = Maybe Natural
a} :: SearchAnalyses)

-- | The ID of the Amazon Web Services account that contains the analyses
-- that you\'re searching for.
searchAnalyses_awsAccountId :: Lens.Lens' SearchAnalyses Prelude.Text
searchAnalyses_awsAccountId :: (Text -> f Text) -> SearchAnalyses -> f SearchAnalyses
searchAnalyses_awsAccountId = (SearchAnalyses -> Text)
-> (SearchAnalyses -> Text -> SearchAnalyses)
-> Lens SearchAnalyses SearchAnalyses Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAnalyses' {Text
awsAccountId :: Text
$sel:awsAccountId:SearchAnalyses' :: SearchAnalyses -> Text
awsAccountId} -> Text
awsAccountId) (\s :: SearchAnalyses
s@SearchAnalyses' {} Text
a -> SearchAnalyses
s {$sel:awsAccountId:SearchAnalyses' :: Text
awsAccountId = Text
a} :: SearchAnalyses)

-- | The structure for the search filters that you want to apply to your
-- search.
searchAnalyses_filters :: Lens.Lens' SearchAnalyses (Prelude.NonEmpty AnalysisSearchFilter)
searchAnalyses_filters :: (NonEmpty AnalysisSearchFilter
 -> f (NonEmpty AnalysisSearchFilter))
-> SearchAnalyses -> f SearchAnalyses
searchAnalyses_filters = (SearchAnalyses -> NonEmpty AnalysisSearchFilter)
-> (SearchAnalyses
    -> NonEmpty AnalysisSearchFilter -> SearchAnalyses)
-> Lens
     SearchAnalyses
     SearchAnalyses
     (NonEmpty AnalysisSearchFilter)
     (NonEmpty AnalysisSearchFilter)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAnalyses' {NonEmpty AnalysisSearchFilter
filters :: NonEmpty AnalysisSearchFilter
$sel:filters:SearchAnalyses' :: SearchAnalyses -> NonEmpty AnalysisSearchFilter
filters} -> NonEmpty AnalysisSearchFilter
filters) (\s :: SearchAnalyses
s@SearchAnalyses' {} NonEmpty AnalysisSearchFilter
a -> SearchAnalyses
s {$sel:filters:SearchAnalyses' :: NonEmpty AnalysisSearchFilter
filters = NonEmpty AnalysisSearchFilter
a} :: SearchAnalyses) ((NonEmpty AnalysisSearchFilter
  -> f (NonEmpty AnalysisSearchFilter))
 -> SearchAnalyses -> f SearchAnalyses)
-> ((NonEmpty AnalysisSearchFilter
     -> f (NonEmpty AnalysisSearchFilter))
    -> NonEmpty AnalysisSearchFilter
    -> f (NonEmpty AnalysisSearchFilter))
-> (NonEmpty AnalysisSearchFilter
    -> f (NonEmpty AnalysisSearchFilter))
-> SearchAnalyses
-> f SearchAnalyses
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty AnalysisSearchFilter
 -> f (NonEmpty AnalysisSearchFilter))
-> NonEmpty AnalysisSearchFilter
-> f (NonEmpty AnalysisSearchFilter)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData SearchAnalyses

instance Core.ToHeaders SearchAnalyses where
  toHeaders :: SearchAnalyses -> ResponseHeaders
toHeaders =
    ResponseHeaders -> SearchAnalyses -> 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.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON SearchAnalyses where
  toJSON :: SearchAnalyses -> Value
toJSON SearchAnalyses' {Maybe Natural
Maybe Text
NonEmpty AnalysisSearchFilter
Text
filters :: NonEmpty AnalysisSearchFilter
awsAccountId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:filters:SearchAnalyses' :: SearchAnalyses -> NonEmpty AnalysisSearchFilter
$sel:awsAccountId:SearchAnalyses' :: SearchAnalyses -> Text
$sel:maxResults:SearchAnalyses' :: SearchAnalyses -> Maybe Natural
$sel:nextToken:SearchAnalyses' :: SearchAnalyses -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"Filters" Text -> NonEmpty AnalysisSearchFilter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty AnalysisSearchFilter
filters)
          ]
      )

instance Core.ToPath SearchAnalyses where
  toPath :: SearchAnalyses -> ByteString
toPath SearchAnalyses' {Maybe Natural
Maybe Text
NonEmpty AnalysisSearchFilter
Text
filters :: NonEmpty AnalysisSearchFilter
awsAccountId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:filters:SearchAnalyses' :: SearchAnalyses -> NonEmpty AnalysisSearchFilter
$sel:awsAccountId:SearchAnalyses' :: SearchAnalyses -> Text
$sel:maxResults:SearchAnalyses' :: SearchAnalyses -> Maybe Natural
$sel:nextToken:SearchAnalyses' :: SearchAnalyses -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
awsAccountId,
        ByteString
"/search/analyses"
      ]

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

-- | /See:/ 'newSearchAnalysesResponse' smart constructor.
data SearchAnalysesResponse = SearchAnalysesResponse'
  { -- | The Amazon Web Services request ID for this operation.
    SearchAnalysesResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | A pagination token that can be used in a subsequent request.
    SearchAnalysesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Metadata describing the analyses that you searched for.
    SearchAnalysesResponse -> Maybe [AnalysisSummary]
analysisSummaryList :: Prelude.Maybe [AnalysisSummary],
    -- | The HTTP status of the request.
    SearchAnalysesResponse -> Int
status :: Prelude.Int
  }
  deriving (SearchAnalysesResponse -> SearchAnalysesResponse -> Bool
(SearchAnalysesResponse -> SearchAnalysesResponse -> Bool)
-> (SearchAnalysesResponse -> SearchAnalysesResponse -> Bool)
-> Eq SearchAnalysesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchAnalysesResponse -> SearchAnalysesResponse -> Bool
$c/= :: SearchAnalysesResponse -> SearchAnalysesResponse -> Bool
== :: SearchAnalysesResponse -> SearchAnalysesResponse -> Bool
$c== :: SearchAnalysesResponse -> SearchAnalysesResponse -> Bool
Prelude.Eq, ReadPrec [SearchAnalysesResponse]
ReadPrec SearchAnalysesResponse
Int -> ReadS SearchAnalysesResponse
ReadS [SearchAnalysesResponse]
(Int -> ReadS SearchAnalysesResponse)
-> ReadS [SearchAnalysesResponse]
-> ReadPrec SearchAnalysesResponse
-> ReadPrec [SearchAnalysesResponse]
-> Read SearchAnalysesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchAnalysesResponse]
$creadListPrec :: ReadPrec [SearchAnalysesResponse]
readPrec :: ReadPrec SearchAnalysesResponse
$creadPrec :: ReadPrec SearchAnalysesResponse
readList :: ReadS [SearchAnalysesResponse]
$creadList :: ReadS [SearchAnalysesResponse]
readsPrec :: Int -> ReadS SearchAnalysesResponse
$creadsPrec :: Int -> ReadS SearchAnalysesResponse
Prelude.Read, Int -> SearchAnalysesResponse -> ShowS
[SearchAnalysesResponse] -> ShowS
SearchAnalysesResponse -> String
(Int -> SearchAnalysesResponse -> ShowS)
-> (SearchAnalysesResponse -> String)
-> ([SearchAnalysesResponse] -> ShowS)
-> Show SearchAnalysesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchAnalysesResponse] -> ShowS
$cshowList :: [SearchAnalysesResponse] -> ShowS
show :: SearchAnalysesResponse -> String
$cshow :: SearchAnalysesResponse -> String
showsPrec :: Int -> SearchAnalysesResponse -> ShowS
$cshowsPrec :: Int -> SearchAnalysesResponse -> ShowS
Prelude.Show, (forall x. SearchAnalysesResponse -> Rep SearchAnalysesResponse x)
-> (forall x.
    Rep SearchAnalysesResponse x -> SearchAnalysesResponse)
-> Generic SearchAnalysesResponse
forall x. Rep SearchAnalysesResponse x -> SearchAnalysesResponse
forall x. SearchAnalysesResponse -> Rep SearchAnalysesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchAnalysesResponse x -> SearchAnalysesResponse
$cfrom :: forall x. SearchAnalysesResponse -> Rep SearchAnalysesResponse x
Prelude.Generic)

-- |
-- Create a value of 'SearchAnalysesResponse' 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:
--
-- 'requestId', 'searchAnalysesResponse_requestId' - The Amazon Web Services request ID for this operation.
--
-- 'nextToken', 'searchAnalysesResponse_nextToken' - A pagination token that can be used in a subsequent request.
--
-- 'analysisSummaryList', 'searchAnalysesResponse_analysisSummaryList' - Metadata describing the analyses that you searched for.
--
-- 'status', 'searchAnalysesResponse_status' - The HTTP status of the request.
newSearchAnalysesResponse ::
  -- | 'status'
  Prelude.Int ->
  SearchAnalysesResponse
newSearchAnalysesResponse :: Int -> SearchAnalysesResponse
newSearchAnalysesResponse Int
pStatus_ =
  SearchAnalysesResponse' :: Maybe Text
-> Maybe Text
-> Maybe [AnalysisSummary]
-> Int
-> SearchAnalysesResponse
SearchAnalysesResponse'
    { $sel:requestId:SearchAnalysesResponse' :: Maybe Text
requestId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:SearchAnalysesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:analysisSummaryList:SearchAnalysesResponse' :: Maybe [AnalysisSummary]
analysisSummaryList = Maybe [AnalysisSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:status:SearchAnalysesResponse' :: Int
status = Int
pStatus_
    }

-- | The Amazon Web Services request ID for this operation.
searchAnalysesResponse_requestId :: Lens.Lens' SearchAnalysesResponse (Prelude.Maybe Prelude.Text)
searchAnalysesResponse_requestId :: (Maybe Text -> f (Maybe Text))
-> SearchAnalysesResponse -> f SearchAnalysesResponse
searchAnalysesResponse_requestId = (SearchAnalysesResponse -> Maybe Text)
-> (SearchAnalysesResponse -> Maybe Text -> SearchAnalysesResponse)
-> Lens' SearchAnalysesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAnalysesResponse' {Maybe Text
requestId :: Maybe Text
$sel:requestId:SearchAnalysesResponse' :: SearchAnalysesResponse -> Maybe Text
requestId} -> Maybe Text
requestId) (\s :: SearchAnalysesResponse
s@SearchAnalysesResponse' {} Maybe Text
a -> SearchAnalysesResponse
s {$sel:requestId:SearchAnalysesResponse' :: Maybe Text
requestId = Maybe Text
a} :: SearchAnalysesResponse)

-- | A pagination token that can be used in a subsequent request.
searchAnalysesResponse_nextToken :: Lens.Lens' SearchAnalysesResponse (Prelude.Maybe Prelude.Text)
searchAnalysesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> SearchAnalysesResponse -> f SearchAnalysesResponse
searchAnalysesResponse_nextToken = (SearchAnalysesResponse -> Maybe Text)
-> (SearchAnalysesResponse -> Maybe Text -> SearchAnalysesResponse)
-> Lens' SearchAnalysesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAnalysesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchAnalysesResponse' :: SearchAnalysesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchAnalysesResponse
s@SearchAnalysesResponse' {} Maybe Text
a -> SearchAnalysesResponse
s {$sel:nextToken:SearchAnalysesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: SearchAnalysesResponse)

-- | Metadata describing the analyses that you searched for.
searchAnalysesResponse_analysisSummaryList :: Lens.Lens' SearchAnalysesResponse (Prelude.Maybe [AnalysisSummary])
searchAnalysesResponse_analysisSummaryList :: (Maybe [AnalysisSummary] -> f (Maybe [AnalysisSummary]))
-> SearchAnalysesResponse -> f SearchAnalysesResponse
searchAnalysesResponse_analysisSummaryList = (SearchAnalysesResponse -> Maybe [AnalysisSummary])
-> (SearchAnalysesResponse
    -> Maybe [AnalysisSummary] -> SearchAnalysesResponse)
-> Lens' SearchAnalysesResponse (Maybe [AnalysisSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAnalysesResponse' {Maybe [AnalysisSummary]
analysisSummaryList :: Maybe [AnalysisSummary]
$sel:analysisSummaryList:SearchAnalysesResponse' :: SearchAnalysesResponse -> Maybe [AnalysisSummary]
analysisSummaryList} -> Maybe [AnalysisSummary]
analysisSummaryList) (\s :: SearchAnalysesResponse
s@SearchAnalysesResponse' {} Maybe [AnalysisSummary]
a -> SearchAnalysesResponse
s {$sel:analysisSummaryList:SearchAnalysesResponse' :: Maybe [AnalysisSummary]
analysisSummaryList = Maybe [AnalysisSummary]
a} :: SearchAnalysesResponse) ((Maybe [AnalysisSummary] -> f (Maybe [AnalysisSummary]))
 -> SearchAnalysesResponse -> f SearchAnalysesResponse)
-> ((Maybe [AnalysisSummary] -> f (Maybe [AnalysisSummary]))
    -> Maybe [AnalysisSummary] -> f (Maybe [AnalysisSummary]))
-> (Maybe [AnalysisSummary] -> f (Maybe [AnalysisSummary]))
-> SearchAnalysesResponse
-> f SearchAnalysesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AnalysisSummary]
  [AnalysisSummary]
  [AnalysisSummary]
  [AnalysisSummary]
-> Iso
     (Maybe [AnalysisSummary])
     (Maybe [AnalysisSummary])
     (Maybe [AnalysisSummary])
     (Maybe [AnalysisSummary])
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
  [AnalysisSummary]
  [AnalysisSummary]
  [AnalysisSummary]
  [AnalysisSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The HTTP status of the request.
searchAnalysesResponse_status :: Lens.Lens' SearchAnalysesResponse Prelude.Int
searchAnalysesResponse_status :: (Int -> f Int)
-> SearchAnalysesResponse -> f SearchAnalysesResponse
searchAnalysesResponse_status = (SearchAnalysesResponse -> Int)
-> (SearchAnalysesResponse -> Int -> SearchAnalysesResponse)
-> Lens SearchAnalysesResponse SearchAnalysesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAnalysesResponse' {Int
status :: Int
$sel:status:SearchAnalysesResponse' :: SearchAnalysesResponse -> Int
status} -> Int
status) (\s :: SearchAnalysesResponse
s@SearchAnalysesResponse' {} Int
a -> SearchAnalysesResponse
s {$sel:status:SearchAnalysesResponse' :: Int
status = Int
a} :: SearchAnalysesResponse)

instance Prelude.NFData SearchAnalysesResponse