{-# 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.SageMaker.Search
-- 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)
--
-- Finds Amazon SageMaker resources that match a search query. Matching
-- resources are returned as a list of @SearchRecord@ objects in the
-- response. You can sort the search results by any resource property in a
-- ascending or descending order.
--
-- You can query against the following value types: numeric, text, Boolean,
-- and timestamp.
--
-- This operation returns paginated results.
module Amazonka.SageMaker.Search
  ( -- * Creating a Request
    Search (..),
    newSearch,

    -- * Request Lenses
    search_nextToken,
    search_searchExpression,
    search_sortOrder,
    search_maxResults,
    search_sortBy,
    search_resource,

    -- * Destructuring the Response
    SearchResponse (..),
    newSearchResponse,

    -- * Response Lenses
    searchResponse_results,
    searchResponse_nextToken,
    searchResponse_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.SageMaker.Types

-- | /See:/ 'newSearch' smart constructor.
data Search = Search'
  { -- | If more than @MaxResults@ resources match the specified
    -- @SearchExpression@, the response includes a @NextToken@. The @NextToken@
    -- can be passed to the next @SearchRequest@ to continue retrieving
    -- results.
    Search -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A Boolean conditional statement. Resources must satisfy this condition
    -- to be included in search results. You must provide at least one
    -- subexpression, filter, or nested filter. The maximum number of recursive
    -- @SubExpressions@, @NestedFilters@, and @Filters@ that can be included in
    -- a @SearchExpression@ object is 50.
    Search -> Maybe SearchExpression
searchExpression :: Prelude.Maybe SearchExpression,
    -- | How @SearchResults@ are ordered. Valid values are @Ascending@ or
    -- @Descending@. The default is @Descending@.
    Search -> Maybe SearchSortOrder
sortOrder :: Prelude.Maybe SearchSortOrder,
    -- | The maximum number of results to return.
    Search -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The name of the resource property used to sort the @SearchResults@. The
    -- default is @LastModifiedTime@.
    Search -> Maybe Text
sortBy :: Prelude.Maybe Prelude.Text,
    -- | The name of the Amazon SageMaker resource to search for.
    Search -> ResourceType
resource :: ResourceType
  }
  deriving (Search -> Search -> Bool
(Search -> Search -> Bool)
-> (Search -> Search -> Bool) -> Eq Search
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Search -> Search -> Bool
$c/= :: Search -> Search -> Bool
== :: Search -> Search -> Bool
$c== :: Search -> Search -> Bool
Prelude.Eq, ReadPrec [Search]
ReadPrec Search
Int -> ReadS Search
ReadS [Search]
(Int -> ReadS Search)
-> ReadS [Search]
-> ReadPrec Search
-> ReadPrec [Search]
-> Read Search
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Search]
$creadListPrec :: ReadPrec [Search]
readPrec :: ReadPrec Search
$creadPrec :: ReadPrec Search
readList :: ReadS [Search]
$creadList :: ReadS [Search]
readsPrec :: Int -> ReadS Search
$creadsPrec :: Int -> ReadS Search
Prelude.Read, Int -> Search -> ShowS
[Search] -> ShowS
Search -> String
(Int -> Search -> ShowS)
-> (Search -> String) -> ([Search] -> ShowS) -> Show Search
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Search] -> ShowS
$cshowList :: [Search] -> ShowS
show :: Search -> String
$cshow :: Search -> String
showsPrec :: Int -> Search -> ShowS
$cshowsPrec :: Int -> Search -> ShowS
Prelude.Show, (forall x. Search -> Rep Search x)
-> (forall x. Rep Search x -> Search) -> Generic Search
forall x. Rep Search x -> Search
forall x. Search -> Rep Search x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Search x -> Search
$cfrom :: forall x. Search -> Rep Search x
Prelude.Generic)

-- |
-- Create a value of 'Search' 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', 'search_nextToken' - If more than @MaxResults@ resources match the specified
-- @SearchExpression@, the response includes a @NextToken@. The @NextToken@
-- can be passed to the next @SearchRequest@ to continue retrieving
-- results.
--
-- 'searchExpression', 'search_searchExpression' - A Boolean conditional statement. Resources must satisfy this condition
-- to be included in search results. You must provide at least one
-- subexpression, filter, or nested filter. The maximum number of recursive
-- @SubExpressions@, @NestedFilters@, and @Filters@ that can be included in
-- a @SearchExpression@ object is 50.
--
-- 'sortOrder', 'search_sortOrder' - How @SearchResults@ are ordered. Valid values are @Ascending@ or
-- @Descending@. The default is @Descending@.
--
-- 'maxResults', 'search_maxResults' - The maximum number of results to return.
--
-- 'sortBy', 'search_sortBy' - The name of the resource property used to sort the @SearchResults@. The
-- default is @LastModifiedTime@.
--
-- 'resource', 'search_resource' - The name of the Amazon SageMaker resource to search for.
newSearch ::
  -- | 'resource'
  ResourceType ->
  Search
newSearch :: ResourceType -> Search
newSearch ResourceType
pResource_ =
  Search' :: Maybe Text
-> Maybe SearchExpression
-> Maybe SearchSortOrder
-> Maybe Natural
-> Maybe Text
-> ResourceType
-> Search
Search'
    { $sel:nextToken:Search' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:searchExpression:Search' :: Maybe SearchExpression
searchExpression = Maybe SearchExpression
forall a. Maybe a
Prelude.Nothing,
      $sel:sortOrder:Search' :: Maybe SearchSortOrder
sortOrder = Maybe SearchSortOrder
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:Search' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:sortBy:Search' :: Maybe Text
sortBy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resource:Search' :: ResourceType
resource = ResourceType
pResource_
    }

-- | If more than @MaxResults@ resources match the specified
-- @SearchExpression@, the response includes a @NextToken@. The @NextToken@
-- can be passed to the next @SearchRequest@ to continue retrieving
-- results.
search_nextToken :: Lens.Lens' Search (Prelude.Maybe Prelude.Text)
search_nextToken :: (Maybe Text -> f (Maybe Text)) -> Search -> f Search
search_nextToken = (Search -> Maybe Text)
-> (Search -> Maybe Text -> Search)
-> Lens Search Search (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Search' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:Search' :: Search -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: Search
s@Search' {} Maybe Text
a -> Search
s {$sel:nextToken:Search' :: Maybe Text
nextToken = Maybe Text
a} :: Search)

-- | A Boolean conditional statement. Resources must satisfy this condition
-- to be included in search results. You must provide at least one
-- subexpression, filter, or nested filter. The maximum number of recursive
-- @SubExpressions@, @NestedFilters@, and @Filters@ that can be included in
-- a @SearchExpression@ object is 50.
search_searchExpression :: Lens.Lens' Search (Prelude.Maybe SearchExpression)
search_searchExpression :: (Maybe SearchExpression -> f (Maybe SearchExpression))
-> Search -> f Search
search_searchExpression = (Search -> Maybe SearchExpression)
-> (Search -> Maybe SearchExpression -> Search)
-> Lens
     Search Search (Maybe SearchExpression) (Maybe SearchExpression)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Search' {Maybe SearchExpression
searchExpression :: Maybe SearchExpression
$sel:searchExpression:Search' :: Search -> Maybe SearchExpression
searchExpression} -> Maybe SearchExpression
searchExpression) (\s :: Search
s@Search' {} Maybe SearchExpression
a -> Search
s {$sel:searchExpression:Search' :: Maybe SearchExpression
searchExpression = Maybe SearchExpression
a} :: Search)

-- | How @SearchResults@ are ordered. Valid values are @Ascending@ or
-- @Descending@. The default is @Descending@.
search_sortOrder :: Lens.Lens' Search (Prelude.Maybe SearchSortOrder)
search_sortOrder :: (Maybe SearchSortOrder -> f (Maybe SearchSortOrder))
-> Search -> f Search
search_sortOrder = (Search -> Maybe SearchSortOrder)
-> (Search -> Maybe SearchSortOrder -> Search)
-> Lens
     Search Search (Maybe SearchSortOrder) (Maybe SearchSortOrder)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Search' {Maybe SearchSortOrder
sortOrder :: Maybe SearchSortOrder
$sel:sortOrder:Search' :: Search -> Maybe SearchSortOrder
sortOrder} -> Maybe SearchSortOrder
sortOrder) (\s :: Search
s@Search' {} Maybe SearchSortOrder
a -> Search
s {$sel:sortOrder:Search' :: Maybe SearchSortOrder
sortOrder = Maybe SearchSortOrder
a} :: Search)

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

-- | The name of the resource property used to sort the @SearchResults@. The
-- default is @LastModifiedTime@.
search_sortBy :: Lens.Lens' Search (Prelude.Maybe Prelude.Text)
search_sortBy :: (Maybe Text -> f (Maybe Text)) -> Search -> f Search
search_sortBy = (Search -> Maybe Text)
-> (Search -> Maybe Text -> Search)
-> Lens Search Search (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Search' {Maybe Text
sortBy :: Maybe Text
$sel:sortBy:Search' :: Search -> Maybe Text
sortBy} -> Maybe Text
sortBy) (\s :: Search
s@Search' {} Maybe Text
a -> Search
s {$sel:sortBy:Search' :: Maybe Text
sortBy = Maybe Text
a} :: Search)

-- | The name of the Amazon SageMaker resource to search for.
search_resource :: Lens.Lens' Search ResourceType
search_resource :: (ResourceType -> f ResourceType) -> Search -> f Search
search_resource = (Search -> ResourceType)
-> (Search -> ResourceType -> Search)
-> Lens Search Search ResourceType ResourceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Search' {ResourceType
resource :: ResourceType
$sel:resource:Search' :: Search -> ResourceType
resource} -> ResourceType
resource) (\s :: Search
s@Search' {} ResourceType
a -> Search
s {$sel:resource:Search' :: ResourceType
resource = ResourceType
a} :: Search)

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

instance Prelude.NFData Search

instance Core.ToHeaders Search where
  toHeaders :: Search -> ResponseHeaders
toHeaders =
    ResponseHeaders -> Search -> 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
"SageMaker.Search" :: 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 Search where
  toJSON :: Search -> Value
toJSON Search' {Maybe Natural
Maybe Text
Maybe SearchExpression
Maybe SearchSortOrder
ResourceType
resource :: ResourceType
sortBy :: Maybe Text
maxResults :: Maybe Natural
sortOrder :: Maybe SearchSortOrder
searchExpression :: Maybe SearchExpression
nextToken :: Maybe Text
$sel:resource:Search' :: Search -> ResourceType
$sel:sortBy:Search' :: Search -> Maybe Text
$sel:maxResults:Search' :: Search -> Maybe Natural
$sel:sortOrder:Search' :: Search -> Maybe SearchSortOrder
$sel:searchExpression:Search' :: Search -> Maybe SearchExpression
$sel:nextToken:Search' :: Search -> 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
"SearchExpression" Text -> SearchExpression -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SearchExpression -> Pair) -> Maybe SearchExpression -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SearchExpression
searchExpression,
            (Text
"SortOrder" Text -> SearchSortOrder -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SearchSortOrder -> Pair) -> Maybe SearchSortOrder -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SearchSortOrder
sortOrder,
            (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,
            (Text
"SortBy" 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
sortBy,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Resource" Text -> ResourceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ResourceType
resource)
          ]
      )

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

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

-- | /See:/ 'newSearchResponse' smart constructor.
data SearchResponse = SearchResponse'
  { -- | A list of @SearchRecord@ objects.
    SearchResponse -> Maybe [SearchRecord]
results :: Prelude.Maybe [SearchRecord],
    -- | If the result of the previous @Search@ request was truncated, the
    -- response includes a NextToken. To retrieve the next set of results, use
    -- the token in the next request.
    SearchResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    SearchResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SearchResponse -> SearchResponse -> Bool
(SearchResponse -> SearchResponse -> Bool)
-> (SearchResponse -> SearchResponse -> Bool) -> Eq SearchResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchResponse -> SearchResponse -> Bool
$c/= :: SearchResponse -> SearchResponse -> Bool
== :: SearchResponse -> SearchResponse -> Bool
$c== :: SearchResponse -> SearchResponse -> Bool
Prelude.Eq, ReadPrec [SearchResponse]
ReadPrec SearchResponse
Int -> ReadS SearchResponse
ReadS [SearchResponse]
(Int -> ReadS SearchResponse)
-> ReadS [SearchResponse]
-> ReadPrec SearchResponse
-> ReadPrec [SearchResponse]
-> Read SearchResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchResponse]
$creadListPrec :: ReadPrec [SearchResponse]
readPrec :: ReadPrec SearchResponse
$creadPrec :: ReadPrec SearchResponse
readList :: ReadS [SearchResponse]
$creadList :: ReadS [SearchResponse]
readsPrec :: Int -> ReadS SearchResponse
$creadsPrec :: Int -> ReadS SearchResponse
Prelude.Read, Int -> SearchResponse -> ShowS
[SearchResponse] -> ShowS
SearchResponse -> String
(Int -> SearchResponse -> ShowS)
-> (SearchResponse -> String)
-> ([SearchResponse] -> ShowS)
-> Show SearchResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchResponse] -> ShowS
$cshowList :: [SearchResponse] -> ShowS
show :: SearchResponse -> String
$cshow :: SearchResponse -> String
showsPrec :: Int -> SearchResponse -> ShowS
$cshowsPrec :: Int -> SearchResponse -> ShowS
Prelude.Show, (forall x. SearchResponse -> Rep SearchResponse x)
-> (forall x. Rep SearchResponse x -> SearchResponse)
-> Generic SearchResponse
forall x. Rep SearchResponse x -> SearchResponse
forall x. SearchResponse -> Rep SearchResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchResponse x -> SearchResponse
$cfrom :: forall x. SearchResponse -> Rep SearchResponse x
Prelude.Generic)

-- |
-- Create a value of 'SearchResponse' 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:
--
-- 'results', 'searchResponse_results' - A list of @SearchRecord@ objects.
--
-- 'nextToken', 'searchResponse_nextToken' - If the result of the previous @Search@ request was truncated, the
-- response includes a NextToken. To retrieve the next set of results, use
-- the token in the next request.
--
-- 'httpStatus', 'searchResponse_httpStatus' - The response's http status code.
newSearchResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SearchResponse
newSearchResponse :: Int -> SearchResponse
newSearchResponse Int
pHttpStatus_ =
  SearchResponse' :: Maybe [SearchRecord] -> Maybe Text -> Int -> SearchResponse
SearchResponse'
    { $sel:results:SearchResponse' :: Maybe [SearchRecord]
results = Maybe [SearchRecord]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:SearchResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SearchResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of @SearchRecord@ objects.
searchResponse_results :: Lens.Lens' SearchResponse (Prelude.Maybe [SearchRecord])
searchResponse_results :: (Maybe [SearchRecord] -> f (Maybe [SearchRecord]))
-> SearchResponse -> f SearchResponse
searchResponse_results = (SearchResponse -> Maybe [SearchRecord])
-> (SearchResponse -> Maybe [SearchRecord] -> SearchResponse)
-> Lens' SearchResponse (Maybe [SearchRecord])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchResponse' {Maybe [SearchRecord]
results :: Maybe [SearchRecord]
$sel:results:SearchResponse' :: SearchResponse -> Maybe [SearchRecord]
results} -> Maybe [SearchRecord]
results) (\s :: SearchResponse
s@SearchResponse' {} Maybe [SearchRecord]
a -> SearchResponse
s {$sel:results:SearchResponse' :: Maybe [SearchRecord]
results = Maybe [SearchRecord]
a} :: SearchResponse) ((Maybe [SearchRecord] -> f (Maybe [SearchRecord]))
 -> SearchResponse -> f SearchResponse)
-> ((Maybe [SearchRecord] -> f (Maybe [SearchRecord]))
    -> Maybe [SearchRecord] -> f (Maybe [SearchRecord]))
-> (Maybe [SearchRecord] -> f (Maybe [SearchRecord]))
-> SearchResponse
-> f SearchResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [SearchRecord] [SearchRecord] [SearchRecord] [SearchRecord]
-> Iso
     (Maybe [SearchRecord])
     (Maybe [SearchRecord])
     (Maybe [SearchRecord])
     (Maybe [SearchRecord])
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 [SearchRecord] [SearchRecord] [SearchRecord] [SearchRecord]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If the result of the previous @Search@ request was truncated, the
-- response includes a NextToken. To retrieve the next set of results, use
-- the token in the next request.
searchResponse_nextToken :: Lens.Lens' SearchResponse (Prelude.Maybe Prelude.Text)
searchResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> SearchResponse -> f SearchResponse
searchResponse_nextToken = (SearchResponse -> Maybe Text)
-> (SearchResponse -> Maybe Text -> SearchResponse)
-> Lens' SearchResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchResponse' :: SearchResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchResponse
s@SearchResponse' {} Maybe Text
a -> SearchResponse
s {$sel:nextToken:SearchResponse' :: Maybe Text
nextToken = Maybe Text
a} :: SearchResponse)

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

instance Prelude.NFData SearchResponse