{-# 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.Budgets.Types.SsmActionDefinition
-- 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.Budgets.Types.SsmActionDefinition where

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

-- | The Amazon Web Services Systems Manager (SSM) action definition details.
--
-- /See:/ 'newSsmActionDefinition' smart constructor.
data SsmActionDefinition = SsmActionDefinition'
  { -- | The action subType.
    SsmActionDefinition -> ActionSubType
actionSubType :: ActionSubType,
    -- | The Region to run the SSM document.
    SsmActionDefinition -> Text
region :: Prelude.Text,
    -- | The EC2 and RDS instance IDs.
    SsmActionDefinition -> NonEmpty Text
instanceIds :: Prelude.NonEmpty Prelude.Text
  }
  deriving (SsmActionDefinition -> SsmActionDefinition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SsmActionDefinition -> SsmActionDefinition -> Bool
$c/= :: SsmActionDefinition -> SsmActionDefinition -> Bool
== :: SsmActionDefinition -> SsmActionDefinition -> Bool
$c== :: SsmActionDefinition -> SsmActionDefinition -> Bool
Prelude.Eq, ReadPrec [SsmActionDefinition]
ReadPrec SsmActionDefinition
Int -> ReadS SsmActionDefinition
ReadS [SsmActionDefinition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SsmActionDefinition]
$creadListPrec :: ReadPrec [SsmActionDefinition]
readPrec :: ReadPrec SsmActionDefinition
$creadPrec :: ReadPrec SsmActionDefinition
readList :: ReadS [SsmActionDefinition]
$creadList :: ReadS [SsmActionDefinition]
readsPrec :: Int -> ReadS SsmActionDefinition
$creadsPrec :: Int -> ReadS SsmActionDefinition
Prelude.Read, Int -> SsmActionDefinition -> ShowS
[SsmActionDefinition] -> ShowS
SsmActionDefinition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SsmActionDefinition] -> ShowS
$cshowList :: [SsmActionDefinition] -> ShowS
show :: SsmActionDefinition -> String
$cshow :: SsmActionDefinition -> String
showsPrec :: Int -> SsmActionDefinition -> ShowS
$cshowsPrec :: Int -> SsmActionDefinition -> ShowS
Prelude.Show, forall x. Rep SsmActionDefinition x -> SsmActionDefinition
forall x. SsmActionDefinition -> Rep SsmActionDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SsmActionDefinition x -> SsmActionDefinition
$cfrom :: forall x. SsmActionDefinition -> Rep SsmActionDefinition x
Prelude.Generic)

-- |
-- Create a value of 'SsmActionDefinition' 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:
--
-- 'actionSubType', 'ssmActionDefinition_actionSubType' - The action subType.
--
-- 'region', 'ssmActionDefinition_region' - The Region to run the SSM document.
--
-- 'instanceIds', 'ssmActionDefinition_instanceIds' - The EC2 and RDS instance IDs.
newSsmActionDefinition ::
  -- | 'actionSubType'
  ActionSubType ->
  -- | 'region'
  Prelude.Text ->
  -- | 'instanceIds'
  Prelude.NonEmpty Prelude.Text ->
  SsmActionDefinition
newSsmActionDefinition :: ActionSubType -> Text -> NonEmpty Text -> SsmActionDefinition
newSsmActionDefinition
  ActionSubType
pActionSubType_
  Text
pRegion_
  NonEmpty Text
pInstanceIds_ =
    SsmActionDefinition'
      { $sel:actionSubType:SsmActionDefinition' :: ActionSubType
actionSubType =
          ActionSubType
pActionSubType_,
        $sel:region:SsmActionDefinition' :: Text
region = Text
pRegion_,
        $sel:instanceIds:SsmActionDefinition' :: NonEmpty Text
instanceIds = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pInstanceIds_
      }

-- | The action subType.
ssmActionDefinition_actionSubType :: Lens.Lens' SsmActionDefinition ActionSubType
ssmActionDefinition_actionSubType :: Lens' SsmActionDefinition ActionSubType
ssmActionDefinition_actionSubType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmActionDefinition' {ActionSubType
actionSubType :: ActionSubType
$sel:actionSubType:SsmActionDefinition' :: SsmActionDefinition -> ActionSubType
actionSubType} -> ActionSubType
actionSubType) (\s :: SsmActionDefinition
s@SsmActionDefinition' {} ActionSubType
a -> SsmActionDefinition
s {$sel:actionSubType:SsmActionDefinition' :: ActionSubType
actionSubType = ActionSubType
a} :: SsmActionDefinition)

-- | The Region to run the SSM document.
ssmActionDefinition_region :: Lens.Lens' SsmActionDefinition Prelude.Text
ssmActionDefinition_region :: Lens' SsmActionDefinition Text
ssmActionDefinition_region = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmActionDefinition' {Text
region :: Text
$sel:region:SsmActionDefinition' :: SsmActionDefinition -> Text
region} -> Text
region) (\s :: SsmActionDefinition
s@SsmActionDefinition' {} Text
a -> SsmActionDefinition
s {$sel:region:SsmActionDefinition' :: Text
region = Text
a} :: SsmActionDefinition)

-- | The EC2 and RDS instance IDs.
ssmActionDefinition_instanceIds :: Lens.Lens' SsmActionDefinition (Prelude.NonEmpty Prelude.Text)
ssmActionDefinition_instanceIds :: Lens' SsmActionDefinition (NonEmpty Text)
ssmActionDefinition_instanceIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmActionDefinition' {NonEmpty Text
instanceIds :: NonEmpty Text
$sel:instanceIds:SsmActionDefinition' :: SsmActionDefinition -> NonEmpty Text
instanceIds} -> NonEmpty Text
instanceIds) (\s :: SsmActionDefinition
s@SsmActionDefinition' {} NonEmpty Text
a -> SsmActionDefinition
s {$sel:instanceIds:SsmActionDefinition' :: NonEmpty Text
instanceIds = NonEmpty Text
a} :: SsmActionDefinition) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON SsmActionDefinition where
  parseJSON :: Value -> Parser SsmActionDefinition
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SsmActionDefinition"
      ( \Object
x ->
          ActionSubType -> Text -> NonEmpty Text -> SsmActionDefinition
SsmActionDefinition'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ActionSubType")
            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
"Region")
            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
"InstanceIds")
      )

instance Prelude.Hashable SsmActionDefinition where
  hashWithSalt :: Int -> SsmActionDefinition -> Int
hashWithSalt Int
_salt SsmActionDefinition' {NonEmpty Text
Text
ActionSubType
instanceIds :: NonEmpty Text
region :: Text
actionSubType :: ActionSubType
$sel:instanceIds:SsmActionDefinition' :: SsmActionDefinition -> NonEmpty Text
$sel:region:SsmActionDefinition' :: SsmActionDefinition -> Text
$sel:actionSubType:SsmActionDefinition' :: SsmActionDefinition -> ActionSubType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ActionSubType
actionSubType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
region
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
instanceIds

instance Prelude.NFData SsmActionDefinition where
  rnf :: SsmActionDefinition -> ()
rnf SsmActionDefinition' {NonEmpty Text
Text
ActionSubType
instanceIds :: NonEmpty Text
region :: Text
actionSubType :: ActionSubType
$sel:instanceIds:SsmActionDefinition' :: SsmActionDefinition -> NonEmpty Text
$sel:region:SsmActionDefinition' :: SsmActionDefinition -> Text
$sel:actionSubType:SsmActionDefinition' :: SsmActionDefinition -> ActionSubType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ActionSubType
actionSubType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
region
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
instanceIds

instance Data.ToJSON SsmActionDefinition where
  toJSON :: SsmActionDefinition -> Value
toJSON SsmActionDefinition' {NonEmpty Text
Text
ActionSubType
instanceIds :: NonEmpty Text
region :: Text
actionSubType :: ActionSubType
$sel:instanceIds:SsmActionDefinition' :: SsmActionDefinition -> NonEmpty Text
$sel:region:SsmActionDefinition' :: SsmActionDefinition -> Text
$sel:actionSubType:SsmActionDefinition' :: SsmActionDefinition -> ActionSubType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ActionSubType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ActionSubType
actionSubType),
            forall a. a -> Maybe a
Prelude.Just (Key
"Region" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
region),
            forall a. a -> Maybe a
Prelude.Just (Key
"InstanceIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
instanceIds)
          ]
      )