{-# 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.SSMIncidents.Types.SsmAutomation
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SSMIncidents.Types.SsmAutomation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSMIncidents.Types.DynamicSsmParameterValue
import Amazonka.SSMIncidents.Types.SsmTargetAccount

-- | Details about the Systems Manager automation document that will be used
-- as a runbook during an incident.
--
-- /See:/ 'newSsmAutomation' smart constructor.
data SsmAutomation = SsmAutomation'
  { -- | The automation document\'s version to use when running.
    SsmAutomation -> Maybe Text
documentVersion :: Prelude.Maybe Prelude.Text,
    -- | The key-value pair to resolve dynamic parameter values when processing a
    -- Systems Manager Automation runbook.
    SsmAutomation -> Maybe (HashMap Text DynamicSsmParameterValue)
dynamicParameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text DynamicSsmParameterValue),
    -- | The key-value pair parameters to use when running the automation
    -- document.
    SsmAutomation -> Maybe (HashMap Text [Text])
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]),
    -- | The account that the automation document will be run in. This can be in
    -- either the management account or an application account.
    SsmAutomation -> Maybe SsmTargetAccount
targetAccount :: Prelude.Maybe SsmTargetAccount,
    -- | The automation document\'s name.
    SsmAutomation -> Text
documentName :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the role that the automation document
    -- will assume when running commands.
    SsmAutomation -> Text
roleArn :: Prelude.Text
  }
  deriving (SsmAutomation -> SsmAutomation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SsmAutomation -> SsmAutomation -> Bool
$c/= :: SsmAutomation -> SsmAutomation -> Bool
== :: SsmAutomation -> SsmAutomation -> Bool
$c== :: SsmAutomation -> SsmAutomation -> Bool
Prelude.Eq, ReadPrec [SsmAutomation]
ReadPrec SsmAutomation
Int -> ReadS SsmAutomation
ReadS [SsmAutomation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SsmAutomation]
$creadListPrec :: ReadPrec [SsmAutomation]
readPrec :: ReadPrec SsmAutomation
$creadPrec :: ReadPrec SsmAutomation
readList :: ReadS [SsmAutomation]
$creadList :: ReadS [SsmAutomation]
readsPrec :: Int -> ReadS SsmAutomation
$creadsPrec :: Int -> ReadS SsmAutomation
Prelude.Read, Int -> SsmAutomation -> ShowS
[SsmAutomation] -> ShowS
SsmAutomation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SsmAutomation] -> ShowS
$cshowList :: [SsmAutomation] -> ShowS
show :: SsmAutomation -> String
$cshow :: SsmAutomation -> String
showsPrec :: Int -> SsmAutomation -> ShowS
$cshowsPrec :: Int -> SsmAutomation -> ShowS
Prelude.Show, forall x. Rep SsmAutomation x -> SsmAutomation
forall x. SsmAutomation -> Rep SsmAutomation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SsmAutomation x -> SsmAutomation
$cfrom :: forall x. SsmAutomation -> Rep SsmAutomation x
Prelude.Generic)

-- |
-- Create a value of 'SsmAutomation' 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:
--
-- 'documentVersion', 'ssmAutomation_documentVersion' - The automation document\'s version to use when running.
--
-- 'dynamicParameters', 'ssmAutomation_dynamicParameters' - The key-value pair to resolve dynamic parameter values when processing a
-- Systems Manager Automation runbook.
--
-- 'parameters', 'ssmAutomation_parameters' - The key-value pair parameters to use when running the automation
-- document.
--
-- 'targetAccount', 'ssmAutomation_targetAccount' - The account that the automation document will be run in. This can be in
-- either the management account or an application account.
--
-- 'documentName', 'ssmAutomation_documentName' - The automation document\'s name.
--
-- 'roleArn', 'ssmAutomation_roleArn' - The Amazon Resource Name (ARN) of the role that the automation document
-- will assume when running commands.
newSsmAutomation ::
  -- | 'documentName'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  SsmAutomation
newSsmAutomation :: Text -> Text -> SsmAutomation
newSsmAutomation Text
pDocumentName_ Text
pRoleArn_ =
  SsmAutomation'
    { $sel:documentVersion:SsmAutomation' :: Maybe Text
documentVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:dynamicParameters:SsmAutomation' :: Maybe (HashMap Text DynamicSsmParameterValue)
dynamicParameters = forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:SsmAutomation' :: Maybe (HashMap Text [Text])
parameters = forall a. Maybe a
Prelude.Nothing,
      $sel:targetAccount:SsmAutomation' :: Maybe SsmTargetAccount
targetAccount = forall a. Maybe a
Prelude.Nothing,
      $sel:documentName:SsmAutomation' :: Text
documentName = Text
pDocumentName_,
      $sel:roleArn:SsmAutomation' :: Text
roleArn = Text
pRoleArn_
    }

-- | The automation document\'s version to use when running.
ssmAutomation_documentVersion :: Lens.Lens' SsmAutomation (Prelude.Maybe Prelude.Text)
ssmAutomation_documentVersion :: Lens' SsmAutomation (Maybe Text)
ssmAutomation_documentVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmAutomation' {Maybe Text
documentVersion :: Maybe Text
$sel:documentVersion:SsmAutomation' :: SsmAutomation -> Maybe Text
documentVersion} -> Maybe Text
documentVersion) (\s :: SsmAutomation
s@SsmAutomation' {} Maybe Text
a -> SsmAutomation
s {$sel:documentVersion:SsmAutomation' :: Maybe Text
documentVersion = Maybe Text
a} :: SsmAutomation)

-- | The key-value pair to resolve dynamic parameter values when processing a
-- Systems Manager Automation runbook.
ssmAutomation_dynamicParameters :: Lens.Lens' SsmAutomation (Prelude.Maybe (Prelude.HashMap Prelude.Text DynamicSsmParameterValue))
ssmAutomation_dynamicParameters :: Lens' SsmAutomation (Maybe (HashMap Text DynamicSsmParameterValue))
ssmAutomation_dynamicParameters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmAutomation' {Maybe (HashMap Text DynamicSsmParameterValue)
dynamicParameters :: Maybe (HashMap Text DynamicSsmParameterValue)
$sel:dynamicParameters:SsmAutomation' :: SsmAutomation -> Maybe (HashMap Text DynamicSsmParameterValue)
dynamicParameters} -> Maybe (HashMap Text DynamicSsmParameterValue)
dynamicParameters) (\s :: SsmAutomation
s@SsmAutomation' {} Maybe (HashMap Text DynamicSsmParameterValue)
a -> SsmAutomation
s {$sel:dynamicParameters:SsmAutomation' :: Maybe (HashMap Text DynamicSsmParameterValue)
dynamicParameters = Maybe (HashMap Text DynamicSsmParameterValue)
a} :: SsmAutomation) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The key-value pair parameters to use when running the automation
-- document.
ssmAutomation_parameters :: Lens.Lens' SsmAutomation (Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]))
ssmAutomation_parameters :: Lens' SsmAutomation (Maybe (HashMap Text [Text]))
ssmAutomation_parameters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmAutomation' {Maybe (HashMap Text [Text])
parameters :: Maybe (HashMap Text [Text])
$sel:parameters:SsmAutomation' :: SsmAutomation -> Maybe (HashMap Text [Text])
parameters} -> Maybe (HashMap Text [Text])
parameters) (\s :: SsmAutomation
s@SsmAutomation' {} Maybe (HashMap Text [Text])
a -> SsmAutomation
s {$sel:parameters:SsmAutomation' :: Maybe (HashMap Text [Text])
parameters = Maybe (HashMap Text [Text])
a} :: SsmAutomation) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The account that the automation document will be run in. This can be in
-- either the management account or an application account.
ssmAutomation_targetAccount :: Lens.Lens' SsmAutomation (Prelude.Maybe SsmTargetAccount)
ssmAutomation_targetAccount :: Lens' SsmAutomation (Maybe SsmTargetAccount)
ssmAutomation_targetAccount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmAutomation' {Maybe SsmTargetAccount
targetAccount :: Maybe SsmTargetAccount
$sel:targetAccount:SsmAutomation' :: SsmAutomation -> Maybe SsmTargetAccount
targetAccount} -> Maybe SsmTargetAccount
targetAccount) (\s :: SsmAutomation
s@SsmAutomation' {} Maybe SsmTargetAccount
a -> SsmAutomation
s {$sel:targetAccount:SsmAutomation' :: Maybe SsmTargetAccount
targetAccount = Maybe SsmTargetAccount
a} :: SsmAutomation)

-- | The automation document\'s name.
ssmAutomation_documentName :: Lens.Lens' SsmAutomation Prelude.Text
ssmAutomation_documentName :: Lens' SsmAutomation Text
ssmAutomation_documentName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmAutomation' {Text
documentName :: Text
$sel:documentName:SsmAutomation' :: SsmAutomation -> Text
documentName} -> Text
documentName) (\s :: SsmAutomation
s@SsmAutomation' {} Text
a -> SsmAutomation
s {$sel:documentName:SsmAutomation' :: Text
documentName = Text
a} :: SsmAutomation)

-- | The Amazon Resource Name (ARN) of the role that the automation document
-- will assume when running commands.
ssmAutomation_roleArn :: Lens.Lens' SsmAutomation Prelude.Text
ssmAutomation_roleArn :: Lens' SsmAutomation Text
ssmAutomation_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmAutomation' {Text
roleArn :: Text
$sel:roleArn:SsmAutomation' :: SsmAutomation -> Text
roleArn} -> Text
roleArn) (\s :: SsmAutomation
s@SsmAutomation' {} Text
a -> SsmAutomation
s {$sel:roleArn:SsmAutomation' :: Text
roleArn = Text
a} :: SsmAutomation)

instance Data.FromJSON SsmAutomation where
  parseJSON :: Value -> Parser SsmAutomation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SsmAutomation"
      ( \Object
x ->
          Maybe Text
-> Maybe (HashMap Text DynamicSsmParameterValue)
-> Maybe (HashMap Text [Text])
-> Maybe SsmTargetAccount
-> Text
-> Text
-> SsmAutomation
SsmAutomation'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"documentVersion")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"dynamicParameters"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"parameters" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"targetAccount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"documentName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"roleArn")
      )

instance Prelude.Hashable SsmAutomation where
  hashWithSalt :: Int -> SsmAutomation -> Int
hashWithSalt Int
_salt SsmAutomation' {Maybe Text
Maybe (HashMap Text [Text])
Maybe (HashMap Text DynamicSsmParameterValue)
Maybe SsmTargetAccount
Text
roleArn :: Text
documentName :: Text
targetAccount :: Maybe SsmTargetAccount
parameters :: Maybe (HashMap Text [Text])
dynamicParameters :: Maybe (HashMap Text DynamicSsmParameterValue)
documentVersion :: Maybe Text
$sel:roleArn:SsmAutomation' :: SsmAutomation -> Text
$sel:documentName:SsmAutomation' :: SsmAutomation -> Text
$sel:targetAccount:SsmAutomation' :: SsmAutomation -> Maybe SsmTargetAccount
$sel:parameters:SsmAutomation' :: SsmAutomation -> Maybe (HashMap Text [Text])
$sel:dynamicParameters:SsmAutomation' :: SsmAutomation -> Maybe (HashMap Text DynamicSsmParameterValue)
$sel:documentVersion:SsmAutomation' :: SsmAutomation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
documentVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text DynamicSsmParameterValue)
dynamicParameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text [Text])
parameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SsmTargetAccount
targetAccount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
documentName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleArn

instance Prelude.NFData SsmAutomation where
  rnf :: SsmAutomation -> ()
rnf SsmAutomation' {Maybe Text
Maybe (HashMap Text [Text])
Maybe (HashMap Text DynamicSsmParameterValue)
Maybe SsmTargetAccount
Text
roleArn :: Text
documentName :: Text
targetAccount :: Maybe SsmTargetAccount
parameters :: Maybe (HashMap Text [Text])
dynamicParameters :: Maybe (HashMap Text DynamicSsmParameterValue)
documentVersion :: Maybe Text
$sel:roleArn:SsmAutomation' :: SsmAutomation -> Text
$sel:documentName:SsmAutomation' :: SsmAutomation -> Text
$sel:targetAccount:SsmAutomation' :: SsmAutomation -> Maybe SsmTargetAccount
$sel:parameters:SsmAutomation' :: SsmAutomation -> Maybe (HashMap Text [Text])
$sel:dynamicParameters:SsmAutomation' :: SsmAutomation -> Maybe (HashMap Text DynamicSsmParameterValue)
$sel:documentVersion:SsmAutomation' :: SsmAutomation -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
documentVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text DynamicSsmParameterValue)
dynamicParameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text [Text])
parameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SsmTargetAccount
targetAccount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
documentName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleArn

instance Data.ToJSON SsmAutomation where
  toJSON :: SsmAutomation -> Value
toJSON SsmAutomation' {Maybe Text
Maybe (HashMap Text [Text])
Maybe (HashMap Text DynamicSsmParameterValue)
Maybe SsmTargetAccount
Text
roleArn :: Text
documentName :: Text
targetAccount :: Maybe SsmTargetAccount
parameters :: Maybe (HashMap Text [Text])
dynamicParameters :: Maybe (HashMap Text DynamicSsmParameterValue)
documentVersion :: Maybe Text
$sel:roleArn:SsmAutomation' :: SsmAutomation -> Text
$sel:documentName:SsmAutomation' :: SsmAutomation -> Text
$sel:targetAccount:SsmAutomation' :: SsmAutomation -> Maybe SsmTargetAccount
$sel:parameters:SsmAutomation' :: SsmAutomation -> Maybe (HashMap Text [Text])
$sel:dynamicParameters:SsmAutomation' :: SsmAutomation -> Maybe (HashMap Text DynamicSsmParameterValue)
$sel:documentVersion:SsmAutomation' :: SsmAutomation -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"documentVersion" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
documentVersion,
            (Key
"dynamicParameters" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text DynamicSsmParameterValue)
dynamicParameters,
            (Key
"parameters" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text [Text])
parameters,
            (Key
"targetAccount" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SsmTargetAccount
targetAccount,
            forall a. a -> Maybe a
Prelude.Just (Key
"documentName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
documentName),
            forall a. a -> Maybe a
Prelude.Just (Key
"roleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
roleArn)
          ]
      )