{-# 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.SSM.Types.TargetLocation
-- 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.SSM.Types.TargetLocation 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.SSM.Types.AlarmConfiguration

-- | The combination of Amazon Web Services Regions and Amazon Web Services
-- accounts targeted by the current Automation execution.
--
-- /See:/ 'newTargetLocation' smart constructor.
data TargetLocation = TargetLocation'
  { -- | The Amazon Web Services accounts targeted by the current Automation
    -- execution.
    TargetLocation -> Maybe (NonEmpty Text)
accounts :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The Automation execution role used by the currently running Automation.
    -- If not specified, the default value is
    -- @AWS-SystemsManager-AutomationExecutionRole@.
    TargetLocation -> Maybe Text
executionRoleName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services Regions targeted by the current Automation
    -- execution.
    TargetLocation -> Maybe (NonEmpty Text)
regions :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    TargetLocation -> Maybe AlarmConfiguration
targetLocationAlarmConfiguration :: Prelude.Maybe AlarmConfiguration,
    -- | The maximum number of Amazon Web Services Regions and Amazon Web
    -- Services accounts allowed to run the Automation concurrently.
    TargetLocation -> Maybe Text
targetLocationMaxConcurrency :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of errors allowed before the system stops queueing
    -- additional Automation executions for the currently running Automation.
    TargetLocation -> Maybe Text
targetLocationMaxErrors :: Prelude.Maybe Prelude.Text
  }
  deriving (TargetLocation -> TargetLocation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetLocation -> TargetLocation -> Bool
$c/= :: TargetLocation -> TargetLocation -> Bool
== :: TargetLocation -> TargetLocation -> Bool
$c== :: TargetLocation -> TargetLocation -> Bool
Prelude.Eq, ReadPrec [TargetLocation]
ReadPrec TargetLocation
Int -> ReadS TargetLocation
ReadS [TargetLocation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TargetLocation]
$creadListPrec :: ReadPrec [TargetLocation]
readPrec :: ReadPrec TargetLocation
$creadPrec :: ReadPrec TargetLocation
readList :: ReadS [TargetLocation]
$creadList :: ReadS [TargetLocation]
readsPrec :: Int -> ReadS TargetLocation
$creadsPrec :: Int -> ReadS TargetLocation
Prelude.Read, Int -> TargetLocation -> ShowS
[TargetLocation] -> ShowS
TargetLocation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetLocation] -> ShowS
$cshowList :: [TargetLocation] -> ShowS
show :: TargetLocation -> String
$cshow :: TargetLocation -> String
showsPrec :: Int -> TargetLocation -> ShowS
$cshowsPrec :: Int -> TargetLocation -> ShowS
Prelude.Show, forall x. Rep TargetLocation x -> TargetLocation
forall x. TargetLocation -> Rep TargetLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TargetLocation x -> TargetLocation
$cfrom :: forall x. TargetLocation -> Rep TargetLocation x
Prelude.Generic)

-- |
-- Create a value of 'TargetLocation' 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:
--
-- 'accounts', 'targetLocation_accounts' - The Amazon Web Services accounts targeted by the current Automation
-- execution.
--
-- 'executionRoleName', 'targetLocation_executionRoleName' - The Automation execution role used by the currently running Automation.
-- If not specified, the default value is
-- @AWS-SystemsManager-AutomationExecutionRole@.
--
-- 'regions', 'targetLocation_regions' - The Amazon Web Services Regions targeted by the current Automation
-- execution.
--
-- 'targetLocationAlarmConfiguration', 'targetLocation_targetLocationAlarmConfiguration' - Undocumented member.
--
-- 'targetLocationMaxConcurrency', 'targetLocation_targetLocationMaxConcurrency' - The maximum number of Amazon Web Services Regions and Amazon Web
-- Services accounts allowed to run the Automation concurrently.
--
-- 'targetLocationMaxErrors', 'targetLocation_targetLocationMaxErrors' - The maximum number of errors allowed before the system stops queueing
-- additional Automation executions for the currently running Automation.
newTargetLocation ::
  TargetLocation
newTargetLocation :: TargetLocation
newTargetLocation =
  TargetLocation'
    { $sel:accounts:TargetLocation' :: Maybe (NonEmpty Text)
accounts = forall a. Maybe a
Prelude.Nothing,
      $sel:executionRoleName:TargetLocation' :: Maybe Text
executionRoleName = forall a. Maybe a
Prelude.Nothing,
      $sel:regions:TargetLocation' :: Maybe (NonEmpty Text)
regions = forall a. Maybe a
Prelude.Nothing,
      $sel:targetLocationAlarmConfiguration:TargetLocation' :: Maybe AlarmConfiguration
targetLocationAlarmConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:targetLocationMaxConcurrency:TargetLocation' :: Maybe Text
targetLocationMaxConcurrency = forall a. Maybe a
Prelude.Nothing,
      $sel:targetLocationMaxErrors:TargetLocation' :: Maybe Text
targetLocationMaxErrors = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Web Services accounts targeted by the current Automation
-- execution.
targetLocation_accounts :: Lens.Lens' TargetLocation (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
targetLocation_accounts :: Lens' TargetLocation (Maybe (NonEmpty Text))
targetLocation_accounts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetLocation' {Maybe (NonEmpty Text)
accounts :: Maybe (NonEmpty Text)
$sel:accounts:TargetLocation' :: TargetLocation -> Maybe (NonEmpty Text)
accounts} -> Maybe (NonEmpty Text)
accounts) (\s :: TargetLocation
s@TargetLocation' {} Maybe (NonEmpty Text)
a -> TargetLocation
s {$sel:accounts:TargetLocation' :: Maybe (NonEmpty Text)
accounts = Maybe (NonEmpty Text)
a} :: TargetLocation) 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 Automation execution role used by the currently running Automation.
-- If not specified, the default value is
-- @AWS-SystemsManager-AutomationExecutionRole@.
targetLocation_executionRoleName :: Lens.Lens' TargetLocation (Prelude.Maybe Prelude.Text)
targetLocation_executionRoleName :: Lens' TargetLocation (Maybe Text)
targetLocation_executionRoleName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetLocation' {Maybe Text
executionRoleName :: Maybe Text
$sel:executionRoleName:TargetLocation' :: TargetLocation -> Maybe Text
executionRoleName} -> Maybe Text
executionRoleName) (\s :: TargetLocation
s@TargetLocation' {} Maybe Text
a -> TargetLocation
s {$sel:executionRoleName:TargetLocation' :: Maybe Text
executionRoleName = Maybe Text
a} :: TargetLocation)

-- | The Amazon Web Services Regions targeted by the current Automation
-- execution.
targetLocation_regions :: Lens.Lens' TargetLocation (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
targetLocation_regions :: Lens' TargetLocation (Maybe (NonEmpty Text))
targetLocation_regions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetLocation' {Maybe (NonEmpty Text)
regions :: Maybe (NonEmpty Text)
$sel:regions:TargetLocation' :: TargetLocation -> Maybe (NonEmpty Text)
regions} -> Maybe (NonEmpty Text)
regions) (\s :: TargetLocation
s@TargetLocation' {} Maybe (NonEmpty Text)
a -> TargetLocation
s {$sel:regions:TargetLocation' :: Maybe (NonEmpty Text)
regions = Maybe (NonEmpty Text)
a} :: TargetLocation) 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

-- | Undocumented member.
targetLocation_targetLocationAlarmConfiguration :: Lens.Lens' TargetLocation (Prelude.Maybe AlarmConfiguration)
targetLocation_targetLocationAlarmConfiguration :: Lens' TargetLocation (Maybe AlarmConfiguration)
targetLocation_targetLocationAlarmConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetLocation' {Maybe AlarmConfiguration
targetLocationAlarmConfiguration :: Maybe AlarmConfiguration
$sel:targetLocationAlarmConfiguration:TargetLocation' :: TargetLocation -> Maybe AlarmConfiguration
targetLocationAlarmConfiguration} -> Maybe AlarmConfiguration
targetLocationAlarmConfiguration) (\s :: TargetLocation
s@TargetLocation' {} Maybe AlarmConfiguration
a -> TargetLocation
s {$sel:targetLocationAlarmConfiguration:TargetLocation' :: Maybe AlarmConfiguration
targetLocationAlarmConfiguration = Maybe AlarmConfiguration
a} :: TargetLocation)

-- | The maximum number of Amazon Web Services Regions and Amazon Web
-- Services accounts allowed to run the Automation concurrently.
targetLocation_targetLocationMaxConcurrency :: Lens.Lens' TargetLocation (Prelude.Maybe Prelude.Text)
targetLocation_targetLocationMaxConcurrency :: Lens' TargetLocation (Maybe Text)
targetLocation_targetLocationMaxConcurrency = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetLocation' {Maybe Text
targetLocationMaxConcurrency :: Maybe Text
$sel:targetLocationMaxConcurrency:TargetLocation' :: TargetLocation -> Maybe Text
targetLocationMaxConcurrency} -> Maybe Text
targetLocationMaxConcurrency) (\s :: TargetLocation
s@TargetLocation' {} Maybe Text
a -> TargetLocation
s {$sel:targetLocationMaxConcurrency:TargetLocation' :: Maybe Text
targetLocationMaxConcurrency = Maybe Text
a} :: TargetLocation)

-- | The maximum number of errors allowed before the system stops queueing
-- additional Automation executions for the currently running Automation.
targetLocation_targetLocationMaxErrors :: Lens.Lens' TargetLocation (Prelude.Maybe Prelude.Text)
targetLocation_targetLocationMaxErrors :: Lens' TargetLocation (Maybe Text)
targetLocation_targetLocationMaxErrors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetLocation' {Maybe Text
targetLocationMaxErrors :: Maybe Text
$sel:targetLocationMaxErrors:TargetLocation' :: TargetLocation -> Maybe Text
targetLocationMaxErrors} -> Maybe Text
targetLocationMaxErrors) (\s :: TargetLocation
s@TargetLocation' {} Maybe Text
a -> TargetLocation
s {$sel:targetLocationMaxErrors:TargetLocation' :: Maybe Text
targetLocationMaxErrors = Maybe Text
a} :: TargetLocation)

instance Data.FromJSON TargetLocation where
  parseJSON :: Value -> Parser TargetLocation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TargetLocation"
      ( \Object
x ->
          Maybe (NonEmpty Text)
-> Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe AlarmConfiguration
-> Maybe Text
-> Maybe Text
-> TargetLocation
TargetLocation'
            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
"Accounts")
            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
"ExecutionRoleName")
            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
"Regions")
            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
"TargetLocationAlarmConfiguration")
            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
"TargetLocationMaxConcurrency")
            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
"TargetLocationMaxErrors")
      )

instance Prelude.Hashable TargetLocation where
  hashWithSalt :: Int -> TargetLocation -> Int
hashWithSalt Int
_salt TargetLocation' {Maybe (NonEmpty Text)
Maybe Text
Maybe AlarmConfiguration
targetLocationMaxErrors :: Maybe Text
targetLocationMaxConcurrency :: Maybe Text
targetLocationAlarmConfiguration :: Maybe AlarmConfiguration
regions :: Maybe (NonEmpty Text)
executionRoleName :: Maybe Text
accounts :: Maybe (NonEmpty Text)
$sel:targetLocationMaxErrors:TargetLocation' :: TargetLocation -> Maybe Text
$sel:targetLocationMaxConcurrency:TargetLocation' :: TargetLocation -> Maybe Text
$sel:targetLocationAlarmConfiguration:TargetLocation' :: TargetLocation -> Maybe AlarmConfiguration
$sel:regions:TargetLocation' :: TargetLocation -> Maybe (NonEmpty Text)
$sel:executionRoleName:TargetLocation' :: TargetLocation -> Maybe Text
$sel:accounts:TargetLocation' :: TargetLocation -> Maybe (NonEmpty Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
accounts
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
executionRoleName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
regions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AlarmConfiguration
targetLocationAlarmConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
targetLocationMaxConcurrency
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
targetLocationMaxErrors

instance Prelude.NFData TargetLocation where
  rnf :: TargetLocation -> ()
rnf TargetLocation' {Maybe (NonEmpty Text)
Maybe Text
Maybe AlarmConfiguration
targetLocationMaxErrors :: Maybe Text
targetLocationMaxConcurrency :: Maybe Text
targetLocationAlarmConfiguration :: Maybe AlarmConfiguration
regions :: Maybe (NonEmpty Text)
executionRoleName :: Maybe Text
accounts :: Maybe (NonEmpty Text)
$sel:targetLocationMaxErrors:TargetLocation' :: TargetLocation -> Maybe Text
$sel:targetLocationMaxConcurrency:TargetLocation' :: TargetLocation -> Maybe Text
$sel:targetLocationAlarmConfiguration:TargetLocation' :: TargetLocation -> Maybe AlarmConfiguration
$sel:regions:TargetLocation' :: TargetLocation -> Maybe (NonEmpty Text)
$sel:executionRoleName:TargetLocation' :: TargetLocation -> Maybe Text
$sel:accounts:TargetLocation' :: TargetLocation -> Maybe (NonEmpty Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
accounts
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
executionRoleName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
regions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AlarmConfiguration
targetLocationAlarmConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
targetLocationMaxConcurrency
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
targetLocationMaxErrors

instance Data.ToJSON TargetLocation where
  toJSON :: TargetLocation -> Value
toJSON TargetLocation' {Maybe (NonEmpty Text)
Maybe Text
Maybe AlarmConfiguration
targetLocationMaxErrors :: Maybe Text
targetLocationMaxConcurrency :: Maybe Text
targetLocationAlarmConfiguration :: Maybe AlarmConfiguration
regions :: Maybe (NonEmpty Text)
executionRoleName :: Maybe Text
accounts :: Maybe (NonEmpty Text)
$sel:targetLocationMaxErrors:TargetLocation' :: TargetLocation -> Maybe Text
$sel:targetLocationMaxConcurrency:TargetLocation' :: TargetLocation -> Maybe Text
$sel:targetLocationAlarmConfiguration:TargetLocation' :: TargetLocation -> Maybe AlarmConfiguration
$sel:regions:TargetLocation' :: TargetLocation -> Maybe (NonEmpty Text)
$sel:executionRoleName:TargetLocation' :: TargetLocation -> Maybe Text
$sel:accounts:TargetLocation' :: TargetLocation -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Accounts" 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 (NonEmpty Text)
accounts,
            (Key
"ExecutionRoleName" 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
executionRoleName,
            (Key
"Regions" 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 (NonEmpty Text)
regions,
            (Key
"TargetLocationAlarmConfiguration" 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 AlarmConfiguration
targetLocationAlarmConfiguration,
            (Key
"TargetLocationMaxConcurrency" 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
targetLocationMaxConcurrency,
            (Key
"TargetLocationMaxErrors" 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
targetLocationMaxErrors
          ]
      )