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

import Amazonka.Budgets.Types.ActionSubType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The AWS 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
(SsmActionDefinition -> SsmActionDefinition -> Bool)
-> (SsmActionDefinition -> SsmActionDefinition -> Bool)
-> Eq SsmActionDefinition
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]
(Int -> ReadS SsmActionDefinition)
-> ReadS [SsmActionDefinition]
-> ReadPrec SsmActionDefinition
-> ReadPrec [SsmActionDefinition]
-> Read 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
(Int -> SsmActionDefinition -> ShowS)
-> (SsmActionDefinition -> String)
-> ([SsmActionDefinition] -> ShowS)
-> Show SsmActionDefinition
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. SsmActionDefinition -> Rep SsmActionDefinition x)
-> (forall x. Rep SsmActionDefinition x -> SsmActionDefinition)
-> Generic SsmActionDefinition
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' :: ActionSubType -> Text -> NonEmpty Text -> SsmActionDefinition
SsmActionDefinition'
      { $sel:actionSubType:SsmActionDefinition' :: ActionSubType
actionSubType =
          ActionSubType
pActionSubType_,
        $sel:region:SsmActionDefinition' :: Text
region = Text
pRegion_,
        $sel:instanceIds:SsmActionDefinition' :: NonEmpty Text
instanceIds = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pInstanceIds_
      }

-- | The action subType.
ssmActionDefinition_actionSubType :: Lens.Lens' SsmActionDefinition ActionSubType
ssmActionDefinition_actionSubType :: (ActionSubType -> f ActionSubType)
-> SsmActionDefinition -> f SsmActionDefinition
ssmActionDefinition_actionSubType = (SsmActionDefinition -> ActionSubType)
-> (SsmActionDefinition -> ActionSubType -> SsmActionDefinition)
-> Lens
     SsmActionDefinition SsmActionDefinition ActionSubType 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 :: (Text -> f Text) -> SsmActionDefinition -> f SsmActionDefinition
ssmActionDefinition_region = (SsmActionDefinition -> Text)
-> (SsmActionDefinition -> Text -> SsmActionDefinition)
-> Lens SsmActionDefinition SsmActionDefinition Text Text
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 :: (NonEmpty Text -> f (NonEmpty Text))
-> SsmActionDefinition -> f SsmActionDefinition
ssmActionDefinition_instanceIds = (SsmActionDefinition -> NonEmpty Text)
-> (SsmActionDefinition -> NonEmpty Text -> SsmActionDefinition)
-> Lens
     SsmActionDefinition
     SsmActionDefinition
     (NonEmpty Text)
     (NonEmpty Text)
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) ((NonEmpty Text -> f (NonEmpty Text))
 -> SsmActionDefinition -> f SsmActionDefinition)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> SsmActionDefinition
-> f SsmActionDefinition
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable SsmActionDefinition

instance Prelude.NFData SsmActionDefinition

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ActionSubType" Text -> ActionSubType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ActionSubType
actionSubType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Region" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
region),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"InstanceIds" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
instanceIds)
          ]
      )