{-# 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.ServiceCatalog.SearchProducts
-- 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)
--
-- Gets information about the products to which the caller has access.
module Amazonka.ServiceCatalog.SearchProducts
  ( -- * Creating a Request
    SearchProducts (..),
    newSearchProducts,

    -- * Request Lenses
    searchProducts_filters,
    searchProducts_sortOrder,
    searchProducts_acceptLanguage,
    searchProducts_pageToken,
    searchProducts_pageSize,
    searchProducts_sortBy,

    -- * Destructuring the Response
    SearchProductsResponse (..),
    newSearchProductsResponse,

    -- * Response Lenses
    searchProductsResponse_nextPageToken,
    searchProductsResponse_productViewAggregations,
    searchProductsResponse_productViewSummaries,
    searchProductsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newSearchProducts' smart constructor.
data SearchProducts = SearchProducts'
  { -- | The search filters. If no search filters are specified, the output
    -- includes all products to which the caller has access.
    SearchProducts -> Maybe (HashMap ProductViewFilterBy [Text])
filters :: Prelude.Maybe (Prelude.HashMap ProductViewFilterBy [Prelude.Text]),
    -- | The sort order. If no value is specified, the results are not sorted.
    SearchProducts -> Maybe SortOrder
sortOrder :: Prelude.Maybe SortOrder,
    -- | The language code.
    --
    -- -   @en@ - English (default)
    --
    -- -   @jp@ - Japanese
    --
    -- -   @zh@ - Chinese
    SearchProducts -> Maybe Text
acceptLanguage :: Prelude.Maybe Prelude.Text,
    -- | The page token for the next set of results. To retrieve the first set of
    -- results, use null.
    SearchProducts -> Maybe Text
pageToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to return with this call.
    SearchProducts -> Maybe Natural
pageSize :: Prelude.Maybe Prelude.Natural,
    -- | The sort field. If no value is specified, the results are not sorted.
    SearchProducts -> Maybe ProductViewSortBy
sortBy :: Prelude.Maybe ProductViewSortBy
  }
  deriving (SearchProducts -> SearchProducts -> Bool
(SearchProducts -> SearchProducts -> Bool)
-> (SearchProducts -> SearchProducts -> Bool) -> Eq SearchProducts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchProducts -> SearchProducts -> Bool
$c/= :: SearchProducts -> SearchProducts -> Bool
== :: SearchProducts -> SearchProducts -> Bool
$c== :: SearchProducts -> SearchProducts -> Bool
Prelude.Eq, ReadPrec [SearchProducts]
ReadPrec SearchProducts
Int -> ReadS SearchProducts
ReadS [SearchProducts]
(Int -> ReadS SearchProducts)
-> ReadS [SearchProducts]
-> ReadPrec SearchProducts
-> ReadPrec [SearchProducts]
-> Read SearchProducts
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchProducts]
$creadListPrec :: ReadPrec [SearchProducts]
readPrec :: ReadPrec SearchProducts
$creadPrec :: ReadPrec SearchProducts
readList :: ReadS [SearchProducts]
$creadList :: ReadS [SearchProducts]
readsPrec :: Int -> ReadS SearchProducts
$creadsPrec :: Int -> ReadS SearchProducts
Prelude.Read, Int -> SearchProducts -> ShowS
[SearchProducts] -> ShowS
SearchProducts -> String
(Int -> SearchProducts -> ShowS)
-> (SearchProducts -> String)
-> ([SearchProducts] -> ShowS)
-> Show SearchProducts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchProducts] -> ShowS
$cshowList :: [SearchProducts] -> ShowS
show :: SearchProducts -> String
$cshow :: SearchProducts -> String
showsPrec :: Int -> SearchProducts -> ShowS
$cshowsPrec :: Int -> SearchProducts -> ShowS
Prelude.Show, (forall x. SearchProducts -> Rep SearchProducts x)
-> (forall x. Rep SearchProducts x -> SearchProducts)
-> Generic SearchProducts
forall x. Rep SearchProducts x -> SearchProducts
forall x. SearchProducts -> Rep SearchProducts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchProducts x -> SearchProducts
$cfrom :: forall x. SearchProducts -> Rep SearchProducts x
Prelude.Generic)

-- |
-- Create a value of 'SearchProducts' 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', 'searchProducts_filters' - The search filters. If no search filters are specified, the output
-- includes all products to which the caller has access.
--
-- 'sortOrder', 'searchProducts_sortOrder' - The sort order. If no value is specified, the results are not sorted.
--
-- 'acceptLanguage', 'searchProducts_acceptLanguage' - The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
--
-- 'pageToken', 'searchProducts_pageToken' - The page token for the next set of results. To retrieve the first set of
-- results, use null.
--
-- 'pageSize', 'searchProducts_pageSize' - The maximum number of items to return with this call.
--
-- 'sortBy', 'searchProducts_sortBy' - The sort field. If no value is specified, the results are not sorted.
newSearchProducts ::
  SearchProducts
newSearchProducts :: SearchProducts
newSearchProducts =
  SearchProducts' :: Maybe (HashMap ProductViewFilterBy [Text])
-> Maybe SortOrder
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Maybe ProductViewSortBy
-> SearchProducts
SearchProducts'
    { $sel:filters:SearchProducts' :: Maybe (HashMap ProductViewFilterBy [Text])
filters = Maybe (HashMap ProductViewFilterBy [Text])
forall a. Maybe a
Prelude.Nothing,
      $sel:sortOrder:SearchProducts' :: Maybe SortOrder
sortOrder = Maybe SortOrder
forall a. Maybe a
Prelude.Nothing,
      $sel:acceptLanguage:SearchProducts' :: Maybe Text
acceptLanguage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pageToken:SearchProducts' :: Maybe Text
pageToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pageSize:SearchProducts' :: Maybe Natural
pageSize = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:sortBy:SearchProducts' :: Maybe ProductViewSortBy
sortBy = Maybe ProductViewSortBy
forall a. Maybe a
Prelude.Nothing
    }

-- | The search filters. If no search filters are specified, the output
-- includes all products to which the caller has access.
searchProducts_filters :: Lens.Lens' SearchProducts (Prelude.Maybe (Prelude.HashMap ProductViewFilterBy [Prelude.Text]))
searchProducts_filters :: (Maybe (HashMap ProductViewFilterBy [Text])
 -> f (Maybe (HashMap ProductViewFilterBy [Text])))
-> SearchProducts -> f SearchProducts
searchProducts_filters = (SearchProducts -> Maybe (HashMap ProductViewFilterBy [Text]))
-> (SearchProducts
    -> Maybe (HashMap ProductViewFilterBy [Text]) -> SearchProducts)
-> Lens
     SearchProducts
     SearchProducts
     (Maybe (HashMap ProductViewFilterBy [Text]))
     (Maybe (HashMap ProductViewFilterBy [Text]))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProducts' {Maybe (HashMap ProductViewFilterBy [Text])
filters :: Maybe (HashMap ProductViewFilterBy [Text])
$sel:filters:SearchProducts' :: SearchProducts -> Maybe (HashMap ProductViewFilterBy [Text])
filters} -> Maybe (HashMap ProductViewFilterBy [Text])
filters) (\s :: SearchProducts
s@SearchProducts' {} Maybe (HashMap ProductViewFilterBy [Text])
a -> SearchProducts
s {$sel:filters:SearchProducts' :: Maybe (HashMap ProductViewFilterBy [Text])
filters = Maybe (HashMap ProductViewFilterBy [Text])
a} :: SearchProducts) ((Maybe (HashMap ProductViewFilterBy [Text])
  -> f (Maybe (HashMap ProductViewFilterBy [Text])))
 -> SearchProducts -> f SearchProducts)
-> ((Maybe (HashMap ProductViewFilterBy [Text])
     -> f (Maybe (HashMap ProductViewFilterBy [Text])))
    -> Maybe (HashMap ProductViewFilterBy [Text])
    -> f (Maybe (HashMap ProductViewFilterBy [Text])))
-> (Maybe (HashMap ProductViewFilterBy [Text])
    -> f (Maybe (HashMap ProductViewFilterBy [Text])))
-> SearchProducts
-> f SearchProducts
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap ProductViewFilterBy [Text])
  (HashMap ProductViewFilterBy [Text])
  (HashMap ProductViewFilterBy [Text])
  (HashMap ProductViewFilterBy [Text])
-> Iso
     (Maybe (HashMap ProductViewFilterBy [Text]))
     (Maybe (HashMap ProductViewFilterBy [Text]))
     (Maybe (HashMap ProductViewFilterBy [Text]))
     (Maybe (HashMap ProductViewFilterBy [Text]))
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
  (HashMap ProductViewFilterBy [Text])
  (HashMap ProductViewFilterBy [Text])
  (HashMap ProductViewFilterBy [Text])
  (HashMap ProductViewFilterBy [Text])
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The sort order. If no value is specified, the results are not sorted.
searchProducts_sortOrder :: Lens.Lens' SearchProducts (Prelude.Maybe SortOrder)
searchProducts_sortOrder :: (Maybe SortOrder -> f (Maybe SortOrder))
-> SearchProducts -> f SearchProducts
searchProducts_sortOrder = (SearchProducts -> Maybe SortOrder)
-> (SearchProducts -> Maybe SortOrder -> SearchProducts)
-> Lens
     SearchProducts SearchProducts (Maybe SortOrder) (Maybe SortOrder)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProducts' {Maybe SortOrder
sortOrder :: Maybe SortOrder
$sel:sortOrder:SearchProducts' :: SearchProducts -> Maybe SortOrder
sortOrder} -> Maybe SortOrder
sortOrder) (\s :: SearchProducts
s@SearchProducts' {} Maybe SortOrder
a -> SearchProducts
s {$sel:sortOrder:SearchProducts' :: Maybe SortOrder
sortOrder = Maybe SortOrder
a} :: SearchProducts)

-- | The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
searchProducts_acceptLanguage :: Lens.Lens' SearchProducts (Prelude.Maybe Prelude.Text)
searchProducts_acceptLanguage :: (Maybe Text -> f (Maybe Text))
-> SearchProducts -> f SearchProducts
searchProducts_acceptLanguage = (SearchProducts -> Maybe Text)
-> (SearchProducts -> Maybe Text -> SearchProducts)
-> Lens SearchProducts SearchProducts (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProducts' {Maybe Text
acceptLanguage :: Maybe Text
$sel:acceptLanguage:SearchProducts' :: SearchProducts -> Maybe Text
acceptLanguage} -> Maybe Text
acceptLanguage) (\s :: SearchProducts
s@SearchProducts' {} Maybe Text
a -> SearchProducts
s {$sel:acceptLanguage:SearchProducts' :: Maybe Text
acceptLanguage = Maybe Text
a} :: SearchProducts)

-- | The page token for the next set of results. To retrieve the first set of
-- results, use null.
searchProducts_pageToken :: Lens.Lens' SearchProducts (Prelude.Maybe Prelude.Text)
searchProducts_pageToken :: (Maybe Text -> f (Maybe Text))
-> SearchProducts -> f SearchProducts
searchProducts_pageToken = (SearchProducts -> Maybe Text)
-> (SearchProducts -> Maybe Text -> SearchProducts)
-> Lens SearchProducts SearchProducts (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProducts' {Maybe Text
pageToken :: Maybe Text
$sel:pageToken:SearchProducts' :: SearchProducts -> Maybe Text
pageToken} -> Maybe Text
pageToken) (\s :: SearchProducts
s@SearchProducts' {} Maybe Text
a -> SearchProducts
s {$sel:pageToken:SearchProducts' :: Maybe Text
pageToken = Maybe Text
a} :: SearchProducts)

-- | The maximum number of items to return with this call.
searchProducts_pageSize :: Lens.Lens' SearchProducts (Prelude.Maybe Prelude.Natural)
searchProducts_pageSize :: (Maybe Natural -> f (Maybe Natural))
-> SearchProducts -> f SearchProducts
searchProducts_pageSize = (SearchProducts -> Maybe Natural)
-> (SearchProducts -> Maybe Natural -> SearchProducts)
-> Lens
     SearchProducts SearchProducts (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProducts' {Maybe Natural
pageSize :: Maybe Natural
$sel:pageSize:SearchProducts' :: SearchProducts -> Maybe Natural
pageSize} -> Maybe Natural
pageSize) (\s :: SearchProducts
s@SearchProducts' {} Maybe Natural
a -> SearchProducts
s {$sel:pageSize:SearchProducts' :: Maybe Natural
pageSize = Maybe Natural
a} :: SearchProducts)

-- | The sort field. If no value is specified, the results are not sorted.
searchProducts_sortBy :: Lens.Lens' SearchProducts (Prelude.Maybe ProductViewSortBy)
searchProducts_sortBy :: (Maybe ProductViewSortBy -> f (Maybe ProductViewSortBy))
-> SearchProducts -> f SearchProducts
searchProducts_sortBy = (SearchProducts -> Maybe ProductViewSortBy)
-> (SearchProducts -> Maybe ProductViewSortBy -> SearchProducts)
-> Lens
     SearchProducts
     SearchProducts
     (Maybe ProductViewSortBy)
     (Maybe ProductViewSortBy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProducts' {Maybe ProductViewSortBy
sortBy :: Maybe ProductViewSortBy
$sel:sortBy:SearchProducts' :: SearchProducts -> Maybe ProductViewSortBy
sortBy} -> Maybe ProductViewSortBy
sortBy) (\s :: SearchProducts
s@SearchProducts' {} Maybe ProductViewSortBy
a -> SearchProducts
s {$sel:sortBy:SearchProducts' :: Maybe ProductViewSortBy
sortBy = Maybe ProductViewSortBy
a} :: SearchProducts)

instance Core.AWSRequest SearchProducts where
  type
    AWSResponse SearchProducts =
      SearchProductsResponse
  request :: SearchProducts -> Request SearchProducts
request = Service -> SearchProducts -> Request SearchProducts
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy SearchProducts
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SearchProducts)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse SearchProducts))
-> Logger
-> Service
-> Proxy SearchProducts
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SearchProducts)))
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 (HashMap Text [ProductViewAggregationValue])
-> Maybe [ProductViewSummary]
-> Int
-> SearchProductsResponse
SearchProductsResponse'
            (Maybe Text
 -> Maybe (HashMap Text [ProductViewAggregationValue])
 -> Maybe [ProductViewSummary]
 -> Int
 -> SearchProductsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe (HashMap Text [ProductViewAggregationValue])
      -> Maybe [ProductViewSummary] -> Int -> SearchProductsResponse)
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
"NextPageToken")
            Either
  String
  (Maybe (HashMap Text [ProductViewAggregationValue])
   -> Maybe [ProductViewSummary] -> Int -> SearchProductsResponse)
-> Either
     String (Maybe (HashMap Text [ProductViewAggregationValue]))
-> Either
     String
     (Maybe [ProductViewSummary] -> Int -> SearchProductsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text
-> Either
     String (Maybe (Maybe (HashMap Text [ProductViewAggregationValue])))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ProductViewAggregations"
                            Either
  String (Maybe (Maybe (HashMap Text [ProductViewAggregationValue])))
-> Maybe (HashMap Text [ProductViewAggregationValue])
-> Either
     String (Maybe (HashMap Text [ProductViewAggregationValue]))
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe (HashMap Text [ProductViewAggregationValue])
forall a. Monoid a => a
Prelude.mempty
                        )
            Either
  String
  (Maybe [ProductViewSummary] -> Int -> SearchProductsResponse)
-> Either String (Maybe [ProductViewSummary])
-> Either String (Int -> SearchProductsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Either String (Maybe (Maybe [ProductViewSummary]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ProductViewSummaries"
                            Either String (Maybe (Maybe [ProductViewSummary]))
-> Maybe [ProductViewSummary]
-> Either String (Maybe [ProductViewSummary])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ProductViewSummary]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> SearchProductsResponse)
-> Either String Int -> Either String SearchProductsResponse
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 SearchProducts

instance Prelude.NFData SearchProducts

instance Core.ToHeaders SearchProducts where
  toHeaders :: SearchProducts -> ResponseHeaders
toHeaders =
    ResponseHeaders -> SearchProducts -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWS242ServiceCatalogService.SearchProducts" ::
                          Prelude.ByteString
                      ),
            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 SearchProducts where
  toJSON :: SearchProducts -> Value
toJSON SearchProducts' {Maybe Natural
Maybe Text
Maybe (HashMap ProductViewFilterBy [Text])
Maybe ProductViewSortBy
Maybe SortOrder
sortBy :: Maybe ProductViewSortBy
pageSize :: Maybe Natural
pageToken :: Maybe Text
acceptLanguage :: Maybe Text
sortOrder :: Maybe SortOrder
filters :: Maybe (HashMap ProductViewFilterBy [Text])
$sel:sortBy:SearchProducts' :: SearchProducts -> Maybe ProductViewSortBy
$sel:pageSize:SearchProducts' :: SearchProducts -> Maybe Natural
$sel:pageToken:SearchProducts' :: SearchProducts -> Maybe Text
$sel:acceptLanguage:SearchProducts' :: SearchProducts -> Maybe Text
$sel:sortOrder:SearchProducts' :: SearchProducts -> Maybe SortOrder
$sel:filters:SearchProducts' :: SearchProducts -> Maybe (HashMap ProductViewFilterBy [Text])
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Filters" Text -> HashMap ProductViewFilterBy [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap ProductViewFilterBy [Text] -> Pair)
-> Maybe (HashMap ProductViewFilterBy [Text]) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap ProductViewFilterBy [Text])
filters,
            (Text
"SortOrder" Text -> SortOrder -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SortOrder -> Pair) -> Maybe SortOrder -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SortOrder
sortOrder,
            (Text
"AcceptLanguage" 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
acceptLanguage,
            (Text
"PageToken" 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
pageToken,
            (Text
"PageSize" 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
pageSize,
            (Text
"SortBy" Text -> ProductViewSortBy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ProductViewSortBy -> Pair)
-> Maybe ProductViewSortBy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ProductViewSortBy
sortBy
          ]
      )

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

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

-- | /See:/ 'newSearchProductsResponse' smart constructor.
data SearchProductsResponse = SearchProductsResponse'
  { -- | The page token to use to retrieve the next set of results. If there are
    -- no additional results, this value is null.
    SearchProductsResponse -> Maybe Text
nextPageToken :: Prelude.Maybe Prelude.Text,
    -- | The product view aggregations.
    SearchProductsResponse
-> Maybe (HashMap Text [ProductViewAggregationValue])
productViewAggregations :: Prelude.Maybe (Prelude.HashMap Prelude.Text [ProductViewAggregationValue]),
    -- | Information about the product views.
    SearchProductsResponse -> Maybe [ProductViewSummary]
productViewSummaries :: Prelude.Maybe [ProductViewSummary],
    -- | The response's http status code.
    SearchProductsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SearchProductsResponse -> SearchProductsResponse -> Bool
(SearchProductsResponse -> SearchProductsResponse -> Bool)
-> (SearchProductsResponse -> SearchProductsResponse -> Bool)
-> Eq SearchProductsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchProductsResponse -> SearchProductsResponse -> Bool
$c/= :: SearchProductsResponse -> SearchProductsResponse -> Bool
== :: SearchProductsResponse -> SearchProductsResponse -> Bool
$c== :: SearchProductsResponse -> SearchProductsResponse -> Bool
Prelude.Eq, ReadPrec [SearchProductsResponse]
ReadPrec SearchProductsResponse
Int -> ReadS SearchProductsResponse
ReadS [SearchProductsResponse]
(Int -> ReadS SearchProductsResponse)
-> ReadS [SearchProductsResponse]
-> ReadPrec SearchProductsResponse
-> ReadPrec [SearchProductsResponse]
-> Read SearchProductsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchProductsResponse]
$creadListPrec :: ReadPrec [SearchProductsResponse]
readPrec :: ReadPrec SearchProductsResponse
$creadPrec :: ReadPrec SearchProductsResponse
readList :: ReadS [SearchProductsResponse]
$creadList :: ReadS [SearchProductsResponse]
readsPrec :: Int -> ReadS SearchProductsResponse
$creadsPrec :: Int -> ReadS SearchProductsResponse
Prelude.Read, Int -> SearchProductsResponse -> ShowS
[SearchProductsResponse] -> ShowS
SearchProductsResponse -> String
(Int -> SearchProductsResponse -> ShowS)
-> (SearchProductsResponse -> String)
-> ([SearchProductsResponse] -> ShowS)
-> Show SearchProductsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchProductsResponse] -> ShowS
$cshowList :: [SearchProductsResponse] -> ShowS
show :: SearchProductsResponse -> String
$cshow :: SearchProductsResponse -> String
showsPrec :: Int -> SearchProductsResponse -> ShowS
$cshowsPrec :: Int -> SearchProductsResponse -> ShowS
Prelude.Show, (forall x. SearchProductsResponse -> Rep SearchProductsResponse x)
-> (forall x.
    Rep SearchProductsResponse x -> SearchProductsResponse)
-> Generic SearchProductsResponse
forall x. Rep SearchProductsResponse x -> SearchProductsResponse
forall x. SearchProductsResponse -> Rep SearchProductsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchProductsResponse x -> SearchProductsResponse
$cfrom :: forall x. SearchProductsResponse -> Rep SearchProductsResponse x
Prelude.Generic)

-- |
-- Create a value of 'SearchProductsResponse' 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:
--
-- 'nextPageToken', 'searchProductsResponse_nextPageToken' - The page token to use to retrieve the next set of results. If there are
-- no additional results, this value is null.
--
-- 'productViewAggregations', 'searchProductsResponse_productViewAggregations' - The product view aggregations.
--
-- 'productViewSummaries', 'searchProductsResponse_productViewSummaries' - Information about the product views.
--
-- 'httpStatus', 'searchProductsResponse_httpStatus' - The response's http status code.
newSearchProductsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SearchProductsResponse
newSearchProductsResponse :: Int -> SearchProductsResponse
newSearchProductsResponse Int
pHttpStatus_ =
  SearchProductsResponse' :: Maybe Text
-> Maybe (HashMap Text [ProductViewAggregationValue])
-> Maybe [ProductViewSummary]
-> Int
-> SearchProductsResponse
SearchProductsResponse'
    { $sel:nextPageToken:SearchProductsResponse' :: Maybe Text
nextPageToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:productViewAggregations:SearchProductsResponse' :: Maybe (HashMap Text [ProductViewAggregationValue])
productViewAggregations = Maybe (HashMap Text [ProductViewAggregationValue])
forall a. Maybe a
Prelude.Nothing,
      $sel:productViewSummaries:SearchProductsResponse' :: Maybe [ProductViewSummary]
productViewSummaries = Maybe [ProductViewSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SearchProductsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The page token to use to retrieve the next set of results. If there are
-- no additional results, this value is null.
searchProductsResponse_nextPageToken :: Lens.Lens' SearchProductsResponse (Prelude.Maybe Prelude.Text)
searchProductsResponse_nextPageToken :: (Maybe Text -> f (Maybe Text))
-> SearchProductsResponse -> f SearchProductsResponse
searchProductsResponse_nextPageToken = (SearchProductsResponse -> Maybe Text)
-> (SearchProductsResponse -> Maybe Text -> SearchProductsResponse)
-> Lens
     SearchProductsResponse
     SearchProductsResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProductsResponse' {Maybe Text
nextPageToken :: Maybe Text
$sel:nextPageToken:SearchProductsResponse' :: SearchProductsResponse -> Maybe Text
nextPageToken} -> Maybe Text
nextPageToken) (\s :: SearchProductsResponse
s@SearchProductsResponse' {} Maybe Text
a -> SearchProductsResponse
s {$sel:nextPageToken:SearchProductsResponse' :: Maybe Text
nextPageToken = Maybe Text
a} :: SearchProductsResponse)

-- | The product view aggregations.
searchProductsResponse_productViewAggregations :: Lens.Lens' SearchProductsResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text [ProductViewAggregationValue]))
searchProductsResponse_productViewAggregations :: (Maybe (HashMap Text [ProductViewAggregationValue])
 -> f (Maybe (HashMap Text [ProductViewAggregationValue])))
-> SearchProductsResponse -> f SearchProductsResponse
searchProductsResponse_productViewAggregations = (SearchProductsResponse
 -> Maybe (HashMap Text [ProductViewAggregationValue]))
-> (SearchProductsResponse
    -> Maybe (HashMap Text [ProductViewAggregationValue])
    -> SearchProductsResponse)
-> Lens
     SearchProductsResponse
     SearchProductsResponse
     (Maybe (HashMap Text [ProductViewAggregationValue]))
     (Maybe (HashMap Text [ProductViewAggregationValue]))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProductsResponse' {Maybe (HashMap Text [ProductViewAggregationValue])
productViewAggregations :: Maybe (HashMap Text [ProductViewAggregationValue])
$sel:productViewAggregations:SearchProductsResponse' :: SearchProductsResponse
-> Maybe (HashMap Text [ProductViewAggregationValue])
productViewAggregations} -> Maybe (HashMap Text [ProductViewAggregationValue])
productViewAggregations) (\s :: SearchProductsResponse
s@SearchProductsResponse' {} Maybe (HashMap Text [ProductViewAggregationValue])
a -> SearchProductsResponse
s {$sel:productViewAggregations:SearchProductsResponse' :: Maybe (HashMap Text [ProductViewAggregationValue])
productViewAggregations = Maybe (HashMap Text [ProductViewAggregationValue])
a} :: SearchProductsResponse) ((Maybe (HashMap Text [ProductViewAggregationValue])
  -> f (Maybe (HashMap Text [ProductViewAggregationValue])))
 -> SearchProductsResponse -> f SearchProductsResponse)
-> ((Maybe (HashMap Text [ProductViewAggregationValue])
     -> f (Maybe (HashMap Text [ProductViewAggregationValue])))
    -> Maybe (HashMap Text [ProductViewAggregationValue])
    -> f (Maybe (HashMap Text [ProductViewAggregationValue])))
-> (Maybe (HashMap Text [ProductViewAggregationValue])
    -> f (Maybe (HashMap Text [ProductViewAggregationValue])))
-> SearchProductsResponse
-> f SearchProductsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text [ProductViewAggregationValue])
  (HashMap Text [ProductViewAggregationValue])
  (HashMap Text [ProductViewAggregationValue])
  (HashMap Text [ProductViewAggregationValue])
-> Iso
     (Maybe (HashMap Text [ProductViewAggregationValue]))
     (Maybe (HashMap Text [ProductViewAggregationValue]))
     (Maybe (HashMap Text [ProductViewAggregationValue]))
     (Maybe (HashMap Text [ProductViewAggregationValue]))
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
  (HashMap Text [ProductViewAggregationValue])
  (HashMap Text [ProductViewAggregationValue])
  (HashMap Text [ProductViewAggregationValue])
  (HashMap Text [ProductViewAggregationValue])
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Information about the product views.
searchProductsResponse_productViewSummaries :: Lens.Lens' SearchProductsResponse (Prelude.Maybe [ProductViewSummary])
searchProductsResponse_productViewSummaries :: (Maybe [ProductViewSummary] -> f (Maybe [ProductViewSummary]))
-> SearchProductsResponse -> f SearchProductsResponse
searchProductsResponse_productViewSummaries = (SearchProductsResponse -> Maybe [ProductViewSummary])
-> (SearchProductsResponse
    -> Maybe [ProductViewSummary] -> SearchProductsResponse)
-> Lens
     SearchProductsResponse
     SearchProductsResponse
     (Maybe [ProductViewSummary])
     (Maybe [ProductViewSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchProductsResponse' {Maybe [ProductViewSummary]
productViewSummaries :: Maybe [ProductViewSummary]
$sel:productViewSummaries:SearchProductsResponse' :: SearchProductsResponse -> Maybe [ProductViewSummary]
productViewSummaries} -> Maybe [ProductViewSummary]
productViewSummaries) (\s :: SearchProductsResponse
s@SearchProductsResponse' {} Maybe [ProductViewSummary]
a -> SearchProductsResponse
s {$sel:productViewSummaries:SearchProductsResponse' :: Maybe [ProductViewSummary]
productViewSummaries = Maybe [ProductViewSummary]
a} :: SearchProductsResponse) ((Maybe [ProductViewSummary] -> f (Maybe [ProductViewSummary]))
 -> SearchProductsResponse -> f SearchProductsResponse)
-> ((Maybe [ProductViewSummary] -> f (Maybe [ProductViewSummary]))
    -> Maybe [ProductViewSummary] -> f (Maybe [ProductViewSummary]))
-> (Maybe [ProductViewSummary] -> f (Maybe [ProductViewSummary]))
-> SearchProductsResponse
-> f SearchProductsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ProductViewSummary]
  [ProductViewSummary]
  [ProductViewSummary]
  [ProductViewSummary]
-> Iso
     (Maybe [ProductViewSummary])
     (Maybe [ProductViewSummary])
     (Maybe [ProductViewSummary])
     (Maybe [ProductViewSummary])
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
  [ProductViewSummary]
  [ProductViewSummary]
  [ProductViewSummary]
  [ProductViewSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData SearchProductsResponse