{-# 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.MGN.Types.SsmDocument
-- 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.MGN.Types.SsmDocument where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MGN.Types.SsmParameterStoreParameter
import qualified Amazonka.Prelude as Prelude

-- | AWS Systems Manager Document.
--
-- /See:/ 'newSsmDocument' smart constructor.
data SsmDocument = SsmDocument'
  { -- | If true, Cutover will not be enabled if the document has failed.
    SsmDocument -> Maybe Bool
mustSucceedForCutover :: Prelude.Maybe Prelude.Bool,
    -- | AWS Systems Manager Document parameters.
    SsmDocument -> Maybe (HashMap Text [SsmParameterStoreParameter])
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text [SsmParameterStoreParameter]),
    -- | AWS Systems Manager Document timeout seconds.
    SsmDocument -> Maybe Natural
timeoutSeconds :: Prelude.Maybe Prelude.Natural,
    -- | User-friendly name for the AWS Systems Manager Document.
    SsmDocument -> Text
actionName :: Prelude.Text,
    -- | AWS Systems Manager Document name or full ARN.
    SsmDocument -> Text
ssmDocumentName :: Prelude.Text
  }
  deriving (SsmDocument -> SsmDocument -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SsmDocument -> SsmDocument -> Bool
$c/= :: SsmDocument -> SsmDocument -> Bool
== :: SsmDocument -> SsmDocument -> Bool
$c== :: SsmDocument -> SsmDocument -> Bool
Prelude.Eq, ReadPrec [SsmDocument]
ReadPrec SsmDocument
Int -> ReadS SsmDocument
ReadS [SsmDocument]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SsmDocument]
$creadListPrec :: ReadPrec [SsmDocument]
readPrec :: ReadPrec SsmDocument
$creadPrec :: ReadPrec SsmDocument
readList :: ReadS [SsmDocument]
$creadList :: ReadS [SsmDocument]
readsPrec :: Int -> ReadS SsmDocument
$creadsPrec :: Int -> ReadS SsmDocument
Prelude.Read, Int -> SsmDocument -> ShowS
[SsmDocument] -> ShowS
SsmDocument -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SsmDocument] -> ShowS
$cshowList :: [SsmDocument] -> ShowS
show :: SsmDocument -> String
$cshow :: SsmDocument -> String
showsPrec :: Int -> SsmDocument -> ShowS
$cshowsPrec :: Int -> SsmDocument -> ShowS
Prelude.Show, forall x. Rep SsmDocument x -> SsmDocument
forall x. SsmDocument -> Rep SsmDocument x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SsmDocument x -> SsmDocument
$cfrom :: forall x. SsmDocument -> Rep SsmDocument x
Prelude.Generic)

-- |
-- Create a value of 'SsmDocument' 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:
--
-- 'mustSucceedForCutover', 'ssmDocument_mustSucceedForCutover' - If true, Cutover will not be enabled if the document has failed.
--
-- 'parameters', 'ssmDocument_parameters' - AWS Systems Manager Document parameters.
--
-- 'timeoutSeconds', 'ssmDocument_timeoutSeconds' - AWS Systems Manager Document timeout seconds.
--
-- 'actionName', 'ssmDocument_actionName' - User-friendly name for the AWS Systems Manager Document.
--
-- 'ssmDocumentName', 'ssmDocument_ssmDocumentName' - AWS Systems Manager Document name or full ARN.
newSsmDocument ::
  -- | 'actionName'
  Prelude.Text ->
  -- | 'ssmDocumentName'
  Prelude.Text ->
  SsmDocument
newSsmDocument :: Text -> Text -> SsmDocument
newSsmDocument Text
pActionName_ Text
pSsmDocumentName_ =
  SsmDocument'
    { $sel:mustSucceedForCutover:SsmDocument' :: Maybe Bool
mustSucceedForCutover =
        forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:SsmDocument' :: Maybe (HashMap Text [SsmParameterStoreParameter])
parameters = forall a. Maybe a
Prelude.Nothing,
      $sel:timeoutSeconds:SsmDocument' :: Maybe Natural
timeoutSeconds = forall a. Maybe a
Prelude.Nothing,
      $sel:actionName:SsmDocument' :: Text
actionName = Text
pActionName_,
      $sel:ssmDocumentName:SsmDocument' :: Text
ssmDocumentName = Text
pSsmDocumentName_
    }

-- | If true, Cutover will not be enabled if the document has failed.
ssmDocument_mustSucceedForCutover :: Lens.Lens' SsmDocument (Prelude.Maybe Prelude.Bool)
ssmDocument_mustSucceedForCutover :: Lens' SsmDocument (Maybe Bool)
ssmDocument_mustSucceedForCutover = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmDocument' {Maybe Bool
mustSucceedForCutover :: Maybe Bool
$sel:mustSucceedForCutover:SsmDocument' :: SsmDocument -> Maybe Bool
mustSucceedForCutover} -> Maybe Bool
mustSucceedForCutover) (\s :: SsmDocument
s@SsmDocument' {} Maybe Bool
a -> SsmDocument
s {$sel:mustSucceedForCutover:SsmDocument' :: Maybe Bool
mustSucceedForCutover = Maybe Bool
a} :: SsmDocument)

-- | AWS Systems Manager Document parameters.
ssmDocument_parameters :: Lens.Lens' SsmDocument (Prelude.Maybe (Prelude.HashMap Prelude.Text [SsmParameterStoreParameter]))
ssmDocument_parameters :: Lens'
  SsmDocument (Maybe (HashMap Text [SsmParameterStoreParameter]))
ssmDocument_parameters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmDocument' {Maybe (HashMap Text [SsmParameterStoreParameter])
parameters :: Maybe (HashMap Text [SsmParameterStoreParameter])
$sel:parameters:SsmDocument' :: SsmDocument -> Maybe (HashMap Text [SsmParameterStoreParameter])
parameters} -> Maybe (HashMap Text [SsmParameterStoreParameter])
parameters) (\s :: SsmDocument
s@SsmDocument' {} Maybe (HashMap Text [SsmParameterStoreParameter])
a -> SsmDocument
s {$sel:parameters:SsmDocument' :: Maybe (HashMap Text [SsmParameterStoreParameter])
parameters = Maybe (HashMap Text [SsmParameterStoreParameter])
a} :: SsmDocument) 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

-- | AWS Systems Manager Document timeout seconds.
ssmDocument_timeoutSeconds :: Lens.Lens' SsmDocument (Prelude.Maybe Prelude.Natural)
ssmDocument_timeoutSeconds :: Lens' SsmDocument (Maybe Natural)
ssmDocument_timeoutSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmDocument' {Maybe Natural
timeoutSeconds :: Maybe Natural
$sel:timeoutSeconds:SsmDocument' :: SsmDocument -> Maybe Natural
timeoutSeconds} -> Maybe Natural
timeoutSeconds) (\s :: SsmDocument
s@SsmDocument' {} Maybe Natural
a -> SsmDocument
s {$sel:timeoutSeconds:SsmDocument' :: Maybe Natural
timeoutSeconds = Maybe Natural
a} :: SsmDocument)

-- | User-friendly name for the AWS Systems Manager Document.
ssmDocument_actionName :: Lens.Lens' SsmDocument Prelude.Text
ssmDocument_actionName :: Lens' SsmDocument Text
ssmDocument_actionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmDocument' {Text
actionName :: Text
$sel:actionName:SsmDocument' :: SsmDocument -> Text
actionName} -> Text
actionName) (\s :: SsmDocument
s@SsmDocument' {} Text
a -> SsmDocument
s {$sel:actionName:SsmDocument' :: Text
actionName = Text
a} :: SsmDocument)

-- | AWS Systems Manager Document name or full ARN.
ssmDocument_ssmDocumentName :: Lens.Lens' SsmDocument Prelude.Text
ssmDocument_ssmDocumentName :: Lens' SsmDocument Text
ssmDocument_ssmDocumentName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmDocument' {Text
ssmDocumentName :: Text
$sel:ssmDocumentName:SsmDocument' :: SsmDocument -> Text
ssmDocumentName} -> Text
ssmDocumentName) (\s :: SsmDocument
s@SsmDocument' {} Text
a -> SsmDocument
s {$sel:ssmDocumentName:SsmDocument' :: Text
ssmDocumentName = Text
a} :: SsmDocument)

instance Data.FromJSON SsmDocument where
  parseJSON :: Value -> Parser SsmDocument
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SsmDocument"
      ( \Object
x ->
          Maybe Bool
-> Maybe (HashMap Text [SsmParameterStoreParameter])
-> Maybe Natural
-> Text
-> Text
-> SsmDocument
SsmDocument'
            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
"mustSucceedForCutover")
            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
"timeoutSeconds")
            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
"actionName")
            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
"ssmDocumentName")
      )

instance Prelude.Hashable SsmDocument where
  hashWithSalt :: Int -> SsmDocument -> Int
hashWithSalt Int
_salt SsmDocument' {Maybe Bool
Maybe Natural
Maybe (HashMap Text [SsmParameterStoreParameter])
Text
ssmDocumentName :: Text
actionName :: Text
timeoutSeconds :: Maybe Natural
parameters :: Maybe (HashMap Text [SsmParameterStoreParameter])
mustSucceedForCutover :: Maybe Bool
$sel:ssmDocumentName:SsmDocument' :: SsmDocument -> Text
$sel:actionName:SsmDocument' :: SsmDocument -> Text
$sel:timeoutSeconds:SsmDocument' :: SsmDocument -> Maybe Natural
$sel:parameters:SsmDocument' :: SsmDocument -> Maybe (HashMap Text [SsmParameterStoreParameter])
$sel:mustSucceedForCutover:SsmDocument' :: SsmDocument -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
mustSucceedForCutover
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text [SsmParameterStoreParameter])
parameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
timeoutSeconds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
actionName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ssmDocumentName

instance Prelude.NFData SsmDocument where
  rnf :: SsmDocument -> ()
rnf SsmDocument' {Maybe Bool
Maybe Natural
Maybe (HashMap Text [SsmParameterStoreParameter])
Text
ssmDocumentName :: Text
actionName :: Text
timeoutSeconds :: Maybe Natural
parameters :: Maybe (HashMap Text [SsmParameterStoreParameter])
mustSucceedForCutover :: Maybe Bool
$sel:ssmDocumentName:SsmDocument' :: SsmDocument -> Text
$sel:actionName:SsmDocument' :: SsmDocument -> Text
$sel:timeoutSeconds:SsmDocument' :: SsmDocument -> Maybe Natural
$sel:parameters:SsmDocument' :: SsmDocument -> Maybe (HashMap Text [SsmParameterStoreParameter])
$sel:mustSucceedForCutover:SsmDocument' :: SsmDocument -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
mustSucceedForCutover
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text [SsmParameterStoreParameter])
parameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
timeoutSeconds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
actionName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
ssmDocumentName

instance Data.ToJSON SsmDocument where
  toJSON :: SsmDocument -> Value
toJSON SsmDocument' {Maybe Bool
Maybe Natural
Maybe (HashMap Text [SsmParameterStoreParameter])
Text
ssmDocumentName :: Text
actionName :: Text
timeoutSeconds :: Maybe Natural
parameters :: Maybe (HashMap Text [SsmParameterStoreParameter])
mustSucceedForCutover :: Maybe Bool
$sel:ssmDocumentName:SsmDocument' :: SsmDocument -> Text
$sel:actionName:SsmDocument' :: SsmDocument -> Text
$sel:timeoutSeconds:SsmDocument' :: SsmDocument -> Maybe Natural
$sel:parameters:SsmDocument' :: SsmDocument -> Maybe (HashMap Text [SsmParameterStoreParameter])
$sel:mustSucceedForCutover:SsmDocument' :: SsmDocument -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"mustSucceedForCutover" 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 Bool
mustSucceedForCutover,
            (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 [SsmParameterStoreParameter])
parameters,
            (Key
"timeoutSeconds" 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 Natural
timeoutSeconds,
            forall a. a -> Maybe a
Prelude.Just (Key
"actionName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
actionName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ssmDocumentName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
ssmDocumentName)
          ]
      )