{-# 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.FIS.Types.ExperimentTemplateTarget
-- 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.FIS.Types.ExperimentTemplateTarget where

import qualified Amazonka.Core as Core
import Amazonka.FIS.Types.ExperimentTemplateTargetFilter
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a target for an experiment template.
--
-- /See:/ 'newExperimentTemplateTarget' smart constructor.
data ExperimentTemplateTarget = ExperimentTemplateTarget'
  { -- | The resource type.
    ExperimentTemplateTarget -> Maybe Text
resourceType :: Prelude.Maybe Prelude.Text,
    -- | The tags for the target resources.
    ExperimentTemplateTarget -> Maybe (HashMap Text Text)
resourceTags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The filters to apply to identify target resources using specific
    -- attributes.
    ExperimentTemplateTarget -> Maybe [ExperimentTemplateTargetFilter]
filters :: Prelude.Maybe [ExperimentTemplateTargetFilter],
    -- | The Amazon Resource Names (ARNs) of the targets.
    ExperimentTemplateTarget -> Maybe [Text]
resourceArns :: Prelude.Maybe [Prelude.Text],
    -- | Scopes the identified resources to a specific count or percentage.
    ExperimentTemplateTarget -> Maybe Text
selectionMode :: Prelude.Maybe Prelude.Text
  }
  deriving (ExperimentTemplateTarget -> ExperimentTemplateTarget -> Bool
(ExperimentTemplateTarget -> ExperimentTemplateTarget -> Bool)
-> (ExperimentTemplateTarget -> ExperimentTemplateTarget -> Bool)
-> Eq ExperimentTemplateTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExperimentTemplateTarget -> ExperimentTemplateTarget -> Bool
$c/= :: ExperimentTemplateTarget -> ExperimentTemplateTarget -> Bool
== :: ExperimentTemplateTarget -> ExperimentTemplateTarget -> Bool
$c== :: ExperimentTemplateTarget -> ExperimentTemplateTarget -> Bool
Prelude.Eq, ReadPrec [ExperimentTemplateTarget]
ReadPrec ExperimentTemplateTarget
Int -> ReadS ExperimentTemplateTarget
ReadS [ExperimentTemplateTarget]
(Int -> ReadS ExperimentTemplateTarget)
-> ReadS [ExperimentTemplateTarget]
-> ReadPrec ExperimentTemplateTarget
-> ReadPrec [ExperimentTemplateTarget]
-> Read ExperimentTemplateTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExperimentTemplateTarget]
$creadListPrec :: ReadPrec [ExperimentTemplateTarget]
readPrec :: ReadPrec ExperimentTemplateTarget
$creadPrec :: ReadPrec ExperimentTemplateTarget
readList :: ReadS [ExperimentTemplateTarget]
$creadList :: ReadS [ExperimentTemplateTarget]
readsPrec :: Int -> ReadS ExperimentTemplateTarget
$creadsPrec :: Int -> ReadS ExperimentTemplateTarget
Prelude.Read, Int -> ExperimentTemplateTarget -> ShowS
[ExperimentTemplateTarget] -> ShowS
ExperimentTemplateTarget -> String
(Int -> ExperimentTemplateTarget -> ShowS)
-> (ExperimentTemplateTarget -> String)
-> ([ExperimentTemplateTarget] -> ShowS)
-> Show ExperimentTemplateTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExperimentTemplateTarget] -> ShowS
$cshowList :: [ExperimentTemplateTarget] -> ShowS
show :: ExperimentTemplateTarget -> String
$cshow :: ExperimentTemplateTarget -> String
showsPrec :: Int -> ExperimentTemplateTarget -> ShowS
$cshowsPrec :: Int -> ExperimentTemplateTarget -> ShowS
Prelude.Show, (forall x.
 ExperimentTemplateTarget -> Rep ExperimentTemplateTarget x)
-> (forall x.
    Rep ExperimentTemplateTarget x -> ExperimentTemplateTarget)
-> Generic ExperimentTemplateTarget
forall x.
Rep ExperimentTemplateTarget x -> ExperimentTemplateTarget
forall x.
ExperimentTemplateTarget -> Rep ExperimentTemplateTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ExperimentTemplateTarget x -> ExperimentTemplateTarget
$cfrom :: forall x.
ExperimentTemplateTarget -> Rep ExperimentTemplateTarget x
Prelude.Generic)

-- |
-- Create a value of 'ExperimentTemplateTarget' 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:
--
-- 'resourceType', 'experimentTemplateTarget_resourceType' - The resource type.
--
-- 'resourceTags', 'experimentTemplateTarget_resourceTags' - The tags for the target resources.
--
-- 'filters', 'experimentTemplateTarget_filters' - The filters to apply to identify target resources using specific
-- attributes.
--
-- 'resourceArns', 'experimentTemplateTarget_resourceArns' - The Amazon Resource Names (ARNs) of the targets.
--
-- 'selectionMode', 'experimentTemplateTarget_selectionMode' - Scopes the identified resources to a specific count or percentage.
newExperimentTemplateTarget ::
  ExperimentTemplateTarget
newExperimentTemplateTarget :: ExperimentTemplateTarget
newExperimentTemplateTarget =
  ExperimentTemplateTarget' :: Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe [ExperimentTemplateTargetFilter]
-> Maybe [Text]
-> Maybe Text
-> ExperimentTemplateTarget
ExperimentTemplateTarget'
    { $sel:resourceType:ExperimentTemplateTarget' :: Maybe Text
resourceType =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceTags:ExperimentTemplateTarget' :: Maybe (HashMap Text Text)
resourceTags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:filters:ExperimentTemplateTarget' :: Maybe [ExperimentTemplateTargetFilter]
filters = Maybe [ExperimentTemplateTargetFilter]
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArns:ExperimentTemplateTarget' :: Maybe [Text]
resourceArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:selectionMode:ExperimentTemplateTarget' :: Maybe Text
selectionMode = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The resource type.
experimentTemplateTarget_resourceType :: Lens.Lens' ExperimentTemplateTarget (Prelude.Maybe Prelude.Text)
experimentTemplateTarget_resourceType :: (Maybe Text -> f (Maybe Text))
-> ExperimentTemplateTarget -> f ExperimentTemplateTarget
experimentTemplateTarget_resourceType = (ExperimentTemplateTarget -> Maybe Text)
-> (ExperimentTemplateTarget
    -> Maybe Text -> ExperimentTemplateTarget)
-> Lens
     ExperimentTemplateTarget
     ExperimentTemplateTarget
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentTemplateTarget' {Maybe Text
resourceType :: Maybe Text
$sel:resourceType:ExperimentTemplateTarget' :: ExperimentTemplateTarget -> Maybe Text
resourceType} -> Maybe Text
resourceType) (\s :: ExperimentTemplateTarget
s@ExperimentTemplateTarget' {} Maybe Text
a -> ExperimentTemplateTarget
s {$sel:resourceType:ExperimentTemplateTarget' :: Maybe Text
resourceType = Maybe Text
a} :: ExperimentTemplateTarget)

-- | The tags for the target resources.
experimentTemplateTarget_resourceTags :: Lens.Lens' ExperimentTemplateTarget (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
experimentTemplateTarget_resourceTags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ExperimentTemplateTarget -> f ExperimentTemplateTarget
experimentTemplateTarget_resourceTags = (ExperimentTemplateTarget -> Maybe (HashMap Text Text))
-> (ExperimentTemplateTarget
    -> Maybe (HashMap Text Text) -> ExperimentTemplateTarget)
-> Lens
     ExperimentTemplateTarget
     ExperimentTemplateTarget
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentTemplateTarget' {Maybe (HashMap Text Text)
resourceTags :: Maybe (HashMap Text Text)
$sel:resourceTags:ExperimentTemplateTarget' :: ExperimentTemplateTarget -> Maybe (HashMap Text Text)
resourceTags} -> Maybe (HashMap Text Text)
resourceTags) (\s :: ExperimentTemplateTarget
s@ExperimentTemplateTarget' {} Maybe (HashMap Text Text)
a -> ExperimentTemplateTarget
s {$sel:resourceTags:ExperimentTemplateTarget' :: Maybe (HashMap Text Text)
resourceTags = Maybe (HashMap Text Text)
a} :: ExperimentTemplateTarget) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ExperimentTemplateTarget -> f ExperimentTemplateTarget)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ExperimentTemplateTarget
-> f ExperimentTemplateTarget
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The filters to apply to identify target resources using specific
-- attributes.
experimentTemplateTarget_filters :: Lens.Lens' ExperimentTemplateTarget (Prelude.Maybe [ExperimentTemplateTargetFilter])
experimentTemplateTarget_filters :: (Maybe [ExperimentTemplateTargetFilter]
 -> f (Maybe [ExperimentTemplateTargetFilter]))
-> ExperimentTemplateTarget -> f ExperimentTemplateTarget
experimentTemplateTarget_filters = (ExperimentTemplateTarget
 -> Maybe [ExperimentTemplateTargetFilter])
-> (ExperimentTemplateTarget
    -> Maybe [ExperimentTemplateTargetFilter]
    -> ExperimentTemplateTarget)
-> Lens
     ExperimentTemplateTarget
     ExperimentTemplateTarget
     (Maybe [ExperimentTemplateTargetFilter])
     (Maybe [ExperimentTemplateTargetFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentTemplateTarget' {Maybe [ExperimentTemplateTargetFilter]
filters :: Maybe [ExperimentTemplateTargetFilter]
$sel:filters:ExperimentTemplateTarget' :: ExperimentTemplateTarget -> Maybe [ExperimentTemplateTargetFilter]
filters} -> Maybe [ExperimentTemplateTargetFilter]
filters) (\s :: ExperimentTemplateTarget
s@ExperimentTemplateTarget' {} Maybe [ExperimentTemplateTargetFilter]
a -> ExperimentTemplateTarget
s {$sel:filters:ExperimentTemplateTarget' :: Maybe [ExperimentTemplateTargetFilter]
filters = Maybe [ExperimentTemplateTargetFilter]
a} :: ExperimentTemplateTarget) ((Maybe [ExperimentTemplateTargetFilter]
  -> f (Maybe [ExperimentTemplateTargetFilter]))
 -> ExperimentTemplateTarget -> f ExperimentTemplateTarget)
-> ((Maybe [ExperimentTemplateTargetFilter]
     -> f (Maybe [ExperimentTemplateTargetFilter]))
    -> Maybe [ExperimentTemplateTargetFilter]
    -> f (Maybe [ExperimentTemplateTargetFilter]))
-> (Maybe [ExperimentTemplateTargetFilter]
    -> f (Maybe [ExperimentTemplateTargetFilter]))
-> ExperimentTemplateTarget
-> f ExperimentTemplateTarget
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ExperimentTemplateTargetFilter]
  [ExperimentTemplateTargetFilter]
  [ExperimentTemplateTargetFilter]
  [ExperimentTemplateTargetFilter]
-> Iso
     (Maybe [ExperimentTemplateTargetFilter])
     (Maybe [ExperimentTemplateTargetFilter])
     (Maybe [ExperimentTemplateTargetFilter])
     (Maybe [ExperimentTemplateTargetFilter])
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
  [ExperimentTemplateTargetFilter]
  [ExperimentTemplateTargetFilter]
  [ExperimentTemplateTargetFilter]
  [ExperimentTemplateTargetFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Names (ARNs) of the targets.
experimentTemplateTarget_resourceArns :: Lens.Lens' ExperimentTemplateTarget (Prelude.Maybe [Prelude.Text])
experimentTemplateTarget_resourceArns :: (Maybe [Text] -> f (Maybe [Text]))
-> ExperimentTemplateTarget -> f ExperimentTemplateTarget
experimentTemplateTarget_resourceArns = (ExperimentTemplateTarget -> Maybe [Text])
-> (ExperimentTemplateTarget
    -> Maybe [Text] -> ExperimentTemplateTarget)
-> Lens
     ExperimentTemplateTarget
     ExperimentTemplateTarget
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentTemplateTarget' {Maybe [Text]
resourceArns :: Maybe [Text]
$sel:resourceArns:ExperimentTemplateTarget' :: ExperimentTemplateTarget -> Maybe [Text]
resourceArns} -> Maybe [Text]
resourceArns) (\s :: ExperimentTemplateTarget
s@ExperimentTemplateTarget' {} Maybe [Text]
a -> ExperimentTemplateTarget
s {$sel:resourceArns:ExperimentTemplateTarget' :: Maybe [Text]
resourceArns = Maybe [Text]
a} :: ExperimentTemplateTarget) ((Maybe [Text] -> f (Maybe [Text]))
 -> ExperimentTemplateTarget -> f ExperimentTemplateTarget)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ExperimentTemplateTarget
-> f ExperimentTemplateTarget
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Scopes the identified resources to a specific count or percentage.
experimentTemplateTarget_selectionMode :: Lens.Lens' ExperimentTemplateTarget (Prelude.Maybe Prelude.Text)
experimentTemplateTarget_selectionMode :: (Maybe Text -> f (Maybe Text))
-> ExperimentTemplateTarget -> f ExperimentTemplateTarget
experimentTemplateTarget_selectionMode = (ExperimentTemplateTarget -> Maybe Text)
-> (ExperimentTemplateTarget
    -> Maybe Text -> ExperimentTemplateTarget)
-> Lens
     ExperimentTemplateTarget
     ExperimentTemplateTarget
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentTemplateTarget' {Maybe Text
selectionMode :: Maybe Text
$sel:selectionMode:ExperimentTemplateTarget' :: ExperimentTemplateTarget -> Maybe Text
selectionMode} -> Maybe Text
selectionMode) (\s :: ExperimentTemplateTarget
s@ExperimentTemplateTarget' {} Maybe Text
a -> ExperimentTemplateTarget
s {$sel:selectionMode:ExperimentTemplateTarget' :: Maybe Text
selectionMode = Maybe Text
a} :: ExperimentTemplateTarget)

instance Core.FromJSON ExperimentTemplateTarget where
  parseJSON :: Value -> Parser ExperimentTemplateTarget
parseJSON =
    String
-> (Object -> Parser ExperimentTemplateTarget)
-> Value
-> Parser ExperimentTemplateTarget
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExperimentTemplateTarget"
      ( \Object
x ->
          Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe [ExperimentTemplateTargetFilter]
-> Maybe [Text]
-> Maybe Text
-> ExperimentTemplateTarget
ExperimentTemplateTarget'
            (Maybe Text
 -> Maybe (HashMap Text Text)
 -> Maybe [ExperimentTemplateTargetFilter]
 -> Maybe [Text]
 -> Maybe Text
 -> ExperimentTemplateTarget)
-> Parser (Maybe Text)
-> Parser
     (Maybe (HashMap Text Text)
      -> Maybe [ExperimentTemplateTargetFilter]
      -> Maybe [Text]
      -> Maybe Text
      -> ExperimentTemplateTarget)
forall (f :: * -> *) a b. Functor 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
"resourceType")
            Parser
  (Maybe (HashMap Text Text)
   -> Maybe [ExperimentTemplateTargetFilter]
   -> Maybe [Text]
   -> Maybe Text
   -> ExperimentTemplateTarget)
-> Parser (Maybe (HashMap Text Text))
-> Parser
     (Maybe [ExperimentTemplateTargetFilter]
      -> Maybe [Text] -> Maybe Text -> ExperimentTemplateTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"resourceTags" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe [ExperimentTemplateTargetFilter]
   -> Maybe [Text] -> Maybe Text -> ExperimentTemplateTarget)
-> Parser (Maybe [ExperimentTemplateTargetFilter])
-> Parser (Maybe [Text] -> Maybe Text -> ExperimentTemplateTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe (Maybe [ExperimentTemplateTargetFilter]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"filters" Parser (Maybe (Maybe [ExperimentTemplateTargetFilter]))
-> Maybe [ExperimentTemplateTargetFilter]
-> Parser (Maybe [ExperimentTemplateTargetFilter])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ExperimentTemplateTargetFilter]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [Text] -> Maybe Text -> ExperimentTemplateTarget)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> ExperimentTemplateTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"resourceArns" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> ExperimentTemplateTarget)
-> Parser (Maybe Text) -> Parser ExperimentTemplateTarget
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
"selectionMode")
      )

instance Prelude.Hashable ExperimentTemplateTarget

instance Prelude.NFData ExperimentTemplateTarget