{-# 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.AttachThingPrincipal
(
AttachThingPrincipal (..),
newAttachThingPrincipal,
attachThingPrincipal_thingName,
attachThingPrincipal_principal,
AttachThingPrincipalResponse (..),
newAttachThingPrincipalResponse,
attachThingPrincipalResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.IoT.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
data AttachThingPrincipal = AttachThingPrincipal'
{
AttachThingPrincipal -> Text
thingName :: Prelude.Text,
AttachThingPrincipal -> Text
principal :: Prelude.Text
}
deriving (AttachThingPrincipal -> AttachThingPrincipal -> Bool
(AttachThingPrincipal -> AttachThingPrincipal -> Bool)
-> (AttachThingPrincipal -> AttachThingPrincipal -> Bool)
-> Eq AttachThingPrincipal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachThingPrincipal -> AttachThingPrincipal -> Bool
$c/= :: AttachThingPrincipal -> AttachThingPrincipal -> Bool
== :: AttachThingPrincipal -> AttachThingPrincipal -> Bool
$c== :: AttachThingPrincipal -> AttachThingPrincipal -> Bool
Prelude.Eq, ReadPrec [AttachThingPrincipal]
ReadPrec AttachThingPrincipal
Int -> ReadS AttachThingPrincipal
ReadS [AttachThingPrincipal]
(Int -> ReadS AttachThingPrincipal)
-> ReadS [AttachThingPrincipal]
-> ReadPrec AttachThingPrincipal
-> ReadPrec [AttachThingPrincipal]
-> Read AttachThingPrincipal
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachThingPrincipal]
$creadListPrec :: ReadPrec [AttachThingPrincipal]
readPrec :: ReadPrec AttachThingPrincipal
$creadPrec :: ReadPrec AttachThingPrincipal
readList :: ReadS [AttachThingPrincipal]
$creadList :: ReadS [AttachThingPrincipal]
readsPrec :: Int -> ReadS AttachThingPrincipal
$creadsPrec :: Int -> ReadS AttachThingPrincipal
Prelude.Read, Int -> AttachThingPrincipal -> ShowS
[AttachThingPrincipal] -> ShowS
AttachThingPrincipal -> String
(Int -> AttachThingPrincipal -> ShowS)
-> (AttachThingPrincipal -> String)
-> ([AttachThingPrincipal] -> ShowS)
-> Show AttachThingPrincipal
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachThingPrincipal] -> ShowS
$cshowList :: [AttachThingPrincipal] -> ShowS
show :: AttachThingPrincipal -> String
$cshow :: AttachThingPrincipal -> String
showsPrec :: Int -> AttachThingPrincipal -> ShowS
$cshowsPrec :: Int -> AttachThingPrincipal -> ShowS
Prelude.Show, (forall x. AttachThingPrincipal -> Rep AttachThingPrincipal x)
-> (forall x. Rep AttachThingPrincipal x -> AttachThingPrincipal)
-> Generic AttachThingPrincipal
forall x. Rep AttachThingPrincipal x -> AttachThingPrincipal
forall x. AttachThingPrincipal -> Rep AttachThingPrincipal x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttachThingPrincipal x -> AttachThingPrincipal
$cfrom :: forall x. AttachThingPrincipal -> Rep AttachThingPrincipal x
Prelude.Generic)
newAttachThingPrincipal ::
Prelude.Text ->
Prelude.Text ->
AttachThingPrincipal
newAttachThingPrincipal :: Text -> Text -> AttachThingPrincipal
newAttachThingPrincipal Text
pThingName_ Text
pPrincipal_ =
AttachThingPrincipal' :: Text -> Text -> AttachThingPrincipal
AttachThingPrincipal'
{ $sel:thingName:AttachThingPrincipal' :: Text
thingName = Text
pThingName_,
$sel:principal:AttachThingPrincipal' :: Text
principal = Text
pPrincipal_
}
attachThingPrincipal_thingName :: Lens.Lens' AttachThingPrincipal Prelude.Text
attachThingPrincipal_thingName :: (Text -> f Text) -> AttachThingPrincipal -> f AttachThingPrincipal
attachThingPrincipal_thingName = (AttachThingPrincipal -> Text)
-> (AttachThingPrincipal -> Text -> AttachThingPrincipal)
-> Lens AttachThingPrincipal AttachThingPrincipal Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachThingPrincipal' {Text
thingName :: Text
$sel:thingName:AttachThingPrincipal' :: AttachThingPrincipal -> Text
thingName} -> Text
thingName) (\s :: AttachThingPrincipal
s@AttachThingPrincipal' {} Text
a -> AttachThingPrincipal
s {$sel:thingName:AttachThingPrincipal' :: Text
thingName = Text
a} :: AttachThingPrincipal)
attachThingPrincipal_principal :: Lens.Lens' AttachThingPrincipal Prelude.Text
attachThingPrincipal_principal :: (Text -> f Text) -> AttachThingPrincipal -> f AttachThingPrincipal
attachThingPrincipal_principal = (AttachThingPrincipal -> Text)
-> (AttachThingPrincipal -> Text -> AttachThingPrincipal)
-> Lens AttachThingPrincipal AttachThingPrincipal Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachThingPrincipal' {Text
principal :: Text
$sel:principal:AttachThingPrincipal' :: AttachThingPrincipal -> Text
principal} -> Text
principal) (\s :: AttachThingPrincipal
s@AttachThingPrincipal' {} Text
a -> AttachThingPrincipal
s {$sel:principal:AttachThingPrincipal' :: Text
principal = Text
a} :: AttachThingPrincipal)
instance Core.AWSRequest AttachThingPrincipal where
type
AWSResponse AttachThingPrincipal =
AttachThingPrincipalResponse
request :: AttachThingPrincipal -> Request AttachThingPrincipal
request = Service -> AttachThingPrincipal -> Request AttachThingPrincipal
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
response :: Logger
-> Service
-> Proxy AttachThingPrincipal
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse AttachThingPrincipal)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse AttachThingPrincipal))
-> Logger
-> Service
-> Proxy AttachThingPrincipal
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse AttachThingPrincipal)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
( \Int
s ResponseHeaders
h ()
x ->
Int -> AttachThingPrincipalResponse
AttachThingPrincipalResponse'
(Int -> AttachThingPrincipalResponse)
-> Either String Int -> Either String AttachThingPrincipalResponse
forall (f :: * -> *) a b. Functor 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 AttachThingPrincipal
instance Prelude.NFData AttachThingPrincipal
instance Core.ToHeaders AttachThingPrincipal where
toHeaders :: AttachThingPrincipal -> ResponseHeaders
toHeaders AttachThingPrincipal' {Text
principal :: Text
thingName :: Text
$sel:principal:AttachThingPrincipal' :: AttachThingPrincipal -> Text
$sel:thingName:AttachThingPrincipal' :: AttachThingPrincipal -> Text
..} =
[ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[HeaderName
"x-amzn-principal" HeaderName -> Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Text
principal]
instance Core.ToJSON AttachThingPrincipal where
toJSON :: AttachThingPrincipal -> Value
toJSON = Value -> AttachThingPrincipal -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)
instance Core.ToPath AttachThingPrincipal where
toPath :: AttachThingPrincipal -> ByteString
toPath AttachThingPrincipal' {Text
principal :: Text
thingName :: Text
$sel:principal:AttachThingPrincipal' :: AttachThingPrincipal -> Text
$sel:thingName:AttachThingPrincipal' :: AttachThingPrincipal -> Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/things/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
thingName, ByteString
"/principals"]
instance Core.ToQuery AttachThingPrincipal where
toQuery :: AttachThingPrincipal -> QueryString
toQuery = QueryString -> AttachThingPrincipal -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data AttachThingPrincipalResponse = AttachThingPrincipalResponse'
{
AttachThingPrincipalResponse -> Int
httpStatus :: Prelude.Int
}
deriving (AttachThingPrincipalResponse
-> AttachThingPrincipalResponse -> Bool
(AttachThingPrincipalResponse
-> AttachThingPrincipalResponse -> Bool)
-> (AttachThingPrincipalResponse
-> AttachThingPrincipalResponse -> Bool)
-> Eq AttachThingPrincipalResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachThingPrincipalResponse
-> AttachThingPrincipalResponse -> Bool
$c/= :: AttachThingPrincipalResponse
-> AttachThingPrincipalResponse -> Bool
== :: AttachThingPrincipalResponse
-> AttachThingPrincipalResponse -> Bool
$c== :: AttachThingPrincipalResponse
-> AttachThingPrincipalResponse -> Bool
Prelude.Eq, ReadPrec [AttachThingPrincipalResponse]
ReadPrec AttachThingPrincipalResponse
Int -> ReadS AttachThingPrincipalResponse
ReadS [AttachThingPrincipalResponse]
(Int -> ReadS AttachThingPrincipalResponse)
-> ReadS [AttachThingPrincipalResponse]
-> ReadPrec AttachThingPrincipalResponse
-> ReadPrec [AttachThingPrincipalResponse]
-> Read AttachThingPrincipalResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachThingPrincipalResponse]
$creadListPrec :: ReadPrec [AttachThingPrincipalResponse]
readPrec :: ReadPrec AttachThingPrincipalResponse
$creadPrec :: ReadPrec AttachThingPrincipalResponse
readList :: ReadS [AttachThingPrincipalResponse]
$creadList :: ReadS [AttachThingPrincipalResponse]
readsPrec :: Int -> ReadS AttachThingPrincipalResponse
$creadsPrec :: Int -> ReadS AttachThingPrincipalResponse
Prelude.Read, Int -> AttachThingPrincipalResponse -> ShowS
[AttachThingPrincipalResponse] -> ShowS
AttachThingPrincipalResponse -> String
(Int -> AttachThingPrincipalResponse -> ShowS)
-> (AttachThingPrincipalResponse -> String)
-> ([AttachThingPrincipalResponse] -> ShowS)
-> Show AttachThingPrincipalResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachThingPrincipalResponse] -> ShowS
$cshowList :: [AttachThingPrincipalResponse] -> ShowS
show :: AttachThingPrincipalResponse -> String
$cshow :: AttachThingPrincipalResponse -> String
showsPrec :: Int -> AttachThingPrincipalResponse -> ShowS
$cshowsPrec :: Int -> AttachThingPrincipalResponse -> ShowS
Prelude.Show, (forall x.
AttachThingPrincipalResponse -> Rep AttachThingPrincipalResponse x)
-> (forall x.
Rep AttachThingPrincipalResponse x -> AttachThingPrincipalResponse)
-> Generic AttachThingPrincipalResponse
forall x.
Rep AttachThingPrincipalResponse x -> AttachThingPrincipalResponse
forall x.
AttachThingPrincipalResponse -> Rep AttachThingPrincipalResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AttachThingPrincipalResponse x -> AttachThingPrincipalResponse
$cfrom :: forall x.
AttachThingPrincipalResponse -> Rep AttachThingPrincipalResponse x
Prelude.Generic)
newAttachThingPrincipalResponse ::
Prelude.Int ->
AttachThingPrincipalResponse
newAttachThingPrincipalResponse :: Int -> AttachThingPrincipalResponse
newAttachThingPrincipalResponse Int
pHttpStatus_ =
AttachThingPrincipalResponse' :: Int -> AttachThingPrincipalResponse
AttachThingPrincipalResponse'
{ $sel:httpStatus:AttachThingPrincipalResponse' :: Int
httpStatus =
Int
pHttpStatus_
}
attachThingPrincipalResponse_httpStatus :: Lens.Lens' AttachThingPrincipalResponse Prelude.Int
attachThingPrincipalResponse_httpStatus :: (Int -> f Int)
-> AttachThingPrincipalResponse -> f AttachThingPrincipalResponse
attachThingPrincipalResponse_httpStatus = (AttachThingPrincipalResponse -> Int)
-> (AttachThingPrincipalResponse
-> Int -> AttachThingPrincipalResponse)
-> Lens
AttachThingPrincipalResponse AttachThingPrincipalResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachThingPrincipalResponse' {Int
httpStatus :: Int
$sel:httpStatus:AttachThingPrincipalResponse' :: AttachThingPrincipalResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AttachThingPrincipalResponse
s@AttachThingPrincipalResponse' {} Int
a -> AttachThingPrincipalResponse
s {$sel:httpStatus:AttachThingPrincipalResponse' :: Int
httpStatus = Int
a} :: AttachThingPrincipalResponse)
instance Prelude.NFData AttachThingPrincipalResponse