{-# 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.ListTargetsForPolicy
(
ListTargetsForPolicy (..),
newListTargetsForPolicy,
listTargetsForPolicy_marker,
listTargetsForPolicy_pageSize,
listTargetsForPolicy_policyName,
ListTargetsForPolicyResponse (..),
newListTargetsForPolicyResponse,
listTargetsForPolicyResponse_nextMarker,
listTargetsForPolicyResponse_targets,
listTargetsForPolicyResponse_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 ListTargetsForPolicy = ListTargetsForPolicy'
{
ListTargetsForPolicy -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
ListTargetsForPolicy -> Maybe Natural
pageSize :: Prelude.Maybe Prelude.Natural,
ListTargetsForPolicy -> Text
policyName :: Prelude.Text
}
deriving (ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
$c/= :: ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
== :: ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
$c== :: ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
Prelude.Eq, ReadPrec [ListTargetsForPolicy]
ReadPrec ListTargetsForPolicy
Int -> ReadS ListTargetsForPolicy
ReadS [ListTargetsForPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTargetsForPolicy]
$creadListPrec :: ReadPrec [ListTargetsForPolicy]
readPrec :: ReadPrec ListTargetsForPolicy
$creadPrec :: ReadPrec ListTargetsForPolicy
readList :: ReadS [ListTargetsForPolicy]
$creadList :: ReadS [ListTargetsForPolicy]
readsPrec :: Int -> ReadS ListTargetsForPolicy
$creadsPrec :: Int -> ReadS ListTargetsForPolicy
Prelude.Read, Int -> ListTargetsForPolicy -> ShowS
[ListTargetsForPolicy] -> ShowS
ListTargetsForPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTargetsForPolicy] -> ShowS
$cshowList :: [ListTargetsForPolicy] -> ShowS
show :: ListTargetsForPolicy -> String
$cshow :: ListTargetsForPolicy -> String
showsPrec :: Int -> ListTargetsForPolicy -> ShowS
$cshowsPrec :: Int -> ListTargetsForPolicy -> ShowS
Prelude.Show, forall x. Rep ListTargetsForPolicy x -> ListTargetsForPolicy
forall x. ListTargetsForPolicy -> Rep ListTargetsForPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTargetsForPolicy x -> ListTargetsForPolicy
$cfrom :: forall x. ListTargetsForPolicy -> Rep ListTargetsForPolicy x
Prelude.Generic)
newListTargetsForPolicy ::
Prelude.Text ->
ListTargetsForPolicy
newListTargetsForPolicy :: Text -> ListTargetsForPolicy
newListTargetsForPolicy Text
pPolicyName_ =
ListTargetsForPolicy'
{ $sel:marker:ListTargetsForPolicy' :: Maybe Text
marker = forall a. Maybe a
Prelude.Nothing,
$sel:pageSize:ListTargetsForPolicy' :: Maybe Natural
pageSize = forall a. Maybe a
Prelude.Nothing,
$sel:policyName:ListTargetsForPolicy' :: Text
policyName = Text
pPolicyName_
}
listTargetsForPolicy_marker :: Lens.Lens' ListTargetsForPolicy (Prelude.Maybe Prelude.Text)
listTargetsForPolicy_marker :: Lens' ListTargetsForPolicy (Maybe Text)
listTargetsForPolicy_marker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicy' {Maybe Text
marker :: Maybe Text
$sel:marker:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListTargetsForPolicy
s@ListTargetsForPolicy' {} Maybe Text
a -> ListTargetsForPolicy
s {$sel:marker:ListTargetsForPolicy' :: Maybe Text
marker = Maybe Text
a} :: ListTargetsForPolicy)
listTargetsForPolicy_pageSize :: Lens.Lens' ListTargetsForPolicy (Prelude.Maybe Prelude.Natural)
listTargetsForPolicy_pageSize :: Lens' ListTargetsForPolicy (Maybe Natural)
listTargetsForPolicy_pageSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicy' {Maybe Natural
pageSize :: Maybe Natural
$sel:pageSize:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Natural
pageSize} -> Maybe Natural
pageSize) (\s :: ListTargetsForPolicy
s@ListTargetsForPolicy' {} Maybe Natural
a -> ListTargetsForPolicy
s {$sel:pageSize:ListTargetsForPolicy' :: Maybe Natural
pageSize = Maybe Natural
a} :: ListTargetsForPolicy)
listTargetsForPolicy_policyName :: Lens.Lens' ListTargetsForPolicy Prelude.Text
listTargetsForPolicy_policyName :: Lens' ListTargetsForPolicy Text
listTargetsForPolicy_policyName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicy' {Text
policyName :: Text
$sel:policyName:ListTargetsForPolicy' :: ListTargetsForPolicy -> Text
policyName} -> Text
policyName) (\s :: ListTargetsForPolicy
s@ListTargetsForPolicy' {} Text
a -> ListTargetsForPolicy
s {$sel:policyName:ListTargetsForPolicy' :: Text
policyName = Text
a} :: ListTargetsForPolicy)
instance Core.AWSPager ListTargetsForPolicy where
page :: ListTargetsForPolicy
-> AWSResponse ListTargetsForPolicy -> Maybe ListTargetsForPolicy
page ListTargetsForPolicy
rq AWSResponse ListTargetsForPolicy
rs
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListTargetsForPolicy
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListTargetsForPolicyResponse (Maybe Text)
listTargetsForPolicyResponse_nextMarker
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 ListTargetsForPolicy
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListTargetsForPolicyResponse (Maybe [Text])
listTargetsForPolicyResponse_targets
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.$ ListTargetsForPolicy
rq
forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListTargetsForPolicy (Maybe Text)
listTargetsForPolicy_marker
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListTargetsForPolicy
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListTargetsForPolicyResponse (Maybe Text)
listTargetsForPolicyResponse_nextMarker
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 ListTargetsForPolicy where
type
AWSResponse ListTargetsForPolicy =
ListTargetsForPolicyResponse
request :: (Service -> Service)
-> ListTargetsForPolicy -> Request ListTargetsForPolicy
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListTargetsForPolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse ListTargetsForPolicy)))
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 [Text] -> Int -> ListTargetsForPolicyResponse
ListTargetsForPolicyResponse'
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
"nextMarker")
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
"targets" 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 ListTargetsForPolicy where
hashWithSalt :: Int -> ListTargetsForPolicy -> Int
hashWithSalt Int
_salt ListTargetsForPolicy' {Maybe Natural
Maybe Text
Text
policyName :: Text
pageSize :: Maybe Natural
marker :: Maybe Text
$sel:policyName:ListTargetsForPolicy' :: ListTargetsForPolicy -> Text
$sel:pageSize:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Natural
$sel:marker:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
marker
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
pageSize
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
policyName
instance Prelude.NFData ListTargetsForPolicy where
rnf :: ListTargetsForPolicy -> ()
rnf ListTargetsForPolicy' {Maybe Natural
Maybe Text
Text
policyName :: Text
pageSize :: Maybe Natural
marker :: Maybe Text
$sel:policyName:ListTargetsForPolicy' :: ListTargetsForPolicy -> Text
$sel:pageSize:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Natural
$sel:marker:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
marker
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
pageSize
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
policyName
instance Data.ToHeaders ListTargetsForPolicy where
toHeaders :: ListTargetsForPolicy -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
instance Data.ToJSON ListTargetsForPolicy where
toJSON :: ListTargetsForPolicy -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)
instance Data.ToPath ListTargetsForPolicy where
toPath :: ListTargetsForPolicy -> ByteString
toPath ListTargetsForPolicy' {Maybe Natural
Maybe Text
Text
policyName :: Text
pageSize :: Maybe Natural
marker :: Maybe Text
$sel:policyName:ListTargetsForPolicy' :: ListTargetsForPolicy -> Text
$sel:pageSize:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Natural
$sel:marker:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Text
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/policy-targets/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
policyName]
instance Data.ToQuery ListTargetsForPolicy where
toQuery :: ListTargetsForPolicy -> QueryString
toQuery ListTargetsForPolicy' {Maybe Natural
Maybe Text
Text
policyName :: Text
pageSize :: Maybe Natural
marker :: Maybe Text
$sel:policyName:ListTargetsForPolicy' :: ListTargetsForPolicy -> Text
$sel:pageSize:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Natural
$sel:marker:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Text
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"marker" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
marker,
ByteString
"pageSize" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
pageSize
]
data ListTargetsForPolicyResponse = ListTargetsForPolicyResponse'
{
ListTargetsForPolicyResponse -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text,
ListTargetsForPolicyResponse -> Maybe [Text]
targets :: Prelude.Maybe [Prelude.Text],
ListTargetsForPolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
$c/= :: ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
== :: ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
$c== :: ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
Prelude.Eq, ReadPrec [ListTargetsForPolicyResponse]
ReadPrec ListTargetsForPolicyResponse
Int -> ReadS ListTargetsForPolicyResponse
ReadS [ListTargetsForPolicyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTargetsForPolicyResponse]
$creadListPrec :: ReadPrec [ListTargetsForPolicyResponse]
readPrec :: ReadPrec ListTargetsForPolicyResponse
$creadPrec :: ReadPrec ListTargetsForPolicyResponse
readList :: ReadS [ListTargetsForPolicyResponse]
$creadList :: ReadS [ListTargetsForPolicyResponse]
readsPrec :: Int -> ReadS ListTargetsForPolicyResponse
$creadsPrec :: Int -> ReadS ListTargetsForPolicyResponse
Prelude.Read, Int -> ListTargetsForPolicyResponse -> ShowS
[ListTargetsForPolicyResponse] -> ShowS
ListTargetsForPolicyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTargetsForPolicyResponse] -> ShowS
$cshowList :: [ListTargetsForPolicyResponse] -> ShowS
show :: ListTargetsForPolicyResponse -> String
$cshow :: ListTargetsForPolicyResponse -> String
showsPrec :: Int -> ListTargetsForPolicyResponse -> ShowS
$cshowsPrec :: Int -> ListTargetsForPolicyResponse -> ShowS
Prelude.Show, forall x.
Rep ListTargetsForPolicyResponse x -> ListTargetsForPolicyResponse
forall x.
ListTargetsForPolicyResponse -> Rep ListTargetsForPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListTargetsForPolicyResponse x -> ListTargetsForPolicyResponse
$cfrom :: forall x.
ListTargetsForPolicyResponse -> Rep ListTargetsForPolicyResponse x
Prelude.Generic)
newListTargetsForPolicyResponse ::
Prelude.Int ->
ListTargetsForPolicyResponse
newListTargetsForPolicyResponse :: Int -> ListTargetsForPolicyResponse
newListTargetsForPolicyResponse Int
pHttpStatus_ =
ListTargetsForPolicyResponse'
{ $sel:nextMarker:ListTargetsForPolicyResponse' :: Maybe Text
nextMarker =
forall a. Maybe a
Prelude.Nothing,
$sel:targets:ListTargetsForPolicyResponse' :: Maybe [Text]
targets = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListTargetsForPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
}
listTargetsForPolicyResponse_nextMarker :: Lens.Lens' ListTargetsForPolicyResponse (Prelude.Maybe Prelude.Text)
listTargetsForPolicyResponse_nextMarker :: Lens' ListTargetsForPolicyResponse (Maybe Text)
listTargetsForPolicyResponse_nextMarker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicyResponse' {Maybe Text
nextMarker :: Maybe Text
$sel:nextMarker:ListTargetsForPolicyResponse' :: ListTargetsForPolicyResponse -> Maybe Text
nextMarker} -> Maybe Text
nextMarker) (\s :: ListTargetsForPolicyResponse
s@ListTargetsForPolicyResponse' {} Maybe Text
a -> ListTargetsForPolicyResponse
s {$sel:nextMarker:ListTargetsForPolicyResponse' :: Maybe Text
nextMarker = Maybe Text
a} :: ListTargetsForPolicyResponse)
listTargetsForPolicyResponse_targets :: Lens.Lens' ListTargetsForPolicyResponse (Prelude.Maybe [Prelude.Text])
listTargetsForPolicyResponse_targets :: Lens' ListTargetsForPolicyResponse (Maybe [Text])
listTargetsForPolicyResponse_targets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicyResponse' {Maybe [Text]
targets :: Maybe [Text]
$sel:targets:ListTargetsForPolicyResponse' :: ListTargetsForPolicyResponse -> Maybe [Text]
targets} -> Maybe [Text]
targets) (\s :: ListTargetsForPolicyResponse
s@ListTargetsForPolicyResponse' {} Maybe [Text]
a -> ListTargetsForPolicyResponse
s {$sel:targets:ListTargetsForPolicyResponse' :: Maybe [Text]
targets = Maybe [Text]
a} :: ListTargetsForPolicyResponse) 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
listTargetsForPolicyResponse_httpStatus :: Lens.Lens' ListTargetsForPolicyResponse Prelude.Int
listTargetsForPolicyResponse_httpStatus :: Lens' ListTargetsForPolicyResponse Int
listTargetsForPolicyResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListTargetsForPolicyResponse' :: ListTargetsForPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListTargetsForPolicyResponse
s@ListTargetsForPolicyResponse' {} Int
a -> ListTargetsForPolicyResponse
s {$sel:httpStatus:ListTargetsForPolicyResponse' :: Int
httpStatus = Int
a} :: ListTargetsForPolicyResponse)
instance Prelude.NFData ListTargetsForPolicyResponse where
rnf :: ListTargetsForPolicyResponse -> ()
rnf ListTargetsForPolicyResponse' {Int
Maybe [Text]
Maybe Text
httpStatus :: Int
targets :: Maybe [Text]
nextMarker :: Maybe Text
$sel:httpStatus:ListTargetsForPolicyResponse' :: ListTargetsForPolicyResponse -> Int
$sel:targets:ListTargetsForPolicyResponse' :: ListTargetsForPolicyResponse -> Maybe [Text]
$sel:nextMarker:ListTargetsForPolicyResponse' :: ListTargetsForPolicyResponse -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextMarker
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
targets
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus