{-# 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.CreateSnapshot
(
CreateSnapshot (..),
newCreateSnapshot,
createSnapshot_kmsKeyId,
createSnapshot_tags,
createSnapshot_clusterName,
createSnapshot_snapshotName,
CreateSnapshotResponse (..),
newCreateSnapshotResponse,
createSnapshotResponse_snapshot,
createSnapshotResponse_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 CreateSnapshot = CreateSnapshot'
{
CreateSnapshot -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
CreateSnapshot -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreateSnapshot -> Text
clusterName :: Prelude.Text,
CreateSnapshot -> Text
snapshotName :: Prelude.Text
}
deriving (CreateSnapshot -> CreateSnapshot -> Bool
(CreateSnapshot -> CreateSnapshot -> Bool)
-> (CreateSnapshot -> CreateSnapshot -> Bool) -> Eq CreateSnapshot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSnapshot -> CreateSnapshot -> Bool
$c/= :: CreateSnapshot -> CreateSnapshot -> Bool
== :: CreateSnapshot -> CreateSnapshot -> Bool
$c== :: CreateSnapshot -> CreateSnapshot -> Bool
Prelude.Eq, ReadPrec [CreateSnapshot]
ReadPrec CreateSnapshot
Int -> ReadS CreateSnapshot
ReadS [CreateSnapshot]
(Int -> ReadS CreateSnapshot)
-> ReadS [CreateSnapshot]
-> ReadPrec CreateSnapshot
-> ReadPrec [CreateSnapshot]
-> Read CreateSnapshot
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSnapshot]
$creadListPrec :: ReadPrec [CreateSnapshot]
readPrec :: ReadPrec CreateSnapshot
$creadPrec :: ReadPrec CreateSnapshot
readList :: ReadS [CreateSnapshot]
$creadList :: ReadS [CreateSnapshot]
readsPrec :: Int -> ReadS CreateSnapshot
$creadsPrec :: Int -> ReadS CreateSnapshot
Prelude.Read, Int -> CreateSnapshot -> ShowS
[CreateSnapshot] -> ShowS
CreateSnapshot -> String
(Int -> CreateSnapshot -> ShowS)
-> (CreateSnapshot -> String)
-> ([CreateSnapshot] -> ShowS)
-> Show CreateSnapshot
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSnapshot] -> ShowS
$cshowList :: [CreateSnapshot] -> ShowS
show :: CreateSnapshot -> String
$cshow :: CreateSnapshot -> String
showsPrec :: Int -> CreateSnapshot -> ShowS
$cshowsPrec :: Int -> CreateSnapshot -> ShowS
Prelude.Show, (forall x. CreateSnapshot -> Rep CreateSnapshot x)
-> (forall x. Rep CreateSnapshot x -> CreateSnapshot)
-> Generic CreateSnapshot
forall x. Rep CreateSnapshot x -> CreateSnapshot
forall x. CreateSnapshot -> Rep CreateSnapshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateSnapshot x -> CreateSnapshot
$cfrom :: forall x. CreateSnapshot -> Rep CreateSnapshot x
Prelude.Generic)
newCreateSnapshot ::
Prelude.Text ->
Prelude.Text ->
CreateSnapshot
newCreateSnapshot :: Text -> Text -> CreateSnapshot
newCreateSnapshot Text
pClusterName_ Text
pSnapshotName_ =
CreateSnapshot' :: Maybe Text -> Maybe [Tag] -> Text -> Text -> CreateSnapshot
CreateSnapshot'
{ $sel:kmsKeyId:CreateSnapshot' :: Maybe Text
kmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateSnapshot' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:clusterName:CreateSnapshot' :: Text
clusterName = Text
pClusterName_,
$sel:snapshotName:CreateSnapshot' :: Text
snapshotName = Text
pSnapshotName_
}
createSnapshot_kmsKeyId :: Lens.Lens' CreateSnapshot (Prelude.Maybe Prelude.Text)
createSnapshot_kmsKeyId :: (Maybe Text -> f (Maybe Text))
-> CreateSnapshot -> f CreateSnapshot
createSnapshot_kmsKeyId = (CreateSnapshot -> Maybe Text)
-> (CreateSnapshot -> Maybe Text -> CreateSnapshot)
-> Lens CreateSnapshot CreateSnapshot (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSnapshot' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:CreateSnapshot' :: CreateSnapshot -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: CreateSnapshot
s@CreateSnapshot' {} Maybe Text
a -> CreateSnapshot
s {$sel:kmsKeyId:CreateSnapshot' :: Maybe Text
kmsKeyId = Maybe Text
a} :: CreateSnapshot)
createSnapshot_tags :: Lens.Lens' CreateSnapshot (Prelude.Maybe [Tag])
createSnapshot_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateSnapshot -> f CreateSnapshot
createSnapshot_tags = (CreateSnapshot -> Maybe [Tag])
-> (CreateSnapshot -> Maybe [Tag] -> CreateSnapshot)
-> Lens CreateSnapshot CreateSnapshot (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSnapshot' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateSnapshot' :: CreateSnapshot -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateSnapshot
s@CreateSnapshot' {} Maybe [Tag]
a -> CreateSnapshot
s {$sel:tags:CreateSnapshot' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateSnapshot) ((Maybe [Tag] -> f (Maybe [Tag]))
-> CreateSnapshot -> f CreateSnapshot)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateSnapshot
-> f CreateSnapshot
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
createSnapshot_clusterName :: Lens.Lens' CreateSnapshot Prelude.Text
createSnapshot_clusterName :: (Text -> f Text) -> CreateSnapshot -> f CreateSnapshot
createSnapshot_clusterName = (CreateSnapshot -> Text)
-> (CreateSnapshot -> Text -> CreateSnapshot)
-> Lens CreateSnapshot CreateSnapshot Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSnapshot' {Text
clusterName :: Text
$sel:clusterName:CreateSnapshot' :: CreateSnapshot -> Text
clusterName} -> Text
clusterName) (\s :: CreateSnapshot
s@CreateSnapshot' {} Text
a -> CreateSnapshot
s {$sel:clusterName:CreateSnapshot' :: Text
clusterName = Text
a} :: CreateSnapshot)
createSnapshot_snapshotName :: Lens.Lens' CreateSnapshot Prelude.Text
createSnapshot_snapshotName :: (Text -> f Text) -> CreateSnapshot -> f CreateSnapshot
createSnapshot_snapshotName = (CreateSnapshot -> Text)
-> (CreateSnapshot -> Text -> CreateSnapshot)
-> Lens CreateSnapshot CreateSnapshot Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSnapshot' {Text
snapshotName :: Text
$sel:snapshotName:CreateSnapshot' :: CreateSnapshot -> Text
snapshotName} -> Text
snapshotName) (\s :: CreateSnapshot
s@CreateSnapshot' {} Text
a -> CreateSnapshot
s {$sel:snapshotName:CreateSnapshot' :: Text
snapshotName = Text
a} :: CreateSnapshot)
instance Core.AWSRequest CreateSnapshot where
type
AWSResponse CreateSnapshot =
CreateSnapshotResponse
request :: CreateSnapshot -> Request CreateSnapshot
request = Service -> CreateSnapshot -> Request CreateSnapshot
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateSnapshot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateSnapshot)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateSnapshot))
-> Logger
-> Service
-> Proxy CreateSnapshot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateSnapshot)))
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 Snapshot -> Int -> CreateSnapshotResponse
CreateSnapshotResponse'
(Maybe Snapshot -> Int -> CreateSnapshotResponse)
-> Either String (Maybe Snapshot)
-> Either String (Int -> CreateSnapshotResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Snapshot)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Snapshot")
Either String (Int -> CreateSnapshotResponse)
-> Either String Int -> Either String CreateSnapshotResponse
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 CreateSnapshot
instance Prelude.NFData CreateSnapshot
instance Core.ToHeaders CreateSnapshot where
toHeaders :: CreateSnapshot -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateSnapshot -> 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.CreateSnapshot" ::
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 CreateSnapshot where
toJSON :: CreateSnapshot -> Value
toJSON CreateSnapshot' {Maybe [Tag]
Maybe Text
Text
snapshotName :: Text
clusterName :: Text
tags :: Maybe [Tag]
kmsKeyId :: Maybe Text
$sel:snapshotName:CreateSnapshot' :: CreateSnapshot -> Text
$sel:clusterName:CreateSnapshot' :: CreateSnapshot -> Text
$sel:tags:CreateSnapshot' :: CreateSnapshot -> Maybe [Tag]
$sel:kmsKeyId:CreateSnapshot' :: CreateSnapshot -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"KmsKeyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
kmsKeyId,
(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
"ClusterName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clusterName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SnapshotName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
snapshotName)
]
)
instance Core.ToPath CreateSnapshot where
toPath :: CreateSnapshot -> ByteString
toPath = ByteString -> CreateSnapshot -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateSnapshot where
toQuery :: CreateSnapshot -> QueryString
toQuery = QueryString -> CreateSnapshot -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateSnapshotResponse = CreateSnapshotResponse'
{
CreateSnapshotResponse -> Maybe Snapshot
snapshot :: Prelude.Maybe Snapshot,
CreateSnapshotResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateSnapshotResponse -> CreateSnapshotResponse -> Bool
(CreateSnapshotResponse -> CreateSnapshotResponse -> Bool)
-> (CreateSnapshotResponse -> CreateSnapshotResponse -> Bool)
-> Eq CreateSnapshotResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSnapshotResponse -> CreateSnapshotResponse -> Bool
$c/= :: CreateSnapshotResponse -> CreateSnapshotResponse -> Bool
== :: CreateSnapshotResponse -> CreateSnapshotResponse -> Bool
$c== :: CreateSnapshotResponse -> CreateSnapshotResponse -> Bool
Prelude.Eq, ReadPrec [CreateSnapshotResponse]
ReadPrec CreateSnapshotResponse
Int -> ReadS CreateSnapshotResponse
ReadS [CreateSnapshotResponse]
(Int -> ReadS CreateSnapshotResponse)
-> ReadS [CreateSnapshotResponse]
-> ReadPrec CreateSnapshotResponse
-> ReadPrec [CreateSnapshotResponse]
-> Read CreateSnapshotResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSnapshotResponse]
$creadListPrec :: ReadPrec [CreateSnapshotResponse]
readPrec :: ReadPrec CreateSnapshotResponse
$creadPrec :: ReadPrec CreateSnapshotResponse
readList :: ReadS [CreateSnapshotResponse]
$creadList :: ReadS [CreateSnapshotResponse]
readsPrec :: Int -> ReadS CreateSnapshotResponse
$creadsPrec :: Int -> ReadS CreateSnapshotResponse
Prelude.Read, Int -> CreateSnapshotResponse -> ShowS
[CreateSnapshotResponse] -> ShowS
CreateSnapshotResponse -> String
(Int -> CreateSnapshotResponse -> ShowS)
-> (CreateSnapshotResponse -> String)
-> ([CreateSnapshotResponse] -> ShowS)
-> Show CreateSnapshotResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSnapshotResponse] -> ShowS
$cshowList :: [CreateSnapshotResponse] -> ShowS
show :: CreateSnapshotResponse -> String
$cshow :: CreateSnapshotResponse -> String
showsPrec :: Int -> CreateSnapshotResponse -> ShowS
$cshowsPrec :: Int -> CreateSnapshotResponse -> ShowS
Prelude.Show, (forall x. CreateSnapshotResponse -> Rep CreateSnapshotResponse x)
-> (forall x.
Rep CreateSnapshotResponse x -> CreateSnapshotResponse)
-> Generic CreateSnapshotResponse
forall x. Rep CreateSnapshotResponse x -> CreateSnapshotResponse
forall x. CreateSnapshotResponse -> Rep CreateSnapshotResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateSnapshotResponse x -> CreateSnapshotResponse
$cfrom :: forall x. CreateSnapshotResponse -> Rep CreateSnapshotResponse x
Prelude.Generic)
newCreateSnapshotResponse ::
Prelude.Int ->
CreateSnapshotResponse
newCreateSnapshotResponse :: Int -> CreateSnapshotResponse
newCreateSnapshotResponse Int
pHttpStatus_ =
CreateSnapshotResponse' :: Maybe Snapshot -> Int -> CreateSnapshotResponse
CreateSnapshotResponse'
{ $sel:snapshot:CreateSnapshotResponse' :: Maybe Snapshot
snapshot = Maybe Snapshot
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateSnapshotResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createSnapshotResponse_snapshot :: Lens.Lens' CreateSnapshotResponse (Prelude.Maybe Snapshot)
createSnapshotResponse_snapshot :: (Maybe Snapshot -> f (Maybe Snapshot))
-> CreateSnapshotResponse -> f CreateSnapshotResponse
createSnapshotResponse_snapshot = (CreateSnapshotResponse -> Maybe Snapshot)
-> (CreateSnapshotResponse
-> Maybe Snapshot -> CreateSnapshotResponse)
-> Lens
CreateSnapshotResponse
CreateSnapshotResponse
(Maybe Snapshot)
(Maybe Snapshot)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSnapshotResponse' {Maybe Snapshot
snapshot :: Maybe Snapshot
$sel:snapshot:CreateSnapshotResponse' :: CreateSnapshotResponse -> Maybe Snapshot
snapshot} -> Maybe Snapshot
snapshot) (\s :: CreateSnapshotResponse
s@CreateSnapshotResponse' {} Maybe Snapshot
a -> CreateSnapshotResponse
s {$sel:snapshot:CreateSnapshotResponse' :: Maybe Snapshot
snapshot = Maybe Snapshot
a} :: CreateSnapshotResponse)
createSnapshotResponse_httpStatus :: Lens.Lens' CreateSnapshotResponse Prelude.Int
createSnapshotResponse_httpStatus :: (Int -> f Int)
-> CreateSnapshotResponse -> f CreateSnapshotResponse
createSnapshotResponse_httpStatus = (CreateSnapshotResponse -> Int)
-> (CreateSnapshotResponse -> Int -> CreateSnapshotResponse)
-> Lens CreateSnapshotResponse CreateSnapshotResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSnapshotResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateSnapshotResponse' :: CreateSnapshotResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateSnapshotResponse
s@CreateSnapshotResponse' {} Int
a -> CreateSnapshotResponse
s {$sel:httpStatus:CreateSnapshotResponse' :: Int
httpStatus = Int
a} :: CreateSnapshotResponse)
instance Prelude.NFData CreateSnapshotResponse