{-# 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 #-}
module Amazonka.IoT.ListThingGroupsForThing
(
ListThingGroupsForThing (..),
newListThingGroupsForThing,
listThingGroupsForThing_maxResults,
listThingGroupsForThing_nextToken,
listThingGroupsForThing_thingName,
ListThingGroupsForThingResponse (..),
newListThingGroupsForThingResponse,
listThingGroupsForThingResponse_nextToken,
listThingGroupsForThingResponse_thingGroups,
listThingGroupsForThingResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data ListThingGroupsForThing = ListThingGroupsForThing'
{
ListThingGroupsForThing -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
ListThingGroupsForThing -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListThingGroupsForThing -> Text
thingName :: Prelude.Text
}
deriving (ListThingGroupsForThing -> ListThingGroupsForThing -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListThingGroupsForThing -> ListThingGroupsForThing -> Bool
$c/= :: ListThingGroupsForThing -> ListThingGroupsForThing -> Bool
== :: ListThingGroupsForThing -> ListThingGroupsForThing -> Bool
$c== :: ListThingGroupsForThing -> ListThingGroupsForThing -> Bool
Prelude.Eq, ReadPrec [ListThingGroupsForThing]
ReadPrec ListThingGroupsForThing
Int -> ReadS ListThingGroupsForThing
ReadS [ListThingGroupsForThing]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListThingGroupsForThing]
$creadListPrec :: ReadPrec [ListThingGroupsForThing]
readPrec :: ReadPrec ListThingGroupsForThing
$creadPrec :: ReadPrec ListThingGroupsForThing
readList :: ReadS [ListThingGroupsForThing]
$creadList :: ReadS [ListThingGroupsForThing]
readsPrec :: Int -> ReadS ListThingGroupsForThing
$creadsPrec :: Int -> ReadS ListThingGroupsForThing
Prelude.Read, Int -> ListThingGroupsForThing -> ShowS
[ListThingGroupsForThing] -> ShowS
ListThingGroupsForThing -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListThingGroupsForThing] -> ShowS
$cshowList :: [ListThingGroupsForThing] -> ShowS
show :: ListThingGroupsForThing -> String
$cshow :: ListThingGroupsForThing -> String
showsPrec :: Int -> ListThingGroupsForThing -> ShowS
$cshowsPrec :: Int -> ListThingGroupsForThing -> ShowS
Prelude.Show, forall x. Rep ListThingGroupsForThing x -> ListThingGroupsForThing
forall x. ListThingGroupsForThing -> Rep ListThingGroupsForThing x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListThingGroupsForThing x -> ListThingGroupsForThing
$cfrom :: forall x. ListThingGroupsForThing -> Rep ListThingGroupsForThing x
Prelude.Generic)
newListThingGroupsForThing ::
Prelude.Text ->
ListThingGroupsForThing
newListThingGroupsForThing :: Text -> ListThingGroupsForThing
newListThingGroupsForThing Text
pThingName_ =
ListThingGroupsForThing'
{ $sel:maxResults:ListThingGroupsForThing' :: Maybe Natural
maxResults =
forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:ListThingGroupsForThing' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
$sel:thingName:ListThingGroupsForThing' :: Text
thingName = Text
pThingName_
}
listThingGroupsForThing_maxResults :: Lens.Lens' ListThingGroupsForThing (Prelude.Maybe Prelude.Natural)
listThingGroupsForThing_maxResults :: Lens' ListThingGroupsForThing (Maybe Natural)
listThingGroupsForThing_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListThingGroupsForThing' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListThingGroupsForThing' :: ListThingGroupsForThing -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListThingGroupsForThing
s@ListThingGroupsForThing' {} Maybe Natural
a -> ListThingGroupsForThing
s {$sel:maxResults:ListThingGroupsForThing' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListThingGroupsForThing)
listThingGroupsForThing_nextToken :: Lens.Lens' ListThingGroupsForThing (Prelude.Maybe Prelude.Text)
listThingGroupsForThing_nextToken :: Lens' ListThingGroupsForThing (Maybe Text)
listThingGroupsForThing_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListThingGroupsForThing' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListThingGroupsForThing' :: ListThingGroupsForThing -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListThingGroupsForThing
s@ListThingGroupsForThing' {} Maybe Text
a -> ListThingGroupsForThing
s {$sel:nextToken:ListThingGroupsForThing' :: Maybe Text
nextToken = Maybe Text
a} :: ListThingGroupsForThing)
listThingGroupsForThing_thingName :: Lens.Lens' ListThingGroupsForThing Prelude.Text
listThingGroupsForThing_thingName :: Lens' ListThingGroupsForThing Text
listThingGroupsForThing_thingName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListThingGroupsForThing' {Text
thingName :: Text
$sel:thingName:ListThingGroupsForThing' :: ListThingGroupsForThing -> Text
thingName} -> Text
thingName) (\s :: ListThingGroupsForThing
s@ListThingGroupsForThing' {} Text
a -> ListThingGroupsForThing
s {$sel:thingName:ListThingGroupsForThing' :: Text
thingName = Text
a} :: ListThingGroupsForThing)
instance Core.AWSPager ListThingGroupsForThing where
page :: ListThingGroupsForThing
-> AWSResponse ListThingGroupsForThing
-> Maybe ListThingGroupsForThing
page ListThingGroupsForThing
rq AWSResponse ListThingGroupsForThing
rs
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListThingGroupsForThing
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListThingGroupsForThingResponse (Maybe Text)
listThingGroupsForThingResponse_nextToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
forall a. Maybe a
Prelude.Nothing
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListThingGroupsForThing
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListThingGroupsForThingResponse (Maybe [GroupNameAndArn])
listThingGroupsForThingResponse_thingGroups
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
forall a. a -> Maybe a
Prelude.Just
forall a b. (a -> b) -> a -> b
Prelude.$ ListThingGroupsForThing
rq
forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListThingGroupsForThing (Maybe Text)
listThingGroupsForThing_nextToken
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListThingGroupsForThing
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListThingGroupsForThingResponse (Maybe Text)
listThingGroupsForThingResponse_nextToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest ListThingGroupsForThing where
type
AWSResponse ListThingGroupsForThing =
ListThingGroupsForThingResponse
request :: (Service -> Service)
-> ListThingGroupsForThing -> Request ListThingGroupsForThing
request Service -> Service
overrides =
forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListThingGroupsForThing
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse ListThingGroupsForThing)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text
-> Maybe [GroupNameAndArn]
-> Int
-> ListThingGroupsForThingResponse
ListThingGroupsForThingResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"nextToken")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"thingGroups" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable ListThingGroupsForThing where
hashWithSalt :: Int -> ListThingGroupsForThing -> Int
hashWithSalt Int
_salt ListThingGroupsForThing' {Maybe Natural
Maybe Text
Text
thingName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:thingName:ListThingGroupsForThing' :: ListThingGroupsForThing -> Text
$sel:nextToken:ListThingGroupsForThing' :: ListThingGroupsForThing -> Maybe Text
$sel:maxResults:ListThingGroupsForThing' :: ListThingGroupsForThing -> Maybe Natural
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
thingName
instance Prelude.NFData ListThingGroupsForThing where
rnf :: ListThingGroupsForThing -> ()
rnf ListThingGroupsForThing' {Maybe Natural
Maybe Text
Text
thingName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:thingName:ListThingGroupsForThing' :: ListThingGroupsForThing -> Text
$sel:nextToken:ListThingGroupsForThing' :: ListThingGroupsForThing -> Maybe Text
$sel:maxResults:ListThingGroupsForThing' :: ListThingGroupsForThing -> Maybe Natural
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
thingName
instance Data.ToHeaders ListThingGroupsForThing where
toHeaders :: ListThingGroupsForThing -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
instance Data.ToPath ListThingGroupsForThing where
toPath :: ListThingGroupsForThing -> ByteString
toPath ListThingGroupsForThing' {Maybe Natural
Maybe Text
Text
thingName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:thingName:ListThingGroupsForThing' :: ListThingGroupsForThing -> Text
$sel:nextToken:ListThingGroupsForThing' :: ListThingGroupsForThing -> Maybe Text
$sel:maxResults:ListThingGroupsForThing' :: ListThingGroupsForThing -> Maybe Natural
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/things/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
thingName, ByteString
"/thing-groups"]
instance Data.ToQuery ListThingGroupsForThing where
toQuery :: ListThingGroupsForThing -> QueryString
toQuery ListThingGroupsForThing' {Maybe Natural
Maybe Text
Text
thingName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:thingName:ListThingGroupsForThing' :: ListThingGroupsForThing -> Text
$sel:nextToken:ListThingGroupsForThing' :: ListThingGroupsForThing -> Maybe Text
$sel:maxResults:ListThingGroupsForThing' :: ListThingGroupsForThing -> Maybe Natural
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
]
data ListThingGroupsForThingResponse = ListThingGroupsForThingResponse'
{
ListThingGroupsForThingResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListThingGroupsForThingResponse -> Maybe [GroupNameAndArn]
thingGroups :: Prelude.Maybe [GroupNameAndArn],
ListThingGroupsForThingResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ListThingGroupsForThingResponse
-> ListThingGroupsForThingResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListThingGroupsForThingResponse
-> ListThingGroupsForThingResponse -> Bool
$c/= :: ListThingGroupsForThingResponse
-> ListThingGroupsForThingResponse -> Bool
== :: ListThingGroupsForThingResponse
-> ListThingGroupsForThingResponse -> Bool
$c== :: ListThingGroupsForThingResponse
-> ListThingGroupsForThingResponse -> Bool
Prelude.Eq, ReadPrec [ListThingGroupsForThingResponse]
ReadPrec ListThingGroupsForThingResponse
Int -> ReadS ListThingGroupsForThingResponse
ReadS [ListThingGroupsForThingResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListThingGroupsForThingResponse]
$creadListPrec :: ReadPrec [ListThingGroupsForThingResponse]
readPrec :: ReadPrec ListThingGroupsForThingResponse
$creadPrec :: ReadPrec ListThingGroupsForThingResponse
readList :: ReadS [ListThingGroupsForThingResponse]
$creadList :: ReadS [ListThingGroupsForThingResponse]
readsPrec :: Int -> ReadS ListThingGroupsForThingResponse
$creadsPrec :: Int -> ReadS ListThingGroupsForThingResponse
Prelude.Read, Int -> ListThingGroupsForThingResponse -> ShowS
[ListThingGroupsForThingResponse] -> ShowS
ListThingGroupsForThingResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListThingGroupsForThingResponse] -> ShowS
$cshowList :: [ListThingGroupsForThingResponse] -> ShowS
show :: ListThingGroupsForThingResponse -> String
$cshow :: ListThingGroupsForThingResponse -> String
showsPrec :: Int -> ListThingGroupsForThingResponse -> ShowS
$cshowsPrec :: Int -> ListThingGroupsForThingResponse -> ShowS
Prelude.Show, forall x.
Rep ListThingGroupsForThingResponse x
-> ListThingGroupsForThingResponse
forall x.
ListThingGroupsForThingResponse
-> Rep ListThingGroupsForThingResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListThingGroupsForThingResponse x
-> ListThingGroupsForThingResponse
$cfrom :: forall x.
ListThingGroupsForThingResponse
-> Rep ListThingGroupsForThingResponse x
Prelude.Generic)
newListThingGroupsForThingResponse ::
Prelude.Int ->
ListThingGroupsForThingResponse
newListThingGroupsForThingResponse :: Int -> ListThingGroupsForThingResponse
newListThingGroupsForThingResponse Int
pHttpStatus_ =
ListThingGroupsForThingResponse'
{ $sel:nextToken:ListThingGroupsForThingResponse' :: Maybe Text
nextToken =
forall a. Maybe a
Prelude.Nothing,
$sel:thingGroups:ListThingGroupsForThingResponse' :: Maybe [GroupNameAndArn]
thingGroups = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListThingGroupsForThingResponse' :: Int
httpStatus = Int
pHttpStatus_
}
listThingGroupsForThingResponse_nextToken :: Lens.Lens' ListThingGroupsForThingResponse (Prelude.Maybe Prelude.Text)
listThingGroupsForThingResponse_nextToken :: Lens' ListThingGroupsForThingResponse (Maybe Text)
listThingGroupsForThingResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListThingGroupsForThingResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListThingGroupsForThingResponse' :: ListThingGroupsForThingResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListThingGroupsForThingResponse
s@ListThingGroupsForThingResponse' {} Maybe Text
a -> ListThingGroupsForThingResponse
s {$sel:nextToken:ListThingGroupsForThingResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListThingGroupsForThingResponse)
listThingGroupsForThingResponse_thingGroups :: Lens.Lens' ListThingGroupsForThingResponse (Prelude.Maybe [GroupNameAndArn])
listThingGroupsForThingResponse_thingGroups :: Lens' ListThingGroupsForThingResponse (Maybe [GroupNameAndArn])
listThingGroupsForThingResponse_thingGroups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListThingGroupsForThingResponse' {Maybe [GroupNameAndArn]
thingGroups :: Maybe [GroupNameAndArn]
$sel:thingGroups:ListThingGroupsForThingResponse' :: ListThingGroupsForThingResponse -> Maybe [GroupNameAndArn]
thingGroups} -> Maybe [GroupNameAndArn]
thingGroups) (\s :: ListThingGroupsForThingResponse
s@ListThingGroupsForThingResponse' {} Maybe [GroupNameAndArn]
a -> ListThingGroupsForThingResponse
s {$sel:thingGroups:ListThingGroupsForThingResponse' :: Maybe [GroupNameAndArn]
thingGroups = Maybe [GroupNameAndArn]
a} :: ListThingGroupsForThingResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
listThingGroupsForThingResponse_httpStatus :: Lens.Lens' ListThingGroupsForThingResponse Prelude.Int
listThingGroupsForThingResponse_httpStatus :: Lens' ListThingGroupsForThingResponse Int
listThingGroupsForThingResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListThingGroupsForThingResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListThingGroupsForThingResponse' :: ListThingGroupsForThingResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListThingGroupsForThingResponse
s@ListThingGroupsForThingResponse' {} Int
a -> ListThingGroupsForThingResponse
s {$sel:httpStatus:ListThingGroupsForThingResponse' :: Int
httpStatus = Int
a} :: ListThingGroupsForThingResponse)
instance
Prelude.NFData
ListThingGroupsForThingResponse
where
rnf :: ListThingGroupsForThingResponse -> ()
rnf ListThingGroupsForThingResponse' {Int
Maybe [GroupNameAndArn]
Maybe Text
httpStatus :: Int
thingGroups :: Maybe [GroupNameAndArn]
nextToken :: Maybe Text
$sel:httpStatus:ListThingGroupsForThingResponse' :: ListThingGroupsForThingResponse -> Int
$sel:thingGroups:ListThingGroupsForThingResponse' :: ListThingGroupsForThingResponse -> Maybe [GroupNameAndArn]
$sel:nextToken:ListThingGroupsForThingResponse' :: ListThingGroupsForThingResponse -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [GroupNameAndArn]
thingGroups
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus