{-# 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.MemoryDb.CreateACL
(
CreateACL (..),
newCreateACL,
createACL_userNames,
createACL_tags,
createACL_aCLName,
CreateACLResponse (..),
newCreateACLResponse,
createACLResponse_acl,
createACLResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MemoryDb.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateACL = CreateACL'
{
CreateACL -> Maybe (NonEmpty Text)
userNames :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
CreateACL -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreateACL -> Text
aCLName :: Prelude.Text
}
deriving (CreateACL -> CreateACL -> Bool
(CreateACL -> CreateACL -> Bool)
-> (CreateACL -> CreateACL -> Bool) -> Eq CreateACL
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateACL -> CreateACL -> Bool
$c/= :: CreateACL -> CreateACL -> Bool
== :: CreateACL -> CreateACL -> Bool
$c== :: CreateACL -> CreateACL -> Bool
Prelude.Eq, ReadPrec [CreateACL]
ReadPrec CreateACL
Int -> ReadS CreateACL
ReadS [CreateACL]
(Int -> ReadS CreateACL)
-> ReadS [CreateACL]
-> ReadPrec CreateACL
-> ReadPrec [CreateACL]
-> Read CreateACL
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateACL]
$creadListPrec :: ReadPrec [CreateACL]
readPrec :: ReadPrec CreateACL
$creadPrec :: ReadPrec CreateACL
readList :: ReadS [CreateACL]
$creadList :: ReadS [CreateACL]
readsPrec :: Int -> ReadS CreateACL
$creadsPrec :: Int -> ReadS CreateACL
Prelude.Read, Int -> CreateACL -> ShowS
[CreateACL] -> ShowS
CreateACL -> String
(Int -> CreateACL -> ShowS)
-> (CreateACL -> String)
-> ([CreateACL] -> ShowS)
-> Show CreateACL
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateACL] -> ShowS
$cshowList :: [CreateACL] -> ShowS
show :: CreateACL -> String
$cshow :: CreateACL -> String
showsPrec :: Int -> CreateACL -> ShowS
$cshowsPrec :: Int -> CreateACL -> ShowS
Prelude.Show, (forall x. CreateACL -> Rep CreateACL x)
-> (forall x. Rep CreateACL x -> CreateACL) -> Generic CreateACL
forall x. Rep CreateACL x -> CreateACL
forall x. CreateACL -> Rep CreateACL x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateACL x -> CreateACL
$cfrom :: forall x. CreateACL -> Rep CreateACL x
Prelude.Generic)
newCreateACL ::
Prelude.Text ->
CreateACL
newCreateACL :: Text -> CreateACL
newCreateACL Text
pACLName_ =
CreateACL' :: Maybe (NonEmpty Text) -> Maybe [Tag] -> Text -> CreateACL
CreateACL'
{ $sel:userNames:CreateACL' :: Maybe (NonEmpty Text)
userNames = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateACL' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:aCLName:CreateACL' :: Text
aCLName = Text
pACLName_
}
createACL_userNames :: Lens.Lens' CreateACL (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
createACL_userNames :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> CreateACL -> f CreateACL
createACL_userNames = (CreateACL -> Maybe (NonEmpty Text))
-> (CreateACL -> Maybe (NonEmpty Text) -> CreateACL)
-> Lens
CreateACL CreateACL (Maybe (NonEmpty Text)) (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateACL' {Maybe (NonEmpty Text)
userNames :: Maybe (NonEmpty Text)
$sel:userNames:CreateACL' :: CreateACL -> Maybe (NonEmpty Text)
userNames} -> Maybe (NonEmpty Text)
userNames) (\s :: CreateACL
s@CreateACL' {} Maybe (NonEmpty Text)
a -> CreateACL
s {$sel:userNames:CreateACL' :: Maybe (NonEmpty Text)
userNames = Maybe (NonEmpty Text)
a} :: CreateACL) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> CreateACL -> f CreateACL)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> CreateACL
-> f CreateACL
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
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
(NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createACL_tags :: Lens.Lens' CreateACL (Prelude.Maybe [Tag])
createACL_tags :: (Maybe [Tag] -> f (Maybe [Tag])) -> CreateACL -> f CreateACL
createACL_tags = (CreateACL -> Maybe [Tag])
-> (CreateACL -> Maybe [Tag] -> CreateACL)
-> Lens CreateACL CreateACL (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateACL' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateACL' :: CreateACL -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateACL
s@CreateACL' {} Maybe [Tag]
a -> CreateACL
s {$sel:tags:CreateACL' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateACL) ((Maybe [Tag] -> f (Maybe [Tag])) -> CreateACL -> f CreateACL)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateACL
-> f CreateACL
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createACL_aCLName :: Lens.Lens' CreateACL Prelude.Text
createACL_aCLName :: (Text -> f Text) -> CreateACL -> f CreateACL
createACL_aCLName = (CreateACL -> Text)
-> (CreateACL -> Text -> CreateACL)
-> Lens CreateACL CreateACL Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateACL' {Text
aCLName :: Text
$sel:aCLName:CreateACL' :: CreateACL -> Text
aCLName} -> Text
aCLName) (\s :: CreateACL
s@CreateACL' {} Text
a -> CreateACL
s {$sel:aCLName:CreateACL' :: Text
aCLName = Text
a} :: CreateACL)
instance Core.AWSRequest CreateACL where
type AWSResponse CreateACL = CreateACLResponse
request :: CreateACL -> Request CreateACL
request = Service -> CreateACL -> Request CreateACL
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateACL
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateACL)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateACL))
-> Logger
-> Service
-> Proxy CreateACL
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateACL)))
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 ->
Maybe ACL -> Int -> CreateACLResponse
CreateACLResponse'
(Maybe ACL -> Int -> CreateACLResponse)
-> Either String (Maybe ACL)
-> Either String (Int -> CreateACLResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ACL)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ACL")
Either String (Int -> CreateACLResponse)
-> Either String Int -> Either String CreateACLResponse
forall (f :: * -> *) a b. Applicative f => 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 CreateACL
instance Prelude.NFData CreateACL
instance Core.ToHeaders CreateACL where
toHeaders :: CreateACL -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateACL -> 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
"AmazonMemoryDB.CreateACL" :: 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 CreateACL where
toJSON :: CreateACL -> Value
toJSON CreateACL' {Maybe [Tag]
Maybe (NonEmpty Text)
Text
aCLName :: Text
tags :: Maybe [Tag]
userNames :: Maybe (NonEmpty Text)
$sel:aCLName:CreateACL' :: CreateACL -> Text
$sel:tags:CreateACL' :: CreateACL -> Maybe [Tag]
$sel:userNames:CreateACL' :: CreateACL -> Maybe (NonEmpty Text)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"UserNames" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
userNames,
(Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ACLName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
aCLName)
]
)
instance Core.ToPath CreateACL where
toPath :: CreateACL -> ByteString
toPath = ByteString -> CreateACL -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateACL where
toQuery :: CreateACL -> QueryString
toQuery = QueryString -> CreateACL -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateACLResponse = CreateACLResponse'
{
CreateACLResponse -> Maybe ACL
acl :: Prelude.Maybe ACL,
CreateACLResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateACLResponse -> CreateACLResponse -> Bool
(CreateACLResponse -> CreateACLResponse -> Bool)
-> (CreateACLResponse -> CreateACLResponse -> Bool)
-> Eq CreateACLResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateACLResponse -> CreateACLResponse -> Bool
$c/= :: CreateACLResponse -> CreateACLResponse -> Bool
== :: CreateACLResponse -> CreateACLResponse -> Bool
$c== :: CreateACLResponse -> CreateACLResponse -> Bool
Prelude.Eq, ReadPrec [CreateACLResponse]
ReadPrec CreateACLResponse
Int -> ReadS CreateACLResponse
ReadS [CreateACLResponse]
(Int -> ReadS CreateACLResponse)
-> ReadS [CreateACLResponse]
-> ReadPrec CreateACLResponse
-> ReadPrec [CreateACLResponse]
-> Read CreateACLResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateACLResponse]
$creadListPrec :: ReadPrec [CreateACLResponse]
readPrec :: ReadPrec CreateACLResponse
$creadPrec :: ReadPrec CreateACLResponse
readList :: ReadS [CreateACLResponse]
$creadList :: ReadS [CreateACLResponse]
readsPrec :: Int -> ReadS CreateACLResponse
$creadsPrec :: Int -> ReadS CreateACLResponse
Prelude.Read, Int -> CreateACLResponse -> ShowS
[CreateACLResponse] -> ShowS
CreateACLResponse -> String
(Int -> CreateACLResponse -> ShowS)
-> (CreateACLResponse -> String)
-> ([CreateACLResponse] -> ShowS)
-> Show CreateACLResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateACLResponse] -> ShowS
$cshowList :: [CreateACLResponse] -> ShowS
show :: CreateACLResponse -> String
$cshow :: CreateACLResponse -> String
showsPrec :: Int -> CreateACLResponse -> ShowS
$cshowsPrec :: Int -> CreateACLResponse -> ShowS
Prelude.Show, (forall x. CreateACLResponse -> Rep CreateACLResponse x)
-> (forall x. Rep CreateACLResponse x -> CreateACLResponse)
-> Generic CreateACLResponse
forall x. Rep CreateACLResponse x -> CreateACLResponse
forall x. CreateACLResponse -> Rep CreateACLResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateACLResponse x -> CreateACLResponse
$cfrom :: forall x. CreateACLResponse -> Rep CreateACLResponse x
Prelude.Generic)
newCreateACLResponse ::
Prelude.Int ->
CreateACLResponse
newCreateACLResponse :: Int -> CreateACLResponse
newCreateACLResponse Int
pHttpStatus_ =
CreateACLResponse' :: Maybe ACL -> Int -> CreateACLResponse
CreateACLResponse'
{ $sel:acl:CreateACLResponse' :: Maybe ACL
acl = Maybe ACL
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateACLResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createACLResponse_acl :: Lens.Lens' CreateACLResponse (Prelude.Maybe ACL)
createACLResponse_acl :: (Maybe ACL -> f (Maybe ACL))
-> CreateACLResponse -> f CreateACLResponse
createACLResponse_acl = (CreateACLResponse -> Maybe ACL)
-> (CreateACLResponse -> Maybe ACL -> CreateACLResponse)
-> Lens CreateACLResponse CreateACLResponse (Maybe ACL) (Maybe ACL)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateACLResponse' {Maybe ACL
acl :: Maybe ACL
$sel:acl:CreateACLResponse' :: CreateACLResponse -> Maybe ACL
acl} -> Maybe ACL
acl) (\s :: CreateACLResponse
s@CreateACLResponse' {} Maybe ACL
a -> CreateACLResponse
s {$sel:acl:CreateACLResponse' :: Maybe ACL
acl = Maybe ACL
a} :: CreateACLResponse)
createACLResponse_httpStatus :: Lens.Lens' CreateACLResponse Prelude.Int
createACLResponse_httpStatus :: (Int -> f Int) -> CreateACLResponse -> f CreateACLResponse
createACLResponse_httpStatus = (CreateACLResponse -> Int)
-> (CreateACLResponse -> Int -> CreateACLResponse)
-> Lens CreateACLResponse CreateACLResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateACLResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateACLResponse' :: CreateACLResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateACLResponse
s@CreateACLResponse' {} Int
a -> CreateACLResponse
s {$sel:httpStatus:CreateACLResponse' :: Int
httpStatus = Int
a} :: CreateACLResponse)
instance Prelude.NFData CreateACLResponse