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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | 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 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,
    -- | The Amazon Web Services Regions targeted by the current Automation
    -- execution.
    TargetLocation -> Maybe (NonEmpty Text)
regions :: 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
  }
  deriving (TargetLocation -> TargetLocation -> Bool
(TargetLocation -> TargetLocation -> Bool)
-> (TargetLocation -> TargetLocation -> Bool) -> Eq TargetLocation
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]
(Int -> ReadS TargetLocation)
-> ReadS [TargetLocation]
-> ReadPrec TargetLocation
-> ReadPrec [TargetLocation]
-> Read 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
(Int -> TargetLocation -> ShowS)
-> (TargetLocation -> String)
-> ([TargetLocation] -> ShowS)
-> Show TargetLocation
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. TargetLocation -> Rep TargetLocation x)
-> (forall x. Rep TargetLocation x -> TargetLocation)
-> Generic TargetLocation
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.
--
-- '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.
--
-- 'regions', 'targetLocation_regions' - The Amazon Web Services Regions 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@.
newTargetLocation ::
  TargetLocation
newTargetLocation :: TargetLocation
newTargetLocation =
  TargetLocation' :: Maybe (NonEmpty Text)
-> Maybe Text
-> Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe Text
-> TargetLocation
TargetLocation'
    { $sel:accounts:TargetLocation' :: Maybe (NonEmpty Text)
accounts = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:targetLocationMaxConcurrency:TargetLocation' :: Maybe Text
targetLocationMaxConcurrency = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetLocationMaxErrors:TargetLocation' :: Maybe Text
targetLocationMaxErrors = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:regions:TargetLocation' :: Maybe (NonEmpty Text)
regions = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:executionRoleName:TargetLocation' :: Maybe Text
executionRoleName = Maybe Text
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 :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> TargetLocation -> f TargetLocation
targetLocation_accounts = (TargetLocation -> Maybe (NonEmpty Text))
-> (TargetLocation -> Maybe (NonEmpty Text) -> TargetLocation)
-> Lens
     TargetLocation
     TargetLocation
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> TargetLocation -> f TargetLocation)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> TargetLocation
-> f TargetLocation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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 AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> TargetLocation -> f TargetLocation
targetLocation_targetLocationMaxConcurrency = (TargetLocation -> Maybe Text)
-> (TargetLocation -> Maybe Text -> TargetLocation)
-> Lens TargetLocation TargetLocation (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> TargetLocation -> f TargetLocation
targetLocation_targetLocationMaxErrors = (TargetLocation -> Maybe Text)
-> (TargetLocation -> Maybe Text -> TargetLocation)
-> Lens TargetLocation TargetLocation (Maybe Text) (Maybe Text)
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)

-- | The Amazon Web Services Regions targeted by the current Automation
-- execution.
targetLocation_regions :: Lens.Lens' TargetLocation (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
targetLocation_regions :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> TargetLocation -> f TargetLocation
targetLocation_regions = (TargetLocation -> Maybe (NonEmpty Text))
-> (TargetLocation -> Maybe (NonEmpty Text) -> TargetLocation)
-> Lens
     TargetLocation
     TargetLocation
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> TargetLocation -> f TargetLocation)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> TargetLocation
-> f TargetLocation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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 AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
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 :: (Maybe Text -> f (Maybe Text))
-> TargetLocation -> f TargetLocation
targetLocation_executionRoleName = (TargetLocation -> Maybe Text)
-> (TargetLocation -> Maybe Text -> TargetLocation)
-> Lens TargetLocation TargetLocation (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON TargetLocation where
  parseJSON :: Value -> Parser TargetLocation
parseJSON =
    String
-> (Object -> Parser TargetLocation)
-> Value
-> Parser TargetLocation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TargetLocation"
      ( \Object
x ->
          Maybe (NonEmpty Text)
-> Maybe Text
-> Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe Text
-> TargetLocation
TargetLocation'
            (Maybe (NonEmpty Text)
 -> Maybe Text
 -> Maybe Text
 -> Maybe (NonEmpty Text)
 -> Maybe Text
 -> TargetLocation)
-> Parser (Maybe (NonEmpty Text))
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe (NonEmpty Text)
      -> Maybe Text
      -> TargetLocation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Accounts")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe (NonEmpty Text)
   -> Maybe Text
   -> TargetLocation)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe (NonEmpty Text) -> Maybe Text -> TargetLocation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TargetLocationMaxConcurrency")
            Parser
  (Maybe Text
   -> Maybe (NonEmpty Text) -> Maybe Text -> TargetLocation)
-> Parser (Maybe Text)
-> Parser (Maybe (NonEmpty Text) -> Maybe Text -> TargetLocation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TargetLocationMaxErrors")
            Parser (Maybe (NonEmpty Text) -> Maybe Text -> TargetLocation)
-> Parser (Maybe (NonEmpty Text))
-> Parser (Maybe Text -> TargetLocation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Regions")
            Parser (Maybe Text -> TargetLocation)
-> Parser (Maybe Text) -> Parser TargetLocation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ExecutionRoleName")
      )

instance Prelude.Hashable TargetLocation

instance Prelude.NFData TargetLocation

instance Core.ToJSON TargetLocation where
  toJSON :: TargetLocation -> Value
toJSON TargetLocation' {Maybe (NonEmpty Text)
Maybe Text
executionRoleName :: Maybe Text
regions :: Maybe (NonEmpty Text)
targetLocationMaxErrors :: Maybe Text
targetLocationMaxConcurrency :: Maybe Text
accounts :: Maybe (NonEmpty Text)
$sel:executionRoleName:TargetLocation' :: TargetLocation -> Maybe Text
$sel:regions:TargetLocation' :: TargetLocation -> Maybe (NonEmpty Text)
$sel:targetLocationMaxErrors:TargetLocation' :: TargetLocation -> Maybe Text
$sel:targetLocationMaxConcurrency:TargetLocation' :: TargetLocation -> Maybe Text
$sel:accounts:TargetLocation' :: TargetLocation -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Accounts" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
accounts,
            (Text
"TargetLocationMaxConcurrency" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
targetLocationMaxConcurrency,
            (Text
"TargetLocationMaxErrors" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
targetLocationMaxErrors,
            (Text
"Regions" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
regions,
            (Text
"ExecutionRoleName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
executionRoleName
          ]
      )