{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

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

-- |
-- Module      : Amazonka.SSM.Types.Runbook
-- 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)
module Amazonka.SSM.Types.Runbook where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSM.Types.Target
import Amazonka.SSM.Types.TargetLocation

-- | Information about an Automation runbook used in a runbook workflow in
-- Change Manager.
--
-- The Automation runbooks specified for the runbook workflow can\'t run
-- until all required approvals for the change request have been received.
--
-- /See:/ 'newRunbook' smart constructor.
data Runbook = Runbook'
  { -- | The name of the parameter used as the target resource for the
    -- rate-controlled runbook workflow. Required if you specify @Targets@.
    Runbook -> Maybe Text
targetParameterName :: Prelude.Maybe Prelude.Text,
    -- | Information about the Amazon Web Services Regions and Amazon Web
    -- Services accounts targeted by the current Runbook operation.
    Runbook -> Maybe (NonEmpty TargetLocation)
targetLocations :: Prelude.Maybe (Prelude.NonEmpty TargetLocation),
    -- | The @MaxErrors@ value specified by the user when the execution started,
    -- indicating the maximum number of errors that can occur during the
    -- operation before the updates are stopped or rolled back.
    Runbook -> Maybe Text
maxErrors :: Prelude.Maybe Prelude.Text,
    -- | A key-value mapping to target resources that the runbook operation
    -- performs tasks on. Required if you specify @TargetParameterName@.
    Runbook -> Maybe [Target]
targets :: Prelude.Maybe [Target],
    -- | The key-value map of execution parameters, which were supplied when
    -- calling @StartChangeRequestExecution@.
    Runbook -> Maybe (HashMap Text [Text])
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]),
    -- | The version of the Automation runbook used in a runbook workflow.
    Runbook -> Maybe Text
documentVersion :: Prelude.Maybe Prelude.Text,
    -- | The @MaxConcurrency@ value specified by the user when the operation
    -- started, indicating the maximum number of resources that the runbook
    -- operation can run on at the same time.
    Runbook -> Maybe Text
maxConcurrency :: Prelude.Maybe Prelude.Text,
    -- | The name of the Automation runbook used in a runbook workflow.
    Runbook -> Text
documentName :: Prelude.Text
  }
  deriving (Runbook -> Runbook -> Bool
(Runbook -> Runbook -> Bool)
-> (Runbook -> Runbook -> Bool) -> Eq Runbook
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Runbook -> Runbook -> Bool
$c/= :: Runbook -> Runbook -> Bool
== :: Runbook -> Runbook -> Bool
$c== :: Runbook -> Runbook -> Bool
Prelude.Eq, ReadPrec [Runbook]
ReadPrec Runbook
Int -> ReadS Runbook
ReadS [Runbook]
(Int -> ReadS Runbook)
-> ReadS [Runbook]
-> ReadPrec Runbook
-> ReadPrec [Runbook]
-> Read Runbook
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Runbook]
$creadListPrec :: ReadPrec [Runbook]
readPrec :: ReadPrec Runbook
$creadPrec :: ReadPrec Runbook
readList :: ReadS [Runbook]
$creadList :: ReadS [Runbook]
readsPrec :: Int -> ReadS Runbook
$creadsPrec :: Int -> ReadS Runbook
Prelude.Read, Int -> Runbook -> ShowS
[Runbook] -> ShowS
Runbook -> String
(Int -> Runbook -> ShowS)
-> (Runbook -> String) -> ([Runbook] -> ShowS) -> Show Runbook
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Runbook] -> ShowS
$cshowList :: [Runbook] -> ShowS
show :: Runbook -> String
$cshow :: Runbook -> String
showsPrec :: Int -> Runbook -> ShowS
$cshowsPrec :: Int -> Runbook -> ShowS
Prelude.Show, (forall x. Runbook -> Rep Runbook x)
-> (forall x. Rep Runbook x -> Runbook) -> Generic Runbook
forall x. Rep Runbook x -> Runbook
forall x. Runbook -> Rep Runbook x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Runbook x -> Runbook
$cfrom :: forall x. Runbook -> Rep Runbook x
Prelude.Generic)

-- |
-- Create a value of 'Runbook' 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:
--
-- 'targetParameterName', 'runbook_targetParameterName' - The name of the parameter used as the target resource for the
-- rate-controlled runbook workflow. Required if you specify @Targets@.
--
-- 'targetLocations', 'runbook_targetLocations' - Information about the Amazon Web Services Regions and Amazon Web
-- Services accounts targeted by the current Runbook operation.
--
-- 'maxErrors', 'runbook_maxErrors' - The @MaxErrors@ value specified by the user when the execution started,
-- indicating the maximum number of errors that can occur during the
-- operation before the updates are stopped or rolled back.
--
-- 'targets', 'runbook_targets' - A key-value mapping to target resources that the runbook operation
-- performs tasks on. Required if you specify @TargetParameterName@.
--
-- 'parameters', 'runbook_parameters' - The key-value map of execution parameters, which were supplied when
-- calling @StartChangeRequestExecution@.
--
-- 'documentVersion', 'runbook_documentVersion' - The version of the Automation runbook used in a runbook workflow.
--
-- 'maxConcurrency', 'runbook_maxConcurrency' - The @MaxConcurrency@ value specified by the user when the operation
-- started, indicating the maximum number of resources that the runbook
-- operation can run on at the same time.
--
-- 'documentName', 'runbook_documentName' - The name of the Automation runbook used in a runbook workflow.
newRunbook ::
  -- | 'documentName'
  Prelude.Text ->
  Runbook
newRunbook :: Text -> Runbook
newRunbook Text
pDocumentName_ =
  Runbook' :: Maybe Text
-> Maybe (NonEmpty TargetLocation)
-> Maybe Text
-> Maybe [Target]
-> Maybe (HashMap Text [Text])
-> Maybe Text
-> Maybe Text
-> Text
-> Runbook
Runbook'
    { $sel:targetParameterName:Runbook' :: Maybe Text
targetParameterName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetLocations:Runbook' :: Maybe (NonEmpty TargetLocation)
targetLocations = Maybe (NonEmpty TargetLocation)
forall a. Maybe a
Prelude.Nothing,
      $sel:maxErrors:Runbook' :: Maybe Text
maxErrors = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targets:Runbook' :: Maybe [Target]
targets = Maybe [Target]
forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:Runbook' :: Maybe (HashMap Text [Text])
parameters = Maybe (HashMap Text [Text])
forall a. Maybe a
Prelude.Nothing,
      $sel:documentVersion:Runbook' :: Maybe Text
documentVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxConcurrency:Runbook' :: Maybe Text
maxConcurrency = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:documentName:Runbook' :: Text
documentName = Text
pDocumentName_
    }

-- | The name of the parameter used as the target resource for the
-- rate-controlled runbook workflow. Required if you specify @Targets@.
runbook_targetParameterName :: Lens.Lens' Runbook (Prelude.Maybe Prelude.Text)
runbook_targetParameterName :: (Maybe Text -> f (Maybe Text)) -> Runbook -> f Runbook
runbook_targetParameterName = (Runbook -> Maybe Text)
-> (Runbook -> Maybe Text -> Runbook)
-> Lens Runbook Runbook (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Runbook' {Maybe Text
targetParameterName :: Maybe Text
$sel:targetParameterName:Runbook' :: Runbook -> Maybe Text
targetParameterName} -> Maybe Text
targetParameterName) (\s :: Runbook
s@Runbook' {} Maybe Text
a -> Runbook
s {$sel:targetParameterName:Runbook' :: Maybe Text
targetParameterName = Maybe Text
a} :: Runbook)

-- | Information about the Amazon Web Services Regions and Amazon Web
-- Services accounts targeted by the current Runbook operation.
runbook_targetLocations :: Lens.Lens' Runbook (Prelude.Maybe (Prelude.NonEmpty TargetLocation))
runbook_targetLocations :: (Maybe (NonEmpty TargetLocation)
 -> f (Maybe (NonEmpty TargetLocation)))
-> Runbook -> f Runbook
runbook_targetLocations = (Runbook -> Maybe (NonEmpty TargetLocation))
-> (Runbook -> Maybe (NonEmpty TargetLocation) -> Runbook)
-> Lens
     Runbook
     Runbook
     (Maybe (NonEmpty TargetLocation))
     (Maybe (NonEmpty TargetLocation))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Runbook' {Maybe (NonEmpty TargetLocation)
targetLocations :: Maybe (NonEmpty TargetLocation)
$sel:targetLocations:Runbook' :: Runbook -> Maybe (NonEmpty TargetLocation)
targetLocations} -> Maybe (NonEmpty TargetLocation)
targetLocations) (\s :: Runbook
s@Runbook' {} Maybe (NonEmpty TargetLocation)
a -> Runbook
s {$sel:targetLocations:Runbook' :: Maybe (NonEmpty TargetLocation)
targetLocations = Maybe (NonEmpty TargetLocation)
a} :: Runbook) ((Maybe (NonEmpty TargetLocation)
  -> f (Maybe (NonEmpty TargetLocation)))
 -> Runbook -> f Runbook)
-> ((Maybe (NonEmpty TargetLocation)
     -> f (Maybe (NonEmpty TargetLocation)))
    -> Maybe (NonEmpty TargetLocation)
    -> f (Maybe (NonEmpty TargetLocation)))
-> (Maybe (NonEmpty TargetLocation)
    -> f (Maybe (NonEmpty TargetLocation)))
-> Runbook
-> f Runbook
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty TargetLocation)
  (NonEmpty TargetLocation)
  (NonEmpty TargetLocation)
  (NonEmpty TargetLocation)
-> Iso
     (Maybe (NonEmpty TargetLocation))
     (Maybe (NonEmpty TargetLocation))
     (Maybe (NonEmpty TargetLocation))
     (Maybe (NonEmpty TargetLocation))
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
  (NonEmpty TargetLocation)
  (NonEmpty TargetLocation)
  (NonEmpty TargetLocation)
  (NonEmpty TargetLocation)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The @MaxErrors@ value specified by the user when the execution started,
-- indicating the maximum number of errors that can occur during the
-- operation before the updates are stopped or rolled back.
runbook_maxErrors :: Lens.Lens' Runbook (Prelude.Maybe Prelude.Text)
runbook_maxErrors :: (Maybe Text -> f (Maybe Text)) -> Runbook -> f Runbook
runbook_maxErrors = (Runbook -> Maybe Text)
-> (Runbook -> Maybe Text -> Runbook)
-> Lens Runbook Runbook (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Runbook' {Maybe Text
maxErrors :: Maybe Text
$sel:maxErrors:Runbook' :: Runbook -> Maybe Text
maxErrors} -> Maybe Text
maxErrors) (\s :: Runbook
s@Runbook' {} Maybe Text
a -> Runbook
s {$sel:maxErrors:Runbook' :: Maybe Text
maxErrors = Maybe Text
a} :: Runbook)

-- | A key-value mapping to target resources that the runbook operation
-- performs tasks on. Required if you specify @TargetParameterName@.
runbook_targets :: Lens.Lens' Runbook (Prelude.Maybe [Target])
runbook_targets :: (Maybe [Target] -> f (Maybe [Target])) -> Runbook -> f Runbook
runbook_targets = (Runbook -> Maybe [Target])
-> (Runbook -> Maybe [Target] -> Runbook)
-> Lens Runbook Runbook (Maybe [Target]) (Maybe [Target])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Runbook' {Maybe [Target]
targets :: Maybe [Target]
$sel:targets:Runbook' :: Runbook -> Maybe [Target]
targets} -> Maybe [Target]
targets) (\s :: Runbook
s@Runbook' {} Maybe [Target]
a -> Runbook
s {$sel:targets:Runbook' :: Maybe [Target]
targets = Maybe [Target]
a} :: Runbook) ((Maybe [Target] -> f (Maybe [Target])) -> Runbook -> f Runbook)
-> ((Maybe [Target] -> f (Maybe [Target]))
    -> Maybe [Target] -> f (Maybe [Target]))
-> (Maybe [Target] -> f (Maybe [Target]))
-> Runbook
-> f Runbook
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Target] [Target] [Target] [Target]
-> Iso
     (Maybe [Target]) (Maybe [Target]) (Maybe [Target]) (Maybe [Target])
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 [Target] [Target] [Target] [Target]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The key-value map of execution parameters, which were supplied when
-- calling @StartChangeRequestExecution@.
runbook_parameters :: Lens.Lens' Runbook (Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]))
runbook_parameters :: (Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> Runbook -> f Runbook
runbook_parameters = (Runbook -> Maybe (HashMap Text [Text]))
-> (Runbook -> Maybe (HashMap Text [Text]) -> Runbook)
-> Lens
     Runbook
     Runbook
     (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 (\Runbook' {Maybe (HashMap Text [Text])
parameters :: Maybe (HashMap Text [Text])
$sel:parameters:Runbook' :: Runbook -> Maybe (HashMap Text [Text])
parameters} -> Maybe (HashMap Text [Text])
parameters) (\s :: Runbook
s@Runbook' {} Maybe (HashMap Text [Text])
a -> Runbook
s {$sel:parameters:Runbook' :: Maybe (HashMap Text [Text])
parameters = Maybe (HashMap Text [Text])
a} :: Runbook) ((Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
 -> Runbook -> f Runbook)
-> ((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])))
-> Runbook
-> f Runbook
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 version of the Automation runbook used in a runbook workflow.
runbook_documentVersion :: Lens.Lens' Runbook (Prelude.Maybe Prelude.Text)
runbook_documentVersion :: (Maybe Text -> f (Maybe Text)) -> Runbook -> f Runbook
runbook_documentVersion = (Runbook -> Maybe Text)
-> (Runbook -> Maybe Text -> Runbook)
-> Lens Runbook Runbook (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Runbook' {Maybe Text
documentVersion :: Maybe Text
$sel:documentVersion:Runbook' :: Runbook -> Maybe Text
documentVersion} -> Maybe Text
documentVersion) (\s :: Runbook
s@Runbook' {} Maybe Text
a -> Runbook
s {$sel:documentVersion:Runbook' :: Maybe Text
documentVersion = Maybe Text
a} :: Runbook)

-- | The @MaxConcurrency@ value specified by the user when the operation
-- started, indicating the maximum number of resources that the runbook
-- operation can run on at the same time.
runbook_maxConcurrency :: Lens.Lens' Runbook (Prelude.Maybe Prelude.Text)
runbook_maxConcurrency :: (Maybe Text -> f (Maybe Text)) -> Runbook -> f Runbook
runbook_maxConcurrency = (Runbook -> Maybe Text)
-> (Runbook -> Maybe Text -> Runbook)
-> Lens Runbook Runbook (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Runbook' {Maybe Text
maxConcurrency :: Maybe Text
$sel:maxConcurrency:Runbook' :: Runbook -> Maybe Text
maxConcurrency} -> Maybe Text
maxConcurrency) (\s :: Runbook
s@Runbook' {} Maybe Text
a -> Runbook
s {$sel:maxConcurrency:Runbook' :: Maybe Text
maxConcurrency = Maybe Text
a} :: Runbook)

-- | The name of the Automation runbook used in a runbook workflow.
runbook_documentName :: Lens.Lens' Runbook Prelude.Text
runbook_documentName :: (Text -> f Text) -> Runbook -> f Runbook
runbook_documentName = (Runbook -> Text)
-> (Runbook -> Text -> Runbook) -> Lens Runbook Runbook Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Runbook' {Text
documentName :: Text
$sel:documentName:Runbook' :: Runbook -> Text
documentName} -> Text
documentName) (\s :: Runbook
s@Runbook' {} Text
a -> Runbook
s {$sel:documentName:Runbook' :: Text
documentName = Text
a} :: Runbook)

instance Core.FromJSON Runbook where
  parseJSON :: Value -> Parser Runbook
parseJSON =
    String -> (Object -> Parser Runbook) -> Value -> Parser Runbook
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Runbook"
      ( \Object
x ->
          Maybe Text
-> Maybe (NonEmpty TargetLocation)
-> Maybe Text
-> Maybe [Target]
-> Maybe (HashMap Text [Text])
-> Maybe Text
-> Maybe Text
-> Text
-> Runbook
Runbook'
            (Maybe Text
 -> Maybe (NonEmpty TargetLocation)
 -> Maybe Text
 -> Maybe [Target]
 -> Maybe (HashMap Text [Text])
 -> Maybe Text
 -> Maybe Text
 -> Text
 -> Runbook)
-> Parser (Maybe Text)
-> Parser
     (Maybe (NonEmpty TargetLocation)
      -> Maybe Text
      -> Maybe [Target]
      -> Maybe (HashMap Text [Text])
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Runbook)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TargetParameterName")
            Parser
  (Maybe (NonEmpty TargetLocation)
   -> Maybe Text
   -> Maybe [Target]
   -> Maybe (HashMap Text [Text])
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Runbook)
-> Parser (Maybe (NonEmpty TargetLocation))
-> Parser
     (Maybe Text
      -> Maybe [Target]
      -> Maybe (HashMap Text [Text])
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Runbook)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty TargetLocation))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TargetLocations")
            Parser
  (Maybe Text
   -> Maybe [Target]
   -> Maybe (HashMap Text [Text])
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Runbook)
-> Parser (Maybe Text)
-> Parser
     (Maybe [Target]
      -> Maybe (HashMap Text [Text])
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Runbook)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaxErrors")
            Parser
  (Maybe [Target]
   -> Maybe (HashMap Text [Text])
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Runbook)
-> Parser (Maybe [Target])
-> Parser
     (Maybe (HashMap Text [Text])
      -> Maybe Text -> Maybe Text -> Text -> Runbook)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Target]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Targets" Parser (Maybe (Maybe [Target]))
-> Maybe [Target] -> Parser (Maybe [Target])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Target]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe (HashMap Text [Text])
   -> Maybe Text -> Maybe Text -> Text -> Runbook)
-> Parser (Maybe (HashMap Text [Text]))
-> Parser (Maybe Text -> Maybe Text -> Text -> Runbook)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text [Text])))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Parameters" Parser (Maybe (Maybe (HashMap Text [Text])))
-> Maybe (HashMap Text [Text])
-> Parser (Maybe (HashMap Text [Text]))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text [Text])
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Maybe Text -> Text -> Runbook)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Text -> Runbook)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DocumentVersion")
            Parser (Maybe Text -> Text -> Runbook)
-> Parser (Maybe Text) -> Parser (Text -> Runbook)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaxConcurrency")
            Parser (Text -> Runbook) -> Parser Text -> Parser Runbook
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DocumentName")
      )

instance Prelude.Hashable Runbook

instance Prelude.NFData Runbook

instance Core.ToJSON Runbook where
  toJSON :: Runbook -> Value
toJSON Runbook' {Maybe [Target]
Maybe (NonEmpty TargetLocation)
Maybe Text
Maybe (HashMap Text [Text])
Text
documentName :: Text
maxConcurrency :: Maybe Text
documentVersion :: Maybe Text
parameters :: Maybe (HashMap Text [Text])
targets :: Maybe [Target]
maxErrors :: Maybe Text
targetLocations :: Maybe (NonEmpty TargetLocation)
targetParameterName :: Maybe Text
$sel:documentName:Runbook' :: Runbook -> Text
$sel:maxConcurrency:Runbook' :: Runbook -> Maybe Text
$sel:documentVersion:Runbook' :: Runbook -> Maybe Text
$sel:parameters:Runbook' :: Runbook -> Maybe (HashMap Text [Text])
$sel:targets:Runbook' :: Runbook -> Maybe [Target]
$sel:maxErrors:Runbook' :: Runbook -> Maybe Text
$sel:targetLocations:Runbook' :: Runbook -> Maybe (NonEmpty TargetLocation)
$sel:targetParameterName:Runbook' :: Runbook -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TargetParameterName" 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
targetParameterName,
            (Text
"TargetLocations" Text -> NonEmpty TargetLocation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty TargetLocation -> Pair)
-> Maybe (NonEmpty TargetLocation) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty TargetLocation)
targetLocations,
            (Text
"MaxErrors" 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
maxErrors,
            (Text
"Targets" Text -> [Target] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Target] -> Pair) -> Maybe [Target] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Target]
targets,
            (Text
"Parameters" 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])
parameters,
            (Text
"DocumentVersion" 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
documentVersion,
            (Text
"MaxConcurrency" 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
maxConcurrency,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DocumentName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
documentName)
          ]
      )