{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates an experiment template.
--
-- To create a template, specify the following information:
--
-- -   __Targets__: A target can be a specific resource in your AWS
--     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 the
-- <https://docs.aws.amazon.com/fis/latest/userguide/ AWS Fault Injection Simulator User Guide>.
module Amazonka.FIS.CreateExperimentTemplate
  ( -- * Creating a Request
    CreateExperimentTemplate (..),
    newCreateExperimentTemplate,

    -- * Request Lenses
    createExperimentTemplate_targets,
    createExperimentTemplate_tags,
    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 Amazonka.FIS.Types
import qualified Amazonka.Lens as Lens
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 targets for the experiment.
    CreateExperimentTemplate
-> Maybe (HashMap Text CreateExperimentTemplateTargetInput)
targets :: Prelude.Maybe (Prelude.HashMap Prelude.Text CreateExperimentTemplateTargetInput),
    -- | The tags to apply to the experiment template.
    CreateExperimentTemplate -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | 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. Can contain up to 64 letters
    -- (A-Z and a-z).
    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 AWS FIS
    -- service permission to perform service actions on your behalf.
    CreateExperimentTemplate -> Text
roleArn :: Prelude.Text
  }
  deriving (CreateExperimentTemplate -> CreateExperimentTemplate -> Bool
(CreateExperimentTemplate -> CreateExperimentTemplate -> Bool)
-> (CreateExperimentTemplate -> CreateExperimentTemplate -> Bool)
-> Eq CreateExperimentTemplate
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]
(Int -> ReadS CreateExperimentTemplate)
-> ReadS [CreateExperimentTemplate]
-> ReadPrec CreateExperimentTemplate
-> ReadPrec [CreateExperimentTemplate]
-> Read 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
(Int -> CreateExperimentTemplate -> ShowS)
-> (CreateExperimentTemplate -> String)
-> ([CreateExperimentTemplate] -> ShowS)
-> Show CreateExperimentTemplate
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.
 CreateExperimentTemplate -> Rep CreateExperimentTemplate x)
-> (forall x.
    Rep CreateExperimentTemplate x -> CreateExperimentTemplate)
-> Generic CreateExperimentTemplate
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:
--
-- 'targets', 'createExperimentTemplate_targets' - The targets for the experiment.
--
-- 'tags', 'createExperimentTemplate_tags' - The tags to apply to the experiment template.
--
-- '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. Can contain up to 64 letters
-- (A-Z and a-z).
--
-- '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 AWS 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' :: Maybe (HashMap Text CreateExperimentTemplateTargetInput)
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> [CreateExperimentTemplateStopConditionInput]
-> HashMap Text CreateExperimentTemplateActionInput
-> Text
-> CreateExperimentTemplate
CreateExperimentTemplate'
      { $sel:targets:CreateExperimentTemplate' :: Maybe (HashMap Text CreateExperimentTemplateTargetInput)
targets =
          Maybe (HashMap Text CreateExperimentTemplateTargetInput)
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateExperimentTemplate' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
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 = [CreateExperimentTemplateStopConditionInput]
forall a. Monoid a => a
Prelude.mempty,
        $sel:actions:CreateExperimentTemplate' :: HashMap Text CreateExperimentTemplateActionInput
actions = HashMap Text CreateExperimentTemplateActionInput
forall a. Monoid a => a
Prelude.mempty,
        $sel:roleArn:CreateExperimentTemplate' :: Text
roleArn = Text
pRoleArn_
      }

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

-- | The tags to apply to the experiment template.
createExperimentTemplate_tags :: Lens.Lens' CreateExperimentTemplate (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createExperimentTemplate_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateExperimentTemplate -> f CreateExperimentTemplate
createExperimentTemplate_tags = (CreateExperimentTemplate -> Maybe (HashMap Text Text))
-> (CreateExperimentTemplate
    -> Maybe (HashMap Text Text) -> CreateExperimentTemplate)
-> Lens
     CreateExperimentTemplate
     CreateExperimentTemplate
     (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 (\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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateExperimentTemplate -> f CreateExperimentTemplate)
-> ((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)))
-> CreateExperimentTemplate
-> f CreateExperimentTemplate
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

-- | Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
createExperimentTemplate_clientToken :: Lens.Lens' CreateExperimentTemplate Prelude.Text
createExperimentTemplate_clientToken :: (Text -> f Text)
-> CreateExperimentTemplate -> f CreateExperimentTemplate
createExperimentTemplate_clientToken = (CreateExperimentTemplate -> Text)
-> (CreateExperimentTemplate -> Text -> CreateExperimentTemplate)
-> Lens CreateExperimentTemplate CreateExperimentTemplate Text Text
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. Can contain up to 64 letters
-- (A-Z and a-z).
createExperimentTemplate_description :: Lens.Lens' CreateExperimentTemplate Prelude.Text
createExperimentTemplate_description :: (Text -> f Text)
-> CreateExperimentTemplate -> f CreateExperimentTemplate
createExperimentTemplate_description = (CreateExperimentTemplate -> Text)
-> (CreateExperimentTemplate -> Text -> CreateExperimentTemplate)
-> Lens CreateExperimentTemplate CreateExperimentTemplate Text Text
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 :: ([CreateExperimentTemplateStopConditionInput]
 -> f [CreateExperimentTemplateStopConditionInput])
-> CreateExperimentTemplate -> f CreateExperimentTemplate
createExperimentTemplate_stopConditions = (CreateExperimentTemplate
 -> [CreateExperimentTemplateStopConditionInput])
-> (CreateExperimentTemplate
    -> [CreateExperimentTemplateStopConditionInput]
    -> CreateExperimentTemplate)
-> Lens
     CreateExperimentTemplate
     CreateExperimentTemplate
     [CreateExperimentTemplateStopConditionInput]
     [CreateExperimentTemplateStopConditionInput]
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) (([CreateExperimentTemplateStopConditionInput]
  -> f [CreateExperimentTemplateStopConditionInput])
 -> CreateExperimentTemplate -> f CreateExperimentTemplate)
-> (([CreateExperimentTemplateStopConditionInput]
     -> f [CreateExperimentTemplateStopConditionInput])
    -> [CreateExperimentTemplateStopConditionInput]
    -> f [CreateExperimentTemplateStopConditionInput])
-> ([CreateExperimentTemplateStopConditionInput]
    -> f [CreateExperimentTemplateStopConditionInput])
-> CreateExperimentTemplate
-> f CreateExperimentTemplate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([CreateExperimentTemplateStopConditionInput]
 -> f [CreateExperimentTemplateStopConditionInput])
-> [CreateExperimentTemplateStopConditionInput]
-> f [CreateExperimentTemplateStopConditionInput]
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 :: (HashMap Text CreateExperimentTemplateActionInput
 -> f (HashMap Text CreateExperimentTemplateActionInput))
-> CreateExperimentTemplate -> f CreateExperimentTemplate
createExperimentTemplate_actions = (CreateExperimentTemplate
 -> HashMap Text CreateExperimentTemplateActionInput)
-> (CreateExperimentTemplate
    -> HashMap Text CreateExperimentTemplateActionInput
    -> CreateExperimentTemplate)
-> Lens
     CreateExperimentTemplate
     CreateExperimentTemplate
     (HashMap Text CreateExperimentTemplateActionInput)
     (HashMap Text CreateExperimentTemplateActionInput)
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) ((HashMap Text CreateExperimentTemplateActionInput
  -> f (HashMap Text CreateExperimentTemplateActionInput))
 -> CreateExperimentTemplate -> f CreateExperimentTemplate)
-> ((HashMap Text CreateExperimentTemplateActionInput
     -> f (HashMap Text CreateExperimentTemplateActionInput))
    -> HashMap Text CreateExperimentTemplateActionInput
    -> f (HashMap Text CreateExperimentTemplateActionInput))
-> (HashMap Text CreateExperimentTemplateActionInput
    -> f (HashMap Text CreateExperimentTemplateActionInput))
-> CreateExperimentTemplate
-> f CreateExperimentTemplate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text CreateExperimentTemplateActionInput
 -> f (HashMap Text CreateExperimentTemplateActionInput))
-> HashMap Text CreateExperimentTemplateActionInput
-> f (HashMap Text CreateExperimentTemplateActionInput)
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 AWS FIS
-- service permission to perform service actions on your behalf.
createExperimentTemplate_roleArn :: Lens.Lens' CreateExperimentTemplate Prelude.Text
createExperimentTemplate_roleArn :: (Text -> f Text)
-> CreateExperimentTemplate -> f CreateExperimentTemplate
createExperimentTemplate_roleArn = (CreateExperimentTemplate -> Text)
-> (CreateExperimentTemplate -> Text -> CreateExperimentTemplate)
-> Lens CreateExperimentTemplate CreateExperimentTemplate Text Text
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 :: CreateExperimentTemplate -> Request CreateExperimentTemplate
request = Service
-> CreateExperimentTemplate -> Request CreateExperimentTemplate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateExperimentTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateExperimentTemplate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateExperimentTemplate))
-> Logger
-> Service
-> Proxy CreateExperimentTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateExperimentTemplate)))
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 ExperimentTemplate -> Int -> CreateExperimentTemplateResponse
CreateExperimentTemplateResponse'
            (Maybe ExperimentTemplate
 -> Int -> CreateExperimentTemplateResponse)
-> Either String (Maybe ExperimentTemplate)
-> Either String (Int -> CreateExperimentTemplateResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ExperimentTemplate)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"experimentTemplate")
            Either String (Int -> CreateExperimentTemplateResponse)
-> Either String Int
-> Either String CreateExperimentTemplateResponse
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 CreateExperimentTemplate

instance Prelude.NFData CreateExperimentTemplate

instance Core.ToHeaders CreateExperimentTemplate where
  toHeaders :: CreateExperimentTemplate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateExperimentTemplate -> 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 CreateExperimentTemplate where
  toJSON :: CreateExperimentTemplate -> Value
toJSON CreateExperimentTemplate' {[CreateExperimentTemplateStopConditionInput]
Maybe (HashMap Text Text)
Maybe (HashMap Text CreateExperimentTemplateTargetInput)
Text
HashMap Text CreateExperimentTemplateActionInput
roleArn :: Text
actions :: HashMap Text CreateExperimentTemplateActionInput
stopConditions :: [CreateExperimentTemplateStopConditionInput]
description :: Text
clientToken :: Text
tags :: Maybe (HashMap Text Text)
targets :: Maybe (HashMap Text CreateExperimentTemplateTargetInput)
$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:tags:CreateExperimentTemplate' :: CreateExperimentTemplate -> Maybe (HashMap Text Text)
$sel:targets:CreateExperimentTemplate' :: CreateExperimentTemplate
-> Maybe (HashMap Text CreateExperimentTemplateTargetInput)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"targets" Text -> HashMap Text CreateExperimentTemplateTargetInput -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text CreateExperimentTemplateTargetInput -> Pair)
-> Maybe (HashMap Text CreateExperimentTemplateTargetInput)
-> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text CreateExperimentTemplateTargetInput)
targets,
            (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
"clientToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clientToken),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
description),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"stopConditions" Text -> [CreateExperimentTemplateStopConditionInput] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [CreateExperimentTemplateStopConditionInput]
stopConditions),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"actions" Text -> HashMap Text CreateExperimentTemplateActionInput -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text CreateExperimentTemplateActionInput
actions),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"roleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArn)
          ]
      )

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

instance Core.ToQuery CreateExperimentTemplate where
  toQuery :: CreateExperimentTemplate -> QueryString
toQuery = QueryString -> CreateExperimentTemplate -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(CreateExperimentTemplateResponse
 -> CreateExperimentTemplateResponse -> Bool)
-> (CreateExperimentTemplateResponse
    -> CreateExperimentTemplateResponse -> Bool)
-> Eq CreateExperimentTemplateResponse
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]
(Int -> ReadS CreateExperimentTemplateResponse)
-> ReadS [CreateExperimentTemplateResponse]
-> ReadPrec CreateExperimentTemplateResponse
-> ReadPrec [CreateExperimentTemplateResponse]
-> Read 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
(Int -> CreateExperimentTemplateResponse -> ShowS)
-> (CreateExperimentTemplateResponse -> String)
-> ([CreateExperimentTemplateResponse] -> ShowS)
-> Show CreateExperimentTemplateResponse
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.
 CreateExperimentTemplateResponse
 -> Rep CreateExperimentTemplateResponse x)
-> (forall x.
    Rep CreateExperimentTemplateResponse x
    -> CreateExperimentTemplateResponse)
-> Generic CreateExperimentTemplateResponse
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' :: Maybe ExperimentTemplate -> Int -> CreateExperimentTemplateResponse
CreateExperimentTemplateResponse'
    { $sel:experimentTemplate:CreateExperimentTemplateResponse' :: Maybe ExperimentTemplate
experimentTemplate =
        Maybe 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 :: (Maybe ExperimentTemplate -> f (Maybe ExperimentTemplate))
-> CreateExperimentTemplateResponse
-> f CreateExperimentTemplateResponse
createExperimentTemplateResponse_experimentTemplate = (CreateExperimentTemplateResponse -> Maybe ExperimentTemplate)
-> (CreateExperimentTemplateResponse
    -> Maybe ExperimentTemplate -> CreateExperimentTemplateResponse)
-> Lens
     CreateExperimentTemplateResponse
     CreateExperimentTemplateResponse
     (Maybe ExperimentTemplate)
     (Maybe 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 :: (Int -> f Int)
-> CreateExperimentTemplateResponse
-> f CreateExperimentTemplateResponse
createExperimentTemplateResponse_httpStatus = (CreateExperimentTemplateResponse -> Int)
-> (CreateExperimentTemplateResponse
    -> Int -> CreateExperimentTemplateResponse)
-> Lens
     CreateExperimentTemplateResponse
     CreateExperimentTemplateResponse
     Int
     Int
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