{-# 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.Glue.CreateTrigger
-- 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 new trigger.
module Amazonka.Glue.CreateTrigger
  ( -- * Creating a Request
    CreateTrigger (..),
    newCreateTrigger,

    -- * Request Lenses
    createTrigger_workflowName,
    createTrigger_schedule,
    createTrigger_predicate,
    createTrigger_startOnCreation,
    createTrigger_eventBatchingCondition,
    createTrigger_description,
    createTrigger_tags,
    createTrigger_name,
    createTrigger_type,
    createTrigger_actions,

    -- * Destructuring the Response
    CreateTriggerResponse (..),
    newCreateTriggerResponse,

    -- * Response Lenses
    createTriggerResponse_name,
    createTriggerResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Glue.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:/ 'newCreateTrigger' smart constructor.
data CreateTrigger = CreateTrigger'
  { -- | The name of the workflow associated with the trigger.
    CreateTrigger -> Maybe Text
workflowName :: Prelude.Maybe Prelude.Text,
    -- | A @cron@ expression used to specify the schedule (see
    -- <https://docs.aws.amazon.com/glue/latest/dg/monitor-data-warehouse-schedule.html Time-Based Schedules for Jobs and Crawlers>.
    -- For example, to run something every day at 12:15 UTC, you would specify:
    -- @cron(15 12 * * ? *)@.
    --
    -- This field is required when the trigger type is SCHEDULED.
    CreateTrigger -> Maybe Text
schedule :: Prelude.Maybe Prelude.Text,
    -- | A predicate to specify when the new trigger should fire.
    --
    -- This field is required when the trigger type is @CONDITIONAL@.
    CreateTrigger -> Maybe Predicate
predicate :: Prelude.Maybe Predicate,
    -- | Set to @true@ to start @SCHEDULED@ and @CONDITIONAL@ triggers when
    -- created. True is not supported for @ON_DEMAND@ triggers.
    CreateTrigger -> Maybe Bool
startOnCreation :: Prelude.Maybe Prelude.Bool,
    -- | Batch condition that must be met (specified number of events received or
    -- batch time window expired) before EventBridge event trigger fires.
    CreateTrigger -> Maybe EventBatchingCondition
eventBatchingCondition :: Prelude.Maybe EventBatchingCondition,
    -- | A description of the new trigger.
    CreateTrigger -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The tags to use with this trigger. You may use tags to limit access to
    -- the trigger. For more information about tags in Glue, see
    -- <https://docs.aws.amazon.com/glue/latest/dg/monitor-tags.html Amazon Web Services Tags in Glue>
    -- in the developer guide.
    CreateTrigger -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of the trigger.
    CreateTrigger -> Text
name :: Prelude.Text,
    -- | The type of the new trigger.
    CreateTrigger -> TriggerType
type' :: TriggerType,
    -- | The actions initiated by this trigger when it fires.
    CreateTrigger -> [Action]
actions :: [Action]
  }
  deriving (CreateTrigger -> CreateTrigger -> Bool
(CreateTrigger -> CreateTrigger -> Bool)
-> (CreateTrigger -> CreateTrigger -> Bool) -> Eq CreateTrigger
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTrigger -> CreateTrigger -> Bool
$c/= :: CreateTrigger -> CreateTrigger -> Bool
== :: CreateTrigger -> CreateTrigger -> Bool
$c== :: CreateTrigger -> CreateTrigger -> Bool
Prelude.Eq, ReadPrec [CreateTrigger]
ReadPrec CreateTrigger
Int -> ReadS CreateTrigger
ReadS [CreateTrigger]
(Int -> ReadS CreateTrigger)
-> ReadS [CreateTrigger]
-> ReadPrec CreateTrigger
-> ReadPrec [CreateTrigger]
-> Read CreateTrigger
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTrigger]
$creadListPrec :: ReadPrec [CreateTrigger]
readPrec :: ReadPrec CreateTrigger
$creadPrec :: ReadPrec CreateTrigger
readList :: ReadS [CreateTrigger]
$creadList :: ReadS [CreateTrigger]
readsPrec :: Int -> ReadS CreateTrigger
$creadsPrec :: Int -> ReadS CreateTrigger
Prelude.Read, Int -> CreateTrigger -> ShowS
[CreateTrigger] -> ShowS
CreateTrigger -> String
(Int -> CreateTrigger -> ShowS)
-> (CreateTrigger -> String)
-> ([CreateTrigger] -> ShowS)
-> Show CreateTrigger
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTrigger] -> ShowS
$cshowList :: [CreateTrigger] -> ShowS
show :: CreateTrigger -> String
$cshow :: CreateTrigger -> String
showsPrec :: Int -> CreateTrigger -> ShowS
$cshowsPrec :: Int -> CreateTrigger -> ShowS
Prelude.Show, (forall x. CreateTrigger -> Rep CreateTrigger x)
-> (forall x. Rep CreateTrigger x -> CreateTrigger)
-> Generic CreateTrigger
forall x. Rep CreateTrigger x -> CreateTrigger
forall x. CreateTrigger -> Rep CreateTrigger x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTrigger x -> CreateTrigger
$cfrom :: forall x. CreateTrigger -> Rep CreateTrigger x
Prelude.Generic)

-- |
-- Create a value of 'CreateTrigger' 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:
--
-- 'workflowName', 'createTrigger_workflowName' - The name of the workflow associated with the trigger.
--
-- 'schedule', 'createTrigger_schedule' - A @cron@ expression used to specify the schedule (see
-- <https://docs.aws.amazon.com/glue/latest/dg/monitor-data-warehouse-schedule.html Time-Based Schedules for Jobs and Crawlers>.
-- For example, to run something every day at 12:15 UTC, you would specify:
-- @cron(15 12 * * ? *)@.
--
-- This field is required when the trigger type is SCHEDULED.
--
-- 'predicate', 'createTrigger_predicate' - A predicate to specify when the new trigger should fire.
--
-- This field is required when the trigger type is @CONDITIONAL@.
--
-- 'startOnCreation', 'createTrigger_startOnCreation' - Set to @true@ to start @SCHEDULED@ and @CONDITIONAL@ triggers when
-- created. True is not supported for @ON_DEMAND@ triggers.
--
-- 'eventBatchingCondition', 'createTrigger_eventBatchingCondition' - Batch condition that must be met (specified number of events received or
-- batch time window expired) before EventBridge event trigger fires.
--
-- 'description', 'createTrigger_description' - A description of the new trigger.
--
-- 'tags', 'createTrigger_tags' - The tags to use with this trigger. You may use tags to limit access to
-- the trigger. For more information about tags in Glue, see
-- <https://docs.aws.amazon.com/glue/latest/dg/monitor-tags.html Amazon Web Services Tags in Glue>
-- in the developer guide.
--
-- 'name', 'createTrigger_name' - The name of the trigger.
--
-- 'type'', 'createTrigger_type' - The type of the new trigger.
--
-- 'actions', 'createTrigger_actions' - The actions initiated by this trigger when it fires.
newCreateTrigger ::
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  TriggerType ->
  CreateTrigger
newCreateTrigger :: Text -> TriggerType -> CreateTrigger
newCreateTrigger Text
pName_ TriggerType
pType_ =
  CreateTrigger' :: Maybe Text
-> Maybe Text
-> Maybe Predicate
-> Maybe Bool
-> Maybe EventBatchingCondition
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> TriggerType
-> [Action]
-> CreateTrigger
CreateTrigger'
    { $sel:workflowName:CreateTrigger' :: Maybe Text
workflowName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:schedule:CreateTrigger' :: Maybe Text
schedule = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:predicate:CreateTrigger' :: Maybe Predicate
predicate = Maybe Predicate
forall a. Maybe a
Prelude.Nothing,
      $sel:startOnCreation:CreateTrigger' :: Maybe Bool
startOnCreation = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:eventBatchingCondition:CreateTrigger' :: Maybe EventBatchingCondition
eventBatchingCondition = Maybe EventBatchingCondition
forall a. Maybe a
Prelude.Nothing,
      $sel:description:CreateTrigger' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateTrigger' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateTrigger' :: Text
name = Text
pName_,
      $sel:type':CreateTrigger' :: TriggerType
type' = TriggerType
pType_,
      $sel:actions:CreateTrigger' :: [Action]
actions = [Action]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name of the workflow associated with the trigger.
createTrigger_workflowName :: Lens.Lens' CreateTrigger (Prelude.Maybe Prelude.Text)
createTrigger_workflowName :: (Maybe Text -> f (Maybe Text)) -> CreateTrigger -> f CreateTrigger
createTrigger_workflowName = (CreateTrigger -> Maybe Text)
-> (CreateTrigger -> Maybe Text -> CreateTrigger)
-> Lens CreateTrigger CreateTrigger (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrigger' {Maybe Text
workflowName :: Maybe Text
$sel:workflowName:CreateTrigger' :: CreateTrigger -> Maybe Text
workflowName} -> Maybe Text
workflowName) (\s :: CreateTrigger
s@CreateTrigger' {} Maybe Text
a -> CreateTrigger
s {$sel:workflowName:CreateTrigger' :: Maybe Text
workflowName = Maybe Text
a} :: CreateTrigger)

-- | A @cron@ expression used to specify the schedule (see
-- <https://docs.aws.amazon.com/glue/latest/dg/monitor-data-warehouse-schedule.html Time-Based Schedules for Jobs and Crawlers>.
-- For example, to run something every day at 12:15 UTC, you would specify:
-- @cron(15 12 * * ? *)@.
--
-- This field is required when the trigger type is SCHEDULED.
createTrigger_schedule :: Lens.Lens' CreateTrigger (Prelude.Maybe Prelude.Text)
createTrigger_schedule :: (Maybe Text -> f (Maybe Text)) -> CreateTrigger -> f CreateTrigger
createTrigger_schedule = (CreateTrigger -> Maybe Text)
-> (CreateTrigger -> Maybe Text -> CreateTrigger)
-> Lens CreateTrigger CreateTrigger (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrigger' {Maybe Text
schedule :: Maybe Text
$sel:schedule:CreateTrigger' :: CreateTrigger -> Maybe Text
schedule} -> Maybe Text
schedule) (\s :: CreateTrigger
s@CreateTrigger' {} Maybe Text
a -> CreateTrigger
s {$sel:schedule:CreateTrigger' :: Maybe Text
schedule = Maybe Text
a} :: CreateTrigger)

-- | A predicate to specify when the new trigger should fire.
--
-- This field is required when the trigger type is @CONDITIONAL@.
createTrigger_predicate :: Lens.Lens' CreateTrigger (Prelude.Maybe Predicate)
createTrigger_predicate :: (Maybe Predicate -> f (Maybe Predicate))
-> CreateTrigger -> f CreateTrigger
createTrigger_predicate = (CreateTrigger -> Maybe Predicate)
-> (CreateTrigger -> Maybe Predicate -> CreateTrigger)
-> Lens
     CreateTrigger CreateTrigger (Maybe Predicate) (Maybe Predicate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrigger' {Maybe Predicate
predicate :: Maybe Predicate
$sel:predicate:CreateTrigger' :: CreateTrigger -> Maybe Predicate
predicate} -> Maybe Predicate
predicate) (\s :: CreateTrigger
s@CreateTrigger' {} Maybe Predicate
a -> CreateTrigger
s {$sel:predicate:CreateTrigger' :: Maybe Predicate
predicate = Maybe Predicate
a} :: CreateTrigger)

-- | Set to @true@ to start @SCHEDULED@ and @CONDITIONAL@ triggers when
-- created. True is not supported for @ON_DEMAND@ triggers.
createTrigger_startOnCreation :: Lens.Lens' CreateTrigger (Prelude.Maybe Prelude.Bool)
createTrigger_startOnCreation :: (Maybe Bool -> f (Maybe Bool)) -> CreateTrigger -> f CreateTrigger
createTrigger_startOnCreation = (CreateTrigger -> Maybe Bool)
-> (CreateTrigger -> Maybe Bool -> CreateTrigger)
-> Lens CreateTrigger CreateTrigger (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrigger' {Maybe Bool
startOnCreation :: Maybe Bool
$sel:startOnCreation:CreateTrigger' :: CreateTrigger -> Maybe Bool
startOnCreation} -> Maybe Bool
startOnCreation) (\s :: CreateTrigger
s@CreateTrigger' {} Maybe Bool
a -> CreateTrigger
s {$sel:startOnCreation:CreateTrigger' :: Maybe Bool
startOnCreation = Maybe Bool
a} :: CreateTrigger)

-- | Batch condition that must be met (specified number of events received or
-- batch time window expired) before EventBridge event trigger fires.
createTrigger_eventBatchingCondition :: Lens.Lens' CreateTrigger (Prelude.Maybe EventBatchingCondition)
createTrigger_eventBatchingCondition :: (Maybe EventBatchingCondition -> f (Maybe EventBatchingCondition))
-> CreateTrigger -> f CreateTrigger
createTrigger_eventBatchingCondition = (CreateTrigger -> Maybe EventBatchingCondition)
-> (CreateTrigger -> Maybe EventBatchingCondition -> CreateTrigger)
-> Lens
     CreateTrigger
     CreateTrigger
     (Maybe EventBatchingCondition)
     (Maybe EventBatchingCondition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrigger' {Maybe EventBatchingCondition
eventBatchingCondition :: Maybe EventBatchingCondition
$sel:eventBatchingCondition:CreateTrigger' :: CreateTrigger -> Maybe EventBatchingCondition
eventBatchingCondition} -> Maybe EventBatchingCondition
eventBatchingCondition) (\s :: CreateTrigger
s@CreateTrigger' {} Maybe EventBatchingCondition
a -> CreateTrigger
s {$sel:eventBatchingCondition:CreateTrigger' :: Maybe EventBatchingCondition
eventBatchingCondition = Maybe EventBatchingCondition
a} :: CreateTrigger)

-- | A description of the new trigger.
createTrigger_description :: Lens.Lens' CreateTrigger (Prelude.Maybe Prelude.Text)
createTrigger_description :: (Maybe Text -> f (Maybe Text)) -> CreateTrigger -> f CreateTrigger
createTrigger_description = (CreateTrigger -> Maybe Text)
-> (CreateTrigger -> Maybe Text -> CreateTrigger)
-> Lens CreateTrigger CreateTrigger (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrigger' {Maybe Text
description :: Maybe Text
$sel:description:CreateTrigger' :: CreateTrigger -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateTrigger
s@CreateTrigger' {} Maybe Text
a -> CreateTrigger
s {$sel:description:CreateTrigger' :: Maybe Text
description = Maybe Text
a} :: CreateTrigger)

-- | The tags to use with this trigger. You may use tags to limit access to
-- the trigger. For more information about tags in Glue, see
-- <https://docs.aws.amazon.com/glue/latest/dg/monitor-tags.html Amazon Web Services Tags in Glue>
-- in the developer guide.
createTrigger_tags :: Lens.Lens' CreateTrigger (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createTrigger_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateTrigger -> f CreateTrigger
createTrigger_tags = (CreateTrigger -> Maybe (HashMap Text Text))
-> (CreateTrigger -> Maybe (HashMap Text Text) -> CreateTrigger)
-> Lens
     CreateTrigger
     CreateTrigger
     (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 (\CreateTrigger' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateTrigger' :: CreateTrigger -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateTrigger
s@CreateTrigger' {} Maybe (HashMap Text Text)
a -> CreateTrigger
s {$sel:tags:CreateTrigger' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateTrigger) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateTrigger -> f CreateTrigger)
-> ((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)))
-> CreateTrigger
-> f CreateTrigger
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

-- | The name of the trigger.
createTrigger_name :: Lens.Lens' CreateTrigger Prelude.Text
createTrigger_name :: (Text -> f Text) -> CreateTrigger -> f CreateTrigger
createTrigger_name = (CreateTrigger -> Text)
-> (CreateTrigger -> Text -> CreateTrigger)
-> Lens CreateTrigger CreateTrigger Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrigger' {Text
name :: Text
$sel:name:CreateTrigger' :: CreateTrigger -> Text
name} -> Text
name) (\s :: CreateTrigger
s@CreateTrigger' {} Text
a -> CreateTrigger
s {$sel:name:CreateTrigger' :: Text
name = Text
a} :: CreateTrigger)

-- | The type of the new trigger.
createTrigger_type :: Lens.Lens' CreateTrigger TriggerType
createTrigger_type :: (TriggerType -> f TriggerType) -> CreateTrigger -> f CreateTrigger
createTrigger_type = (CreateTrigger -> TriggerType)
-> (CreateTrigger -> TriggerType -> CreateTrigger)
-> Lens CreateTrigger CreateTrigger TriggerType TriggerType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrigger' {TriggerType
type' :: TriggerType
$sel:type':CreateTrigger' :: CreateTrigger -> TriggerType
type'} -> TriggerType
type') (\s :: CreateTrigger
s@CreateTrigger' {} TriggerType
a -> CreateTrigger
s {$sel:type':CreateTrigger' :: TriggerType
type' = TriggerType
a} :: CreateTrigger)

-- | The actions initiated by this trigger when it fires.
createTrigger_actions :: Lens.Lens' CreateTrigger [Action]
createTrigger_actions :: ([Action] -> f [Action]) -> CreateTrigger -> f CreateTrigger
createTrigger_actions = (CreateTrigger -> [Action])
-> (CreateTrigger -> [Action] -> CreateTrigger)
-> Lens CreateTrigger CreateTrigger [Action] [Action]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrigger' {[Action]
actions :: [Action]
$sel:actions:CreateTrigger' :: CreateTrigger -> [Action]
actions} -> [Action]
actions) (\s :: CreateTrigger
s@CreateTrigger' {} [Action]
a -> CreateTrigger
s {$sel:actions:CreateTrigger' :: [Action]
actions = [Action]
a} :: CreateTrigger) (([Action] -> f [Action]) -> CreateTrigger -> f CreateTrigger)
-> (([Action] -> f [Action]) -> [Action] -> f [Action])
-> ([Action] -> f [Action])
-> CreateTrigger
-> f CreateTrigger
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Action] -> f [Action]) -> [Action] -> f [Action]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreateTrigger where
  type
    AWSResponse CreateTrigger =
      CreateTriggerResponse
  request :: CreateTrigger -> Request CreateTrigger
request = Service -> CreateTrigger -> Request CreateTrigger
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateTrigger
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTrigger)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateTrigger))
-> Logger
-> Service
-> Proxy CreateTrigger
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTrigger)))
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 Text -> Int -> CreateTriggerResponse
CreateTriggerResponse'
            (Maybe Text -> Int -> CreateTriggerResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateTriggerResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Name")
            Either String (Int -> CreateTriggerResponse)
-> Either String Int -> Either String CreateTriggerResponse
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 CreateTrigger

instance Prelude.NFData CreateTrigger

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

instance Core.ToJSON CreateTrigger where
  toJSON :: CreateTrigger -> Value
toJSON CreateTrigger' {[Action]
Maybe Bool
Maybe Text
Maybe (HashMap Text Text)
Maybe EventBatchingCondition
Maybe Predicate
Text
TriggerType
actions :: [Action]
type' :: TriggerType
name :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
eventBatchingCondition :: Maybe EventBatchingCondition
startOnCreation :: Maybe Bool
predicate :: Maybe Predicate
schedule :: Maybe Text
workflowName :: Maybe Text
$sel:actions:CreateTrigger' :: CreateTrigger -> [Action]
$sel:type':CreateTrigger' :: CreateTrigger -> TriggerType
$sel:name:CreateTrigger' :: CreateTrigger -> Text
$sel:tags:CreateTrigger' :: CreateTrigger -> Maybe (HashMap Text Text)
$sel:description:CreateTrigger' :: CreateTrigger -> Maybe Text
$sel:eventBatchingCondition:CreateTrigger' :: CreateTrigger -> Maybe EventBatchingCondition
$sel:startOnCreation:CreateTrigger' :: CreateTrigger -> Maybe Bool
$sel:predicate:CreateTrigger' :: CreateTrigger -> Maybe Predicate
$sel:schedule:CreateTrigger' :: CreateTrigger -> Maybe Text
$sel:workflowName:CreateTrigger' :: CreateTrigger -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"WorkflowName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
workflowName,
            (Text
"Schedule" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
schedule,
            (Text
"Predicate" Text -> Predicate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Predicate -> Pair) -> Maybe Predicate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Predicate
predicate,
            (Text
"StartOnCreation" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
startOnCreation,
            (Text
"EventBatchingCondition" Text -> EventBatchingCondition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (EventBatchingCondition -> Pair)
-> Maybe EventBatchingCondition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EventBatchingCondition
eventBatchingCondition,
            (Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Text
"Tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> TriggerType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TriggerType
type'),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Actions" Text -> [Action] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Action]
actions)
          ]
      )

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

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

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

-- |
-- Create a value of 'CreateTriggerResponse' 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:
--
-- 'name', 'createTriggerResponse_name' - The name of the trigger.
--
-- 'httpStatus', 'createTriggerResponse_httpStatus' - The response's http status code.
newCreateTriggerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateTriggerResponse
newCreateTriggerResponse :: Int -> CreateTriggerResponse
newCreateTriggerResponse Int
pHttpStatus_ =
  CreateTriggerResponse' :: Maybe Text -> Int -> CreateTriggerResponse
CreateTriggerResponse'
    { $sel:name:CreateTriggerResponse' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateTriggerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The name of the trigger.
createTriggerResponse_name :: Lens.Lens' CreateTriggerResponse (Prelude.Maybe Prelude.Text)
createTriggerResponse_name :: (Maybe Text -> f (Maybe Text))
-> CreateTriggerResponse -> f CreateTriggerResponse
createTriggerResponse_name = (CreateTriggerResponse -> Maybe Text)
-> (CreateTriggerResponse -> Maybe Text -> CreateTriggerResponse)
-> Lens
     CreateTriggerResponse
     CreateTriggerResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTriggerResponse' {Maybe Text
name :: Maybe Text
$sel:name:CreateTriggerResponse' :: CreateTriggerResponse -> Maybe Text
name} -> Maybe Text
name) (\s :: CreateTriggerResponse
s@CreateTriggerResponse' {} Maybe Text
a -> CreateTriggerResponse
s {$sel:name:CreateTriggerResponse' :: Maybe Text
name = Maybe Text
a} :: CreateTriggerResponse)

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

instance Prelude.NFData CreateTriggerResponse