{-# 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.StepFunctions.CreateStateMachine
-- 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 a state machine. A state machine consists of a collection of
-- states that can do work (@Task@ states), determine to which states to
-- transition next (@Choice@ states), stop an execution with an error
-- (@Fail@ states), and so on. State machines are specified using a
-- JSON-based, structured language. For more information, see
-- <https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html Amazon States Language>
-- in the AWS Step Functions User Guide.
--
-- This operation is eventually consistent. The results are best effort and
-- may not reflect very recent updates and changes.
--
-- @CreateStateMachine@ is an idempotent API. Subsequent requests won’t
-- create a duplicate resource if it was already created.
-- @CreateStateMachine@\'s idempotency check is based on the state machine
-- @name@, @definition@, @type@, @LoggingConfiguration@ and
-- @TracingConfiguration@. If a following request has a different @roleArn@
-- or @tags@, Step Functions will ignore these differences and treat it as
-- an idempotent request of the previous. In this case, @roleArn@ and
-- @tags@ will not be updated, even if they are different.
module Amazonka.StepFunctions.CreateStateMachine
  ( -- * Creating a Request
    CreateStateMachine (..),
    newCreateStateMachine,

    -- * Request Lenses
    createStateMachine_tracingConfiguration,
    createStateMachine_type,
    createStateMachine_loggingConfiguration,
    createStateMachine_tags,
    createStateMachine_name,
    createStateMachine_definition,
    createStateMachine_roleArn,

    -- * Destructuring the Response
    CreateStateMachineResponse (..),
    newCreateStateMachineResponse,

    -- * Response Lenses
    createStateMachineResponse_httpStatus,
    createStateMachineResponse_stateMachineArn,
    createStateMachineResponse_creationDate,
  )
where

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
import Amazonka.StepFunctions.Types

-- | /See:/ 'newCreateStateMachine' smart constructor.
data CreateStateMachine = CreateStateMachine'
  { -- | Selects whether AWS X-Ray tracing is enabled.
    CreateStateMachine -> Maybe TracingConfiguration
tracingConfiguration :: Prelude.Maybe TracingConfiguration,
    -- | Determines whether a Standard or Express state machine is created. The
    -- default is @STANDARD@. You cannot update the @type@ of a state machine
    -- once it has been created.
    CreateStateMachine -> Maybe StateMachineType
type' :: Prelude.Maybe StateMachineType,
    -- | Defines what execution history events are logged and where they are
    -- logged.
    --
    -- By default, the @level@ is set to @OFF@. For more information see
    -- <https://docs.aws.amazon.com/step-functions/latest/dg/cloudwatch-log-level.html Log Levels>
    -- in the AWS Step Functions User Guide.
    CreateStateMachine -> Maybe LoggingConfiguration
loggingConfiguration :: Prelude.Maybe LoggingConfiguration,
    -- | Tags to be added when creating a state machine.
    --
    -- An array of key-value pairs. For more information, see
    -- <https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html Using Cost Allocation Tags>
    -- in the /AWS Billing and Cost Management User Guide/, and
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_iam-tags.html Controlling Access Using IAM Tags>.
    --
    -- Tags may only contain Unicode letters, digits, white space, or these
    -- symbols: @_ . : \/ = + - \@@.
    CreateStateMachine -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name of the state machine.
    --
    -- A name must /not/ contain:
    --
    -- -   white space
    --
    -- -   brackets @\< > { } [ ]@
    --
    -- -   wildcard characters @? *@
    --
    -- -   special characters @\" # % \\ ^ | ~ \` $ & , ; : \/@
    --
    -- -   control characters (@U+0000-001F@, @U+007F-009F@)
    --
    -- To enable logging with CloudWatch Logs, the name should only contain
    -- 0-9, A-Z, a-z, - and _.
    CreateStateMachine -> Text
name :: Prelude.Text,
    -- | The Amazon States Language definition of the state machine. See
    -- <https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html Amazon States Language>.
    CreateStateMachine -> Sensitive Text
definition :: Core.Sensitive Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the IAM role to use for this state
    -- machine.
    CreateStateMachine -> Text
roleArn :: Prelude.Text
  }
  deriving (CreateStateMachine -> CreateStateMachine -> Bool
(CreateStateMachine -> CreateStateMachine -> Bool)
-> (CreateStateMachine -> CreateStateMachine -> Bool)
-> Eq CreateStateMachine
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateStateMachine -> CreateStateMachine -> Bool
$c/= :: CreateStateMachine -> CreateStateMachine -> Bool
== :: CreateStateMachine -> CreateStateMachine -> Bool
$c== :: CreateStateMachine -> CreateStateMachine -> Bool
Prelude.Eq, Int -> CreateStateMachine -> ShowS
[CreateStateMachine] -> ShowS
CreateStateMachine -> String
(Int -> CreateStateMachine -> ShowS)
-> (CreateStateMachine -> String)
-> ([CreateStateMachine] -> ShowS)
-> Show CreateStateMachine
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateStateMachine] -> ShowS
$cshowList :: [CreateStateMachine] -> ShowS
show :: CreateStateMachine -> String
$cshow :: CreateStateMachine -> String
showsPrec :: Int -> CreateStateMachine -> ShowS
$cshowsPrec :: Int -> CreateStateMachine -> ShowS
Prelude.Show, (forall x. CreateStateMachine -> Rep CreateStateMachine x)
-> (forall x. Rep CreateStateMachine x -> CreateStateMachine)
-> Generic CreateStateMachine
forall x. Rep CreateStateMachine x -> CreateStateMachine
forall x. CreateStateMachine -> Rep CreateStateMachine x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateStateMachine x -> CreateStateMachine
$cfrom :: forall x. CreateStateMachine -> Rep CreateStateMachine x
Prelude.Generic)

-- |
-- Create a value of 'CreateStateMachine' 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:
--
-- 'tracingConfiguration', 'createStateMachine_tracingConfiguration' - Selects whether AWS X-Ray tracing is enabled.
--
-- 'type'', 'createStateMachine_type' - Determines whether a Standard or Express state machine is created. The
-- default is @STANDARD@. You cannot update the @type@ of a state machine
-- once it has been created.
--
-- 'loggingConfiguration', 'createStateMachine_loggingConfiguration' - Defines what execution history events are logged and where they are
-- logged.
--
-- By default, the @level@ is set to @OFF@. For more information see
-- <https://docs.aws.amazon.com/step-functions/latest/dg/cloudwatch-log-level.html Log Levels>
-- in the AWS Step Functions User Guide.
--
-- 'tags', 'createStateMachine_tags' - Tags to be added when creating a state machine.
--
-- An array of key-value pairs. For more information, see
-- <https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html Using Cost Allocation Tags>
-- in the /AWS Billing and Cost Management User Guide/, and
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_iam-tags.html Controlling Access Using IAM Tags>.
--
-- Tags may only contain Unicode letters, digits, white space, or these
-- symbols: @_ . : \/ = + - \@@.
--
-- 'name', 'createStateMachine_name' - The name of the state machine.
--
-- A name must /not/ contain:
--
-- -   white space
--
-- -   brackets @\< > { } [ ]@
--
-- -   wildcard characters @? *@
--
-- -   special characters @\" # % \\ ^ | ~ \` $ & , ; : \/@
--
-- -   control characters (@U+0000-001F@, @U+007F-009F@)
--
-- To enable logging with CloudWatch Logs, the name should only contain
-- 0-9, A-Z, a-z, - and _.
--
-- 'definition', 'createStateMachine_definition' - The Amazon States Language definition of the state machine. See
-- <https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html Amazon States Language>.
--
-- 'roleArn', 'createStateMachine_roleArn' - The Amazon Resource Name (ARN) of the IAM role to use for this state
-- machine.
newCreateStateMachine ::
  -- | 'name'
  Prelude.Text ->
  -- | 'definition'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  CreateStateMachine
newCreateStateMachine :: Text -> Text -> Text -> CreateStateMachine
newCreateStateMachine Text
pName_ Text
pDefinition_ Text
pRoleArn_ =
  CreateStateMachine' :: Maybe TracingConfiguration
-> Maybe StateMachineType
-> Maybe LoggingConfiguration
-> Maybe [Tag]
-> Text
-> Sensitive Text
-> Text
-> CreateStateMachine
CreateStateMachine'
    { $sel:tracingConfiguration:CreateStateMachine' :: Maybe TracingConfiguration
tracingConfiguration =
        Maybe TracingConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:type':CreateStateMachine' :: Maybe StateMachineType
type' = Maybe StateMachineType
forall a. Maybe a
Prelude.Nothing,
      $sel:loggingConfiguration:CreateStateMachine' :: Maybe LoggingConfiguration
loggingConfiguration = Maybe LoggingConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateStateMachine' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateStateMachine' :: Text
name = Text
pName_,
      $sel:definition:CreateStateMachine' :: Sensitive Text
definition = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pDefinition_,
      $sel:roleArn:CreateStateMachine' :: Text
roleArn = Text
pRoleArn_
    }

-- | Selects whether AWS X-Ray tracing is enabled.
createStateMachine_tracingConfiguration :: Lens.Lens' CreateStateMachine (Prelude.Maybe TracingConfiguration)
createStateMachine_tracingConfiguration :: (Maybe TracingConfiguration -> f (Maybe TracingConfiguration))
-> CreateStateMachine -> f CreateStateMachine
createStateMachine_tracingConfiguration = (CreateStateMachine -> Maybe TracingConfiguration)
-> (CreateStateMachine
    -> Maybe TracingConfiguration -> CreateStateMachine)
-> Lens
     CreateStateMachine
     CreateStateMachine
     (Maybe TracingConfiguration)
     (Maybe TracingConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStateMachine' {Maybe TracingConfiguration
tracingConfiguration :: Maybe TracingConfiguration
$sel:tracingConfiguration:CreateStateMachine' :: CreateStateMachine -> Maybe TracingConfiguration
tracingConfiguration} -> Maybe TracingConfiguration
tracingConfiguration) (\s :: CreateStateMachine
s@CreateStateMachine' {} Maybe TracingConfiguration
a -> CreateStateMachine
s {$sel:tracingConfiguration:CreateStateMachine' :: Maybe TracingConfiguration
tracingConfiguration = Maybe TracingConfiguration
a} :: CreateStateMachine)

-- | Determines whether a Standard or Express state machine is created. The
-- default is @STANDARD@. You cannot update the @type@ of a state machine
-- once it has been created.
createStateMachine_type :: Lens.Lens' CreateStateMachine (Prelude.Maybe StateMachineType)
createStateMachine_type :: (Maybe StateMachineType -> f (Maybe StateMachineType))
-> CreateStateMachine -> f CreateStateMachine
createStateMachine_type = (CreateStateMachine -> Maybe StateMachineType)
-> (CreateStateMachine
    -> Maybe StateMachineType -> CreateStateMachine)
-> Lens
     CreateStateMachine
     CreateStateMachine
     (Maybe StateMachineType)
     (Maybe StateMachineType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStateMachine' {Maybe StateMachineType
type' :: Maybe StateMachineType
$sel:type':CreateStateMachine' :: CreateStateMachine -> Maybe StateMachineType
type'} -> Maybe StateMachineType
type') (\s :: CreateStateMachine
s@CreateStateMachine' {} Maybe StateMachineType
a -> CreateStateMachine
s {$sel:type':CreateStateMachine' :: Maybe StateMachineType
type' = Maybe StateMachineType
a} :: CreateStateMachine)

-- | Defines what execution history events are logged and where they are
-- logged.
--
-- By default, the @level@ is set to @OFF@. For more information see
-- <https://docs.aws.amazon.com/step-functions/latest/dg/cloudwatch-log-level.html Log Levels>
-- in the AWS Step Functions User Guide.
createStateMachine_loggingConfiguration :: Lens.Lens' CreateStateMachine (Prelude.Maybe LoggingConfiguration)
createStateMachine_loggingConfiguration :: (Maybe LoggingConfiguration -> f (Maybe LoggingConfiguration))
-> CreateStateMachine -> f CreateStateMachine
createStateMachine_loggingConfiguration = (CreateStateMachine -> Maybe LoggingConfiguration)
-> (CreateStateMachine
    -> Maybe LoggingConfiguration -> CreateStateMachine)
-> Lens
     CreateStateMachine
     CreateStateMachine
     (Maybe LoggingConfiguration)
     (Maybe LoggingConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStateMachine' {Maybe LoggingConfiguration
loggingConfiguration :: Maybe LoggingConfiguration
$sel:loggingConfiguration:CreateStateMachine' :: CreateStateMachine -> Maybe LoggingConfiguration
loggingConfiguration} -> Maybe LoggingConfiguration
loggingConfiguration) (\s :: CreateStateMachine
s@CreateStateMachine' {} Maybe LoggingConfiguration
a -> CreateStateMachine
s {$sel:loggingConfiguration:CreateStateMachine' :: Maybe LoggingConfiguration
loggingConfiguration = Maybe LoggingConfiguration
a} :: CreateStateMachine)

-- | Tags to be added when creating a state machine.
--
-- An array of key-value pairs. For more information, see
-- <https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html Using Cost Allocation Tags>
-- in the /AWS Billing and Cost Management User Guide/, and
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_iam-tags.html Controlling Access Using IAM Tags>.
--
-- Tags may only contain Unicode letters, digits, white space, or these
-- symbols: @_ . : \/ = + - \@@.
createStateMachine_tags :: Lens.Lens' CreateStateMachine (Prelude.Maybe [Tag])
createStateMachine_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateStateMachine -> f CreateStateMachine
createStateMachine_tags = (CreateStateMachine -> Maybe [Tag])
-> (CreateStateMachine -> Maybe [Tag] -> CreateStateMachine)
-> Lens
     CreateStateMachine CreateStateMachine (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStateMachine' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateStateMachine' :: CreateStateMachine -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateStateMachine
s@CreateStateMachine' {} Maybe [Tag]
a -> CreateStateMachine
s {$sel:tags:CreateStateMachine' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateStateMachine) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateStateMachine -> f CreateStateMachine)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateStateMachine
-> f CreateStateMachine
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the state machine.
--
-- A name must /not/ contain:
--
-- -   white space
--
-- -   brackets @\< > { } [ ]@
--
-- -   wildcard characters @? *@
--
-- -   special characters @\" # % \\ ^ | ~ \` $ & , ; : \/@
--
-- -   control characters (@U+0000-001F@, @U+007F-009F@)
--
-- To enable logging with CloudWatch Logs, the name should only contain
-- 0-9, A-Z, a-z, - and _.
createStateMachine_name :: Lens.Lens' CreateStateMachine Prelude.Text
createStateMachine_name :: (Text -> f Text) -> CreateStateMachine -> f CreateStateMachine
createStateMachine_name = (CreateStateMachine -> Text)
-> (CreateStateMachine -> Text -> CreateStateMachine)
-> Lens CreateStateMachine CreateStateMachine Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStateMachine' {Text
name :: Text
$sel:name:CreateStateMachine' :: CreateStateMachine -> Text
name} -> Text
name) (\s :: CreateStateMachine
s@CreateStateMachine' {} Text
a -> CreateStateMachine
s {$sel:name:CreateStateMachine' :: Text
name = Text
a} :: CreateStateMachine)

-- | The Amazon States Language definition of the state machine. See
-- <https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html Amazon States Language>.
createStateMachine_definition :: Lens.Lens' CreateStateMachine Prelude.Text
createStateMachine_definition :: (Text -> f Text) -> CreateStateMachine -> f CreateStateMachine
createStateMachine_definition = (CreateStateMachine -> Sensitive Text)
-> (CreateStateMachine -> Sensitive Text -> CreateStateMachine)
-> Lens
     CreateStateMachine
     CreateStateMachine
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStateMachine' {Sensitive Text
definition :: Sensitive Text
$sel:definition:CreateStateMachine' :: CreateStateMachine -> Sensitive Text
definition} -> Sensitive Text
definition) (\s :: CreateStateMachine
s@CreateStateMachine' {} Sensitive Text
a -> CreateStateMachine
s {$sel:definition:CreateStateMachine' :: Sensitive Text
definition = Sensitive Text
a} :: CreateStateMachine) ((Sensitive Text -> f (Sensitive Text))
 -> CreateStateMachine -> f CreateStateMachine)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> CreateStateMachine
-> f CreateStateMachine
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The Amazon Resource Name (ARN) of the IAM role to use for this state
-- machine.
createStateMachine_roleArn :: Lens.Lens' CreateStateMachine Prelude.Text
createStateMachine_roleArn :: (Text -> f Text) -> CreateStateMachine -> f CreateStateMachine
createStateMachine_roleArn = (CreateStateMachine -> Text)
-> (CreateStateMachine -> Text -> CreateStateMachine)
-> Lens CreateStateMachine CreateStateMachine Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStateMachine' {Text
roleArn :: Text
$sel:roleArn:CreateStateMachine' :: CreateStateMachine -> Text
roleArn} -> Text
roleArn) (\s :: CreateStateMachine
s@CreateStateMachine' {} Text
a -> CreateStateMachine
s {$sel:roleArn:CreateStateMachine' :: Text
roleArn = Text
a} :: CreateStateMachine)

instance Core.AWSRequest CreateStateMachine where
  type
    AWSResponse CreateStateMachine =
      CreateStateMachineResponse
  request :: CreateStateMachine -> Request CreateStateMachine
request = Service -> CreateStateMachine -> Request CreateStateMachine
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateStateMachine
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateStateMachine)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateStateMachine))
-> Logger
-> Service
-> Proxy CreateStateMachine
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateStateMachine)))
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 -> Text -> POSIX -> CreateStateMachineResponse
CreateStateMachineResponse'
            (Int -> Text -> POSIX -> CreateStateMachineResponse)
-> Either String Int
-> Either String (Text -> POSIX -> CreateStateMachineResponse)
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 (Text -> POSIX -> CreateStateMachineResponse)
-> Either String Text
-> Either String (POSIX -> CreateStateMachineResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"stateMachineArn")
            Either String (POSIX -> CreateStateMachineResponse)
-> Either String POSIX -> Either String CreateStateMachineResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String POSIX
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"creationDate")
      )

instance Prelude.Hashable CreateStateMachine

instance Prelude.NFData CreateStateMachine

instance Core.ToHeaders CreateStateMachine where
  toHeaders :: CreateStateMachine -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateStateMachine -> 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
"AWSStepFunctions.CreateStateMachine" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CreateStateMachine where
  toJSON :: CreateStateMachine -> Value
toJSON CreateStateMachine' {Maybe [Tag]
Maybe LoggingConfiguration
Maybe StateMachineType
Maybe TracingConfiguration
Text
Sensitive Text
roleArn :: Text
definition :: Sensitive Text
name :: Text
tags :: Maybe [Tag]
loggingConfiguration :: Maybe LoggingConfiguration
type' :: Maybe StateMachineType
tracingConfiguration :: Maybe TracingConfiguration
$sel:roleArn:CreateStateMachine' :: CreateStateMachine -> Text
$sel:definition:CreateStateMachine' :: CreateStateMachine -> Sensitive Text
$sel:name:CreateStateMachine' :: CreateStateMachine -> Text
$sel:tags:CreateStateMachine' :: CreateStateMachine -> Maybe [Tag]
$sel:loggingConfiguration:CreateStateMachine' :: CreateStateMachine -> Maybe LoggingConfiguration
$sel:type':CreateStateMachine' :: CreateStateMachine -> Maybe StateMachineType
$sel:tracingConfiguration:CreateStateMachine' :: CreateStateMachine -> Maybe TracingConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"tracingConfiguration" Text -> TracingConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (TracingConfiguration -> Pair)
-> Maybe TracingConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TracingConfiguration
tracingConfiguration,
            (Text
"type" Text -> StateMachineType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (StateMachineType -> Pair) -> Maybe StateMachineType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StateMachineType
type',
            (Text
"loggingConfiguration" Text -> LoggingConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (LoggingConfiguration -> Pair)
-> Maybe LoggingConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LoggingConfiguration
loggingConfiguration,
            (Text
"tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"definition" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
definition),
            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 CreateStateMachine where
  toPath :: CreateStateMachine -> ByteString
toPath = ByteString -> CreateStateMachine -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newCreateStateMachineResponse' smart constructor.
data CreateStateMachineResponse = CreateStateMachineResponse'
  { -- | The response's http status code.
    CreateStateMachineResponse -> Int
httpStatus :: Prelude.Int,
    -- | The Amazon Resource Name (ARN) that identifies the created state
    -- machine.
    CreateStateMachineResponse -> Text
stateMachineArn :: Prelude.Text,
    -- | The date the state machine is created.
    CreateStateMachineResponse -> POSIX
creationDate :: Core.POSIX
  }
  deriving (CreateStateMachineResponse -> CreateStateMachineResponse -> Bool
(CreateStateMachineResponse -> CreateStateMachineResponse -> Bool)
-> (CreateStateMachineResponse
    -> CreateStateMachineResponse -> Bool)
-> Eq CreateStateMachineResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateStateMachineResponse -> CreateStateMachineResponse -> Bool
$c/= :: CreateStateMachineResponse -> CreateStateMachineResponse -> Bool
== :: CreateStateMachineResponse -> CreateStateMachineResponse -> Bool
$c== :: CreateStateMachineResponse -> CreateStateMachineResponse -> Bool
Prelude.Eq, ReadPrec [CreateStateMachineResponse]
ReadPrec CreateStateMachineResponse
Int -> ReadS CreateStateMachineResponse
ReadS [CreateStateMachineResponse]
(Int -> ReadS CreateStateMachineResponse)
-> ReadS [CreateStateMachineResponse]
-> ReadPrec CreateStateMachineResponse
-> ReadPrec [CreateStateMachineResponse]
-> Read CreateStateMachineResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateStateMachineResponse]
$creadListPrec :: ReadPrec [CreateStateMachineResponse]
readPrec :: ReadPrec CreateStateMachineResponse
$creadPrec :: ReadPrec CreateStateMachineResponse
readList :: ReadS [CreateStateMachineResponse]
$creadList :: ReadS [CreateStateMachineResponse]
readsPrec :: Int -> ReadS CreateStateMachineResponse
$creadsPrec :: Int -> ReadS CreateStateMachineResponse
Prelude.Read, Int -> CreateStateMachineResponse -> ShowS
[CreateStateMachineResponse] -> ShowS
CreateStateMachineResponse -> String
(Int -> CreateStateMachineResponse -> ShowS)
-> (CreateStateMachineResponse -> String)
-> ([CreateStateMachineResponse] -> ShowS)
-> Show CreateStateMachineResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateStateMachineResponse] -> ShowS
$cshowList :: [CreateStateMachineResponse] -> ShowS
show :: CreateStateMachineResponse -> String
$cshow :: CreateStateMachineResponse -> String
showsPrec :: Int -> CreateStateMachineResponse -> ShowS
$cshowsPrec :: Int -> CreateStateMachineResponse -> ShowS
Prelude.Show, (forall x.
 CreateStateMachineResponse -> Rep CreateStateMachineResponse x)
-> (forall x.
    Rep CreateStateMachineResponse x -> CreateStateMachineResponse)
-> Generic CreateStateMachineResponse
forall x.
Rep CreateStateMachineResponse x -> CreateStateMachineResponse
forall x.
CreateStateMachineResponse -> Rep CreateStateMachineResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateStateMachineResponse x -> CreateStateMachineResponse
$cfrom :: forall x.
CreateStateMachineResponse -> Rep CreateStateMachineResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateStateMachineResponse' 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:
--
-- 'httpStatus', 'createStateMachineResponse_httpStatus' - The response's http status code.
--
-- 'stateMachineArn', 'createStateMachineResponse_stateMachineArn' - The Amazon Resource Name (ARN) that identifies the created state
-- machine.
--
-- 'creationDate', 'createStateMachineResponse_creationDate' - The date the state machine is created.
newCreateStateMachineResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'stateMachineArn'
  Prelude.Text ->
  -- | 'creationDate'
  Prelude.UTCTime ->
  CreateStateMachineResponse
newCreateStateMachineResponse :: Int -> Text -> UTCTime -> CreateStateMachineResponse
newCreateStateMachineResponse
  Int
pHttpStatus_
  Text
pStateMachineArn_
  UTCTime
pCreationDate_ =
    CreateStateMachineResponse' :: Int -> Text -> POSIX -> CreateStateMachineResponse
CreateStateMachineResponse'
      { $sel:httpStatus:CreateStateMachineResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:stateMachineArn:CreateStateMachineResponse' :: Text
stateMachineArn = Text
pStateMachineArn_,
        $sel:creationDate:CreateStateMachineResponse' :: POSIX
creationDate = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreationDate_
      }

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

-- | The Amazon Resource Name (ARN) that identifies the created state
-- machine.
createStateMachineResponse_stateMachineArn :: Lens.Lens' CreateStateMachineResponse Prelude.Text
createStateMachineResponse_stateMachineArn :: (Text -> f Text)
-> CreateStateMachineResponse -> f CreateStateMachineResponse
createStateMachineResponse_stateMachineArn = (CreateStateMachineResponse -> Text)
-> (CreateStateMachineResponse
    -> Text -> CreateStateMachineResponse)
-> Lens
     CreateStateMachineResponse CreateStateMachineResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStateMachineResponse' {Text
stateMachineArn :: Text
$sel:stateMachineArn:CreateStateMachineResponse' :: CreateStateMachineResponse -> Text
stateMachineArn} -> Text
stateMachineArn) (\s :: CreateStateMachineResponse
s@CreateStateMachineResponse' {} Text
a -> CreateStateMachineResponse
s {$sel:stateMachineArn:CreateStateMachineResponse' :: Text
stateMachineArn = Text
a} :: CreateStateMachineResponse)

-- | The date the state machine is created.
createStateMachineResponse_creationDate :: Lens.Lens' CreateStateMachineResponse Prelude.UTCTime
createStateMachineResponse_creationDate :: (UTCTime -> f UTCTime)
-> CreateStateMachineResponse -> f CreateStateMachineResponse
createStateMachineResponse_creationDate = (CreateStateMachineResponse -> POSIX)
-> (CreateStateMachineResponse
    -> POSIX -> CreateStateMachineResponse)
-> Lens
     CreateStateMachineResponse CreateStateMachineResponse POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStateMachineResponse' {POSIX
creationDate :: POSIX
$sel:creationDate:CreateStateMachineResponse' :: CreateStateMachineResponse -> POSIX
creationDate} -> POSIX
creationDate) (\s :: CreateStateMachineResponse
s@CreateStateMachineResponse' {} POSIX
a -> CreateStateMachineResponse
s {$sel:creationDate:CreateStateMachineResponse' :: POSIX
creationDate = POSIX
a} :: CreateStateMachineResponse) ((POSIX -> f POSIX)
 -> CreateStateMachineResponse -> f CreateStateMachineResponse)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> CreateStateMachineResponse
-> f CreateStateMachineResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Prelude.NFData CreateStateMachineResponse