{-# 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.IoTThingsGraph.SearchThings
-- 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 things associated with the specified entity. You can search
-- by both device and device model.
--
-- For example, if two different devices, camera1 and camera2, implement
-- the camera device model, the user can associate thing1 to camera1 and
-- thing2 to camera2. @SearchThings(camera2)@ will return only thing2, but
-- @SearchThings(camera)@ will return both thing1 and thing2.
--
-- This action searches for exact matches and doesn\'t perform partial text
-- matching.
--
-- This operation returns paginated results.
module Amazonka.IoTThingsGraph.SearchThings
  ( -- * Creating a Request
    SearchThings (..),
    newSearchThings,

    -- * Request Lenses
    searchThings_namespaceVersion,
    searchThings_nextToken,
    searchThings_maxResults,
    searchThings_entityId,

    -- * Destructuring the Response
    SearchThingsResponse (..),
    newSearchThingsResponse,

    -- * Response Lenses
    searchThingsResponse_nextToken,
    searchThingsResponse_things,
    searchThingsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newSearchThings' smart constructor.
data SearchThings = SearchThings'
  { -- | The version of the user\'s namespace. Defaults to the latest version of
    -- the user\'s namespace.
    SearchThings -> Maybe Integer
namespaceVersion :: Prelude.Maybe Prelude.Integer,
    -- | The string that specifies the next page of results. Use this when
    -- you\'re paginating results.
    SearchThings -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return in the response.
    SearchThings -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The ID of the entity to which the things are associated.
    --
    -- The IDs should be in the following format.
    --
    -- @urn:tdm:REGION\/ACCOUNT ID\/default:device:DEVICENAME@
    SearchThings -> Text
entityId :: Prelude.Text
  }
  deriving (SearchThings -> SearchThings -> Bool
(SearchThings -> SearchThings -> Bool)
-> (SearchThings -> SearchThings -> Bool) -> Eq SearchThings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchThings -> SearchThings -> Bool
$c/= :: SearchThings -> SearchThings -> Bool
== :: SearchThings -> SearchThings -> Bool
$c== :: SearchThings -> SearchThings -> Bool
Prelude.Eq, ReadPrec [SearchThings]
ReadPrec SearchThings
Int -> ReadS SearchThings
ReadS [SearchThings]
(Int -> ReadS SearchThings)
-> ReadS [SearchThings]
-> ReadPrec SearchThings
-> ReadPrec [SearchThings]
-> Read SearchThings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchThings]
$creadListPrec :: ReadPrec [SearchThings]
readPrec :: ReadPrec SearchThings
$creadPrec :: ReadPrec SearchThings
readList :: ReadS [SearchThings]
$creadList :: ReadS [SearchThings]
readsPrec :: Int -> ReadS SearchThings
$creadsPrec :: Int -> ReadS SearchThings
Prelude.Read, Int -> SearchThings -> ShowS
[SearchThings] -> ShowS
SearchThings -> String
(Int -> SearchThings -> ShowS)
-> (SearchThings -> String)
-> ([SearchThings] -> ShowS)
-> Show SearchThings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchThings] -> ShowS
$cshowList :: [SearchThings] -> ShowS
show :: SearchThings -> String
$cshow :: SearchThings -> String
showsPrec :: Int -> SearchThings -> ShowS
$cshowsPrec :: Int -> SearchThings -> ShowS
Prelude.Show, (forall x. SearchThings -> Rep SearchThings x)
-> (forall x. Rep SearchThings x -> SearchThings)
-> Generic SearchThings
forall x. Rep SearchThings x -> SearchThings
forall x. SearchThings -> Rep SearchThings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchThings x -> SearchThings
$cfrom :: forall x. SearchThings -> Rep SearchThings x
Prelude.Generic)

-- |
-- Create a value of 'SearchThings' 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:
--
-- 'namespaceVersion', 'searchThings_namespaceVersion' - The version of the user\'s namespace. Defaults to the latest version of
-- the user\'s namespace.
--
-- 'nextToken', 'searchThings_nextToken' - The string that specifies the next page of results. Use this when
-- you\'re paginating results.
--
-- 'maxResults', 'searchThings_maxResults' - The maximum number of results to return in the response.
--
-- 'entityId', 'searchThings_entityId' - The ID of the entity to which the things are associated.
--
-- The IDs should be in the following format.
--
-- @urn:tdm:REGION\/ACCOUNT ID\/default:device:DEVICENAME@
newSearchThings ::
  -- | 'entityId'
  Prelude.Text ->
  SearchThings
newSearchThings :: Text -> SearchThings
newSearchThings Text
pEntityId_ =
  SearchThings' :: Maybe Integer
-> Maybe Text -> Maybe Natural -> Text -> SearchThings
SearchThings'
    { $sel:namespaceVersion:SearchThings' :: Maybe Integer
namespaceVersion = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:SearchThings' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:SearchThings' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:entityId:SearchThings' :: Text
entityId = Text
pEntityId_
    }

-- | The version of the user\'s namespace. Defaults to the latest version of
-- the user\'s namespace.
searchThings_namespaceVersion :: Lens.Lens' SearchThings (Prelude.Maybe Prelude.Integer)
searchThings_namespaceVersion :: (Maybe Integer -> f (Maybe Integer))
-> SearchThings -> f SearchThings
searchThings_namespaceVersion = (SearchThings -> Maybe Integer)
-> (SearchThings -> Maybe Integer -> SearchThings)
-> Lens SearchThings SearchThings (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchThings' {Maybe Integer
namespaceVersion :: Maybe Integer
$sel:namespaceVersion:SearchThings' :: SearchThings -> Maybe Integer
namespaceVersion} -> Maybe Integer
namespaceVersion) (\s :: SearchThings
s@SearchThings' {} Maybe Integer
a -> SearchThings
s {$sel:namespaceVersion:SearchThings' :: Maybe Integer
namespaceVersion = Maybe Integer
a} :: SearchThings)

-- | The string that specifies the next page of results. Use this when
-- you\'re paginating results.
searchThings_nextToken :: Lens.Lens' SearchThings (Prelude.Maybe Prelude.Text)
searchThings_nextToken :: (Maybe Text -> f (Maybe Text)) -> SearchThings -> f SearchThings
searchThings_nextToken = (SearchThings -> Maybe Text)
-> (SearchThings -> Maybe Text -> SearchThings)
-> Lens SearchThings SearchThings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchThings' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchThings' :: SearchThings -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchThings
s@SearchThings' {} Maybe Text
a -> SearchThings
s {$sel:nextToken:SearchThings' :: Maybe Text
nextToken = Maybe Text
a} :: SearchThings)

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

-- | The ID of the entity to which the things are associated.
--
-- The IDs should be in the following format.
--
-- @urn:tdm:REGION\/ACCOUNT ID\/default:device:DEVICENAME@
searchThings_entityId :: Lens.Lens' SearchThings Prelude.Text
searchThings_entityId :: (Text -> f Text) -> SearchThings -> f SearchThings
searchThings_entityId = (SearchThings -> Text)
-> (SearchThings -> Text -> SearchThings)
-> Lens SearchThings SearchThings Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchThings' {Text
entityId :: Text
$sel:entityId:SearchThings' :: SearchThings -> Text
entityId} -> Text
entityId) (\s :: SearchThings
s@SearchThings' {} Text
a -> SearchThings
s {$sel:entityId:SearchThings' :: Text
entityId = Text
a} :: SearchThings)

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

instance Prelude.NFData SearchThings

instance Core.ToHeaders SearchThings where
  toHeaders :: SearchThings -> ResponseHeaders
toHeaders =
    ResponseHeaders -> SearchThings -> 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
"IotThingsGraphFrontEndService.SearchThings" ::
                          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 SearchThings where
  toJSON :: SearchThings -> Value
toJSON SearchThings' {Maybe Integer
Maybe Natural
Maybe Text
Text
entityId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
namespaceVersion :: Maybe Integer
$sel:entityId:SearchThings' :: SearchThings -> Text
$sel:maxResults:SearchThings' :: SearchThings -> Maybe Natural
$sel:nextToken:SearchThings' :: SearchThings -> Maybe Text
$sel:namespaceVersion:SearchThings' :: SearchThings -> Maybe Integer
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"namespaceVersion" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
namespaceVersion,
            (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
"entityId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
entityId)
          ]
      )

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

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

-- | /See:/ 'newSearchThingsResponse' smart constructor.
data SearchThingsResponse = SearchThingsResponse'
  { -- | The string to specify as @nextToken@ when you request the next page of
    -- results.
    SearchThingsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of things in the result set.
    SearchThingsResponse -> Maybe [Thing]
things :: Prelude.Maybe [Thing],
    -- | The response's http status code.
    SearchThingsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SearchThingsResponse -> SearchThingsResponse -> Bool
(SearchThingsResponse -> SearchThingsResponse -> Bool)
-> (SearchThingsResponse -> SearchThingsResponse -> Bool)
-> Eq SearchThingsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchThingsResponse -> SearchThingsResponse -> Bool
$c/= :: SearchThingsResponse -> SearchThingsResponse -> Bool
== :: SearchThingsResponse -> SearchThingsResponse -> Bool
$c== :: SearchThingsResponse -> SearchThingsResponse -> Bool
Prelude.Eq, ReadPrec [SearchThingsResponse]
ReadPrec SearchThingsResponse
Int -> ReadS SearchThingsResponse
ReadS [SearchThingsResponse]
(Int -> ReadS SearchThingsResponse)
-> ReadS [SearchThingsResponse]
-> ReadPrec SearchThingsResponse
-> ReadPrec [SearchThingsResponse]
-> Read SearchThingsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchThingsResponse]
$creadListPrec :: ReadPrec [SearchThingsResponse]
readPrec :: ReadPrec SearchThingsResponse
$creadPrec :: ReadPrec SearchThingsResponse
readList :: ReadS [SearchThingsResponse]
$creadList :: ReadS [SearchThingsResponse]
readsPrec :: Int -> ReadS SearchThingsResponse
$creadsPrec :: Int -> ReadS SearchThingsResponse
Prelude.Read, Int -> SearchThingsResponse -> ShowS
[SearchThingsResponse] -> ShowS
SearchThingsResponse -> String
(Int -> SearchThingsResponse -> ShowS)
-> (SearchThingsResponse -> String)
-> ([SearchThingsResponse] -> ShowS)
-> Show SearchThingsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchThingsResponse] -> ShowS
$cshowList :: [SearchThingsResponse] -> ShowS
show :: SearchThingsResponse -> String
$cshow :: SearchThingsResponse -> String
showsPrec :: Int -> SearchThingsResponse -> ShowS
$cshowsPrec :: Int -> SearchThingsResponse -> ShowS
Prelude.Show, (forall x. SearchThingsResponse -> Rep SearchThingsResponse x)
-> (forall x. Rep SearchThingsResponse x -> SearchThingsResponse)
-> Generic SearchThingsResponse
forall x. Rep SearchThingsResponse x -> SearchThingsResponse
forall x. SearchThingsResponse -> Rep SearchThingsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchThingsResponse x -> SearchThingsResponse
$cfrom :: forall x. SearchThingsResponse -> Rep SearchThingsResponse x
Prelude.Generic)

-- |
-- Create a value of 'SearchThingsResponse' 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', 'searchThingsResponse_nextToken' - The string to specify as @nextToken@ when you request the next page of
-- results.
--
-- 'things', 'searchThingsResponse_things' - An array of things in the result set.
--
-- 'httpStatus', 'searchThingsResponse_httpStatus' - The response's http status code.
newSearchThingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SearchThingsResponse
newSearchThingsResponse :: Int -> SearchThingsResponse
newSearchThingsResponse Int
pHttpStatus_ =
  SearchThingsResponse' :: Maybe Text -> Maybe [Thing] -> Int -> SearchThingsResponse
SearchThingsResponse'
    { $sel:nextToken:SearchThingsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:things:SearchThingsResponse' :: Maybe [Thing]
things = Maybe [Thing]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SearchThingsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The string to specify as @nextToken@ when you request the next page of
-- results.
searchThingsResponse_nextToken :: Lens.Lens' SearchThingsResponse (Prelude.Maybe Prelude.Text)
searchThingsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> SearchThingsResponse -> f SearchThingsResponse
searchThingsResponse_nextToken = (SearchThingsResponse -> Maybe Text)
-> (SearchThingsResponse -> Maybe Text -> SearchThingsResponse)
-> Lens' SearchThingsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchThingsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchThingsResponse' :: SearchThingsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchThingsResponse
s@SearchThingsResponse' {} Maybe Text
a -> SearchThingsResponse
s {$sel:nextToken:SearchThingsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: SearchThingsResponse)

-- | An array of things in the result set.
searchThingsResponse_things :: Lens.Lens' SearchThingsResponse (Prelude.Maybe [Thing])
searchThingsResponse_things :: (Maybe [Thing] -> f (Maybe [Thing]))
-> SearchThingsResponse -> f SearchThingsResponse
searchThingsResponse_things = (SearchThingsResponse -> Maybe [Thing])
-> (SearchThingsResponse -> Maybe [Thing] -> SearchThingsResponse)
-> Lens' SearchThingsResponse (Maybe [Thing])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchThingsResponse' {Maybe [Thing]
things :: Maybe [Thing]
$sel:things:SearchThingsResponse' :: SearchThingsResponse -> Maybe [Thing]
things} -> Maybe [Thing]
things) (\s :: SearchThingsResponse
s@SearchThingsResponse' {} Maybe [Thing]
a -> SearchThingsResponse
s {$sel:things:SearchThingsResponse' :: Maybe [Thing]
things = Maybe [Thing]
a} :: SearchThingsResponse) ((Maybe [Thing] -> f (Maybe [Thing]))
 -> SearchThingsResponse -> f SearchThingsResponse)
-> ((Maybe [Thing] -> f (Maybe [Thing]))
    -> Maybe [Thing] -> f (Maybe [Thing]))
-> (Maybe [Thing] -> f (Maybe [Thing]))
-> SearchThingsResponse
-> f SearchThingsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Thing] [Thing] [Thing] [Thing]
-> Iso
     (Maybe [Thing]) (Maybe [Thing]) (Maybe [Thing]) (Maybe [Thing])
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 [Thing] [Thing] [Thing] [Thing]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData SearchThingsResponse