{-# 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.CanaryCodeOutput
-- 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.CanaryCodeOutput where

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

-- | This structure contains information about the canary\'s Lambda handler
-- and where its code is stored by CloudWatch Synthetics.
--
-- /See:/ 'newCanaryCodeOutput' smart constructor.
data CanaryCodeOutput = CanaryCodeOutput'
  { -- | The ARN of the Lambda layer where Synthetics stores the canary script
    -- code.
    CanaryCodeOutput -> Maybe Text
sourceLocationArn :: Prelude.Maybe Prelude.Text,
    -- | The entry point to use for the source code when running the canary.
    CanaryCodeOutput -> Maybe Text
handler :: Prelude.Maybe Prelude.Text
  }
  deriving (CanaryCodeOutput -> CanaryCodeOutput -> Bool
(CanaryCodeOutput -> CanaryCodeOutput -> Bool)
-> (CanaryCodeOutput -> CanaryCodeOutput -> Bool)
-> Eq CanaryCodeOutput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CanaryCodeOutput -> CanaryCodeOutput -> Bool
$c/= :: CanaryCodeOutput -> CanaryCodeOutput -> Bool
== :: CanaryCodeOutput -> CanaryCodeOutput -> Bool
$c== :: CanaryCodeOutput -> CanaryCodeOutput -> Bool
Prelude.Eq, ReadPrec [CanaryCodeOutput]
ReadPrec CanaryCodeOutput
Int -> ReadS CanaryCodeOutput
ReadS [CanaryCodeOutput]
(Int -> ReadS CanaryCodeOutput)
-> ReadS [CanaryCodeOutput]
-> ReadPrec CanaryCodeOutput
-> ReadPrec [CanaryCodeOutput]
-> Read CanaryCodeOutput
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CanaryCodeOutput]
$creadListPrec :: ReadPrec [CanaryCodeOutput]
readPrec :: ReadPrec CanaryCodeOutput
$creadPrec :: ReadPrec CanaryCodeOutput
readList :: ReadS [CanaryCodeOutput]
$creadList :: ReadS [CanaryCodeOutput]
readsPrec :: Int -> ReadS CanaryCodeOutput
$creadsPrec :: Int -> ReadS CanaryCodeOutput
Prelude.Read, Int -> CanaryCodeOutput -> ShowS
[CanaryCodeOutput] -> ShowS
CanaryCodeOutput -> String
(Int -> CanaryCodeOutput -> ShowS)
-> (CanaryCodeOutput -> String)
-> ([CanaryCodeOutput] -> ShowS)
-> Show CanaryCodeOutput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CanaryCodeOutput] -> ShowS
$cshowList :: [CanaryCodeOutput] -> ShowS
show :: CanaryCodeOutput -> String
$cshow :: CanaryCodeOutput -> String
showsPrec :: Int -> CanaryCodeOutput -> ShowS
$cshowsPrec :: Int -> CanaryCodeOutput -> ShowS
Prelude.Show, (forall x. CanaryCodeOutput -> Rep CanaryCodeOutput x)
-> (forall x. Rep CanaryCodeOutput x -> CanaryCodeOutput)
-> Generic CanaryCodeOutput
forall x. Rep CanaryCodeOutput x -> CanaryCodeOutput
forall x. CanaryCodeOutput -> Rep CanaryCodeOutput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CanaryCodeOutput x -> CanaryCodeOutput
$cfrom :: forall x. CanaryCodeOutput -> Rep CanaryCodeOutput x
Prelude.Generic)

-- |
-- Create a value of 'CanaryCodeOutput' 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:
--
-- 'sourceLocationArn', 'canaryCodeOutput_sourceLocationArn' - The ARN of the Lambda layer where Synthetics stores the canary script
-- code.
--
-- 'handler', 'canaryCodeOutput_handler' - The entry point to use for the source code when running the canary.
newCanaryCodeOutput ::
  CanaryCodeOutput
newCanaryCodeOutput :: CanaryCodeOutput
newCanaryCodeOutput =
  CanaryCodeOutput' :: Maybe Text -> Maybe Text -> CanaryCodeOutput
CanaryCodeOutput'
    { $sel:sourceLocationArn:CanaryCodeOutput' :: Maybe Text
sourceLocationArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:handler:CanaryCodeOutput' :: Maybe Text
handler = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the Lambda layer where Synthetics stores the canary script
-- code.
canaryCodeOutput_sourceLocationArn :: Lens.Lens' CanaryCodeOutput (Prelude.Maybe Prelude.Text)
canaryCodeOutput_sourceLocationArn :: (Maybe Text -> f (Maybe Text))
-> CanaryCodeOutput -> f CanaryCodeOutput
canaryCodeOutput_sourceLocationArn = (CanaryCodeOutput -> Maybe Text)
-> (CanaryCodeOutput -> Maybe Text -> CanaryCodeOutput)
-> Lens CanaryCodeOutput CanaryCodeOutput (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanaryCodeOutput' {Maybe Text
sourceLocationArn :: Maybe Text
$sel:sourceLocationArn:CanaryCodeOutput' :: CanaryCodeOutput -> Maybe Text
sourceLocationArn} -> Maybe Text
sourceLocationArn) (\s :: CanaryCodeOutput
s@CanaryCodeOutput' {} Maybe Text
a -> CanaryCodeOutput
s {$sel:sourceLocationArn:CanaryCodeOutput' :: Maybe Text
sourceLocationArn = Maybe Text
a} :: CanaryCodeOutput)

-- | The entry point to use for the source code when running the canary.
canaryCodeOutput_handler :: Lens.Lens' CanaryCodeOutput (Prelude.Maybe Prelude.Text)
canaryCodeOutput_handler :: (Maybe Text -> f (Maybe Text))
-> CanaryCodeOutput -> f CanaryCodeOutput
canaryCodeOutput_handler = (CanaryCodeOutput -> Maybe Text)
-> (CanaryCodeOutput -> Maybe Text -> CanaryCodeOutput)
-> Lens CanaryCodeOutput CanaryCodeOutput (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanaryCodeOutput' {Maybe Text
handler :: Maybe Text
$sel:handler:CanaryCodeOutput' :: CanaryCodeOutput -> Maybe Text
handler} -> Maybe Text
handler) (\s :: CanaryCodeOutput
s@CanaryCodeOutput' {} Maybe Text
a -> CanaryCodeOutput
s {$sel:handler:CanaryCodeOutput' :: Maybe Text
handler = Maybe Text
a} :: CanaryCodeOutput)

instance Core.FromJSON CanaryCodeOutput where
  parseJSON :: Value -> Parser CanaryCodeOutput
parseJSON =
    String
-> (Object -> Parser CanaryCodeOutput)
-> Value
-> Parser CanaryCodeOutput
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CanaryCodeOutput"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> CanaryCodeOutput
CanaryCodeOutput'
            (Maybe Text -> Maybe Text -> CanaryCodeOutput)
-> Parser (Maybe Text) -> Parser (Maybe Text -> CanaryCodeOutput)
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
"SourceLocationArn")
            Parser (Maybe Text -> CanaryCodeOutput)
-> Parser (Maybe Text) -> Parser CanaryCodeOutput
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
"Handler")
      )

instance Prelude.Hashable CanaryCodeOutput

instance Prelude.NFData CanaryCodeOutput