{-# 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.Grafana.UpdatePermissions
(
UpdatePermissions (..),
newUpdatePermissions,
updatePermissions_updateInstructionBatch,
updatePermissions_workspaceId,
UpdatePermissionsResponse (..),
newUpdatePermissionsResponse,
updatePermissionsResponse_httpStatus,
updatePermissionsResponse_errors,
)
where
import qualified Amazonka.Core as Core
import Amazonka.Grafana.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 UpdatePermissions = UpdatePermissions'
{
UpdatePermissions -> [UpdateInstruction]
updateInstructionBatch :: [UpdateInstruction],
UpdatePermissions -> Text
workspaceId :: Prelude.Text
}
deriving (UpdatePermissions -> UpdatePermissions -> Bool
(UpdatePermissions -> UpdatePermissions -> Bool)
-> (UpdatePermissions -> UpdatePermissions -> Bool)
-> Eq UpdatePermissions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePermissions -> UpdatePermissions -> Bool
$c/= :: UpdatePermissions -> UpdatePermissions -> Bool
== :: UpdatePermissions -> UpdatePermissions -> Bool
$c== :: UpdatePermissions -> UpdatePermissions -> Bool
Prelude.Eq, ReadPrec [UpdatePermissions]
ReadPrec UpdatePermissions
Int -> ReadS UpdatePermissions
ReadS [UpdatePermissions]
(Int -> ReadS UpdatePermissions)
-> ReadS [UpdatePermissions]
-> ReadPrec UpdatePermissions
-> ReadPrec [UpdatePermissions]
-> Read UpdatePermissions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePermissions]
$creadListPrec :: ReadPrec [UpdatePermissions]
readPrec :: ReadPrec UpdatePermissions
$creadPrec :: ReadPrec UpdatePermissions
readList :: ReadS [UpdatePermissions]
$creadList :: ReadS [UpdatePermissions]
readsPrec :: Int -> ReadS UpdatePermissions
$creadsPrec :: Int -> ReadS UpdatePermissions
Prelude.Read, Int -> UpdatePermissions -> ShowS
[UpdatePermissions] -> ShowS
UpdatePermissions -> String
(Int -> UpdatePermissions -> ShowS)
-> (UpdatePermissions -> String)
-> ([UpdatePermissions] -> ShowS)
-> Show UpdatePermissions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePermissions] -> ShowS
$cshowList :: [UpdatePermissions] -> ShowS
show :: UpdatePermissions -> String
$cshow :: UpdatePermissions -> String
showsPrec :: Int -> UpdatePermissions -> ShowS
$cshowsPrec :: Int -> UpdatePermissions -> ShowS
Prelude.Show, (forall x. UpdatePermissions -> Rep UpdatePermissions x)
-> (forall x. Rep UpdatePermissions x -> UpdatePermissions)
-> Generic UpdatePermissions
forall x. Rep UpdatePermissions x -> UpdatePermissions
forall x. UpdatePermissions -> Rep UpdatePermissions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdatePermissions x -> UpdatePermissions
$cfrom :: forall x. UpdatePermissions -> Rep UpdatePermissions x
Prelude.Generic)
newUpdatePermissions ::
Prelude.Text ->
UpdatePermissions
newUpdatePermissions :: Text -> UpdatePermissions
newUpdatePermissions Text
pWorkspaceId_ =
UpdatePermissions' :: [UpdateInstruction] -> Text -> UpdatePermissions
UpdatePermissions'
{ $sel:updateInstructionBatch:UpdatePermissions' :: [UpdateInstruction]
updateInstructionBatch =
[UpdateInstruction]
forall a. Monoid a => a
Prelude.mempty,
$sel:workspaceId:UpdatePermissions' :: Text
workspaceId = Text
pWorkspaceId_
}
updatePermissions_updateInstructionBatch :: Lens.Lens' UpdatePermissions [UpdateInstruction]
updatePermissions_updateInstructionBatch :: ([UpdateInstruction] -> f [UpdateInstruction])
-> UpdatePermissions -> f UpdatePermissions
updatePermissions_updateInstructionBatch = (UpdatePermissions -> [UpdateInstruction])
-> (UpdatePermissions -> [UpdateInstruction] -> UpdatePermissions)
-> Lens
UpdatePermissions
UpdatePermissions
[UpdateInstruction]
[UpdateInstruction]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePermissions' {[UpdateInstruction]
updateInstructionBatch :: [UpdateInstruction]
$sel:updateInstructionBatch:UpdatePermissions' :: UpdatePermissions -> [UpdateInstruction]
updateInstructionBatch} -> [UpdateInstruction]
updateInstructionBatch) (\s :: UpdatePermissions
s@UpdatePermissions' {} [UpdateInstruction]
a -> UpdatePermissions
s {$sel:updateInstructionBatch:UpdatePermissions' :: [UpdateInstruction]
updateInstructionBatch = [UpdateInstruction]
a} :: UpdatePermissions) (([UpdateInstruction] -> f [UpdateInstruction])
-> UpdatePermissions -> f UpdatePermissions)
-> (([UpdateInstruction] -> f [UpdateInstruction])
-> [UpdateInstruction] -> f [UpdateInstruction])
-> ([UpdateInstruction] -> f [UpdateInstruction])
-> UpdatePermissions
-> f UpdatePermissions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([UpdateInstruction] -> f [UpdateInstruction])
-> [UpdateInstruction] -> f [UpdateInstruction]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
updatePermissions_workspaceId :: Lens.Lens' UpdatePermissions Prelude.Text
updatePermissions_workspaceId :: (Text -> f Text) -> UpdatePermissions -> f UpdatePermissions
updatePermissions_workspaceId = (UpdatePermissions -> Text)
-> (UpdatePermissions -> Text -> UpdatePermissions)
-> Lens UpdatePermissions UpdatePermissions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePermissions' {Text
workspaceId :: Text
$sel:workspaceId:UpdatePermissions' :: UpdatePermissions -> Text
workspaceId} -> Text
workspaceId) (\s :: UpdatePermissions
s@UpdatePermissions' {} Text
a -> UpdatePermissions
s {$sel:workspaceId:UpdatePermissions' :: Text
workspaceId = Text
a} :: UpdatePermissions)
instance Core.AWSRequest UpdatePermissions where
type
AWSResponse UpdatePermissions =
UpdatePermissionsResponse
request :: UpdatePermissions -> Request UpdatePermissions
request = Service -> UpdatePermissions -> Request UpdatePermissions
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
response :: Logger
-> Service
-> Proxy UpdatePermissions
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse UpdatePermissions)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse UpdatePermissions))
-> Logger
-> Service
-> Proxy UpdatePermissions
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse UpdatePermissions)))
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 ->
Int -> [UpdateError] -> UpdatePermissionsResponse
UpdatePermissionsResponse'
(Int -> [UpdateError] -> UpdatePermissionsResponse)
-> Either String Int
-> Either String ([UpdateError] -> UpdatePermissionsResponse)
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))
Either String ([UpdateError] -> UpdatePermissionsResponse)
-> Either String [UpdateError]
-> Either String UpdatePermissionsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [UpdateError])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"errors" Either String (Maybe [UpdateError])
-> [UpdateError] -> Either String [UpdateError]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [UpdateError]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable UpdatePermissions
instance Prelude.NFData UpdatePermissions
instance Core.ToHeaders UpdatePermissions where
toHeaders :: UpdatePermissions -> ResponseHeaders
toHeaders =
ResponseHeaders -> UpdatePermissions -> 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.ToJSON UpdatePermissions where
toJSON :: UpdatePermissions -> Value
toJSON UpdatePermissions' {[UpdateInstruction]
Text
workspaceId :: Text
updateInstructionBatch :: [UpdateInstruction]
$sel:workspaceId:UpdatePermissions' :: UpdatePermissions -> Text
$sel:updateInstructionBatch:UpdatePermissions' :: UpdatePermissions -> [UpdateInstruction]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
( Text
"updateInstructionBatch"
Text -> [UpdateInstruction] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [UpdateInstruction]
updateInstructionBatch
)
]
)
instance Core.ToPath UpdatePermissions where
toPath :: UpdatePermissions -> ByteString
toPath UpdatePermissions' {[UpdateInstruction]
Text
workspaceId :: Text
updateInstructionBatch :: [UpdateInstruction]
$sel:workspaceId:UpdatePermissions' :: UpdatePermissions -> Text
$sel:updateInstructionBatch:UpdatePermissions' :: UpdatePermissions -> [UpdateInstruction]
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/workspaces/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
workspaceId,
ByteString
"/permissions"
]
instance Core.ToQuery UpdatePermissions where
toQuery :: UpdatePermissions -> QueryString
toQuery = QueryString -> UpdatePermissions -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data UpdatePermissionsResponse = UpdatePermissionsResponse'
{
UpdatePermissionsResponse -> Int
httpStatus :: Prelude.Int,
UpdatePermissionsResponse -> [UpdateError]
errors :: [UpdateError]
}
deriving (UpdatePermissionsResponse -> UpdatePermissionsResponse -> Bool
(UpdatePermissionsResponse -> UpdatePermissionsResponse -> Bool)
-> (UpdatePermissionsResponse -> UpdatePermissionsResponse -> Bool)
-> Eq UpdatePermissionsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePermissionsResponse -> UpdatePermissionsResponse -> Bool
$c/= :: UpdatePermissionsResponse -> UpdatePermissionsResponse -> Bool
== :: UpdatePermissionsResponse -> UpdatePermissionsResponse -> Bool
$c== :: UpdatePermissionsResponse -> UpdatePermissionsResponse -> Bool
Prelude.Eq, ReadPrec [UpdatePermissionsResponse]
ReadPrec UpdatePermissionsResponse
Int -> ReadS UpdatePermissionsResponse
ReadS [UpdatePermissionsResponse]
(Int -> ReadS UpdatePermissionsResponse)
-> ReadS [UpdatePermissionsResponse]
-> ReadPrec UpdatePermissionsResponse
-> ReadPrec [UpdatePermissionsResponse]
-> Read UpdatePermissionsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePermissionsResponse]
$creadListPrec :: ReadPrec [UpdatePermissionsResponse]
readPrec :: ReadPrec UpdatePermissionsResponse
$creadPrec :: ReadPrec UpdatePermissionsResponse
readList :: ReadS [UpdatePermissionsResponse]
$creadList :: ReadS [UpdatePermissionsResponse]
readsPrec :: Int -> ReadS UpdatePermissionsResponse
$creadsPrec :: Int -> ReadS UpdatePermissionsResponse
Prelude.Read, Int -> UpdatePermissionsResponse -> ShowS
[UpdatePermissionsResponse] -> ShowS
UpdatePermissionsResponse -> String
(Int -> UpdatePermissionsResponse -> ShowS)
-> (UpdatePermissionsResponse -> String)
-> ([UpdatePermissionsResponse] -> ShowS)
-> Show UpdatePermissionsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePermissionsResponse] -> ShowS
$cshowList :: [UpdatePermissionsResponse] -> ShowS
show :: UpdatePermissionsResponse -> String
$cshow :: UpdatePermissionsResponse -> String
showsPrec :: Int -> UpdatePermissionsResponse -> ShowS
$cshowsPrec :: Int -> UpdatePermissionsResponse -> ShowS
Prelude.Show, (forall x.
UpdatePermissionsResponse -> Rep UpdatePermissionsResponse x)
-> (forall x.
Rep UpdatePermissionsResponse x -> UpdatePermissionsResponse)
-> Generic UpdatePermissionsResponse
forall x.
Rep UpdatePermissionsResponse x -> UpdatePermissionsResponse
forall x.
UpdatePermissionsResponse -> Rep UpdatePermissionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdatePermissionsResponse x -> UpdatePermissionsResponse
$cfrom :: forall x.
UpdatePermissionsResponse -> Rep UpdatePermissionsResponse x
Prelude.Generic)
newUpdatePermissionsResponse ::
Prelude.Int ->
UpdatePermissionsResponse
newUpdatePermissionsResponse :: Int -> UpdatePermissionsResponse
newUpdatePermissionsResponse Int
pHttpStatus_ =
UpdatePermissionsResponse' :: Int -> [UpdateError] -> UpdatePermissionsResponse
UpdatePermissionsResponse'
{ $sel:httpStatus:UpdatePermissionsResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:errors:UpdatePermissionsResponse' :: [UpdateError]
errors = [UpdateError]
forall a. Monoid a => a
Prelude.mempty
}
updatePermissionsResponse_httpStatus :: Lens.Lens' UpdatePermissionsResponse Prelude.Int
updatePermissionsResponse_httpStatus :: (Int -> f Int)
-> UpdatePermissionsResponse -> f UpdatePermissionsResponse
updatePermissionsResponse_httpStatus = (UpdatePermissionsResponse -> Int)
-> (UpdatePermissionsResponse -> Int -> UpdatePermissionsResponse)
-> Lens UpdatePermissionsResponse UpdatePermissionsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePermissionsResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdatePermissionsResponse' :: UpdatePermissionsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdatePermissionsResponse
s@UpdatePermissionsResponse' {} Int
a -> UpdatePermissionsResponse
s {$sel:httpStatus:UpdatePermissionsResponse' :: Int
httpStatus = Int
a} :: UpdatePermissionsResponse)
updatePermissionsResponse_errors :: Lens.Lens' UpdatePermissionsResponse [UpdateError]
updatePermissionsResponse_errors :: ([UpdateError] -> f [UpdateError])
-> UpdatePermissionsResponse -> f UpdatePermissionsResponse
updatePermissionsResponse_errors = (UpdatePermissionsResponse -> [UpdateError])
-> (UpdatePermissionsResponse
-> [UpdateError] -> UpdatePermissionsResponse)
-> Lens
UpdatePermissionsResponse
UpdatePermissionsResponse
[UpdateError]
[UpdateError]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePermissionsResponse' {[UpdateError]
errors :: [UpdateError]
$sel:errors:UpdatePermissionsResponse' :: UpdatePermissionsResponse -> [UpdateError]
errors} -> [UpdateError]
errors) (\s :: UpdatePermissionsResponse
s@UpdatePermissionsResponse' {} [UpdateError]
a -> UpdatePermissionsResponse
s {$sel:errors:UpdatePermissionsResponse' :: [UpdateError]
errors = [UpdateError]
a} :: UpdatePermissionsResponse) (([UpdateError] -> f [UpdateError])
-> UpdatePermissionsResponse -> f UpdatePermissionsResponse)
-> (([UpdateError] -> f [UpdateError])
-> [UpdateError] -> f [UpdateError])
-> ([UpdateError] -> f [UpdateError])
-> UpdatePermissionsResponse
-> f UpdatePermissionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([UpdateError] -> f [UpdateError])
-> [UpdateError] -> f [UpdateError]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Prelude.NFData UpdatePermissionsResponse