{-# 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.OpsWorksCM.CreateBackup
(
CreateBackup (..),
newCreateBackup,
createBackup_description,
createBackup_tags,
createBackup_serverName,
CreateBackupResponse (..),
newCreateBackupResponse,
createBackupResponse_backup,
createBackupResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpsWorksCM.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateBackup = CreateBackup'
{
CreateBackup -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CreateBackup -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreateBackup -> Text
serverName :: Prelude.Text
}
deriving (CreateBackup -> CreateBackup -> Bool
(CreateBackup -> CreateBackup -> Bool)
-> (CreateBackup -> CreateBackup -> Bool) -> Eq CreateBackup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateBackup -> CreateBackup -> Bool
$c/= :: CreateBackup -> CreateBackup -> Bool
== :: CreateBackup -> CreateBackup -> Bool
$c== :: CreateBackup -> CreateBackup -> Bool
Prelude.Eq, ReadPrec [CreateBackup]
ReadPrec CreateBackup
Int -> ReadS CreateBackup
ReadS [CreateBackup]
(Int -> ReadS CreateBackup)
-> ReadS [CreateBackup]
-> ReadPrec CreateBackup
-> ReadPrec [CreateBackup]
-> Read CreateBackup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateBackup]
$creadListPrec :: ReadPrec [CreateBackup]
readPrec :: ReadPrec CreateBackup
$creadPrec :: ReadPrec CreateBackup
readList :: ReadS [CreateBackup]
$creadList :: ReadS [CreateBackup]
readsPrec :: Int -> ReadS CreateBackup
$creadsPrec :: Int -> ReadS CreateBackup
Prelude.Read, Int -> CreateBackup -> ShowS
[CreateBackup] -> ShowS
CreateBackup -> String
(Int -> CreateBackup -> ShowS)
-> (CreateBackup -> String)
-> ([CreateBackup] -> ShowS)
-> Show CreateBackup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateBackup] -> ShowS
$cshowList :: [CreateBackup] -> ShowS
show :: CreateBackup -> String
$cshow :: CreateBackup -> String
showsPrec :: Int -> CreateBackup -> ShowS
$cshowsPrec :: Int -> CreateBackup -> ShowS
Prelude.Show, (forall x. CreateBackup -> Rep CreateBackup x)
-> (forall x. Rep CreateBackup x -> CreateBackup)
-> Generic CreateBackup
forall x. Rep CreateBackup x -> CreateBackup
forall x. CreateBackup -> Rep CreateBackup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateBackup x -> CreateBackup
$cfrom :: forall x. CreateBackup -> Rep CreateBackup x
Prelude.Generic)
newCreateBackup ::
Prelude.Text ->
CreateBackup
newCreateBackup :: Text -> CreateBackup
newCreateBackup Text
pServerName_ =
CreateBackup' :: Maybe Text -> Maybe [Tag] -> Text -> CreateBackup
CreateBackup'
{ $sel:description:CreateBackup' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateBackup' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:serverName:CreateBackup' :: Text
serverName = Text
pServerName_
}
createBackup_description :: Lens.Lens' CreateBackup (Prelude.Maybe Prelude.Text)
createBackup_description :: (Maybe Text -> f (Maybe Text)) -> CreateBackup -> f CreateBackup
createBackup_description = (CreateBackup -> Maybe Text)
-> (CreateBackup -> Maybe Text -> CreateBackup)
-> Lens CreateBackup CreateBackup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBackup' {Maybe Text
description :: Maybe Text
$sel:description:CreateBackup' :: CreateBackup -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateBackup
s@CreateBackup' {} Maybe Text
a -> CreateBackup
s {$sel:description:CreateBackup' :: Maybe Text
description = Maybe Text
a} :: CreateBackup)
createBackup_tags :: Lens.Lens' CreateBackup (Prelude.Maybe [Tag])
createBackup_tags :: (Maybe [Tag] -> f (Maybe [Tag])) -> CreateBackup -> f CreateBackup
createBackup_tags = (CreateBackup -> Maybe [Tag])
-> (CreateBackup -> Maybe [Tag] -> CreateBackup)
-> Lens CreateBackup CreateBackup (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBackup' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateBackup' :: CreateBackup -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateBackup
s@CreateBackup' {} Maybe [Tag]
a -> CreateBackup
s {$sel:tags:CreateBackup' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateBackup) ((Maybe [Tag] -> f (Maybe [Tag]))
-> CreateBackup -> f CreateBackup)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateBackup
-> f CreateBackup
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
createBackup_serverName :: Lens.Lens' CreateBackup Prelude.Text
createBackup_serverName :: (Text -> f Text) -> CreateBackup -> f CreateBackup
createBackup_serverName = (CreateBackup -> Text)
-> (CreateBackup -> Text -> CreateBackup)
-> Lens CreateBackup CreateBackup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBackup' {Text
serverName :: Text
$sel:serverName:CreateBackup' :: CreateBackup -> Text
serverName} -> Text
serverName) (\s :: CreateBackup
s@CreateBackup' {} Text
a -> CreateBackup
s {$sel:serverName:CreateBackup' :: Text
serverName = Text
a} :: CreateBackup)
instance Core.AWSRequest CreateBackup where
type AWSResponse CreateBackup = CreateBackupResponse
request :: CreateBackup -> Request CreateBackup
request = Service -> CreateBackup -> Request CreateBackup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateBackup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateBackup)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateBackup))
-> Logger
-> Service
-> Proxy CreateBackup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateBackup)))
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 Backup -> Int -> CreateBackupResponse
CreateBackupResponse'
(Maybe Backup -> Int -> CreateBackupResponse)
-> Either String (Maybe Backup)
-> Either String (Int -> CreateBackupResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Backup)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Backup")
Either String (Int -> CreateBackupResponse)
-> Either String Int -> Either String CreateBackupResponse
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 CreateBackup
instance Prelude.NFData CreateBackup
instance Core.ToHeaders CreateBackup where
toHeaders :: CreateBackup -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateBackup -> 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
"OpsWorksCM_V2016_11_01.CreateBackup" ::
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 CreateBackup where
toJSON :: CreateBackup -> Value
toJSON CreateBackup' {Maybe [Tag]
Maybe Text
Text
serverName :: Text
tags :: Maybe [Tag]
description :: Maybe Text
$sel:serverName:CreateBackup' :: CreateBackup -> Text
$sel:tags:CreateBackup' :: CreateBackup -> Maybe [Tag]
$sel:description:CreateBackup' :: CreateBackup -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Description" 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
description,
(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
"ServerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serverName)
]
)
instance Core.ToPath CreateBackup where
toPath :: CreateBackup -> ByteString
toPath = ByteString -> CreateBackup -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateBackup where
toQuery :: CreateBackup -> QueryString
toQuery = QueryString -> CreateBackup -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateBackupResponse = CreateBackupResponse'
{
CreateBackupResponse -> Maybe Backup
backup :: Prelude.Maybe Backup,
CreateBackupResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateBackupResponse -> CreateBackupResponse -> Bool
(CreateBackupResponse -> CreateBackupResponse -> Bool)
-> (CreateBackupResponse -> CreateBackupResponse -> Bool)
-> Eq CreateBackupResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateBackupResponse -> CreateBackupResponse -> Bool
$c/= :: CreateBackupResponse -> CreateBackupResponse -> Bool
== :: CreateBackupResponse -> CreateBackupResponse -> Bool
$c== :: CreateBackupResponse -> CreateBackupResponse -> Bool
Prelude.Eq, ReadPrec [CreateBackupResponse]
ReadPrec CreateBackupResponse
Int -> ReadS CreateBackupResponse
ReadS [CreateBackupResponse]
(Int -> ReadS CreateBackupResponse)
-> ReadS [CreateBackupResponse]
-> ReadPrec CreateBackupResponse
-> ReadPrec [CreateBackupResponse]
-> Read CreateBackupResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateBackupResponse]
$creadListPrec :: ReadPrec [CreateBackupResponse]
readPrec :: ReadPrec CreateBackupResponse
$creadPrec :: ReadPrec CreateBackupResponse
readList :: ReadS [CreateBackupResponse]
$creadList :: ReadS [CreateBackupResponse]
readsPrec :: Int -> ReadS CreateBackupResponse
$creadsPrec :: Int -> ReadS CreateBackupResponse
Prelude.Read, Int -> CreateBackupResponse -> ShowS
[CreateBackupResponse] -> ShowS
CreateBackupResponse -> String
(Int -> CreateBackupResponse -> ShowS)
-> (CreateBackupResponse -> String)
-> ([CreateBackupResponse] -> ShowS)
-> Show CreateBackupResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateBackupResponse] -> ShowS
$cshowList :: [CreateBackupResponse] -> ShowS
show :: CreateBackupResponse -> String
$cshow :: CreateBackupResponse -> String
showsPrec :: Int -> CreateBackupResponse -> ShowS
$cshowsPrec :: Int -> CreateBackupResponse -> ShowS
Prelude.Show, (forall x. CreateBackupResponse -> Rep CreateBackupResponse x)
-> (forall x. Rep CreateBackupResponse x -> CreateBackupResponse)
-> Generic CreateBackupResponse
forall x. Rep CreateBackupResponse x -> CreateBackupResponse
forall x. CreateBackupResponse -> Rep CreateBackupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateBackupResponse x -> CreateBackupResponse
$cfrom :: forall x. CreateBackupResponse -> Rep CreateBackupResponse x
Prelude.Generic)
newCreateBackupResponse ::
Prelude.Int ->
CreateBackupResponse
newCreateBackupResponse :: Int -> CreateBackupResponse
newCreateBackupResponse Int
pHttpStatus_ =
CreateBackupResponse' :: Maybe Backup -> Int -> CreateBackupResponse
CreateBackupResponse'
{ $sel:backup:CreateBackupResponse' :: Maybe Backup
backup = Maybe Backup
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateBackupResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createBackupResponse_backup :: Lens.Lens' CreateBackupResponse (Prelude.Maybe Backup)
createBackupResponse_backup :: (Maybe Backup -> f (Maybe Backup))
-> CreateBackupResponse -> f CreateBackupResponse
createBackupResponse_backup = (CreateBackupResponse -> Maybe Backup)
-> (CreateBackupResponse -> Maybe Backup -> CreateBackupResponse)
-> Lens
CreateBackupResponse
CreateBackupResponse
(Maybe Backup)
(Maybe Backup)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBackupResponse' {Maybe Backup
backup :: Maybe Backup
$sel:backup:CreateBackupResponse' :: CreateBackupResponse -> Maybe Backup
backup} -> Maybe Backup
backup) (\s :: CreateBackupResponse
s@CreateBackupResponse' {} Maybe Backup
a -> CreateBackupResponse
s {$sel:backup:CreateBackupResponse' :: Maybe Backup
backup = Maybe Backup
a} :: CreateBackupResponse)
createBackupResponse_httpStatus :: Lens.Lens' CreateBackupResponse Prelude.Int
createBackupResponse_httpStatus :: (Int -> f Int) -> CreateBackupResponse -> f CreateBackupResponse
createBackupResponse_httpStatus = (CreateBackupResponse -> Int)
-> (CreateBackupResponse -> Int -> CreateBackupResponse)
-> Lens CreateBackupResponse CreateBackupResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBackupResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateBackupResponse' :: CreateBackupResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateBackupResponse
s@CreateBackupResponse' {} Int
a -> CreateBackupResponse
s {$sel:httpStatus:CreateBackupResponse' :: Int
httpStatus = Int
a} :: CreateBackupResponse)
instance Prelude.NFData CreateBackupResponse