{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Synthetics.Types.CanaryRunConfigInput 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

-- | A structure that contains input information for a canary run.
--
-- /See:/ 'newCanaryRunConfigInput' smart constructor.
data CanaryRunConfigInput = CanaryRunConfigInput'
  { -- | 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,
    -- | 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>.
    --
    -- The environment variables keys and values are not encrypted. Do not
    -- store sensitive information in this field.
    CanaryRunConfigInput -> Maybe (HashMap Text Text)
environmentVariables :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | 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,
    -- | 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
  }
  deriving (CanaryRunConfigInput -> CanaryRunConfigInput -> Bool
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]
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
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. 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:
--
-- '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.
--
-- '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>.
--
-- The environment variables keys and values are not encrypted. Do not
-- store sensitive information in this field.
--
-- '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.
--
-- '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.
newCanaryRunConfigInput ::
  CanaryRunConfigInput
newCanaryRunConfigInput :: CanaryRunConfigInput
newCanaryRunConfigInput =
  CanaryRunConfigInput'
    { $sel:activeTracing:CanaryRunConfigInput' :: Maybe Bool
activeTracing =
        forall a. Maybe a
Prelude.Nothing,
      $sel:environmentVariables:CanaryRunConfigInput' :: Maybe (HashMap Text Text)
environmentVariables = forall a. Maybe a
Prelude.Nothing,
      $sel:memoryInMB:CanaryRunConfigInput' :: Maybe Natural
memoryInMB = forall a. Maybe a
Prelude.Nothing,
      $sel:timeoutInSeconds:CanaryRunConfigInput' :: Maybe Natural
timeoutInSeconds = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' CanaryRunConfigInput (Maybe Bool)
canaryRunConfigInput_activeTracing = 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)

-- | 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>.
--
-- The environment variables keys and values are not encrypted. Do not
-- store sensitive information in this field.
canaryRunConfigInput_environmentVariables :: Lens.Lens' CanaryRunConfigInput (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
canaryRunConfigInput_environmentVariables :: Lens' CanaryRunConfigInput (Maybe (HashMap Text Text))
canaryRunConfigInput_environmentVariables = 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) 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 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 :: Lens' CanaryRunConfigInput (Maybe Natural)
canaryRunConfigInput_memoryInMB = 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)

-- | 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 :: Lens' CanaryRunConfigInput (Maybe Natural)
canaryRunConfigInput_timeoutInSeconds = 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)

instance Prelude.Hashable CanaryRunConfigInput where
  hashWithSalt :: Int -> CanaryRunConfigInput -> Int
hashWithSalt Int
_salt CanaryRunConfigInput' {Maybe Bool
Maybe Natural
Maybe (HashMap Text Text)
timeoutInSeconds :: Maybe Natural
memoryInMB :: Maybe Natural
environmentVariables :: Maybe (HashMap Text Text)
activeTracing :: Maybe Bool
$sel:timeoutInSeconds:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Natural
$sel:memoryInMB:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Natural
$sel:environmentVariables:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe (HashMap Text Text)
$sel:activeTracing:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
activeTracing
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
environmentVariables
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
memoryInMB
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
timeoutInSeconds

instance Prelude.NFData CanaryRunConfigInput where
  rnf :: CanaryRunConfigInput -> ()
rnf CanaryRunConfigInput' {Maybe Bool
Maybe Natural
Maybe (HashMap Text Text)
timeoutInSeconds :: Maybe Natural
memoryInMB :: Maybe Natural
environmentVariables :: Maybe (HashMap Text Text)
activeTracing :: Maybe Bool
$sel:timeoutInSeconds:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Natural
$sel:memoryInMB:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Natural
$sel:environmentVariables:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe (HashMap Text Text)
$sel:activeTracing:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
activeTracing
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
environmentVariables
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
memoryInMB
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
timeoutInSeconds

instance Data.ToJSON CanaryRunConfigInput where
  toJSON :: CanaryRunConfigInput -> Value
toJSON CanaryRunConfigInput' {Maybe Bool
Maybe Natural
Maybe (HashMap Text Text)
timeoutInSeconds :: Maybe Natural
memoryInMB :: Maybe Natural
environmentVariables :: Maybe (HashMap Text Text)
activeTracing :: Maybe Bool
$sel:timeoutInSeconds:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Natural
$sel:memoryInMB:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Natural
$sel:environmentVariables:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe (HashMap Text Text)
$sel:activeTracing:CanaryRunConfigInput' :: CanaryRunConfigInput -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ActiveTracing" 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 Bool
activeTracing,
            (Key
"EnvironmentVariables" 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 (HashMap Text Text)
environmentVariables,
            (Key
"MemoryInMB" 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 Natural
memoryInMB,
            (Key
"TimeoutInSeconds" 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 Natural
timeoutInSeconds
          ]
      )