{-# 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.AlexaBusiness.SearchDevices
-- 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 devices and lists the ones that meet a set of filter criteria.
--
-- This operation returns paginated results.
module Amazonka.AlexaBusiness.SearchDevices
  ( -- * Creating a Request
    SearchDevices (..),
    newSearchDevices,

    -- * Request Lenses
    searchDevices_filters,
    searchDevices_sortCriteria,
    searchDevices_nextToken,
    searchDevices_maxResults,

    -- * Destructuring the Response
    SearchDevicesResponse (..),
    newSearchDevicesResponse,

    -- * Response Lenses
    searchDevicesResponse_nextToken,
    searchDevicesResponse_devices,
    searchDevicesResponse_totalCount,
    searchDevicesResponse_httpStatus,
  )
where

import Amazonka.AlexaBusiness.Types
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

-- | /See:/ 'newSearchDevices' smart constructor.
data SearchDevices = SearchDevices'
  { -- | The filters to use to list a specified set of devices. Supported filter
    -- keys are DeviceName, DeviceStatus, DeviceStatusDetailCode, RoomName,
    -- DeviceType, DeviceSerialNumber, UnassociatedOnly, ConnectionStatus
    -- (ONLINE and OFFLINE), NetworkProfileName, NetworkProfileArn, Feature,
    -- and FailureCode.
    SearchDevices -> Maybe [Filter]
filters :: Prelude.Maybe [Filter],
    -- | The sort order to use in listing the specified set of devices. Supported
    -- sort keys are DeviceName, DeviceStatus, RoomName, DeviceType,
    -- DeviceSerialNumber, ConnectionStatus, NetworkProfileName,
    -- NetworkProfileArn, Feature, and FailureCode.
    SearchDevices -> Maybe [Sort]
sortCriteria :: Prelude.Maybe [Sort],
    -- | An optional token returned from a prior request. Use this token for
    -- pagination of results from this action. If this parameter is specified,
    -- the response includes only results beyond the token, up to the value
    -- specified by @MaxResults@.
    SearchDevices -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to include in the response. If more
    -- results exist than the specified @MaxResults@ value, a token is included
    -- in the response so that the remaining results can be retrieved.
    SearchDevices -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (SearchDevices -> SearchDevices -> Bool
(SearchDevices -> SearchDevices -> Bool)
-> (SearchDevices -> SearchDevices -> Bool) -> Eq SearchDevices
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchDevices -> SearchDevices -> Bool
$c/= :: SearchDevices -> SearchDevices -> Bool
== :: SearchDevices -> SearchDevices -> Bool
$c== :: SearchDevices -> SearchDevices -> Bool
Prelude.Eq, ReadPrec [SearchDevices]
ReadPrec SearchDevices
Int -> ReadS SearchDevices
ReadS [SearchDevices]
(Int -> ReadS SearchDevices)
-> ReadS [SearchDevices]
-> ReadPrec SearchDevices
-> ReadPrec [SearchDevices]
-> Read SearchDevices
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchDevices]
$creadListPrec :: ReadPrec [SearchDevices]
readPrec :: ReadPrec SearchDevices
$creadPrec :: ReadPrec SearchDevices
readList :: ReadS [SearchDevices]
$creadList :: ReadS [SearchDevices]
readsPrec :: Int -> ReadS SearchDevices
$creadsPrec :: Int -> ReadS SearchDevices
Prelude.Read, Int -> SearchDevices -> ShowS
[SearchDevices] -> ShowS
SearchDevices -> String
(Int -> SearchDevices -> ShowS)
-> (SearchDevices -> String)
-> ([SearchDevices] -> ShowS)
-> Show SearchDevices
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchDevices] -> ShowS
$cshowList :: [SearchDevices] -> ShowS
show :: SearchDevices -> String
$cshow :: SearchDevices -> String
showsPrec :: Int -> SearchDevices -> ShowS
$cshowsPrec :: Int -> SearchDevices -> ShowS
Prelude.Show, (forall x. SearchDevices -> Rep SearchDevices x)
-> (forall x. Rep SearchDevices x -> SearchDevices)
-> Generic SearchDevices
forall x. Rep SearchDevices x -> SearchDevices
forall x. SearchDevices -> Rep SearchDevices x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchDevices x -> SearchDevices
$cfrom :: forall x. SearchDevices -> Rep SearchDevices x
Prelude.Generic)

-- |
-- Create a value of 'SearchDevices' 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', 'searchDevices_filters' - The filters to use to list a specified set of devices. Supported filter
-- keys are DeviceName, DeviceStatus, DeviceStatusDetailCode, RoomName,
-- DeviceType, DeviceSerialNumber, UnassociatedOnly, ConnectionStatus
-- (ONLINE and OFFLINE), NetworkProfileName, NetworkProfileArn, Feature,
-- and FailureCode.
--
-- 'sortCriteria', 'searchDevices_sortCriteria' - The sort order to use in listing the specified set of devices. Supported
-- sort keys are DeviceName, DeviceStatus, RoomName, DeviceType,
-- DeviceSerialNumber, ConnectionStatus, NetworkProfileName,
-- NetworkProfileArn, Feature, and FailureCode.
--
-- 'nextToken', 'searchDevices_nextToken' - An optional token returned from a prior request. Use this token for
-- pagination of results from this action. If this parameter is specified,
-- the response includes only results beyond the token, up to the value
-- specified by @MaxResults@.
--
-- 'maxResults', 'searchDevices_maxResults' - The maximum number of results to include in the response. If more
-- results exist than the specified @MaxResults@ value, a token is included
-- in the response so that the remaining results can be retrieved.
newSearchDevices ::
  SearchDevices
newSearchDevices :: SearchDevices
newSearchDevices =
  SearchDevices' :: Maybe [Filter]
-> Maybe [Sort] -> Maybe Text -> Maybe Natural -> SearchDevices
SearchDevices'
    { $sel:filters:SearchDevices' :: Maybe [Filter]
filters = Maybe [Filter]
forall a. Maybe a
Prelude.Nothing,
      $sel:sortCriteria:SearchDevices' :: Maybe [Sort]
sortCriteria = Maybe [Sort]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:SearchDevices' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:SearchDevices' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The filters to use to list a specified set of devices. Supported filter
-- keys are DeviceName, DeviceStatus, DeviceStatusDetailCode, RoomName,
-- DeviceType, DeviceSerialNumber, UnassociatedOnly, ConnectionStatus
-- (ONLINE and OFFLINE), NetworkProfileName, NetworkProfileArn, Feature,
-- and FailureCode.
searchDevices_filters :: Lens.Lens' SearchDevices (Prelude.Maybe [Filter])
searchDevices_filters :: (Maybe [Filter] -> f (Maybe [Filter]))
-> SearchDevices -> f SearchDevices
searchDevices_filters = (SearchDevices -> Maybe [Filter])
-> (SearchDevices -> Maybe [Filter] -> SearchDevices)
-> Lens
     SearchDevices SearchDevices (Maybe [Filter]) (Maybe [Filter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchDevices' {Maybe [Filter]
filters :: Maybe [Filter]
$sel:filters:SearchDevices' :: SearchDevices -> Maybe [Filter]
filters} -> Maybe [Filter]
filters) (\s :: SearchDevices
s@SearchDevices' {} Maybe [Filter]
a -> SearchDevices
s {$sel:filters:SearchDevices' :: Maybe [Filter]
filters = Maybe [Filter]
a} :: SearchDevices) ((Maybe [Filter] -> f (Maybe [Filter]))
 -> SearchDevices -> f SearchDevices)
-> ((Maybe [Filter] -> f (Maybe [Filter]))
    -> Maybe [Filter] -> f (Maybe [Filter]))
-> (Maybe [Filter] -> f (Maybe [Filter]))
-> SearchDevices
-> f SearchDevices
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Filter] [Filter] [Filter] [Filter]
-> Iso
     (Maybe [Filter]) (Maybe [Filter]) (Maybe [Filter]) (Maybe [Filter])
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 [Filter] [Filter] [Filter] [Filter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The sort order to use in listing the specified set of devices. Supported
-- sort keys are DeviceName, DeviceStatus, RoomName, DeviceType,
-- DeviceSerialNumber, ConnectionStatus, NetworkProfileName,
-- NetworkProfileArn, Feature, and FailureCode.
searchDevices_sortCriteria :: Lens.Lens' SearchDevices (Prelude.Maybe [Sort])
searchDevices_sortCriteria :: (Maybe [Sort] -> f (Maybe [Sort]))
-> SearchDevices -> f SearchDevices
searchDevices_sortCriteria = (SearchDevices -> Maybe [Sort])
-> (SearchDevices -> Maybe [Sort] -> SearchDevices)
-> Lens SearchDevices SearchDevices (Maybe [Sort]) (Maybe [Sort])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchDevices' {Maybe [Sort]
sortCriteria :: Maybe [Sort]
$sel:sortCriteria:SearchDevices' :: SearchDevices -> Maybe [Sort]
sortCriteria} -> Maybe [Sort]
sortCriteria) (\s :: SearchDevices
s@SearchDevices' {} Maybe [Sort]
a -> SearchDevices
s {$sel:sortCriteria:SearchDevices' :: Maybe [Sort]
sortCriteria = Maybe [Sort]
a} :: SearchDevices) ((Maybe [Sort] -> f (Maybe [Sort]))
 -> SearchDevices -> f SearchDevices)
-> ((Maybe [Sort] -> f (Maybe [Sort]))
    -> Maybe [Sort] -> f (Maybe [Sort]))
-> (Maybe [Sort] -> f (Maybe [Sort]))
-> SearchDevices
-> f SearchDevices
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Sort] [Sort] [Sort] [Sort]
-> Iso (Maybe [Sort]) (Maybe [Sort]) (Maybe [Sort]) (Maybe [Sort])
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 [Sort] [Sort] [Sort] [Sort]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An optional token returned from a prior request. Use this token for
-- pagination of results from this action. If this parameter is specified,
-- the response includes only results beyond the token, up to the value
-- specified by @MaxResults@.
searchDevices_nextToken :: Lens.Lens' SearchDevices (Prelude.Maybe Prelude.Text)
searchDevices_nextToken :: (Maybe Text -> f (Maybe Text)) -> SearchDevices -> f SearchDevices
searchDevices_nextToken = (SearchDevices -> Maybe Text)
-> (SearchDevices -> Maybe Text -> SearchDevices)
-> Lens SearchDevices SearchDevices (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchDevices' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchDevices' :: SearchDevices -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchDevices
s@SearchDevices' {} Maybe Text
a -> SearchDevices
s {$sel:nextToken:SearchDevices' :: Maybe Text
nextToken = Maybe Text
a} :: SearchDevices)

-- | The maximum number of results to include in the response. If more
-- results exist than the specified @MaxResults@ value, a token is included
-- in the response so that the remaining results can be retrieved.
searchDevices_maxResults :: Lens.Lens' SearchDevices (Prelude.Maybe Prelude.Natural)
searchDevices_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> SearchDevices -> f SearchDevices
searchDevices_maxResults = (SearchDevices -> Maybe Natural)
-> (SearchDevices -> Maybe Natural -> SearchDevices)
-> Lens SearchDevices SearchDevices (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchDevices' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:SearchDevices' :: SearchDevices -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: SearchDevices
s@SearchDevices' {} Maybe Natural
a -> SearchDevices
s {$sel:maxResults:SearchDevices' :: Maybe Natural
maxResults = Maybe Natural
a} :: SearchDevices)

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

instance Prelude.NFData SearchDevices

instance Core.ToHeaders SearchDevices where
  toHeaders :: SearchDevices -> ResponseHeaders
toHeaders =
    ResponseHeaders -> SearchDevices -> 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
"AlexaForBusiness.SearchDevices" ::
                          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 SearchDevices where
  toJSON :: SearchDevices -> Value
toJSON SearchDevices' {Maybe Natural
Maybe [Filter]
Maybe [Sort]
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
sortCriteria :: Maybe [Sort]
filters :: Maybe [Filter]
$sel:maxResults:SearchDevices' :: SearchDevices -> Maybe Natural
$sel:nextToken:SearchDevices' :: SearchDevices -> Maybe Text
$sel:sortCriteria:SearchDevices' :: SearchDevices -> Maybe [Sort]
$sel:filters:SearchDevices' :: SearchDevices -> Maybe [Filter]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Filters" Text -> [Filter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Filter] -> Pair) -> Maybe [Filter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Filter]
filters,
            (Text
"SortCriteria" Text -> [Sort] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Sort] -> Pair) -> Maybe [Sort] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Sort]
sortCriteria,
            (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
          ]
      )

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

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

-- | /See:/ 'newSearchDevicesResponse' smart constructor.
data SearchDevicesResponse = SearchDevicesResponse'
  { -- | The token returned to indicate that there is more data available.
    SearchDevicesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The devices that meet the specified set of filter criteria, in sort
    -- order.
    SearchDevicesResponse -> Maybe [DeviceData]
devices :: Prelude.Maybe [DeviceData],
    -- | The total number of devices returned.
    SearchDevicesResponse -> Maybe Int
totalCount :: Prelude.Maybe Prelude.Int,
    -- | The response's http status code.
    SearchDevicesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SearchDevicesResponse -> SearchDevicesResponse -> Bool
(SearchDevicesResponse -> SearchDevicesResponse -> Bool)
-> (SearchDevicesResponse -> SearchDevicesResponse -> Bool)
-> Eq SearchDevicesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchDevicesResponse -> SearchDevicesResponse -> Bool
$c/= :: SearchDevicesResponse -> SearchDevicesResponse -> Bool
== :: SearchDevicesResponse -> SearchDevicesResponse -> Bool
$c== :: SearchDevicesResponse -> SearchDevicesResponse -> Bool
Prelude.Eq, ReadPrec [SearchDevicesResponse]
ReadPrec SearchDevicesResponse
Int -> ReadS SearchDevicesResponse
ReadS [SearchDevicesResponse]
(Int -> ReadS SearchDevicesResponse)
-> ReadS [SearchDevicesResponse]
-> ReadPrec SearchDevicesResponse
-> ReadPrec [SearchDevicesResponse]
-> Read SearchDevicesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchDevicesResponse]
$creadListPrec :: ReadPrec [SearchDevicesResponse]
readPrec :: ReadPrec SearchDevicesResponse
$creadPrec :: ReadPrec SearchDevicesResponse
readList :: ReadS [SearchDevicesResponse]
$creadList :: ReadS [SearchDevicesResponse]
readsPrec :: Int -> ReadS SearchDevicesResponse
$creadsPrec :: Int -> ReadS SearchDevicesResponse
Prelude.Read, Int -> SearchDevicesResponse -> ShowS
[SearchDevicesResponse] -> ShowS
SearchDevicesResponse -> String
(Int -> SearchDevicesResponse -> ShowS)
-> (SearchDevicesResponse -> String)
-> ([SearchDevicesResponse] -> ShowS)
-> Show SearchDevicesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchDevicesResponse] -> ShowS
$cshowList :: [SearchDevicesResponse] -> ShowS
show :: SearchDevicesResponse -> String
$cshow :: SearchDevicesResponse -> String
showsPrec :: Int -> SearchDevicesResponse -> ShowS
$cshowsPrec :: Int -> SearchDevicesResponse -> ShowS
Prelude.Show, (forall x. SearchDevicesResponse -> Rep SearchDevicesResponse x)
-> (forall x. Rep SearchDevicesResponse x -> SearchDevicesResponse)
-> Generic SearchDevicesResponse
forall x. Rep SearchDevicesResponse x -> SearchDevicesResponse
forall x. SearchDevicesResponse -> Rep SearchDevicesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchDevicesResponse x -> SearchDevicesResponse
$cfrom :: forall x. SearchDevicesResponse -> Rep SearchDevicesResponse x
Prelude.Generic)

-- |
-- Create a value of 'SearchDevicesResponse' 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', 'searchDevicesResponse_nextToken' - The token returned to indicate that there is more data available.
--
-- 'devices', 'searchDevicesResponse_devices' - The devices that meet the specified set of filter criteria, in sort
-- order.
--
-- 'totalCount', 'searchDevicesResponse_totalCount' - The total number of devices returned.
--
-- 'httpStatus', 'searchDevicesResponse_httpStatus' - The response's http status code.
newSearchDevicesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SearchDevicesResponse
newSearchDevicesResponse :: Int -> SearchDevicesResponse
newSearchDevicesResponse Int
pHttpStatus_ =
  SearchDevicesResponse' :: Maybe Text
-> Maybe [DeviceData] -> Maybe Int -> Int -> SearchDevicesResponse
SearchDevicesResponse'
    { $sel:nextToken:SearchDevicesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:devices:SearchDevicesResponse' :: Maybe [DeviceData]
devices = Maybe [DeviceData]
forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:SearchDevicesResponse' :: Maybe Int
totalCount = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SearchDevicesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token returned to indicate that there is more data available.
searchDevicesResponse_nextToken :: Lens.Lens' SearchDevicesResponse (Prelude.Maybe Prelude.Text)
searchDevicesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> SearchDevicesResponse -> f SearchDevicesResponse
searchDevicesResponse_nextToken = (SearchDevicesResponse -> Maybe Text)
-> (SearchDevicesResponse -> Maybe Text -> SearchDevicesResponse)
-> Lens' SearchDevicesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchDevicesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchDevicesResponse' :: SearchDevicesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchDevicesResponse
s@SearchDevicesResponse' {} Maybe Text
a -> SearchDevicesResponse
s {$sel:nextToken:SearchDevicesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: SearchDevicesResponse)

-- | The devices that meet the specified set of filter criteria, in sort
-- order.
searchDevicesResponse_devices :: Lens.Lens' SearchDevicesResponse (Prelude.Maybe [DeviceData])
searchDevicesResponse_devices :: (Maybe [DeviceData] -> f (Maybe [DeviceData]))
-> SearchDevicesResponse -> f SearchDevicesResponse
searchDevicesResponse_devices = (SearchDevicesResponse -> Maybe [DeviceData])
-> (SearchDevicesResponse
    -> Maybe [DeviceData] -> SearchDevicesResponse)
-> Lens' SearchDevicesResponse (Maybe [DeviceData])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchDevicesResponse' {Maybe [DeviceData]
devices :: Maybe [DeviceData]
$sel:devices:SearchDevicesResponse' :: SearchDevicesResponse -> Maybe [DeviceData]
devices} -> Maybe [DeviceData]
devices) (\s :: SearchDevicesResponse
s@SearchDevicesResponse' {} Maybe [DeviceData]
a -> SearchDevicesResponse
s {$sel:devices:SearchDevicesResponse' :: Maybe [DeviceData]
devices = Maybe [DeviceData]
a} :: SearchDevicesResponse) ((Maybe [DeviceData] -> f (Maybe [DeviceData]))
 -> SearchDevicesResponse -> f SearchDevicesResponse)
-> ((Maybe [DeviceData] -> f (Maybe [DeviceData]))
    -> Maybe [DeviceData] -> f (Maybe [DeviceData]))
-> (Maybe [DeviceData] -> f (Maybe [DeviceData]))
-> SearchDevicesResponse
-> f SearchDevicesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [DeviceData] [DeviceData] [DeviceData] [DeviceData]
-> Iso
     (Maybe [DeviceData])
     (Maybe [DeviceData])
     (Maybe [DeviceData])
     (Maybe [DeviceData])
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 [DeviceData] [DeviceData] [DeviceData] [DeviceData]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The total number of devices returned.
searchDevicesResponse_totalCount :: Lens.Lens' SearchDevicesResponse (Prelude.Maybe Prelude.Int)
searchDevicesResponse_totalCount :: (Maybe Int -> f (Maybe Int))
-> SearchDevicesResponse -> f SearchDevicesResponse
searchDevicesResponse_totalCount = (SearchDevicesResponse -> Maybe Int)
-> (SearchDevicesResponse -> Maybe Int -> SearchDevicesResponse)
-> Lens
     SearchDevicesResponse SearchDevicesResponse (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchDevicesResponse' {Maybe Int
totalCount :: Maybe Int
$sel:totalCount:SearchDevicesResponse' :: SearchDevicesResponse -> Maybe Int
totalCount} -> Maybe Int
totalCount) (\s :: SearchDevicesResponse
s@SearchDevicesResponse' {} Maybe Int
a -> SearchDevicesResponse
s {$sel:totalCount:SearchDevicesResponse' :: Maybe Int
totalCount = Maybe Int
a} :: SearchDevicesResponse)

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

instance Prelude.NFData SearchDevicesResponse