{-# 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.GreengrassV2.ListClientDevicesAssociatedWithCoreDevice
-- 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)
--
-- Retrieves a paginated list of client devices that are associated with a
-- core device.
--
-- This operation returns paginated results.
module Amazonka.GreengrassV2.ListClientDevicesAssociatedWithCoreDevice
  ( -- * Creating a Request
    ListClientDevicesAssociatedWithCoreDevice (..),
    newListClientDevicesAssociatedWithCoreDevice,

    -- * Request Lenses
    listClientDevicesAssociatedWithCoreDevice_nextToken,
    listClientDevicesAssociatedWithCoreDevice_maxResults,
    listClientDevicesAssociatedWithCoreDevice_coreDeviceThingName,

    -- * Destructuring the Response
    ListClientDevicesAssociatedWithCoreDeviceResponse (..),
    newListClientDevicesAssociatedWithCoreDeviceResponse,

    -- * Response Lenses
    listClientDevicesAssociatedWithCoreDeviceResponse_associatedClientDevices,
    listClientDevicesAssociatedWithCoreDeviceResponse_nextToken,
    listClientDevicesAssociatedWithCoreDeviceResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GreengrassV2.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:/ 'newListClientDevicesAssociatedWithCoreDevice' smart constructor.
data ListClientDevicesAssociatedWithCoreDevice = ListClientDevicesAssociatedWithCoreDevice'
  { -- | The token to be used for the next set of paginated results.
    ListClientDevicesAssociatedWithCoreDevice -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to be returned per paginated request.
    ListClientDevicesAssociatedWithCoreDevice -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The name of the core device. This is also the name of the IoT thing.
    ListClientDevicesAssociatedWithCoreDevice -> Text
coreDeviceThingName :: Prelude.Text
  }
  deriving (ListClientDevicesAssociatedWithCoreDevice
-> ListClientDevicesAssociatedWithCoreDevice -> Bool
(ListClientDevicesAssociatedWithCoreDevice
 -> ListClientDevicesAssociatedWithCoreDevice -> Bool)
-> (ListClientDevicesAssociatedWithCoreDevice
    -> ListClientDevicesAssociatedWithCoreDevice -> Bool)
-> Eq ListClientDevicesAssociatedWithCoreDevice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListClientDevicesAssociatedWithCoreDevice
-> ListClientDevicesAssociatedWithCoreDevice -> Bool
$c/= :: ListClientDevicesAssociatedWithCoreDevice
-> ListClientDevicesAssociatedWithCoreDevice -> Bool
== :: ListClientDevicesAssociatedWithCoreDevice
-> ListClientDevicesAssociatedWithCoreDevice -> Bool
$c== :: ListClientDevicesAssociatedWithCoreDevice
-> ListClientDevicesAssociatedWithCoreDevice -> Bool
Prelude.Eq, ReadPrec [ListClientDevicesAssociatedWithCoreDevice]
ReadPrec ListClientDevicesAssociatedWithCoreDevice
Int -> ReadS ListClientDevicesAssociatedWithCoreDevice
ReadS [ListClientDevicesAssociatedWithCoreDevice]
(Int -> ReadS ListClientDevicesAssociatedWithCoreDevice)
-> ReadS [ListClientDevicesAssociatedWithCoreDevice]
-> ReadPrec ListClientDevicesAssociatedWithCoreDevice
-> ReadPrec [ListClientDevicesAssociatedWithCoreDevice]
-> Read ListClientDevicesAssociatedWithCoreDevice
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListClientDevicesAssociatedWithCoreDevice]
$creadListPrec :: ReadPrec [ListClientDevicesAssociatedWithCoreDevice]
readPrec :: ReadPrec ListClientDevicesAssociatedWithCoreDevice
$creadPrec :: ReadPrec ListClientDevicesAssociatedWithCoreDevice
readList :: ReadS [ListClientDevicesAssociatedWithCoreDevice]
$creadList :: ReadS [ListClientDevicesAssociatedWithCoreDevice]
readsPrec :: Int -> ReadS ListClientDevicesAssociatedWithCoreDevice
$creadsPrec :: Int -> ReadS ListClientDevicesAssociatedWithCoreDevice
Prelude.Read, Int -> ListClientDevicesAssociatedWithCoreDevice -> ShowS
[ListClientDevicesAssociatedWithCoreDevice] -> ShowS
ListClientDevicesAssociatedWithCoreDevice -> String
(Int -> ListClientDevicesAssociatedWithCoreDevice -> ShowS)
-> (ListClientDevicesAssociatedWithCoreDevice -> String)
-> ([ListClientDevicesAssociatedWithCoreDevice] -> ShowS)
-> Show ListClientDevicesAssociatedWithCoreDevice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListClientDevicesAssociatedWithCoreDevice] -> ShowS
$cshowList :: [ListClientDevicesAssociatedWithCoreDevice] -> ShowS
show :: ListClientDevicesAssociatedWithCoreDevice -> String
$cshow :: ListClientDevicesAssociatedWithCoreDevice -> String
showsPrec :: Int -> ListClientDevicesAssociatedWithCoreDevice -> ShowS
$cshowsPrec :: Int -> ListClientDevicesAssociatedWithCoreDevice -> ShowS
Prelude.Show, (forall x.
 ListClientDevicesAssociatedWithCoreDevice
 -> Rep ListClientDevicesAssociatedWithCoreDevice x)
-> (forall x.
    Rep ListClientDevicesAssociatedWithCoreDevice x
    -> ListClientDevicesAssociatedWithCoreDevice)
-> Generic ListClientDevicesAssociatedWithCoreDevice
forall x.
Rep ListClientDevicesAssociatedWithCoreDevice x
-> ListClientDevicesAssociatedWithCoreDevice
forall x.
ListClientDevicesAssociatedWithCoreDevice
-> Rep ListClientDevicesAssociatedWithCoreDevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListClientDevicesAssociatedWithCoreDevice x
-> ListClientDevicesAssociatedWithCoreDevice
$cfrom :: forall x.
ListClientDevicesAssociatedWithCoreDevice
-> Rep ListClientDevicesAssociatedWithCoreDevice x
Prelude.Generic)

-- |
-- Create a value of 'ListClientDevicesAssociatedWithCoreDevice' 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', 'listClientDevicesAssociatedWithCoreDevice_nextToken' - The token to be used for the next set of paginated results.
--
-- 'maxResults', 'listClientDevicesAssociatedWithCoreDevice_maxResults' - The maximum number of results to be returned per paginated request.
--
-- 'coreDeviceThingName', 'listClientDevicesAssociatedWithCoreDevice_coreDeviceThingName' - The name of the core device. This is also the name of the IoT thing.
newListClientDevicesAssociatedWithCoreDevice ::
  -- | 'coreDeviceThingName'
  Prelude.Text ->
  ListClientDevicesAssociatedWithCoreDevice
newListClientDevicesAssociatedWithCoreDevice :: Text -> ListClientDevicesAssociatedWithCoreDevice
newListClientDevicesAssociatedWithCoreDevice
  Text
pCoreDeviceThingName_ =
    ListClientDevicesAssociatedWithCoreDevice' :: Maybe Text
-> Maybe Natural
-> Text
-> ListClientDevicesAssociatedWithCoreDevice
ListClientDevicesAssociatedWithCoreDevice'
      { $sel:nextToken:ListClientDevicesAssociatedWithCoreDevice' :: Maybe Text
nextToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:maxResults:ListClientDevicesAssociatedWithCoreDevice' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:coreDeviceThingName:ListClientDevicesAssociatedWithCoreDevice' :: Text
coreDeviceThingName =
          Text
pCoreDeviceThingName_
      }

-- | The token to be used for the next set of paginated results.
listClientDevicesAssociatedWithCoreDevice_nextToken :: Lens.Lens' ListClientDevicesAssociatedWithCoreDevice (Prelude.Maybe Prelude.Text)
listClientDevicesAssociatedWithCoreDevice_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListClientDevicesAssociatedWithCoreDevice
-> f ListClientDevicesAssociatedWithCoreDevice
listClientDevicesAssociatedWithCoreDevice_nextToken = (ListClientDevicesAssociatedWithCoreDevice -> Maybe Text)
-> (ListClientDevicesAssociatedWithCoreDevice
    -> Maybe Text -> ListClientDevicesAssociatedWithCoreDevice)
-> Lens
     ListClientDevicesAssociatedWithCoreDevice
     ListClientDevicesAssociatedWithCoreDevice
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListClientDevicesAssociatedWithCoreDevice' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListClientDevicesAssociatedWithCoreDevice' :: ListClientDevicesAssociatedWithCoreDevice -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListClientDevicesAssociatedWithCoreDevice
s@ListClientDevicesAssociatedWithCoreDevice' {} Maybe Text
a -> ListClientDevicesAssociatedWithCoreDevice
s {$sel:nextToken:ListClientDevicesAssociatedWithCoreDevice' :: Maybe Text
nextToken = Maybe Text
a} :: ListClientDevicesAssociatedWithCoreDevice)

-- | The maximum number of results to be returned per paginated request.
listClientDevicesAssociatedWithCoreDevice_maxResults :: Lens.Lens' ListClientDevicesAssociatedWithCoreDevice (Prelude.Maybe Prelude.Natural)
listClientDevicesAssociatedWithCoreDevice_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListClientDevicesAssociatedWithCoreDevice
-> f ListClientDevicesAssociatedWithCoreDevice
listClientDevicesAssociatedWithCoreDevice_maxResults = (ListClientDevicesAssociatedWithCoreDevice -> Maybe Natural)
-> (ListClientDevicesAssociatedWithCoreDevice
    -> Maybe Natural -> ListClientDevicesAssociatedWithCoreDevice)
-> Lens
     ListClientDevicesAssociatedWithCoreDevice
     ListClientDevicesAssociatedWithCoreDevice
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListClientDevicesAssociatedWithCoreDevice' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListClientDevicesAssociatedWithCoreDevice' :: ListClientDevicesAssociatedWithCoreDevice -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListClientDevicesAssociatedWithCoreDevice
s@ListClientDevicesAssociatedWithCoreDevice' {} Maybe Natural
a -> ListClientDevicesAssociatedWithCoreDevice
s {$sel:maxResults:ListClientDevicesAssociatedWithCoreDevice' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListClientDevicesAssociatedWithCoreDevice)

-- | The name of the core device. This is also the name of the IoT thing.
listClientDevicesAssociatedWithCoreDevice_coreDeviceThingName :: Lens.Lens' ListClientDevicesAssociatedWithCoreDevice Prelude.Text
listClientDevicesAssociatedWithCoreDevice_coreDeviceThingName :: (Text -> f Text)
-> ListClientDevicesAssociatedWithCoreDevice
-> f ListClientDevicesAssociatedWithCoreDevice
listClientDevicesAssociatedWithCoreDevice_coreDeviceThingName = (ListClientDevicesAssociatedWithCoreDevice -> Text)
-> (ListClientDevicesAssociatedWithCoreDevice
    -> Text -> ListClientDevicesAssociatedWithCoreDevice)
-> Lens
     ListClientDevicesAssociatedWithCoreDevice
     ListClientDevicesAssociatedWithCoreDevice
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListClientDevicesAssociatedWithCoreDevice' {Text
coreDeviceThingName :: Text
$sel:coreDeviceThingName:ListClientDevicesAssociatedWithCoreDevice' :: ListClientDevicesAssociatedWithCoreDevice -> Text
coreDeviceThingName} -> Text
coreDeviceThingName) (\s :: ListClientDevicesAssociatedWithCoreDevice
s@ListClientDevicesAssociatedWithCoreDevice' {} Text
a -> ListClientDevicesAssociatedWithCoreDevice
s {$sel:coreDeviceThingName:ListClientDevicesAssociatedWithCoreDevice' :: Text
coreDeviceThingName = Text
a} :: ListClientDevicesAssociatedWithCoreDevice)

instance
  Core.AWSPager
    ListClientDevicesAssociatedWithCoreDevice
  where
  page :: ListClientDevicesAssociatedWithCoreDevice
-> AWSResponse ListClientDevicesAssociatedWithCoreDevice
-> Maybe ListClientDevicesAssociatedWithCoreDevice
page ListClientDevicesAssociatedWithCoreDevice
rq AWSResponse ListClientDevicesAssociatedWithCoreDevice
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListClientDevicesAssociatedWithCoreDevice
ListClientDevicesAssociatedWithCoreDeviceResponse
rs
            ListClientDevicesAssociatedWithCoreDeviceResponse
-> Getting
     (First Text) ListClientDevicesAssociatedWithCoreDeviceResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListClientDevicesAssociatedWithCoreDeviceResponse
-> Const
     (First Text) ListClientDevicesAssociatedWithCoreDeviceResponse
Lens'
  ListClientDevicesAssociatedWithCoreDeviceResponse (Maybe Text)
listClientDevicesAssociatedWithCoreDeviceResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListClientDevicesAssociatedWithCoreDeviceResponse
 -> Const
      (First Text) ListClientDevicesAssociatedWithCoreDeviceResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) ListClientDevicesAssociatedWithCoreDeviceResponse 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 ListClientDevicesAssociatedWithCoreDevice
forall a. Maybe a
Prelude.Nothing
    | Maybe [AssociatedClientDevice] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListClientDevicesAssociatedWithCoreDevice
ListClientDevicesAssociatedWithCoreDeviceResponse
rs
            ListClientDevicesAssociatedWithCoreDeviceResponse
-> Getting
     (First [AssociatedClientDevice])
     ListClientDevicesAssociatedWithCoreDeviceResponse
     [AssociatedClientDevice]
-> Maybe [AssociatedClientDevice]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe (NonEmpty AssociatedClientDevice)
 -> Const
      (First [AssociatedClientDevice])
      (Maybe (NonEmpty AssociatedClientDevice)))
-> ListClientDevicesAssociatedWithCoreDeviceResponse
-> Const
     (First [AssociatedClientDevice])
     ListClientDevicesAssociatedWithCoreDeviceResponse
Lens'
  ListClientDevicesAssociatedWithCoreDeviceResponse
  (Maybe (NonEmpty AssociatedClientDevice))
listClientDevicesAssociatedWithCoreDeviceResponse_associatedClientDevices
              ((Maybe (NonEmpty AssociatedClientDevice)
  -> Const
       (First [AssociatedClientDevice])
       (Maybe (NonEmpty AssociatedClientDevice)))
 -> ListClientDevicesAssociatedWithCoreDeviceResponse
 -> Const
      (First [AssociatedClientDevice])
      ListClientDevicesAssociatedWithCoreDeviceResponse)
-> (([AssociatedClientDevice]
     -> Const (First [AssociatedClientDevice]) [AssociatedClientDevice])
    -> Maybe (NonEmpty AssociatedClientDevice)
    -> Const
         (First [AssociatedClientDevice])
         (Maybe (NonEmpty AssociatedClientDevice)))
-> Getting
     (First [AssociatedClientDevice])
     ListClientDevicesAssociatedWithCoreDeviceResponse
     [AssociatedClientDevice]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty AssociatedClientDevice
 -> Const
      (First [AssociatedClientDevice]) (NonEmpty AssociatedClientDevice))
-> Maybe (NonEmpty AssociatedClientDevice)
-> Const
     (First [AssociatedClientDevice])
     (Maybe (NonEmpty AssociatedClientDevice))
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
              ((NonEmpty AssociatedClientDevice
  -> Const
       (First [AssociatedClientDevice]) (NonEmpty AssociatedClientDevice))
 -> Maybe (NonEmpty AssociatedClientDevice)
 -> Const
      (First [AssociatedClientDevice])
      (Maybe (NonEmpty AssociatedClientDevice)))
-> (([AssociatedClientDevice]
     -> Const (First [AssociatedClientDevice]) [AssociatedClientDevice])
    -> NonEmpty AssociatedClientDevice
    -> Const
         (First [AssociatedClientDevice]) (NonEmpty AssociatedClientDevice))
-> ([AssociatedClientDevice]
    -> Const (First [AssociatedClientDevice]) [AssociatedClientDevice])
-> Maybe (NonEmpty AssociatedClientDevice)
-> Const
     (First [AssociatedClientDevice])
     (Maybe (NonEmpty AssociatedClientDevice))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty AssociatedClientDevice -> [AssociatedClientDevice])
-> ([AssociatedClientDevice]
    -> Const (First [AssociatedClientDevice]) [AssociatedClientDevice])
-> NonEmpty AssociatedClientDevice
-> Const
     (First [AssociatedClientDevice]) (NonEmpty AssociatedClientDevice)
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to NonEmpty AssociatedClientDevice -> [AssociatedClientDevice]
forall l. IsList l => l -> [Item l]
Prelude.toList
        ) =
      Maybe ListClientDevicesAssociatedWithCoreDevice
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListClientDevicesAssociatedWithCoreDevice
-> Maybe ListClientDevicesAssociatedWithCoreDevice
forall a. a -> Maybe a
Prelude.Just (ListClientDevicesAssociatedWithCoreDevice
 -> Maybe ListClientDevicesAssociatedWithCoreDevice)
-> ListClientDevicesAssociatedWithCoreDevice
-> Maybe ListClientDevicesAssociatedWithCoreDevice
forall a b. (a -> b) -> a -> b
Prelude.$
        ListClientDevicesAssociatedWithCoreDevice
rq
          ListClientDevicesAssociatedWithCoreDevice
-> (ListClientDevicesAssociatedWithCoreDevice
    -> ListClientDevicesAssociatedWithCoreDevice)
-> ListClientDevicesAssociatedWithCoreDevice
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListClientDevicesAssociatedWithCoreDevice
-> Identity ListClientDevicesAssociatedWithCoreDevice
Lens
  ListClientDevicesAssociatedWithCoreDevice
  ListClientDevicesAssociatedWithCoreDevice
  (Maybe Text)
  (Maybe Text)
listClientDevicesAssociatedWithCoreDevice_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListClientDevicesAssociatedWithCoreDevice
 -> Identity ListClientDevicesAssociatedWithCoreDevice)
-> Maybe Text
-> ListClientDevicesAssociatedWithCoreDevice
-> ListClientDevicesAssociatedWithCoreDevice
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListClientDevicesAssociatedWithCoreDevice
ListClientDevicesAssociatedWithCoreDeviceResponse
rs
            ListClientDevicesAssociatedWithCoreDeviceResponse
-> Getting
     (First Text) ListClientDevicesAssociatedWithCoreDeviceResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListClientDevicesAssociatedWithCoreDeviceResponse
-> Const
     (First Text) ListClientDevicesAssociatedWithCoreDeviceResponse
Lens'
  ListClientDevicesAssociatedWithCoreDeviceResponse (Maybe Text)
listClientDevicesAssociatedWithCoreDeviceResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListClientDevicesAssociatedWithCoreDeviceResponse
 -> Const
      (First Text) ListClientDevicesAssociatedWithCoreDeviceResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) ListClientDevicesAssociatedWithCoreDeviceResponse 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
    ListClientDevicesAssociatedWithCoreDevice
  where
  type
    AWSResponse
      ListClientDevicesAssociatedWithCoreDevice =
      ListClientDevicesAssociatedWithCoreDeviceResponse
  request :: ListClientDevicesAssociatedWithCoreDevice
-> Request ListClientDevicesAssociatedWithCoreDevice
request = Service
-> ListClientDevicesAssociatedWithCoreDevice
-> Request ListClientDevicesAssociatedWithCoreDevice
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListClientDevicesAssociatedWithCoreDevice
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse ListClientDevicesAssociatedWithCoreDevice)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either
      String (AWSResponse ListClientDevicesAssociatedWithCoreDevice))
-> Logger
-> Service
-> Proxy ListClientDevicesAssociatedWithCoreDevice
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse ListClientDevicesAssociatedWithCoreDevice)))
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 (NonEmpty AssociatedClientDevice)
-> Maybe Text
-> Int
-> ListClientDevicesAssociatedWithCoreDeviceResponse
ListClientDevicesAssociatedWithCoreDeviceResponse'
            (Maybe (NonEmpty AssociatedClientDevice)
 -> Maybe Text
 -> Int
 -> ListClientDevicesAssociatedWithCoreDeviceResponse)
-> Either String (Maybe (NonEmpty AssociatedClientDevice))
-> Either
     String
     (Maybe Text
      -> Int -> ListClientDevicesAssociatedWithCoreDeviceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Either String (Maybe (NonEmpty AssociatedClientDevice))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"associatedClientDevices")
              Either
  String
  (Maybe Text
   -> Int -> ListClientDevicesAssociatedWithCoreDeviceResponse)
-> Either String (Maybe Text)
-> Either
     String (Int -> ListClientDevicesAssociatedWithCoreDeviceResponse)
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 -> ListClientDevicesAssociatedWithCoreDeviceResponse)
-> Either String Int
-> Either String ListClientDevicesAssociatedWithCoreDeviceResponse
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
    ListClientDevicesAssociatedWithCoreDevice

instance
  Prelude.NFData
    ListClientDevicesAssociatedWithCoreDevice

instance
  Core.ToHeaders
    ListClientDevicesAssociatedWithCoreDevice
  where
  toHeaders :: ListClientDevicesAssociatedWithCoreDevice -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> ListClientDevicesAssociatedWithCoreDevice -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance
  Core.ToPath
    ListClientDevicesAssociatedWithCoreDevice
  where
  toPath :: ListClientDevicesAssociatedWithCoreDevice -> ByteString
toPath ListClientDevicesAssociatedWithCoreDevice' {Maybe Natural
Maybe Text
Text
coreDeviceThingName :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:coreDeviceThingName:ListClientDevicesAssociatedWithCoreDevice' :: ListClientDevicesAssociatedWithCoreDevice -> Text
$sel:maxResults:ListClientDevicesAssociatedWithCoreDevice' :: ListClientDevicesAssociatedWithCoreDevice -> Maybe Natural
$sel:nextToken:ListClientDevicesAssociatedWithCoreDevice' :: ListClientDevicesAssociatedWithCoreDevice -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/greengrass/v2/coreDevices/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
coreDeviceThingName,
        ByteString
"/associatedClientDevices"
      ]

instance
  Core.ToQuery
    ListClientDevicesAssociatedWithCoreDevice
  where
  toQuery :: ListClientDevicesAssociatedWithCoreDevice -> QueryString
toQuery
    ListClientDevicesAssociatedWithCoreDevice' {Maybe Natural
Maybe Text
Text
coreDeviceThingName :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:coreDeviceThingName:ListClientDevicesAssociatedWithCoreDevice' :: ListClientDevicesAssociatedWithCoreDevice -> Text
$sel:maxResults:ListClientDevicesAssociatedWithCoreDevice' :: ListClientDevicesAssociatedWithCoreDevice -> Maybe Natural
$sel:nextToken:ListClientDevicesAssociatedWithCoreDevice' :: ListClientDevicesAssociatedWithCoreDevice -> Maybe Text
..} =
      [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
        [ ByteString
"nextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
          ByteString
"maxResults" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults
        ]

-- | /See:/ 'newListClientDevicesAssociatedWithCoreDeviceResponse' smart constructor.
data ListClientDevicesAssociatedWithCoreDeviceResponse = ListClientDevicesAssociatedWithCoreDeviceResponse'
  { -- | A list that describes the client devices that are associated with the
    -- core device.
    ListClientDevicesAssociatedWithCoreDeviceResponse
-> Maybe (NonEmpty AssociatedClientDevice)
associatedClientDevices :: Prelude.Maybe (Prelude.NonEmpty AssociatedClientDevice),
    -- | The token for the next set of results, or null if there are no
    -- additional results.
    ListClientDevicesAssociatedWithCoreDeviceResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListClientDevicesAssociatedWithCoreDeviceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListClientDevicesAssociatedWithCoreDeviceResponse
-> ListClientDevicesAssociatedWithCoreDeviceResponse -> Bool
(ListClientDevicesAssociatedWithCoreDeviceResponse
 -> ListClientDevicesAssociatedWithCoreDeviceResponse -> Bool)
-> (ListClientDevicesAssociatedWithCoreDeviceResponse
    -> ListClientDevicesAssociatedWithCoreDeviceResponse -> Bool)
-> Eq ListClientDevicesAssociatedWithCoreDeviceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListClientDevicesAssociatedWithCoreDeviceResponse
-> ListClientDevicesAssociatedWithCoreDeviceResponse -> Bool
$c/= :: ListClientDevicesAssociatedWithCoreDeviceResponse
-> ListClientDevicesAssociatedWithCoreDeviceResponse -> Bool
== :: ListClientDevicesAssociatedWithCoreDeviceResponse
-> ListClientDevicesAssociatedWithCoreDeviceResponse -> Bool
$c== :: ListClientDevicesAssociatedWithCoreDeviceResponse
-> ListClientDevicesAssociatedWithCoreDeviceResponse -> Bool
Prelude.Eq, ReadPrec [ListClientDevicesAssociatedWithCoreDeviceResponse]
ReadPrec ListClientDevicesAssociatedWithCoreDeviceResponse
Int -> ReadS ListClientDevicesAssociatedWithCoreDeviceResponse
ReadS [ListClientDevicesAssociatedWithCoreDeviceResponse]
(Int -> ReadS ListClientDevicesAssociatedWithCoreDeviceResponse)
-> ReadS [ListClientDevicesAssociatedWithCoreDeviceResponse]
-> ReadPrec ListClientDevicesAssociatedWithCoreDeviceResponse
-> ReadPrec [ListClientDevicesAssociatedWithCoreDeviceResponse]
-> Read ListClientDevicesAssociatedWithCoreDeviceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListClientDevicesAssociatedWithCoreDeviceResponse]
$creadListPrec :: ReadPrec [ListClientDevicesAssociatedWithCoreDeviceResponse]
readPrec :: ReadPrec ListClientDevicesAssociatedWithCoreDeviceResponse
$creadPrec :: ReadPrec ListClientDevicesAssociatedWithCoreDeviceResponse
readList :: ReadS [ListClientDevicesAssociatedWithCoreDeviceResponse]
$creadList :: ReadS [ListClientDevicesAssociatedWithCoreDeviceResponse]
readsPrec :: Int -> ReadS ListClientDevicesAssociatedWithCoreDeviceResponse
$creadsPrec :: Int -> ReadS ListClientDevicesAssociatedWithCoreDeviceResponse
Prelude.Read, Int -> ListClientDevicesAssociatedWithCoreDeviceResponse -> ShowS
[ListClientDevicesAssociatedWithCoreDeviceResponse] -> ShowS
ListClientDevicesAssociatedWithCoreDeviceResponse -> String
(Int -> ListClientDevicesAssociatedWithCoreDeviceResponse -> ShowS)
-> (ListClientDevicesAssociatedWithCoreDeviceResponse -> String)
-> ([ListClientDevicesAssociatedWithCoreDeviceResponse] -> ShowS)
-> Show ListClientDevicesAssociatedWithCoreDeviceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListClientDevicesAssociatedWithCoreDeviceResponse] -> ShowS
$cshowList :: [ListClientDevicesAssociatedWithCoreDeviceResponse] -> ShowS
show :: ListClientDevicesAssociatedWithCoreDeviceResponse -> String
$cshow :: ListClientDevicesAssociatedWithCoreDeviceResponse -> String
showsPrec :: Int -> ListClientDevicesAssociatedWithCoreDeviceResponse -> ShowS
$cshowsPrec :: Int -> ListClientDevicesAssociatedWithCoreDeviceResponse -> ShowS
Prelude.Show, (forall x.
 ListClientDevicesAssociatedWithCoreDeviceResponse
 -> Rep ListClientDevicesAssociatedWithCoreDeviceResponse x)
-> (forall x.
    Rep ListClientDevicesAssociatedWithCoreDeviceResponse x
    -> ListClientDevicesAssociatedWithCoreDeviceResponse)
-> Generic ListClientDevicesAssociatedWithCoreDeviceResponse
forall x.
Rep ListClientDevicesAssociatedWithCoreDeviceResponse x
-> ListClientDevicesAssociatedWithCoreDeviceResponse
forall x.
ListClientDevicesAssociatedWithCoreDeviceResponse
-> Rep ListClientDevicesAssociatedWithCoreDeviceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListClientDevicesAssociatedWithCoreDeviceResponse x
-> ListClientDevicesAssociatedWithCoreDeviceResponse
$cfrom :: forall x.
ListClientDevicesAssociatedWithCoreDeviceResponse
-> Rep ListClientDevicesAssociatedWithCoreDeviceResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListClientDevicesAssociatedWithCoreDeviceResponse' 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:
--
-- 'associatedClientDevices', 'listClientDevicesAssociatedWithCoreDeviceResponse_associatedClientDevices' - A list that describes the client devices that are associated with the
-- core device.
--
-- 'nextToken', 'listClientDevicesAssociatedWithCoreDeviceResponse_nextToken' - The token for the next set of results, or null if there are no
-- additional results.
--
-- 'httpStatus', 'listClientDevicesAssociatedWithCoreDeviceResponse_httpStatus' - The response's http status code.
newListClientDevicesAssociatedWithCoreDeviceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListClientDevicesAssociatedWithCoreDeviceResponse
newListClientDevicesAssociatedWithCoreDeviceResponse :: Int -> ListClientDevicesAssociatedWithCoreDeviceResponse
newListClientDevicesAssociatedWithCoreDeviceResponse
  Int
pHttpStatus_ =
    ListClientDevicesAssociatedWithCoreDeviceResponse' :: Maybe (NonEmpty AssociatedClientDevice)
-> Maybe Text
-> Int
-> ListClientDevicesAssociatedWithCoreDeviceResponse
ListClientDevicesAssociatedWithCoreDeviceResponse'
      { $sel:associatedClientDevices:ListClientDevicesAssociatedWithCoreDeviceResponse' :: Maybe (NonEmpty AssociatedClientDevice)
associatedClientDevices =
          Maybe (NonEmpty AssociatedClientDevice)
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:ListClientDevicesAssociatedWithCoreDeviceResponse' :: Maybe Text
nextToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:ListClientDevicesAssociatedWithCoreDeviceResponse' :: Int
httpStatus =
          Int
pHttpStatus_
      }

-- | A list that describes the client devices that are associated with the
-- core device.
listClientDevicesAssociatedWithCoreDeviceResponse_associatedClientDevices :: Lens.Lens' ListClientDevicesAssociatedWithCoreDeviceResponse (Prelude.Maybe (Prelude.NonEmpty AssociatedClientDevice))
listClientDevicesAssociatedWithCoreDeviceResponse_associatedClientDevices :: (Maybe (NonEmpty AssociatedClientDevice)
 -> f (Maybe (NonEmpty AssociatedClientDevice)))
-> ListClientDevicesAssociatedWithCoreDeviceResponse
-> f ListClientDevicesAssociatedWithCoreDeviceResponse
listClientDevicesAssociatedWithCoreDeviceResponse_associatedClientDevices = (ListClientDevicesAssociatedWithCoreDeviceResponse
 -> Maybe (NonEmpty AssociatedClientDevice))
-> (ListClientDevicesAssociatedWithCoreDeviceResponse
    -> Maybe (NonEmpty AssociatedClientDevice)
    -> ListClientDevicesAssociatedWithCoreDeviceResponse)
-> Lens'
     ListClientDevicesAssociatedWithCoreDeviceResponse
     (Maybe (NonEmpty AssociatedClientDevice))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListClientDevicesAssociatedWithCoreDeviceResponse' {Maybe (NonEmpty AssociatedClientDevice)
associatedClientDevices :: Maybe (NonEmpty AssociatedClientDevice)
$sel:associatedClientDevices:ListClientDevicesAssociatedWithCoreDeviceResponse' :: ListClientDevicesAssociatedWithCoreDeviceResponse
-> Maybe (NonEmpty AssociatedClientDevice)
associatedClientDevices} -> Maybe (NonEmpty AssociatedClientDevice)
associatedClientDevices) (\s :: ListClientDevicesAssociatedWithCoreDeviceResponse
s@ListClientDevicesAssociatedWithCoreDeviceResponse' {} Maybe (NonEmpty AssociatedClientDevice)
a -> ListClientDevicesAssociatedWithCoreDeviceResponse
s {$sel:associatedClientDevices:ListClientDevicesAssociatedWithCoreDeviceResponse' :: Maybe (NonEmpty AssociatedClientDevice)
associatedClientDevices = Maybe (NonEmpty AssociatedClientDevice)
a} :: ListClientDevicesAssociatedWithCoreDeviceResponse) ((Maybe (NonEmpty AssociatedClientDevice)
  -> f (Maybe (NonEmpty AssociatedClientDevice)))
 -> ListClientDevicesAssociatedWithCoreDeviceResponse
 -> f ListClientDevicesAssociatedWithCoreDeviceResponse)
-> ((Maybe (NonEmpty AssociatedClientDevice)
     -> f (Maybe (NonEmpty AssociatedClientDevice)))
    -> Maybe (NonEmpty AssociatedClientDevice)
    -> f (Maybe (NonEmpty AssociatedClientDevice)))
-> (Maybe (NonEmpty AssociatedClientDevice)
    -> f (Maybe (NonEmpty AssociatedClientDevice)))
-> ListClientDevicesAssociatedWithCoreDeviceResponse
-> f ListClientDevicesAssociatedWithCoreDeviceResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty AssociatedClientDevice)
  (NonEmpty AssociatedClientDevice)
  (NonEmpty AssociatedClientDevice)
  (NonEmpty AssociatedClientDevice)
-> Iso
     (Maybe (NonEmpty AssociatedClientDevice))
     (Maybe (NonEmpty AssociatedClientDevice))
     (Maybe (NonEmpty AssociatedClientDevice))
     (Maybe (NonEmpty AssociatedClientDevice))
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
  (NonEmpty AssociatedClientDevice)
  (NonEmpty AssociatedClientDevice)
  (NonEmpty AssociatedClientDevice)
  (NonEmpty AssociatedClientDevice)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token for the next set of results, or null if there are no
-- additional results.
listClientDevicesAssociatedWithCoreDeviceResponse_nextToken :: Lens.Lens' ListClientDevicesAssociatedWithCoreDeviceResponse (Prelude.Maybe Prelude.Text)
listClientDevicesAssociatedWithCoreDeviceResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListClientDevicesAssociatedWithCoreDeviceResponse
-> f ListClientDevicesAssociatedWithCoreDeviceResponse
listClientDevicesAssociatedWithCoreDeviceResponse_nextToken = (ListClientDevicesAssociatedWithCoreDeviceResponse -> Maybe Text)
-> (ListClientDevicesAssociatedWithCoreDeviceResponse
    -> Maybe Text -> ListClientDevicesAssociatedWithCoreDeviceResponse)
-> Lens'
     ListClientDevicesAssociatedWithCoreDeviceResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListClientDevicesAssociatedWithCoreDeviceResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListClientDevicesAssociatedWithCoreDeviceResponse' :: ListClientDevicesAssociatedWithCoreDeviceResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListClientDevicesAssociatedWithCoreDeviceResponse
s@ListClientDevicesAssociatedWithCoreDeviceResponse' {} Maybe Text
a -> ListClientDevicesAssociatedWithCoreDeviceResponse
s {$sel:nextToken:ListClientDevicesAssociatedWithCoreDeviceResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListClientDevicesAssociatedWithCoreDeviceResponse)

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

instance
  Prelude.NFData
    ListClientDevicesAssociatedWithCoreDeviceResponse