{-# 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.CognitoIdentityProvider.CreateResourceServer
(
CreateResourceServer (..),
newCreateResourceServer,
createResourceServer_scopes,
createResourceServer_userPoolId,
createResourceServer_identifier,
createResourceServer_name,
CreateResourceServerResponse (..),
newCreateResourceServerResponse,
createResourceServerResponse_httpStatus,
createResourceServerResponse_resourceServer,
)
where
import Amazonka.CognitoIdentityProvider.Types
import qualified Amazonka.Core as Core
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 CreateResourceServer = CreateResourceServer'
{
CreateResourceServer -> Maybe [ResourceServerScopeType]
scopes :: Prelude.Maybe [ResourceServerScopeType],
CreateResourceServer -> Text
userPoolId :: Prelude.Text,
CreateResourceServer -> Text
identifier :: Prelude.Text,
CreateResourceServer -> Text
name :: Prelude.Text
}
deriving (CreateResourceServer -> CreateResourceServer -> Bool
(CreateResourceServer -> CreateResourceServer -> Bool)
-> (CreateResourceServer -> CreateResourceServer -> Bool)
-> Eq CreateResourceServer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateResourceServer -> CreateResourceServer -> Bool
$c/= :: CreateResourceServer -> CreateResourceServer -> Bool
== :: CreateResourceServer -> CreateResourceServer -> Bool
$c== :: CreateResourceServer -> CreateResourceServer -> Bool
Prelude.Eq, ReadPrec [CreateResourceServer]
ReadPrec CreateResourceServer
Int -> ReadS CreateResourceServer
ReadS [CreateResourceServer]
(Int -> ReadS CreateResourceServer)
-> ReadS [CreateResourceServer]
-> ReadPrec CreateResourceServer
-> ReadPrec [CreateResourceServer]
-> Read CreateResourceServer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateResourceServer]
$creadListPrec :: ReadPrec [CreateResourceServer]
readPrec :: ReadPrec CreateResourceServer
$creadPrec :: ReadPrec CreateResourceServer
readList :: ReadS [CreateResourceServer]
$creadList :: ReadS [CreateResourceServer]
readsPrec :: Int -> ReadS CreateResourceServer
$creadsPrec :: Int -> ReadS CreateResourceServer
Prelude.Read, Int -> CreateResourceServer -> ShowS
[CreateResourceServer] -> ShowS
CreateResourceServer -> String
(Int -> CreateResourceServer -> ShowS)
-> (CreateResourceServer -> String)
-> ([CreateResourceServer] -> ShowS)
-> Show CreateResourceServer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateResourceServer] -> ShowS
$cshowList :: [CreateResourceServer] -> ShowS
show :: CreateResourceServer -> String
$cshow :: CreateResourceServer -> String
showsPrec :: Int -> CreateResourceServer -> ShowS
$cshowsPrec :: Int -> CreateResourceServer -> ShowS
Prelude.Show, (forall x. CreateResourceServer -> Rep CreateResourceServer x)
-> (forall x. Rep CreateResourceServer x -> CreateResourceServer)
-> Generic CreateResourceServer
forall x. Rep CreateResourceServer x -> CreateResourceServer
forall x. CreateResourceServer -> Rep CreateResourceServer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateResourceServer x -> CreateResourceServer
$cfrom :: forall x. CreateResourceServer -> Rep CreateResourceServer x
Prelude.Generic)
newCreateResourceServer ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
CreateResourceServer
newCreateResourceServer :: Text -> Text -> Text -> CreateResourceServer
newCreateResourceServer
Text
pUserPoolId_
Text
pIdentifier_
Text
pName_ =
CreateResourceServer' :: Maybe [ResourceServerScopeType]
-> Text -> Text -> Text -> CreateResourceServer
CreateResourceServer'
{ $sel:scopes:CreateResourceServer' :: Maybe [ResourceServerScopeType]
scopes = Maybe [ResourceServerScopeType]
forall a. Maybe a
Prelude.Nothing,
$sel:userPoolId:CreateResourceServer' :: Text
userPoolId = Text
pUserPoolId_,
$sel:identifier:CreateResourceServer' :: Text
identifier = Text
pIdentifier_,
$sel:name:CreateResourceServer' :: Text
name = Text
pName_
}
createResourceServer_scopes :: Lens.Lens' CreateResourceServer (Prelude.Maybe [ResourceServerScopeType])
createResourceServer_scopes :: (Maybe [ResourceServerScopeType]
-> f (Maybe [ResourceServerScopeType]))
-> CreateResourceServer -> f CreateResourceServer
createResourceServer_scopes = (CreateResourceServer -> Maybe [ResourceServerScopeType])
-> (CreateResourceServer
-> Maybe [ResourceServerScopeType] -> CreateResourceServer)
-> Lens
CreateResourceServer
CreateResourceServer
(Maybe [ResourceServerScopeType])
(Maybe [ResourceServerScopeType])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceServer' {Maybe [ResourceServerScopeType]
scopes :: Maybe [ResourceServerScopeType]
$sel:scopes:CreateResourceServer' :: CreateResourceServer -> Maybe [ResourceServerScopeType]
scopes} -> Maybe [ResourceServerScopeType]
scopes) (\s :: CreateResourceServer
s@CreateResourceServer' {} Maybe [ResourceServerScopeType]
a -> CreateResourceServer
s {$sel:scopes:CreateResourceServer' :: Maybe [ResourceServerScopeType]
scopes = Maybe [ResourceServerScopeType]
a} :: CreateResourceServer) ((Maybe [ResourceServerScopeType]
-> f (Maybe [ResourceServerScopeType]))
-> CreateResourceServer -> f CreateResourceServer)
-> ((Maybe [ResourceServerScopeType]
-> f (Maybe [ResourceServerScopeType]))
-> Maybe [ResourceServerScopeType]
-> f (Maybe [ResourceServerScopeType]))
-> (Maybe [ResourceServerScopeType]
-> f (Maybe [ResourceServerScopeType]))
-> CreateResourceServer
-> f CreateResourceServer
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[ResourceServerScopeType]
[ResourceServerScopeType]
[ResourceServerScopeType]
[ResourceServerScopeType]
-> Iso
(Maybe [ResourceServerScopeType])
(Maybe [ResourceServerScopeType])
(Maybe [ResourceServerScopeType])
(Maybe [ResourceServerScopeType])
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
[ResourceServerScopeType]
[ResourceServerScopeType]
[ResourceServerScopeType]
[ResourceServerScopeType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createResourceServer_userPoolId :: Lens.Lens' CreateResourceServer Prelude.Text
createResourceServer_userPoolId :: (Text -> f Text) -> CreateResourceServer -> f CreateResourceServer
createResourceServer_userPoolId = (CreateResourceServer -> Text)
-> (CreateResourceServer -> Text -> CreateResourceServer)
-> Lens CreateResourceServer CreateResourceServer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceServer' {Text
userPoolId :: Text
$sel:userPoolId:CreateResourceServer' :: CreateResourceServer -> Text
userPoolId} -> Text
userPoolId) (\s :: CreateResourceServer
s@CreateResourceServer' {} Text
a -> CreateResourceServer
s {$sel:userPoolId:CreateResourceServer' :: Text
userPoolId = Text
a} :: CreateResourceServer)
createResourceServer_identifier :: Lens.Lens' CreateResourceServer Prelude.Text
createResourceServer_identifier :: (Text -> f Text) -> CreateResourceServer -> f CreateResourceServer
createResourceServer_identifier = (CreateResourceServer -> Text)
-> (CreateResourceServer -> Text -> CreateResourceServer)
-> Lens CreateResourceServer CreateResourceServer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceServer' {Text
identifier :: Text
$sel:identifier:CreateResourceServer' :: CreateResourceServer -> Text
identifier} -> Text
identifier) (\s :: CreateResourceServer
s@CreateResourceServer' {} Text
a -> CreateResourceServer
s {$sel:identifier:CreateResourceServer' :: Text
identifier = Text
a} :: CreateResourceServer)
createResourceServer_name :: Lens.Lens' CreateResourceServer Prelude.Text
createResourceServer_name :: (Text -> f Text) -> CreateResourceServer -> f CreateResourceServer
createResourceServer_name = (CreateResourceServer -> Text)
-> (CreateResourceServer -> Text -> CreateResourceServer)
-> Lens CreateResourceServer CreateResourceServer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceServer' {Text
name :: Text
$sel:name:CreateResourceServer' :: CreateResourceServer -> Text
name} -> Text
name) (\s :: CreateResourceServer
s@CreateResourceServer' {} Text
a -> CreateResourceServer
s {$sel:name:CreateResourceServer' :: Text
name = Text
a} :: CreateResourceServer)
instance Core.AWSRequest CreateResourceServer where
type
AWSResponse CreateResourceServer =
CreateResourceServerResponse
request :: CreateResourceServer -> Request CreateResourceServer
request = Service -> CreateResourceServer -> Request CreateResourceServer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateResourceServer
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateResourceServer)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateResourceServer))
-> Logger
-> Service
-> Proxy CreateResourceServer
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateResourceServer)))
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 -> ResourceServerType -> CreateResourceServerResponse
CreateResourceServerResponse'
(Int -> ResourceServerType -> CreateResourceServerResponse)
-> Either String Int
-> Either
String (ResourceServerType -> CreateResourceServerResponse)
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 (ResourceServerType -> CreateResourceServerResponse)
-> Either String ResourceServerType
-> Either String CreateResourceServerResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String ResourceServerType
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"ResourceServer")
)
instance Prelude.Hashable CreateResourceServer
instance Prelude.NFData CreateResourceServer
instance Core.ToHeaders CreateResourceServer where
toHeaders :: CreateResourceServer -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateResourceServer -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSCognitoIdentityProviderService.CreateResourceServer" ::
Prelude.ByteString
),
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 CreateResourceServer where
toJSON :: CreateResourceServer -> Value
toJSON CreateResourceServer' {Maybe [ResourceServerScopeType]
Text
name :: Text
identifier :: Text
userPoolId :: Text
scopes :: Maybe [ResourceServerScopeType]
$sel:name:CreateResourceServer' :: CreateResourceServer -> Text
$sel:identifier:CreateResourceServer' :: CreateResourceServer -> Text
$sel:userPoolId:CreateResourceServer' :: CreateResourceServer -> Text
$sel:scopes:CreateResourceServer' :: CreateResourceServer -> Maybe [ResourceServerScopeType]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Scopes" Text -> [ResourceServerScopeType] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([ResourceServerScopeType] -> Pair)
-> Maybe [ResourceServerScopeType] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ResourceServerScopeType]
scopes,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UserPoolId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userPoolId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Identifier" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
identifier),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
]
)
instance Core.ToPath CreateResourceServer where
toPath :: CreateResourceServer -> ByteString
toPath = ByteString -> CreateResourceServer -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateResourceServer where
toQuery :: CreateResourceServer -> QueryString
toQuery = QueryString -> CreateResourceServer -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateResourceServerResponse = CreateResourceServerResponse'
{
CreateResourceServerResponse -> Int
httpStatus :: Prelude.Int,
CreateResourceServerResponse -> ResourceServerType
resourceServer :: ResourceServerType
}
deriving (CreateResourceServerResponse
-> CreateResourceServerResponse -> Bool
(CreateResourceServerResponse
-> CreateResourceServerResponse -> Bool)
-> (CreateResourceServerResponse
-> CreateResourceServerResponse -> Bool)
-> Eq CreateResourceServerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateResourceServerResponse
-> CreateResourceServerResponse -> Bool
$c/= :: CreateResourceServerResponse
-> CreateResourceServerResponse -> Bool
== :: CreateResourceServerResponse
-> CreateResourceServerResponse -> Bool
$c== :: CreateResourceServerResponse
-> CreateResourceServerResponse -> Bool
Prelude.Eq, ReadPrec [CreateResourceServerResponse]
ReadPrec CreateResourceServerResponse
Int -> ReadS CreateResourceServerResponse
ReadS [CreateResourceServerResponse]
(Int -> ReadS CreateResourceServerResponse)
-> ReadS [CreateResourceServerResponse]
-> ReadPrec CreateResourceServerResponse
-> ReadPrec [CreateResourceServerResponse]
-> Read CreateResourceServerResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateResourceServerResponse]
$creadListPrec :: ReadPrec [CreateResourceServerResponse]
readPrec :: ReadPrec CreateResourceServerResponse
$creadPrec :: ReadPrec CreateResourceServerResponse
readList :: ReadS [CreateResourceServerResponse]
$creadList :: ReadS [CreateResourceServerResponse]
readsPrec :: Int -> ReadS CreateResourceServerResponse
$creadsPrec :: Int -> ReadS CreateResourceServerResponse
Prelude.Read, Int -> CreateResourceServerResponse -> ShowS
[CreateResourceServerResponse] -> ShowS
CreateResourceServerResponse -> String
(Int -> CreateResourceServerResponse -> ShowS)
-> (CreateResourceServerResponse -> String)
-> ([CreateResourceServerResponse] -> ShowS)
-> Show CreateResourceServerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateResourceServerResponse] -> ShowS
$cshowList :: [CreateResourceServerResponse] -> ShowS
show :: CreateResourceServerResponse -> String
$cshow :: CreateResourceServerResponse -> String
showsPrec :: Int -> CreateResourceServerResponse -> ShowS
$cshowsPrec :: Int -> CreateResourceServerResponse -> ShowS
Prelude.Show, (forall x.
CreateResourceServerResponse -> Rep CreateResourceServerResponse x)
-> (forall x.
Rep CreateResourceServerResponse x -> CreateResourceServerResponse)
-> Generic CreateResourceServerResponse
forall x.
Rep CreateResourceServerResponse x -> CreateResourceServerResponse
forall x.
CreateResourceServerResponse -> Rep CreateResourceServerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateResourceServerResponse x -> CreateResourceServerResponse
$cfrom :: forall x.
CreateResourceServerResponse -> Rep CreateResourceServerResponse x
Prelude.Generic)
newCreateResourceServerResponse ::
Prelude.Int ->
ResourceServerType ->
CreateResourceServerResponse
newCreateResourceServerResponse :: Int -> ResourceServerType -> CreateResourceServerResponse
newCreateResourceServerResponse
Int
pHttpStatus_
ResourceServerType
pResourceServer_ =
CreateResourceServerResponse' :: Int -> ResourceServerType -> CreateResourceServerResponse
CreateResourceServerResponse'
{ $sel:httpStatus:CreateResourceServerResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:resourceServer:CreateResourceServerResponse' :: ResourceServerType
resourceServer = ResourceServerType
pResourceServer_
}
createResourceServerResponse_httpStatus :: Lens.Lens' CreateResourceServerResponse Prelude.Int
createResourceServerResponse_httpStatus :: (Int -> f Int)
-> CreateResourceServerResponse -> f CreateResourceServerResponse
createResourceServerResponse_httpStatus = (CreateResourceServerResponse -> Int)
-> (CreateResourceServerResponse
-> Int -> CreateResourceServerResponse)
-> Lens
CreateResourceServerResponse CreateResourceServerResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceServerResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateResourceServerResponse' :: CreateResourceServerResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateResourceServerResponse
s@CreateResourceServerResponse' {} Int
a -> CreateResourceServerResponse
s {$sel:httpStatus:CreateResourceServerResponse' :: Int
httpStatus = Int
a} :: CreateResourceServerResponse)
createResourceServerResponse_resourceServer :: Lens.Lens' CreateResourceServerResponse ResourceServerType
createResourceServerResponse_resourceServer :: (ResourceServerType -> f ResourceServerType)
-> CreateResourceServerResponse -> f CreateResourceServerResponse
createResourceServerResponse_resourceServer = (CreateResourceServerResponse -> ResourceServerType)
-> (CreateResourceServerResponse
-> ResourceServerType -> CreateResourceServerResponse)
-> Lens
CreateResourceServerResponse
CreateResourceServerResponse
ResourceServerType
ResourceServerType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceServerResponse' {ResourceServerType
resourceServer :: ResourceServerType
$sel:resourceServer:CreateResourceServerResponse' :: CreateResourceServerResponse -> ResourceServerType
resourceServer} -> ResourceServerType
resourceServer) (\s :: CreateResourceServerResponse
s@CreateResourceServerResponse' {} ResourceServerType
a -> CreateResourceServerResponse
s {$sel:resourceServer:CreateResourceServerResponse' :: ResourceServerType
resourceServer = ResourceServerType
a} :: CreateResourceServerResponse)
instance Prelude.NFData CreateResourceServerResponse