{-# 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.AppConfig.CreateEnvironment
(
CreateEnvironment (..),
newCreateEnvironment,
createEnvironment_monitors,
createEnvironment_description,
createEnvironment_tags,
createEnvironment_applicationId,
createEnvironment_name,
Environment (..),
newEnvironment,
environment_state,
environment_monitors,
environment_applicationId,
environment_name,
environment_id,
environment_description,
)
where
import Amazonka.AppConfig.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 CreateEnvironment = CreateEnvironment'
{
CreateEnvironment -> Maybe [Monitor]
monitors :: Prelude.Maybe [Monitor],
CreateEnvironment -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CreateEnvironment -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
CreateEnvironment -> Text
applicationId :: Prelude.Text,
CreateEnvironment -> Text
name :: Prelude.Text
}
deriving (CreateEnvironment -> CreateEnvironment -> Bool
(CreateEnvironment -> CreateEnvironment -> Bool)
-> (CreateEnvironment -> CreateEnvironment -> Bool)
-> Eq CreateEnvironment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateEnvironment -> CreateEnvironment -> Bool
$c/= :: CreateEnvironment -> CreateEnvironment -> Bool
== :: CreateEnvironment -> CreateEnvironment -> Bool
$c== :: CreateEnvironment -> CreateEnvironment -> Bool
Prelude.Eq, ReadPrec [CreateEnvironment]
ReadPrec CreateEnvironment
Int -> ReadS CreateEnvironment
ReadS [CreateEnvironment]
(Int -> ReadS CreateEnvironment)
-> ReadS [CreateEnvironment]
-> ReadPrec CreateEnvironment
-> ReadPrec [CreateEnvironment]
-> Read CreateEnvironment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateEnvironment]
$creadListPrec :: ReadPrec [CreateEnvironment]
readPrec :: ReadPrec CreateEnvironment
$creadPrec :: ReadPrec CreateEnvironment
readList :: ReadS [CreateEnvironment]
$creadList :: ReadS [CreateEnvironment]
readsPrec :: Int -> ReadS CreateEnvironment
$creadsPrec :: Int -> ReadS CreateEnvironment
Prelude.Read, Int -> CreateEnvironment -> ShowS
[CreateEnvironment] -> ShowS
CreateEnvironment -> String
(Int -> CreateEnvironment -> ShowS)
-> (CreateEnvironment -> String)
-> ([CreateEnvironment] -> ShowS)
-> Show CreateEnvironment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateEnvironment] -> ShowS
$cshowList :: [CreateEnvironment] -> ShowS
show :: CreateEnvironment -> String
$cshow :: CreateEnvironment -> String
showsPrec :: Int -> CreateEnvironment -> ShowS
$cshowsPrec :: Int -> CreateEnvironment -> ShowS
Prelude.Show, (forall x. CreateEnvironment -> Rep CreateEnvironment x)
-> (forall x. Rep CreateEnvironment x -> CreateEnvironment)
-> Generic CreateEnvironment
forall x. Rep CreateEnvironment x -> CreateEnvironment
forall x. CreateEnvironment -> Rep CreateEnvironment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateEnvironment x -> CreateEnvironment
$cfrom :: forall x. CreateEnvironment -> Rep CreateEnvironment x
Prelude.Generic)
newCreateEnvironment ::
Prelude.Text ->
Prelude.Text ->
CreateEnvironment
newCreateEnvironment :: Text -> Text -> CreateEnvironment
newCreateEnvironment Text
pApplicationId_ Text
pName_ =
CreateEnvironment' :: Maybe [Monitor]
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> CreateEnvironment
CreateEnvironment'
{ $sel:monitors:CreateEnvironment' :: Maybe [Monitor]
monitors = Maybe [Monitor]
forall a. Maybe a
Prelude.Nothing,
$sel:description:CreateEnvironment' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateEnvironment' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:applicationId:CreateEnvironment' :: Text
applicationId = Text
pApplicationId_,
$sel:name:CreateEnvironment' :: Text
name = Text
pName_
}
createEnvironment_monitors :: Lens.Lens' CreateEnvironment (Prelude.Maybe [Monitor])
createEnvironment_monitors :: (Maybe [Monitor] -> f (Maybe [Monitor]))
-> CreateEnvironment -> f CreateEnvironment
createEnvironment_monitors = (CreateEnvironment -> Maybe [Monitor])
-> (CreateEnvironment -> Maybe [Monitor] -> CreateEnvironment)
-> Lens
CreateEnvironment
CreateEnvironment
(Maybe [Monitor])
(Maybe [Monitor])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEnvironment' {Maybe [Monitor]
monitors :: Maybe [Monitor]
$sel:monitors:CreateEnvironment' :: CreateEnvironment -> Maybe [Monitor]
monitors} -> Maybe [Monitor]
monitors) (\s :: CreateEnvironment
s@CreateEnvironment' {} Maybe [Monitor]
a -> CreateEnvironment
s {$sel:monitors:CreateEnvironment' :: Maybe [Monitor]
monitors = Maybe [Monitor]
a} :: CreateEnvironment) ((Maybe [Monitor] -> f (Maybe [Monitor]))
-> CreateEnvironment -> f CreateEnvironment)
-> ((Maybe [Monitor] -> f (Maybe [Monitor]))
-> Maybe [Monitor] -> f (Maybe [Monitor]))
-> (Maybe [Monitor] -> f (Maybe [Monitor]))
-> CreateEnvironment
-> f CreateEnvironment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Monitor] [Monitor] [Monitor] [Monitor]
-> Iso
(Maybe [Monitor])
(Maybe [Monitor])
(Maybe [Monitor])
(Maybe [Monitor])
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 [Monitor] [Monitor] [Monitor] [Monitor]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createEnvironment_description :: Lens.Lens' CreateEnvironment (Prelude.Maybe Prelude.Text)
createEnvironment_description :: (Maybe Text -> f (Maybe Text))
-> CreateEnvironment -> f CreateEnvironment
createEnvironment_description = (CreateEnvironment -> Maybe Text)
-> (CreateEnvironment -> Maybe Text -> CreateEnvironment)
-> Lens
CreateEnvironment CreateEnvironment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEnvironment' {Maybe Text
description :: Maybe Text
$sel:description:CreateEnvironment' :: CreateEnvironment -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateEnvironment
s@CreateEnvironment' {} Maybe Text
a -> CreateEnvironment
s {$sel:description:CreateEnvironment' :: Maybe Text
description = Maybe Text
a} :: CreateEnvironment)
createEnvironment_tags :: Lens.Lens' CreateEnvironment (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createEnvironment_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateEnvironment -> f CreateEnvironment
createEnvironment_tags = (CreateEnvironment -> Maybe (HashMap Text Text))
-> (CreateEnvironment
-> Maybe (HashMap Text Text) -> CreateEnvironment)
-> Lens
CreateEnvironment
CreateEnvironment
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEnvironment' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateEnvironment' :: CreateEnvironment -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateEnvironment
s@CreateEnvironment' {} Maybe (HashMap Text Text)
a -> CreateEnvironment
s {$sel:tags:CreateEnvironment' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateEnvironment) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateEnvironment -> f CreateEnvironment)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateEnvironment
-> f CreateEnvironment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
-> Iso
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text 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
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createEnvironment_applicationId :: Lens.Lens' CreateEnvironment Prelude.Text
createEnvironment_applicationId :: (Text -> f Text) -> CreateEnvironment -> f CreateEnvironment
createEnvironment_applicationId = (CreateEnvironment -> Text)
-> (CreateEnvironment -> Text -> CreateEnvironment)
-> Lens CreateEnvironment CreateEnvironment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEnvironment' {Text
applicationId :: Text
$sel:applicationId:CreateEnvironment' :: CreateEnvironment -> Text
applicationId} -> Text
applicationId) (\s :: CreateEnvironment
s@CreateEnvironment' {} Text
a -> CreateEnvironment
s {$sel:applicationId:CreateEnvironment' :: Text
applicationId = Text
a} :: CreateEnvironment)
createEnvironment_name :: Lens.Lens' CreateEnvironment Prelude.Text
createEnvironment_name :: (Text -> f Text) -> CreateEnvironment -> f CreateEnvironment
createEnvironment_name = (CreateEnvironment -> Text)
-> (CreateEnvironment -> Text -> CreateEnvironment)
-> Lens CreateEnvironment CreateEnvironment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEnvironment' {Text
name :: Text
$sel:name:CreateEnvironment' :: CreateEnvironment -> Text
name} -> Text
name) (\s :: CreateEnvironment
s@CreateEnvironment' {} Text
a -> CreateEnvironment
s {$sel:name:CreateEnvironment' :: Text
name = Text
a} :: CreateEnvironment)
instance Core.AWSRequest CreateEnvironment where
type AWSResponse CreateEnvironment = Environment
request :: CreateEnvironment -> Request CreateEnvironment
request = Service -> CreateEnvironment -> Request CreateEnvironment
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateEnvironment
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateEnvironment)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateEnvironment))
-> Logger
-> Service
-> Proxy CreateEnvironment
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateEnvironment)))
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 -> Object -> Either String Environment
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
instance Prelude.Hashable CreateEnvironment
instance Prelude.NFData CreateEnvironment
instance Core.ToHeaders CreateEnvironment where
toHeaders :: CreateEnvironment -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateEnvironment -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ 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 CreateEnvironment where
toJSON :: CreateEnvironment -> Value
toJSON CreateEnvironment' {Maybe [Monitor]
Maybe Text
Maybe (HashMap Text Text)
Text
name :: Text
applicationId :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
monitors :: Maybe [Monitor]
$sel:name:CreateEnvironment' :: CreateEnvironment -> Text
$sel:applicationId:CreateEnvironment' :: CreateEnvironment -> Text
$sel:tags:CreateEnvironment' :: CreateEnvironment -> Maybe (HashMap Text Text)
$sel:description:CreateEnvironment' :: CreateEnvironment -> Maybe Text
$sel:monitors:CreateEnvironment' :: CreateEnvironment -> Maybe [Monitor]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Monitors" Text -> [Monitor] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Monitor] -> Pair) -> Maybe [Monitor] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Monitor]
monitors,
(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 -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
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 CreateEnvironment where
toPath :: CreateEnvironment -> ByteString
toPath CreateEnvironment' {Maybe [Monitor]
Maybe Text
Maybe (HashMap Text Text)
Text
name :: Text
applicationId :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
monitors :: Maybe [Monitor]
$sel:name:CreateEnvironment' :: CreateEnvironment -> Text
$sel:applicationId:CreateEnvironment' :: CreateEnvironment -> Text
$sel:tags:CreateEnvironment' :: CreateEnvironment -> Maybe (HashMap Text Text)
$sel:description:CreateEnvironment' :: CreateEnvironment -> Maybe Text
$sel:monitors:CreateEnvironment' :: CreateEnvironment -> Maybe [Monitor]
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/applications/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId,
ByteString
"/environments"
]
instance Core.ToQuery CreateEnvironment where
toQuery :: CreateEnvironment -> QueryString
toQuery = QueryString -> CreateEnvironment -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty