{-# 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.Definition
-- 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.Definition where

import Amazonka.Budgets.Types.IamActionDefinition
import Amazonka.Budgets.Types.ScpActionDefinition
import Amazonka.Budgets.Types.SsmActionDefinition
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies all of the type-specific parameters.
--
-- /See:/ 'newDefinition' smart constructor.
data Definition = Definition'
  { -- | The service control policies (SCPs) action definition details.
    Definition -> Maybe ScpActionDefinition
scpActionDefinition :: Prelude.Maybe ScpActionDefinition,
    -- | The AWS Identity and Access Management (IAM) action definition details.
    Definition -> Maybe IamActionDefinition
iamActionDefinition :: Prelude.Maybe IamActionDefinition,
    -- | The AWS Systems Manager (SSM) action definition details.
    Definition -> Maybe SsmActionDefinition
ssmActionDefinition :: Prelude.Maybe SsmActionDefinition
  }
  deriving (Definition -> Definition -> Bool
(Definition -> Definition -> Bool)
-> (Definition -> Definition -> Bool) -> Eq Definition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Definition -> Definition -> Bool
$c/= :: Definition -> Definition -> Bool
== :: Definition -> Definition -> Bool
$c== :: Definition -> Definition -> Bool
Prelude.Eq, ReadPrec [Definition]
ReadPrec Definition
Int -> ReadS Definition
ReadS [Definition]
(Int -> ReadS Definition)
-> ReadS [Definition]
-> ReadPrec Definition
-> ReadPrec [Definition]
-> Read Definition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Definition]
$creadListPrec :: ReadPrec [Definition]
readPrec :: ReadPrec Definition
$creadPrec :: ReadPrec Definition
readList :: ReadS [Definition]
$creadList :: ReadS [Definition]
readsPrec :: Int -> ReadS Definition
$creadsPrec :: Int -> ReadS Definition
Prelude.Read, Int -> Definition -> ShowS
[Definition] -> ShowS
Definition -> String
(Int -> Definition -> ShowS)
-> (Definition -> String)
-> ([Definition] -> ShowS)
-> Show Definition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Definition] -> ShowS
$cshowList :: [Definition] -> ShowS
show :: Definition -> String
$cshow :: Definition -> String
showsPrec :: Int -> Definition -> ShowS
$cshowsPrec :: Int -> Definition -> ShowS
Prelude.Show, (forall x. Definition -> Rep Definition x)
-> (forall x. Rep Definition x -> Definition) -> Generic Definition
forall x. Rep Definition x -> Definition
forall x. Definition -> Rep Definition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Definition x -> Definition
$cfrom :: forall x. Definition -> Rep Definition x
Prelude.Generic)

-- |
-- Create a value of 'Definition' 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:
--
-- 'scpActionDefinition', 'definition_scpActionDefinition' - The service control policies (SCPs) action definition details.
--
-- 'iamActionDefinition', 'definition_iamActionDefinition' - The AWS Identity and Access Management (IAM) action definition details.
--
-- 'ssmActionDefinition', 'definition_ssmActionDefinition' - The AWS Systems Manager (SSM) action definition details.
newDefinition ::
  Definition
newDefinition :: Definition
newDefinition =
  Definition' :: Maybe ScpActionDefinition
-> Maybe IamActionDefinition
-> Maybe SsmActionDefinition
-> Definition
Definition'
    { $sel:scpActionDefinition:Definition' :: Maybe ScpActionDefinition
scpActionDefinition = Maybe ScpActionDefinition
forall a. Maybe a
Prelude.Nothing,
      $sel:iamActionDefinition:Definition' :: Maybe IamActionDefinition
iamActionDefinition = Maybe IamActionDefinition
forall a. Maybe a
Prelude.Nothing,
      $sel:ssmActionDefinition:Definition' :: Maybe SsmActionDefinition
ssmActionDefinition = Maybe SsmActionDefinition
forall a. Maybe a
Prelude.Nothing
    }

-- | The service control policies (SCPs) action definition details.
definition_scpActionDefinition :: Lens.Lens' Definition (Prelude.Maybe ScpActionDefinition)
definition_scpActionDefinition :: (Maybe ScpActionDefinition -> f (Maybe ScpActionDefinition))
-> Definition -> f Definition
definition_scpActionDefinition = (Definition -> Maybe ScpActionDefinition)
-> (Definition -> Maybe ScpActionDefinition -> Definition)
-> Lens
     Definition
     Definition
     (Maybe ScpActionDefinition)
     (Maybe ScpActionDefinition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Definition' {Maybe ScpActionDefinition
scpActionDefinition :: Maybe ScpActionDefinition
$sel:scpActionDefinition:Definition' :: Definition -> Maybe ScpActionDefinition
scpActionDefinition} -> Maybe ScpActionDefinition
scpActionDefinition) (\s :: Definition
s@Definition' {} Maybe ScpActionDefinition
a -> Definition
s {$sel:scpActionDefinition:Definition' :: Maybe ScpActionDefinition
scpActionDefinition = Maybe ScpActionDefinition
a} :: Definition)

-- | The AWS Identity and Access Management (IAM) action definition details.
definition_iamActionDefinition :: Lens.Lens' Definition (Prelude.Maybe IamActionDefinition)
definition_iamActionDefinition :: (Maybe IamActionDefinition -> f (Maybe IamActionDefinition))
-> Definition -> f Definition
definition_iamActionDefinition = (Definition -> Maybe IamActionDefinition)
-> (Definition -> Maybe IamActionDefinition -> Definition)
-> Lens
     Definition
     Definition
     (Maybe IamActionDefinition)
     (Maybe IamActionDefinition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Definition' {Maybe IamActionDefinition
iamActionDefinition :: Maybe IamActionDefinition
$sel:iamActionDefinition:Definition' :: Definition -> Maybe IamActionDefinition
iamActionDefinition} -> Maybe IamActionDefinition
iamActionDefinition) (\s :: Definition
s@Definition' {} Maybe IamActionDefinition
a -> Definition
s {$sel:iamActionDefinition:Definition' :: Maybe IamActionDefinition
iamActionDefinition = Maybe IamActionDefinition
a} :: Definition)

-- | The AWS Systems Manager (SSM) action definition details.
definition_ssmActionDefinition :: Lens.Lens' Definition (Prelude.Maybe SsmActionDefinition)
definition_ssmActionDefinition :: (Maybe SsmActionDefinition -> f (Maybe SsmActionDefinition))
-> Definition -> f Definition
definition_ssmActionDefinition = (Definition -> Maybe SsmActionDefinition)
-> (Definition -> Maybe SsmActionDefinition -> Definition)
-> Lens
     Definition
     Definition
     (Maybe SsmActionDefinition)
     (Maybe SsmActionDefinition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Definition' {Maybe SsmActionDefinition
ssmActionDefinition :: Maybe SsmActionDefinition
$sel:ssmActionDefinition:Definition' :: Definition -> Maybe SsmActionDefinition
ssmActionDefinition} -> Maybe SsmActionDefinition
ssmActionDefinition) (\s :: Definition
s@Definition' {} Maybe SsmActionDefinition
a -> Definition
s {$sel:ssmActionDefinition:Definition' :: Maybe SsmActionDefinition
ssmActionDefinition = Maybe SsmActionDefinition
a} :: Definition)

instance Core.FromJSON Definition where
  parseJSON :: Value -> Parser Definition
parseJSON =
    String
-> (Object -> Parser Definition) -> Value -> Parser Definition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Definition"
      ( \Object
x ->
          Maybe ScpActionDefinition
-> Maybe IamActionDefinition
-> Maybe SsmActionDefinition
-> Definition
Definition'
            (Maybe ScpActionDefinition
 -> Maybe IamActionDefinition
 -> Maybe SsmActionDefinition
 -> Definition)
-> Parser (Maybe ScpActionDefinition)
-> Parser
     (Maybe IamActionDefinition
      -> Maybe SsmActionDefinition -> Definition)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ScpActionDefinition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ScpActionDefinition")
            Parser
  (Maybe IamActionDefinition
   -> Maybe SsmActionDefinition -> Definition)
-> Parser (Maybe IamActionDefinition)
-> Parser (Maybe SsmActionDefinition -> Definition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe IamActionDefinition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IamActionDefinition")
            Parser (Maybe SsmActionDefinition -> Definition)
-> Parser (Maybe SsmActionDefinition) -> Parser Definition
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SsmActionDefinition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SsmActionDefinition")
      )

instance Prelude.Hashable Definition

instance Prelude.NFData Definition

instance Core.ToJSON Definition where
  toJSON :: Definition -> Value
toJSON Definition' {Maybe IamActionDefinition
Maybe ScpActionDefinition
Maybe SsmActionDefinition
ssmActionDefinition :: Maybe SsmActionDefinition
iamActionDefinition :: Maybe IamActionDefinition
scpActionDefinition :: Maybe ScpActionDefinition
$sel:ssmActionDefinition:Definition' :: Definition -> Maybe SsmActionDefinition
$sel:iamActionDefinition:Definition' :: Definition -> Maybe IamActionDefinition
$sel:scpActionDefinition:Definition' :: Definition -> Maybe ScpActionDefinition
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ScpActionDefinition" Text -> ScpActionDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ScpActionDefinition -> Pair)
-> Maybe ScpActionDefinition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ScpActionDefinition
scpActionDefinition,
            (Text
"IamActionDefinition" Text -> IamActionDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (IamActionDefinition -> Pair)
-> Maybe IamActionDefinition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe IamActionDefinition
iamActionDefinition,
            (Text
"SsmActionDefinition" Text -> SsmActionDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SsmActionDefinition -> Pair)
-> Maybe SsmActionDefinition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SsmActionDefinition
ssmActionDefinition
          ]
      )