{-# 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.Synthetics.Types.CanaryRunConfigInput
-- 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.Synthetics.Types.CanaryRunConfigInput where

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

-- | A structure that contains input information for a canary run.
--
-- /See:/ 'newCanaryRunConfigInput' smart constructor.
data CanaryRunConfigInput = CanaryRunConfigInput'
  { -- | How long the canary is allowed to run before it must stop. You can\'t
    -- set this time to be longer than the frequency of the runs of this
    -- canary.
    --
    -- If you omit this field, the frequency of the canary is used as this
    -- value, up to a maximum of 14 minutes.
    CanaryRunConfigInput -> Maybe Natural
timeoutInSeconds :: Prelude.Maybe Prelude.Natural,
    -- | Specifies the keys and values to use for any environment variables used
    -- in the canary script. Use the following format:
    --
    -- { \"key1\" : \"value1\", \"key2\" : \"value2\", ...}
    --
    -- Keys must start with a letter and be at least two characters. The total
    -- size of your environment variables cannot exceed 4 KB. You can\'t
    -- specify any Lambda reserved environment variables as the keys for your
    -- environment variables. For more information about reserved keys, see
    -- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime Runtime environment variables>.
    CanaryRunConfigInput -> Maybe (HashMap Text Text)
environmentVariables :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Specifies whether this canary is to use active X-Ray tracing when it
    -- runs. Active tracing enables this canary run to be displayed in the
    -- ServiceLens and X-Ray service maps even if the canary does not hit an
    -- endpoint that has X-Ray tracing enabled. Using X-Ray tracing incurs
    -- charges. For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_tracing.html Canaries and X-Ray tracing>.
    --
    -- You can enable active tracing only for canaries that use version
    -- @syn-nodejs-2.0@ or later for their canary runtime.
    CanaryRunConfigInput -> Maybe Bool
activeTracing :: Prelude.Maybe Prelude.Bool,
    -- | The maximum amount of memory available to the canary while it is
    -- running, in MB. This value must be a multiple of 64.
    CanaryRunConfigInput -> Maybe Natural
memoryInMB :: Prelude.Maybe Prelude.Natural
  }
  deriving (CanaryRunConfigInput -> CanaryRunConfigInput -> Bool
(CanaryRunConfigInput -> CanaryRunConfigInput -> Bool)
-> (CanaryRunConfigInput -> CanaryRunConfigInput -> Bool)
-> Eq CanaryRunConfigInput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CanaryRunConfigInput -> CanaryRunConfigInput -> Bool
$c/= :: CanaryRunConfigInput -> CanaryRunConfigInput -> Bool
== :: CanaryRunConfigInput -> CanaryRunConfigInput -> Bool
$c== :: CanaryRunConfigInput -> CanaryRunConfigInput -> Bool
Prelude.Eq, ReadPrec [CanaryRunConfigInput]
ReadPrec CanaryRunConfigInput
Int -> ReadS CanaryRunConfigInput
ReadS [CanaryRunConfigInput]
(Int -> ReadS CanaryRunConfigInput)
-> ReadS [CanaryRunConfigInput]
-> ReadPrec CanaryRunConfigInput
-> ReadPrec [CanaryRunConfigInput]
-> Read CanaryRunConfigInput
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CanaryRunConfigInput]
$creadListPrec :: ReadPrec [CanaryRunConfigInput]
readPrec :: ReadPrec CanaryRunConfigInput
$creadPrec :: ReadPrec CanaryRunConfigInput
readList :: ReadS [CanaryRunConfigInput]
$creadList :: ReadS [CanaryRunConfigInput]
readsPrec :: Int -> ReadS CanaryRunConfigInput
$creadsPrec :: Int -> ReadS CanaryRunConfigInput
Prelude.Read, Int -> CanaryRunConfigInput -> ShowS
[CanaryRunConfigInput] -> ShowS
CanaryRunConfigInput -> String
(Int -> CanaryRunConfigInput -> ShowS)
-> (CanaryRunConfigInput -> String)
-> ([CanaryRunConfigInput] -> ShowS)
-> Show CanaryRunConfigInput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CanaryRunConfigInput] -> ShowS
$cshowList :: [CanaryRunConfigInput] -> ShowS
show :: CanaryRunConfigInput -> String
$cshow :: CanaryRunConfigInput -> String
showsPrec :: Int -> CanaryRunConfigInput -> ShowS
$cshowsPrec :: Int -> CanaryRunConfigInput -> ShowS
Prelude.Show, (forall x. CanaryRunConfigInput -> Rep CanaryRunConfigInput x)
-> (forall x. Rep CanaryRunConfigInput x -> CanaryRunConfigInput)
-> Generic CanaryRunConfigInput
forall x. Rep CanaryRunConfigInput x -> CanaryRunConfigInput
forall x. CanaryRunConfigInput -> Rep CanaryRunConfigInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CanaryRunConfigInput x -> CanaryRunConfigInput
$cfrom :: forall x. CanaryRunConfigInput -> Rep CanaryRunConfigInput x
Prelude.Generic)

-- |
-- Create a value of 'CanaryRunConfigInput' 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:
--
-- 'timeoutInSeconds', 'canaryRunConfigInput_timeoutInSeconds' - How long the canary is allowed to run before it must stop. You can\'t
-- set this time to be longer than the frequency of the runs of this
-- canary.
--
-- If you omit this field, the frequency of the canary is used as this
-- value, up to a maximum of 14 minutes.
--
-- 'environmentVariables', 'canaryRunConfigInput_environmentVariables' - Specifies the keys and values to use for any environment variables used
-- in the canary script. Use the following format:
--
-- { \"key1\" : \"value1\", \"key2\" : \"value2\", ...}
--
-- Keys must start with a letter and be at least two characters. The total
-- size of your environment variables cannot exceed 4 KB. You can\'t
-- specify any Lambda reserved environment variables as the keys for your
-- environment variables. For more information about reserved keys, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime Runtime environment variables>.
--
-- 'activeTracing', 'canaryRunConfigInput_activeTracing' - Specifies whether this canary is to use active X-Ray tracing when it
-- runs. Active tracing enables this canary run to be displayed in the
-- ServiceLens and X-Ray service maps even if the canary does not hit an
-- endpoint that has X-Ray tracing enabled. Using X-Ray tracing incurs
-- charges. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_tracing.html Canaries and X-Ray tracing>.
--
-- You can enable active tracing only for canaries that use version
-- @syn-nodejs-2.0@ or later for their canary runtime.
--
-- 'memoryInMB', 'canaryRunConfigInput_memoryInMB' - The maximum amount of memory available to the canary while it is
-- running, in MB. This value must be a multiple of 64.
newCanaryRunConfigInput ::
  CanaryRunConfigInput
newCanaryRunConfigInput :: CanaryRunConfigInput
newCanaryRunConfigInput =
  CanaryRunConfigInput' :: Maybe Natural
-> Maybe (HashMap Text Text)
-> Maybe Bool
-> Maybe Natural
-> CanaryRunConfigInput
CanaryRunConfigInput'
    { $sel:timeoutInSeconds:CanaryRunConfigInput' :: Maybe Natural
timeoutInSeconds =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:environmentVariables:CanaryRunConfigInput' :: Maybe (HashMap Text Text)
environmentVariables = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:activeTracing:CanaryRunConfigInput' :: Maybe Bool
activeTracing = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:memoryInMB:CanaryRunConfigInput' :: Maybe Natural
memoryInMB = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | How long the canary is allowed to run before it must stop. You can\'t
-- set this time to be longer than the frequency of the runs of this
-- canary.
--
-- If you omit this field, the frequency of the canary is used as this
-- value, up to a maximum of 14 minutes.
canaryRunConfigInput_timeoutInSeconds :: Lens.Lens' CanaryRunConfigInput (Prelude.Maybe Prelude.Natural)
canaryRunConfigInput_timeoutInSeconds :: (Maybe Natural -> f (Maybe Natural))
-> CanaryRunConfigInput -> f CanaryRunConfigInput
canaryRunConfigInput_timeoutInSeconds = (CanaryRunConfigInput -> Maybe Natural)
-> (CanaryRunConfigInput -> Maybe Natural -> CanaryRunConfigInput)
-> Lens
     CanaryRunConfigInput
     CanaryRunConfigInput
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanaryRunConfigInput' {Maybe Natural
timeoutInSeconds :: Maybe Natural
$sel:timeoutInSeconds:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Natural
timeoutInSeconds} -> Maybe Natural
timeoutInSeconds) (\s :: CanaryRunConfigInput
s@CanaryRunConfigInput' {} Maybe Natural
a -> CanaryRunConfigInput
s {$sel:timeoutInSeconds:CanaryRunConfigInput' :: Maybe Natural
timeoutInSeconds = Maybe Natural
a} :: CanaryRunConfigInput)

-- | Specifies the keys and values to use for any environment variables used
-- in the canary script. Use the following format:
--
-- { \"key1\" : \"value1\", \"key2\" : \"value2\", ...}
--
-- Keys must start with a letter and be at least two characters. The total
-- size of your environment variables cannot exceed 4 KB. You can\'t
-- specify any Lambda reserved environment variables as the keys for your
-- environment variables. For more information about reserved keys, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime Runtime environment variables>.
canaryRunConfigInput_environmentVariables :: Lens.Lens' CanaryRunConfigInput (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
canaryRunConfigInput_environmentVariables :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CanaryRunConfigInput -> f CanaryRunConfigInput
canaryRunConfigInput_environmentVariables = (CanaryRunConfigInput -> Maybe (HashMap Text Text))
-> (CanaryRunConfigInput
    -> Maybe (HashMap Text Text) -> CanaryRunConfigInput)
-> Lens
     CanaryRunConfigInput
     CanaryRunConfigInput
     (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 (\CanaryRunConfigInput' {Maybe (HashMap Text Text)
environmentVariables :: Maybe (HashMap Text Text)
$sel:environmentVariables:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe (HashMap Text Text)
environmentVariables} -> Maybe (HashMap Text Text)
environmentVariables) (\s :: CanaryRunConfigInput
s@CanaryRunConfigInput' {} Maybe (HashMap Text Text)
a -> CanaryRunConfigInput
s {$sel:environmentVariables:CanaryRunConfigInput' :: Maybe (HashMap Text Text)
environmentVariables = Maybe (HashMap Text Text)
a} :: CanaryRunConfigInput) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CanaryRunConfigInput -> f CanaryRunConfigInput)
-> ((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)))
-> CanaryRunConfigInput
-> f CanaryRunConfigInput
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

-- | Specifies whether this canary is to use active X-Ray tracing when it
-- runs. Active tracing enables this canary run to be displayed in the
-- ServiceLens and X-Ray service maps even if the canary does not hit an
-- endpoint that has X-Ray tracing enabled. Using X-Ray tracing incurs
-- charges. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_tracing.html Canaries and X-Ray tracing>.
--
-- You can enable active tracing only for canaries that use version
-- @syn-nodejs-2.0@ or later for their canary runtime.
canaryRunConfigInput_activeTracing :: Lens.Lens' CanaryRunConfigInput (Prelude.Maybe Prelude.Bool)
canaryRunConfigInput_activeTracing :: (Maybe Bool -> f (Maybe Bool))
-> CanaryRunConfigInput -> f CanaryRunConfigInput
canaryRunConfigInput_activeTracing = (CanaryRunConfigInput -> Maybe Bool)
-> (CanaryRunConfigInput -> Maybe Bool -> CanaryRunConfigInput)
-> Lens
     CanaryRunConfigInput CanaryRunConfigInput (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanaryRunConfigInput' {Maybe Bool
activeTracing :: Maybe Bool
$sel:activeTracing:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Bool
activeTracing} -> Maybe Bool
activeTracing) (\s :: CanaryRunConfigInput
s@CanaryRunConfigInput' {} Maybe Bool
a -> CanaryRunConfigInput
s {$sel:activeTracing:CanaryRunConfigInput' :: Maybe Bool
activeTracing = Maybe Bool
a} :: CanaryRunConfigInput)

-- | The maximum amount of memory available to the canary while it is
-- running, in MB. This value must be a multiple of 64.
canaryRunConfigInput_memoryInMB :: Lens.Lens' CanaryRunConfigInput (Prelude.Maybe Prelude.Natural)
canaryRunConfigInput_memoryInMB :: (Maybe Natural -> f (Maybe Natural))
-> CanaryRunConfigInput -> f CanaryRunConfigInput
canaryRunConfigInput_memoryInMB = (CanaryRunConfigInput -> Maybe Natural)
-> (CanaryRunConfigInput -> Maybe Natural -> CanaryRunConfigInput)
-> Lens
     CanaryRunConfigInput
     CanaryRunConfigInput
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanaryRunConfigInput' {Maybe Natural
memoryInMB :: Maybe Natural
$sel:memoryInMB:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Natural
memoryInMB} -> Maybe Natural
memoryInMB) (\s :: CanaryRunConfigInput
s@CanaryRunConfigInput' {} Maybe Natural
a -> CanaryRunConfigInput
s {$sel:memoryInMB:CanaryRunConfigInput' :: Maybe Natural
memoryInMB = Maybe Natural
a} :: CanaryRunConfigInput)

instance Prelude.Hashable CanaryRunConfigInput

instance Prelude.NFData CanaryRunConfigInput

instance Core.ToJSON CanaryRunConfigInput where
  toJSON :: CanaryRunConfigInput -> Value
toJSON CanaryRunConfigInput' {Maybe Bool
Maybe Natural
Maybe (HashMap Text Text)
memoryInMB :: Maybe Natural
activeTracing :: Maybe Bool
environmentVariables :: Maybe (HashMap Text Text)
timeoutInSeconds :: Maybe Natural
$sel:memoryInMB:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Natural
$sel:activeTracing:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Bool
$sel:environmentVariables:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe (HashMap Text Text)
$sel:timeoutInSeconds:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TimeoutInSeconds" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
timeoutInSeconds,
            (Text
"EnvironmentVariables" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
environmentVariables,
            (Text
"ActiveTracing" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
activeTracing,
            (Text
"MemoryInMB" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
memoryInMB
          ]
      )