{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CodeDeploy.Types.RawString 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 revision for an Lambda deployment that is a YAML-formatted or
-- JSON-formatted string. For 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
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]
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
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. 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'
    { $sel:content:RawString' :: Maybe Text
content = forall a. Maybe a
Prelude.Nothing,
      $sel:sha256:RawString' :: Maybe Text
sha256 = 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 :: Lens' RawString (Maybe Text)
rawString_content = 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 :: Lens' RawString (Maybe Text)
rawString_sha256 = 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 Data.FromJSON RawString where
  parseJSON :: Value -> Parser RawString
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RawString"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> RawString
RawString'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"content")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"sha256")
      )

instance Prelude.Hashable RawString where
  hashWithSalt :: Int -> RawString -> Int
hashWithSalt Int
_salt RawString' {Maybe Text
sha256 :: Maybe Text
content :: Maybe Text
$sel:sha256:RawString' :: RawString -> Maybe Text
$sel:content:RawString' :: RawString -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
content
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sha256

instance Prelude.NFData RawString where
  rnf :: RawString -> ()
rnf RawString' {Maybe Text
sha256 :: Maybe Text
content :: Maybe Text
$sel:sha256:RawString' :: RawString -> Maybe Text
$sel:content:RawString' :: RawString -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
content
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sha256

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"content" 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 Text
content,
            (Key
"sha256" 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 Text
sha256
          ]
      )