{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.FIS.CreateExperimentTemplate
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates an experiment template.
--
-- An experiment template includes the following components:
--
-- -   __Targets__: A target can be a specific resource in your Amazon Web
--     Services environment, or one or more resources that match criteria
--     that you specify, for example, resources that have specific tags.
--
-- -   __Actions__: The actions to carry out on the target. You can specify
--     multiple actions, the duration of each action, and when to start
--     each action during an experiment.
--
-- -   __Stop conditions__: If a stop condition is triggered while an
--     experiment is running, the experiment is automatically stopped. You
--     can define a stop condition as a CloudWatch alarm.
--
-- For more information, see
-- <https://docs.aws.amazon.com/fis/latest/userguide/experiment-templates.html Experiment templates>
-- in the /Fault Injection Simulator User Guide/.
module Amazonka.FIS.CreateExperimentTemplate
  ( -- * Creating a Request
    CreateExperimentTemplate (..),
    newCreateExperimentTemplate,

    -- * Request Lenses
    createExperimentTemplate_logConfiguration,
    createExperimentTemplate_tags,
    createExperimentTemplate_targets,
    createExperimentTemplate_clientToken,
    createExperimentTemplate_description,
    createExperimentTemplate_stopConditions,
    createExperimentTemplate_actions,
    createExperimentTemplate_roleArn,

    -- * Destructuring the Response
    CreateExperimentTemplateResponse (..),
    newCreateExperimentTemplateResponse,

    -- * Response Lenses
    createExperimentTemplateResponse_experimentTemplate,
    createExperimentTemplateResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FIS.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreateExperimentTemplate' smart constructor.
data CreateExperimentTemplate = CreateExperimentTemplate'
  { -- | The configuration for experiment logging.
    CreateExperimentTemplate
-> Maybe CreateExperimentTemplateLogConfigurationInput
logConfiguration :: Prelude.Maybe CreateExperimentTemplateLogConfigurationInput,
    -- | The tags to apply to the experiment template.
    CreateExperimentTemplate -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The targets for the experiment.
    CreateExperimentTemplate
-> Maybe (HashMap Text CreateExperimentTemplateTargetInput)
targets :: Prelude.Maybe (Prelude.HashMap Prelude.Text CreateExperimentTemplateTargetInput),
    -- | Unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request.
    CreateExperimentTemplate -> Text
clientToken :: Prelude.Text,
    -- | A description for the experiment template.
    CreateExperimentTemplate -> Text
description :: Prelude.Text,
    -- | The stop conditions.
    CreateExperimentTemplate
-> [CreateExperimentTemplateStopConditionInput]
stopConditions :: [CreateExperimentTemplateStopConditionInput],
    -- | The actions for the experiment.
    CreateExperimentTemplate
-> HashMap Text CreateExperimentTemplateActionInput
actions :: Prelude.HashMap Prelude.Text CreateExperimentTemplateActionInput,
    -- | The Amazon Resource Name (ARN) of an IAM role that grants the FIS
    -- service permission to perform service actions on your behalf.
    CreateExperimentTemplate -> Text
roleArn :: Prelude.Text
  }
  deriving (CreateExperimentTemplate -> CreateExperimentTemplate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateExperimentTemplate -> CreateExperimentTemplate -> Bool
$c/= :: CreateExperimentTemplate -> CreateExperimentTemplate -> Bool
== :: CreateExperimentTemplate -> CreateExperimentTemplate -> Bool
$c== :: CreateExperimentTemplate -> CreateExperimentTemplate -> Bool
Prelude.Eq, ReadPrec [CreateExperimentTemplate]
ReadPrec CreateExperimentTemplate
Int -> ReadS CreateExperimentTemplate
ReadS [CreateExperimentTemplate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateExperimentTemplate]
$creadListPrec :: ReadPrec [CreateExperimentTemplate]
readPrec :: ReadPrec CreateExperimentTemplate
$creadPrec :: ReadPrec CreateExperimentTemplate
readList :: ReadS [CreateExperimentTemplate]
$creadList :: ReadS [CreateExperimentTemplate]
readsPrec :: Int -> ReadS CreateExperimentTemplate
$creadsPrec :: Int -> ReadS CreateExperimentTemplate
Prelude.Read, Int -> CreateExperimentTemplate -> ShowS
[CreateExperimentTemplate] -> ShowS
CreateExperimentTemplate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateExperimentTemplate] -> ShowS
$cshowList :: [CreateExperimentTemplate] -> ShowS
show :: CreateExperimentTemplate -> String
$cshow :: CreateExperimentTemplate -> String
showsPrec :: Int -> CreateExperimentTemplate -> ShowS
$cshowsPrec :: Int -> CreateExperimentTemplate -> ShowS
Prelude.Show, forall x.
Rep CreateExperimentTemplate x -> CreateExperimentTemplate
forall x.
CreateExperimentTemplate -> Rep CreateExperimentTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateExperimentTemplate x -> CreateExperimentTemplate
$cfrom :: forall x.
CreateExperimentTemplate -> Rep CreateExperimentTemplate x
Prelude.Generic)

-- |
-- Create a value of 'CreateExperimentTemplate' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'logConfiguration', 'createExperimentTemplate_logConfiguration' - The configuration for experiment logging.
--
-- 'tags', 'createExperimentTemplate_tags' - The tags to apply to the experiment template.
--
-- 'targets', 'createExperimentTemplate_targets' - The targets for the experiment.
--
-- 'clientToken', 'createExperimentTemplate_clientToken' - Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
--
-- 'description', 'createExperimentTemplate_description' - A description for the experiment template.
--
-- 'stopConditions', 'createExperimentTemplate_stopConditions' - The stop conditions.
--
-- 'actions', 'createExperimentTemplate_actions' - The actions for the experiment.
--
-- 'roleArn', 'createExperimentTemplate_roleArn' - The Amazon Resource Name (ARN) of an IAM role that grants the FIS
-- service permission to perform service actions on your behalf.
newCreateExperimentTemplate ::
  -- | 'clientToken'
  Prelude.Text ->
  -- | 'description'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  CreateExperimentTemplate
newCreateExperimentTemplate :: Text -> Text -> Text -> CreateExperimentTemplate
newCreateExperimentTemplate
  Text
pClientToken_
  Text
pDescription_
  Text
pRoleArn_ =
    CreateExperimentTemplate'
      { $sel:logConfiguration:CreateExperimentTemplate' :: Maybe CreateExperimentTemplateLogConfigurationInput
logConfiguration =
          forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateExperimentTemplate' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
        $sel:targets:CreateExperimentTemplate' :: Maybe (HashMap Text CreateExperimentTemplateTargetInput)
targets = forall a. Maybe a
Prelude.Nothing,
        $sel:clientToken:CreateExperimentTemplate' :: Text
clientToken = Text
pClientToken_,
        $sel:description:CreateExperimentTemplate' :: Text
description = Text
pDescription_,
        $sel:stopConditions:CreateExperimentTemplate' :: [CreateExperimentTemplateStopConditionInput]
stopConditions = forall a. Monoid a => a
Prelude.mempty,
        $sel:actions:CreateExperimentTemplate' :: HashMap Text CreateExperimentTemplateActionInput
actions = forall a. Monoid a => a
Prelude.mempty,
        $sel:roleArn:CreateExperimentTemplate' :: Text
roleArn = Text
pRoleArn_
      }

-- | The configuration for experiment logging.
createExperimentTemplate_logConfiguration :: Lens.Lens' CreateExperimentTemplate (Prelude.Maybe CreateExperimentTemplateLogConfigurationInput)
createExperimentTemplate_logConfiguration :: Lens'
  CreateExperimentTemplate
  (Maybe CreateExperimentTemplateLogConfigurationInput)
createExperimentTemplate_logConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateExperimentTemplate' {Maybe CreateExperimentTemplateLogConfigurationInput
logConfiguration :: Maybe CreateExperimentTemplateLogConfigurationInput
$sel:logConfiguration:CreateExperimentTemplate' :: CreateExperimentTemplate
-> Maybe CreateExperimentTemplateLogConfigurationInput
logConfiguration} -> Maybe CreateExperimentTemplateLogConfigurationInput
logConfiguration) (\s :: CreateExperimentTemplate
s@CreateExperimentTemplate' {} Maybe CreateExperimentTemplateLogConfigurationInput
a -> CreateExperimentTemplate
s {$sel:logConfiguration:CreateExperimentTemplate' :: Maybe CreateExperimentTemplateLogConfigurationInput
logConfiguration = Maybe CreateExperimentTemplateLogConfigurationInput
a} :: CreateExperimentTemplate)

-- | The tags to apply to the experiment template.
createExperimentTemplate_tags :: Lens.Lens' CreateExperimentTemplate (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createExperimentTemplate_tags :: Lens' CreateExperimentTemplate (Maybe (HashMap Text Text))
createExperimentTemplate_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateExperimentTemplate' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateExperimentTemplate' :: CreateExperimentTemplate -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateExperimentTemplate
s@CreateExperimentTemplate' {} Maybe (HashMap Text Text)
a -> CreateExperimentTemplate
s {$sel:tags:CreateExperimentTemplate' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateExperimentTemplate) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The targets for the experiment.
createExperimentTemplate_targets :: Lens.Lens' CreateExperimentTemplate (Prelude.Maybe (Prelude.HashMap Prelude.Text CreateExperimentTemplateTargetInput))
createExperimentTemplate_targets :: Lens'
  CreateExperimentTemplate
  (Maybe (HashMap Text CreateExperimentTemplateTargetInput))
createExperimentTemplate_targets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateExperimentTemplate' {Maybe (HashMap Text CreateExperimentTemplateTargetInput)
targets :: Maybe (HashMap Text CreateExperimentTemplateTargetInput)
$sel:targets:CreateExperimentTemplate' :: CreateExperimentTemplate
-> Maybe (HashMap Text CreateExperimentTemplateTargetInput)
targets} -> Maybe (HashMap Text CreateExperimentTemplateTargetInput)
targets) (\s :: CreateExperimentTemplate
s@CreateExperimentTemplate' {} Maybe (HashMap Text CreateExperimentTemplateTargetInput)
a -> CreateExperimentTemplate
s {$sel:targets:CreateExperimentTemplate' :: Maybe (HashMap Text CreateExperimentTemplateTargetInput)
targets = Maybe (HashMap Text CreateExperimentTemplateTargetInput)
a} :: CreateExperimentTemplate) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
createExperimentTemplate_clientToken :: Lens.Lens' CreateExperimentTemplate Prelude.Text
createExperimentTemplate_clientToken :: Lens' CreateExperimentTemplate Text
createExperimentTemplate_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateExperimentTemplate' {Text
clientToken :: Text
$sel:clientToken:CreateExperimentTemplate' :: CreateExperimentTemplate -> Text
clientToken} -> Text
clientToken) (\s :: CreateExperimentTemplate
s@CreateExperimentTemplate' {} Text
a -> CreateExperimentTemplate
s {$sel:clientToken:CreateExperimentTemplate' :: Text
clientToken = Text
a} :: CreateExperimentTemplate)

-- | A description for the experiment template.
createExperimentTemplate_description :: Lens.Lens' CreateExperimentTemplate Prelude.Text
createExperimentTemplate_description :: Lens' CreateExperimentTemplate Text
createExperimentTemplate_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateExperimentTemplate' {Text
description :: Text
$sel:description:CreateExperimentTemplate' :: CreateExperimentTemplate -> Text
description} -> Text
description) (\s :: CreateExperimentTemplate
s@CreateExperimentTemplate' {} Text
a -> CreateExperimentTemplate
s {$sel:description:CreateExperimentTemplate' :: Text
description = Text
a} :: CreateExperimentTemplate)

-- | The stop conditions.
createExperimentTemplate_stopConditions :: Lens.Lens' CreateExperimentTemplate [CreateExperimentTemplateStopConditionInput]
createExperimentTemplate_stopConditions :: Lens'
  CreateExperimentTemplate
  [CreateExperimentTemplateStopConditionInput]
createExperimentTemplate_stopConditions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateExperimentTemplate' {[CreateExperimentTemplateStopConditionInput]
stopConditions :: [CreateExperimentTemplateStopConditionInput]
$sel:stopConditions:CreateExperimentTemplate' :: CreateExperimentTemplate
-> [CreateExperimentTemplateStopConditionInput]
stopConditions} -> [CreateExperimentTemplateStopConditionInput]
stopConditions) (\s :: CreateExperimentTemplate
s@CreateExperimentTemplate' {} [CreateExperimentTemplateStopConditionInput]
a -> CreateExperimentTemplate
s {$sel:stopConditions:CreateExperimentTemplate' :: [CreateExperimentTemplateStopConditionInput]
stopConditions = [CreateExperimentTemplateStopConditionInput]
a} :: CreateExperimentTemplate) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The actions for the experiment.
createExperimentTemplate_actions :: Lens.Lens' CreateExperimentTemplate (Prelude.HashMap Prelude.Text CreateExperimentTemplateActionInput)
createExperimentTemplate_actions :: Lens'
  CreateExperimentTemplate
  (HashMap Text CreateExperimentTemplateActionInput)
createExperimentTemplate_actions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateExperimentTemplate' {HashMap Text CreateExperimentTemplateActionInput
actions :: HashMap Text CreateExperimentTemplateActionInput
$sel:actions:CreateExperimentTemplate' :: CreateExperimentTemplate
-> HashMap Text CreateExperimentTemplateActionInput
actions} -> HashMap Text CreateExperimentTemplateActionInput
actions) (\s :: CreateExperimentTemplate
s@CreateExperimentTemplate' {} HashMap Text CreateExperimentTemplateActionInput
a -> CreateExperimentTemplate
s {$sel:actions:CreateExperimentTemplate' :: HashMap Text CreateExperimentTemplateActionInput
actions = HashMap Text CreateExperimentTemplateActionInput
a} :: CreateExperimentTemplate) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of an IAM role that grants the FIS
-- service permission to perform service actions on your behalf.
createExperimentTemplate_roleArn :: Lens.Lens' CreateExperimentTemplate Prelude.Text
createExperimentTemplate_roleArn :: Lens' CreateExperimentTemplate Text
createExperimentTemplate_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateExperimentTemplate' {Text
roleArn :: Text
$sel:roleArn:CreateExperimentTemplate' :: CreateExperimentTemplate -> Text
roleArn} -> Text
roleArn) (\s :: CreateExperimentTemplate
s@CreateExperimentTemplate' {} Text
a -> CreateExperimentTemplate
s {$sel:roleArn:CreateExperimentTemplate' :: Text
roleArn = Text
a} :: CreateExperimentTemplate)

instance Core.AWSRequest CreateExperimentTemplate where
  type
    AWSResponse CreateExperimentTemplate =
      CreateExperimentTemplateResponse
  request :: (Service -> Service)
-> CreateExperimentTemplate -> Request CreateExperimentTemplate
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateExperimentTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateExperimentTemplate)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ExperimentTemplate -> Int -> CreateExperimentTemplateResponse
CreateExperimentTemplateResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"experimentTemplate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateExperimentTemplate where
  hashWithSalt :: Int -> CreateExperimentTemplate -> Int
hashWithSalt Int
_salt CreateExperimentTemplate' {[CreateExperimentTemplateStopConditionInput]
Maybe (HashMap Text Text)
Maybe (HashMap Text CreateExperimentTemplateTargetInput)
Maybe CreateExperimentTemplateLogConfigurationInput
Text
HashMap Text CreateExperimentTemplateActionInput
roleArn :: Text
actions :: HashMap Text CreateExperimentTemplateActionInput
stopConditions :: [CreateExperimentTemplateStopConditionInput]
description :: Text
clientToken :: Text
targets :: Maybe (HashMap Text CreateExperimentTemplateTargetInput)
tags :: Maybe (HashMap Text Text)
logConfiguration :: Maybe CreateExperimentTemplateLogConfigurationInput
$sel:roleArn:CreateExperimentTemplate' :: CreateExperimentTemplate -> Text
$sel:actions:CreateExperimentTemplate' :: CreateExperimentTemplate
-> HashMap Text CreateExperimentTemplateActionInput
$sel:stopConditions:CreateExperimentTemplate' :: CreateExperimentTemplate
-> [CreateExperimentTemplateStopConditionInput]
$sel:description:CreateExperimentTemplate' :: CreateExperimentTemplate -> Text
$sel:clientToken:CreateExperimentTemplate' :: CreateExperimentTemplate -> Text
$sel:targets:CreateExperimentTemplate' :: CreateExperimentTemplate
-> Maybe (HashMap Text CreateExperimentTemplateTargetInput)
$sel:tags:CreateExperimentTemplate' :: CreateExperimentTemplate -> Maybe (HashMap Text Text)
$sel:logConfiguration:CreateExperimentTemplate' :: CreateExperimentTemplate
-> Maybe CreateExperimentTemplateLogConfigurationInput
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CreateExperimentTemplateLogConfigurationInput
logConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text CreateExperimentTemplateTargetInput)
targets
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [CreateExperimentTemplateStopConditionInput]
stopConditions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashMap Text CreateExperimentTemplateActionInput
actions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleArn

instance Prelude.NFData CreateExperimentTemplate where
  rnf :: CreateExperimentTemplate -> ()
rnf CreateExperimentTemplate' {[CreateExperimentTemplateStopConditionInput]
Maybe (HashMap Text Text)
Maybe (HashMap Text CreateExperimentTemplateTargetInput)
Maybe CreateExperimentTemplateLogConfigurationInput
Text
HashMap Text CreateExperimentTemplateActionInput
roleArn :: Text
actions :: HashMap Text CreateExperimentTemplateActionInput
stopConditions :: [CreateExperimentTemplateStopConditionInput]
description :: Text
clientToken :: Text
targets :: Maybe (HashMap Text CreateExperimentTemplateTargetInput)
tags :: Maybe (HashMap Text Text)
logConfiguration :: Maybe CreateExperimentTemplateLogConfigurationInput
$sel:roleArn:CreateExperimentTemplate' :: CreateExperimentTemplate -> Text
$sel:actions:CreateExperimentTemplate' :: CreateExperimentTemplate
-> HashMap Text CreateExperimentTemplateActionInput
$sel:stopConditions:CreateExperimentTemplate' :: CreateExperimentTemplate
-> [CreateExperimentTemplateStopConditionInput]
$sel:description:CreateExperimentTemplate' :: CreateExperimentTemplate -> Text
$sel:clientToken:CreateExperimentTemplate' :: CreateExperimentTemplate -> Text
$sel:targets:CreateExperimentTemplate' :: CreateExperimentTemplate
-> Maybe (HashMap Text CreateExperimentTemplateTargetInput)
$sel:tags:CreateExperimentTemplate' :: CreateExperimentTemplate -> Maybe (HashMap Text Text)
$sel:logConfiguration:CreateExperimentTemplate' :: CreateExperimentTemplate
-> Maybe CreateExperimentTemplateLogConfigurationInput
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CreateExperimentTemplateLogConfigurationInput
logConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text CreateExperimentTemplateTargetInput)
targets
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [CreateExperimentTemplateStopConditionInput]
stopConditions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text CreateExperimentTemplateActionInput
actions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleArn

instance Data.ToHeaders CreateExperimentTemplate where
  toHeaders :: CreateExperimentTemplate -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON CreateExperimentTemplate where
  toJSON :: CreateExperimentTemplate -> Value
toJSON CreateExperimentTemplate' {[CreateExperimentTemplateStopConditionInput]
Maybe (HashMap Text Text)
Maybe (HashMap Text CreateExperimentTemplateTargetInput)
Maybe CreateExperimentTemplateLogConfigurationInput
Text
HashMap Text CreateExperimentTemplateActionInput
roleArn :: Text
actions :: HashMap Text CreateExperimentTemplateActionInput
stopConditions :: [CreateExperimentTemplateStopConditionInput]
description :: Text
clientToken :: Text
targets :: Maybe (HashMap Text CreateExperimentTemplateTargetInput)
tags :: Maybe (HashMap Text Text)
logConfiguration :: Maybe CreateExperimentTemplateLogConfigurationInput
$sel:roleArn:CreateExperimentTemplate' :: CreateExperimentTemplate -> Text
$sel:actions:CreateExperimentTemplate' :: CreateExperimentTemplate
-> HashMap Text CreateExperimentTemplateActionInput
$sel:stopConditions:CreateExperimentTemplate' :: CreateExperimentTemplate
-> [CreateExperimentTemplateStopConditionInput]
$sel:description:CreateExperimentTemplate' :: CreateExperimentTemplate -> Text
$sel:clientToken:CreateExperimentTemplate' :: CreateExperimentTemplate -> Text
$sel:targets:CreateExperimentTemplate' :: CreateExperimentTemplate
-> Maybe (HashMap Text CreateExperimentTemplateTargetInput)
$sel:tags:CreateExperimentTemplate' :: CreateExperimentTemplate -> Maybe (HashMap Text Text)
$sel:logConfiguration:CreateExperimentTemplate' :: CreateExperimentTemplate
-> Maybe CreateExperimentTemplateLogConfigurationInput
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"logConfiguration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CreateExperimentTemplateLogConfigurationInput
logConfiguration,
            (Key
"tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            (Key
"targets" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text CreateExperimentTemplateTargetInput)
targets,
            forall a. a -> Maybe a
Prelude.Just (Key
"clientToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
clientToken),
            forall a. a -> Maybe a
Prelude.Just (Key
"description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
description),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"stopConditions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [CreateExperimentTemplateStopConditionInput]
stopConditions),
            forall a. a -> Maybe a
Prelude.Just (Key
"actions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= HashMap Text CreateExperimentTemplateActionInput
actions),
            forall a. a -> Maybe a
Prelude.Just (Key
"roleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
roleArn)
          ]
      )

instance Data.ToPath CreateExperimentTemplate where
  toPath :: CreateExperimentTemplate -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/experimentTemplates"

instance Data.ToQuery CreateExperimentTemplate where
  toQuery :: CreateExperimentTemplate -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateExperimentTemplateResponse' smart constructor.
data CreateExperimentTemplateResponse = CreateExperimentTemplateResponse'
  { -- | Information about the experiment template.
    CreateExperimentTemplateResponse -> Maybe ExperimentTemplate
experimentTemplate :: Prelude.Maybe ExperimentTemplate,
    -- | The response's http status code.
    CreateExperimentTemplateResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateExperimentTemplateResponse
-> CreateExperimentTemplateResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateExperimentTemplateResponse
-> CreateExperimentTemplateResponse -> Bool
$c/= :: CreateExperimentTemplateResponse
-> CreateExperimentTemplateResponse -> Bool
== :: CreateExperimentTemplateResponse
-> CreateExperimentTemplateResponse -> Bool
$c== :: CreateExperimentTemplateResponse
-> CreateExperimentTemplateResponse -> Bool
Prelude.Eq, ReadPrec [CreateExperimentTemplateResponse]
ReadPrec CreateExperimentTemplateResponse
Int -> ReadS CreateExperimentTemplateResponse
ReadS [CreateExperimentTemplateResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateExperimentTemplateResponse]
$creadListPrec :: ReadPrec [CreateExperimentTemplateResponse]
readPrec :: ReadPrec CreateExperimentTemplateResponse
$creadPrec :: ReadPrec CreateExperimentTemplateResponse
readList :: ReadS [CreateExperimentTemplateResponse]
$creadList :: ReadS [CreateExperimentTemplateResponse]
readsPrec :: Int -> ReadS CreateExperimentTemplateResponse
$creadsPrec :: Int -> ReadS CreateExperimentTemplateResponse
Prelude.Read, Int -> CreateExperimentTemplateResponse -> ShowS
[CreateExperimentTemplateResponse] -> ShowS
CreateExperimentTemplateResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateExperimentTemplateResponse] -> ShowS
$cshowList :: [CreateExperimentTemplateResponse] -> ShowS
show :: CreateExperimentTemplateResponse -> String
$cshow :: CreateExperimentTemplateResponse -> String
showsPrec :: Int -> CreateExperimentTemplateResponse -> ShowS
$cshowsPrec :: Int -> CreateExperimentTemplateResponse -> ShowS
Prelude.Show, forall x.
Rep CreateExperimentTemplateResponse x
-> CreateExperimentTemplateResponse
forall x.
CreateExperimentTemplateResponse
-> Rep CreateExperimentTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateExperimentTemplateResponse x
-> CreateExperimentTemplateResponse
$cfrom :: forall x.
CreateExperimentTemplateResponse
-> Rep CreateExperimentTemplateResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateExperimentTemplateResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'experimentTemplate', 'createExperimentTemplateResponse_experimentTemplate' - Information about the experiment template.
--
-- 'httpStatus', 'createExperimentTemplateResponse_httpStatus' - The response's http status code.
newCreateExperimentTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateExperimentTemplateResponse
newCreateExperimentTemplateResponse :: Int -> CreateExperimentTemplateResponse
newCreateExperimentTemplateResponse Int
pHttpStatus_ =
  CreateExperimentTemplateResponse'
    { $sel:experimentTemplate:CreateExperimentTemplateResponse' :: Maybe ExperimentTemplate
experimentTemplate =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateExperimentTemplateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the experiment template.
createExperimentTemplateResponse_experimentTemplate :: Lens.Lens' CreateExperimentTemplateResponse (Prelude.Maybe ExperimentTemplate)
createExperimentTemplateResponse_experimentTemplate :: Lens' CreateExperimentTemplateResponse (Maybe ExperimentTemplate)
createExperimentTemplateResponse_experimentTemplate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateExperimentTemplateResponse' {Maybe ExperimentTemplate
experimentTemplate :: Maybe ExperimentTemplate
$sel:experimentTemplate:CreateExperimentTemplateResponse' :: CreateExperimentTemplateResponse -> Maybe ExperimentTemplate
experimentTemplate} -> Maybe ExperimentTemplate
experimentTemplate) (\s :: CreateExperimentTemplateResponse
s@CreateExperimentTemplateResponse' {} Maybe ExperimentTemplate
a -> CreateExperimentTemplateResponse
s {$sel:experimentTemplate:CreateExperimentTemplateResponse' :: Maybe ExperimentTemplate
experimentTemplate = Maybe ExperimentTemplate
a} :: CreateExperimentTemplateResponse)

-- | The response's http status code.
createExperimentTemplateResponse_httpStatus :: Lens.Lens' CreateExperimentTemplateResponse Prelude.Int
createExperimentTemplateResponse_httpStatus :: Lens' CreateExperimentTemplateResponse Int
createExperimentTemplateResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateExperimentTemplateResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateExperimentTemplateResponse' :: CreateExperimentTemplateResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateExperimentTemplateResponse
s@CreateExperimentTemplateResponse' {} Int
a -> CreateExperimentTemplateResponse
s {$sel:httpStatus:CreateExperimentTemplateResponse' :: Int
httpStatus = Int
a} :: CreateExperimentTemplateResponse)

instance
  Prelude.NFData
    CreateExperimentTemplateResponse
  where
  rnf :: CreateExperimentTemplateResponse -> ()
rnf CreateExperimentTemplateResponse' {Int
Maybe ExperimentTemplate
httpStatus :: Int
experimentTemplate :: Maybe ExperimentTemplate
$sel:httpStatus:CreateExperimentTemplateResponse' :: CreateExperimentTemplateResponse -> Int
$sel:experimentTemplate:CreateExperimentTemplateResponse' :: CreateExperimentTemplateResponse -> Maybe ExperimentTemplate
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ExperimentTemplate
experimentTemplate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus