{-# 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.CodeDeploy.Types.RawString
-- 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.CodeDeploy.Types.RawString where

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

-- | A revision for an AWS Lambda deployment that is a YAML-formatted or
-- JSON-formatted string. For AWS Lambda deployments, the revision is the
-- same as the AppSpec file.
--
-- /See:/ 'newRawString' smart constructor.
data RawString = RawString'
  { -- | The YAML-formatted or JSON-formatted revision string. It includes
    -- information about which Lambda function to update and optional Lambda
    -- functions that validate deployment lifecycle events.
    RawString -> Maybe Text
content :: Prelude.Maybe Prelude.Text,
    -- | The SHA256 hash value of the revision content.
    RawString -> Maybe Text
sha256 :: Prelude.Maybe Prelude.Text
  }
  deriving (RawString -> RawString -> Bool
(RawString -> RawString -> Bool)
-> (RawString -> RawString -> Bool) -> Eq RawString
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RawString -> RawString -> Bool
$c/= :: RawString -> RawString -> Bool
== :: RawString -> RawString -> Bool
$c== :: RawString -> RawString -> Bool
Prelude.Eq, ReadPrec [RawString]
ReadPrec RawString
Int -> ReadS RawString
ReadS [RawString]
(Int -> ReadS RawString)
-> ReadS [RawString]
-> ReadPrec RawString
-> ReadPrec [RawString]
-> Read RawString
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RawString]
$creadListPrec :: ReadPrec [RawString]
readPrec :: ReadPrec RawString
$creadPrec :: ReadPrec RawString
readList :: ReadS [RawString]
$creadList :: ReadS [RawString]
readsPrec :: Int -> ReadS RawString
$creadsPrec :: Int -> ReadS RawString
Prelude.Read, Int -> RawString -> ShowS
[RawString] -> ShowS
RawString -> String
(Int -> RawString -> ShowS)
-> (RawString -> String)
-> ([RawString] -> ShowS)
-> Show RawString
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RawString] -> ShowS
$cshowList :: [RawString] -> ShowS
show :: RawString -> String
$cshow :: RawString -> String
showsPrec :: Int -> RawString -> ShowS
$cshowsPrec :: Int -> RawString -> ShowS
Prelude.Show, (forall x. RawString -> Rep RawString x)
-> (forall x. Rep RawString x -> RawString) -> Generic RawString
forall x. Rep RawString x -> RawString
forall x. RawString -> Rep RawString x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RawString x -> RawString
$cfrom :: forall x. RawString -> Rep RawString x
Prelude.Generic)

-- |
-- Create a value of 'RawString' 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:
--
-- 'content', 'rawString_content' - The YAML-formatted or JSON-formatted revision string. It includes
-- information about which Lambda function to update and optional Lambda
-- functions that validate deployment lifecycle events.
--
-- 'sha256', 'rawString_sha256' - The SHA256 hash value of the revision content.
newRawString ::
  RawString
newRawString :: RawString
newRawString =
  RawString' :: Maybe Text -> Maybe Text -> RawString
RawString'
    { $sel:content:RawString' :: Maybe Text
content = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sha256:RawString' :: Maybe Text
sha256 = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The YAML-formatted or JSON-formatted revision string. It includes
-- information about which Lambda function to update and optional Lambda
-- functions that validate deployment lifecycle events.
rawString_content :: Lens.Lens' RawString (Prelude.Maybe Prelude.Text)
rawString_content :: (Maybe Text -> f (Maybe Text)) -> RawString -> f RawString
rawString_content = (RawString -> Maybe Text)
-> (RawString -> Maybe Text -> RawString)
-> Lens RawString RawString (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RawString' {Maybe Text
content :: Maybe Text
$sel:content:RawString' :: RawString -> Maybe Text
content} -> Maybe Text
content) (\s :: RawString
s@RawString' {} Maybe Text
a -> RawString
s {$sel:content:RawString' :: Maybe Text
content = Maybe Text
a} :: RawString)

-- | The SHA256 hash value of the revision content.
rawString_sha256 :: Lens.Lens' RawString (Prelude.Maybe Prelude.Text)
rawString_sha256 :: (Maybe Text -> f (Maybe Text)) -> RawString -> f RawString
rawString_sha256 = (RawString -> Maybe Text)
-> (RawString -> Maybe Text -> RawString)
-> Lens RawString RawString (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RawString' {Maybe Text
sha256 :: Maybe Text
$sel:sha256:RawString' :: RawString -> Maybe Text
sha256} -> Maybe Text
sha256) (\s :: RawString
s@RawString' {} Maybe Text
a -> RawString
s {$sel:sha256:RawString' :: Maybe Text
sha256 = Maybe Text
a} :: RawString)

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

instance Prelude.Hashable RawString

instance Prelude.NFData RawString

instance Core.ToJSON RawString where
  toJSON :: RawString -> Value
toJSON RawString' {Maybe Text
sha256 :: Maybe Text
content :: Maybe Text
$sel:sha256:RawString' :: RawString -> Maybe Text
$sel:content:RawString' :: RawString -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"content" 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
content,
            (Text
"sha256" 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
sha256
          ]
      )