{-# 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.AutoScalingPlans.CreateScalingPlan
(
CreateScalingPlan (..),
newCreateScalingPlan,
createScalingPlan_scalingPlanName,
createScalingPlan_applicationSource,
createScalingPlan_scalingInstructions,
CreateScalingPlanResponse (..),
newCreateScalingPlanResponse,
createScalingPlanResponse_httpStatus,
createScalingPlanResponse_scalingPlanVersion,
)
where
import Amazonka.AutoScalingPlans.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 CreateScalingPlan = CreateScalingPlan'
{
CreateScalingPlan -> Text
scalingPlanName :: Prelude.Text,
CreateScalingPlan -> ApplicationSource
applicationSource :: ApplicationSource,
CreateScalingPlan -> [ScalingInstruction]
scalingInstructions :: [ScalingInstruction]
}
deriving (CreateScalingPlan -> CreateScalingPlan -> Bool
(CreateScalingPlan -> CreateScalingPlan -> Bool)
-> (CreateScalingPlan -> CreateScalingPlan -> Bool)
-> Eq CreateScalingPlan
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateScalingPlan -> CreateScalingPlan -> Bool
$c/= :: CreateScalingPlan -> CreateScalingPlan -> Bool
== :: CreateScalingPlan -> CreateScalingPlan -> Bool
$c== :: CreateScalingPlan -> CreateScalingPlan -> Bool
Prelude.Eq, ReadPrec [CreateScalingPlan]
ReadPrec CreateScalingPlan
Int -> ReadS CreateScalingPlan
ReadS [CreateScalingPlan]
(Int -> ReadS CreateScalingPlan)
-> ReadS [CreateScalingPlan]
-> ReadPrec CreateScalingPlan
-> ReadPrec [CreateScalingPlan]
-> Read CreateScalingPlan
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateScalingPlan]
$creadListPrec :: ReadPrec [CreateScalingPlan]
readPrec :: ReadPrec CreateScalingPlan
$creadPrec :: ReadPrec CreateScalingPlan
readList :: ReadS [CreateScalingPlan]
$creadList :: ReadS [CreateScalingPlan]
readsPrec :: Int -> ReadS CreateScalingPlan
$creadsPrec :: Int -> ReadS CreateScalingPlan
Prelude.Read, Int -> CreateScalingPlan -> ShowS
[CreateScalingPlan] -> ShowS
CreateScalingPlan -> String
(Int -> CreateScalingPlan -> ShowS)
-> (CreateScalingPlan -> String)
-> ([CreateScalingPlan] -> ShowS)
-> Show CreateScalingPlan
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateScalingPlan] -> ShowS
$cshowList :: [CreateScalingPlan] -> ShowS
show :: CreateScalingPlan -> String
$cshow :: CreateScalingPlan -> String
showsPrec :: Int -> CreateScalingPlan -> ShowS
$cshowsPrec :: Int -> CreateScalingPlan -> ShowS
Prelude.Show, (forall x. CreateScalingPlan -> Rep CreateScalingPlan x)
-> (forall x. Rep CreateScalingPlan x -> CreateScalingPlan)
-> Generic CreateScalingPlan
forall x. Rep CreateScalingPlan x -> CreateScalingPlan
forall x. CreateScalingPlan -> Rep CreateScalingPlan x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateScalingPlan x -> CreateScalingPlan
$cfrom :: forall x. CreateScalingPlan -> Rep CreateScalingPlan x
Prelude.Generic)
newCreateScalingPlan ::
Prelude.Text ->
ApplicationSource ->
CreateScalingPlan
newCreateScalingPlan :: Text -> ApplicationSource -> CreateScalingPlan
newCreateScalingPlan
Text
pScalingPlanName_
ApplicationSource
pApplicationSource_ =
CreateScalingPlan' :: Text
-> ApplicationSource -> [ScalingInstruction] -> CreateScalingPlan
CreateScalingPlan'
{ $sel:scalingPlanName:CreateScalingPlan' :: Text
scalingPlanName =
Text
pScalingPlanName_,
$sel:applicationSource:CreateScalingPlan' :: ApplicationSource
applicationSource = ApplicationSource
pApplicationSource_,
$sel:scalingInstructions:CreateScalingPlan' :: [ScalingInstruction]
scalingInstructions = [ScalingInstruction]
forall a. Monoid a => a
Prelude.mempty
}
createScalingPlan_scalingPlanName :: Lens.Lens' CreateScalingPlan Prelude.Text
createScalingPlan_scalingPlanName :: (Text -> f Text) -> CreateScalingPlan -> f CreateScalingPlan
createScalingPlan_scalingPlanName = (CreateScalingPlan -> Text)
-> (CreateScalingPlan -> Text -> CreateScalingPlan)
-> Lens CreateScalingPlan CreateScalingPlan Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateScalingPlan' {Text
scalingPlanName :: Text
$sel:scalingPlanName:CreateScalingPlan' :: CreateScalingPlan -> Text
scalingPlanName} -> Text
scalingPlanName) (\s :: CreateScalingPlan
s@CreateScalingPlan' {} Text
a -> CreateScalingPlan
s {$sel:scalingPlanName:CreateScalingPlan' :: Text
scalingPlanName = Text
a} :: CreateScalingPlan)
createScalingPlan_applicationSource :: Lens.Lens' CreateScalingPlan ApplicationSource
createScalingPlan_applicationSource :: (ApplicationSource -> f ApplicationSource)
-> CreateScalingPlan -> f CreateScalingPlan
createScalingPlan_applicationSource = (CreateScalingPlan -> ApplicationSource)
-> (CreateScalingPlan -> ApplicationSource -> CreateScalingPlan)
-> Lens
CreateScalingPlan
CreateScalingPlan
ApplicationSource
ApplicationSource
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateScalingPlan' {ApplicationSource
applicationSource :: ApplicationSource
$sel:applicationSource:CreateScalingPlan' :: CreateScalingPlan -> ApplicationSource
applicationSource} -> ApplicationSource
applicationSource) (\s :: CreateScalingPlan
s@CreateScalingPlan' {} ApplicationSource
a -> CreateScalingPlan
s {$sel:applicationSource:CreateScalingPlan' :: ApplicationSource
applicationSource = ApplicationSource
a} :: CreateScalingPlan)
createScalingPlan_scalingInstructions :: Lens.Lens' CreateScalingPlan [ScalingInstruction]
createScalingPlan_scalingInstructions :: ([ScalingInstruction] -> f [ScalingInstruction])
-> CreateScalingPlan -> f CreateScalingPlan
createScalingPlan_scalingInstructions = (CreateScalingPlan -> [ScalingInstruction])
-> (CreateScalingPlan -> [ScalingInstruction] -> CreateScalingPlan)
-> Lens
CreateScalingPlan
CreateScalingPlan
[ScalingInstruction]
[ScalingInstruction]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateScalingPlan' {[ScalingInstruction]
scalingInstructions :: [ScalingInstruction]
$sel:scalingInstructions:CreateScalingPlan' :: CreateScalingPlan -> [ScalingInstruction]
scalingInstructions} -> [ScalingInstruction]
scalingInstructions) (\s :: CreateScalingPlan
s@CreateScalingPlan' {} [ScalingInstruction]
a -> CreateScalingPlan
s {$sel:scalingInstructions:CreateScalingPlan' :: [ScalingInstruction]
scalingInstructions = [ScalingInstruction]
a} :: CreateScalingPlan) (([ScalingInstruction] -> f [ScalingInstruction])
-> CreateScalingPlan -> f CreateScalingPlan)
-> (([ScalingInstruction] -> f [ScalingInstruction])
-> [ScalingInstruction] -> f [ScalingInstruction])
-> ([ScalingInstruction] -> f [ScalingInstruction])
-> CreateScalingPlan
-> f CreateScalingPlan
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ScalingInstruction] -> f [ScalingInstruction])
-> [ScalingInstruction] -> f [ScalingInstruction]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest CreateScalingPlan where
type
AWSResponse CreateScalingPlan =
CreateScalingPlanResponse
request :: CreateScalingPlan -> Request CreateScalingPlan
request = Service -> CreateScalingPlan -> Request CreateScalingPlan
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateScalingPlan
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateScalingPlan)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateScalingPlan))
-> Logger
-> Service
-> Proxy CreateScalingPlan
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateScalingPlan)))
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 -> Integer -> CreateScalingPlanResponse
CreateScalingPlanResponse'
(Int -> Integer -> CreateScalingPlanResponse)
-> Either String Int
-> Either String (Integer -> CreateScalingPlanResponse)
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 (Integer -> CreateScalingPlanResponse)
-> Either String Integer -> Either String CreateScalingPlanResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Integer
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"ScalingPlanVersion")
)
instance Prelude.Hashable CreateScalingPlan
instance Prelude.NFData CreateScalingPlan
instance Core.ToHeaders CreateScalingPlan where
toHeaders :: CreateScalingPlan -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateScalingPlan -> 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
"AnyScaleScalingPlannerFrontendService.CreateScalingPlan" ::
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 CreateScalingPlan where
toJSON :: CreateScalingPlan -> Value
toJSON CreateScalingPlan' {[ScalingInstruction]
Text
ApplicationSource
scalingInstructions :: [ScalingInstruction]
applicationSource :: ApplicationSource
scalingPlanName :: Text
$sel:scalingInstructions:CreateScalingPlan' :: CreateScalingPlan -> [ScalingInstruction]
$sel:applicationSource:CreateScalingPlan' :: CreateScalingPlan -> ApplicationSource
$sel:scalingPlanName:CreateScalingPlan' :: CreateScalingPlan -> Text
..} =
[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
"ScalingPlanName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
scalingPlanName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"ApplicationSource" Text -> ApplicationSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ApplicationSource
applicationSource),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"ScalingInstructions" Text -> [ScalingInstruction] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [ScalingInstruction]
scalingInstructions)
]
)
instance Core.ToPath CreateScalingPlan where
toPath :: CreateScalingPlan -> ByteString
toPath = ByteString -> CreateScalingPlan -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateScalingPlan where
toQuery :: CreateScalingPlan -> QueryString
toQuery = QueryString -> CreateScalingPlan -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateScalingPlanResponse = CreateScalingPlanResponse'
{
CreateScalingPlanResponse -> Int
httpStatus :: Prelude.Int,
CreateScalingPlanResponse -> Integer
scalingPlanVersion :: Prelude.Integer
}
deriving (CreateScalingPlanResponse -> CreateScalingPlanResponse -> Bool
(CreateScalingPlanResponse -> CreateScalingPlanResponse -> Bool)
-> (CreateScalingPlanResponse -> CreateScalingPlanResponse -> Bool)
-> Eq CreateScalingPlanResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateScalingPlanResponse -> CreateScalingPlanResponse -> Bool
$c/= :: CreateScalingPlanResponse -> CreateScalingPlanResponse -> Bool
== :: CreateScalingPlanResponse -> CreateScalingPlanResponse -> Bool
$c== :: CreateScalingPlanResponse -> CreateScalingPlanResponse -> Bool
Prelude.Eq, ReadPrec [CreateScalingPlanResponse]
ReadPrec CreateScalingPlanResponse
Int -> ReadS CreateScalingPlanResponse
ReadS [CreateScalingPlanResponse]
(Int -> ReadS CreateScalingPlanResponse)
-> ReadS [CreateScalingPlanResponse]
-> ReadPrec CreateScalingPlanResponse
-> ReadPrec [CreateScalingPlanResponse]
-> Read CreateScalingPlanResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateScalingPlanResponse]
$creadListPrec :: ReadPrec [CreateScalingPlanResponse]
readPrec :: ReadPrec CreateScalingPlanResponse
$creadPrec :: ReadPrec CreateScalingPlanResponse
readList :: ReadS [CreateScalingPlanResponse]
$creadList :: ReadS [CreateScalingPlanResponse]
readsPrec :: Int -> ReadS CreateScalingPlanResponse
$creadsPrec :: Int -> ReadS CreateScalingPlanResponse
Prelude.Read, Int -> CreateScalingPlanResponse -> ShowS
[CreateScalingPlanResponse] -> ShowS
CreateScalingPlanResponse -> String
(Int -> CreateScalingPlanResponse -> ShowS)
-> (CreateScalingPlanResponse -> String)
-> ([CreateScalingPlanResponse] -> ShowS)
-> Show CreateScalingPlanResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateScalingPlanResponse] -> ShowS
$cshowList :: [CreateScalingPlanResponse] -> ShowS
show :: CreateScalingPlanResponse -> String
$cshow :: CreateScalingPlanResponse -> String
showsPrec :: Int -> CreateScalingPlanResponse -> ShowS
$cshowsPrec :: Int -> CreateScalingPlanResponse -> ShowS
Prelude.Show, (forall x.
CreateScalingPlanResponse -> Rep CreateScalingPlanResponse x)
-> (forall x.
Rep CreateScalingPlanResponse x -> CreateScalingPlanResponse)
-> Generic CreateScalingPlanResponse
forall x.
Rep CreateScalingPlanResponse x -> CreateScalingPlanResponse
forall x.
CreateScalingPlanResponse -> Rep CreateScalingPlanResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateScalingPlanResponse x -> CreateScalingPlanResponse
$cfrom :: forall x.
CreateScalingPlanResponse -> Rep CreateScalingPlanResponse x
Prelude.Generic)
newCreateScalingPlanResponse ::
Prelude.Int ->
Prelude.Integer ->
CreateScalingPlanResponse
newCreateScalingPlanResponse :: Int -> Integer -> CreateScalingPlanResponse
newCreateScalingPlanResponse
Int
pHttpStatus_
Integer
pScalingPlanVersion_ =
CreateScalingPlanResponse' :: Int -> Integer -> CreateScalingPlanResponse
CreateScalingPlanResponse'
{ $sel:httpStatus:CreateScalingPlanResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:scalingPlanVersion:CreateScalingPlanResponse' :: Integer
scalingPlanVersion = Integer
pScalingPlanVersion_
}
createScalingPlanResponse_httpStatus :: Lens.Lens' CreateScalingPlanResponse Prelude.Int
createScalingPlanResponse_httpStatus :: (Int -> f Int)
-> CreateScalingPlanResponse -> f CreateScalingPlanResponse
createScalingPlanResponse_httpStatus = (CreateScalingPlanResponse -> Int)
-> (CreateScalingPlanResponse -> Int -> CreateScalingPlanResponse)
-> Lens CreateScalingPlanResponse CreateScalingPlanResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateScalingPlanResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateScalingPlanResponse' :: CreateScalingPlanResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateScalingPlanResponse
s@CreateScalingPlanResponse' {} Int
a -> CreateScalingPlanResponse
s {$sel:httpStatus:CreateScalingPlanResponse' :: Int
httpStatus = Int
a} :: CreateScalingPlanResponse)
createScalingPlanResponse_scalingPlanVersion :: Lens.Lens' CreateScalingPlanResponse Prelude.Integer
createScalingPlanResponse_scalingPlanVersion :: (Integer -> f Integer)
-> CreateScalingPlanResponse -> f CreateScalingPlanResponse
createScalingPlanResponse_scalingPlanVersion = (CreateScalingPlanResponse -> Integer)
-> (CreateScalingPlanResponse
-> Integer -> CreateScalingPlanResponse)
-> Lens
CreateScalingPlanResponse CreateScalingPlanResponse Integer Integer
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateScalingPlanResponse' {Integer
scalingPlanVersion :: Integer
$sel:scalingPlanVersion:CreateScalingPlanResponse' :: CreateScalingPlanResponse -> Integer
scalingPlanVersion} -> Integer
scalingPlanVersion) (\s :: CreateScalingPlanResponse
s@CreateScalingPlanResponse' {} Integer
a -> CreateScalingPlanResponse
s {$sel:scalingPlanVersion:CreateScalingPlanResponse' :: Integer
scalingPlanVersion = Integer
a} :: CreateScalingPlanResponse)
instance Prelude.NFData CreateScalingPlanResponse